@microsoft/teams-js 2.0.0-beta.6-dev.7 → 2.0.0-beta.6-dev.10

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.
@@ -1122,7 +1122,7 @@ __webpack_require__.d(__webpack_exports__, {
1122
1122
  });
1123
1123
 
1124
1124
  ;// CONCATENATED MODULE: ./src/internal/constants.ts
1125
- var version = "2.0.0-beta.6-dev.7";
1125
+ var version = "2.0.0-beta.6-dev.10";
1126
1126
  /**
1127
1127
  * @hidden
1128
1128
  * The client version when all SDK APIs started to check platform compatibility for the APIs was 1.6.0.
@@ -2366,7 +2366,6 @@ var runtime = {
2366
2366
  location: undefined,
2367
2367
  logs: undefined,
2368
2368
  mail: undefined,
2369
- media: undefined,
2370
2369
  meetingRoom: undefined,
2371
2370
  menus: undefined,
2372
2371
  monetization: undefined,
@@ -2404,7 +2403,6 @@ var teamsRuntimeConfig = {
2404
2403
  update: {},
2405
2404
  },
2406
2405
  logs: {},
2407
- media: {},
2408
2406
  meetingRoom: {},
2409
2407
  menus: {},
2410
2408
  monetization: {},
@@ -2493,6 +2491,29 @@ function generateBackCompatRuntimeConfig(highestSupportedVersion) {
2493
2491
  function applyRuntimeConfig(runtimeConfig) {
2494
2492
  runtime = deepFreeze(runtimeConfig);
2495
2493
  }
2494
+ /**
2495
+ * @hidden
2496
+ * Hide from docs.
2497
+ * ------
2498
+ * Constant used to set minimum runtime configuration
2499
+ * while un-initializing an app in unit test case.
2500
+ *
2501
+ * @internal
2502
+ */
2503
+ var _minRuntimeConfigToUninitialize = {
2504
+ apiVersion: 1,
2505
+ supports: {
2506
+ pages: {
2507
+ appButton: {},
2508
+ tabs: {},
2509
+ config: {},
2510
+ backStack: {},
2511
+ fullTrust: {},
2512
+ },
2513
+ teamsCore: {},
2514
+ logs: {},
2515
+ },
2516
+ };
2496
2517
 
2497
2518
  ;// CONCATENATED MODULE: ./src/public/dialog.ts
