@microsoft/teams-js 2.16.0 → 2.17.0-beta.0

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.
@@ -2138,6 +2138,41 @@ var mapTeamsVersionToSupportedCapabilities = {
2138
2138
  ],
2139
2139
  };
2140
2140
  var generateBackCompatRuntimeConfigLogger = runtimeLogger.extend('generateBackCompatRuntimeConfig');
2141
+ /**
2142
+ * @internal
2143
+ * Limited to Microsoft-internal use
2144
+ *
2145
+ * Merges the capabilities of two runtime objects. Fully supports arbitrarily nested capabilities/subcapabilities.
2146
+ *
2147
+ * Note that this function isn't actually doing anything specific to capabilities/runtime. It's just doing a
2148
+ * generic merge of two objects.
2149
+ *
2150
+ * This function is NOT intended to handle objects that are NOT "shaped" like runtime objects. Specifically
2151
+ * this means that it doesn't know how to merge values that aren't themselves objects. For example, it cannot
2152
+ * properly handle situations where both objects contain a string or number with the same property name since the proper way to
2153
+ * merge such values would be domain-dependent. For now it just happens to keep the value in the baseline and ignore the other.
2154
+ * Since the runtime is only supposed to have objects, this limitation is fine.
2155
+ *
2156
+ * @param baselineRuntime the baseline runtime object
2157
+ * @param runtimeToMergeIntoBaseline the runtime object to merge into the baseline
2158
+ * @returns the merged runtime object which is the union of baselineRuntime and runtimeToMergeIntoBaseline
2159
+ */
2160
+ function mergeRuntimeCapabilities(baselineRuntime, runtimeToMergeIntoBaseline) {
2161
+ var merged = __assign({}, baselineRuntime);
2162
+ for (var key in runtimeToMergeIntoBaseline) {
2163
+ if (Object.prototype.hasOwnProperty.call(runtimeToMergeIntoBaseline, key)) {
2164
+ if (typeof runtimeToMergeIntoBaseline[key] === 'object' && !Array.isArray(runtimeToMergeIntoBaseline[key])) {
2165
+ merged[key] = mergeRuntimeCapabilities(baselineRuntime[key] || {}, runtimeToMergeIntoBaseline[key]);
2166
+ }
2167
+ else {
2168
+ if (!(key in baselineRuntime)) {
2169
+ merged[key] = runtimeToMergeIntoBaseline[key];
2170
+ }
2171
+ }
2172
+ }
2173
+ }
2174
+ return merged;
2175
+ }
2141
2176
  /**
2142
2177
  * @internal
2143
2178
  * Limited to Microsoft-internal use
@@ -2149,15 +2184,15 @@ var generateBackCompatRuntimeConfigLogger = runtimeLogger.extend('generateBackCo
2149
2184
  * @param highestSupportedVersion - The highest client SDK version that the host client can support.
2150
2185
  * @returns runtime which describes the APIs supported by the legacy host client.
2151
2186
  */
