@microsoft/teams-js 2.0.0-beta.6-dev.0 → 2.0.0-beta.6-dev.3

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
  *
@@ -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.0";
1124
+ var version = "2.0.0-beta.6-dev.3";
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,204 @@ 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
+ sendMessageToParent('tasks.startTask', [urlDialogInfo], function (err, result) {
2531
+ submitHandler({ err: err, result: result });
2532
+ removeHandler('messageForParent');
2533
+ });
2534
+ }
2535
+ dialog.open = open;
2536
+ /**
2537
+ * Submit the dialog module.
2538
+ *
2539
+ * @param result - The result to be sent to the bot or the app. Typically a JSON object or a serialized version of it
2540
+ * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
2541
+ */
2542
+ function submit(result, appIds) {
2543
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
2544
+ // Send tasks.completeTask instead of tasks.submitTask message for backward compatibility with Mobile clients
2545
+ sendMessageToParent('tasks.completeTask', [result, appIds ? (Array.isArray(appIds) ? appIds : [appIds]) : []]);
2546
+ }
2547
+ dialog.submit = submit;
2548
+ /**
2549
+ * Send message to the parent from dialog
2550
+ *
2551
+ * @remarks
2552
+ * This function is only called from inside of a dialog
2553
+ *
2554
+ * @param message - The message to send to the parent
2555
+ */
2556
+ function sendMessageToParentFromDialog(
2557
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2558
+ message) {
2559
+ ensureInitialized(FrameContexts.task);
2560
+ sendMessageToParent('messageForParent', [message]);
2561
+ }
2562
+ dialog.sendMessageToParentFromDialog = sendMessageToParentFromDialog;
2563
+ /**
2564
+ * Send message to the dialog from the parent
2565
+ *
2566
+ * @param message - The message to send
2567
+ */
2568
+ function sendMessageToDialog(
2569
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2570
+ message) {
2571
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
2572
+ sendMessageToParent('messageForChild', [message]);
2573
+ }
2574
+ dialog.sendMessageToDialog = sendMessageToDialog;
2575
+ /**
2576
+ * Register a listener that will be triggered when a message is received from the app that opened the dialog.
2577
+ *
2578
+ * @remarks
2579
+ * This function is only called from inside of a dialog.
2580
+ *
2581
+ * @param listener - The listener that will be triggered.
2582
+ */
2583
+ function registerOnMessageFromParent(listener) {
2584
+ ensureInitialized(FrameContexts.task);
2585
+ // We need to remove the original 'messageForChild'
2586
+ // handler since the original does not allow for post messages.
2587
+ // It is replaced by the user specified listener that is passed in.
2588
+ removeHandler('messageForChild');
2589
+ registerHandler('messageForChild', listener);
2590
+ storedMessages.reverse();
2591
+ while (storedMessages.length > 0) {
2592
+ var message = storedMessages.pop();
2593
+ listener(message);
2594
+ }
2595
+ }
2596
+ dialog.registerOnMessageFromParent = registerOnMessageFromParent;
2597
+ /**
2598
+ * Checks if dialog module is supported by the host
2599
+ *
2600
+ * @returns boolean to represent whether dialog module is supported
2601
+ */
2602
+ function isSupported() {
2603
+ return runtime.supports.dialog ? true : false;
2604
+ }
2605
+ dialog.isSupported = isSupported;
2606
+ /**
2607
+ * Namespace to update the dialog
2608
+ */
2609
+ var update;
2610
+ (function (update) {
2611
+ /**
2612
+ * Update dimensions - height/width of a dialog.
2613
+ *
2614
+ * @param dimensions - An object containing width and height properties.
2615
+ */
2616
+ function resize(dimensions) {
2617
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
2618
+ sendMessageToParent('tasks.updateTask', [dimensions]);
2619
+ }
2620
+ update.resize = resize;
2621
+ /**
2622
+ * Checks if dialog.update capability is supported by the host
2623
+ *
2624
+ * @returns boolean to represent whether dialog.update is supported
2625
+ */
2626
+ function isSupported() {
2627
+ return runtime.supports.dialog ? (runtime.supports.dialog.update ? true : false) : false;
2628
+ }
2629
+ update.isSupported = isSupported;
2630
+ })(update = dialog.update || (dialog.update = {}));
2631
+ /**
2632
+ * Namespace to open a dialog that sends results to the bot framework
2633
+ */
2634
+ var bot;
2635
+ (function (bot) {
2636
+ /**
2637
+ * Allows an app to open the dialog module using bot.
2638
+ *
2639
+ * @param botUrlDialogInfo - An object containing the parameters of the dialog module including completionBotId.
2640
+ * @param submitHandler - Handler that triggers when the dialog has been submitted or closed.
2641
+ * @param messageFromChildHandler - Handler that triggers if dialog sends a message to the app.
2642
+ *
2643
+ * @returns a function that can be used to send messages to the dialog.
2644
+ */
2645
+ function open(botUrlDialogInfo, submitHandler, messageFromChildHandler) {
2646
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
2647
+ if (messageFromChildHandler) {
2648
+ registerHandler('messageForParent', messageFromChildHandler);
2649
+ }
2650
+ sendMessageToParent('tasks.startTask', [botUrlDialogInfo], function (err, result) {
2651
+ submitHandler({ err: err, result: result });
2652
+ removeHandler('messageForParent');
2653
+ });
2654
+ }
2655
+ bot.open = open;
2656
+ /**
2657
+ * Checks if dialog.bot capability is supported by the host
2658
+ *
2659
+ * @returns boolean to represent whether dialog.bot is supported
2660
+ */
2661
+ function isSupported() {
2662
+ return runtime.supports.dialog ? (runtime.supports.dialog.bot ? true : false) : false;
2663
+ }
2664
+ bot.isSupported = isSupported;
2665
+ })(bot = dialog.bot || (dialog.bot = {}));
2666
+ })(dialog || (dialog = {}));
2667
+
2470
2668
  ;// CONCATENATED MODULE: ./src/public/menus.ts
