-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into juancard/messageDelay
- Loading branch information
Showing
19 changed files
with
1,368 additions
and
1,294 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-teams-js-2f4e536b-d22a-4105-903c-024e6d9a51a5.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Made the `pages` file treeshakable", | ||
"packageName": "@microsoft/teams-js", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
import { AppId } from '../public/appId'; | ||
import { errorNotSupportedOnPlatform, FrameContexts } from '../public/constants'; | ||
import { | ||
FrameInfo, | ||
ShareDeepLinkParameters, | ||
TabInformation, | ||
TabInstance, | ||
TabInstanceParameters, | ||
} from '../public/interfaces'; | ||
import * as pages from '../public/pages/pages'; | ||
import { runtime } from '../public/runtime'; | ||
import { | ||
sendAndHandleStatusAndReason, | ||
sendAndHandleStatusAndReasonWithDefaultError, | ||
sendAndUnwrap, | ||
sendMessageToParent, | ||
} from './communication'; | ||
import { ensureInitialized } from './internalAPIs'; | ||
import { ApiVersionNumber } from './telemetry'; | ||
|
||
/** | ||
* v2 APIs telemetry file: All of APIs in this capability file should send out API version v2 ONLY | ||
*/ | ||
export const pagesTelemetryVersionNumber: ApiVersionNumber = ApiVersionNumber.V_2; | ||
|
||
export function navigateCrossDomainHelper(apiVersionTag: string, url: string): Promise<void> { | ||
return new Promise<void>((resolve) => { | ||
ensureInitialized( | ||
runtime, | ||
FrameContexts.content, | ||
FrameContexts.sidePanel, | ||
FrameContexts.settings, | ||
FrameContexts.remove, | ||
FrameContexts.task, | ||
FrameContexts.stage, | ||
FrameContexts.meetingStage, | ||
); | ||
if (!pages.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
const errorMessage = | ||
'Cross-origin navigation is only supported for URLs matching the pattern registered in the manifest.'; | ||
resolve(sendAndHandleStatusAndReasonWithDefaultError(apiVersionTag, 'navigateCrossDomain', errorMessage, url)); | ||
}); | ||
} | ||
|
||
export function backStackNavigateBackHelper(apiVersionTag: string): Promise<void> { | ||
return new Promise<void>((resolve) => { | ||
ensureInitialized(runtime); | ||
if (!pages.backStack.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
const errorMessage = 'Back navigation is not supported in the current client or context.'; | ||
resolve(sendAndHandleStatusAndReasonWithDefaultError(apiVersionTag, 'navigateBack', errorMessage)); | ||
}); | ||
} | ||
|
||
export function tabsNavigateToTabHelper(apiVersionTag: string, tabInstance: TabInstance): Promise<void> { | ||
return new Promise<void>((resolve) => { | ||
ensureInitialized(runtime); | ||
if (!pages.tabs.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
const errorMessage = 'Invalid internalTabInstanceId and/or channelId were/was provided'; | ||
resolve(sendAndHandleStatusAndReasonWithDefaultError(apiVersionTag, 'navigateToTab', errorMessage, tabInstance)); | ||
}); | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
export function returnFocusHelper(apiVersionTag: string, navigateForward?: boolean): void { | ||
ensureInitialized(runtime); | ||
if (!pages.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
sendMessageToParent(apiVersionTag, 'returnFocus', [navigateForward]); | ||
} | ||
|
||
export function getTabInstancesHelper( | ||
apiVersionTag: string, | ||
tabInstanceParameters?: TabInstanceParameters, | ||
): Promise<TabInformation> { | ||
return new Promise<TabInformation>((resolve) => { | ||
ensureInitialized(runtime); | ||
if (!pages.tabs.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
/* eslint-disable-next-line strict-null-checks/all */ /* Fix tracked by 5730662 */ | ||
resolve(sendAndUnwrap(apiVersionTag, 'getTabInstances', tabInstanceParameters)); | ||
}); | ||
} | ||
|
||
export function getMruTabInstancesHelper( | ||
apiVersionTag: string, | ||
tabInstanceParameters?: TabInstanceParameters, | ||
): Promise<TabInformation> { | ||
return new Promise<TabInformation>((resolve) => { | ||
ensureInitialized(runtime); | ||
if (!pages.tabs.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
/* eslint-disable-next-line strict-null-checks/all */ /* Fix tracked by 5730662 */ | ||
resolve(sendAndUnwrap(apiVersionTag, 'getMruTabInstances', tabInstanceParameters)); | ||
}); | ||
} | ||
|
||
export function shareDeepLinkHelper(apiVersionTag: string, deepLinkParameters: ShareDeepLinkParameters): void { | ||
ensureInitialized(runtime, FrameContexts.content, FrameContexts.sidePanel, FrameContexts.meetingStage); | ||
if (!pages.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
sendMessageToParent(apiVersionTag, 'shareDeepLink', [ | ||
deepLinkParameters.subPageId, | ||
deepLinkParameters.subPageLabel, | ||
deepLinkParameters.subPageWebUrl, | ||
]); | ||
} | ||
|
||
export function setCurrentFrameHelper(apiVersionTag: string, frameInfo: FrameInfo): void { | ||
ensureInitialized(runtime, FrameContexts.content); | ||
if (!pages.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
sendMessageToParent(apiVersionTag, 'setFrameContext', [frameInfo]); | ||
} | ||
|
||
export function configSetValidityStateHelper(apiVersionTag: string, validityState: boolean): void { | ||
ensureInitialized(runtime, FrameContexts.settings, FrameContexts.remove); | ||
if (!pages.config.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
sendMessageToParent(apiVersionTag, 'settings.setValidityState', [validityState]); | ||
} | ||
|
||
export function getConfigHelper(apiVersionTag: string): Promise<pages.InstanceConfig> { | ||
return new Promise<pages.InstanceConfig>((resolve) => { | ||
ensureInitialized( | ||
runtime, | ||
FrameContexts.content, | ||
FrameContexts.settings, | ||
FrameContexts.remove, | ||
FrameContexts.sidePanel, | ||
); | ||
if (!pages.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
resolve(sendAndUnwrap(apiVersionTag, 'settings.getSettings')); | ||
}); | ||
} | ||
|
||
export function configSetConfigHelper(apiVersionTag: string, instanceConfig: pages.InstanceConfig): Promise<void> { | ||
return new Promise<void>((resolve) => { | ||
ensureInitialized(runtime, FrameContexts.content, FrameContexts.settings, FrameContexts.sidePanel); | ||
if (!pages.config.isSupported()) { | ||
throw errorNotSupportedOnPlatform; | ||
} | ||
resolve(sendAndHandleStatusAndReason(apiVersionTag, 'settings.setSettings', instanceConfig)); | ||
}); | ||
} | ||
|
||
export function isAppNavigationParametersObject( | ||
obj: pages.AppNavigationParameters | pages.NavigateToAppParams, | ||
): obj is pages.AppNavigationParameters { | ||
return obj.appId instanceof AppId; | ||
} | ||
|
||
export function convertNavigateToAppParamsToAppNavigationParameters( | ||
params: pages.NavigateToAppParams, | ||
): pages.AppNavigationParameters { | ||
return { | ||
...params, | ||
appId: new AppId(params.appId), | ||
webUrl: params.webUrl ? new URL(params.webUrl) : undefined, | ||
}; | ||
} | ||
|
||
export function convertAppNavigationParametersToNavigateToAppParams( | ||
params: pages.AppNavigationParameters, | ||
): pages.NavigateToAppParams { | ||
return { | ||
...params, | ||
appId: params.appId.toString(), | ||
webUrl: params.webUrl ? params.webUrl.toString() : undefined, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.