@microsoft/teams-js 2.50.0 → 2.51.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.
@@ -1070,6 +1070,7 @@ __webpack_require__.d(__webpack_exports__, {
1070
1070
  overwriteFeatureFlagsState: () => (/* reexport */ overwriteFeatureFlagsState),
1071
1071
  pages: () => (/* reexport */ pages_namespaceObject),
1072
1072
  people: () => (/* reexport */ people_namespaceObject),
1073
+ plugins: () => (/* reexport */ plugins_namespaceObject),
1073
1074
  print: () => (/* reexport */ publicAPIs_print),
1074
1075
  profile: () => (/* reexport */ profile_namespaceObject),
1075
1076
  registerAppButtonClickHandler: () => (/* reexport */ registerAppButtonClickHandler),
@@ -1562,6 +1563,15 @@ __webpack_require__.d(otherAppStateChange_namespaceObject, {
1562
1563
  unregisterAppInstallationHandler: () => (unregisterAppInstallationHandler)
1563
1564
  });
1564
1565
 
1566
+ // NAMESPACE OBJECT: ./src/private/plugins.ts
1567
+ var plugins_namespaceObject = {};
1568
+ __webpack_require__.r(plugins_namespaceObject);
1569
+ __webpack_require__.d(plugins_namespaceObject, {
1570
+ isSupported: () => (plugins_isSupported),
1571
+ registerPluginMessage: () => (registerPluginMessage),
1572
+ sendPluginMessage: () => (sendPluginMessage)
1573
+ });
1574
+
1565
1575
  // NAMESPACE OBJECT: ./src/private/remoteCamera.ts
1566
1576
  var remoteCamera_namespaceObject = {};
1567
1577
  __webpack_require__.r(remoteCamera_namespaceObject);
@@ -4669,7 +4679,7 @@ function isSerializable(arg) {
4669
4679
  * @hidden
4670
4680
  * Package version.
4671
4681
  */
4672
- const version = "2.50.0";
4682
+ const version = "2.51.0";
4673
4683
 
4674
4684
  ;// ./src/public/featureFlags.ts
4675
4685
  // All build feature flags are defined inside this object. Any build feature flag must have its own unique getter and setter function. This pattern allows for client apps to treeshake unused code and avoid including code guarded by this feature flags in the final bundle. If this property isn't desired, use the below runtime feature flags object.
@@ -4959,8 +4969,10 @@ function ensureInitialized(runtime, ...expectedFrameContexts) {
4959
4969
  }
4960
4970
  }
4961
4971
  if (!found) {
4962
- throw new Error(`This call is only allowed in following contexts: ${JSON.stringify(expectedFrameContexts)}. ` +
4963
- `Current context: "${GlobalVars.frameContext}".`);
4972
+ const errorMessage = `This call is only allowed in following contexts: ${JSON.stringify(expectedFrameContexts)}. ` +
4973
+ `Current context: "${GlobalVars.frameContext}".`;
4974
+ ensureInitializedLogger(errorMessage);
4975
+ throw new Error(errorMessage);
4964
4976
  }
4965
4977
  }
4966
4978
  return isRuntimeInitialized(runtime);
@@ -5679,6 +5691,7 @@ function transformLegacyContextToAppContext(legacyContext) {
5679
5691
  host: {
5680
5692
  name: legacyContext.hostName ? legacyContext.hostName : HostName.teams,
5681
5693
  clientType: legacyContext.hostClientType ? legacyContext.hostClientType : HostClientType.web,
5694
+ features: legacyContext.hostFeatures,
5682
5695
  sessionId: legacyContext.sessionId ? legacyContext.sessionId : '',
5683
5696
  ringId: legacyContext.ringId,
5684
5697
  ancestors: legacyContext.hostAncestors,
@@ -9301,6 +9314,8 @@ function uploadCustomApp(manifestBlob, onComplete) {
9301
9314
  sendMessageToParent(getApiVersionTag(privateAPIsTelemetryVersionNumber, "uploadCustomApp" /* ApiName.PrivateAPIs_UploadCustomApp */), 'uploadCustomApp', [manifestBlob], onComplete ? onComplete : getGenericOnCompleteHandler());
9302
9315
  }
9303
9316
  /**
9317
+ * @deprecated Use {@link plugins.sendPluginMessage} with {@link plugins.registerPluginMessage} and a correlationId-based response pattern.
9318
+ *
9304
9319
  * @hidden
9305
9320
  * Sends a custom action MessageRequest to host or parent window
9306
9321
  *
@@ -9309,6 +9324,39 @@ function uploadCustomApp(manifestBlob, onComplete) {
9309
9324
  * @param callback - Optionally specify a callback to receive response parameters from the parent
9310
9325
  * @returns id of sent message
9311
9326
  *
9327
+ * @remarks
9328
+ * Prefer the plugin event model for new development. In that model, send a request message
9329
+ * with a unique `correlationId` and listen for a response event with the same `correlationId`.
9330
+ *
9331
+ * Example:
9332
+ * ```ts
9333
+ * // Request side
9334
+ * const correlationId = crypto.randomUUID();
9335
+ *
9336
+ * plugins.registerPluginMessage((message) => {
9337
+ * if (message.func !== 'example.customAction.response') {
9338
+ * return;
9339
+ * }
9340
+ * if (message.correlationId !== correlationId) {
9341
+ * return;
9342
+ * }
9343
+ *
9344
+ * // This is the response for the request above.
9345
+ * const response = message.args;
9346
+ * console.log('Received response', response);
9347
+ * });
9348
+ *
9349
+ * await plugins.sendPluginMessage({
9350
+ * func: 'example.customAction.request',
9351
+ * args: { itemId: '12345' },
9352
+ * correlationId,
9353
+ * });
9354
+ *
9355
+ * // Host side contract example (conceptual):
9356
+ * // On receiving example.customAction.request, send back
9357
+ * // example.customAction.response with the same correlationId.
9358
+ * ```
9359
+ *
9312
9360
  * @internal
9313
9361
  * Limited to Microsoft-internal use
9314
9362
  */
@@ -9395,6 +9443,8 @@ function openFilePreview(filePreviewParameters) {
9395
9443
  filePreviewParameters.messageId,
9396
9444
  filePreviewParameters.callerInfo,
9397
9445
  filePreviewParameters.atpData,
9446
+ filePreviewParameters.shareUrl,
9447
+ filePreviewParameters.replyChainId,
9398
9448
  ];
9399
9449
  sendMessageToParent(getApiVersionTag(privateAPIsTelemetryVersionNumber, "openFilePreview" /* ApiName.PrivateAPIs_OpenFilePreview */), 'openFilePreview', params);
9400
9450
  }
@@ -12185,6 +12235,122 @@ function otherAppStateChange_isSupported() {
12185
12235
  return ensureInitialized(runtime) && runtime.supports.otherAppStateChange ? true : false;
12186
12236
  }
12187
12237
 
12238
+ ;// ./src/private/plugins.ts
12239
+ var plugins_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
12240
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12241
+ return new (P || (P = Promise))(function (resolve, reject) {
12242
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12243
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12244
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12245
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12246
+ });
12247
+ };
12248
+
12249
+
12250
+
12251
+
12252
+
12253
+
12254
+ const pluginTelemetryVersionNumber = "v2" /* ApiVersionNumber.V_2 */;
12255
+ /**
12256
+ * Indicates whether the plugin capability is available in the current host.
12257
+ *
12258
+ * @remarks
12259
+ * This API validates SDK initialization and then checks runtime capability flags
12260
+ * for `supports.plugins`.
12261
+ *
12262
+ * @returns `true` if the host reports plugin support; otherwise `false`.
12263
+ *
12264
+ * @throws Error if {@linkcode app.initialize} has not successfully completed.
12265
+ *
12266
+ * @hidden
12267
+ * @internal
12268
+ * Limited to Microsoft-internal use
12269
+ * @beta
12270
+ */
12271
+ function plugins_isSupported() {
12272
+ return ensureInitialized(runtime) && !!runtime.supports.plugins;
12273
+ }
12274
+ /**
12275
+ * Sends a plugin message to the host.
12276
+ *
12277
+ * @remarks
12278
+ * The message payload is serialized before transmission to the host.
12279
+ * All payload data must be JSON-safe (see {@link JsonValue}).
12280
+ *
12281
+ * @returns A promise that resolves when the host acknowledges the message.
12282
+ *
12283
+ * @throws Error if SDK initialization has not completed, if the host returns
12284
+ * an error response, or if `func` is missing.
12285
+ *
12286
+ * @hidden
12287
+ * @internal
12288
+ * Limited to Microsoft-internal use
12289
+ * @beta
12290
+ */
12291
+ function sendPluginMessage(message) {
12292
+ return plugins_awaiter(this, void 0, void 0, function* () {
12293
+ ensureInitialized(runtime);
12294
+ if (!message.func) {
12295
+ throw new Error('func is required in PluginMessage.');
12296
+ }
12297
+ return callFunctionInHost("plugins.sendMessage" /* ApiName.Plugins_SendMessage */, [new SerializablePluginMessage(message)], getApiVersionTag(pluginTelemetryVersionNumber, "plugins.sendMessage" /* ApiName.Plugins_SendMessage */));
12298
+ });
12299
+ }
12300
+ /**
12301
+ * Registers a handler to receive plugin messages from the host.
12302
+ *
12303
+ * @remarks
12304
+ * This API registers the callback under the `plugin.receiveMessage` handler name.
12305
+ * When the host dispatches a plugin message, the supplied handler is invoked with
12306
+ * the received JSON payload.
12307
+ *
12308
+ * @param handler - Callback invoked for each incoming plugin message payload.
12309
+ *
12310
+ * @throws Error if plugin messaging is not supported by the current host.
12311
+ *
12312
+ * @hidden
12313
+ * @internal
12314
+ * Limited to Microsoft-internal use
12315
+ * @beta
12316
+ */
12317
+ function registerPluginMessage(handler) {
12318
+ registerHandlerHelper(getApiVersionTag(pluginTelemetryVersionNumber, "plugins.receiveMessage" /* ApiName.Plugins_ReceiveMessage */), "plugins.receiveMessage" /* ApiName.Plugins_ReceiveMessage */, (...incoming) => {
12319
+ handler(normalizePluginInboundMessage(incoming));
12320
+ }, Object.values(FrameContexts), () => {
12321
+ if (!plugins_isSupported()) {
12322
+ throw new Error('Receiving plugin messages is not supported in the current host.');
12323
+ }
12324
+ });
12325
+ }
12326
+ class SerializablePluginMessage {
12327
+ constructor(message) {
12328
+ this.message = message;
12329
+ }
12330
+ serialize() {
12331
+ return this.message;
12332
+ }
12333
+ }
12334
+ function normalizePluginInboundMessage(incoming) {
12335
+ // New envelope format: { func, args, correlationId?, schemaVersion? }
12336
+ if (incoming.length === 1 && isPluginInboundMessage(incoming[0])) {
12337
+ return incoming[0];
12338
+ }
12339
+ const [func, args, correlationId] = incoming;
12340
+ return {
12341
+ func: typeof func === 'string' ? func : String(func !== null && func !== void 0 ? func : ''),
12342
+ args: args,
12343
+ correlationId: typeof correlationId === 'string' ? correlationId : undefined,
12344
+ };
12345
+ }
12346
+ function isPluginInboundMessage(value) {
12347
+ if (!value || typeof value !== 'object') {
12348
+ return false;
12349
+ }
12350
+ const message = value;
12351
+ return typeof message.func === 'string';
12352
+ }
12353
+
12188
12354
  ;// ./src/private/remoteCamera.ts
12189
12355
  /**
12190
12356
  * @hidden
@@ -14649,6 +14815,8 @@ class SerializableContentSizeArgs {
14649
14815
 
14650
14816
 
14651
14817
 
14818
+
14819
+
14652
14820
 
14653
14821
 
14654
14822