@microsoft/teams-js 2.13.0-beta.1 → 2.13.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.
@@ -845,6 +845,7 @@ __webpack_require__.d(__webpack_exports__, {
845
845
  "location": () => (/* reexport */ location_location),
846
846
  "logs": () => (/* reexport */ logs),
847
847
  "mail": () => (/* reexport */ mail),
848
+ "marketplace": () => (/* reexport */ marketplace),
848
849
  "media": () => (/* reexport */ media),
849
850
  "meeting": () => (/* reexport */ meeting),
850
851
  "meetingRoom": () => (/* reexport */ meetingRoom),
@@ -2088,7 +2089,7 @@ var _minRuntimeConfigToUninitialize = {
2088
2089
  * @hidden
2089
2090
  * Package version.
2090
2091
  */
2091
- var version = "2.13.0-beta.1";
2092
+ var version = "2.13.0";
2092
2093
 
2093
2094
  ;// CONCATENATED MODULE: ./src/internal/internalAPIs.ts
2094
2095
 
@@ -7884,6 +7885,7 @@ var videoUtils_generator = (undefined && undefined.__generator) || function (thi
7884
7885
 
7885
7886
 
7886
7887
 
7888
+
7887
7889
  /**
7888
7890
  * @hidden
7889
7891
  * Create a MediaStreamTrack from the media stream with the given streamId and processed by videoFrameHandler.
@@ -7896,8 +7898,28 @@ function processMediaStream(streamId, videoFrameHandler, notifyError) {
7896
7898
  case 0:
7897
7899
  _a = createProcessedStreamGenerator;
7898
7900
  return [4 /*yield*/, getInputVideoTrack(streamId, notifyError)];
7899
- case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), videoFrameHandler,
7900
- notifyError])];
7901
+ case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), new DefaultTransformer(notifyError, videoFrameHandler)])];
7902
+ }
7903
+ });
7904
+ });
7905
+ }
7906
+ /**
7907
+ * @hidden
7908
+ * Create a MediaStreamTrack from the media stream with the given streamId and processed by videoFrameHandler.
7909
+ * The videoFrameHandler will receive metadata of the video frame.
7910
+ *
7911
+ * @internal
7912
+ * Limited to Microsoft-internal use
7913
+ */
7914
+ function processMediaStreamWithMetadata(streamId, videoFrameHandler, notifyError) {
7915
+ return videoUtils_awaiter(this, void 0, void 0, function () {
7916
+ var _a;
7917
+ return videoUtils_generator(this, function (_b) {
7918
+ switch (_b.label) {
7919
+ case 0:
7920
+ _a = createProcessedStreamGenerator;
7921
+ return [4 /*yield*/, getInputVideoTrack(streamId, notifyError)];
7922
+ case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), new TransformerWithMetadata(notifyError, videoFrameHandler)])];
7901
7923
  }
7902
7924
  });
7903
7925
  });
