@microsoft/teams-js 2.8.1-beta.0 → 2.9.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.
@@ -2151,7 +2151,7 @@ var _minRuntimeConfigToUninitialize = {
2151
2151
  };
2152
2152
 
2153
2153
  ;// CONCATENATED MODULE: ./src/public/version.ts
2154
- var version = "2.8.1-beta.0";
2154
+ var version = "2.9.0";
2155
2155
 
2156
2156
  ;// CONCATENATED MODULE: ./src/internal/internalAPIs.ts
2157
2157
 
@@ -2302,6 +2302,11 @@ var authentication;
2302
2302
  (function (authentication) {
2303
2303
  var authHandlers;
2304
2304
  var authWindowMonitor;
2305
+ /**
2306
+ * @hidden
2307
+ * @internal
2308
+ * Limited to Microsoft-internal use; automatically called when library is initialized
2309
+ */
2305
2310
  function initialize() {
2306
2311
  registerHandler('authentication.authenticate.success', handleSuccess, false);
2307
2312
  registerHandler('authentication.authenticate.failure', handleFailure, false);
@@ -2310,10 +2315,11 @@ var authentication;
2310
2315
  var authParams;
2311
2316
  /**
2312
2317
  * @deprecated
2313
- * As of 2.0.0, this function has been deprecated in favor of a Promise-based pattern.
2314
- * Registers the authentication Communication.handlers
2318
+ * As of 2.0.0, this function has been deprecated in favor of a Promise-based pattern using {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>}
2315
2319
  *
2316
- * @param authenticateParameters - A set of values that configure the authentication pop-up.
2320
+ * Registers handlers to be called with the result of an authentication flow triggered using {@link authentication.authenticate authentication.authenticate(authenticateParameters?: AuthenticateParameters): void}
2321
+ *
2322
+ * @param authenticateParameters - Configuration for authentication flow pop-up result communication
2317
2323
  */
2318
2324
  function registerAuthenticationHandlers(authenticateParameters) {
2319
2325
  authParams = authenticateParameters;
@@ -2563,13 +2569,17 @@ var authentication;
2563
2569
  });
2564
2570
  }
2565
2571
  /**
2566
- * Notifies the frame that initiated this authentication request that the request was successful.
2572
+ * When using {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>}, the
2573
+ * window that was opened to execute the authentication flow should call this method after authentiction to notify the caller of
2574
+ * {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>} that the
2575
+ * authentication request was successful.
2567
2576
  *
2568
2577
  * @remarks
2569
- * This function is usable only on the authentication window.
2578
+ * This function is usable only from the authentication window.
2570
2579
  * This call causes the authentication window to be closed.
2571
2580
  *
2572
- * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives this value in its callback.
2581
+ * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives
2582
+ * this value in its callback or via the `Promise` return value
2573
2583
  * @param callbackUrl - Specifies the url to redirect back to if the client is Win32 Outlook.
2574
2584
  */
2575
2585
  function notifySuccess(result, callbackUrl) {
@@ -2581,13 +2591,18 @@ var authentication;
2581
2591
  }
2582
2592
  authentication.notifySuccess = notifySuccess;
2583
2593
  /**
2584
- * Notifies the frame that initiated this authentication request that the request failed.
2594
+ * When using {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>}, the
2595
+ * window that was opened to execute the authentication flow should call this method after authentiction to notify the caller of
2596
+ * {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>} that the
2597
+ * authentication request failed.
2598
+
2585
2599
  *
2586
2600
  * @remarks
2587
2601
  * This function is usable only on the authentication window.
2588
2602
  * This call causes the authentication window to be closed.
2589
2603
  *
2590
- * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives this value in its callback.
2604
+ * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives
2605
+ * this value in its callback or via the `Promise` return value
2591
2606
  * @param callbackUrl - Specifies the url to redirect back to if the client is Win32 Outlook.
2592
2607
  */
2593
2608
  function notifyFailure(reason, callbackUrl) {
@@ -7766,6 +7781,53 @@ var profile;
7766
7781
  })(profile || (profile = {}));
7767
7782
 
7768
7783
  ;// CONCATENATED MODULE: ./src/public/video.ts