2498
2519
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
@@ -4329,6 +4350,7 @@ function createMessageEvent(func, args) {
4329
4350
 
4330
4351
 
4331
4352
 
4353
+
4332
4354
  /**
4333
4355
  * @hidden
4334
4356
  * Namespace to interact with the logging part of the SDK.
@@ -4350,6 +4372,9 @@ var logs;
4350
4372
  */
4351
4373
  function registerGetLogHandler(handler) {
4352
4374
  ensureInitialized();
4375
+ if (!isSupported()) {
4376
+ throw errorNotSupportedOnPlatform;
4377
+ }
4353
4378
  if (handler) {
4354
4379
  registerHandler('log.request', function () {
4355
4380
  var log = handler();
@@ -5006,9 +5031,9 @@ var __extends = (undefined && undefined.__extends) || (function () {
5006
5031
 
5007
5032
 
5008
5033
 
5009
-
5010
5034
  /**
5011
- * @alpha
5035
+ * @deprecated
5036
+ * As of 2.0.0-beta.6, use media only for backwards compatibility of existing code.
5012
5037
  */
5013
5038
  var media;
5014
5039
  (function (media) {
@@ -5029,20 +5054,35 @@ var media;
5029
5054
  return File;
5030
5055
  }());
5031
5056
  media.File = File;
5057
+ /**
5058
+ * @deprecated
5059
+ * As of 2.0.0-beta.6, use only for backwards compatibility of existing code.
5060
+ *
5061
+ * Launch camera, capture image or choose image from gallery and return the images as a File[] object to the callback.
5062
+ *
5063
+ * @params callback - Callback will be called with an @see SdkError if there are any.
5064
+ * If error is null or undefined, the callback will be called with a collection of @see File objects
5065
+ * @remarks
5066
+ * Note: Currently we support getting one File through this API, i.e. the file arrays size will be one.
5067
+ * Note: For desktop, this API is not supported. Callback will be resolved with ErrorCode.NotSupported.
5068
+ *
5069
+ */
5032
5070
  function captureImage(callback) {
5071
+ if (!callback) {
5072
+ throw new Error('[captureImage] Callback cannot be null');
5073
+ }
5033
5074
  ensureInitialized(FrameContexts.content, FrameContexts.task);
5034
- var wrappedFunction = function () {
5035
- return new Promise(function (resolve) {
5036
- if (!GlobalVars.isFramelessWindow) {
5037
- throw { errorCode: ErrorCode.NOT_SUPPORTED_ON_PLATFORM };
5038
- }
5039
- if (!isCurrentSDKVersionAtLeast(captureImageMobileSupportVersion)) {
5040
- throw { errorCode: ErrorCode.OLD_PLATFORM };
5041
- }
5042
- resolve(sendAndHandleSdkError('captureImage'));
5043
- });
5044
- };
5045
- return callCallbackWithErrorOrResultFromPromiseAndReturnPromise(wrappedFunction, callback);
5075
+ if (!GlobalVars.isFramelessWindow) {
5076
+ var notSupportedError = { errorCode: ErrorCode.NOT_SUPPORTED_ON_PLATFORM };
5077
+ callback(notSupportedError, undefined);
5078
+ return;
5079
+ }
5080
+ if (!isCurrentSDKVersionAtLeast(captureImageMobileSupportVersion)) {
5081
+ var oldPlatformError = { errorCode: ErrorCode.OLD_PLATFORM };
5082
+ callback(oldPlatformError, undefined);
5083
+ return;
5084
+ }
5085
+ sendMessageToParent('captureImage', callback);
5046
5086
  }
5047
5087
  media.captureImage = captureImage;
5048
5088
  /**
@@ -5063,95 +5103,105 @@ var media;
5063
5103
  }
5064
5104
  return _this;
5065
5105
  }
5106
+ /**
5107
+ * Gets the media in chunks irrespective of size, these chunks are assembled and sent back to the webapp as file/blob
5108
+ * @param callback - callback is called with the @see SdkError if there is an error
5109
+ * If error is null or undefined, the callback will be called with @see Blob.
5110
+ */
5066
5111
  Media.prototype.getMedia = function (callback) {
5067
- var _this = this;
5112
+ if (!callback) {
5113
+ throw new Error('[get Media] Callback cannot be null');
5114
+ }
5068
5115
  ensureInitialized(FrameContexts.content, FrameContexts.task);
5069
- var wrappedFunction = function () {
5070
- return new Promise(function (resolve) {
5071
- if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
5072
- throw { errorCode: ErrorCode.OLD_PLATFORM };
5073
- }
5074
- if (!validateGetMediaInputs(_this.mimeType, _this.format, _this.content)) {
5075
- throw { errorCode: ErrorCode.INVALID_ARGUMENTS };
5076
- }
5077
- // Call the new get media implementation via callbacks if the client version is greater than or equal to '2.0.0'
5078
- if (isCurrentSDKVersionAtLeast(getMediaCallbackSupportVersion)) {
5079
- resolve(_this.getMediaViaCallback());
5080
- }
5081
- else {
5082
- resolve(_this.getMediaViaHandler());
5083
- }
5084
- });
5085
- };
5086
- return callCallbackWithErrorOrResultFromPromiseAndReturnPromise(wrappedFunction, callback);
5116
+ if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
5117
+ var oldPlatformError = { errorCode: ErrorCode.OLD_PLATFORM };
5118
+ callback(oldPlatformError, null);
5119
+ return;
5120
+ }
5121
+ if (!validateGetMediaInputs(this.mimeType, this.format, this.content)) {
5122
+ var invalidInput = { errorCode: ErrorCode.INVALID_ARGUMENTS };
5123
+ callback(invalidInput, null);
5124
+ return;
5125
+ }
5126
+ // Call the new get media implementation via callbacks if the client version is greater than or equal to '2.0.0'
5127
+ if (isCurrentSDKVersionAtLeast(getMediaCallbackSupportVersion)) {
5128
+ this.getMediaViaCallback(callback);
5129
+ }
5130
+ else {
5131
+ this.getMediaViaHandler(callback);
5132
+ }
5087
5133
  };
5088
- Media.prototype.getMediaViaCallback = function () {
5089
- var _this = this;
5090
- return new Promise(function (resolve, reject) {
5091
- var helper = {
5092
- mediaMimeType: _this.mimeType,
5093
- assembleAttachment: [],
5094
- };
5095
- var localUriId = [_this.content];
5096
- sendMessageToParent('getMedia', localUriId, function (mediaResult) {
5134
+ Media.prototype.getMediaViaCallback = function (callback) {
5135
+ var helper = {
5136
+ mediaMimeType: this.mimeType,
5137
+ assembleAttachment: [],
5138
+ };
5139
+ var localUriId = [this.content];
5140
+ function handleGetMediaCallbackRequest(mediaResult) {
5141
+ if (callback) {
5097
5142
  if (mediaResult && mediaResult.error) {
5098
- reject(mediaResult.error);
5099
- }
5100
- else if (!mediaResult || !mediaResult.mediaChunk) {
5101
- reject({ errorCode: ErrorCode.INTERNAL_ERROR, message: 'data received is null' });
5102
- }
5103
- else if (mediaResult.mediaChunk.chunkSequence <= 0) {
5104
- var file = createFile(helper.assembleAttachment, helper.mediaMimeType);
5105
- resolve(file);
5143
+ callback(mediaResult.error, null);
5106
5144
  }
5107
5145
  else {
5108
- // Keep pushing chunks into assemble attachment
5109
- var assemble = decodeAttachment(mediaResult.mediaChunk, helper.mediaMimeType);
5110
- helper.assembleAttachment.push(assemble);
5111
- }
5112
- });
5113
- });
5114
- };
5115
- Media.prototype.getMediaViaHandler = function () {
5116
- var _this = this;
5117
- return new Promise(function (resolve, reject) {
5118
- var actionName = generateGUID();
5119
- var helper = {
5120
- mediaMimeType: _this.mimeType,
5121
- assembleAttachment: [],
5122
- };
5123
- var params = [actionName, _this.content];
5124
- _this.content && sendMessageToParent('getMedia', params);
5125
- registerHandler('getMedia' + actionName, function (response) {
5126
- try {
5127
- var mediaResult = JSON.parse(response);
5128
- if (mediaResult.error) {
5129
- reject(mediaResult.error);
5130
- removeHandler('getMedia' + actionName);
5146
+ if (mediaResult && mediaResult.mediaChunk) {
5147
+ // If the chunksequence number is less than equal to 0 implies EOF
5148
+ // create file/blob when all chunks have arrived and we get 0/-1 as chunksequence number
5149
+ if (mediaResult.mediaChunk.chunkSequence <= 0) {
5150
+ var file = createFile(helper.assembleAttachment, helper.mediaMimeType);
5151
+ callback(mediaResult.error, file);
5152
+ }
5153
+ else {
5154
+ // Keep pushing chunks into assemble attachment
5155
+ var assemble = decodeAttachment(mediaResult.mediaChunk, helper.mediaMimeType);
5156
+ helper.assembleAttachment.push(assemble);
5157
+ }
5131
5158
  }
5132
- else if (!mediaResult || !mediaResult.mediaChunk) {
5133
- reject({ errorCode: ErrorCode.INTERNAL_ERROR, message: 'data received is null' });
5134
- removeHandler('getMedia' + actionName);
5159
+ else {
5160
+ callback({ errorCode: ErrorCode.INTERNAL_ERROR, message: 'data received is null' }, null);
5135
5161
  }
5136
- else if (mediaResult.mediaChunk.chunkSequence <= 0) {
5162
+ }
5163
+ }
5164
+ }
5165
+ sendMessageToParent('getMedia', localUriId, handleGetMediaCallbackRequest);
5166
+ };
5167
+ Media.prototype.getMediaViaHandler = function (callback) {
5168
+ var actionName = generateGUID();
5169
+ var helper = {
5170
+ mediaMimeType: this.mimeType,
5171
+ assembleAttachment: [],
5172
+ };
5173
+ var params = [actionName, this.content];
5174
+ this.content && callback && sendMessageToParent('getMedia', params);
5175
+ function handleGetMediaRequest(response) {
5176
+ if (callback) {
5177
+ var mediaResult = JSON.parse(response);
5178
+ if (mediaResult.error) {
5179
+ callback(mediaResult.error, null);
5180
+ removeHandler('getMedia' + actionName);
5181
+ }
5182
+ else {
5183
+ if (mediaResult.mediaChunk) {
5137
5184
  // If the chunksequence number is less than equal to 0 implies EOF
5138
5185
  // create file/blob when all chunks have arrived and we get 0/-1 as chunksequence number
5139
- var file = createFile(helper.assembleAttachment, helper.mediaMimeType);
5140
- resolve(file);
5141
- removeHandler('getMedia' + actionName);
5186
+ if (mediaResult.mediaChunk.chunkSequence <= 0) {
5187
+ var file = createFile(helper.assembleAttachment, helper.mediaMimeType);
5188
+ callback(mediaResult.error, file);
5189
+ removeHandler('getMedia' + actionName);
5190
+ }
5191
+ else {
5192
+ // Keep pushing chunks into assemble attachment
5193
+ var assemble = decodeAttachment(mediaResult.mediaChunk, helper.mediaMimeType);
5194
+ helper.assembleAttachment.push(assemble);
5195
+ }
5142
5196
  }
5143
5197
  else {
5144
- // Keep pushing chunks into assemble attachment
5145
- var assemble = decodeAttachment(mediaResult.mediaChunk, helper.mediaMimeType);
5146
- helper.assembleAttachment.push(assemble);
5198
+ callback({ errorCode: ErrorCode.INTERNAL_ERROR, message: 'data received is null' }, null);
5199
+ removeHandler('getMedia' + actionName);
5147
5200
  }
5148
5201
  }
5149
- catch (err) {
5150
- // catch JSON.parse() errors
5151
- reject({ errorCode: ErrorCode.INTERNAL_ERROR, message: 'Error parsing the response: ' + response });
5152
- }
5153
- });
5154
- });
5202
+ }
5203
+ }
5204
+ registerHandler('getMedia' + actionName, handleGetMediaRequest);
5155
5205
  };
5156
5206
  return Media;
5157
5207
  }(File));
@@ -5166,26 +5216,38 @@ var media;
5166
5216
  function MediaController(controllerCallback) {
5167
5217
  this.controllerCallback = controllerCallback;
5168
5218
  }
5219
+ /**
5220
+ * @hidden
5221
+ * Hide from docs
5222
+ * --------
5223
+ * Function to notify the host client to programatically control the experience
5224
+ * @param mediaEvent indicates what the event that needs to be signaled to the host client
5225
+ * Optional; @param callback is used to send app if host client has successfully handled the notification event or not
5226
+ */
5169
5227
  MediaController.prototype.notifyEventToHost = function (mediaEvent, callback) {
5170
5228
  ensureInitialized(FrameContexts.content, FrameContexts.task);
5171
5229
  try {
5172
5230
  throwExceptionIfMobileApiIsNotSupported(nonFullScreenVideoModeAPISupportVersion);
5173
5231
  }
5174
5232
  catch (err) {
5175
- var wrappedRejectedErrorFn = function () { return Promise.reject(err); };
5176
- return callCallbackWithSdkErrorFromPromiseAndReturnPromise(wrappedRejectedErrorFn, callback);
5233
+ if (callback) {
5234
+ callback(err);
5235
+ }
5236
+ return;
5177
5237
  }
5178
- var params = {
5179
- mediaType: this.getMediaType(),
5180
- mediaControllerEvent: mediaEvent,
5181
- };
5182
- var wrappedFunction = function () {
5183
- return new Promise(function (resolve) { return resolve(sendAndHandleSdkError('media.controller', [params])); });
5184
- };
5185
- return callCallbackWithSdkErrorFromPromiseAndReturnPromise(wrappedFunction, callback);
5238
+ var params = { mediaType: this.getMediaType(), mediaControllerEvent: mediaEvent };
5239
+ sendMessageToParent('media.controller', [params], function (err) {
5240
+ if (callback) {
5241
+ callback(err);
5242
+ }
5243
+ });
5186
5244
  };
5245
+ /**
5246
+ * Function to programatically stop the ongoing media event
5247
+ * Optional; @param callback is used to send app if host client has successfully stopped the event or not
5248
+ */
5187
5249
  MediaController.prototype.stop = function (callback) {
5188
- return Promise.resolve(this.notifyEventToHost(MediaControllerEvent.StopRecording, callback));
5250
+ this.notifyEventToHost(MediaControllerEvent.StopRecording, callback);
5189
5251
  };
5190
5252
  return MediaController;
5191
5253
  }());
@@ -5201,14 +5263,16 @@ var media;
5201
5263
  return MediaType.Video;
5202
5264
  };
5203
5265
  VideoController.prototype.notifyEventToApp = function (mediaEvent) {
5266
+ if (!this.controllerCallback) {
5267
+ // Early return as app has not registered with the callback
5268
+ return;
5269
+ }
5204
5270
  switch (mediaEvent) {
5205
5271
  case MediaControllerEvent.StartRecording:
5206
- this.controllerCallback.onRecordingStarted();
5207
- break;
5208
- // TODO - Should discuss whether this function should be required
5209
- case MediaControllerEvent.StopRecording:
5210
- this.controllerCallback.onRecordingStopped && this.controllerCallback.onRecordingStopped();
5211
- break;
5272
+ if (this.controllerCallback.onRecordingStarted) {
5273
+ this.controllerCallback.onRecordingStarted();
5274
+ break;
5275
+ }
5212
5276
  }
5213
5277
  };
5214
5278
  return VideoController;
@@ -5269,109 +5333,128 @@ var media;
5269
5333
  ImageOutputFormats[ImageOutputFormats["IMAGE"] = 1] = "IMAGE";
5270
5334
  ImageOutputFormats[ImageOutputFormats["PDF"] = 2] = "PDF";
5271
5335
  })(ImageOutputFormats = media.ImageOutputFormats || (media.ImageOutputFormats = {}));
5336
+ /**
5337
+ * @deprecated
5338
+ * As of 2.0.0-beta.6, use only for backwards compatibility of existing code.
5339
+ *
5340
+ * Select an attachment using camera/gallery
5341
+ *
5342
+ * @param mediaInputs - The input params to customize the media to be selected
5343
+ * @param callback - The callback to invoke after fetching the media
5344
+ */
5272
5345
  function selectMedia(mediaInputs, callback) {
5346
+ if (!callback) {
5347
+ throw new Error('[select Media] Callback cannot be null');
5348
+ }
5273
5349
  ensureInitialized(FrameContexts.content, FrameContexts.task);
5274
- var wrappedFunction = function () {
5275
- return new Promise(function (resolve) {
5276
- if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
5277
- throw { errorCode: ErrorCode.OLD_PLATFORM };
5278
- }
5279
- throwExceptionIfMediaCallIsNotSupportedOnMobile(mediaInputs);
5280
- if (!validateSelectMediaInputs(mediaInputs)) {
5281
- throw { errorCode: ErrorCode.INVALID_ARGUMENTS };
5282
- }
5283
- var params = [mediaInputs];
5284
- // What comes back from native at attachments would just be objects and will be missing getMedia method on them.
5285
- resolve(sendMessageToParentAsync('selectMedia', params));
5286
- }).then(function (_a) {
5287
- var err = _a[0], localAttachments = _a[1], mediaEvent = _a[2];
5288
- // MediaControllerEvent response is used to notify the app about events and is a partial response to selectMedia
5289
- if (mediaEvent) {
5290
- if (isVideoControllerRegistered(mediaInputs)) {
5291
- mediaInputs.videoProps.videoController.notifyEventToApp(mediaEvent);
5292
- }
5293
- return [];
5294
- }
5295
- // Media Attachments are final response to selectMedia
5296
- if (!localAttachments) {
5297
- throw err;
5298
- }
5299
- var mediaArray = [];
5300
- for (var _i = 0, localAttachments_1 = localAttachments; _i < localAttachments_1.length; _i++) {
5301
- var attachment = localAttachments_1[_i];
5302
- mediaArray.push(new Media(attachment));
5350
+ if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
5351
+ var oldPlatformError = { errorCode: ErrorCode.OLD_PLATFORM };
5352
+ callback(oldPlatformError, null);
5353
+ return;
5354
+ }
5355
+ try {
5356
+ throwExceptionIfMediaCallIsNotSupportedOnMobile(mediaInputs);
5357
+ }
5358
+ catch (err) {
5359
+ callback(err, null);
5360
+ return;
5361
+ }
5362
+ if (!validateSelectMediaInputs(mediaInputs)) {
5363
+ var invalidInput = { errorCode: ErrorCode.INVALID_ARGUMENTS };
5364
+ callback(invalidInput, null);
5365
+ return;
5366
+ }
5367
+ var params = [mediaInputs];
5368
+ // What comes back from native as attachments would just be objects and will be missing getMedia method on them
5369
+ sendMessageToParent('selectMedia', params, function (err, localAttachments, mediaEvent) {
5370
+ // MediaControllerEvent response is used to notify the app about events and is a partial response to selectMedia
5371
+ if (mediaEvent) {
5372
+ if (isVideoControllerRegistered(mediaInputs)) {
5373
+ mediaInputs.videoProps.videoController.notifyEventToApp(mediaEvent);
5303
5374
  }
5304
- return mediaArray;
5305
- });
5306
- };
5307
- return callCallbackWithErrorOrResultFromPromiseAndReturnPromise(wrappedFunction, callback);
5375
+ return;
5376
+ }
5377
+ // Media Attachments are final response to selectMedia
5378
+ if (!localAttachments) {
5379
+ callback(err, null);
5380
+ return;
5381
+ }
5382
+ var mediaArray = [];
5383
+ for (var _i = 0, localAttachments_1 = localAttachments; _i < localAttachments_1.length; _i++) {
5384
+ var attachment = localAttachments_1[_i];
5385
+ mediaArray.push(new Media(attachment));
5386
+ }
5387
+ callback(err, mediaArray);
5388
+ });
5308
5389
  }
5309
5390
  media.selectMedia = selectMedia;
5391
+ /**
5392
+ * @deprecated
5393
+ * As of 2.0.0-beta.6, use only for backwards compatibility of existing code.
5394
+ *
5395
+ * View images using native image viewer
5396
+ * @param uriList - list of URIs for images to be viewed - can be content URI or server URL. Supports up to 10 Images in a single call
5397
+ * @param callback - returns back error if encountered, returns null in case of success
5398
+ */
5310
5399
  function viewImages(uriList, callback) {
5400
+ if (!callback) {
5401
+ throw new Error('[view images] Callback cannot be null');
5402
+ }
5311
5403
  ensureInitialized(FrameContexts.content, FrameContexts.task);
5312
- var wrappedFunction = function () {
5313
- return new Promise(function (resolve) {
5314
- if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
5315
- throw { errorCode: ErrorCode.OLD_PLATFORM };
5316
- }
5317
- if (!validateViewImagesInput(uriList)) {
5318
- throw { errorCode: ErrorCode.INVALID_ARGUMENTS };
5319
- }
5320
- resolve(sendAndHandleSdkError('viewImages', uriList));
5321
- });
5322
- };
5323
- return callCallbackWithSdkErrorFromPromiseAndReturnPromise(wrappedFunction, callback);
5404
+ if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
5405
+ var oldPlatformError = { errorCode: ErrorCode.OLD_PLATFORM };
5406
+ callback(oldPlatformError);
5407
+ return;
5408
+ }
5409
+ if (!validateViewImagesInput(uriList)) {
5410
+ var invalidInput = { errorCode: ErrorCode.INVALID_ARGUMENTS };
5411
+ callback(invalidInput);
5412
+ return;
5413
+ }
5414
+ var params = [uriList];
5415
+ sendMessageToParent('viewImages', params, callback);
5324
5416
  }
