@microsoft/teams-js 2.0.0-beta.4-dev.14 → 2.0.0-beta.4-dev.15

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.
@@ -2109,6 +2109,39 @@ export interface DeepLinkParameters {
2109
2109
  */
2110
2110
  subEntityWebUrl?: string;
2111
2111
  }
2112
+ export interface DialogSize {
2113
+ /**
2114
+ * The requested height of the webview/iframe.
2115
+ */
2116
+ height: DialogDimension | number;
2117
+ /**
2118
+ * The requested width of the webview/iframe.
2119
+ */
2120
+ width: DialogDimension | number;
2121
+ }
2122
+ export interface UrlDialogInfo {
2123
+ /**
2124
+ * The url to be rendered in the webview/iframe.
2125
+ */
2126
+ url: string;
2127
+ size: DialogSize;
2128
+ /**
2129
+ * Title of the task module.
2130
+ */
2131
+ title?: string;
2132
+ /**
2133
+ * If client doesnt support the URL, the URL that needs to be opened in the browser.
2134
+ */
2135
+ fallbackUrl?: string;
2136
+ }
2137
+ export interface BotUrlDialogInfo extends UrlDialogInfo {
2138
+ /**
2139
+ * Specifies a bot ID to send the result of the user's interaction with the task module.
2140
+ * The bot will receive a task/complete invoke event with a JSON object
2141
+ * in the event payload.
2142
+ */
2143
+ completionBotId: string;
2144
+ }
2112
2145
  export interface DialogInfo {
2113
2146
  /**
2114
2147
  * The url to be rendered in the webview/iframe.
@@ -2749,14 +2782,23 @@ export namespace appInstallDialog {
2749
2782
  *
2750
2783
  * @beta
2751
2784
  */
2785
+ export interface SdkResponse {
2786
+ err: string;
2787
+ result: string | object;
2788
+ }
2752
2789
  export namespace dialog {
2790
+ type PostMessageChannel = (message: any, onComplete?: (status: boolean, reason?: string) => void) => void;
2791
+ type DialogSubmitHandler = (result: SdkResponse) => void;
2753
2792
  /**
2754
2793
  * Allows an app to open the dialog module.
2755
2794
  *
2756
- * @param dialogInfo - An object containing the parameters of the dialog module
2757
- * @param submitHandler - Handler to call when the task module is completed
2795
+ * @param urlDialogInfo - An object containing the parameters of the dialog module.
2796
+ * @param submitHandler - This Handler is called when the dialog has been submitted or closed.
2797
+ * @param messageFromChildHandler - Handler that triggers if dialog sends a message to the app.
2798
+ *
2799
+ * @returns a function that can be used to send messages to the dialog.
2758
2800
  */
2759
- function open(dialogInfo: DialogInfo, submitHandler?: (err: string, result: string | object) => void): IAppWindow;
2801
+ function open(urlDialogInfo: UrlDialogInfo, submitHandler?: DialogSubmitHandler, messageFromChildHandler?: PostMessageChannel): PostMessageChannel;
2760
2802
  /**
2761
2803
  * Update height/width dialog info properties.
2762
2804
  *
@@ -2785,6 +2827,10 @@ export namespace dialog {
2785
2827
  */
2786
2828
  function registerOnMessageFromParent(listener: (message: any) => void): void;
2787
2829
  function isSupported(): boolean;
2830
+ namespace bot {
2831
+ function open(botUrlDialogInfo: BotUrlDialogInfo, submitHandler?: DialogSubmitHandler, messageFromChildHandler?: PostMessageChannel): PostMessageChannel;
2832
+ function isSupported(): boolean;
2833
+ }
2788
2834
  }
2789
2835
 
2790
2836
  /**
@@ -5048,7 +5094,7 @@ export namespace settings {
5048
5094
  export namespace tasks {
5049
5095
  /**
5050
5096
  * @deprecated
5051
- * As of 2.0.0-beta.1, please use {@link dialog.open dialog.open(dialogInfo: DialogInfo, submitHandler?: (err: string, result: string) => void): IAppWindow} instead.
5097
+ * As of 2.0.0-beta.4, please use {@link dialog.open(dialogInfo: DialogInfo, submitHandler?: DialogSubmitHandler, messageFromChildHandler?: PostMessageChannel): PostMessageChannel} instead.
5052
5098
  *
5053
5099
  * Allows an app to open the task module.
5054
5100
  *
@@ -5075,5 +5121,8 @@ export namespace tasks {
5075
5121
  * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
5076
5122
  */
5077
5123
  function submitTask(result?: string | object, appIds?: string | string[]): void;
5124
+ function getUrlDialogInfoFromTaskInfo(taskInfo: TaskInfo): UrlDialogInfo;
5125
+ function getBotUrlDialogInfoFromTaskInfo(taskInfo: TaskInfo): BotUrlDialogInfo;
5126
+ function getDefaultSizeIfNotProvided(taskInfo: TaskInfo): TaskInfo;
5078
5127
  }
