@detiq/crawler 1.1.8 → 1.1.9

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.
Files changed (82) hide show
  1. package/dist/accessibility-auditor.js +74 -54
  2. package/dist/ai-login.js +249 -227
  3. package/dist/auth-token-rotator.js +67 -57
  4. package/dist/auth.js +336 -299
  5. package/dist/browser-extension.js +142 -104
  6. package/dist/captcha-solver.js +125 -98
  7. package/dist/color-contrast.js +89 -77
  8. package/dist/content-chunker.js +126 -126
  9. package/dist/content-dedup.js +71 -54
  10. package/dist/cookie-consent.js +83 -68
  11. package/dist/cookie-jar.js +60 -53
  12. package/dist/crawler.js +5345 -4486
  13. package/dist/custom-js-injector.js +61 -45
  14. package/dist/dark-mode-capture.js +81 -67
  15. package/dist/dead-link-detector.js +55 -47
  16. package/dist/element-hash.js +12 -8
  17. package/dist/email-otp.js +195 -154
  18. package/dist/engine-router.js +98 -87
  19. package/dist/export/bulk-export.js +55 -70
  20. package/dist/export/vector-export.js +105 -77
  21. package/dist/extractors/advanced.js +266 -249
  22. package/dist/extractors/artifact-envelope.js +58 -59
  23. package/dist/failure-analysis-agent.js +33 -37
  24. package/dist/feature-flag-detector.js +66 -51
  25. package/dist/form-detector.js +75 -55
  26. package/dist/frontier.js +101 -76
  27. package/dist/gap-pass.js +89 -68
  28. package/dist/graphql-detector.js +72 -62
  29. package/dist/http-engine.js +330 -282
  30. package/dist/incremental-diff.js +87 -54
  31. package/dist/index.js +28 -67
  32. package/dist/input-fuzzer.js +97 -93
  33. package/dist/interactive-probe.js +827 -715
  34. package/dist/job-queue.js +2169 -2151
  35. package/dist/js-coverage.js +56 -52
  36. package/dist/js-router-detector.js +117 -86
  37. package/dist/language-detector.js +63 -51
  38. package/dist/link-classifier.js +50 -32
  39. package/dist/live-view.js +108 -91
  40. package/dist/locator-extractor.js +187 -151
  41. package/dist/logger.js +7 -9
  42. package/dist/markdown-extract.js +61 -48
  43. package/dist/native-crawler.js +946 -780
  44. package/dist/network-observer.js +156 -135
  45. package/dist/network-throttle.js +40 -29
  46. package/dist/openapi-generator.js +92 -77
  47. package/dist/pdf-extractor.js +90 -72
  48. package/dist/performance-metrics.js +102 -80
  49. package/dist/phash.js +144 -125
  50. package/dist/pii-scrubber.js +68 -65
  51. package/dist/playwright-recorder.js +58 -70
  52. package/dist/policies/crawl-safety.js +34 -31
  53. package/dist/profiles/domain-profile.js +125 -130
  54. package/dist/proxy.js +172 -146
  55. package/dist/rate-limiter.js +65 -58
  56. package/dist/redirect-tracker.js +64 -60
  57. package/dist/redis-frontier.js +136 -116
  58. package/dist/redis-queue.js +144 -157
  59. package/dist/response-cache.js +140 -127
  60. package/dist/responsive-detector.js +46 -42
  61. package/dist/retry-policy.js +50 -46
  62. package/dist/robots-txt.js +83 -69
  63. package/dist/screen-reader.js +70 -45
  64. package/dist/screenshot-masker.js +77 -59
  65. package/dist/seo-checker.js +107 -88
  66. package/dist/session-capture.js +212 -192
  67. package/dist/session-export.js +133 -107
  68. package/dist/sitemap-writer.js +41 -38
  69. package/dist/sitemap.js +202 -141
  70. package/dist/skyvern.js +148 -123
  71. package/dist/sqs-queue.js +42 -42
  72. package/dist/sso-token.js +90 -74
  73. package/dist/stealth/human-behavior.js +173 -156
  74. package/dist/telemetry.js +82 -68
  75. package/dist/test-executor.js +335 -309
  76. package/dist/tls-fingerprint.js +88 -77
  77. package/dist/url-pattern-completer.js +90 -71
  78. package/dist/visual-diff-verdict.js +38 -23
  79. package/dist/webhook-notifier.js +69 -71
  80. package/dist/websocket-detector.js +68 -56
  81. package/dist/worker.js +38 -29
  82. package/package.json +1 -1