@@ -7942,7 +7964,7 @@ function getInputVideoTrack(streamId, notifyError) {
7942
7964
  * The processed frames are then enqueued to the generator.
7943
7965
  * The generator can be registered back to the media stream so that the host can get the processed frames.
7944
7966
  */
7945
- function createProcessedStreamGenerator(videoTrack, videoFrameHandler, notifyError) {
7967
+ function createProcessedStreamGenerator(videoTrack, transformer) {
7946
7968
  if (inServerSideRenderingEnvironment()) {
7947
7969
  throw errorNotSupportedOnPlatform;
7948
7970
  }
@@ -7952,48 +7974,301 @@ function createProcessedStreamGenerator(videoTrack, videoFrameHandler, notifyErr
7952
7974
  var MediaStreamTrackGenerator = window['MediaStreamTrackGenerator'];
7953
7975
  var generator = new MediaStreamTrackGenerator({ kind: 'video' });
7954
7976
  var sink = generator.writable;
7955
- source
7956
- .pipeThrough(new TransformStream({
7957
- transform: function (originalFrame, controller) {
7958
- return videoUtils_awaiter(this, void 0, void 0, function () {
7959
- var timestamp, frameProcessedByApp, processedFrame, error_2;
7960
- return videoUtils_generator(this, function (_a) {
7961
- switch (_a.label) {
7962
- case 0:
7963
- timestamp = originalFrame.timestamp;
7964
- if (!(timestamp !== null)) return [3 /*break*/, 5];
7965
- _a.label = 1;
7966
- case 1:
7967
- _a.trys.push([1, 3, , 4]);
7968
- return [4 /*yield*/, videoFrameHandler({ videoFrame: originalFrame })];
7969
- case 2:
7970
- frameProcessedByApp = _a.sent();
7971
- processedFrame = new VideoFrame(frameProcessedByApp, {
7972
- // we need the timestamp to be unchanged from the oirginal frame, so we explicitly set it here.
7973
- timestamp: timestamp,
7974
- });
7975
- controller.enqueue(processedFrame);
7976
- originalFrame.close();
7977
- frameProcessedByApp.close();
7978
- return [3 /*break*/, 4];
7979
- case 3:
7980
- error_2 = _a.sent();
7981
- originalFrame.close();
7982
- notifyError(error_2);
7983
- return [3 /*break*/, 4];
7984
- case 4: return [3 /*break*/, 6];
7985
- case 5:
7986
- notifyError('timestamp of the original video frame is null');
7987
- _a.label = 6;
7988
- case 6: return [2 /*return*/];
7989
- }
7990
- });
7991
- });
7992
- },
7993
- }))
7994
- .pipeTo(sink);
7977
+ source.pipeThrough(new TransformStream(transformer)).pipeTo(sink);
7995
7978
  return generator;
7996
7979
  }
7980
+ /**
7981
+ * @hidden
7982
+ * Error messages during video frame transformation.
7983
+ */
7984
+ var VideoFrameTransformErrors;
7985
+ (function (VideoFrameTransformErrors) {
7986
+ VideoFrameTransformErrors["TimestampIsNull"] = "timestamp of the original video frame is null";
7987
+ VideoFrameTransformErrors["UnsupportedVideoFramePixelFormat"] = "Unsupported video frame pixel format";
7988
+ })(VideoFrameTransformErrors || (VideoFrameTransformErrors = {}));
7989
+ var DefaultTransformer = /** @class */ (function () {
7990
+ function DefaultTransformer(notifyError, videoFrameHandler) {
7991
+ var _this = this;
7992
+ this.notifyError = notifyError;
7993
+ this.videoFrameHandler = videoFrameHandler;
7994
+ this.transform = function (originalFrame, controller) { return videoUtils_awaiter(_this, void 0, void 0, function () {
7995
+ var timestamp, frameProcessedByApp, processedFrame, error_2;
7996
+ return videoUtils_generator(this, function (_a) {
7997
+ switch (_a.label) {
7998
+ case 0:
7999
+ timestamp = originalFrame.timestamp;
8000
+ if (!(timestamp !== null)) return [3 /*break*/, 5];
8001
+ _a.label = 1;
8002
+ case 1:
8003
+ _a.trys.push([1, 3, , 4]);
8004
+ return [4 /*yield*/, this.videoFrameHandler({ videoFrame: originalFrame })];
8005
+ case 2:
8006
+ frameProcessedByApp = _a.sent();
8007
+ processedFrame = new VideoFrame(frameProcessedByApp, {
8008
+ // we need the timestamp to be unchanged from the oirginal frame, so we explicitly set it here.
8009
+ timestamp: timestamp,
8010
+ });
8011
+ controller.enqueue(processedFrame);
8012
+ originalFrame.close();
8013
+ frameProcessedByApp.close();
8014
+ return [3 /*break*/, 4];
8015
+ case 3:
8016
+ error_2 = _a.sent();
8017
+ originalFrame.close();
8018
+ this.notifyError(error_2);
8019
+ return [3 /*break*/, 4];
8020
+ case 4: return [3 /*break*/, 6];
8021
+ case 5:
8022
+ this.notifyError(VideoFrameTransformErrors.TimestampIsNull);
8023
+ _a.label = 6;
8024
+ case 6: return [2 /*return*/];
8025
+ }
8026
+ });
8027
+ }); };
8028
+ }
8029
+ return DefaultTransformer;
8030
+ }());
8031
+ /**
8032
+ * @hidden
8033
+ * Utility class to parse the header of a one-texture-input texture.
8034
+ */
8035
+ var OneTextureHeader = /** @class */ (function () {
8036
+ function OneTextureHeader(headerBuffer, notifyError) {
8037
+ this.headerBuffer = headerBuffer;
8038
+ this.notifyError = notifyError;
8039
+ // Identifier for the texture layout, which is the 4-byte ASCII string "oti1" hardcoded by the host
8040
+ // (oti1 stands for "one texture input version 1")
8041
+ this.ONE_TEXTURE_INPUT_ID = 0x6f746931;
8042
+ this.INVALID_HEADER_ERROR = 'Invalid video frame header';
8043
+ this.UNSUPPORTED_LAYOUT_ERROR = 'Unsupported texture layout';
8044
+ this.headerDataView = new Uint32Array(headerBuffer);
8045
+ // headerDataView will contain the following data:
8046
+ // 0: oneTextureLayoutId
8047
+ // 1: version
8048
+ // 2: frameRowOffset
8049
+ // 3: frameFormat
8050
+ // 4: frameWidth
8051
+ // 5: frameHeight
8052
+ // 6: multiStreamHeaderRowOffset
8053
+ // 7: multiStreamCount
8054
+ if (this.headerDataView.length < 8) {
8055
+ this.notifyError(this.INVALID_HEADER_ERROR);
8056
+ throw new Error(this.INVALID_HEADER_ERROR);
8057
+ }
8058
+ // ensure the texture layout is supported
8059
+ if (this.headerDataView[0] !== this.ONE_TEXTURE_INPUT_ID) {
8060
+ this.notifyError(this.UNSUPPORTED_LAYOUT_ERROR);
8061
+ throw new Error(this.UNSUPPORTED_LAYOUT_ERROR);
8062
+ }
8063
+ }
8064
+ Object.defineProperty(OneTextureHeader.prototype, "oneTextureLayoutId", {
8065
+ get: function () {
8066
+ return this.headerDataView[0];
8067
+ },
8068
+ enumerable: false,
8069
+ configurable: true
8070
+ });
8071
+ Object.defineProperty(OneTextureHeader.prototype, "version", {
8072
+ get: function () {
8073
+ return this.headerDataView[1];
8074
+ },
8075
+ enumerable: false,
8076
+ configurable: true
8077
+ });
8078
+ Object.defineProperty(OneTextureHeader.prototype, "frameRowOffset", {
8079
+ get: function () {
8080
+ return this.headerDataView[2];
8081
+ },
8082
+ enumerable: false,
8083
+ configurable: true
8084
+ });
8085
+ Object.defineProperty(OneTextureHeader.prototype, "frameFormat", {
8086
+ get: function () {
8087
+ return this.headerDataView[3];
8088
+ },
8089
+ enumerable: false,
8090
+ configurable: true
8091
+ });
8092
+ Object.defineProperty(OneTextureHeader.prototype, "frameWidth", {
8093
+ get: function () {
8094
+ return this.headerDataView[4];
8095
+ },
8096
+ enumerable: false,
8097
+ configurable: true
8098
+ });
8099
+ Object.defineProperty(OneTextureHeader.prototype, "frameHeight", {
8100
+ get: function () {
8101
+ return this.headerDataView[5];
8102
+ },
8103
+ enumerable: false,
8104
+ configurable: true
8105
+ });
8106
+ Object.defineProperty(OneTextureHeader.prototype, "multiStreamHeaderRowOffset", {
8107
+ get: function () {
8108
+ return this.headerDataView[6];
8109
+ },
8110
+ enumerable: false,
8111
+ configurable: true
8112
+ });
8113
+ Object.defineProperty(OneTextureHeader.prototype, "multiStreamCount", {
8114
+ get: function () {
8115
+ return this.headerDataView[7];
8116
+ },
8117
+ enumerable: false,
8118
+ configurable: true
8119
+ });
8120
+ return OneTextureHeader;
8121
+ }());
8122
+ /**
8123
+ * @hidden
8124
+ * Utility class to parse the metadata of a one-texture-input texture.
8125
+ */
8126
+ var OneTextureMetadata = /** @class */ (function () {
8127
+ function OneTextureMetadata(metadataBuffer, streamCount) {
8128
+ this.metadataMap = new Map();
8129
+ // Stream id for audio inference metadata, which is the 4-byte ASCII string "1dia" hardcoded by the host
8130
+ // (1dia stands for "audio inference data version 1")
8131
+ this.AUDIO_INFERENCE_RESULT_STREAM_ID = 0x31646961;
8132
+ var metadataDataView = new Uint32Array(metadataBuffer);
8133
+ for (var i = 0, index = 0; i < streamCount; i++) {
8134
+ var streamId = metadataDataView[index++];
8135
+ var streamDataOffset = metadataDataView[index++];
8136
+ var streamDataSize = metadataDataView[index++];
8137
+ var streamData = new Uint8Array(metadataBuffer, streamDataOffset, streamDataSize);
8138
+ this.metadataMap.set(streamId, streamData);
8139
+ }
8140
+ }
8141
+ Object.defineProperty(OneTextureMetadata.prototype, "audioInferenceResult", {
8142
+ get: function () {
8143
+ return this.metadataMap.get(this.AUDIO_INFERENCE_RESULT_STREAM_ID);
8144
+ },
8145
+ enumerable: false,
8146
+ configurable: true
8147
+ });
8148
+ return OneTextureMetadata;
8149
+ }());
8150
+ var TransformerWithMetadata = /** @class */ (function () {
8151
+ function TransformerWithMetadata(notifyError, videoFrameHandler) {
8152
+ var _this = this;
8153
+ this.notifyError = notifyError;
8154
+ this.videoFrameHandler = videoFrameHandler;
8155
+ this.shouldDiscardAudioInferenceResult = false;
8156
+ this.transform = function (originalFrame, controller) { return videoUtils_awaiter(_this, void 0, void 0, function () {
8157
+ var timestamp, _a, videoFrame, _b, _c, audioInferenceResult, frameProcessedByApp, processedFrame, error_3;
8158
+ return videoUtils_generator(this, function (_d) {
8159
+ switch (_d.label) {
8160
+ case 0:
8161
+ timestamp = originalFrame.timestamp;
8162
+ if (!(timestamp !== null)) return [3 /*break*/, 6];
8163
+ _d.label = 1;
8164
+ case 1:
8165
+ _d.trys.push([1, 4, , 5]);
8166
+ return [4 /*yield*/, this.extractVideoFrameAndMetadata(originalFrame)];
8167
+ case 2:
8168
+ _a = _d.sent(), videoFrame = _a.videoFrame, _b = _a.metadata, _c = _b === void 0 ? {} : _b, audioInferenceResult = _c.audioInferenceResult;
8169
+ return [4 /*yield*/, this.videoFrameHandler({ videoFrame: videoFrame, audioInferenceResult: audioInferenceResult })];
8170
+ case 3:
8171
+ frameProcessedByApp = _d.sent();
8172
+ processedFrame = new VideoFrame(frameProcessedByApp, {
8173
+ // we need the timestamp to be unchanged from the oirginal frame, so we explicitly set it here.
8174
+ timestamp: timestamp,
8175
+ });
8176
+ controller.enqueue(processedFrame);
8177
+ videoFrame.close();
8178
+ originalFrame.close();
8179
+ frameProcessedByApp.close();
8180
+ return [3 /*break*/, 5];
8181
+ case 4:
8182
+ error_3 = _d.sent();
8183
+ originalFrame.close();
8184
+ this.notifyError(error_3);
8185
+ return [3 /*break*/, 5];
8186
+ case 5: return [3 /*break*/, 7];
8187
+ case 6:
8188
+ this.notifyError(VideoFrameTransformErrors.TimestampIsNull);
8189
+ _d.label = 7;
8190
+ case 7: return [2 /*return*/];
8191
+ }
8192
+ });
8193
+ }); };
8194
+ /**
8195
+ * @hidden
8196
+ * Extract video frame and metadata from the given texture.
8197
+ * The given texure should be in NV12 format and the layout of the texture should be:
8198
+ * | Texture layout |
8199
+ * | :--- |
8200
+ * | Header |
8201
+ * | Real video frame data |
8202
+ * | Metadata |
8203
+ *
8204
+ * The header data is in the first two rows with the following format:
8205
+ * | oneTextureLayoutId | version | frameRowOffset | frameFormat | frameWidth | frameHeight | multiStreamHeaderRowOffset | multiStreamCount | ... |
8206
+ * | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
8207
+ * | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | ... |
8208
+ *
8209
+ * After header, it comes with the real video frame data.
8210
+ * At the end of the texture, it comes with the metadata. The metadata section can contain multiple types of metadata.
8211
+ * Each type of metadata is called a stream. The section is in the following format:
8212
+ * | stream1.id | stream1.dataOffset | stream1.dataSize | stream2.id | stream2.dataOffset | stream2.dataSize | ... | stream1.data | stream2.data | ... |
8213
+ * | :---: | :---: | :---: | :---: | :---: | :---: |:---:| :---: | :---: |:---:|
8214
+ * | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | ... | ... | ... | ... |
8215
+ *
8216
+ * @internal
8217
+ * Limited to Microsoft-internal use
8218
+ */
8219
+ this.extractVideoFrameAndMetadata = function (texture) { return videoUtils_awaiter(_this, void 0, void 0, function () {
8220
+ var headerRect, headerBuffer, header, metadataRect, metadataBuffer, metadata;
8221
+ return videoUtils_generator(this, function (_a) {
8222
+ switch (_a.label) {
8223
+ case 0:
8224
+ if (inServerSideRenderingEnvironment()) {
8225
+ throw errorNotSupportedOnPlatform;
8226
+ }
8227
+ if (texture.format !== 'NV12') {
8228
+ this.notifyError(VideoFrameTransformErrors.UnsupportedVideoFramePixelFormat);
8229
+ throw new Error(VideoFrameTransformErrors.UnsupportedVideoFramePixelFormat);
8230
+ }
8231
+ headerRect = { x: 0, y: 0, width: texture.codedWidth, height: 2 };
8232
+ headerBuffer = new ArrayBuffer((headerRect.width * headerRect.height * 3) / 2);
8233
+ return [4 /*yield*/, texture.copyTo(headerBuffer, { rect: headerRect })];
8234
+ case 1:
8235
+ _a.sent();
8236
+ header = new OneTextureHeader(headerBuffer, this.notifyError);
8237
+ metadataRect = {
8238
+ x: 0,
8239
+ y: header.multiStreamHeaderRowOffset,
8240
+ width: texture.codedWidth,
8241
+ height: texture.codedHeight - header.multiStreamHeaderRowOffset,
8242
+ };
8243
+ metadataBuffer = new ArrayBuffer((metadataRect.width * metadataRect.height * 3) / 2);
8244
+ return [4 /*yield*/, texture.copyTo(metadataBuffer, { rect: metadataRect })];
8245
+ case 2:
8246
+ _a.sent();
8247
+ metadata = new OneTextureMetadata(metadataBuffer, header.multiStreamCount);
8248
+ return [2 /*return*/, {
8249
+ videoFrame: new VideoFrame(texture, {
8250
+ timestamp: texture.timestamp,
8251
+ visibleRect: {
8252
+ x: 0,
8253
+ y: header.frameRowOffset,
8254
+ width: header.frameWidth,
8255
+ height: header.frameHeight,
8256
+ },
8257
+ }),
8258
+ metadata: {
8259
+ audioInferenceResult: this.shouldDiscardAudioInferenceResult ? undefined : metadata.audioInferenceResult,
8260
+ },
8261
+ }];
8262
+ }
8263
+ });
8264
+ }); };
8265
+ registerHandler('video.mediaStream.audioInferenceDiscardStatusChange', function (_a) {
8266
+ var discardAudioInferenceResult = _a.discardAudioInferenceResult;
8267
+ _this.shouldDiscardAudioInferenceResult = discardAudioInferenceResult;
8268
+ });
8269
+ }
8270
+ return TransformerWithMetadata;
8271
+ }());
7997
8272
  /**
7998
8273
  * @hidden
7999
8274
  */
@@ -8001,11 +8276,11 @@ function createEffectParameterChangeCallback(callback) {
8001
8276
  return function (effectId, effectParam) {
8002
8277
  callback(effectId, effectParam)
8003
8278
  .then(function () {
8004
- sendMessageToParent('video.videoEffectReadiness', [true, effectId]);
8279
+ sendMessageToParent('video.videoEffectReadiness', [true, effectId, undefined, effectParam]);
8005
8280
  })
8006
8281
  .catch(function (reason) {
8007
8282
  var validReason = reason in video.EffectFailureReason ? reason : video.EffectFailureReason.InitializationFailure;
8008
- sendMessageToParent('video.videoEffectReadiness', [false, effectId, validReason]);
8283
+ sendMessageToParent('video.videoEffectReadiness', [false, effectId, validReason, effectParam]);
8009
8284
  });
8010
8285
  };
8011
8286
  }
@@ -9571,6 +9846,423 @@ function ensureSupported() {
9571
9846
  }
9572
9847
  }
9573
9848
 
9849
+ ;// CONCATENATED MODULE: ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/regex.js
9850
+ /* harmony default export */ const regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
9851
+ ;// CONCATENATED MODULE: ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/validate.js
9852
+
9853
+
9854
+ function validate_validate(uuid) {
9855
+ return typeof uuid === 'string' && regex.test(uuid);
9856
+ }
9857
+
9858
+ /* harmony default export */ const esm_browser_validate = (validate_validate);
9859
+ ;// CONCATENATED MODULE: ./src/internal/marketplaceUtils.ts
9860
+ var marketplaceUtils_assign = (undefined && undefined.__assign) || function () {
9861
+ marketplaceUtils_assign = Object.assign || function(t) {
9862
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9863
+ s = arguments[i];
9864
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
9865
+ t[p] = s[p];
9866
+ }
9867
+ return t;
9868
+ };
9869
+ return marketplaceUtils_assign.apply(this, arguments);
9870
+ };
9871
+ var marketplaceUtils_rest = (undefined && undefined.__rest) || function (s, e) {
9872
+ var t = {};
9873
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
9874
+ t[p] = s[p];
9875
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
9876
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9877
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9878
+ t[p[i]] = s[p[i]];
9879
+ }
9880
+ return t;
9881
+ };
9882
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
9883
+ /* eslint-disable @typescript-eslint/no-explicit-any */
9884
+
9885
+
9886
+ /**
9887
+ * @hidden
9888
+ * deserialize the cart data:
9889
+ * - convert url properties from string to URL
9890
+ * @param cartItems The cart items
9891
+ *
9892
+ * @internal
9893
+ * Limited to Microsoft-internal use
9894
+ */
9895
+ function deserializeCart(cartData) {
9896
+ try {
9897
+ cartData.cartItems = deserializeCartItems(cartData.cartItems);
9898
+ return cartData;
9899
+ }
9900
+ catch (e) {
9901
+ throw new Error('Error deserializing cart');
9902
+ }
9903
+ }
9904
+ /**
9905
+ * @hidden
9906
+ * deserialize the cart items:
9907
+ * - convert url properties from string to URL
9908
+ * @param cartItems The cart items
9909
+ *
9910
+ * @internal
9911
+ * Limited to Microsoft-internal use
9912
+ */
9913
+ function deserializeCartItems(cartItemsData) {
9914
+ return cartItemsData.map(function (cartItem) {
9915
+ if (cartItem.imageURL) {
9916
+ var url = new URL(cartItem.imageURL);
9917
+ cartItem.imageURL = url;
9918
+ }
9919
+ if (cartItem.accessories) {
9920
+ cartItem.accessories = deserializeCartItems(cartItem.accessories);
9921
+ }
9922
+ return cartItem;
9923
+ });
9924
+ }
9925
+ /**
9926
+ * @hidden
9927
+ * serialize the cart items:
9928
+ * - make URL properties to string
9929
+ * @param cartItems The cart items
9930
+ *
9931
+ * @internal
9932
+ * Limited to Microsoft-internal use
9933
+ */
9934
+ var serializeCartItems = function (cartItems) {
9935
+ try {
9936
+ return cartItems.map(function (cartItem) {
9937
+ var imageURL = cartItem.imageURL, accessories = cartItem.accessories, rest = marketplaceUtils_rest(cartItem, ["imageURL", "accessories"]);
9938
+ var cartItemsData = marketplaceUtils_assign({}, rest);
9939
+ if (imageURL) {
9940
+ cartItemsData.imageURL = imageURL.href;
9941
+ }
9942
+ if (accessories) {
9943
+ cartItemsData.accessories = serializeCartItems(accessories);
9944
+ }
9945
+ return cartItemsData;
9946
+ });
9947
+ }
9948
+ catch (e) {
9949
+ throw new Error('Error serializing cart items');
9950
+ }
9951
+ };
9952
+ /**
9953
+ * @hidden
9954
+ * Validate the cart item properties are valid
9955
+ * @param cartItems The cart items
9956
+ *
9957
+ * @internal
9958
+ * Limited to Microsoft-internal use
9959
+ */
9960
+ function validateCartItems(cartItems) {
9961
+ if (!Array.isArray(cartItems) || cartItems.length === 0) {
9962
+ throw new Error('cartItems must be a non-empty array');
9963
+ }
9964
+ for (var _i = 0, cartItems_1 = cartItems; _i < cartItems_1.length; _i++) {
9965
+ var cartItem = cartItems_1[_i];
9966
+ validateBasicCartItem(cartItem);
9967
+ validateAccessoryItems(cartItem.accessories);
9968
+ }
9969
+ }
9970
+ /**
9971
+ * @hidden
9972
+ * Validate accessories
9973
+ * @param accessoryItems The accessories to be validated
9974
+ *
9975
+ * @internal
9976
+ * Limited to Microsoft-internal use
9977
+ */
9978
+ function validateAccessoryItems(accessoryItems) {
9979
+ if (accessoryItems === null || accessoryItems === undefined) {
9980
+ return;
9981
+ }
9982
+ if (!Array.isArray(accessoryItems) || accessoryItems.length === 0) {
9983
+ throw new Error('CartItem.accessories must be a non-empty array');
9984
+ }
9985
+ for (var _i = 0, accessoryItems_1 = accessoryItems; _i < accessoryItems_1.length; _i++) {
9986
+ var accessoryItem = accessoryItems_1[_i];
9987
+ if (accessoryItem['accessories']) {
9988
+ throw new Error('Item in CartItem.accessories cannot have accessories');
9989
+ }
9990
+ validateBasicCartItem(accessoryItem);
9991
+ }
9992
+ }
9993
+ /**
9994
+ * @hidden
9995
+ * Validate the basic cart item properties are valid
9996
+ * @param basicCartItem The basic cart item
9997
+ *
9998
+ * @internal
9999
+ * Limited to Microsoft-internal use
10000
+ */
10001
+ function validateBasicCartItem(basicCartItem) {
10002
+ if (!basicCartItem.id) {
10003
+ throw new Error('cartItem.id must not be empty');
10004
+ }
10005
+ if (!basicCartItem.name) {
10006
+ throw new Error('cartItem.name must not be empty');
10007
+ }
10008
+ validatePrice(basicCartItem.price);
10009
+ validateQuantity(basicCartItem.quantity);
10010
+ }
10011
+ /**
10012
+ * @hidden
10013
+ * Validate the id is valid
10014
+ * @param id A uuid string
10015
+ *
10016
+ * @internal
10017
+ * Limited to Microsoft-internal use
10018
+ */
10019
+ function validateUuid(id) {
10020
+ if (id === undefined || id === null) {
10021
+ return;
10022
+ }
10023
+ if (!id) {
10024
+ throw new Error('id must not be empty');
10025
+ }
10026
+ if (esm_browser_validate(id) === false) {
10027
+ throw new Error('id must be a valid UUID');
10028
+ }
10029
+ }
10030
+ /**
10031
+ * @hidden
10032
+ * Validate the cart item properties are valid
10033
+ * @param price The price to be validated
10034
+ *
10035
+ * @internal
10036
+ * Limited to Microsoft-internal use
10037
+ */
10038
+ function validatePrice(price) {
10039
+ if (typeof price !== 'number' || price < 0) {
10040
+ throw new Error("price ".concat(price, " must be a number not less than 0"));
10041
+ }
10042
+ if (parseFloat(price.toFixed(3)) !== price) {
10043
+ throw new Error("price ".concat(price, " must have at most 3 decimal places"));
10044
+ }
10045
+ }
10046
+ /**
10047
+ * @hidden
10048
+ * Validate quantity
10049
+ * @param quantity The quantity to be validated
10050
+ *
10051
+ * @internal
10052
+ * Limited to Microsoft-internal use
10053
+ */
10054
+ function validateQuantity(quantity) {
10055
+ if (typeof quantity !== 'number' || quantity <= 0 || parseInt(quantity.toString()) !== quantity) {
10056
+ throw new Error("quantity ".concat(quantity, " must be an integer greater than 0"));
10057
+ }
10058
+ }
10059
+ /**
10060
+ * @hidden
10061
+ * Validate cart status
10062
+ * @param cartStatus The cartStatus to be validated
10063
+ *
10064
+ * @internal
10065
+ * Limited to Microsoft-internal use
10066
+ */
10067
+ function validateCartStatus(cartStatus) {
10068
+ if (!Object.values(marketplace.CartStatus).includes(cartStatus)) {
10069
+ throw new Error("cartStatus ".concat(cartStatus, " is not valid"));
10070
+ }
10071
+ }
10072
+
10073
+ ;// CONCATENATED MODULE: ./src/public/marketplace.ts
10074
+ var marketplace_assign = (undefined && undefined.__assign) || function () {
10075
+ marketplace_assign = Object.assign || function(t) {
10076
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
10077
+ s = arguments[i];
10078
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10079
+ t[p] = s[p];
10080
+ }
10081
+ return t;
10082
+ };
10083
+ return marketplace_assign.apply(this, arguments);
10084
+ };
10085
+
10086
+
10087
+
10088
+
10089
+
10090
+ /**
10091
+ * @hidden
10092
+ * Namespace for an app to support a checkout flow by interacting with the marketplace cart in the host.
10093
+ * @beta
10094
+ */
10095
+ var marketplace;
10096
+ (function (marketplace) {
10097
+ /**
10098
+ * @hidden
10099
+ * the version of the current cart interface
10100
+ * which is forced to send to the host in the calls.
10101
+ * @internal
10102
+ * Limited to Microsoft-internal use
10103
+ * @beta
10104
+ */
10105
+ marketplace.cartVersion = {
10106
+ /**
10107
+ * @hidden
10108
+ * Represents the major version of the current cart interface,
10109
+ * it is increased when incompatible interface update happens.
10110
+ */
10111
+ majorVersion: 1,
10112
+ /**
10113
+ * @hidden
10114
+ * The minor version of the current cart interface, which is compatible
10115
+ * with the previous minor version in the same major version.
10116
+ */
10117
+ minorVersion: 1,
10118
+ };
10119
+ /**
10120
+ * @hidden
10121
+ * Represents the persona creating the cart.
10122
+ * @beta
10123
+ */
10124
+ var Intent;
10125
+ (function (Intent) {
10126
+ /**
10127
+ * @hidden
10128
+ * The cart is created by admin of an organization in Teams Admin Center.
10129
+ */
10130
+ Intent["TACAdminUser"] = "TACAdminUser";
10131
+ /**
10132
+ * @hidden
10133
+ * The cart is created by admin of an organization in Teams.
10134
+ */
10135
+ Intent["TeamsAdminUser"] = "TeamsAdminUser";
10136
+ /**
10137
+ * @hidden
10138
+ * The cart is created by end user of an organization in Teams.
10139
+ */
10140
+ Intent["TeamsEndUser"] = "TeamsEndUser";
10141
+ })(Intent = marketplace.Intent || (marketplace.Intent = {}));
10142
+ /**
10143
+ * @hidden
10144
+ * Represents the status of the cart.
10145
+ * @beta
10146
+ */
10147
+ var CartStatus;
10148
+ (function (CartStatus) {
10149
+ /**
10150
+ * @hidden
10151
+ * Cart is created but not checked out yet.
10152
+ */
10153
+ CartStatus["Open"] = "Open";
10154
+ /**
10155
+ * @hidden
10156
+ * Cart is checked out but not completed yet.
10157
+ */
10158
+ CartStatus["Processing"] = "Processing";
10159
+ /**
10160
+ * @hidden
10161
+ * Indicate checking out is completed and the host should
10162
+ * return a new cart in the next getCart call.
10163
+ */
10164
+ CartStatus["Processed"] = "Processed";
10165
+ /**
10166
+ * @hidden
10167
+ * Indicate checking out process is manually cancelled by the user
10168
+ */
10169
+ CartStatus["Closed"] = "Closed";
10170
+ /**
10171
+ * @hidden
10172
+ * Indicate checking out is failed and the host should
10173
+ * return a new cart in the next getCart call.
10174
+ */
10175
+ CartStatus["Error"] = "Error";
10176
+ })(CartStatus = marketplace.CartStatus || (marketplace.CartStatus = {}));
10177
+ /**
10178
+ * @hidden
10179
+ * Get the cart object owned by the host to checkout.
10180
+ * @returns A promise of the cart object in the cartVersion.
10181
+ * @beta
10182
+ */
10183
+ function getCart() {
10184
+ ensureInitialized(runtime, FrameContexts.content, FrameContexts.task);
10185
+ if (!isSupported()) {
10186
+ throw errorNotSupportedOnPlatform;
10187
+ }
10188
+ return sendAndHandleSdkError('marketplace.getCart', marketplace.cartVersion).then(deserializeCart);
10189
+ }
10190
+ marketplace.getCart = getCart;
10191
+ /**
10192
+ * @hidden
10193
+ * Add or update cart items in the cart owned by the host.
10194
+ * @param addOrUpdateCartItemsParams Represents the parameters to update the cart items.
10195
+ * @returns A promise of the updated cart object in the cartVersion.
10196
+ * @beta
10197
+ */
10198
+ function addOrUpdateCartItems(addOrUpdateCartItemsParams) {
10199
+ ensureInitialized(runtime, FrameContexts.content, FrameContexts.task);
10200
+ if (!isSupported()) {
10201
+ throw errorNotSupportedOnPlatform;
10202
+ }
10203
+ if (!addOrUpdateCartItemsParams) {
10204
+ throw new Error('addOrUpdateCartItemsParams must be provided');
10205
+ }
10206
+ validateUuid(addOrUpdateCartItemsParams === null || addOrUpdateCartItemsParams === void 0 ? void 0 : addOrUpdateCartItemsParams.cartId);
10207
+ validateCartItems(addOrUpdateCartItemsParams === null || addOrUpdateCartItemsParams === void 0 ? void 0 : addOrUpdateCartItemsParams.cartItems);
10208
+ return sendAndHandleSdkError('marketplace.addOrUpdateCartItems', marketplace_assign(marketplace_assign({}, addOrUpdateCartItemsParams), { cartItems: serializeCartItems(addOrUpdateCartItemsParams.cartItems), cartVersion: marketplace.cartVersion })).then(deserializeCart);
10209
+ }
10210
+ marketplace.addOrUpdateCartItems = addOrUpdateCartItems;
10211
+ /**
10212
+ * @hidden
10213
+ * Remove cart items from the cart owned by the host.
10214
+ * @param removeCartItemsParams The parameters to remove the cart items.
10215
+ * @returns A promise of the updated cart object in the cartVersion.
10216
+ * @beta
10217
+ */
10218
+ function removeCartItems(removeCartItemsParams) {
10219
+ ensureInitialized(runtime, FrameContexts.content, FrameContexts.task);
10220
+ if (!isSupported()) {
10221
+ throw errorNotSupportedOnPlatform;
10222
+ }
10223
+ if (!removeCartItemsParams) {
10224
+ throw new Error('removeCartItemsParams must be provided');
10225
+ }
10226
+ validateUuid(removeCartItemsParams === null || removeCartItemsParams === void 0 ? void 0 : removeCartItemsParams.cartId);
10227
+ if (!Array.isArray(removeCartItemsParams === null || removeCartItemsParams === void 0 ? void 0 : removeCartItemsParams.cartItemIds) || (removeCartItemsParams === null || removeCartItemsParams === void 0 ? void 0 : removeCartItemsParams.cartItemIds.length) === 0) {
10228
+ throw new Error('cartItemIds must be a non-empty array');
10229
+ }
10230
+ return sendAndHandleSdkError('marketplace.removeCartItems', marketplace_assign(marketplace_assign({}, removeCartItemsParams), { cartVersion: marketplace.cartVersion })).then(deserializeCart);
10231
+ }
10232
+ marketplace.removeCartItems = removeCartItems;
10233
+ /**
10234
+ * @hidden
10235
+ * Update cart status in the cart owned by the host.
10236
+ * @param updateCartStatusParams The parameters to update the cart status.
10237
+ * @returns A promise of the updated cart object in the cartVersion.
10238
+ * @beta
10239
+ */
10240
+ function updateCartStatus(updateCartStatusParams) {
10241
+ ensureInitialized(runtime, FrameContexts.content, FrameContexts.task);
10242
+ if (!isSupported()) {
10243
+ throw errorNotSupportedOnPlatform;
10244
+ }
10245
+ if (!updateCartStatusParams) {
10246
+ throw new Error('updateCartStatusParams must be provided');
10247
+ }
10248
+ validateUuid(updateCartStatusParams === null || updateCartStatusParams === void 0 ? void 0 : updateCartStatusParams.cartId);
10249
+ validateCartStatus(updateCartStatusParams === null || updateCartStatusParams === void 0 ? void 0 : updateCartStatusParams.cartStatus);
10250
+ return sendAndHandleSdkError('marketplace.updateCartStatus', marketplace_assign(marketplace_assign({}, updateCartStatusParams), { cartVersion: marketplace.cartVersion })).then(deserializeCart);
10251
+ }
10252
+ marketplace.updateCartStatus = updateCartStatus;
10253
+ /**
10254
+ * @hidden
10255
+ * Checks if the marketplace capability is supported by the host.
10256
+ * @returns Boolean to represent whether the marketplace capability is supported.
10257
+ * @throws Error if {@linkcode app.initialize} has not successfully completed.
10258
+ * @beta
10259
+ */
10260
+ function isSupported() {
10261
+ return ensureInitialized(runtime) && runtime.supports.marketplace ? true : false;
10262
+ }
10263
+ marketplace.isSupported = isSupported;
10264
+ })(marketplace || (marketplace = {}));
10265
+
9574
10266
  ;// CONCATENATED MODULE: ./src/public/index.ts
