UNPKG

@microsoft/sp-webpart-base

Version:

SharePoint Framework support for building web parts

51 lines 2.43 kB
import type { IClientSideWebPartManifest } from '@microsoft/sp-module-interfaces'; import { DisplayMode } from '@microsoft/sp-core-library'; import type IWebPartData from '../IWebPartData'; import type { ISupportedIdleLoadDisplayMode } from './types'; /** * @internal * A function that returns the dependencies to be preloaded for a web part. */ export type IIdleLoadExecutableOrVoid = void | ((webPartData: IWebPartData | undefined) => void); /** * The instance ID of the web part to remove * @internal */ export type InstanceId = string; /** * @internal * Manages the loading idle load components for web parts. * @privateRemarks * Idle load components can be loaded during idle to improve render performance of web parts - or in parallel of loading a web part. */ export declare class WebPartIdleLoad { private _prefetchWebParts; /** * Removes the web part from the specified displayMode prefetching queue. * @param instanceId - the instance ID of the web part to remove */ cancelPrefetching(instanceId: InstanceId): void; cancelAllPrefetching(): void; /** * Enables prefetching idle load components for the specified web parts. * @param controls - the web parts to prefetch */ enablePrefetching(controls: IWebPartData[]): void; /** * Prefetches the specified web part's idle load components for the specified display mode. * @param control - the specified web part * @param displayMode - the display mode of the web part to prefetch * @param manifest - the manifest of the web part, if not provided SPComponentLoader.tryGetManifestById will be called * @returns A function that can be called to cancel the prefetching of the web parts. */ prefetchWebPart(control: IWebPartData, displayMode: DisplayMode, manifest?: IClientSideWebPartManifest<unknown> | undefined): () => void; /** * Prefetches the idle load components for web parts in the specified display mode. Note that enablePrefetching must be called first. * @param displayMode - the display mode of the web part to prefetch * @param limit - the maximum number of web parts to prefetch. * @defaultValue 3 * @returns A function that can be called to cancel the prefetching of the web parts. */ prefetchWebParts(displayMode: ISupportedIdleLoadDisplayMode, limit?: number): () => void; } //# sourceMappingURL=WebPartIdleLoad.d.ts.map