@microsoft/teams-js 2.0.0-beta.4-dev.12 → 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
  *
@@ -2770,7 +2812,25 @@ export namespace dialog {
2770
2812
  * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
2771
2813
  */
2772
2814
  function submit(result?: string | object, appIds?: string | string[]): void;
2815
+ /**
2816
+ * Send message to the parent from dialog
2817
+ *
2818
+ * @param message - The message to send
2819
+ * @param onComplete - The callback to know if the message to parent has been success/failed.
2820
+ */
2821
+ function sendMessageToParentFromDialog(message: any, onComplete?: (status: boolean, reason?: string) => void): void;
2822
+ /**
2823
+ * Fucntion to call when an event is received from the Parent
2824
+ *
2825
+ * @param type - The event to listen to. Currently the only supported type is 'message'.
2826
+ * @param listener - listener - The listener that will be called.
2827
+ */
2828
+ function registerOnMessageFromParent(listener: (message: any) => void): void;
2773
2829
  function isSupported(): boolean;
2830
+ namespace bot {
2831
+ function open(botUrlDialogInfo: BotUrlDialogInfo, submitHandler?: DialogSubmitHandler, messageFromChildHandler?: PostMessageChannel): PostMessageChannel;
2832
+ function isSupported(): boolean;
2833
+ }
2774
2834
  }
2775
2835
 
2776
2836
  /**
@@ -5034,7 +5094,7 @@ export namespace settings {
5034
5094
  export namespace tasks {
5035
5095
  /**
5036
5096
  * @deprecated
5037
- * 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.
5038
5098
  *
5039
5099
  * Allows an app to open the task module.
5040
5100
  *
@@ -5061,5 +5121,8 @@ export namespace tasks {
5061
5121
  * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
5062
5122
  */
5063
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;
5064
5127
  }
5065
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.12";
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.
@@ -1220,6 +1220,8 @@ var validOrigins = [
1220
1220
  '*.sharepointonline.com',
1221
1221
  'outlook.office.com',
1222
1222
  'outlook-sdf.office.com',
1223
+ 'outlook.office365.com',
1224
+ 'outlook-sdf.office365.com',
1223
1225
  '*.teams.microsoft.com',
1224
1226
  'www.office.com',
1225
1227
  'word.office.com',
@@ -1818,7 +1820,9 @@ var runtime = {
1818
1820
  calendar: undefined,
1819
1821
  call: undefined,
1820
1822
  chat: undefined,
1821
- dialog: undefined,
1823
+ dialog: {
1824
+ bot: undefined,
1825
+ },
1822
1826
  location: undefined,
1823
1827
  logs: undefined,
1824
1828
  mail: undefined,
@@ -1854,7 +1858,9 @@ var teamsRuntimeConfig = {
1854
1858
  bot: {},
1855
1859
  call: {},
1856
1860
  chat: {},
1857
- dialog: {},
1861
+ dialog: {
1862
+ bot: {},
1863
+ },
1858
1864
  files: {},
1859
1865
  location: {},
1860
1866
  logs: {},
@@ -4245,6 +4251,134 @@ var appInstallDialog;
4245
4251
  appInstallDialog.isSupported = isSupported;
4246
4252
  })(appInstallDialog || (appInstallDialog = {}));
4247
4253
 
4254
+ ;// CONCATENATED MODULE: ./src/public/dialog.ts
4255
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4256
+ /* eslint-disable @typescript-eslint/ban-types */
4257
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4258
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
4259
+ var t = {};
4260
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4261
+ t[p] = s[p];
4262
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
4263
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
4264
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
4265
+ t[p[i]] = s[p[i]];
4266
+ }
4267
+ return t;
4268
+ };
4269
+
4270
+
4271
+
4272
+
4273
+
4274
+
4275
+ var dialog;
4276
+ (function (dialog) {
4277
+ /**
4278
+ * Allows an app to open the dialog module.
4279
+ *
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.
4285
+ */
4286
+ function open(urlDialogInfo, submitHandler, messageFromChildHandler) {
4287
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
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;
4299
+ }
4300
+ dialog.open = open;
4301
+ /**
4302
+ * Update height/width dialog info properties.
4303
+ *
4304
+ * @param dialogInfo - An object containing width and height properties
4305
+ */
4306
+ function resize(dialogInfo) {
4307
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
4308
+ var width = dialogInfo.width, height = dialogInfo.height, extra = __rest(dialogInfo, ["width", "height"]);
4309
+ if (!Object.keys(extra).length) {
4310
+ sendMessageToParent('tasks.updateTask', [dialogInfo]);
4311
+ }
4312
+ else {
4313
+ throw new Error('resize requires a dialogInfo argument containing only width and height');
4314
+ }
4315
+ }
4316
+ dialog.resize = resize;
4317
+ /**
4318
+ * Submit the dialog module.
4319
+ *
4320
+ * @param result - Contains the result to be sent to the bot or the app. Typically a JSON object or a serialized version of it
4321
+ * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
4322
+ */
4323
+ function submit(result, appIds) {
4324
+ ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
4325
+ // Send tasks.completeTask instead of tasks.submitTask message for backward compatibility with Mobile clients
4326
+ sendMessageToParent('tasks.completeTask', [result, Array.isArray(appIds) ? appIds : [appIds]]);
4327
+ }
4328
+ dialog.submit = submit;
4329
+ /**
4330
+ * Send message to the parent from dialog
4331
+ *
4332
+ * @param message - The message to send
4333
+ * @param onComplete - The callback to know if the message to parent has been success/failed.
4334
+ */
4335
+ function sendMessageToParentFromDialog(
4336
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4337
+ message, onComplete) {
4338
+ ensureInitialized(FrameContexts.task);
4339
+ sendMessageToParent('messageForParent', [message], onComplete ? onComplete : getGenericOnCompleteHandler());
4340
+ }
4341
+ dialog.sendMessageToParentFromDialog = sendMessageToParentFromDialog;
4342
+ /**
4343
+ * Fucntion to call when an event is received from the Parent
4344
+ *
4345
+ * @param type - The event to listen to. Currently the only supported type is 'message'.
4346
+ * @param listener - listener - The listener that will be called.
4347
+ */
4348
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4349
+ function registerOnMessageFromParent(listener) {
4350
+ ensureInitialized();
4351
+ registerHandler('messageForChild', listener);
4352
+ }
4353
+ dialog.registerOnMessageFromParent = registerOnMessageFromParent;
4354
+ function isSupported() {
4355
+ return runtime.supports.dialog ? true : false;
4356
+ }
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 = {}));
4380
+ })(dialog || (dialog = {}));
4381
+
4248
4382
  ;// CONCATENATED MODULE: ./src/public/appWindow.ts