9575
10267
 
9576
10268
 
@@ -9606,6 +10298,7 @@ function ensureSupported() {
9606
10298
 
9607
10299
 
9608
10300
 
10301
+
9609
10302
 
9610
10303
 
9611
10304
 
@@ -10841,6 +11534,43 @@ var teams;
10841
11534
  })(teams || (teams = {}));
10842
11535
 
10843
11536
  ;// CONCATENATED MODULE: ./src/private/videoEx.ts
11537
+ var videoEx_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
11538
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11539
+ return new (P || (P = Promise))(function (resolve, reject) {
11540
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11541
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11542
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11543
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11544
+ });
11545
+ };
11546
+ var videoEx_generator = (undefined && undefined.__generator) || function (thisArg, body) {
11547
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
11548
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
11549
+ function verb(n) { return function (v) { return step([n, v]); }; }
11550
+ function step(op) {
11551
+ if (f) throw new TypeError("Generator is already executing.");
11552
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
11553
+ 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;
11554
+ if (y = 0, t) op = [op[0] & 2, t.value];
11555
+ switch (op[0]) {
11556
+ case 0: case 1: t = op; break;
11557
+ case 4: _.label++; return { value: op[1], done: false };
11558
+ case 5: _.label++; y = op[1]; op = [0]; continue;
11559
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
11560
+ default:
11561
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
11562
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
11563
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
11564
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
11565
+ if (t[2]) _.ops.pop();
11566
+ _.trys.pop(); continue;
11567
+ }
11568
+ op = body.call(thisArg, _);
11569
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
11570
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
11571
+ }
11572
+ };
11573
+
10844
11574
 
