@microsoft/teams-js
Version:
Microsoft Client SDK for building app for Microsoft hosts
2 lines (1 loc) • 4.19 kB
JavaScript
import{__awaiter as t}from"../../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.24.4_tslib@2.6.3_typescript@4.9.5/node_modules/tslib/tslib.es6.js";import{callFunctionInHost as i,callFunctionInHostAndHandleResponse as e}from"../../internal/communication.js";import{registerHandlerHelper as n}from"../../internal/handlers.js";import{ensureInitialized as s,ensureInitializeCalled as o}from"../../internal/internalAPIs.js";import{ResponseHandler as d}from"../../internal/responseHandler.js";import{getLogger as r,getApiVersionTag as g}from"../../internal/telemetry.js";import{isSdkError as h}from"../../public/interfaces.js";import{runtime as w}from"../../public/runtime.js";const l="v1",a=r("widgetHosting");function u(){return s(w)&&!!w.supports.widgetHosting}function c(i,n){return t(this,void 0,void 0,(function*(){return o(),a("Calling tool with widgetId and input: ",{widgetId:i,input:n}),e("widgetHosting.callTool",[new b(i,n)],new j,g(l,"widgetHosting.callTool"),h)}))}function p(e,n){return t(this,void 0,void 0,(function*(){return o(),a("Sending follow-up message with widgetId and prompt: ",{widgetId:e,prompt:n.prompt}),i("widgetHosting.sendFollowUpMessage",[new q(e,n)],g(l,"widgetHosting.sendFollowUpMessage"))}))}function I(e,n){return t(this,void 0,void 0,(function*(){return o(),a("Requesting display mode with widgetId: ",{widgetId:e,mode:n.mode}),i("widgetHosting.requestDisplayMode",[new x(e,n)],g(l,"widgetHosting.requestDisplayMode"))}))}function m(i,n){return t(this,void 0,void 0,(function*(){return o(),a("Requesting modal with widgetId and options: ",{widgetId:i,options:n}),e("widgetHosting.requestModal",[new W(i,n)],new M,g(l,"widgetHosting.requestModal"),h)}))}function f(t,e){o(),a("Notifying intrinsic height with widgetId: ",{widgetId:t,height:e}),i("widgetHosting.notifyIntrinsicHeight",[new C(t,e)],g(l,"widgetHosting.notifyIntrinsicHeight"))}function H(t,e,n){o(),a("Content size changed with widgetId: ",{widgetId:t,width:e,height:n}),i("widgetHosting.contentSizeChanged",[new E(t,e,n)],g(l,"widgetHosting.contentSizeChanged"))}function v(e,n){return t(this,void 0,void 0,(function*(){return o(),a("Setting widget state with widgetId: ",{widgetId:e,state:n}),i("widgetHosting.setWidgetState",[new _(e,n)],g(l,"widgetHosting.setWidgetState"))}))}function y(t,e){o(),a("Opening external URL with widgetId: ",{widgetId:t,href:e.href}),i("widgetHosting.openExternal",[new S(t,e)],g(l,"widgetHosting.openExternal"))}function z(t){n(g(l,"widgetHosting.registerModalCloseHandler"),"widgetHosting.closeWidgetModal",t,[],(()=>{if(!u())throw new Error("Widget Hosting is not supported on this platform")}))}class j extends d{validate(t){return null!==t&&"object"==typeof t}deserialize(t){return t}}class M extends d{validate(t){return null!==t&&"object"==typeof t}deserialize(t){return t}}class b{constructor(t,i){this.widgetId=t,this.toolInput=i}serialize(){return{widgetId:this.widgetId,name:this.toolInput.name,arguments:this.toolInput.arguments}}}class q{constructor(t,i){this.widgetId=t,this.args=i}serialize(){return{widgetId:this.widgetId,prompt:this.args.prompt}}}class x{constructor(t,i){this.widgetId=t,this.args=i}serialize(){return{widgetId:this.widgetId,mode:this.args.mode}}}class S{constructor(t,i){this.widgetId=t,this.payload=i}serialize(){return{widgetId:this.widgetId,href:this.payload.href}}}class _{constructor(t,i){this.widgetId=t,this.state=i}serialize(){return{widgetId:this.widgetId,state:this.state}}}class C{constructor(t,i){this.widgetId=t,this.height=i}serialize(){return{widgetId:this.widgetId,height:this.height}}}class W{constructor(t,i){this.widgetId=t,this.options=i}serialize(){return{widgetId:this.widgetId,id:this.options.id,title:this.options.title,content:this.options.content,width:this.options.width,height:this.options.height}}}class E{constructor(t,i,e){this.widgetId=t,this.width=i,this.height=e}serialize(){return{widgetId:this.widgetId,width:this.width,height:this.height}}}export{c as callTool,H as contentSizeChanged,u as isSupported,f as notifyIntrinsicHeight,y as openExternal,z as registerModalCloseHandler,I as requestDisplayMode,m as requestModal,p as sendFollowUpMessage,v as setWidgetState};