2152
- function generateVersionBasedTeamsRuntimeConfig(highestSupportedVersion) {
2187
+ function generateVersionBasedTeamsRuntimeConfig(highestSupportedVersion, versionAgnosticRuntimeConfig, mapVersionToSupportedCapabilities) {
2153
2188
  generateBackCompatRuntimeConfigLogger('generating back compat runtime config for %s', highestSupportedVersion);
2154
- var newSupports = __assign({}, versionAndPlatformAgnosticTeamsRuntimeConfig.supports);
2189
+ var newSupports = __assign({}, versionAgnosticRuntimeConfig.supports);
2155
2190
  generateBackCompatRuntimeConfigLogger('Supported capabilities in config before updating based on highestSupportedVersion: %o', newSupports);
2156
- Object.keys(mapTeamsVersionToSupportedCapabilities).forEach(function (versionNumber) {
2191
+ Object.keys(mapVersionToSupportedCapabilities).forEach(function (versionNumber) {
2157
2192
  if (compareSDKVersions(highestSupportedVersion, versionNumber) >= 0) {
2158
- mapTeamsVersionToSupportedCapabilities[versionNumber].forEach(function (capabilityReqs) {
2193
+ mapVersionToSupportedCapabilities[versionNumber].forEach(function (capabilityReqs) {
2159
2194
  if (capabilityReqs.hostClientTypes.includes(GlobalVars.hostClientType)) {
2160
- newSupports = __assign(__assign({}, newSupports), capabilityReqs.capability);
2195
+ newSupports = mergeRuntimeCapabilities(newSupports, capabilityReqs.capability);
2161
2196
  }
2162
2197
  });
2163
2198
  }
@@ -2214,7 +2249,7 @@ var _minRuntimeConfigToUninitialize = {
2214
2249
  * @hidden
2215
2250
  * Package version.
2216
2251
  */
2217
- var version = "2.16.0";
2252
+ var version = "2.17.0-beta.0";
2218
2253
 
2219
2254
  ;// CONCATENATED MODULE: ./src/internal/internalAPIs.ts
2220
2255
 
@@ -3543,7 +3578,7 @@ var app;
3543
3578
  }
3544
3579
  catch (e) {
3545
3580
  if (e instanceof SyntaxError) {
3546
- applyRuntimeConfig(generateVersionBasedTeamsRuntimeConfig(GlobalVars.clientSupportedSDKVersion));
3581
+ applyRuntimeConfig(generateVersionBasedTeamsRuntimeConfig(GlobalVars.clientSupportedSDKVersion, versionAndPlatformAgnosticTeamsRuntimeConfig, mapTeamsVersionToSupportedCapabilities));
3547
3582
  }
3548
3583
  else {
3549
3584
  throw e;
@@ -4612,8 +4647,6 @@ var HandlersPrivate = /** @class */ (function () {
4612
4647
  HandlersPrivate.handlers['themeChange'] = handleThemeChange;
4613
4648
  HandlersPrivate.handlers['load'] = handleLoad;
4614
4649
  HandlersPrivate.handlers['beforeUnload'] = handleBeforeUnload;
4615
- HandlersPrivate.handlers['beforeSuspendOrTerminate'] = handleBeforeSuspendOrTerminate;
4616
- HandlersPrivate.handlers['resume'] = handleResume;
4617
4650
  pages.backStack._initialize();
4618
4651
  };
4619
4652
  /**
@@ -4749,11 +4782,12 @@ function handlers_registerOnLoadHandler(handler) {
4749
4782
  /**
4750
4783
  * @internal
4751
4784
  * Limited to Microsoft-internal use
4752
- *
4753
- * @deprecated
4754
4785
  */
4755
4786
  function handleLoad(context) {
4756
- if (HandlersPrivate.loadHandler) {
4787
+ if (HandlersPrivate.resumeHandler) {
4788
+ HandlersPrivate.resumeHandler(context);
4789
+ }
4790
+ else if (HandlersPrivate.loadHandler) {
4757
4791
  HandlersPrivate.loadHandler(context);
4758
4792
  }
4759
4793
  if (Communication.childWindow) {
@@ -4773,14 +4807,21 @@ function handlers_registerBeforeUnloadHandler(handler) {
4773
4807
  /**
4774
4808
  * @internal
4775
4809
  * Limited to Microsoft-internal use
4776
- *
4777
- * @deprecated
4778
4810
  */
4779
4811
  function handleBeforeUnload() {
4780
4812
  var readyToUnload = function () {
4781
4813
  sendMessageToParent('readyToUnload', []);
4782
4814
  };
4783
- if (!HandlersPrivate.beforeUnloadHandler || !HandlersPrivate.beforeUnloadHandler(readyToUnload)) {
4815
+ if (HandlersPrivate.beforeSuspendOrTerminateHandler) {
4816
+ HandlersPrivate.beforeSuspendOrTerminateHandler();
4817
+ if (Communication.childWindow) {
4818
+ sendMessageEventToChild('beforeUnload');
4819
+ }
4820
+ else {
4821
+ readyToUnload();
4822
+ }
4823
+ }
4824
+ else if (!HandlersPrivate.beforeUnloadHandler || !HandlersPrivate.beforeUnloadHandler(readyToUnload)) {
4784
4825
  if (Communication.childWindow) {
4785
4826
  sendMessageEventToChild('beforeUnload');
4786
4827
  }
@@ -4795,45 +4836,15 @@ function handleBeforeUnload() {
4795
4836
  */
4796
4837
  function handlers_registerBeforeSuspendOrTerminateHandler(handler) {
4797
4838
  HandlersPrivate.beforeSuspendOrTerminateHandler = handler;
4798
- handler && sendMessageToParent('registerHandler', ['beforeSuspendOrTerminate']);
4799
- }
4800
- /**
4801
- * @internal
4802
- * Limited to Microsoft-internal use
4803
- */
4804
- function handleBeforeSuspendOrTerminate() {
4805
- var readyToSuspendOrTerminate = function () {
4806
- sendMessageToParent('readyToSuspendOrTerminate', []);
4807
- };
4808
- if (HandlersPrivate.beforeSuspendOrTerminateHandler) {
4809
- HandlersPrivate.beforeSuspendOrTerminateHandler();
4810
- }
4811
- if (Communication.childWindow) {
4812
- sendMessageEventToChild('beforeSuspendOrTerminate');
4813
- }
4814
- else {
4815
- readyToSuspendOrTerminate();
4816
- }
4839
+ handler && sendMessageToParent('registerHandler', ['beforeUnload']);
4817
4840
  }
4818
4841
  /**
4819
4842
  * @internal
4820
4843
  * Limited to Microsoft-internal use
4821
4844
  */
4822
4845
  function handlers_registerOnResumeHandler(handler) {
4823
- HandlersPrivate.loadHandler = handler;
4824
- handler && sendMessageToParent('registerHandler', ['resume']);
4825
- }
4826
- /**
4827
- * @internal
4828
- * Limited to Microsoft-internal use
4829
- */
4830
- function handleResume(context) {
4831
- if (HandlersPrivate.loadHandler) {
4832
- HandlersPrivate.loadHandler(context);
4833
- }
4834
- if (Communication.childWindow) {
4835
- sendMessageEventToChild('resume', [context]);
4836
- }
4846
+ HandlersPrivate.resumeHandler = handler;
4847
+ handler && sendMessageToParent('registerHandler', ['load']);
4837
4848
  }
4838
4849
 
4839
4850
  ;// CONCATENATED MODULE: ./src/internal/communication.ts
@@ -8142,9 +8153,6 @@ var teamsCore;
8142
8153
  *
8143
8154
  * @param handler - The handler to invoke when the page is loaded.
8144
8155
  *
8145
- * @deprecated
8146
- * As of 2.14.1, please use {@link app.lifecycle.registerOnResumeHandler} instead.
8147
- *
8148
8156
  * @beta
8149
8157
  */
8150
8158
  function registerOnLoadHandler(handler) {
@@ -8185,7 +8193,6 @@ var teamsCore;
8185
8193
  * @param handler - The handler to invoke before the page is unloaded. If this handler returns true the page should
8186
8194
  * invoke the readyToUnload function provided to it once it's ready to be unloaded.
8187
8195
  *
8188
- * @deprecated
8189
8196
  * @beta
8190
8197
  */
8191
8198
  function registerBeforeUnloadHandler(handler) {