10845
11575
 
10846
11576
 
@@ -10876,31 +11606,74 @@ var videoEx;
10876
11606
  * Register to process video frames
10877
11607
  * @beta
10878
11608
  *
10879
- * @param frameCallback - The callback to invoke when registerForVideoFrame has completed
10880
- * @param config - VideoFrameConfig to customize generated video frame parameters
11609
+ * @param parameters - Callbacks and configuration to process the video frames. A host may support either {@link VideoFrameHandler} or {@link VideoBufferHandler}, but not both.
11610
+ * To ensure the video effect works on all supported hosts, the video app must provide both {@link VideoFrameHandler} and {@link VideoBufferHandler}.
11611
+ * The host will choose the appropriate callback based on the host's capability.
10881
11612
  *
10882
11613
  * @internal
10883
11614
  * Limited to Microsoft-internal use
10884
11615
  */
10885
11616
  function registerForVideoFrame(parameters) {
10886
- ensureInitialized(runtime, FrameContexts.sidePanel);
11617
+ var _this = this;
11618
+ var _a, _b;
10887
11619
  if (!isSupported()) {
10888
11620
  throw errorNotSupportedOnPlatform;
10889
11621
  }
10890
- if (!parameters.videoBufferHandler) {
10891
- throw new Error('parameters.videoBufferHandler must be provided');
11622
+ if (!parameters.videoFrameHandler || !parameters.videoBufferHandler) {
11623
+ throw new Error('Both videoFrameHandler and videoBufferHandler must be provided');
10892
11624
  }
10893
- registerHandler('video.newVideoFrame', function (videoBufferData) {
10894
- if (videoBufferData) {
10895
- var timestamp_1 = videoBufferData.timestamp;
10896
- parameters.videoBufferHandler(videoBufferData, function () {
10897
- notifyVideoFrameProcessed(timestamp_1);
10898
- }, notifyError);
11625
+ if (ensureInitialized(runtime, FrameContexts.sidePanel)) {
11626
+ if ((_a = runtime.supports.video) === null || _a === void 0 ? void 0 : _a.mediaStream) {
11627
+ registerHandler('video.startVideoExtensibilityVideoStream', function (mediaStreamInfo) { return videoEx_awaiter(_this, void 0, void 0, function () {
11628
+ var streamId, metadataInTexture, generator, _a;
11629
+ var _b, _c;
11630
+ return videoEx_generator(this, function (_d) {
11631
+ switch (_d.label) {
11632
+ case 0:
11633
+ streamId = mediaStreamInfo.streamId, metadataInTexture = mediaStreamInfo.metadataInTexture;
11634
+ if (!metadataInTexture) return [3 /*break*/, 2];
11635
+ return [4 /*yield*/, processMediaStreamWithMetadata(streamId, parameters.videoFrameHandler, notifyError)];
11636
+ case 1:
11637
+ _a = _d.sent();
11638
+ return [3 /*break*/, 4];
11639
+ case 2: return [4 /*yield*/, processMediaStream(streamId, parameters.videoFrameHandler, notifyError)];
11640
+ case 3:
11641
+ _a = _d.sent();
11642
+ _d.label = 4;
11643
+ case 4:
11644
+ generator = _a;
11645
+ // register the video track with processed frames back to the stream
11646
+ !inServerSideRenderingEnvironment() &&
11647
+ ((_c = (_b = window['chrome']) === null || _b === void 0 ? void 0 : _b.webview) === null || _c === void 0 ? void 0 : _c.registerTextureStream(streamId, generator));
11648
+ return [2 /*return*/];
11649
+ }
11650
+ });
11651
+ }); }, false);
11652
+ sendMessageToParent('video.mediaStream.registerForVideoFrame', [parameters.config]);
11653
+ }
11654
+ else if ((_b = runtime.supports.video) === null || _b === void 0 ? void 0 : _b.sharedFrame) {
11655
+ registerHandler('video.newVideoFrame', function (videoBufferData) {
11656
+ if (videoBufferData) {
11657
+ var timestamp_1 = videoBufferData.timestamp;
11658
+ parameters.videoBufferHandler(normalizedVideoBufferData(videoBufferData), function () {
11659
+ notifyVideoFrameProcessed(timestamp_1);
11660
+ }, notifyError);
11661
+ }
11662
+ }, false);
11663
+ sendMessageToParent('video.registerForVideoFrame', [parameters.config]);
10899
11664
  }
10900
- }, false);
10901
- sendMessageToParent('video.registerForVideoFrame', [parameters.config]);
11665
+ else {
11666
+ // should not happen if isSupported() is true
11667
+ throw errorNotSupportedOnPlatform;
11668
+ }
11669
+ }
10902
11670
  }
10903
11671
  videoEx.registerForVideoFrame = registerForVideoFrame;
11672
+ function normalizedVideoBufferData(videoBufferData) {
11673
+ videoBufferData['videoFrameBuffer'] = videoBufferData['videoFrameBuffer'] || videoBufferData['data'];
11674
+ delete videoBufferData['data'];
11675
+ return videoBufferData;
11676
+ }
10904
11677
  /**
10905
11678
  * @hidden
10906
11679
  * Video extension should call this to notify host that the current selected effect parameter changed.