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

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/README.md CHANGED
@@ -52,7 +52,7 @@ Reference the SDK inside of your `.html` page using:
52
52
  <!-- Microsoft Teams JavaScript API (via CDN) -->
53
53
  <script
54
54
  src="https://res.cdn.office.net/teams-js/2.0.0-beta.2/js/MicrosoftTeams.min.js"
55
- integrity="sha384-Q2Z9S56exI6Oz/ThvYaV0SUn8j4HwS8BveGPmuwLXe4CvCUEGlL80qSzHMnvGqee"
55
+ integrity="sha384-RhShpWwRxSnc+keX0WZxCsf8olaKOOw416Jky+StW6qhctsNR3GMwav/hMB1Snas"
56
56
  crossorigin="anonymous"
57
57
  ></script>
58
58
 
@@ -3970,6 +3970,21 @@ export namespace monetization {
3970
3970
  term: string;
3971
3971
  }
3972
3972
  /**
3973
+ * @hidden
3974
+ * Hide from docs
3975
+ * Open dialog to start user's purchase experience
3976
+ *
3977
+ * @param planInfo optional parameter. It contains info of the subscription plan pushed to users.
3978
+ * error can either contain an error of type SdkError, incase of an error, or null when get is successful
3979
+ * @returns Promise that will be resolved when the operation has completed or rejected with SdkError value
3980
+ *
3981
+ * @internal
3982
+ */
3983
+ function openPurchaseExperience(planInfo?: PlanInfo): Promise<void>;
3984
+ /**
3985
+ * @deprecated
3986
+ * As of 2.0.0-beta.3, please use {@link monetization.openPurchaseExperience monetization.openPurchaseExperience(planInfo?: PlanInfo): Promise\<void\>} instead.
3987
+ *
3973
3988
  * @hidden
3974
3989
  * Hide from docs
3975
3990
  * Open dialog to start user's purchase experience
@@ -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.14';
398
+ var version = '2.0.0-beta.3-dev.15';
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.
@@ -2726,10 +2726,15 @@ function initializeCommunication(validMessageOrigins) {
2726
2726
  Communication.currentWindow.addEventListener('message', CommunicationPrivate.messageListener, false);
2727
2727
  }
2728
2728
  if (!Communication.parentWindow) {
2729
- GlobalVars.isFramelessWindow = true;
2730
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2731
- // @ts-ignore: window as ExtendedWindow
2732
- window.onNativeMessage = handleParentMessage;
2729
+ var extendedWindow = Communication.currentWindow;
2730
+ if (extendedWindow.nativeInterface) {
2731
+ GlobalVars.isFramelessWindow = true;
2732
+ extendedWindow.onNativeMessage = handleParentMessage;
2733
+ }
2734
+ else {
2735
+ // at this point we weren't able to find a parent to talk to, no way initialization will succeed
2736
+ return Promise.reject(new Error('Initialization Failed. No Parent window found.'));
2737
+ }
2733
2738
  }
2734
2739
  try {
2735
2740
  // Send the initialized message to any origin, because at this point we most likely don't know the origin
@@ -4293,6 +4298,7 @@ var meeting;
4293
4298
 
4294
4299
 
4295
4300
 
4301
+
4296
4302
  /**
4297
4303
  * @alpha
4298
4304
  */