5079
5128
 
@@ -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.4-dev.14";
1124
+ var version = "2.0.0-beta.4-dev.15";
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.
@@ -1820,7 +1820,9 @@ var runtime = {
1820
1820
  calendar: undefined,
1821
1821
  call: undefined,
1822
1822
  chat: undefined,
1823
- dialog: undefined,
1823
+ dialog: {
1824
+ bot: undefined,
1825
+ },
1824
1826
  location: undefined,
1825
1827
  logs: undefined,
1826
1828
  mail: undefined,
@@ -1856,7 +1858,9 @@ var teamsRuntimeConfig = {
1856
1858
  bot: {},
1857
1859
  call: {},
1858
1860
  chat: {},
1859
- dialog: {},
1861
+ dialog: {
1862
+ bot: {},
1863
+ },
1860
1864
  files: {},
1861
1865
  location: {},
1862
1866
  logs: {},
@@ -4247,78 +4251,6 @@ var appInstallDialog;
4247
4251
  appInstallDialog.isSupported = isSupported;
4248
4252
  })(appInstallDialog || (appInstallDialog = {}));
4249
4253
 
4250
- ;// CONCATENATED MODULE: ./src/public/appWindow.ts
4251
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4252
- /* eslint-disable @typescript-eslint/no-explicit-any */
4253
- /* eslint-disable @typescript-eslint/ban-types */
4254
-
4255
-
4256
-
4257
-
4258
-
4259
- var ChildAppWindow = /** @class */ (function () {
4260
- function ChildAppWindow() {
4261
- }
4262
- /**
4263
- * Send a message to the ChildAppWindow.
4264
- *
4265
- * @param message - The message to send
4266
- * @param onComplete - The callback to know if the postMessage has been success/failed.
4267
- */
4268
- ChildAppWindow.prototype.postMessage = function (message, onComplete) {
4269
- ensureInitialized();
4270
- sendMessageToParent('messageForChild', [message], onComplete ? onComplete : getGenericOnCompleteHandler());
4271
- };
4272
- /**
4273
- * Add a listener that will be called when an event is received from the ChildAppWindow.
4274
- *
4275
- * @param type - The event to listen to. Currently the only supported type is 'message'.
4276
- * @param listener - The listener that will be called
4277
- */
4278
- ChildAppWindow.prototype.addEventListener = function (type, listener) {
4279
- if (type === 'message') {
4280
- registerHandler('messageForParent', listener);
4281
- }
4282
- };
4283
- return ChildAppWindow;
4284
- }());
4285
-
4286
- var ParentAppWindow = /** @class */ (function () {
4287
- function ParentAppWindow() {
4288
- }
4289
- Object.defineProperty(ParentAppWindow, "Instance", {
4290
- get: function () {
4291
- // Do you need arguments? Make it a regular method instead.
4292
- return this._instance || (this._instance = new this());
4293
- },
4294
- enumerable: false,
4295
- configurable: true
4296
- });
4297
- /**
4298
- * Send a message to the ParentAppWindow.
4299
- *
4300
- * @param message - The message to send
4301
- * @param onComplete - The callback to know if the postMessage has been success/failed.
4302
- */
4303
- ParentAppWindow.prototype.postMessage = function (message, onComplete) {
4304
- ensureInitialized(FrameContexts.task);
4305
- sendMessageToParent('messageForParent', [message], onComplete ? onComplete : getGenericOnCompleteHandler());
4306
- };
4307
- /**
4308
- * Add a listener that will be called when an event is received from the ParentAppWindow.
4309
- *
4310
- * @param type - The event to listen to. Currently the only supported type is 'message'.
4311
- * @param listener - The listener that will be called
4312
- */
4313
- ParentAppWindow.prototype.addEventListener = function (type, listener) {
4314
- if (type === 'message') {
4315
- registerHandler('messageForChild', listener);
4316
- }
4317
- };
4318
- return ParentAppWindow;
4319
- }());
4320
-
4321
-
4322
4254
  ;// CONCATENATED MODULE: ./src/public/dialog.ts