2471
2669
 
2472
2670
 
@@ -2685,6 +2883,7 @@ var teamsCore;
2685
2883
 
2686
2884
 
2687
2885
 
2886
+
2688
2887
  /**
2689
2888
  * Namespace to interact with app initialization and lifecycle.
2690
2889
  *
@@ -2809,6 +3008,7 @@ var app_app;
2809
3008
  authentication.initialize();
2810
3009
  menus.initialize();
2811
3010
  pages.config.initialize();
3011
+ dialog.initialize();
2812
3012
  initializePrivateApis();
2813
3013
  }
2814
3014
  // Handle additional valid message origins if specified
@@ -4432,168 +4632,6 @@ var chat;
4432
4632
  chat.isSupported = isSupported;
4433
4633
  })(chat || (chat = {}));
4434
4634
 
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
4635
  ;// CONCATENATED MODULE: ./src/public/appWindow.ts
4598
4636
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4599
4637
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -5857,6 +5895,9 @@ var sharing;
5857
5895
  sharing.shareWebContent = shareWebContent;
5858
5896
  function shareWebContentHelper(shareWebContentRequest) {
5859
5897
  return new Promise(function (resolve) {
5898
+ if (!isSupported()) {
5899
+ throw errorNotSupportedOnPlatform;
5900
+ }
5860
5901
  resolve(sendAndHandleSdkError(sharing.SharingAPIMessages.shareWebContent, shareWebContentRequest));
5861
5902
  });
5862
5903
  }
@@ -7105,6 +7146,9 @@ var legacy;
7105
7146
  function getUserJoinedTeams(teamInstanceParameters) {
7106
7147
  return new Promise(function (resolve) {
7107
7148
  ensureInitialized();
7149
+ if (!isSupported()) {
7150
+ throw errorNotSupportedOnPlatform;
7151
+ }
7108
7152
  if ((GlobalVars.hostClientType === HostClientType.android ||
7109
7153
  GlobalVars.hostClientType === HostClientType.teamsRoomsAndroid ||
7110
7154
  GlobalVars.hostClientType === HostClientType.teamsPhones ||
@@ -7140,6 +7184,9 @@ var legacy;
7140
7184
  function getConfigSetting(key) {
7141
7185
  return new Promise(function (resolve) {
7142
7186
  ensureInitialized();
7187
+ if (!isSupported()) {
7188
+ throw errorNotSupportedOnPlatform;
7189
+ }
7143
7190
  resolve(sendAndUnwrap('getConfigSetting', key));
7144
7191
  });
7145
7192
  }
@@ -7166,6 +7213,7 @@ var legacy;
7166
7213
 
7167
7214
 
7168
7215
 
7216
+
7169
7217
  /**
7170
7218
  * @alpha
7171
7219
  */
@@ -7182,6 +7230,9 @@ var meetingRoom;
7182
7230
  function getPairedMeetingRoomInfo() {
7183
7231
  return new Promise(function (resolve) {
7184
7232
  ensureInitialized();
7233
+ if (!isSupported()) {
7234
+ throw errorNotSupportedOnPlatform;
7235
+ }
7185
7236
  resolve(sendAndHandleSdkError('meetingRoom.getPairedMeetingRoomInfo'));
7186
7237
  });
7187
7238
  }
@@ -7201,6 +7252,9 @@ var meetingRoom;
7201
7252
  throw new Error('[meetingRoom.sendCommandToPairedMeetingRoom] Command name cannot be null or empty');
7202
7253
  }
7203
7254
  ensureInitialized();
7255
+ if (!isSupported()) {
7256
+ throw errorNotSupportedOnPlatform;
7257
+ }
7204
7258
  resolve(sendAndHandleSdkError('meetingRoom.sendCommandToPairedMeetingRoom', commandName));
7205
7259
  });
7206
7260
  }
@@ -7219,6 +7273,9 @@ var meetingRoom;
7219
7273
  throw new Error('[meetingRoom.registerMeetingRoomCapabilitiesUpdateHandler] Handler cannot be null');
7220
7274
  }
7221
7275
  ensureInitialized();
7276
+ if (!isSupported()) {
7277
+ throw errorNotSupportedOnPlatform;
7278
+ }
7222
7279
  registerHandler('meetingRoom.meetingRoomCapabilitiesUpdate', function (capabilities) {
7223
7280
  ensureInitialized();
7224
7281
  handler(capabilities);
@@ -7238,6 +7295,9 @@ var meetingRoom;
7238
7295
  throw new Error('[meetingRoom.registerMeetingRoomStatesUpdateHandler] Handler cannot be null');
7239
7296
  }
7240
7297
  ensureInitialized();
7298
+ if (!isSupported()) {
7299
+ throw errorNotSupportedOnPlatform;
7300
+ }
7241
7301
  registerHandler('meetingRoom.meetingRoomStatesUpdate', function (states) {
7242
7302
  ensureInitialized();
7243
7303
  handler(states);