/** * Page Registry — POM classes stored by name. `register-pages.ts` calls * `registerPage`, `BasePageObject.create` calls `createPage`, and * `EntryPointPageObject.installPageHooks` calls * `getRegisteredPopupHandlers` / `getRegisteredRouteInterceptors`. * * Constructing by name is one of two options — a page object can equally * import a sibling and call `createFromPage` on it. Hook installation has no * such alternative: it walks the registry, so a POM that declares * `popupHandlers()` or `routeInterceptors()` needs an entry here however its * instances get built. * * Registration is eager (`registerPage("LoginPage", LoginPage)`) or lazy * (`registerPage("LoginPage", () => import("../pages/login-page.ts"))`). A * lazy module loads on first use and must export the class under the * registered name. Lazy registration keeps the barrel free of value imports. */ import type { Page } from "playwright"; import type { RegisteredPages } from "./index.js"; import type { PopupHandlerDef, RouteInterceptorDef } from "./pageHooks.js"; type RegistrablePage = { popupHandlers(): PopupHandlerDef[]; routeInterceptors(): RouteInterceptorDef[]; }; export type PomClass = { createFromPage(page: Page): RegistrablePage; prototype: RegistrablePage; }; /** * Loads the module that exports the registered class, e.g. * `() => import("../pages/login-page.ts")`. The module must export the class * under the registered `name`; `PomModuleLoader` ties the two together * so a mismatched import — `registerPage("LoginPage", () => import("./other.js"))` * — is a compile error. */ export type PomModuleLoader = () => Promise>; export type RegisterPageOptions = { /** * Pass `false` when the POM declares no `popupHandlers()` / * `routeInterceptors()` overrides, so page-hook installation can skip * loading its module. Omit when unsure — unflagged lazy entries are * loaded and inspected at hook-install time, which is always correct. */ providesPageHooks: boolean; }; export type RegistryEntry = { cls: PomClass; kind: "eager"; } | { kind: "lazy"; loader: PomModuleLoader; loading: Promise | undefined; providesPageHooks: boolean | undefined; }; export declare const entries: Record; export declare function registerPage(name: TName, classOrLoader: PomClass | PomModuleLoader, options?: RegisterPageOptions): void; export declare function classDeclaresPageHooks(cls: PomClass): boolean; export declare function loadPageClass(name: string, entry: Extract): Promise; /** * Shared by `createPage` and `BasePageObject.create`, which each capture their * own caller: an unregistered name is resolved against the imports of the file * that named it, not against this package's. */ export declare function createPageForCaller(name: string, page: Page, callerUrl: string | undefined): Promise; export declare function createPage(name: TName, page: Page): Promise; export declare function createPage(name: string, page: Page): Promise; export {}; //# sourceMappingURL=pageRegistry.d.ts.map