@microsoft/teams-js 2.15.0-beta.3 → 2.16.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.
@@ -1351,6 +1351,10 @@ var HostName;
1351
1351
  * Microsoft-internal test Host
1352
1352
  */
1353
1353
  HostName["orange"] = "Orange";
1354
+ /**
1355
+ * Microsoft connected workplace platform
1356
+ */
1357
+ HostName["places"] = "Places";
1354
1358
  /**
1355
1359
  * Teams
1356
1360
  */
@@ -1884,6 +1888,27 @@ function getBase64StringFromBlob(blob) {
1884
1888
  reader.readAsDataURL(blob);
1885
1889
  });
1886
1890
  }
1891
+ /**
1892
+ * Returns an SSR safe reference to the window object
1893
+ * @returns Window object reference
1894
+ */
1895
+ function ssrSafeWindow() {
1896
+ if (!inServerSideRenderingEnvironment()) {
1897
+ return window;
1898
+ }
1899
+ else {
1900
+ // This should NEVER actually be written.
1901
+ // If you EVER see this error in ANY log file, something has gone horribly wrong and a bug needs to be filed.
1902
+ throw new Error('window object undefined at SSR check');
1903
+ }
1904
+ }
1905
+ /**
1906
+ * Checks if running in a Server Side Environment
1907
+ * @returns True if running in a Server Side Environment
1908
+ */
1909
+ function inServerSideRenderingEnvironment() {
1910
+ return typeof window === 'undefined';
1911
+ }
1887
1912
 
1888
1913
  ;// CONCATENATED MODULE: ./src/public/runtime.ts
1889
1914
  /* eslint-disable @typescript-eslint/ban-types */
