UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

30 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerOriginalGoto = registerOriginalGoto; exports.hasOriginalGoto = hasOriginalGoto; exports.getOriginalGoto = getOriginalGoto; /** * Playwright creates a unique `goto` implementation for every page instance. * Once Donobu decorates a page we override that method, so the original * reference has to be stored somewhere page-specific. We can no longer stash * it on `_dnb` because all decorated pages share the same `_dnb` object. * * This registry keeps the native implementation in a WeakMap keyed by page. * Using a WeakMap ensures entries vanish automatically when a page is closed, * preventing leaks while still letting us delegate back to the correct tab. */ const originalGotoRegistry = new WeakMap(); function registerOriginalGoto(page, originalGoto) { originalGotoRegistry.set(page, originalGoto); } function hasOriginalGoto(page) { return originalGotoRegistry.has(page); } function getOriginalGoto(page) { const originalGoto = originalGotoRegistry.get(page); if (!originalGoto) { throw new Error('Original goto not registered for the provided page.'); } return originalGoto; } //# sourceMappingURL=originalGotoRegistry.js.map