@@ -1,54 +1,67 @@
1
- import { parseHTML } from "linkedom";
2
- import { Readability } from "@mozilla/readability";
3
- import TurndownService from "turndown";
4
- const turndown = new TurndownService({ headingStyle: "atx", codeBlockStyle: "fenced" });
5
- turndown.remove(["script", "style", "noscript", "svg", "iframe"]);
1
+ /**
2
+ * HTML → Markdown extraction for crawled pages — matches crawl4AI's markdown
3
+ * output capability. Two-tier, mirroring crawl4AI's "markdown" vs "fit markdown":
4
+ *
5
+ * - "fit" markdown: Readability's best guess at the primary content (title +
6
+ * article body), stripped of nav/ads/chrome. Ideal for content/marketing
7
+ * pages and RAG chunking. null when Readability finds no article (most
8
+ * app UI screens — dashboards, forms — legitimately have none).
9
+ * - "full" markdown: the whole visible page converted straight to Markdown,
10
+ * always present. The fallback for app screens where there's no "article".
11
+ *
12
+ * Runs entirely on an already-captured `page.content()` string — no extra
13
+ * network fetch, no extra page navigation.
14
+ */
15
+ import { parseHTML } from 'linkedom';
16
+ import { Readability } from '@mozilla/readability';
17
+ import TurndownService from 'turndown';
18
+ const turndown = new TurndownService({ headingStyle: 'atx', codeBlockStyle: 'fenced' });
19
+ turndown.remove(['script', 'style', 'noscript', 'svg', 'iframe']);
6
20
  function stripNoiseElements(document) {
7
- const noisy = document.querySelectorAll('script, style, noscript, svg, iframe, [aria-hidden="true"]');
8
- noisy.forEach((el) => el.remove());
21
+ const noisy = document.querySelectorAll('script, style, noscript, svg, iframe, [aria-hidden="true"]');
22
+ noisy.forEach((el) => el.remove());
9
23
  }
10
- function extractMarkdown(html, url) {
11
- try {
12
- const { document } = parseHTML(html);
13
- stripNoiseElements(document);
14
- let readabilityResult = null;
24
+ /** Best-effort HTML→Markdown for one crawled page. Never throws. */
25
+ export function extractMarkdown(html, url) {
15
26
  try {
16
- const { document: readerDoc } = parseHTML(html);
17
- stripNoiseElements(readerDoc);
18
- readabilityResult = new Readability(readerDoc, { charThreshold: 50 }).parse();
19
- } catch {
20
- readabilityResult = null;
27
+ const { document } = parseHTML(html);
28
+ stripNoiseElements(document);
29
+ let readabilityResult = null;
30
+ try {
31
+ // Readability mutates the DOM it's given — clone via re-parsing so the
32
+ // full-page fallback below still has an intact document.
33
+ const { document: readerDoc } = parseHTML(html);
34
+ stripNoiseElements(readerDoc);
35
+ readabilityResult = new Readability(readerDoc, { charThreshold: 50 }).parse();
36
+ }
37
+ catch {
38
+ readabilityResult = null;
39
+ }
40
+ if (readabilityResult?.content && readabilityResult.textContent.trim().length >= 50) {
41
+ const markdown = turndown.turndown(readabilityResult.content);
42
+ return {
43
+ markdown: `# ${readabilityResult.title || document.title || url}\n\n${markdown}`,
44
+ method: 'readability',
45
+ title: readabilityResult.title || document.title || null,
46
+ wordCount: readabilityResult.textContent.trim().split(/\s+/).length,
47
+ };
48
+ }
49
+ const body = document.body;
50
+ if (!body)
51
+ return null;
52
+ const markdown = turndown.turndown(body.innerHTML || '');
53
+ const text = markdown.trim();
54
+ if (!text)
55
+ return null;
56
+ const title = document.title || null;
57
+ return {
58
+ markdown: title ? `# ${title}\n\n${markdown}` : markdown,
59
+ method: 'full-page',
60
+ title,
61
+ wordCount: text.split(/\s+/).length,
62
+ };
21
63
  }
22
- if (readabilityResult?.content && readabilityResult.textContent.trim().length >= 50) {
23
- const markdown2 = turndown.turndown(readabilityResult.content);
24
- return {
25
- markdown: `# ${readabilityResult.title || document.title || url}
26
-
27
- ${markdown2}`,
28
- method: "readability",
29
- title: readabilityResult.title || document.title || null,
30
- wordCount: readabilityResult.textContent.trim().split(/\s+/).length
31
- };
64
+ catch {
65
+ return null;
32
66
  }
33
- const body = document.body;
34
- if (!body) return null;
35
- const markdown = turndown.turndown(body.innerHTML || "");
36
- const text = markdown.trim();
37
- if (!text) return null;
38
- const title = document.title || null;
39
- return {
40
- markdown: title ? `# ${title}
41
-
42
- ${markdown}` : markdown,
43
- method: "full-page",
44
- title,
45
- wordCount: text.split(/\s+/).length
46
- };
47
- } catch {
48
- return null;
49
- }
50
67
  }
51
- export {
52
- extractMarkdown
53
- };
54
- //# sourceMappingURL=markdown-extract.js.map