Adapter layer for turning saved HTML now, and rendered URLs later, into @a1local/adpages-audit-core snapshots.
This package is intentionally small:
- no runtime dependencies
- no Playwright import yet
- no remote crawling in the package itself
- no storage, analytics, or licensing logic
Use captureStaticHtmlSnapshot when a CLI, GitHub Action, local script, or Docker job already has HTML available from disk or stdin.
import { auditLandingPageSnapshot } from "@a1local/adpages-audit-core";
import { captureStaticHtmlSnapshot } from "@a1local/adpages-browser-capture";
const snapshot = captureStaticHtmlSnapshot(html, {
url: "https://example.com/landing?utm_source=google&utm_medium=cpc&utm_campaign=brand",
sourceLabel: "saved preview HTML"
});
const audit = auditLandingPageSnapshot(snapshot);The helper returns the PageAuditSnapshot shape used by audit core. It does not depend on document, window, JSDOM, or browser APIs, so it is safe for Node-only workflows.
Static capture is best for pre-rendered HTML, build artifacts, and existing saved-page audits. It will not see client-rendered content, redirects, cookies, layout, computed accessibility state, network requests, or browser console errors.
The first CLI integration should keep fetching and file I/O outside this package:
- Read HTML from
--html-file, stdin, or a wrapper-owned URL fetch. - Call
captureStaticHtmlSnapshot(html, { url, sourceLabel }). - Pass the snapshot to
auditLandingPageSnapshot. - Render text, Markdown, JSON, or CI-friendly output in the CLI wrapper.
When URL capture is added, the CLI can accept a rendered-browser adapter that implements BrowserCaptureAdapter without making this package depend on Playwright.
For the existing saved-HTML Action, this package can replace duplicated extraction logic:
- Checkout the site or receive a preview artifact.
- Read the saved HTML file.
- Build a snapshot with
captureStaticHtmlSnapshot. - Run audit core and publish the report.
For future preview URL audits, the Action should own browser installation, cache settings, secrets, timeouts, and failure policy. The rendered capture implementation can live beside the Action and satisfy the adapter type exported here.
A Docker image can provide the heavier runtime without pushing those dependencies into this package:
- Install the browser runtime in the image.
- Run the adapter against one or more URLs.
- Emit audit-core-compatible snapshots.
- Run audit core and write reports to mounted output paths.
This keeps local package installs fast while still allowing reproducible URL audits in CI.
Remote capture should be explicit, user-initiated, and monetisation-safe:
- require a supplied URL or preview URL; do not crawl arbitrary sites by default
- keep request timeouts, max pages, and concurrency bounded
- avoid collecting form inputs, cookies, local storage, or authenticated data unless a wrapper explicitly owns that flow
- keep paid-gating, account state, and license checks outside this package
- return deterministic snapshot data that audit core can evaluate locally
The intended future shape is:
import type { BrowserCaptureAdapter } from "@a1local/adpages-browser-capture";
export const captureWithPlaywright: BrowserCaptureAdapter = async (request) => {
// Wrapper-owned Playwright code goes here later.
// Return a PageAuditSnapshot compatible with @a1local/adpages-audit-core.
};