@microsoft/teams-js 2.0.0-beta.6-dev.2 → 2.0.0-beta.6-dev.5

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.
@@ -2827,6 +2827,15 @@ export namespace dialog {
2827
2827
  }
2828
2828
  type PostMessageChannel = (message: any) => void;
2829
2829
  type DialogSubmitHandler = (result: ISdkResponse) => void;
2830
+ /**
2831
+ * @hidden
2832
+ * Hide from docs because this function is only used during initialization
2833
+ * ------------------
2834
+ * Adds register handlers for messageForChild upon initialization and only in the tasks FrameContext. {@link FrameContexts.task}
2835
+ * Function is called during app intitialization
2836
+ * @internal
2837
+ */
2838
+ function initialize(): void;
2830
2839
  /**
2831
2840
  * Allows app to open a url based dialog.
2832
2841
  *
@@ -2915,6 +2924,24 @@ export namespace dialog {
2915
2924
  */
2916
2925
  function isSupported(): boolean;
2917
2926
  }
2927
+ /**
2928
+ * @hidden
2929
+ * Hide from docs
2930
+ * --------
2931
+ * Convert UrlDialogInfo to DialogInfo to send the information to host in {@linkcode open} API.
2932
+ *
2933
+ * @internal
2934
+ */
2935
+ function getDialogInfoFromUrlDialogInfo(urlDialogInfo: UrlDialogInfo): DialogInfo;
2936
+ /**
2937
+ * @hidden
2938
+ * Hide from docs
2939
+ * --------
2940
+ * Convert BotUrlDialogInfo to DialogInfo to send the information to host in {@linkcode bot.open} API.
2941
+ *
2942
+ * @internal
2943
+ */
2944
+ function getDialogInfoFromBotUrlDialogInfo(botUrlDialogInfo: BotUrlDialogInfo): DialogInfo;
2918
2945
  }
2919
2946
 
