import { ServiceKey, type ServiceScope } from '@microsoft/sp-core-library'; import AzureActiveDirectoryInfo, { type IAzureActiveDirectoryInfoParameters } from './AzureActiveDirectoryInfo'; import CultureInfo, { type ICultureInfoData } from './CultureInfo'; import type { ISearchData } from './ISearchData'; import type { IPageData } from './Page'; import type Page from './Page'; import SPFeatureInfo, { type ISPFeatureInfoData } from './SPFeatureInfo'; import SPList, { type ISPListData } from './SPList'; import SPListItem, { type ISPListItemData } from './SPListItem'; import SPSite, { type ISPSiteData } from './SPSite'; import SPUser, { type ISPUserData } from './SPUser'; import SPWeb, { type ISPWebData } from './SPWeb'; /** * Interface for properties necessary for building a `PageContext` object. * @internal */ export interface IPageContextData { aadInfo?: IAzureActiveDirectoryInfoParameters; cultureInfo: ICultureInfoData; list?: ISPListData; listItem?: ISPListItemData; page: IPageData; site: ISPSiteData; user: ISPUserData; web: ISPWebData; featureInfo: ISPFeatureInfoData; } /** * The SharePoint page context object. * * @remarks * The page context provides standard definitions for common SharePoint objects * that need to be shared between the client-side application, web parts, and other * components. Typically the data is fetched via REST queries when navigating to a * new page, but it can also be preloaded by the web server, or filled from a custom * application cache. * @public */ export default class PageContext { /** * The service key for PageContext. */ static readonly serviceKey: ServiceKey; private static _logSource; private static _pageContextInfoId; private static _pageContextUserDynamicProperty; private static _pageContextSiteDataDynamicProperty; private static _pageContextUrlDataDynamicProperty; private static _pageContextSearchDataDynamicProperty; private _aadInfo; private _cultureInfo; private _list; private _listItem; private _page; private _site; private _user; private _web; private _spFeatureInfo; private _legacyPageContext; private _isInitialized; private _serviceScope; private _pageContextDataSource; private _searchData; private _initializationData; constructor(serviceScope: ServiceScope); /** * Initializes the Page Context. * @internal */ initialize(options: IPageContextData, legacyPageContext?: any): void; /** * Sets the search query value for the page context dynamic data. * Updating the value triggers a notification to dynamic data consumers for that property. * * @param searchQuery - Search query to set. * @internal */ _setSearchQuery(searchQuery: string | undefined): void; /** * Sets the search query and scope query value for the page context dynamic data. * Updating the value triggers a notification to dynamic data consumers for that property. * * @param searchData - Search Data to set. * @internal */ _setSearchData(searchData: ISearchData): void; /** * Contextual information for communicating with Azure Active Directory. * If the current page doesn't have an associated Azure Active Directory tenant, this * property will be undefined. */ get aadInfo(): AzureActiveDirectoryInfo | undefined; /** * It provides culture info for the current user of the application. * This class is primarily used with the `PageContext` class. */ get cultureInfo(): CultureInfo; /** * Contextual information for the SharePoint list that is hosting the page. * If there is no list associated to the current page, this property will be undefined. */ get list(): SPList | undefined; /** * Contextual information for the SharePoint list item that is hosting the page. * If there is no list item associated to the current page, this property will be undefined. */ get listItem(): SPListItem | undefined; /** * Exposes information that is associated with the SharePoint web page that is currently being displayed. * @alpha */ get page(): Page; /** * Contextual information for the SharePoint site collection ("SPSite") that is hosting the page. */ get site(): SPSite; /** * It provides contextual information for the SharePoint user that is accessing the page. * This class is primarily used with the `PageContext` class. */ get user(): SPUser; /** * Contextual information for the SharePoint site ("SPWeb") that is hosting the page. */ get web(): SPWeb; /** * Contextual information for the features that are enabled on the SharePoint site * that is hosting the page. * @internal */ get _featureInfo(): SPFeatureInfo; /** * An object providing classic SharePoint properties that may be required by certain legacy scripts. * * @remarks * This property is provided to facilitate migration of legacy code. It returns a JavaScript * object whose contents are similar to the `_spPageContextInfo` window variable from classic pages. * The contents of this variable may change in future releases of SharePoint. For this reason, * new projects are encouraged to use the SharePoint Framework TypeScript APIs instead, since they * are fully documented and provide reliable backwards compatibility guarantees. * * NOTE: If certain functionality is exposed in the `legacyPageContext` but does not seem to have * a proper TypeScript API, please file an issue on GitHub. The intention is that no modern application * should need to rely on the `legacyPageContext` object. */ get legacyPageContext(): any; /** * Returns whether the `PageContext` has been initialized. */ get isInitialized(): boolean; /** * Returns data object that was used to initialize the `PageContext` instance. * * @internal */ get _initData(): IPageContextData | undefined; private _getPropertyDefinitions; private _getPropertyValue; private _getAnnotatedPropertyValue; /** * Returns decoded key-value pair collection for the current page's query parameters. * * @remarks * If the key or value doesn't exist, it adds an empty string instead. */ private _getUrlQueryParameterCollection; /** * Returns the fragment identifier for the current page's url. */ private _getUrlFragmentIdentifier; } //# sourceMappingURL=PageContext.d.ts.map