@detiq/crawler 1.1.11 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crawler.js +52 -6
- package/dist/crawler.js.map +2 -2
- package/dist/job-queue.js +499 -10
- package/dist/job-queue.js.map +2 -2
- package/dist/locator-extractor.js +35 -1
- package/dist/locator-extractor.js.map +2 -2
- package/dist/test-executor.js +102 -0
- package/dist/test-executor.js.map +2 -2
- package/package.json +1 -1
- package/src/crawler.ts +59 -7
- package/src/job-queue.ts +339 -13
- package/src/locator-extractor.ts +41 -3
- package/src/test-executor.ts +122 -0
- package/types/crawler.d.ts +9 -0
- package/types/locator-extractor.d.ts +2 -0
- package/types/test-executor.d.ts +7 -0
package/dist/crawler.js
CHANGED
|
@@ -1994,15 +1994,55 @@ async function crawlProject(opts, onProgress) {
|
|
|
1994
1994
|
}
|
|
1995
1995
|
})()}`);
|
|
1996
1996
|
const pageDpr = await page.evaluate(() => window.devicePixelRatio ?? 1).catch(() => 1);
|
|
1997
|
-
const
|
|
1997
|
+
const elements = await extractElements(stagehand, page, elementLLM ?? void 0).catch((err) => {
|
|
1998
|
+
console.error("[crawler] extractElements failed:", err);
|
|
1999
|
+
return [];
|
|
2000
|
+
});
|
|
2001
|
+
await page.evaluate((elems) => {
|
|
2002
|
+
const container = document.createElement("div");
|
|
2003
|
+
container.id = "__zeta_element_highlights";
|
|
2004
|
+
container.style.position = "absolute";
|
|
2005
|
+
container.style.top = "0";
|
|
2006
|
+
container.style.left = "0";
|
|
2007
|
+
container.style.width = "100%";
|
|
2008
|
+
container.style.height = "100%";
|
|
2009
|
+
container.style.pointerEvents = "none";
|
|
2010
|
+
container.style.zIndex = "2147483647";
|
|
2011
|
+
elems.forEach((el, index) => {
|
|
2012
|
+
if (!el.boundingRect) return;
|
|
2013
|
+
const rect = el.boundingRect;
|
|
2014
|
+
const box = document.createElement("div");
|
|
2015
|
+
box.style.position = "absolute";
|
|
2016
|
+
box.style.left = rect.x + window.scrollX + "px";
|
|
2017
|
+
box.style.top = rect.y + window.scrollY + "px";
|
|
2018
|
+
box.style.width = rect.width + "px";
|
|
2019
|
+
box.style.height = rect.height + "px";
|
|
2020
|
+
box.style.border = "2px solid rgba(255, 0, 0, 0.8)";
|
|
2021
|
+
box.style.backgroundColor = "rgba(255, 0, 0, 0.1)";
|
|
2022
|
+
box.style.boxSizing = "border-box";
|
|
2023
|
+
const label = document.createElement("div");
|
|
2024
|
+
label.textContent = el.role || "element";
|
|
2025
|
+
label.style.position = "absolute";
|
|
2026
|
+
label.style.top = "-16px";
|
|
2027
|
+
label.style.left = "-2px";
|
|
2028
|
+
label.style.backgroundColor = "rgba(255, 0, 0, 0.9)";
|
|
2029
|
+
label.style.color = "#FFF";
|
|
2030
|
+
label.style.fontSize = "10px";
|
|
2031
|
+
label.style.padding = "2px 4px";
|
|
2032
|
+
label.style.borderRadius = "2px";
|
|
2033
|
+
label.style.whiteSpace = "nowrap";
|
|
2034
|
+
label.style.fontFamily = "monospace";
|
|
2035
|
+
box.appendChild(label);
|
|
2036
|
+
container.appendChild(box);
|
|
2037
|
+
});
|
|
2038
|
+
document.body.appendChild(container);
|
|
2039
|
+
}, elements).catch(() => {
|
|
2040
|
+
});
|
|
2041
|
+
const [, nextLinks, atElements] = await Promise.all([
|
|
1998
2042
|
page.screenshot({ path: shotPath, fullPage: true }).then(async () => {
|
|
1999
2043
|
const cloudUrl = await uploadToCloud(shotPath, `${opts.tenantId}/${opts.projectId}/screenshots/${path.basename(shotPath)}`);
|
|
2000
2044
|
return AppBrain.saveScreenshot(opts.tenantId, opts.projectId, screen.id, shotPath, screen.version, "DESKTOP", cloudUrl, pageDpr);
|
|
2001
2045
|
}).catch((err) => console.error("[crawler] page.screenshot failed:", err)),
|
|
2002
|
-
extractElements(stagehand, page, elementLLM ?? void 0).catch((err) => {
|
|
2003
|
-
console.error("[crawler] extractElements failed:", err);
|
|
2004
|
-
return [];
|
|
2005
|
-
}),
|
|
2006
2046
|
// Always run AI link discovery (even when cache exists) — cache is merged in, not used as a replacement.
|
|
2007
2047
|
// Skipping AI when cache exists was a bug: stale cache from broken crawls permanently blocked discovery.
|
|
2008
2048
|
// Skip AI on simple pages (< 5 interactive elements) — DOM-only is sufficient and saves ~12s per page.
|
|
@@ -2041,6 +2081,11 @@ async function crawlProject(opts, onProgress) {
|
|
|
2041
2081
|
}),
|
|
2042
2082
|
readScreen(page).catch(() => [])
|
|
2043
2083
|
]);
|
|
2084
|
+
await page.evaluate(() => {
|
|
2085
|
+
const container = document.getElementById("__zeta_element_highlights");
|
|
2086
|
+
if (container) container.remove();
|
|
2087
|
+
}).catch(() => {
|
|
2088
|
+
});
|
|
2044
2089
|
logger.info({ url, screenId: screen.id, version: screen.version, elements: elements.length, links: nextLinks.length, atSample: atElements.slice(0, 3).map((a) => a.label) }, "[crawler] screen captured");
|
|
2045
2090
|
console.log("[crawler] AT:", JSON.stringify(atElements.slice(0, 5)));
|
|
2046
2091
|
probeKeyboardNav(page).then((kbResult) => {
|
|
@@ -4712,6 +4757,7 @@ async function runAuthDiscoveryPhase(page, opts, origin, onProgress) {
|
|
|
4712
4757
|
}
|
|
4713
4758
|
export {
|
|
4714
4759
|
crawlProject,
|
|
4715
|
-
discoverLinksViaBrowser
|
|
4760
|
+
discoverLinksViaBrowser,
|
|
4761
|
+
domFallbackElements
|
|
4716
4762
|
};
|
|
4717
4763
|
//# sourceMappingURL=crawler.js.map
|