2920
2947
  /**
@@ -1121,7 +1121,7 @@ __webpack_require__.d(__webpack_exports__, {
1121
1121
  });
1122
1122
 
1123
1123
  ;// CONCATENATED MODULE: ./src/internal/constants.ts
1124
- var version = "2.0.0-beta.6-dev.2";
1124
+ var version = "2.0.0-beta.6-dev.5";
1125
1125
  /**
1126
1126
  * @hidden
1127
1127
  * The client version when all SDK APIs started to check platform compatibility for the APIs was 1.6.0.
@@ -2467,6 +2467,245 @@ function applyRuntimeConfig(runtimeConfig) {
2467
2467
  runtime = deepFreeze(runtimeConfig);
2468
2468
  }
2469
2469
 
2470
+ ;// CONCATENATED MODULE: ./src/public/dialog.ts
2471
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2472
+ /* eslint-disable @typescript-eslint/ban-types */
2473
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2474
+
2475
+
2476
+
2477
+
2478
+
2479
+
2480
+ /**
2481
+ * Namespace to interact with the dialog module-specific part of the SDK.
2482
+ *
2483
+ * @beta
2484
+ */
2485
+ var dialog;
2486
+ (function (dialog) {
2487
+ var storedMessages = [];
2488
+ /**
2489
+ * @hidden
2490
+ * Hide from docs because this function is only used during initialization
2491
+ * ------------------
2492
+ * Adds register handlers for messageForChild upon initialization and only in the tasks FrameContext. {@link FrameContexts.task}
2493
+ * Function is called during app intitialization
2494
+ * @internal
2495
+ */
2496
+ function initialize() {
2497
+ registerHandler('messageForChild', handleDialogMessage, false);
2498
+ }
2499
+ dialog.initialize = initialize;
2500
+ function handleDialogMessage(message) {
2501
+ if (!GlobalVars.frameContext) {
2502
+ // GlobalVars.frameContext is currently not set
2503
+ return;
2504
+ }
2505
+ if (GlobalVars.frameContext === FrameContexts.task) {
2506
+ storedMessages.push(message);
2507
+ }
2508
+ else {
2509
+ // Not in task FrameContext, remove 'messageForChild' handler
2510
+ removeHandler('messageForChild');
2511
+ }
2512
+ }
2513
+ /**
2514
+ * Allows app to open a url based dialog.
2515
+ *
2516
+ * @remarks
2517
+ * This function cannot be called from inside of a dialog
2518
+ *
2519
+ * @param urlDialogInfo - An object containing the parameters of the dialog module.
2520
+ * @param submitHandler - Handler that triggers when a dialog calls the {@linkcode submit} function or when the user closes the dialog.
2521
+ * @param messageFromChildHandler - Handler that triggers if dialog sends a message to the app.
2522
+ *
2523
+ * @returns a function that can be used to send messages to the dialog.
2524
+ */
2525
+ function open(urlDialogInfo, submitHandler, messageFromChildHandler) {
2526
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
2527
+ if (messageFromChildHandler) {
2528
+ registerHandler('messageForParent', messageFromChildHandler);
2529
+ }
2530
+ var dialogInfo = getDialogInfoFromUrlDialogInfo(urlDialogInfo);
2531
+ sendMessageToParent('tasks.startTask', [dialogInfo], function (err, result) {
2532
+ submitHandler({ err: err, result: result });
2533
+ removeHandler('messageForParent');
2534
+ });
2535
+ }
2536
+ dialog.open = open;
2537
+ /**
2538
+ * Submit the dialog module.
2539
+ *
2540
+ * @param result - The result to be sent to the bot or the app. Typically a JSON object or a serialized version of it
2541
+ * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
2542
+ */
2543
+ function submit(result, appIds) {
2544
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
2545
+ // Send tasks.completeTask instead of tasks.submitTask message for backward compatibility with Mobile clients
2546
+ sendMessageToParent('tasks.completeTask', [result, appIds ? (Array.isArray(appIds) ? appIds : [appIds]) : []]);
2547
+ }
2548
+ dialog.submit = submit;
2549
+ /**
2550
+ * Send message to the parent from dialog
2551
+ *
2552
+ * @remarks
2553
+ * This function is only called from inside of a dialog
2554
+ *
2555
+ * @param message - The message to send to the parent
2556
+ */
2557
+ function sendMessageToParentFromDialog(
2558
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2559
+ message) {
2560
+ ensureInitialized(FrameContexts.task);
2561
+ sendMessageToParent('messageForParent', [message]);
2562
+ }
2563
+ dialog.sendMessageToParentFromDialog = sendMessageToParentFromDialog;
2564
+ /**
2565
+ * Send message to the dialog from the parent
2566
+ *
2567
+ * @param message - The message to send
2568
+ */
2569
+ function sendMessageToDialog(
2570
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2571
+ message) {
2572
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
2573
+ sendMessageToParent('messageForChild', [message]);
2574
+ }
2575
+ dialog.sendMessageToDialog = sendMessageToDialog;
2576
+ /**
2577
+ * Register a listener that will be triggered when a message is received from the app that opened the dialog.
2578
+ *
2579
+ * @remarks
2580
+ * This function is only called from inside of a dialog.
2581
+ *
2582
+ * @param listener - The listener that will be triggered.
2583
+ */
2584
+ function registerOnMessageFromParent(listener) {
2585
+ ensureInitialized(FrameContexts.task);
2586
+ // We need to remove the original 'messageForChild'
2587
+ // handler since the original does not allow for post messages.
2588
+ // It is replaced by the user specified listener that is passed in.
2589
+ removeHandler('messageForChild');
2590
+ registerHandler('messageForChild', listener);
2591
+ storedMessages.reverse();
2592
+ while (storedMessages.length > 0) {
2593
+ var message = storedMessages.pop();
2594
+ listener(message);
2595
+ }
2596
+ }
2597
+ dialog.registerOnMessageFromParent = registerOnMessageFromParent;
2598
+ /**
2599
+ * Checks if dialog module is supported by the host
2600
+ *
2601
+ * @returns boolean to represent whether dialog module is supported
2602
+ */
2603
+ function isSupported() {
2604
+ return runtime.supports.dialog ? true : false;
2605
+ }
2606
+ dialog.isSupported = isSupported;
2607
+ /**
2608
+ * Namespace to update the dialog
2609
+ */
2610
+ var update;
2611
+ (function (update) {
2612
+ /**
2613
+ * Update dimensions - height/width of a dialog.
2614
+ *
2615
+ * @param dimensions - An object containing width and height properties.
2616
+ */
2617
+ function resize(dimensions) {
2618
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
2619
+ sendMessageToParent('tasks.updateTask', [dimensions]);
2620
+ }
2621
+ update.resize = resize;
2622
+ /**
2623
+ * Checks if dialog.update capability is supported by the host
2624
+ *
2625
+ * @returns boolean to represent whether dialog.update is supported
2626
+ */
2627
+ function isSupported() {
2628
+ return runtime.supports.dialog ? (runtime.supports.dialog.update ? true : false) : false;
2629
+ }
2630
+ update.isSupported = isSupported;
2631
+ })(update = dialog.update || (dialog.update = {}));
2632
+ /**
2633
+ * Namespace to open a dialog that sends results to the bot framework
2634
+ */
2635
+ var bot;
2636
+ (function (bot) {
2637
+ /**
2638
+ * Allows an app to open the dialog module using bot.
2639
+ *
2640
+ * @param botUrlDialogInfo - An object containing the parameters of the dialog module including completionBotId.
2641
+ * @param submitHandler - Handler that triggers when the dialog has been submitted or closed.
2642
+ * @param messageFromChildHandler - Handler that triggers if dialog sends a message to the app.
2643
+ *
2644
+ * @returns a function that can be used to send messages to the dialog.
2645
+ */
2646
+ function open(botUrlDialogInfo, submitHandler, messageFromChildHandler) {
2647
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
2648
+ if (messageFromChildHandler) {
2649
+ registerHandler('messageForParent', messageFromChildHandler);
2650
+ }
2651
+ var dialogInfo = getDialogInfoFromBotUrlDialogInfo(botUrlDialogInfo);
2652
+ sendMessageToParent('tasks.startTask', [dialogInfo], function (err, result) {
2653
+ submitHandler({ err: err, result: result });
2654
+ removeHandler('messageForParent');
2655
+ });
2656
+ }
2657
+ bot.open = open;
2658
+ /**
2659
+ * Checks if dialog.bot capability is supported by the host
2660
+ *
2661
+ * @returns boolean to represent whether dialog.bot is supported
2662
+ */
2663
+ function isSupported() {
2664
+ return runtime.supports.dialog ? (runtime.supports.dialog.bot ? true : false) : false;
2665
+ }
2666
+ bot.isSupported = isSupported;
2667
+ })(bot = dialog.bot || (dialog.bot = {}));
2668
+ /**
2669
+ * @hidden
2670
+ * Hide from docs
2671
+ * --------
2672
+ * Convert UrlDialogInfo to DialogInfo to send the information to host in {@linkcode open} API.
2673
+ *
2674
+ * @internal
2675
+ */
2676
+ function getDialogInfoFromUrlDialogInfo(urlDialogInfo) {
2677
+ var dialogInfo = {
2678
+ url: urlDialogInfo.url,
2679
+ height: urlDialogInfo.size ? urlDialogInfo.size.height : DialogDimension.Small,
2680
+ width: urlDialogInfo.size ? urlDialogInfo.size.width : DialogDimension.Small,
2681
+ title: urlDialogInfo.title,
2682
+ fallbackUrl: urlDialogInfo.fallbackUrl,
2683
+ };
2684
+ return dialogInfo;
2685
+ }
2686
+ dialog.getDialogInfoFromUrlDialogInfo = getDialogInfoFromUrlDialogInfo;
2687
+ /**
2688
+ * @hidden
2689
+ * Hide from docs
2690
+ * --------
2691
+ * Convert BotUrlDialogInfo to DialogInfo to send the information to host in {@linkcode bot.open} API.
2692
+ *
2693
+ * @internal
2694
+ */
2695
+ function getDialogInfoFromBotUrlDialogInfo(botUrlDialogInfo) {
2696
+ var dialogInfo = {
2697
+ url: botUrlDialogInfo.url,
2698
+ height: botUrlDialogInfo.size ? botUrlDialogInfo.size.height : DialogDimension.Small,
2699
+ width: botUrlDialogInfo.size ? botUrlDialogInfo.size.width : DialogDimension.Small,
2700
+ title: botUrlDialogInfo.title,
2701
+ fallbackUrl: botUrlDialogInfo.fallbackUrl,
2702
+ completionBotId: botUrlDialogInfo.completionBotId,
2703
+ };
2704
+ return dialogInfo;
2705
+ }
2706
+ dialog.getDialogInfoFromBotUrlDialogInfo = getDialogInfoFromBotUrlDialogInfo;
2707
+ })(dialog || (dialog = {}));
2708
+
2470
2709
  ;// CONCATENATED MODULE: ./src/public/menus.ts
