Skip to content

Commit 3632af8

Browse files
Added renderingSurface property to {app.Page.Context} (#2794)
* initial changes for renderingSurface data * adding comments * adding RenderingSurface to index.ts * run changefile * adding comments * adding comments * increase the bundle size --------- Co-authored-by: Niharika <[email protected]>
1 parent fda12a0 commit 3632af8

File tree

7 files changed

+61
-4
lines changed

7 files changed

+61
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Added `renderingSurface` property to `{app.Page.Context}` capability.",
4+
"packageName": "@microsoft/teams-js",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"brotli": false,
163163
"path": "./packages/teams-js/dist/esm/packages/teams-js/src/index.js",
164164
"import": "{ app, authentication, pages }",
165-
"limit": "57.204 KB"
165+
"limit": "57.33 KB"
166166
},
167167
{
168168
"brotli": false,

packages/teams-js/src/public/app/app.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ import { ApiName, ApiVersionNumber, getApiVersionTag, getLogger } from '../../in
1616
import { inServerSideRenderingEnvironment } from '../../internal/utils';
1717
import * as messageChannels from '../../private/messageChannels/messageChannels';
1818
import { AppId } from '../appId';
19-
import { ChannelType, FrameContexts, HostClientType, HostName, TeamType, UserTeamRole } from '../constants';
19+
import {
20+
ChannelType,
21+
FrameContexts,
22+
HostClientType,
23+
HostName,
24+
RenderingSurfaces,
25+
TeamType,
26+
UserTeamRole,
27+
} from '../constants';
2028
import {
2129
ActionInfo,
2230
Context as LegacyContext,
@@ -297,6 +305,12 @@ export interface PageInfo {
297305
*/
298306
frameContext: FrameContexts;
299307

308+
/**
309+
* The mode or surface where the page is rendered (e.g. sidePanel, meetingStage, etc.)
310+
* This will be used by the app developers in future to know where in the host the app is rendered instead of the frameContext.
311+
*/
312+
renderingSurface?: RenderingSurfaces;
313+
300314
/**
301315
* The developer-defined unique ID for the sub-page this content points to.
302316
* This field should be used to restore to a specific state within a page,
@@ -824,6 +838,7 @@ function transformLegacyContextToAppContext(legacyContext: LegacyContext): Conte
824838
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
825839
// @ts-ignore
826840
frameContext: legacyContext.frameContext ? legacyContext.frameContext : GlobalVars.frameContext,
841+
renderingSurface: legacyContext.renderingSurface ? legacyContext.renderingSurface : undefined,
827842
subPageId: legacyContext.subEntityId,
828843
isFullScreen: legacyContext.isFullScreen,
829844
isMultiWindow: legacyContext.isMultiWindow,

packages/teams-js/src/public/constants.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ export enum FrameContexts {
102102
meetingStage = 'meetingStage',
103103
}
104104

105+
/**
106+
* RenderingSurfaces describes the context or surface in which your app is being displayed within the host application.
107+
* This parameter allows your app to detect where it is rendered (for example, in a side panel or stage view)
108+
* and adjust its behavior or UI accordingly. The intent is to help developers understand the user's context of use,
109+
* not the exact pixel size or layout. If a host (such as Outlook Meeting Apps) changes the size of a surface (e.g., makes the side panel larger),
110+
* it will still use the same RenderingSurface value. Developers are expected to use responsive UI techniques to adapt to size changes,
111+
* since the user's context and intent remain the same even if the surface dimensions change.
112+
*/
113+
export enum RenderingSurfaces {
114+
/**
115+
* The mode the copilot app rendered by the host.
116+
*/
117+
copilotSidePanel = 'copilotSidePanel',
118+
}
119+
105120
/**
106121
* Indicates the team type, currently used to distinguish between different team
107122
* types in Office 365 for Education (team types 1, 2, 3, and 4).

packages/teams-js/src/public/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export {
55
FrameContexts,
66
HostClientType,
77
HostName,
8+
RenderingSurfaces,
89
TaskModuleDimension,
910
TeamType,
1011
UserTeamRole,

packages/teams-js/src/public/interfaces.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any*/
22

3-
import { ChannelType, DialogDimension, HostClientType, HostName, TeamType, UserTeamRole } from './constants';
3+
import {
4+
ChannelType,
5+
DialogDimension,
6+
HostClientType,
7+
HostName,
8+
RenderingSurfaces,
9+
TeamType,
10+
UserTeamRole,
11+
} from './constants';
412
import { FrameContexts } from './constants';
513

614
/**
@@ -582,6 +590,14 @@ export interface Context {
582590
*/
583591
frameContext?: FrameContexts;
584592

593+
/**
594+
* @deprecated
595+
* As of TeamsJS v2.0.0, please use {@link app.PageInfo.renderingSurface | app.Context.page.renderingSurface} instead
596+
*
597+
* The surface where the tab is rendered (sidePanel, meeting, chat, channel)
598+
*/
599+
renderingSurface?: RenderingSurfaces;
600+
585601
/**
586602
* @deprecated
587603
* As of TeamsJS v2.0.0, please use {@link app.Context | app.Context.sharepoint} instead

packages/teams-js/test/public/app.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
FrameContexts,
1010
HostClientType,
1111
HostName,
12+
RenderingSurfaces,
1213
TeamType,
1314
UserTeamRole,
1415
} from '../../src/public/constants';
@@ -412,7 +413,7 @@ describe('Testing app capability', () => {
412413
message = utils.findMessageByFunc('getContext');
413414
expect(message).not.toBeNull();
414415
});
415-
416+
416417
Object.values(FrameContexts).forEach((context) => {
417418
it(`app.getContext should successfully get frame context in ${context} context`, async () => {
418419
await utils.initializeWithContext(context);
@@ -556,6 +557,7 @@ describe('Testing app capability', () => {
556557
isMultiWindow: true,
557558
isBackgroundLoad: true,
558559
frameContext: context,
560+
renderingSurface: RenderingSurfaces.copilotSidePanel,
559561
appLaunchId: 'appLaunchId',
560562
userDisplayName: 'someTestUser',
561563
teamSiteId: 'someSiteId',
@@ -588,6 +590,7 @@ describe('Testing app capability', () => {
588590
page: {
589591
id: 'someEntityId',
590592
subPageId: 'someSubEntityId',
593+
renderingSurface: RenderingSurfaces.copilotSidePanel,
591594
isFullScreen: true,
592595
sourceOrigin: 'www.origin.com',
593596
frameContext: context,

0 commit comments

Comments
 (0)