@microsoft/teams-js 2.0.0-beta.3-dev.13 → 2.0.0-beta.3-dev.14

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.
@@ -4280,6 +4280,20 @@ export namespace sharing {
4280
4280
  preview?: boolean;
4281
4281
  }
4282
4282
  /**
4283
+ * @hidden
4284
+ * Feature is under development
4285
+ * Opens a share dialog for web content
4286
+ *
4287
+ * @param shareWebContentRequest - web content info
4288
+ * @returns Promise that will be fulfilled when the operation has completed
4289
+ *
4290
+ * @internal
4291
+ */
4292
+ export function shareWebContent(shareWebContentRequest: IShareRequest<IShareRequestContentType>): Promise<void>;
4293
+ /**
4294
+ * @deprecated
4295
+ * As of 2.0.0-beta.3, please use {@link sharing.shareWebContent sharing.shareWebContent(shareWebContentRequest: IShareRequest\<IShareRequestContentType\>): Promise\<void\>} instead.
4296
+ *
4283
4297
  * @hidden
4284
4298
  * Feature is under development
4285
4299
  * Opens a share dialog for web content
@@ -4289,7 +4303,7 @@ export namespace sharing {
4289
4303
  *
4290
4304
  * @internal
4291
4305
  */
4292
- export function shareWebContent(shareWebContentRequest: IShareRequest<IShareRequestContentType>, callback?: (err?: SdkError) => void): void;
4306
+ export function shareWebContent(shareWebContentRequest: IShareRequest<IShareRequestContentType>, callback: (err?: SdkError) => void): void;
4293
4307
  export function isSupported(): boolean;
4294
4308
  export {};
4295
4309
  }
@@ -395,7 +395,7 @@ __webpack_require__.d(__webpack_exports__, {
395
395
  });
396
396
 
397
397
  ;// CONCATENATED MODULE: ./src/internal/constants.ts
398
- var version = '2.0.0-beta.3-dev.13';
398
+ var version = '2.0.0-beta.3-dev.14';
399
399
  /**
400
400
  * @hidden
401
401
  * The SDK version when all SDK APIs started to check platform compatibility for the APIs was 1.6.0.
@@ -4550,6 +4550,7 @@ var video;
4550
4550
 
4551
4551
 
4552
4552
 
4553
+
4553
4554
  /**
4554
4555
  * @alpha
4555
4556
  */
@@ -4558,88 +4559,74 @@ var sharing;
4558
4559
  sharing.SharingAPIMessages = {
4559
4560
  shareWebContent: 'sharing.shareWebContent',
4560
4561
  };