2471
2710
 
2472
2711
 
@@ -2685,6 +2924,7 @@ var teamsCore;
2685
2924
 
2686
2925
 
2687
2926
 
2927
+
2688
2928
  /**
2689
2929
  * Namespace to interact with app initialization and lifecycle.
2690
2930
  *
@@ -2809,6 +3049,7 @@ var app_app;
2809
3049
  authentication.initialize();
2810
3050
  menus.initialize();
2811
3051
  pages.config.initialize();
3052
+ dialog.initialize();
2812
3053
  initializePrivateApis();
2813
3054
  }
2814
3055
  // Handle additional valid message origins if specified
@@ -4432,168 +4673,6 @@ var chat;
4432
4673
  chat.isSupported = isSupported;
4433
4674
  })(chat || (chat = {}));
4434
4675
 
4435
- ;// CONCATENATED MODULE: ./src/public/dialog.ts
4436
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4437
- /* eslint-disable @typescript-eslint/ban-types */
4438
- /* eslint-disable @typescript-eslint/no-unused-vars */
4439
-
4440
-
4441
-
4442
-
4443
-
4444
- /**
4445
- * Namespace to interact with the dialog module-specific part of the SDK.
4446
- *
4447
- * @beta
4448
- */
4449
- var dialog;
4450
- (function (dialog) {
4451
- /**
4452
- * Allows app to open a url based dialog.
4453
- *
4454
- * @remarks
4455
- * This function cannot be called from inside of a dialog
4456
- *
4457
- * @param urlDialogInfo - An object containing the parameters of the dialog module.
4458
- * @param submitHandler - Handler that triggers when a dialog calls the {@linkcode submit} function or when the user closes the dialog.
4459
- * @param messageFromChildHandler - Handler that triggers if dialog sends a message to the app.
4460
- *
4461
- * @returns a function that can be used to send messages to the dialog.
4462
- */
4463
- function open(urlDialogInfo, submitHandler, messageFromChildHandler) {
4464
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
4465
- if (messageFromChildHandler) {
4466
- registerHandler('messageForParent', messageFromChildHandler);
4467
- }
4468
- sendMessageToParent('tasks.startTask', [urlDialogInfo], function (err, result) {
4469
- submitHandler({ err: err, result: result });
4470
- removeHandler('messageForParent');
4471
- });
4472
- }
4473
- dialog.open = open;
4474
- /**
4475
- * Submit the dialog module.
4476
- *
4477
- * @param result - The result to be sent to the bot or the app. Typically a JSON object or a serialized version of it
4478
- * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
4479
- */
4480
- function submit(result, appIds) {
4481
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
4482
- // Send tasks.completeTask instead of tasks.submitTask message for backward compatibility with Mobile clients
4483
- sendMessageToParent('tasks.completeTask', [result, appIds ? (Array.isArray(appIds) ? appIds : [appIds]) : []]);
4484
- }
4485
- dialog.submit = submit;
4486
- /**
4487
- * Send message to the parent from dialog
4488
- *
4489
- * @remarks
4490
- * This function is only called from inside of a dialog
4491
- *
4492
- * @param message - The message to send to the parent
4493
- */
4494
- function sendMessageToParentFromDialog(
4495
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4496
- message) {
4497
- ensureInitialized(FrameContexts.task);
4498
- sendMessageToParent('messageForParent', [message]);
4499
- }
4500
- dialog.sendMessageToParentFromDialog = sendMessageToParentFromDialog;
4501
- /**
4502
- * Send message to the dialog from the parent
4503
- *
4504
- * @param message - The message to send
4505
- */
4506
- function sendMessageToDialog(
4507
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4508
- message) {
4509
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
4510
- sendMessageToParent('messageForChild', [message]);
4511
- }
4512
- dialog.sendMessageToDialog = sendMessageToDialog;
4513
- /**
4514
- * Register a listener that will be triggered when a message is received from the app that opened the dialog.
4515
- *
4516
- * @remarks
4517
- * This function is only called from inside of a dialog.
4518
- *
4519
- * @param listener - The listener that will be triggered.
4520
- */
4521
- function registerOnMessageFromParent(listener) {
4522
- ensureInitialized(FrameContexts.task);
4523
- registerHandler('messageForChild', listener);
4524
- }
4525
- dialog.registerOnMessageFromParent = registerOnMessageFromParent;
4526
- /**
4527
- * Checks if dialog module is supported by the host
4528
- *
4529
- * @returns boolean to represent whether dialog module is supported
4530
- */
4531
- function isSupported() {
4532
- return runtime.supports.dialog ? true : false;
4533
- }
4534
- dialog.isSupported = isSupported;
4535
- /**
4536
- * Namespace to update the dialog
4537
- */
4538
- var update;
4539
- (function (update) {
4540
- /**
4541
- * Update dimensions - height/width of a dialog.
4542
- *
4543
- * @param dimensions - An object containing width and height properties.
4544
- */
4545
- function resize(dimensions) {
4546
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
4547
- sendMessageToParent('tasks.updateTask', [dimensions]);
4548
- }
4549
- update.resize = resize;
4550
- /**
4551
- * Checks if dialog.update capability is supported by the host
4552
- *
4553
- * @returns boolean to represent whether dialog.update is supported
4554
- */
4555
- function isSupported() {
4556
- return runtime.supports.dialog ? (runtime.supports.dialog.update ? true : false) : false;
4557
- }
4558
- update.isSupported = isSupported;
4559
- })(update = dialog.update || (dialog.update = {}));
4560
- /**
4561
- * Namespace to open a dialog that sends results to the bot framework
4562
- */
4563
- var bot;
4564
- (function (bot) {
4565
- /**
4566
- * Allows an app to open the dialog module using bot.
4567
- *
4568
- * @param botUrlDialogInfo - An object containing the parameters of the dialog module including completionBotId.
4569
- * @param submitHandler - Handler that triggers when the dialog has been submitted or closed.
4570
- * @param messageFromChildHandler - Handler that triggers if dialog sends a message to the app.
4571
- *
4572
- * @returns a function that can be used to send messages to the dialog.
4573
- */
4574
- function open(botUrlDialogInfo, submitHandler, messageFromChildHandler) {
4575
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
4576
- if (messageFromChildHandler) {
4577
- registerHandler('messageForParent', messageFromChildHandler);
4578
- }
4579
- sendMessageToParent('tasks.startTask', [botUrlDialogInfo], function (err, result) {
4580
- submitHandler({ err: err, result: result });
4581
- removeHandler('messageForParent');
4582
- });
4583
- }
4584
- bot.open = open;
4585
- /**
4586
- * Checks if dialog.bot capability is supported by the host
4587
- *
4588
- * @returns boolean to represent whether dialog.bot is supported
4589
- */
4590
- function isSupported() {
4591
- return runtime.supports.dialog ? (runtime.supports.dialog.bot ? true : false) : false;
4592
- }
4593
- bot.isSupported = isSupported;
4594
- })(bot = dialog.bot || (dialog.bot = {}));
4595
- })(dialog || (dialog = {}));
4596
-
4597
4676
  ;// CONCATENATED MODULE: ./src/public/appWindow.ts