7784
+ var video_assign = (undefined && undefined.__assign) || function () {
7785
+ video_assign = Object.assign || function(t) {
7786
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
7787
+ s = arguments[i];
7788
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7789
+ t[p] = s[p];
7790
+ }
7791
+ return t;
7792
+ };
7793
+ return video_assign.apply(this, arguments);
7794
+ };
7795
+ var video_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
7796
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7797
+ return new (P || (P = Promise))(function (resolve, reject) {
7798
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7799
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7800
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7801
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
7802
+ });
7803
+ };
7804
+ var video_generator = (undefined && undefined.__generator) || function (thisArg, body) {
7805
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
7806
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
7807
+ function verb(n) { return function (v) { return step([n, v]); }; }
7808
+ function step(op) {
7809
+ if (f) throw new TypeError("Generator is already executing.");
7810
+ while (_) try {
7811
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
7812
+ if (y = 0, t) op = [op[0] & 2, t.value];
7813
+ switch (op[0]) {
7814
+ case 0: case 1: t = op; break;
7815
+ case 4: _.label++; return { value: op[1], done: false };
7816
+ case 5: _.label++; y = op[1]; op = [0]; continue;
7817
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
7818
+ default:
7819
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
7820
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
7821
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
7822
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
7823
+ if (t[2]) _.ops.pop();
7824
+ _.trys.pop(); continue;
7825
+ }
7826
+ op = body.call(thisArg, _);
7827
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
7828
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
7829
+ }
7830
+ };
7769
7831
 
7770
7832
 
7771
7833
 
@@ -7783,7 +7845,7 @@ var video;
7783
7845
  */
7784
7846
  var VideoFrameFormat;
7785
7847
  (function (VideoFrameFormat) {
7786
- VideoFrameFormat[VideoFrameFormat["NV12"] = 0] = "NV12";
7848
+ VideoFrameFormat["NV12"] = "NV12";
7787
7849
  })(VideoFrameFormat = video.VideoFrameFormat || (video.VideoFrameFormat = {}));
7788
7850
  /**
7789
7851
  * Video effect change type enum
@@ -7800,6 +7862,22 @@ var video;
7800
7862
  */
7801
7863
  EffectChangeType[EffectChangeType["EffectDisabled"] = 1] = "EffectDisabled";
7802
7864
  })(EffectChangeType = video.EffectChangeType || (video.EffectChangeType = {}));
7865
+ /**
7866
+ * Predefined failure reasons for preparing the selected video effect
7867
+ * @beta
7868
+ */
7869
+ var EffectFailureReason;
7870
+ (function (EffectFailureReason) {
7871
+ /**
7872
+ * A wrong effect id is provide.
7873
+ * Use this reason when the effect id is not found or empty, this may indicate a mismatch between the app and its manifest or a bug of the host.
7874
+ */
7875
+ EffectFailureReason["InvalidEffectId"] = "InvalidEffectId";
7876
+ /**
7877
+ * The effect can't be initialized
7878
+ */
7879
+ EffectFailureReason["InitializationFailure"] = "InitializationFailure";
7880
+ })(EffectFailureReason = video.EffectFailureReason || (video.EffectFailureReason = {}));
7803
7881
  /**
7804
7882
  * Register to read the video frames in Permissions section
7805
7883
  * @beta
@@ -7811,10 +7889,14 @@ var video;
7811
7889
  if (!isSupported()) {
7812
7890
  throw errorNotSupportedOnPlatform;
7813
7891
  }
7814
- registerHandler('video.newVideoFrame', function (videoFrame) {
7892
+ registerHandler('video.newVideoFrame',
7893
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7894
+ function (videoFrame) {
7815
7895
  if (videoFrame) {
7816
- var timestamp_1 = videoFrame.timestamp;
7817
- frameCallback(videoFrame, function () {
7896
+ // The host may pass the VideoFrame with the old definition which has `data` instead of `videoFrameBuffer`
7897
+ var videoFrameData = video_assign(video_assign({}, videoFrame), { videoFrameBuffer: videoFrame.videoFrameBuffer || videoFrame.data });
7898
+ var timestamp_1 = videoFrameData.timestamp;
7899
+ frameCallback(videoFrameData, function () {
7818
7900
  notifyVideoFrameProcessed(timestamp_1);
7819
7901
  }, notifyError);
7820
7902
  }
@@ -7839,16 +7921,26 @@ var video;
7839
7921
  }
7840
7922
  video.notifySelectedVideoEffectChanged = notifySelectedVideoEffectChanged;
7841
7923
  /**
7842
- * Register the video effect callback, host uses this to notify the video extension the new video effect will by applied
7924
+ * Register a callback to be notified when a new video effect is applied.
7843
7925
  * @beta
7844
- * @param callback - The VideoEffectCallback to invoke when registerForVideoEffect has completed
7926
+ * @param callback - Function to be called when new video effect is applied.
7845
7927
  */