4249
4383
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4250
4384
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -4317,81 +4451,6 @@ var ParentAppWindow = /** @class */ (function () {
4317
4451
  }());
4318
4452
 
4319
4453
 
4320
- ;// CONCATENATED MODULE: ./src/public/dialog.ts
4321
- /* eslint-disable @typescript-eslint/ban-types */
4322
- /* eslint-disable @typescript-eslint/no-unused-vars */
4323
- var __rest = (undefined && undefined.__rest) || function (s, e) {
4324
- var t = {};
4325
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4326
- t[p] = s[p];
4327
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
4328
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
4329
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
4330
- t[p[i]] = s[p[i]];
4331
- }
4332
- return t;
4333
- };
4334
-
4335
-
4336
-
4337
-
4338
-
4339
- /**
4340
- * Namespace to interact with the dialog module-specific part of the SDK.
4341
- *
4342
- * @remarks
4343
- * This object is usable only on the content frame.
4344
- *
4345
- * @beta
4346
- */
4347
- var dialog;
4348
- (function (dialog) {
4349
- /**
4350
- * Allows an app to open the dialog module.
4351
- *
4352
- * @param dialogInfo - An object containing the parameters of the dialog module
4353
- * @param submitHandler - Handler to call when the task module is completed
4354
- */
4355
- function open(dialogInfo, submitHandler) {
4356
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage);
4357
- sendMessageToParent('tasks.startTask', [dialogInfo], submitHandler);
4358
- return new ChildAppWindow();
4359
- }
4360
- dialog.open = open;
4361
- /**
4362
- * Update height/width dialog info properties.
4363
- *
4364
- * @param dialogInfo - An object containing width and height properties
4365
- */
4366
- function resize(dialogInfo) {
4367
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
4368
- var width = dialogInfo.width, height = dialogInfo.height, extra = __rest(dialogInfo, ["width", "height"]);
4369
- if (!Object.keys(extra).length) {
4370
- sendMessageToParent('tasks.updateTask', [dialogInfo]);
4371
- }
4372
- else {
4373
- throw new Error('resize requires a dialogInfo argument containing only width and height');
4374
- }
4375
- }
4376
- dialog.resize = resize;
4377
- /**
4378
- * Submit the dialog module.
4379
- *
4380
- * @param result - Contains the result to be sent to the bot or the app. Typically a JSON object or a serialized version of it
4381
- * @param appIds - Helps to validate that the call originates from the same appId as the one that invoked the task module
4382
- */
4383
- function submit(result, appIds) {
4384
- ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.meetingStage);
4385
- // Send tasks.completeTask instead of tasks.submitTask message for backward compatibility with Mobile clients
4386
- sendMessageToParent('tasks.completeTask', [result, Array.isArray(appIds) ? appIds : [appIds]]);
4387
- }
4388
- dialog.submit = submit;
4389
- function isSupported() {
4390
- return runtime.supports.dialog ? true : false;
4391
- }
4392
- dialog.isSupported = isSupported;
4393
- })(dialog || (dialog = {}));
4394
-
4395
4454
  ;// CONCATENATED MODULE: ./src/internal/mediaUtil.ts