4561
- /**
4562
- * @hidden
4563
- * Feature is under development
4564
- * Opens a share dialog for web content
4565
- *
4566
- * @param shareWebContentRequest - web content info
4567
- * @param callback - optional callback
4568
- *
4569
- * @internal
4570
- */
4571
4562
  function shareWebContent(shareWebContentRequest, callback) {
4572
- if (!validateNonEmptyContent(shareWebContentRequest, callback)) {
4573
- return;
4574
- }
4575
- if (!validateTypeConsistency(shareWebContentRequest, callback)) {
4576
- return;
4563
+ // validate the given input (synchronous check)
4564
+ try {
4565
+ validateNonEmptyContent(shareWebContentRequest);
4566
+ validateTypeConsistency(shareWebContentRequest);
4567
+ validateContentForSupportedTypes(shareWebContentRequest);
4577
4568
  }
4578
- if (!validateContentForSupportedTypes(shareWebContentRequest, callback)) {
4579
- return;
4569
+ catch (err) {
4570
+ //return the error via callback(v1) or rejected promise(v2)
4571
+ var wrappedFunction = function () { return Promise.reject(err); };
4572
+ return callCallbackWithSdkErrorFromPromiseAndReturnPromise(wrappedFunction, callback);
4580
4573
  }
4581
4574
  ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.stage, FrameContexts.meetingStage);
4582
- sendMessageToParent(sharing.SharingAPIMessages.shareWebContent, [shareWebContentRequest], callback);
4575
+ return callCallbackWithSdkErrorFromPromiseAndReturnPromise(shareWebContentHelper, callback, shareWebContentRequest);
4583
4576
  }
4584
4577
  sharing.shareWebContent = shareWebContent;
4578
+ function shareWebContentHelper(shareWebContentRequest) {
4579
+ return new Promise(function (resolve) {
4580
+ resolve(sendAndHandleSdkError(sharing.SharingAPIMessages.shareWebContent, shareWebContentRequest));
4581
+ });
4582
+ }
4585
4583
  /**
4586
- * Error checks
4584
+ * Functions for validating the shareRequest input parameter
4587
4585
  */
4588
- function validateNonEmptyContent(shareRequest, callback) {
4586
+ function validateNonEmptyContent(shareRequest) {
4589
4587
  if (!(shareRequest && shareRequest.content && shareRequest.content.length)) {
4590
- if (callback) {
4591
- callback({
4592
- errorCode: ErrorCode.INVALID_ARGUMENTS,
4593
- message: 'Shared content is missing',
4594
- });
4595
- }
4596
- return false;
4588
+ var err = {
4589
+ errorCode: ErrorCode.INVALID_ARGUMENTS,
4590
+ message: 'Shared content is missing',
4591
+ };
4592
+ throw err;
4597
4593
  }
4598
- return true;
4599
4594
  }
4600
- function validateTypeConsistency(shareRequest, callback) {
4595
+ function validateTypeConsistency(shareRequest) {
4596
+ var err;
4601
4597
  if (shareRequest.content.some(function (item) { return !item.type; })) {
4602
- if (callback) {
4603
- callback({
4604
- errorCode: ErrorCode.INVALID_ARGUMENTS,
4605
- message: 'Shared content type cannot be undefined',
4606
- });
4607
- }
4608
- return false;
4598
+ err = {
4599
+ errorCode: ErrorCode.INVALID_ARGUMENTS,
4600
+ message: 'Shared content type cannot be undefined',
4601
+ };
4602
+ throw err;
4609
4603
  }
4610
4604
  if (shareRequest.content.some(function (item) { return item.type !== shareRequest.content[0].type; })) {
4611
- if (callback) {
4612
- callback({
4613
- errorCode: ErrorCode.INVALID_ARGUMENTS,
4614
- message: 'Shared content must be of the same type',
4615
- });
4616
- }
4617
- return false;
4605
+ err = {
4606
+ errorCode: ErrorCode.INVALID_ARGUMENTS,
4607
+ message: 'Shared content must be of the same type',
4608
+ };
4609
+ throw err;
4618
4610
  }
4619
- return true;
4620
4611
  }
4621
- function validateContentForSupportedTypes(shareRequest, callback) {
4612
+ function validateContentForSupportedTypes(shareRequest) {
4613
+ var err;
4622
4614
  if (shareRequest.content[0].type === 'URL') {
4623
4615
  if (shareRequest.content.some(function (item) { return !item.url; })) {
4624
- if (callback) {
4625
- callback({
4626
- errorCode: ErrorCode.INVALID_ARGUMENTS,
4627
- message: 'URLs are required for URL content types',
4628
- });
4629
- }
4630
- return false;
4616
+ err = {
4617
+ errorCode: ErrorCode.INVALID_ARGUMENTS,
4618
+ message: 'URLs are required for URL content types',
4619
+ };
4620
+ throw err;
4631
4621
  }
4632
4622
  }
4633
4623
  else {
4634
- if (callback) {
4635
- callback({
4636
- errorCode: ErrorCode.INVALID_ARGUMENTS,
4637
- message: 'Content type is unsupported',
4638
- });
4639
- }
4640
- return false;
4624
+ err = {
4625
+ errorCode: ErrorCode.INVALID_ARGUMENTS,
4626
+ message: 'Content type is unsupported',
4627
+ };
4628
+ throw err;
4641
4629
  }
4642
- return true;
4643
4630
  }
4644
4631
  function isSupported() {
4645
4632
  return runtime.supports.sharing ? true : false;