7846
7928
  function registerForVideoEffect(callback) {
7847
7929
  ensureInitialized(runtime, FrameContexts.sidePanel);
7848
7930
  if (!isSupported()) {
7849
7931
  throw errorNotSupportedOnPlatform;
7850
7932
  }
7851
- registerHandler('video.effectParameterChange', callback, false);
7933
+ var effectParameterChangeHandler = function (effectId) {
7934
+ callback(effectId)
7935
+ .then(function () {
7936
+ sendMessageToParent('video.videoEffectReadiness', [true, effectId]);
7937
+ })
7938
+ .catch(function (reason) {
7939
+ var validReason = reason in EffectFailureReason ? reason : EffectFailureReason.InitializationFailure;
7940
+ sendMessageToParent('video.videoEffectReadiness', [false, effectId, validReason]);
7941
+ });
7942
+ };
7943
+ registerHandler('video.effectParameterChange', effectParameterChangeHandler, false);
7852
7944
  sendMessageToParent('video.registerForVideoEffect');
7853
7945
  }
7854
7946
  video.registerForVideoEffect = registerForVideoEffect;
@@ -7880,6 +7972,165 @@ var video;
7880
7972
  return ensureInitialized(runtime) && runtime.supports.video ? true : false;
7881
7973
  }
7882
7974
  video.isSupported = isSupported;