@@ -2182,7 +2207,7 @@ var _minRuntimeConfigToUninitialize = {
2182
2207
  * @hidden
2183
2208
  * Package version.
2184
2209
  */
2185
- var version = "2.15.0-beta.3";
2210
+ var version = "2.16.0-beta.0";
2186
2211
 
2187
2212
  ;// CONCATENATED MODULE: ./src/internal/internalAPIs.ts
2188
2213
 
@@ -2319,11 +2344,6 @@ function processAdditionalValidOrigins(validMessageOrigins) {
2319
2344
  GlobalVars.additionalValidOrigins = combinedOriginUrls;
2320
2345
  }
2321
2346
 
2322
- ;// CONCATENATED MODULE: ./src/private/inServerSideRenderingEnvironment.ts
2323
- function inServerSideRenderingEnvironment() {
2324
- return typeof window === 'undefined';
2325
- }
2326
-
2327
2347
  ;// CONCATENATED MODULE: ./src/public/authentication.ts
2328
2348
 
2329
2349
 
@@ -2331,6 +2351,7 @@ function inServerSideRenderingEnvironment() {
2331
2351
 
2332
2352
 
2333
2353
 
2354
+
2334
2355
  /**
2335
2356
  * Namespace to interact with the authentication-specific part of the SDK.
2336
2357
  *
@@ -2687,7 +2708,7 @@ var authentication;
2687
2708
  var link = document.createElement('a');
2688
2709
  link.href = decodeURIComponent(callbackUrl);
2689
2710
  if (link.host &&
2690
- link.host !== window.location.host &&
2711
+ link.host !== ssrSafeWindow().location.host &&
2691
2712
  link.host === 'outlook.office.com' &&
2692
2713
  link.search.indexOf('client_type=Win32_Outlook') > -1) {
2693
2714
  if (key && key === 'result') {
@@ -3337,143 +3358,6 @@ var menus;
3337
3358
  menus.isSupported = isSupported;
3338
3359
  })(menus || (menus = {}));
3339
3360
 
3340
- ;// CONCATENATED MODULE: ./src/public/teamsAPIs.ts
3341
-
3342
- // Conflict with some names
3343
-
3344
-
3345
-
3346
- /**
3347
- * Namespace containing the set of APIs that support Teams-specific functionalities.
3348
- */
3349
- var teamsCore;
3350
- (function (teamsCore) {
3351
- /**
3352
- * Enable print capability to support printing page using Ctrl+P and cmd+P
3353
- */
3354
- function enablePrintCapability() {
3355
- if (!GlobalVars.printCapabilityEnabled) {
3356
- ensureInitialized(runtime);
3357
- if (!isSupported()) {
3358
- throw errorNotSupportedOnPlatform;
3359
- }
3360
- GlobalVars.printCapabilityEnabled = true;
3361
- // adding ctrl+P and cmd+P handler
3362
- document.addEventListener('keydown', function (event) {
3363
- if ((event.ctrlKey || event.metaKey) && event.keyCode === 80) {
3364
- print();
3365
- event.cancelBubble = true;
3366
- event.preventDefault();
3367
- event.stopImmediatePropagation();
3368
- }
3369
- });
3370
- }
3371
- }
3372
- teamsCore.enablePrintCapability = enablePrintCapability;
3373
- /**
3374
- * default print handler
3375
- */
3376
- function print() {
3377
- if (typeof window !== 'undefined') {
3378
- window.print();
3379
- }
3380
- else {
3381
- // This codepath only exists to enable compilation in a server-side redered environment. In standard usage, the window object should never be undefined so this code path should never run.
3382
- // If this error has actually been thrown, something has gone very wrong and it is a bug
3383
- throw new Error('window object undefined at print call');
3384
- }
3385
- }
3386
- teamsCore.print = print;
3387
- /**
3388
- * Registers a handler to be called when the page has been requested to load.
3389
- *
3390
- * @remarks Check out [App Caching in Teams](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/build-tabs-for-meeting?tabs=desktop%2Cmeeting-chat-view-desktop%2Cmeeting-stage-view-desktop%2Cchannel-meeting-desktop#app-caching)
3391
- * for a more detailed explanation about using this API.
3392
- *
3393
- * @param handler - The handler to invoke when the page is loaded.
3394
- *
3395
- * @beta
3396
- */
3397
- function registerOnLoadHandler(handler) {
3398
- registerOnLoadHandlerHelper(handler, function () {
3399
- if (handler && !isSupported()) {
3400
- throw errorNotSupportedOnPlatform;
3401
- }
3402
- });
3403
- }
3404
- teamsCore.registerOnLoadHandler = registerOnLoadHandler;
3405
- /**
3406
- * @hidden
3407
- * Undocumented helper function with shared code between deprecated version and current version of the registerOnLoadHandler API.
3408
- *
3409
- * @internal
3410
- * Limited to Microsoft-internal use
3411
- *
3412
- * @param handler - The handler to invoke when the page is loaded.
3413
- * @param versionSpecificHelper - The helper function containing logic pertaining to a specific version of the API.
3414
- */
3415
- function registerOnLoadHandlerHelper(handler, versionSpecificHelper) {
3416
- // allow for registration cleanup even when not finished initializing
3417
- handler && ensureInitialized(runtime);
3418
- if (handler && versionSpecificHelper) {
3419
- versionSpecificHelper();
3420
- }
3421
- handlers_registerOnLoadHandler(handler);
3422
- }
3423
- teamsCore.registerOnLoadHandlerHelper = registerOnLoadHandlerHelper;
3424
- /**
3425
- * Registers a handler to be called before the page is unloaded.
3426
- *
3427
- * @remarks Check out [App Caching in Teams](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/build-tabs-for-meeting?tabs=desktop%2Cmeeting-chat-view-desktop%2Cmeeting-stage-view-desktop%2Cchannel-meeting-desktop#app-caching)
3428
- * for a more detailed explanation about using this API.
3429
- *
3430
- * @param handler - The handler to invoke before the page is unloaded. If this handler returns true the page should
3431
- * invoke the readyToUnload function provided to it once it's ready to be unloaded.
3432
- *
3433
- * @beta
3434
- */
3435
- function registerBeforeUnloadHandler(handler) {
3436
- registerBeforeUnloadHandlerHelper(handler, function () {
3437
- if (handler && !isSupported()) {
3438
- throw errorNotSupportedOnPlatform;
3439
- }
3440
- });
3441
- }
3442
- teamsCore.registerBeforeUnloadHandler = registerBeforeUnloadHandler;
3443
- /**
3444
- * @hidden
3445
- * Undocumented helper function with shared code between deprecated version and current version of the registerBeforeUnloadHandler API.
3446
- *
3447
- * @internal
3448
- * Limited to Microsoft-internal use
3449
- *
3450
- * @param handler - - The handler to invoke before the page is unloaded. If this handler returns true the page should
3451
- * invoke the readyToUnload function provided to it once it's ready to be unloaded.
3452
- * @param versionSpecificHelper - The helper function containing logic pertaining to a specific version of the API.
3453
- */
3454
- function registerBeforeUnloadHandlerHelper(handler, versionSpecificHelper) {
3455
- // allow for registration cleanup even when not finished initializing
3456
- handler && ensureInitialized(runtime);
3457
- if (handler && versionSpecificHelper) {
3458
- versionSpecificHelper();
3459
- }
3460
- handlers_registerBeforeUnloadHandler(handler);
3461
- }
3462
- teamsCore.registerBeforeUnloadHandlerHelper = registerBeforeUnloadHandlerHelper;
3463
- /**
3464
- * Checks if teamsCore capability is supported by the host
3465
- *
3466
- * @returns boolean to represent whether the teamsCore capability is supported
3467
- *
3468
- * @throws Error if {@linkcode app.initialize} has not successfully completed
3469
- *
3470
- */
3471
- function isSupported() {
3472
- return ensureInitialized(runtime) && runtime.supports.teamsCore ? true : false;
3473
- }
3474
- teamsCore.isSupported = isSupported;
3475
- })(teamsCore || (teamsCore = {}));
3476
-
3477
3361
  ;// CONCATENATED MODULE: ./src/public/app.ts
3478
3362
  /* eslint-disable @typescript-eslint/no-empty-function */
3479
3363
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
@@ -3492,9 +3376,6 @@ var teamsCore;
3492
3376
 
3493
3377
 
3494
3378
 
3495
-
3496
-
3497
-
3498
3379
  /**
3499
3380
  * Namespace to interact with app initialization and lifecycle.
3500
3381
  */
@@ -3703,24 +3584,7 @@ var app;
3703
3584
  if (!GlobalVars.initializeCalled) {
3704
3585
  return;
3705
3586
  }
3706
- if (GlobalVars.frameContext) {
3707
- /* eslint-disable strict-null-checks/all */ /* Fix tracked by 5730662 */
3708
- registerOnThemeChangeHandler(null);
3709
- pages.backStack.registerBackButtonHandler(null);
3710
- pages.registerFullScreenHandler(null);
3711
- teamsCore.registerBeforeUnloadHandler(null);
3712
- teamsCore.registerOnLoadHandler(null);
3713
- logs.registerGetLogHandler(null); /* Fix tracked by 5730662 */
3714
- /* eslint-enable strict-null-checks/all */
3715
- }
3716
- if (GlobalVars.frameContext === FrameContexts.settings) {
3717
- /* eslint-disable-next-line strict-null-checks/all */ /* Fix tracked by 5730662 */
3718
- pages.config.registerOnSaveHandler(null);
3719
- }
3720
- if (GlobalVars.frameContext === FrameContexts.remove) {
3721
- /* eslint-disable-next-line strict-null-checks/all */ /* Fix tracked by 5730662 */
3722
- pages.config.registerOnRemoveHandler(null);
3723
- }
3587
+ uninitializeHandlers();
3724
3588
  GlobalVars.initializeCalled = false;
3725
3589
  GlobalVars.initializeCompleted = false;
3726
3590
  GlobalVars.initializePromise = null;
@@ -4671,6 +4535,29 @@ var handlersLogger = getLogger('handlers');
4671
4535
  var HandlersPrivate = /** @class */ (function () {
4672
4536
  function HandlersPrivate() {
4673
4537
  }
4538
+ /**
4539
+ * @internal
4540
+ * Limited to Microsoft-internal use
4541
+ * Initializes the handlers.
4542
+ */
4543
+ HandlersPrivate.initializeHandlers = function () {
4544
+ // ::::::::::::::::::::MicrosoftTeams SDK Internal :::::::::::::::::
4545
+ HandlersPrivate.handlers['themeChange'] = handleThemeChange;
4546
+ HandlersPrivate.handlers['load'] = handleLoad;
4547
+ HandlersPrivate.handlers['beforeUnload'] = handleBeforeUnload;
4548
+ pages.backStack._initialize();
4549
+ };
4550
+ /**
4551
+ * @internal
4552
+ * Limited to Microsoft-internal use
4553
+ * Uninitializes the handlers.
4554
+ */
4555
+ HandlersPrivate.uninitializeHandlers = function () {
4556
+ HandlersPrivate.handlers = {};
4557
+ HandlersPrivate.themeChangeHandler = null;
4558
+ HandlersPrivate.loadHandler = null;
4559
+ HandlersPrivate.beforeUnloadHandler = null;
4560
+ };
4674
4561
  HandlersPrivate.handlers = {};
4675
4562
  return HandlersPrivate;
4676
4563
  }());
@@ -4679,11 +4566,14 @@ var HandlersPrivate = /** @class */ (function () {
4679
4566
  * Limited to Microsoft-internal use
4680
4567
  */
4681
4568
  function initializeHandlers() {
4682
- // ::::::::::::::::::::MicrosoftTeams SDK Internal :::::::::::::::::
4683
- HandlersPrivate.handlers['themeChange'] = handleThemeChange;
4684
- HandlersPrivate.handlers['load'] = handleLoad;
4685
- HandlersPrivate.handlers['beforeUnload'] = handleBeforeUnload;
4686
- pages.backStack._initialize();
4569
+ HandlersPrivate.initializeHandlers();
4570
+ }
4571
+ /**
4572
+ * @internal
4573
+ * Limited to Microsoft-internal use
4574
+ */
4575
+ function uninitializeHandlers() {
4576
+ HandlersPrivate.uninitializeHandlers();
4687
4577
  }
4688
4578
  var callHandlerLogger = handlersLogger.extend('callHandler');
4689
4579
  /**
@@ -4873,7 +4763,7 @@ function initializeCommunication(validMessageOrigins) {
4873
4763
  CommunicationPrivate.messageListener = function (evt) { return processMessage(evt); };
4874
4764
  // If we are in an iframe, our parent window is the one hosting us (i.e., window.parent); otherwise,
4875
4765
  // it's the window that opened us (i.e., window.opener)
4876
- Communication.currentWindow = Communication.currentWindow || window;
4766
+ Communication.currentWindow = Communication.currentWindow || ssrSafeWindow();
4877
4767
  Communication.parentWindow =
4878
4768
  Communication.currentWindow.parent !== Communication.currentWindow.self
4879
4769
  ? Communication.currentWindow.parent
@@ -7942,6 +7832,137 @@ var mail;
7942
7832
  })(ComposeMailType = mail.ComposeMailType || (mail.ComposeMailType = {}));
7943
7833
  })(mail || (mail = {}));
7944
7834
 
7835
+ ;// CONCATENATED MODULE: ./src/public/teamsAPIs.ts
7836
+
7837
+ // Conflict with some names
7838
+
7839
+
7840
+
7841
+
7842
+ /**
7843
+ * Namespace containing the set of APIs that support Teams-specific functionalities.
7844
+ */
7845
+ var teamsCore;
7846
+ (function (teamsCore) {
7847
+ /**
7848
+ * Enable print capability to support printing page using Ctrl+P and cmd+P
7849
+ */
7850
+ function enablePrintCapability() {
7851
+ if (!GlobalVars.printCapabilityEnabled) {
7852
+ ensureInitialized(runtime);
7853
+ if (!isSupported()) {
7854
+ throw errorNotSupportedOnPlatform;
7855
+ }
7856
+ GlobalVars.printCapabilityEnabled = true;
7857
+ // adding ctrl+P and cmd+P handler
7858
+ document.addEventListener('keydown', function (event) {
7859
+ if ((event.ctrlKey || event.metaKey) && event.keyCode === 80) {
7860
+ print();
7861
+ event.cancelBubble = true;
7862
+ event.preventDefault();
7863
+ event.stopImmediatePropagation();
7864
+ }
7865
+ });
7866
+ }
7867
+ }
7868
+ teamsCore.enablePrintCapability = enablePrintCapability;
7869
+ /**
7870
+ * default print handler
7871
+ */
7872
+ function print() {
7873
+ ssrSafeWindow().print();
7874
+ }
7875
+ teamsCore.print = print;
7876
+ /**
7877
+ * Registers a handler to be called when the page has been requested to load.
7878
+ *
7879
+ * @remarks Check out [App Caching in Teams](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/build-tabs-for-meeting?tabs=desktop%2Cmeeting-chat-view-desktop%2Cmeeting-stage-view-desktop%2Cchannel-meeting-desktop#app-caching)
7880
+ * for a more detailed explanation about using this API.
7881
+ *
7882
+ * @param handler - The handler to invoke when the page is loaded.
7883
+ *
7884
+ * @beta
7885
+ */
7886
+ function registerOnLoadHandler(handler) {
7887
+ registerOnLoadHandlerHelper(handler, function () {
7888
+ if (handler && !isSupported()) {
7889
+ throw errorNotSupportedOnPlatform;
7890
+ }
7891
+ });
7892
+ }
7893
+ teamsCore.registerOnLoadHandler = registerOnLoadHandler;
7894
+ /**
7895
+ * @hidden
7896
+ * Undocumented helper function with shared code between deprecated version and current version of the registerOnLoadHandler API.
7897
+ *
7898
+ * @internal
7899
+ * Limited to Microsoft-internal use
7900
+ *
7901
+ * @param handler - The handler to invoke when the page is loaded.
7902
+ * @param versionSpecificHelper - The helper function containing logic pertaining to a specific version of the API.
7903
+ */
7904
+ function registerOnLoadHandlerHelper(handler, versionSpecificHelper) {
7905
+ // allow for registration cleanup even when not finished initializing
7906
+ handler && ensureInitialized(runtime);
7907
+ if (handler && versionSpecificHelper) {
7908
+ versionSpecificHelper();
7909
+ }
7910
+ handlers_registerOnLoadHandler(handler);
7911
+ }
7912
+ teamsCore.registerOnLoadHandlerHelper = registerOnLoadHandlerHelper;
7913
+ /**
7914
+ * Registers a handler to be called before the page is unloaded.
7915
+ *
7916
+ * @remarks Check out [App Caching in Teams](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/build-tabs-for-meeting?tabs=desktop%2Cmeeting-chat-view-desktop%2Cmeeting-stage-view-desktop%2Cchannel-meeting-desktop#app-caching)
7917
+ * for a more detailed explanation about using this API.
7918
+ *
7919
+ * @param handler - The handler to invoke before the page is unloaded. If this handler returns true the page should
7920
+ * invoke the readyToUnload function provided to it once it's ready to be unloaded.
7921
+ *
7922
+ * @beta
7923
+ */
7924
+ function registerBeforeUnloadHandler(handler) {
7925
+ registerBeforeUnloadHandlerHelper(handler, function () {
7926
+ if (handler && !isSupported()) {
7927
+ throw errorNotSupportedOnPlatform;
7928
+ }
7929
+ });
7930
+ }
7931
+ teamsCore.registerBeforeUnloadHandler = registerBeforeUnloadHandler;
7932
+ /**
7933
+ * @hidden
7934
+ * Undocumented helper function with shared code between deprecated version and current version of the registerBeforeUnloadHandler API.
7935
+ *
7936
+ * @internal
7937
+ * Limited to Microsoft-internal use
7938
+ *
7939
+ * @param handler - - The handler to invoke before the page is unloaded. If this handler returns true the page should
7940
+ * invoke the readyToUnload function provided to it once it's ready to be unloaded.
7941
+ * @param versionSpecificHelper - The helper function containing logic pertaining to a specific version of the API.
7942
+ */
7943
+ function registerBeforeUnloadHandlerHelper(handler, versionSpecificHelper) {
7944
+ // allow for registration cleanup even when not finished initializing
7945
+ handler && ensureInitialized(runtime);
7946
+ if (handler && versionSpecificHelper) {
7947
+ versionSpecificHelper();
7948
+ }
7949
+ handlers_registerBeforeUnloadHandler(handler);
7950
+ }
7951
+ teamsCore.registerBeforeUnloadHandlerHelper = registerBeforeUnloadHandlerHelper;
7952
+ /**
7953
+ * Checks if teamsCore capability is supported by the host
7954
+ *
7955
+ * @returns boolean to represent whether the teamsCore capability is supported
7956
+ *
7957
+ * @throws Error if {@linkcode app.initialize} has not successfully completed
7958
+ *
7959
+ */
7960
+ function isSupported() {
7961
+ return ensureInitialized(runtime) && runtime.supports.teamsCore ? true : false;
7962
+ }
7963
+ teamsCore.isSupported = isSupported;
7964
+ })(teamsCore || (teamsCore = {}));
7965
+
7945
7966
  ;// CONCATENATED MODULE: ./src/public/people.ts
7946
7967
 
7947
7968
 
@@ -8442,14 +8463,20 @@ var videoUtils_generator = (undefined && undefined.__generator) || function (thi
8442
8463
  * Create a MediaStreamTrack from the media stream with the given streamId and processed by videoFrameHandler.
8443
8464
  */
8444
8465
  function processMediaStream(streamId, videoFrameHandler, notifyError, videoPerformanceMonitor) {
8466
+ var _a, _b;
8445
8467
  return videoUtils_awaiter(this, void 0, void 0, function () {
8446
- var _a;
8447
- return videoUtils_generator(this, function (_b) {
8448
- switch (_b.label) {
8468
+ var generator, _c;
8469
+ return videoUtils_generator(this, function (_d) {
8470
+ switch (_d.label) {
8449
8471
  case 0:
8450
- _a = createProcessedStreamGenerator;
8472
+ generator = createProcessedStreamGeneratorWithoutSource();
8473
+ !inServerSideRenderingEnvironment() && ((_b = (_a = window['chrome']) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.registerTextureStream(streamId, generator));
8474
+ _c = pipeVideoSourceToGenerator;
8451
8475
  return [4 /*yield*/, getInputVideoTrack(streamId, notifyError, videoPerformanceMonitor)];
8452
- case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), new DefaultTransformer(notifyError, videoFrameHandler)])];
8476
+ case 1:
8477
+ _c.apply(void 0, [_d.sent(), new DefaultTransformer(notifyError, videoFrameHandler),
8478
+ generator.writable]);
8479
+ return [2 /*return*/];
8453
8480
  }
8454
8481
  });
8455
8482
  });
@@ -8463,14 +8490,20 @@ function processMediaStream(streamId, videoFrameHandler, notifyError, videoPerfo
8463
8490
  * Limited to Microsoft-internal use
8464
8491
  */
8465
8492
  function processMediaStreamWithMetadata(streamId, videoFrameHandler, notifyError, videoPerformanceMonitor) {
8493
+ var _a, _b;
8466
8494
  return videoUtils_awaiter(this, void 0, void 0, function () {
8467
- var _a;
8468
- return videoUtils_generator(this, function (_b) {
8469
- switch (_b.label) {
8495
+ var generator, _c;
8496
+ return videoUtils_generator(this, function (_d) {
8497
+ switch (_d.label) {
8470
8498
  case 0:
8471
- _a = createProcessedStreamGenerator;
8499
+ generator = createProcessedStreamGeneratorWithoutSource();
8500
+ !inServerSideRenderingEnvironment() && ((_b = (_a = window['chrome']) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.registerTextureStream(streamId, generator));
8501
+ _c = pipeVideoSourceToGenerator;
8472
8502
  return [4 /*yield*/, getInputVideoTrack(streamId, notifyError, videoPerformanceMonitor)];
8473
- case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), new TransformerWithMetadata(notifyError, videoFrameHandler)])];
8503
+ case 1:
8504
+ _c.apply(void 0, [_d.sent(), new TransformerWithMetadata(notifyError, videoFrameHandler),
8505
+ generator.writable]);
8506
+ return [2 /*return*/];
8474
8507
  }
8475
8508
  });
8476
8509
  });
@@ -8487,7 +8520,7 @@ function getInputVideoTrack(streamId, notifyError, videoPerformanceMonitor) {
8487
8520
  if (inServerSideRenderingEnvironment()) {
8488
8521
  throw errorNotSupportedOnPlatform;
8489
8522
  }
8490
- chrome = window['chrome'];
8523
+ chrome = ssrSafeWindow()['chrome'];
8491
8524
  _a.label = 1;
8492
8525
  case 1:
8493
8526
  _a.trys.push([1, 3, , 4]);
@@ -8512,23 +8545,30 @@ function getInputVideoTrack(streamId, notifyError, videoPerformanceMonitor) {
8512
8545
  });
8513
8546
  }
8514
8547
  /**
8515
- * The function to create a processed video track from the original video track.
8516
- * It reads frames from the video track and pipes them to the video frame callback to process the frames.
8517
- * The processed frames are then enqueued to the generator.
8548
+ * The function to create a MediaStreamTrack generator.
8549
+ * The generator can then get the processed frames as media stream source.
8518
8550
  * The generator can be registered back to the media stream so that the host can get the processed frames.
8519
8551
  */
8520
- function createProcessedStreamGenerator(videoTrack, transformer) {
8552
+ function createProcessedStreamGeneratorWithoutSource() {
8521
8553
  if (inServerSideRenderingEnvironment()) {
8522
8554
  throw errorNotSupportedOnPlatform;
8523
8555
  }
8524
- var MediaStreamTrackProcessor = window['MediaStreamTrackProcessor'];
8556
+ var MediaStreamTrackGenerator = window['MediaStreamTrackGenerator'];
8557
+ if (!MediaStreamTrackGenerator) {
8558
+ throw errorNotSupportedOnPlatform;
8559
+ }
8560
+ return new MediaStreamTrackGenerator({ kind: 'video' });
8561
+ }
8562
+ /**
8563
+ * The function to create a processed video track from the original video track.
8564
+ * It reads frames from the video track and pipes them to the video frame callback to process the frames.
8565
+ * The processed frames are then enqueued to the generator.
8566
+ */
8567
+ function pipeVideoSourceToGenerator(videoTrack, transformer, sink) {
8568
+ var MediaStreamTrackProcessor = ssrSafeWindow()['MediaStreamTrackProcessor'];
8525
8569
  var processor = new MediaStreamTrackProcessor({ track: videoTrack });
8526
8570
  var source = processor.readable;
8527
- var MediaStreamTrackGenerator = window['MediaStreamTrackGenerator'];
8528
- var generator = new MediaStreamTrackGenerator({ kind: 'video' });
8529
- var sink = generator.writable;
8530
8571
  source.pipeThrough(new TransformStream(transformer)).pipeTo(sink);
8531
- return generator;
8532
8572
  }
8533
8573
  /**
8534
8574
  * @hidden
@@ -9085,18 +9125,15 @@ var video;
9085
9125
  throw errorNotSupportedOnPlatform;
9086
9126
  }
9087
9127
  registerHandler('video.startVideoExtensibilityVideoStream', function (mediaStreamInfo) { return video_awaiter(_this, void 0, void 0, function () {
9088
- var streamId, monitoredVideoFrameHandler, generator;
9089
- var _a, _b;
9090
- return video_generator(this, function (_c) {
9091
- switch (_c.label) {
9128
+ var streamId, monitoredVideoFrameHandler;
9129
+ return video_generator(this, function (_a) {
9130
+ switch (_a.label) {
9092
9131
  case 0:
9093
9132
  streamId = mediaStreamInfo.streamId;
9094
9133
  monitoredVideoFrameHandler = createMonitoredVideoFrameHandler(videoFrameHandler, videoPerformanceMonitor);
9095
9134
  return [4 /*yield*/, processMediaStream(streamId, monitoredVideoFrameHandler, notifyError, videoPerformanceMonitor)];
9096
9135
  case 1:
9097
- generator = _c.sent();
9098
- // register the video track with processed frames back to the stream:
9099
- !inServerSideRenderingEnvironment() && ((_b = (_a = window['chrome']) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.registerTextureStream(streamId, generator));
9136
+ _a.sent();
9100
9137
  return [2 /*return*/];
9101
9138
  }
9102
9139
  });
@@ -9158,8 +9195,7 @@ var video;
9158
9195
  }
9159
9196
  function isTextureStreamAvailable() {
9160
9197
  var _a, _b, _c, _d;
9161
- return (!inServerSideRenderingEnvironment() &&
9162
- !!(((_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)));
9198
+ return !!(((_b = (_a = ssrSafeWindow()['chrome']) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.getTextureStream) && ((_d = (_c = ssrSafeWindow()['chrome']) === null || _c === void 0 ? void 0 : _c.webview) === null || _d === void 0 ? void 0 : _d.registerTextureStream));
9163
9199
  }
9164
9200
  function doesSupportSharedFrame() {
9165
9201
  var _a;
@@ -12215,26 +12251,25 @@ var videoEx;
12215
12251
  registerHandler('video.setFrameProcessTimeLimit', function (timeLimit) { return videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.setFrameProcessTimeLimit(timeLimit); }, false);
12216
12252
  if ((_a = runtime.supports.video) === null || _a === void 0 ? void 0 : _a.mediaStream) {
12217
12253
  registerHandler('video.startVideoExtensibilityVideoStream', function (mediaStreamInfo) { return videoEx_awaiter(_this, void 0, void 0, function () {
12218
- var streamId, metadataInTexture, generator, _a;
12219
- var _b, _c;
12220
- return videoEx_generator(this, function (_d) {
12221
- switch (_d.label) {
12254
+ var streamId, metadataInTexture, handler, _a;
12255
+ return videoEx_generator(this, function (_b) {
12256
+ switch (_b.label) {
12222
12257
  case 0:
12223
12258
  streamId = mediaStreamInfo.streamId, metadataInTexture = mediaStreamInfo.metadataInTexture;
12259
+ handler = videoPerformanceMonitor
12260
+ ? createMonitoredVideoFrameHandler(parameters.videoFrameHandler, videoPerformanceMonitor)
12261
+ : parameters.videoFrameHandler;
12224
12262
  if (!metadataInTexture) return [3 /*break*/, 2];
12225
- return [4 /*yield*/, processMediaStreamWithMetadata(streamId, parameters.videoFrameHandler, notifyError, videoPerformanceMonitor)];
12263
+ return [4 /*yield*/, processMediaStreamWithMetadata(streamId, handler, notifyError, videoPerformanceMonitor)];
12226
12264
  case 1:
12227
- _a = _d.sent();
12265
+ _a = _b.sent();
12228
12266
  return [3 /*break*/, 4];
12229
- case 2: return [4 /*yield*/, processMediaStream(streamId, parameters.videoFrameHandler, notifyError, videoPerformanceMonitor)];
12267
+ case 2: return [4 /*yield*/, processMediaStream(streamId, handler, notifyError, videoPerformanceMonitor)];
12230
12268
  case 3:
12231
- _a = _d.sent();
12232
- _d.label = 4;
12269
+ _a = _b.sent();
12270
+ _b.label = 4;
12233
12271
  case 4:
12234
- generator = _a;
12235
- // register the video track with processed frames back to the stream
12236
- !inServerSideRenderingEnvironment() &&
12237
- ((_c = (_b = window['chrome']) === null || _b === void 0 ? void 0 : _b.webview) === null || _c === void 0 ? void 0 : _c.registerTextureStream(streamId, generator));
12272
+ _a;
12238
12273
  return [2 /*return*/];
12239
12274
  }
12240
12275
  });
@@ -12262,6 +12297,24 @@ var videoEx;
12262
12297
  }
12263
12298
  }
12264
12299
  videoEx.registerForVideoFrame = registerForVideoFrame;
12300
+ function createMonitoredVideoFrameHandler(videoFrameHandler, videoPerformanceMonitor) {
12301
+ var _this = this;
12302
+ return function (receivedVideoFrame) { return videoEx_awaiter(_this, void 0, void 0, function () {
12303
+ var originalFrame, processedFrame;
12304
+ return videoEx_generator(this, function (_a) {
12305
+ switch (_a.label) {
12306
+ case 0:
12307
+ originalFrame = receivedVideoFrame.videoFrame;
12308
+ videoPerformanceMonitor.reportStartFrameProcessing(originalFrame.codedWidth, originalFrame.codedHeight);
12309
+ return [4 /*yield*/, videoFrameHandler(receivedVideoFrame)];
12310
+ case 1:
12311
+ processedFrame = _a.sent();
12312
+ videoPerformanceMonitor.reportFrameProcessed();
12313
+ return [2 /*return*/, processedFrame];
12314
+ }
12315
+ });
12316
+ }); };
12317
+ }
12265
12318
  function normalizedVideoBufferData(videoBufferData) {
12266
12319
  videoBufferData['videoFrameBuffer'] = videoBufferData['videoFrameBuffer'] || videoBufferData['data'];
12267
12320
  delete videoBufferData['data'];