@microsoft/teams-js
Version:
Microsoft Client SDK for building app for Microsoft hosts
2 lines (1 loc) • 2.34 kB
JavaScript
import{ensureInitialized as t}from"./internalAPIs.js";import{FrameContexts as e,errorNotSupportedOnPlatform as o,DialogDimension as r}from"../public/constants.js";import{runtime as s}from"../public/runtime.js";import{sendMessageToParent as i}from"./communication.js";import{GlobalVars as n}from"./globalVars.js";import{registerHandler as a,removeHandler as l}from"./handlers.js";import{getApiVersionTag as m}from"./telemetry.js";import{isSupported as c}from"../public/dialog/update.js";import{isSupported as u,getDialogInfoFromUrlDialogInfo as d,getDialogInfoFromBotUrlDialogInfo as g}from"../public/dialog/url/url.js";import{isSupported as f}from"../public/dialog/url/bot.js";const p="v2";function h(r,n){if(t(s,e.content,e.sidePanel,e.task,e.meetingStage),!c())throw o;i(r,"tasks.updateTask",[n])}function b(r,n,c,g){if(t(s,e.content,e.sidePanel,e.meetingStage),!u())throw o;g&&a(m(p,"dialog.url.registerMessageForParentHandler"),"messageForParent",g);const f=d(n);i(r,"tasks.startTask",[f],((t,e)=>{null==c||c({err:t,result:e}),l("messageForParent")}))}function k(r,n,c,u){if(t(s,e.content,e.sidePanel,e.meetingStage),!f())throw o;u&&a(m(p,"dialog.url.bot.registerMessageForParentHandler"),"messageForParent",u);const d=g(n);i(r,"tasks.startTask",[d],((t,e)=>{null==c||c({err:t,result:e}),l("messageForParent")}))}function j(r,a,l){if(t(s,e.content,e.task),!u())throw o;n.frameContext===e.content&&console.warn("dialog.submit should not be called from FrameContext.content.\nIf dialog.submit was called from inside the dialog, please disregard this message.\nThis issue occurs due to a bug in Teams mobile where the dialog is incorrectly identified as being in the content FrameContext.\nWe are working to resolve this."),i(r,"tasks.completeTask",[a,l?Array.isArray(l)?l:[l]:[]])}function w(t){return{card:t.card,height:t.size?t.size.height:r.Small,width:t.size?t.size.width:r.Small,title:t.title}}function P(t){const e=w(t);return e.completionBotId=t.completionBotId,e}const F=[];function S(t){n.frameContext&&(n.frameContext===e.task?F.push(t):l("messageForChild"))}export{k as botUrlOpenHelper,p as dialogTelemetryVersionNumber,w as getDialogInfoFromAdaptiveCardDialogInfo,P as getDialogInfoFromBotAdaptiveCardDialogInfo,S as handleDialogMessage,F as storedMessages,h as updateResizeHelper,b as urlOpenHelper,j as urlSubmitHelper};