UNPKG

@auto-browse/auto-browse

Version:
35 lines (34 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sessionManager = void 0; class SessionManager { constructor() { this.currentPage = null; this.currentContext = null; } static getInstance() { if (!SessionManager.instance) { SessionManager.instance = new SessionManager(); } return SessionManager.instance; } setPage(page) { this.currentPage = page; } setContext(context) { this.currentContext = context; } getPage() { if (!this.currentPage) { throw new Error("No active page found. Make sure you are running within a Playwright test."); } return this.currentPage; } getContext() { if (!this.currentContext) { throw new Error("No active browser context found. Make sure you are running within a Playwright test."); } return this.currentContext; } } exports.sessionManager = SessionManager.getInstance();