import { bindReporter } from './lib/bindReporter.js'; import { getActivationStart } from './lib/getActivationStart.js'; import { getVisibilityWatcher } from './lib/getVisibilityWatcher.js'; import { initMetric } from './lib/initMetric.js'; import { observe } from './lib/observe.js'; import { whenActivated } from './lib/whenActivated.js'; const FCPThresholds = [1800, 3e3]; const onFCP = (onReport, opts = {}) => { whenActivated(() => { const visibilityWatcher = getVisibilityWatcher(); const metric = initMetric("FCP"); let report; const handleEntries = (entries) => { for (const entry of entries) { if (entry.name === "first-contentful-paint") { po.disconnect(); if (entry.startTime < visibilityWatcher.firstHiddenTime) { metric.value = Math.max(entry.startTime - getActivationStart(), 0); metric.entries.push(entry); report(true); } } } }; const po = observe("paint", handleEntries); if (po) { report = bindReporter(onReport, metric, FCPThresholds, opts.reportAllChanges); } }); }; export { FCPThresholds, onFCP }; //# sourceMappingURL=onFCP.js.map