Skip to content

Commit

Permalink
Add visionOS client type (#2670)
Browse files Browse the repository at this point in the history
* Add visionOS as new HostClientType

* Add change file

* Update change file placeholder comment

* Fix linting issues
  • Loading branch information
wyAbhishek authored Feb 3, 2025
1 parent d10369a commit 87cce22
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Add visionOS client type support for Teams SDK. This change will enable app developers to find out if app is running on visionOS",
"packageName": "@microsoft/teams-js",
"email": "[email protected]",
"dependentChangeType": "patch"
}
5 changes: 3 additions & 2 deletions packages/teams-js/src/internal/internalAPIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function isCurrentSDKVersionAtLeast(requiredVersion: string = defaultSDKV

/**
* @hidden
* Helper function to identify if host client is either android, ios, or ipados
* Helper function to identify if host client is either android, ios, ipados, or visionOS
*
* @internal
* Limited to Microsoft-internal use
Expand All @@ -100,7 +100,8 @@ export function isHostClientMobile(): boolean {
return (
GlobalVars.hostClientType == HostClientType.android ||
GlobalVars.hostClientType == HostClientType.ios ||
GlobalVars.hostClientType == HostClientType.ipados
GlobalVars.hostClientType == HostClientType.ipados ||
GlobalVars.hostClientType == HostClientType.visionOS
);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/teams-js/src/public/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export enum HostClientType {
ipados = 'ipados',
/** The host is running on a macOS client, which runs on devices such as MacBooks. */
macos = 'macos',
/** The host is running on a visionOS client, which runs on devices such as Apple Vision. */
visionOS = 'visionOS',
/**
* @deprecated
* As of TeamsJS v2.0.0, please use {@link teamsRoomsWindows} instead.
Expand Down
7 changes: 4 additions & 3 deletions packages/teams-js/src/public/nestedAppAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ export function isNAAChannelRecommended(): boolean {

function isNAAChannelRecommendedForLegacyTeamsMobile(): boolean {
return ensureInitialized(runtime) &&
isHostAndroidOrIOSOrIPadOS() &&
isHostAndroidOrIOSOrIPadOSOrVisionOS() &&
runtime.isLegacyTeams &&
runtime.supports.nestedAppAuth
? true
: false;
}

function isHostAndroidOrIOSOrIPadOS(): boolean {
function isHostAndroidOrIOSOrIPadOSOrVisionOS(): boolean {
return (
GlobalVars.hostClientType === HostClientType.android ||
GlobalVars.hostClientType === HostClientType.ios ||
GlobalVars.hostClientType === HostClientType.ipados
GlobalVars.hostClientType === HostClientType.ipados ||
GlobalVars.hostClientType === HostClientType.visionOS
);
}
9 changes: 7 additions & 2 deletions packages/teams-js/src/public/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,12 @@ const v1NonMobileHostClientTypes = [
HostClientType.teamsDisplays,
];

export const v1MobileHostClientTypes = [HostClientType.android, HostClientType.ios, HostClientType.ipados];
export const v1MobileHostClientTypes = [
HostClientType.android,
HostClientType.ios,
HostClientType.ipados,
HostClientType.visionOS,
];

export const v1HostClientTypes = [...v1NonMobileHostClientTypes, ...v1MobileHostClientTypes];

Expand Down Expand Up @@ -599,7 +604,7 @@ export const mapTeamsVersionToSupportedCapabilities: Record<string, Array<ICapab
'2.1.1': [
{
capability: { nestedAppAuth: {} },
hostClientTypes: [HostClientType.android, HostClientType.ios, HostClientType.ipados],
hostClientTypes: [HostClientType.android, HostClientType.ios, HostClientType.ipados, HostClientType.visionOS],
},
],
};
Expand Down
3 changes: 2 additions & 1 deletion packages/teams-js/src/public/webStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export async function isWebStorageClearedOnUserLogOut(): Promise<boolean> {
runtime.isLegacyTeams &&
(GlobalVars.hostClientType === HostClientType.android ||
GlobalVars.hostClientType === HostClientType.ios ||
GlobalVars.hostClientType === HostClientType.ipados) &&
GlobalVars.hostClientType === HostClientType.ipados ||
GlobalVars.hostClientType === HostClientType.visionOS) &&
(await getHostName()) === HostName.teams
) {
// On Teams Mobile, they haven't yet implemented this capability. However, for compatibility reasons, we need
Expand Down
1 change: 1 addition & 0 deletions packages/teams-js/test/public/authentication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('Testing authentication capability', () => {
HostClientType.ios,
HostClientType.ipados,
HostClientType.macos,
HostClientType.visionOS,
HostClientType.rigel,
HostClientType.teamsRoomsWindows,
HostClientType.teamsRoomsAndroid,
Expand Down
1 change: 1 addition & 0 deletions packages/teams-js/test/public/clipboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ describe('clipboard', () => {
HostClientType.desktop,
HostClientType.ios,
HostClientType.ipados,
HostClientType.visionOS,
HostClientType.macos,
]).forEach((mobilePlatform) => {
if (allowedContexts.some((allowedContext) => allowedContext === context)) {
Expand Down

0 comments on commit 87cce22

Please sign in to comment.