7975
+ /**
7976
+ * @beta
7977
+ * Namespace to get video frames from a media stream.
7978
+ * When the host supports this capability, developer should call {@link mediaStream.registerForVideoFrame} to get the video frames instead of {@link registerForVideoFrame} to get the video frames, callback of {@link registerForVideoFrame} will be ignored when the host supports this capability.
7979
+ */
7980
+ var mediaStream;
7981
+ (function (mediaStream_1) {
7982
+ /**
7983
+ * @beta
7984
+ * Checks if video.mediaStream capability is supported by the host
7985
+ * @returns boolean to represent whether the video.medisStream capability is supported
7986
+ *
7987
+ * @throws Error if {@linkcode app.initialize} has not successfully completed
7988
+ *
7989
+ */
7990
+ function isSupported() {
7991
+ var _a;
7992
+ return ensureInitialized(runtime) && isTextureStreamAvailable() && !!((_a = runtime.supports.video) === null || _a === void 0 ? void 0 : _a.mediaStream);
7993
+ }
7994
+ mediaStream_1.isSupported = isSupported;
7995
+ function isTextureStreamAvailable() {
7996
+ var _a, _b, _c, _d;
7997
+ return (typeof window !== 'undefined' &&
7998
+ !!(((_b = (_a = window['chrome']) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.getTextureStream) && ((_d = (_c = window['chrome']) === null || _c === void 0 ? void 0 : _c.webview) === null || _d === void 0 ? void 0 : _d.registerTextureStream)));
7999
+ }
8000
+ /**
8001
+ * @beta
8002
+ * Register to read the video frames from the media stream provided by the host.
8003
+ * @param frameCallback - The callback to invoke when recieve a video frame from the media stream.
8004
+ * @example
8005
+ * ```typescript
8006
+ * video.mediaStream.registerForVideoFrame(async (receivedVideoFrame) => {
8007
+ * const { videoFrame } = receivedVideoFrame;
8008
+ * try {
8009
+ * return await processVideoFrame(videoFrame);
8010
+ * } catch (error) {
8011
+ * throw error;
8012
+ * }
8013
+ * });
8014
+ * ```
8015
+ */
8016
+ function registerForVideoFrame(frameCallback) {
8017
+ var _this = this;
8018
+ ensureInitialized(runtime, FrameContexts.sidePanel);
8019
+ if (!isSupported()) {
8020
+ throw errorNotSupportedOnPlatform;
8021
+ }
8022
+ registerHandler('video.startVideoExtensibilityVideoStream', function (mediaStreamInfo) { return video_awaiter(_this, void 0, void 0, function () {
8023
+ var streamId, videoTrack, generator;
8024
+ var _a, _b;
8025
+ return video_generator(this, function (_c) {
8026
+ switch (_c.label) {
8027
+ case 0:
8028
+ streamId = mediaStreamInfo.streamId;
8029
+ return [4 /*yield*/, getInputVideoTrack(streamId)];
8030
+ case 1:
8031
+ videoTrack = _c.sent();
8032
+ generator = createProcessedStreamGenerator(videoTrack, frameCallback);
8033
+ // register the video track with processed frames back to the stream:
8034
+ typeof window !== 'undefined' && ((_b = (_a = window['chrome']) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.registerTextureStream(streamId, generator));
8035
+ return [2 /*return*/];
8036
+ }
8037
+ });
8038
+ }); });
8039
+ sendMessageToParent('video.registerForVideoFrame', [
8040
+ {
8041
+ format: VideoFrameFormat.NV12,
8042
+ },
8043
+ ]);
8044
+ }
8045
+ mediaStream_1.registerForVideoFrame = registerForVideoFrame;
8046
+ /**
8047
+ * Get the video track from the media stream gotten from chrome.webview.getTextureStream(streamId).
8048
+ */
8049
+ function getInputVideoTrack(streamId) {
8050
+ return video_awaiter(this, void 0, void 0, function () {
8051
+ var chrome, mediaStream_2, tracks, error_1, errorMsg;
8052
+ return video_generator(this, function (_a) {
8053
+ switch (_a.label) {
8054
+ case 0:
8055
+ if (typeof window === 'undefined') {
8056
+ throw errorNotSupportedOnPlatform;
8057
+ }
8058
+ chrome = window['chrome'];
8059
+ _a.label = 1;
8060
+ case 1:
8061
+ _a.trys.push([1, 3, , 4]);
8062
+ return [4 /*yield*/, chrome.webview.getTextureStream(streamId)];
8063
+ case 2:
8064
+ mediaStream_2 = _a.sent();
8065
+ tracks = mediaStream_2.getVideoTracks();
8066
+ if (tracks.length === 0) {
8067
+ throw new Error("No video track in stream ".concat(streamId));
8068
+ }
8069
+ return [2 /*return*/, tracks[0]];
8070
+ case 3:
8071
+ error_1 = _a.sent();
8072
+ errorMsg = "Failed to get video track from stream ".concat(streamId, ", error: ").concat(error_1);
8073
+ notifyError(errorMsg);
8074
+ throw new Error(errorMsg);
8075
+ case 4: return [2 /*return*/];
8076
+ }
8077
+ });
8078
+ });
8079
+ }
8080
+ /**
8081
+ * The function to create a processed video track from the original video track.
8082
+ * It reads frames from the video track and pipes them to the video frame callback to process the frames.
8083
+ * The processed frames are then enqueued to the generator.
8084
+ * The generator can be registered back to the media stream so that the host can get the processed frames.
8085
+ */
8086
+ function createProcessedStreamGenerator(videoTrack, videoFrameCallback) {
8087
+ var processor = new MediaStreamTrackProcessor({ track: videoTrack });
8088
+ var source = processor.readable;
8089
+ var generator = new MediaStreamTrackGenerator({ kind: 'video' });
8090
+ var sink = generator.writable;
8091
+ source
8092
+ .pipeThrough(new TransformStream({
8093
+ transform: function (originalFrame, controller) {
8094
+ return video_awaiter(this, void 0, void 0, function () {
8095
+ var timestamp, frameProcessedByApp, processedFrame, error_2;
8096
+ return video_generator(this, function (_a) {
8097
+ switch (_a.label) {
8098
+ case 0:
8099
+ timestamp = originalFrame.timestamp;
8100
+ if (!(timestamp !== null)) return [3 /*break*/, 5];
8101
+ _a.label = 1;
8102
+ case 1:
8103
+ _a.trys.push([1, 3, , 4]);
8104
+ return [4 /*yield*/, videoFrameCallback({ videoFrame: originalFrame })];
8105
+ case 2:
8106
+ frameProcessedByApp = _a.sent();
8107
+ processedFrame = new VideoFrame(frameProcessedByApp, {
8108
+ // we need the timestamp to be unchanged from the oirginal frame, so we explicitly set it here.
8109
+ timestamp: timestamp,
8110
+ });
8111
+ controller.enqueue(processedFrame);
8112
+ originalFrame.close();
8113
+ frameProcessedByApp.close();
8114
+ return [3 /*break*/, 4];
8115
+ case 3:
8116
+ error_2 = _a.sent();
8117
+ originalFrame.close();
8118
+ notifyError(error_2);
8119
+ return [3 /*break*/, 4];
8120
+ case 4: return [3 /*break*/, 6];
8121
+ case 5:
8122
+ notifyError('timestamp of the original video frame is null');
8123
+ _a.label = 6;
8124
+ case 6: return [2 /*return*/];
8125
+ }
8126
+ });
8127
+ });
8128
+ },
8129
+ }))
8130
+ .pipeTo(sink);
8131
+ return generator;
8132
+ }
8133
+ })(mediaStream = video.mediaStream || (video.mediaStream = {}));
7883
8134
  })(video || (video = {})); //end of video namespace
7884
8135
 
7885
8136
  ;// CONCATENATED MODULE: ./src/public/search.ts