4396
4455
 
4397
4456
 
@@ -6294,6 +6353,9 @@ var settings;
6294
6353
  /* eslint-disable @typescript-eslint/ban-types */
6295
6354
 
6296
6355
 
6356
+
6357
+
6358
+
6297
6359
  /**
6298
6360
  * @deprecated
6299
6361
  * As of 2.0.0-beta.1, please use {@link dialog} namespace instead.
@@ -6306,7 +6368,7 @@ var tasks;
6306
6368
  (function (tasks) {
6307
6369
  /**
6308
6370
  * @deprecated
6309
- * 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.
6310
6372
  *
6311
6373
  * Allows an app to open the task module.
6312
6374
  *
@@ -6314,7 +6376,22 @@ var tasks;
6314
6376
  * @param submitHandler - Handler to call when the task module is completed
6315
6377
  */
6316
6378
  function startTask(taskInfo, submitHandler) {
6317
- 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();
6318
6395
  }
6319
6396
  tasks.startTask = startTask;
6320
6397
  /**
@@ -6342,35 +6419,39 @@ var tasks;
6342
6419
  dialog.submit(result, appIds);
6343
6420
  }
6344
6421
  tasks.submitTask = submitTask;
6345
- function getDialogInfoFromTaskInfo(taskInfo) {
6346
- var dialogHeight = taskInfo.height && typeof taskInfo.height !== 'number'
6347
- ? getDialogDimensionFromTaskModuleDimension(taskInfo.height)
6348
- : taskInfo.height;
6349
- var dialogWidth = taskInfo.width && typeof taskInfo.width !== 'number'
6350
- ? getDialogDimensionFromTaskModuleDimension(taskInfo.width)
6351
- : taskInfo.width;
6352
- var dialogInfo = {
6422
+ function getUrlDialogInfoFromTaskInfo(taskInfo) {
6423
+ var urldialogInfo = {
6353
6424
  url: taskInfo.url,
6354
- card: taskInfo.card,
6355
- height: dialogHeight,
6356
- 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
+ },
6357
6442
  title: taskInfo.title,
6358
6443
  fallbackUrl: taskInfo.fallbackUrl,
6359
6444
  completionBotId: taskInfo.completionBotId,
6360
6445
  };
6361
- return dialogInfo;
6446
+ return botUrldialogInfo;
6362
6447
  }
6363
- function getDialogDimensionFromTaskModuleDimension(taskModuleDimension) {
6364
- if (taskModuleDimension === TaskModuleDimension.Large) {
6365
- return TaskModuleDimension.Large;
6366
- }
6367
- else if (taskModuleDimension === TaskModuleDimension.Medium) {
6368
- return TaskModuleDimension.Medium;
6369
- }
6370
- else {
6371
- return TaskModuleDimension.Small;
6372
- }
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;
6373
6453
  }
6454
+ tasks.getDefaultSizeIfNotProvided = getDefaultSizeIfNotProvided;
6374
6455
  })(tasks || (tasks = {}));
6375
6456
 
6376
6457
  ;// CONCATENATED MODULE: ./src/public/index.ts