/** * Studio Manager Base * * Shared page-lifecycle plumbing for the NotebookLM "Studio" managers * (audio, video, data table). These managers all open a notebook page, * validate authentication, drive a Studio-panel artifact flow, then close * the page. The navigation and teardown logic is identical across them and * lives here; the artifact-specific flows stay in each subclass. * * Behavior is preserved exactly: * - navigateToNotebook: getOrCreateContext → validateWithRetry (throws * "Not authenticated. Run setup_auth first." when false) → newPage → * goto(domcontentloaded) → waitForLoadState("networkidle") (errors * swallowed) → per-subclass randomDelay → return page. * - closePage: close the page, swallowing errors, then null the handle. * * Per-subclass differences are expressed as protected properties so that no * call site needs to thread arguments: * - navigateDelay: video & data table use 2000–3000ms, audio uses 1500–2500ms. * - logName: the log-prefix used in the swallowed close-error debug line. */ import type { Page } from "patchright"; import { AuthManager } from "../auth/auth-manager.js"; import { SharedContextManager } from "../session/shared-context-manager.js"; /** Opaque DOM element handle used only in `as`-casts inside page.evaluate bodies. */ export type BrowserDomElement = unknown; /** Minimal `document` shape used inside page.evaluate bodies. Common to all managers. */ export interface BrowserDocumentContext { document: { querySelector(selector: string): BrowserDomElement | null; querySelectorAll(selector: string): Iterable; }; } export declare abstract class StudioManagerBase { protected authManager: AuthManager; protected contextManager: SharedContextManager; protected page: Page | null; /** * Trailing delay applied after navigation settles. Video & data table use the * default (2000–3000ms); audio overrides to 1500–2500ms. */ protected readonly navigateDelay: { min: number; max: number; }; /** Log prefix used in the swallowed close-error debug line (kept per-manager). */ protected abstract readonly logName: string; constructor(authManager: AuthManager, contextManager: SharedContextManager); /** * Navigate to a notebook and ensure we're on the right page */ protected navigateToNotebook(notebookUrl: string): Promise; /** * Close the page if open */ protected closePage(): Promise; }