@@ -4300,21 +4306,30 @@ var monetization;
4300
4306
  (function (monetization) {
4301
4307
  /**
4302
4308
  * @hidden
4303
- * Hide from docs
4304
- * Open dialog to start user's purchase experience
4305
- *
4306
- * @param callback Callback contains 1 parameters, error.
4307
- * @param planInfo optional parameter. It contains info of the subscription plan pushed to users.
4308
- * error can either contain an error of type SdkError, incase of an error, or null when get is successful
4309
- *
4310
- * @internal
4309
+ * This function is the overloaded implementation of openPurchaseExperience.
4310
+ * Since the method signatures of the v1 callback and v2 promise differ in the type of the first parameter,
4311
+ * we need to do an extra check to know the typeof the @param1 to set the proper arguments of the utility function.
4312
+ * @param param1
4313
+ * @param param2
4314
+ * @returns Promise that will be resolved when the operation has completed or rejected with SdkError value
4311
4315
  */
4312
- function openPurchaseExperience(callback, planInfo) {
4313
- if (!callback) {
4314
- throw new Error('[open purchase experience] Callback cannot be null');
4316
+ function openPurchaseExperience(param1, param2) {
4317
+ var callback;
4318
+ var planInfo;
4319
+ if (typeof param1 === 'function') {
4320
+ callback = param1;
4321
+ planInfo = param2;
4322
+ }
4323
+ else {
4324
+ planInfo = param1;
4315
4325
  }
4326
+ var wrappedFunction = function () {
4327
+ return new Promise(function (resolve) {
4328
+ resolve(sendAndHandleSdkError('monetization.openPurchaseExperience', planInfo));
4329
+ });
4330
+ };
4316
4331
  ensureInitialized(FrameContexts.content);
4317
- sendMessageToParent('monetization.openPurchaseExperience', [planInfo], callback);
4332
+ return callCallbackWithErrorOrResultOrNullFromPromiseAndReturnPromise(wrappedFunction, callback);
4318
4333
  }
4319
4334
  monetization.openPurchaseExperience = openPurchaseExperience;
4320
4335
  function isSupported() {
@@ -4744,6 +4759,7 @@ var appInitialization;
4744
4759
 
4745
4760
 
4746
4761
 
4762
+
4747
4763
  /**
4748
4764
  * @deprecated
4749
4765
  * As of 2.0.0-beta.1, please use {@link app.initialize app.initialize(validMessageOrigins?: string[]): Promise\<void\>} instead.
@@ -4998,16 +5014,13 @@ function shareDeepLink(deepLinkParameters) {
4998
5014
  */
4999
5015
  function executeDeepLink(deepLink, onComplete) {
5000
5016
  ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.settings, FrameContexts.task, FrameContexts.stage, FrameContexts.meetingStage);
5017
+ onComplete = onComplete ? onComplete : getGenericOnCompleteHandler();
5001
5018
  core.executeDeepLink(deepLink)
5002
5019
  .then(function () {
5003
- if (onComplete) {
5004
- onComplete(true);
5005
- }
5020
+ onComplete(true);
5006
5021
  })
5007
5022
  .catch(function (err) {
5008
- if (onComplete) {
5009
- onComplete(false, err.message);
5010
- }
5023
+ onComplete(false, err.message);
5011
5024
  });
5012
5025
  }
5013
5026
  /**
@@ -5114,6 +5127,7 @@ function transformAppContextToLegacyContext(appContext) {
5114
5127
 
5115
5128
 
5116
5129
 
5130
+
5117
5131
  /**
5118
5132
  * Navigation specific part of the SDK.
5119
5133
  */
@@ -5139,16 +5153,13 @@ function returnFocus(navigateForward) {
5139
5153
  */
5140
5154
  function navigateToTab(tabInstance, onComplete) {
5141
5155
  ensureInitialized();
5156
+ onComplete = onComplete ? onComplete : getGenericOnCompleteHandler();
5142
5157
  pages.tabs.navigateToTab(tabInstance)
5143
5158
  .then(function () {
5144
- if (onComplete) {
5145
- onComplete(true);
5146
- }
5159
+ onComplete(true);
5147
5160
  })
5148
5161
  .catch(function (error) {
5149
- if (onComplete) {
5150
- onComplete(false, error.message);
5151
- }
5162
+ onComplete(false, error.message);
5152
5163
  });
5153
5164
  }
5154
5165
  /**
@@ -5166,16 +5177,13 @@ function navigateToTab(tabInstance, onComplete) {
5166
5177
  */
5167
5178
  function navigateCrossDomain(url, onComplete) {
5168
5179
  ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.settings, FrameContexts.remove, FrameContexts.task, FrameContexts.stage, FrameContexts.meetingStage);
5180
+ onComplete = onComplete ? onComplete : getGenericOnCompleteHandler();
5169
5181
  pages.navigateCrossDomain(url)
5170
5182
  .then(function () {
5171
- if (onComplete) {
5172
- onComplete(true);
5173
- }
5183
+ onComplete(true);
5174
5184
  })
5175
5185
  .catch(function (error) {
5176
- if (onComplete) {
5177
- onComplete(false, error.message);
5178
- }
5186
+ onComplete(false, error.message);
5179
5187
  });
5180
5188
  }
5181
5189
  /**
@@ -5189,16 +5197,13 @@ function navigateCrossDomain(url, onComplete) {
5189
5197
  */
5190
5198
  function navigateBack(onComplete) {
5191
5199
  ensureInitialized();
5200
+ onComplete = onComplete ? onComplete : getGenericOnCompleteHandler();
5192
5201
  pages.backStack.navigateBack()
5193
5202
  .then(function () {
5194
- if (onComplete) {
5195
- onComplete(true);
5196
- }
5203
+ onComplete(true);
5197
5204
  })
5198
5205
  .catch(function (error) {
5199
- if (onComplete) {
5200
- onComplete(false, error.message);
5201
- }
5206
+ onComplete(false, error.message);
5202
5207
  });
5203
5208
  }
5204
5209
 
@@ -5206,6 +5211,7 @@ function navigateBack(onComplete) {
5206
5211
 
5207
5212
 
5208
5213
 
5214
+
5209
5215
  /**
5210
5216
  * @deprecated
5211
5217
  * As of 2.0.0-beta.1, please use {@link pages.config} namespace instead.
@@ -5254,16 +5260,13 @@ var settings;
5254
5260
  */
5255
5261
  function setSettings(instanceSettings, onComplete) {
5256
5262
  ensureInitialized(FrameContexts.content, FrameContexts.settings, FrameContexts.sidePanel);
5263
+ onComplete = onComplete ? onComplete : getGenericOnCompleteHandler();
5257
5264
  pages.config.setConfig(instanceSettings)
5258
5265
  .then(function () {
5259
- if (onComplete) {
5260
- onComplete(true);
5261
- }
5266
+ onComplete(true);
5262
5267
  })
5263
5268
  .catch(function (error) {
5264
- if (onComplete) {
5265
- onComplete(false, error.message);
5266
- }
5269
+ onComplete(false, error.message);
5267
5270
  });
5268
5271
  }
5269
5272
  settings.setSettings = setSettings;