4598
4677
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4599
4678
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -7108,6 +7187,9 @@ var legacy;
7108
7187
  function getUserJoinedTeams(teamInstanceParameters) {
7109
7188
  return new Promise(function (resolve) {
7110
7189
  ensureInitialized();
7190
+ if (!isSupported()) {
7191
+ throw errorNotSupportedOnPlatform;
7192
+ }
7111
7193
  if ((GlobalVars.hostClientType === HostClientType.android ||
7112
7194
  GlobalVars.hostClientType === HostClientType.teamsRoomsAndroid ||
7113
7195
  GlobalVars.hostClientType === HostClientType.teamsPhones ||
@@ -7143,6 +7225,9 @@ var legacy;
7143
7225
  function getConfigSetting(key) {
7144
7226
  return new Promise(function (resolve) {
7145
7227
  ensureInitialized();
7228
+ if (!isSupported()) {
7229
+ throw errorNotSupportedOnPlatform;
7230
+ }
7146
7231
  resolve(sendAndUnwrap('getConfigSetting', key));
7147
7232
  });
7148
7233
  }
@@ -7286,6 +7371,9 @@ var notifications;
7286
7371
  */
7287
7372
  function showNotification(showNotificationParameters) {
7288
7373
  ensureInitialized(FrameContexts.content);
7374
+ if (!isSupported()) {
7375
+ throw errorNotSupportedOnPlatform;
7376
+ }
7289
7377
  sendMessageToParent('notifications.showNotification', [showNotificationParameters]);
7290
7378
  }
7291
7379
  notifications.showNotification = showNotification;