5325
5417
  media.viewImages = viewImages;
5326
- function scanBarCode(callbackOrConfig, configMaybe) {
5327
- var callback;
5328
- var config;
5329
- // Because the callback isn't the second parameter in the original v1 method we need to
5330
- // do a bit of trickery to see which of the two ways were used to call into
5331
- // the flow and if the first parameter is a callback (v1) or a config object (v2)
5332
- if (callbackOrConfig === undefined) {
5333
- // no first parameter - the second one might be a config, definitely no callback
5334
- config = configMaybe;
5335
- }
5336
- else {
5337
- if (typeof callbackOrConfig === 'object') {
5338
- // the first parameter is an object - it's the config! No callback.
5339
- config = callbackOrConfig;
5340
- }
5341
- else {
5342
- // otherwise, it's a function, so a callback. The second parameter might be a callback
5343
- callback = callbackOrConfig;
5344
- config = configMaybe;
5345
- }
5418
+ /**
5419
+ * @deprecated
5420
+ * As of 2.0.0-beta.6, use only for backwards compatibility of existing code.
5421
+ *
5422
+ * Scan Barcode/QRcode using camera
5423
+ * @remarks
5424
+ * Note: For desktop and web, this API is not supported. Callback will be resolved with ErrorCode.NotSupported.
5425
+ *
5426
+ * @param callback - callback to invoke after scanning the barcode
5427
+ * @param config - optional input configuration to customize the barcode scanning experience
5428
+ */
5429
+ function scanBarCode(callback, config) {
5430
+ if (!callback) {
5431
+ throw new Error('[media.scanBarCode] Callback cannot be null');
5346
5432
  }
5347
5433
  ensureInitialized(FrameContexts.content, FrameContexts.task);
5348
- var wrappedFunction = function () {
5349
- return new Promise(function (resolve) {
5350
- if (GlobalVars.hostClientType === HostClientType.desktop ||
5351
- GlobalVars.hostClientType === HostClientType.web ||
5352
- GlobalVars.hostClientType === HostClientType.rigel ||
5353
- GlobalVars.hostClientType === HostClientType.teamsRoomsWindows ||
5354
- GlobalVars.hostClientType === HostClientType.teamsRoomsAndroid ||
5355
- GlobalVars.hostClientType === HostClientType.teamsPhones ||
5356
- GlobalVars.hostClientType === HostClientType.teamsDisplays) {
5357
- throw { errorCode: ErrorCode.NOT_SUPPORTED_ON_PLATFORM };
5358
- }
5359
- if (!isCurrentSDKVersionAtLeast(scanBarCodeAPIMobileSupportVersion)) {
5360
- throw { errorCode: ErrorCode.OLD_PLATFORM };
5361
- }
5362
- if (!validateScanBarCodeInput(config)) {
5363
- throw { errorCode: ErrorCode.INVALID_ARGUMENTS };
5364
- }
5365
- resolve(sendAndHandleSdkError('media.scanBarCode', config));
5366
- });
5367
- };
5368
- return callCallbackWithErrorOrResultFromPromiseAndReturnPromise(wrappedFunction, callback);
5434
+ if (GlobalVars.hostClientType === HostClientType.desktop ||
5435
+ GlobalVars.hostClientType === HostClientType.web ||
5436
+ GlobalVars.hostClientType === HostClientType.rigel ||
5437
+ GlobalVars.hostClientType === HostClientType.teamsRoomsWindows ||
5438
+ GlobalVars.hostClientType === HostClientType.teamsRoomsAndroid ||
5439
+ GlobalVars.hostClientType === HostClientType.teamsPhones ||
5440
+ GlobalVars.hostClientType === HostClientType.teamsDisplays) {
5441
+ var notSupportedError = { errorCode: ErrorCode.NOT_SUPPORTED_ON_PLATFORM };
5442
+ callback(notSupportedError, null);
5443
+ return;
5444
+ }
5445
+ if (!isCurrentSDKVersionAtLeast(scanBarCodeAPIMobileSupportVersion)) {
5446
+ var oldPlatformError = { errorCode: ErrorCode.OLD_PLATFORM };
5447
+ callback(oldPlatformError, null);
5448
+ return;
5449
+ }
5450
+ if (!validateScanBarCodeInput(config)) {
5451
+ var invalidInput = { errorCode: ErrorCode.INVALID_ARGUMENTS };
5452
+ callback(invalidInput, null);
5453
+ return;
5454
+ }
5455
+ sendMessageToParent('media.scanBarCode', [config], callback);
5369
5456
  }
5370
5457
  media.scanBarCode = scanBarCode;
5371
- function isSupported() {
5372
- return runtime.supports.media ? true : false;
5373
- }
5374
- media.isSupported = isSupported;
5375
5458
  })(media || (media = {}));
5376
5459
 
5377
5460
  ;// CONCATENATED MODULE: ./src/public/location.ts