4323
4255
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4324
4256
  /* eslint-disable @typescript-eslint/ban-types */
@@ -4340,27 +4272,30 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
4340
4272
 
4341
4273
 
4342
4274
 
4343
-
4344
- /**
4345
- * Namespace to interact with the dialog module-specific part of the SDK.
4346
- *
4347
- * @remarks
4348
- * This object is usable only on the content frame.
4349
- *
4350
- * @beta
4351
- */
4352
4275
  var dialog;
4353
4276
  (function (dialog) {
4354
4277
  /**
4355
4278
  * Allows an app to open the dialog module.
4356
4279
  *
4357
- * @param dialogInfo - An object containing the parameters of the dialog module
4358
- * @param submitHandler - Handler to call when the task module is completed
4280
+ * @param urlDialogInfo - An object containing the parameters of the dialog module.
4281
+ * @param submitHandler - This Handler is called when the dialog has been submitted or closed.
4282
+ * @param messageFromChildHandler - Handler that triggers if dialog sends a message to the app.
4283
+ *
4284
+ * @returns a function that can be used to send messages to the dialog.
4359
4285
  */
4360
- function open(dialogInfo, submitHandler) {
4286
+ function open(urlDialogInfo, submitHandler, messageFromChildHandler) {
4361
4287
  ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
4362
- sendMessageToParent('tasks.startTask', [dialogInfo], submitHandler);
4363
- return new ChildAppWindow();
4288
+ if (messageFromChildHandler) {
4289
+ registerHandler('messageForParent', messageFromChildHandler);
4290
+ }
4291
+ sendMessageToParent('tasks.startTask', [urlDialogInfo], function (err, result) {
4292
+ submitHandler({ err: err, result: result });
4293
+ });
4294
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4295
+ var sendMessageToDialog = function (message, onComplete) {
4296
+ sendMessageToParent('messageForChild', [message], onComplete ? onComplete : getGenericOnCompleteHandler());
4297
+ };
4298
+ return sendMessageToDialog;
4364
4299
  }
4365
4300
  dialog.open = open;
4366
4301
  /**
@@ -4420,8 +4355,102 @@ var dialog;
4420
4355
  return runtime.supports.dialog ? true : false;
4421
4356
  }
4422
4357
  dialog.isSupported = isSupported;
4358
+ var bot;
4359
+ (function (bot) {
4360
+ function open(botUrlDialogInfo, submitHandler, messageFromChildHandler) {
4361
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
4362
+ if (messageFromChildHandler) {
4363
+ registerHandler('messageForParent', messageFromChildHandler);
4364
+ }
4365
+ sendMessageToParent('tasks.startTask', [botUrlDialogInfo], function (err, result) {
4366
+ submitHandler({ err: err, result: result });
4367
+ });
4368
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4369
+ var sendMessageToDialog = function (message, onComplete) {
4370
+ sendMessageToParent('messageForChild', [message], onComplete ? onComplete : getGenericOnCompleteHandler());
4371
+ };
4372
+ return sendMessageToDialog;
4373
+ }
4374
+ bot.open = open;
4375
+ function isSupported() {
4376
+ return runtime.supports.dialog ? (runtime.supports.dialog.bot ? true : false) : false;
4377
+ }
4378
+ bot.isSupported = isSupported;
4379
+ })(bot = dialog.bot || (dialog.bot = {}));
4423
4380
  })(dialog || (dialog = {}));
4424
4381
 
4382
+ ;// CONCATENATED MODULE: ./src/public/appWindow.ts
4383
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4384
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4385
+ /* eslint-disable @typescript-eslint/ban-types */
4386
+
4387
+
4388
+
4389
+
4390
+
4391
+ var ChildAppWindow = /** @class */ (function () {
4392
+ function ChildAppWindow() {
4393
+ }
4394
+ /**
4395
+ * Send a message to the ChildAppWindow.
4396
+ *
4397
+ * @param message - The message to send
4398
+ * @param onComplete - The callback to know if the postMessage has been success/failed.
4399
+ */
4400
+ ChildAppWindow.prototype.postMessage = function (message, onComplete) {
4401
+ ensureInitialized();
4402
+ sendMessageToParent('messageForChild', [message], onComplete ? onComplete : getGenericOnCompleteHandler());
4403
+ };
4404
+ /**
4405
+ * Add a listener that will be called when an event is received from the ChildAppWindow.
4406
+ *
4407
+ * @param type - The event to listen to. Currently the only supported type is 'message'.
4408
+ * @param listener - The listener that will be called
4409
+ */
4410
+ ChildAppWindow.prototype.addEventListener = function (type, listener) {
4411
+ if (type === 'message') {
4412
+ registerHandler('messageForParent', listener);
4413
+ }
4414
+ };
4415
+ return ChildAppWindow;
4416
+ }());
4417
+
4418
+ var ParentAppWindow = /** @class */ (function () {
4419
+ function ParentAppWindow() {
4420
+ }
4421
+ Object.defineProperty(ParentAppWindow, "Instance", {
4422
+ get: function () {
4423
+ // Do you need arguments? Make it a regular method instead.
4424
+ return this._instance || (this._instance = new this());
4425
+ },
4426
+ enumerable: false,
4427
+ configurable: true
4428
+ });
4429
+ /**
4430
+ * Send a message to the ParentAppWindow.
4431
+ *
4432
+ * @param message - The message to send
4433
+ * @param onComplete - The callback to know if the postMessage has been success/failed.
4434
+ */
4435
+ ParentAppWindow.prototype.postMessage = function (message, onComplete) {
4436
+ ensureInitialized(FrameContexts.task);
4437
+ sendMessageToParent('messageForParent', [message], onComplete ? onComplete : getGenericOnCompleteHandler());
4438
+ };
4439
+ /**
4440
+ * Add a listener that will be called when an event is received from the ParentAppWindow.
4441
+ *
4442
+ * @param type - The event to listen to. Currently the only supported type is 'message'.
4443
+ * @param listener - The listener that will be called
4444
+ */
4445
+ ParentAppWindow.prototype.addEventListener = function (type, listener) {
4446
+ if (type === 'message') {
4447
+ registerHandler('messageForChild', listener);
4448
+ }
4449
+ };
4450
+ return ParentAppWindow;
4451
+ }());
4452
+
4453
+
4425
4454
  ;// CONCATENATED MODULE: ./src/internal/mediaUtil.ts
4426
4455
 
4427
4456
 
@@ -6324,6 +6353,9 @@ var settings;
6324
6353
  /* eslint-disable @typescript-eslint/ban-types */
6325
6354
 
6326
6355
 
6356
+
6357
+
6358
+
6327
6359
  /**
6328
6360
  * @deprecated
6329
6361
  * As of 2.0.0-beta.1, please use {@link dialog} namespace instead.
@@ -6336,7 +6368,7 @@ var tasks;
6336
6368
  (function (tasks) {
6337
6369
  /**
6338
6370
  * @deprecated
6339
- * As of 2.0.0-beta.1, please use {@link dialog.open dialog.open(dialogInfo: DialogInfo, submitHandler?: (err: string, result: string) => void): IAppWindow} instead.
6371
+ * As of 2.0.0-beta.4, please use {@link dialog.open(dialogInfo: DialogInfo, submitHandler?: DialogSubmitHandler, messageFromChildHandler?: PostMessageChannel): PostMessageChannel} instead.
6340
6372
  *
6341
6373
  * Allows an app to open the task module.
6342
6374
  *
@@ -6344,7 +6376,22 @@ var tasks;
6344
6376
  * @param submitHandler - Handler to call when the task module is completed
6345
6377
  */
6346
6378
  function startTask(taskInfo, submitHandler) {
6347
- return dialog.open(getDialogInfoFromTaskInfo(taskInfo), submitHandler);
6379
+ taskInfo = getDefaultSizeIfNotProvided(taskInfo);
6380
+ if (taskInfo.card !== undefined || taskInfo.url === undefined) {
6381
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
6382
+ sendMessageToParent('tasks.startTask', [taskInfo], submitHandler);
6383
+ }
6384
+ else if (taskInfo.completionBotId !== undefined) {
6385
+ dialog.bot.open(getBotUrlDialogInfoFromTaskInfo(taskInfo), function (sdkResponse) {
6386
+ return submitHandler(sdkResponse.err, sdkResponse.result);
6387
+ });
6388
+ }
6389
+ else {
6390
+ dialog.open(getUrlDialogInfoFromTaskInfo(taskInfo), function (sdkResponse) {
6391
+ return submitHandler(sdkResponse.err, sdkResponse.result);
6392
+ });
6393
+ }
6394
+ return new ChildAppWindow();
6348
6395
  }
6349
6396
  tasks.startTask = startTask;
6350
6397
  /**
@@ -6372,35 +6419,39 @@ var tasks;
6372
6419
  dialog.submit(result, appIds);
6373
6420
  }
6374
6421
  tasks.submitTask = submitTask;
6375
- function getDialogInfoFromTaskInfo(taskInfo) {
6376
- var dialogHeight = taskInfo.height && typeof taskInfo.height !== 'number'
6377
- ? getDialogDimensionFromTaskModuleDimension(taskInfo.height)
6378
- : taskInfo.height;
6379
- var dialogWidth = taskInfo.width && typeof taskInfo.width !== 'number'
6380
- ? getDialogDimensionFromTaskModuleDimension(taskInfo.width)
6381
- : taskInfo.width;
6382
- var dialogInfo = {
6422
+ function getUrlDialogInfoFromTaskInfo(taskInfo) {
6423
+ var urldialogInfo = {
6383
6424
  url: taskInfo.url,
6384
- card: taskInfo.card,
6385
- height: dialogHeight,
6386
- width: dialogWidth,
6425
+ size: {
6426
+ height: taskInfo.height,
6427
+ width: taskInfo.width,
6428
+ },
6429
+ title: taskInfo.title,
6430
+ fallbackUrl: taskInfo.fallbackUrl,
6431
+ };
6432
+ return urldialogInfo;
6433
+ }
6434
+ tasks.getUrlDialogInfoFromTaskInfo = getUrlDialogInfoFromTaskInfo;
6435
+ function getBotUrlDialogInfoFromTaskInfo(taskInfo) {
6436
+ var botUrldialogInfo = {
6437
+ url: taskInfo.url,
6438
+ size: {
6439
+ height: taskInfo.height,
6440
+ width: taskInfo.width,
6441
+ },
6387
6442
  title: taskInfo.title,
6388
6443
  fallbackUrl: taskInfo.fallbackUrl,
6389
6444
  completionBotId: taskInfo.completionBotId,
6390
6445
  };
6391
- return dialogInfo;
6446
+ return botUrldialogInfo;
6392
6447
  }
6393
- function getDialogDimensionFromTaskModuleDimension(taskModuleDimension) {
6394
- if (taskModuleDimension === TaskModuleDimension.Large) {
6395
- return TaskModuleDimension.Large;
6396
- }
6397
- else if (taskModuleDimension === TaskModuleDimension.Medium) {
6398
- return TaskModuleDimension.Medium;
6399
- }
6400
- else {
6401
- return TaskModuleDimension.Small;
6402
- }
6448
+ tasks.getBotUrlDialogInfoFromTaskInfo = getBotUrlDialogInfoFromTaskInfo;
6449
+ function getDefaultSizeIfNotProvided(taskInfo) {
6450
+ taskInfo.height = taskInfo.height ? taskInfo.height : TaskModuleDimension.Small;
6451
+ taskInfo.width = taskInfo.width ? taskInfo.width : TaskModuleDimension.Small;
6452
+ return taskInfo;
6403
6453
  }
6454
+ tasks.getDefaultSizeIfNotProvided = getDefaultSizeIfNotProvided;
6404
6455
  })(tasks || (tasks = {}));
6405
6456
 
6406
6457
  ;// CONCATENATED MODULE: ./src/public/index.ts