@taodigital/crawler 0.0.0-stage → 1.2.0
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/Dockerfile +82 -0
- package/README.md +10 -2
- package/dist/accessibility-auditor.d.ts +29 -0
- package/dist/accessibility-auditor.js +57 -0
- package/dist/accessibility-auditor.js.map +7 -0
- package/dist/accessibility-tree-crawler.d.ts +44 -0
- package/dist/accessibility-tree-crawler.js +156 -0
- package/dist/accessibility-tree-crawler.js.map +7 -0
- package/dist/advanced-ui-probes.d.ts +47 -0
- package/dist/advanced-ui-probes.js +310 -0
- package/dist/advanced-ui-probes.js.map +7 -0
- package/dist/ai-login.d.ts +32 -0
- package/dist/ai-login.js +250 -0
- package/dist/ai-login.js.map +7 -0
- package/dist/auth-token-rotator.d.ts +47 -0
- package/dist/auth-token-rotator.js +58 -0
- package/dist/auth-token-rotator.js.map +7 -0
- package/dist/auth.d.ts +20 -0
- package/dist/auth.js +348 -0
- package/dist/auth.js.map +7 -0
- package/dist/browser-extension.d.ts +37 -0
- package/dist/browser-extension.js +113 -0
- package/dist/browser-extension.js.map +7 -0
- package/dist/captcha-solver.d.ts +16 -0
- package/dist/captcha-solver.js +105 -0
- package/dist/captcha-solver.js.map +7 -0
- package/dist/color-contrast.d.ts +30 -0
- package/dist/color-contrast.js +78 -0
- package/dist/color-contrast.js.map +7 -0
- package/dist/content-chunker.d.ts +18 -0
- package/dist/content-chunker.js +152 -0
- package/dist/content-chunker.js.map +7 -0
- package/dist/content-dedup.d.ts +23 -0
- package/dist/content-dedup.js +60 -0
- package/dist/content-dedup.js.map +7 -0
- package/dist/cookie-consent.d.ts +25 -0
- package/dist/cookie-consent.js +78 -0
- package/dist/cookie-consent.js.map +7 -0
- package/dist/cookie-jar.d.ts +20 -0
- package/dist/cookie-jar.js +61 -0
- package/dist/cookie-jar.js.map +7 -0
- package/dist/crawl-session-manager.d.ts +44 -0
- package/dist/crawl-session-manager.js +145 -0
- package/dist/crawl-session-manager.js.map +7 -0
- package/dist/crawler.d.ts +233 -0
- package/dist/crawler.js +6239 -0
- package/dist/crawler.js.map +7 -0
- package/dist/crud-interaction.d.ts +31 -0
- package/dist/crud-interaction.js +264 -0
- package/dist/crud-interaction.js.map +7 -0
- package/dist/custom-js-injector.d.ts +42 -0
- package/dist/custom-js-injector.js +50 -0
- package/dist/custom-js-injector.js.map +7 -0
- package/dist/dark-mode-capture.d.ts +23 -0
- package/dist/dark-mode-capture.js +75 -0
- package/dist/dark-mode-capture.js.map +7 -0
- package/dist/dead-link-detector.d.ts +37 -0
- package/dist/dead-link-detector.js +50 -0
- package/dist/dead-link-detector.js.map +7 -0
- package/dist/dropdown-enumerator.d.ts +20 -0
- package/dist/dropdown-enumerator.js +230 -0
- package/dist/dropdown-enumerator.js.map +7 -0
- package/dist/element-hash.d.ts +9 -0
- package/dist/element-hash.js +9 -0
- package/dist/element-hash.js.map +7 -0
- package/dist/email-otp.d.ts +42 -0
- package/dist/email-otp.js +177 -0
- package/dist/email-otp.js.map +7 -0
- package/dist/engine-router.d.ts +47 -0
- package/dist/engine-router.js +94 -0
- package/dist/engine-router.js.map +7 -0
- package/dist/export/bulk-export.d.ts +26 -0
- package/dist/export/bulk-export.js +76 -0
- package/dist/export/bulk-export.js.map +7 -0
- package/dist/export/vector-export.d.ts +76 -0
- package/dist/export/vector-export.js +85 -0
- package/dist/export/vector-export.js.map +7 -0
- package/dist/extractors/advanced.d.ts +64 -0
- package/dist/extractors/advanced.js +265 -0
- package/dist/extractors/advanced.js.map +7 -0
- package/dist/extractors/artifact-envelope.d.ts +63 -0
- package/dist/extractors/artifact-envelope.js +63 -0
- package/dist/extractors/artifact-envelope.js.map +7 -0
- package/dist/extractors/branding-extractor.d.ts +46 -0
- package/dist/extractors/branding-extractor.js +104 -0
- package/dist/extractors/branding-extractor.js.map +7 -0
- package/dist/extractors/summary-extractor.d.ts +10 -0
- package/dist/extractors/summary-extractor.js +36 -0
- package/dist/extractors/summary-extractor.js.map +7 -0
- package/dist/failure-analysis-agent.d.ts +16 -0
- package/dist/failure-analysis-agent.js +42 -0
- package/dist/failure-analysis-agent.js.map +7 -0
- package/dist/feature-flag-detector.d.ts +30 -0
- package/dist/feature-flag-detector.js +55 -0
- package/dist/feature-flag-detector.js.map +7 -0
- package/dist/filter-pagination-crawler.d.ts +52 -0
- package/dist/filter-pagination-crawler.js +299 -0
- package/dist/filter-pagination-crawler.js.map +7 -0
- package/dist/form-detector.d.ts +34 -0
- package/dist/form-detector.js +58 -0
- package/dist/form-detector.js.map +7 -0
- package/dist/frontier.d.ts +40 -0
- package/dist/frontier.js +103 -0
- package/dist/frontier.js.map +7 -0
- package/dist/gap-pass.d.ts +36 -0
- package/dist/gap-pass.js +115 -0
- package/dist/gap-pass.js.map +7 -0
- package/dist/graphql-detector.d.ts +39 -0
- package/dist/graphql-detector.js +86 -0
- package/dist/graphql-detector.js.map +7 -0
- package/dist/http-engine.d.ts +80 -0
- package/dist/http-engine.js +318 -0
- package/dist/http-engine.js.map +7 -0
- package/dist/incremental-diff.d.ts +116 -0
- package/dist/incremental-diff.js +137 -0
- package/dist/incremental-diff.js.map +7 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +7 -0
- package/dist/input-fuzzer.d.ts +30 -0
- package/dist/input-fuzzer.js +105 -0
- package/dist/input-fuzzer.js.map +7 -0
- package/dist/interactive-probe.d.ts +144 -0
- package/dist/interactive-probe.js +865 -0
- package/dist/interactive-probe.js.map +7 -0
- package/dist/job-queue.d.ts +297 -0
- package/dist/job-queue.js +3812 -0
- package/dist/job-queue.js.map +7 -0
- package/dist/js-coverage.d.ts +29 -0
- package/dist/js-coverage.js +56 -0
- package/dist/js-coverage.js.map +7 -0
- package/dist/js-router-detector.d.ts +17 -0
- package/dist/js-router-detector.js +90 -0
- package/dist/js-router-detector.js.map +7 -0
- package/dist/language-detector.d.ts +22 -0
- package/dist/language-detector.js +57 -0
- package/dist/language-detector.js.map +7 -0
- package/dist/link-classifier.d.ts +23 -0
- package/dist/link-classifier.js +40 -0
- package/dist/link-classifier.js.map +7 -0
- package/dist/live-view.d.ts +36 -0
- package/dist/live-view.js +105 -0
- package/dist/live-view.js.map +7 -0
- package/dist/locator-extractor.d.ts +46 -0
- package/dist/locator-extractor.js +220 -0
- package/dist/locator-extractor.js.map +7 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +10 -0
- package/dist/logger.js.map +7 -0
- package/dist/markdown-extract.d.ts +8 -0
- package/dist/markdown-extract.js +54 -0
- package/dist/markdown-extract.js.map +7 -0
- package/dist/multi-context-handler.d.ts +55 -0
- package/dist/multi-context-handler.js +182 -0
- package/dist/multi-context-handler.js.map +7 -0
- package/dist/native-crawler.d.ts +69 -0
- package/dist/native-crawler.js +839 -0
- package/dist/native-crawler.js.map +7 -0
- package/dist/nested-window-crawler.d.ts +41 -0
- package/dist/nested-window-crawler.js +172 -0
- package/dist/nested-window-crawler.js.map +7 -0
- package/dist/network-action-correlator.d.ts +47 -0
- package/dist/network-action-correlator.js +209 -0
- package/dist/network-action-correlator.js.map +7 -0
- package/dist/network-observer.d.ts +49 -0
- package/dist/network-observer.js +149 -0
- package/dist/network-observer.js.map +7 -0
- package/dist/network-throttle.d.ts +25 -0
- package/dist/network-throttle.js +34 -0
- package/dist/network-throttle.js.map +7 -0
- package/dist/openapi-generator.d.ts +49 -0
- package/dist/openapi-generator.js +89 -0
- package/dist/openapi-generator.js.map +7 -0
- package/dist/pdf-extractor.d.ts +28 -0
- package/dist/pdf-extractor.js +81 -0
- package/dist/pdf-extractor.js.map +7 -0
- package/dist/performance-metrics-collector.d.ts +50 -0
- package/dist/performance-metrics-collector.js +155 -0
- package/dist/performance-metrics-collector.js.map +7 -0
- package/dist/performance-metrics.d.ts +52 -0
- package/dist/performance-metrics.js +83 -0
- package/dist/performance-metrics.js.map +7 -0
- package/dist/phash.d.ts +50 -0
- package/dist/phash.js +136 -0
- package/dist/phash.js.map +7 -0
- package/dist/pii-scrubber.d.ts +21 -0
- package/dist/pii-scrubber.js +75 -0
- package/dist/pii-scrubber.js.map +7 -0
- package/dist/playwright-recorder.d.ts +39 -0
- package/dist/playwright-recorder.js +123 -0
- package/dist/playwright-recorder.js.map +7 -0
- package/dist/policies/crawl-safety.d.ts +9 -0
- package/dist/policies/crawl-safety.js +41 -0
- package/dist/policies/crawl-safety.js.map +7 -0
- package/dist/profiles/domain-profile.d.ts +19 -0
- package/dist/profiles/domain-profile.js +160 -0
- package/dist/profiles/domain-profile.js.map +7 -0
- package/dist/proxy.d.ts +50 -0
- package/dist/proxy.js +165 -0
- package/dist/proxy.js.map +7 -0
- package/dist/rate-limiter.d.ts +31 -0
- package/dist/rate-limiter.js +64 -0
- package/dist/rate-limiter.js.map +7 -0
- package/dist/redirect-tracker.d.ts +37 -0
- package/dist/redirect-tracker.js +65 -0
- package/dist/redirect-tracker.js.map +7 -0
- package/dist/redis-frontier.d.ts +48 -0
- package/dist/redis-frontier.js +126 -0
- package/dist/redis-frontier.js.map +7 -0
- package/dist/redis-queue.d.ts +48 -0
- package/dist/redis-queue.js +165 -0
- package/dist/redis-queue.js.map +7 -0
- package/dist/response-cache.d.ts +38 -0
- package/dist/response-cache.js +140 -0
- package/dist/response-cache.js.map +7 -0
- package/dist/responsive-detector.d.ts +29 -0
- package/dist/responsive-detector.js +46 -0
- package/dist/responsive-detector.js.map +7 -0
- package/dist/retry-policy.d.ts +20 -0
- package/dist/retry-policy.js +54 -0
- package/dist/retry-policy.js.map +7 -0
- package/dist/robots-txt.d.ts +9 -0
- package/dist/robots-txt.js +77 -0
- package/dist/robots-txt.js.map +7 -0
- package/dist/screen-reader.d.ts +15 -0
- package/dist/screen-reader.js +48 -0
- package/dist/screen-reader.js.map +7 -0
- package/dist/screenshot-masker.d.ts +28 -0
- package/dist/screenshot-masker.js +62 -0
- package/dist/screenshot-masker.js.map +7 -0
- package/dist/seo-checker.d.ts +33 -0
- package/dist/seo-checker.js +91 -0
- package/dist/seo-checker.js.map +7 -0
- package/dist/service-worker-interceptor.d.ts +36 -0
- package/dist/service-worker-interceptor.js +136 -0
- package/dist/service-worker-interceptor.js.map +7 -0
- package/dist/session-capture.d.ts +39 -0
- package/dist/session-capture.js +274 -0
- package/dist/session-capture.js.map +7 -0
- package/dist/session-export.d.ts +49 -0
- package/dist/session-export.js +117 -0
- package/dist/session-export.js.map +7 -0
- package/dist/shadow-dom-crawler.d.ts +35 -0
- package/dist/shadow-dom-crawler.js +132 -0
- package/dist/shadow-dom-crawler.js.map +7 -0
- package/dist/sitemap-writer.d.ts +21 -0
- package/dist/sitemap-writer.js +47 -0
- package/dist/sitemap-writer.js.map +7 -0
- package/dist/sitemap.d.ts +51 -0
- package/dist/sitemap.js +160 -0
- package/dist/sitemap.js.map +7 -0
- package/dist/skyvern.d.ts +56 -0
- package/dist/skyvern.js +129 -0
- package/dist/skyvern.js.map +7 -0
- package/dist/sqs-queue.d.ts +13 -0
- package/dist/sqs-queue.js +115 -0
- package/dist/sqs-queue.js.map +7 -0
- package/dist/sso-token.d.ts +29 -0
- package/dist/sso-token.js +76 -0
- package/dist/sso-token.js.map +7 -0
- package/dist/state-graph.d.ts +59 -0
- package/dist/state-graph.js +193 -0
- package/dist/state-graph.js.map +7 -0
- package/dist/stealth/human-behavior.d.ts +20 -0
- package/dist/stealth/human-behavior.js +202 -0
- package/dist/stealth/human-behavior.js.map +7 -0
- package/dist/telemetry.d.ts +34 -0
- package/dist/telemetry.js +77 -0
- package/dist/telemetry.js.map +7 -0
- package/dist/test-executor.d.ts +81 -0
- package/dist/test-executor.js +443 -0
- package/dist/test-executor.js.map +7 -0
- package/dist/tls-fingerprint.d.ts +50 -0
- package/dist/tls-fingerprint.js +81 -0
- package/dist/tls-fingerprint.js.map +7 -0
- package/dist/url-pattern-completer.d.ts +28 -0
- package/dist/url-pattern-completer.js +122 -0
- package/dist/url-pattern-completer.js.map +7 -0
- package/dist/visual-diff-verdict.d.ts +40 -0
- package/dist/visual-diff-verdict.js +27 -0
- package/dist/visual-diff-verdict.js.map +7 -0
- package/dist/webhook-notifier.d.ts +30 -0
- package/dist/webhook-notifier.js +76 -0
- package/dist/webhook-notifier.js.map +7 -0
- package/dist/websocket-detector.d.ts +24 -0
- package/dist/websocket-detector.js +60 -0
- package/dist/websocket-detector.js.map +7 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +33 -0
- package/dist/worker.js.map +7 -0
- package/package.json +49 -4
- package/src/accessibility-auditor.ts +102 -0
- package/src/accessibility-tree-crawler.ts +246 -0
- package/src/advanced-ui-probes.ts +470 -0
- package/src/ai-login.ts +298 -0
- package/src/auth-token-rotator.ts +89 -0
- package/src/auth.ts +418 -0
- package/src/browser-extension.ts +186 -0
- package/src/captcha-solver.ts +143 -0
- package/src/color-contrast.ts +116 -0
- package/src/content-chunker.ts +170 -0
- package/src/content-dedup.ts +99 -0
- package/src/cookie-consent.ts +106 -0
- package/src/cookie-jar.ts +91 -0
- package/src/crawl-session-manager.ts +231 -0
- package/src/crawler.ts +7123 -0
- package/src/crawler.ts.rej +12 -0
- package/src/crud-interaction.ts +386 -0
- package/src/custom-js-injector.ts +93 -0
- package/src/dark-mode-capture.ts +110 -0
- package/src/dead-link-detector.ts +76 -0
- package/src/dropdown-enumerator.ts +312 -0
- package/src/element-hash.ts +16 -0
- package/src/email-otp.ts +252 -0
- package/src/engine-router.ts +141 -0
- package/src/export/bulk-export.ts +85 -0
- package/src/export/vector-export.ts +160 -0
- package/src/extractors/advanced.ts +309 -0
- package/src/extractors/artifact-envelope.ts +111 -0
- package/src/extractors/branding-extractor.ts +159 -0
- package/src/extractors/summary-extractor.ts +49 -0
- package/src/failure-analysis-agent.ts +51 -0
- package/src/feature-flag-detector.ts +97 -0
- package/src/filter-pagination-crawler.ts +500 -0
- package/src/form-detector.ts +103 -0
- package/src/frontier.test.ts +64 -0
- package/src/frontier.ts +144 -0
- package/src/gap-pass.ts +165 -0
- package/src/graphql-detector.ts +129 -0
- package/src/http-engine.ts +453 -0
- package/src/incremental-diff.ts +259 -0
- package/src/index.ts +52 -0
- package/src/input-fuzzer.ts +129 -0
- package/src/interactive-probe.ts +1136 -0
- package/src/job-queue.test.ts +187 -0
- package/src/job-queue.ts +4504 -0
- package/src/js-coverage.ts +87 -0
- package/src/js-router-detector.ts +112 -0
- package/src/language-detector.ts +82 -0
- package/src/link-classifier.ts +65 -0
- package/src/live-view.ts +146 -0
- package/src/locator-extractor.ts +309 -0
- package/src/logger.ts +9 -0
- package/src/markdown-extract.test.ts +73 -0
- package/src/markdown-extract.ts +76 -0
- package/src/multi-context-handler.ts +296 -0
- package/src/native-crawler.ts +1108 -0
- package/src/nested-window-crawler.ts +310 -0
- package/src/network-action-correlator.ts +320 -0
- package/src/network-observer.ts +204 -0
- package/src/network-throttle.ts +69 -0
- package/src/openapi-generator.ts +135 -0
- package/src/pdf-extractor.ts +123 -0
- package/src/performance-metrics-collector.ts +243 -0
- package/src/performance-metrics.ts +134 -0
- package/src/phash.ts +184 -0
- package/src/pii-scrubber.ts +99 -0
- package/src/playwright-recorder.ts +170 -0
- package/src/policies/crawl-safety.ts +52 -0
- package/src/profiles/domain-profile.ts +190 -0
- package/src/proxy.ts +238 -0
- package/src/rate-limiter.ts +87 -0
- package/src/redirect-tracker.ts +97 -0
- package/src/redis-frontier.ts +143 -0
- package/src/redis-queue.ts +208 -0
- package/src/response-cache.ts +150 -0
- package/src/responsive-detector.ts +92 -0
- package/src/retry-policy.ts +87 -0
- package/src/robots-txt.ts +96 -0
- package/src/screen-reader.ts +98 -0
- package/src/screenshot-masker.ts +98 -0
- package/src/seo-checker.ts +134 -0
- package/src/service-worker-interceptor.ts +185 -0
- package/src/session-capture.ts +335 -0
- package/src/session-export.test.ts +75 -0
- package/src/session-export.ts +172 -0
- package/src/shadow-dom-crawler.ts +198 -0
- package/src/sitemap-writer.ts +65 -0
- package/src/sitemap.test.ts +127 -0
- package/src/sitemap.ts +233 -0
- package/src/skyvern.ts +199 -0
- package/src/sqs-queue.ts +129 -0
- package/src/sso-token.ts +120 -0
- package/src/state-graph.ts +280 -0
- package/src/stealth/human-behavior.ts +227 -0
- package/src/telemetry.ts +122 -0
- package/src/test-executor.test.ts +72 -0
- package/src/test-executor.ts +578 -0
- package/src/tls-fingerprint.ts +111 -0
- package/src/url-pattern-completer.ts +161 -0
- package/src/vendor.d.ts +20 -0
- package/src/visual-diff-verdict.test.ts +80 -0
- package/src/visual-diff-verdict.ts +59 -0
- package/src/webhook-notifier.ts +109 -0
- package/src/websocket-detector.ts +83 -0
- package/src/worker.ts +50 -0
- package/tsconfig.json +13 -0
- package/types/accessibility-auditor.d.ts +29 -0
- package/types/accessibility-tree-crawler.d.ts +44 -0
- package/types/advanced-ui-probes.d.ts +47 -0
- package/types/ai-login.d.ts +32 -0
- package/types/auth-token-rotator.d.ts +47 -0
- package/types/auth.d.ts +20 -0
- package/types/browser-extension.d.ts +37 -0
- package/types/bull-worker.d.ts +6 -0
- package/types/captcha-solver.d.ts +16 -0
- package/types/color-contrast.d.ts +30 -0
- package/types/content-chunker.d.ts +18 -0
- package/types/content-dedup.d.ts +23 -0
- package/types/cookie-consent.d.ts +25 -0
- package/types/cookie-jar.d.ts +20 -0
- package/types/crawl-session-manager.d.ts +44 -0
- package/types/crawler.d.ts +233 -0
- package/types/crud-interaction.d.ts +31 -0
- package/types/custom-js-injector.d.ts +42 -0
- package/types/dark-mode-capture.d.ts +23 -0
- package/types/dead-link-detector.d.ts +37 -0
- package/types/dropdown-enumerator.d.ts +20 -0
- package/types/element-hash.d.ts +9 -0
- package/types/email-otp.d.ts +42 -0
- package/types/engine-router.d.ts +47 -0
- package/types/export/bulk-export.d.ts +26 -0
- package/types/export/vector-export.d.ts +76 -0
- package/types/extractors/advanced.d.ts +64 -0
- package/types/extractors/artifact-envelope.d.ts +63 -0
- package/types/extractors/branding-extractor.d.ts +46 -0
- package/types/extractors/summary-extractor.d.ts +10 -0
- package/types/failure-analysis-agent.d.ts +16 -0
- package/types/feature-flag-detector.d.ts +30 -0
- package/types/filter-pagination-crawler.d.ts +52 -0
- package/types/form-detector.d.ts +34 -0
- package/types/frontier.d.ts +40 -0
- package/types/gap-pass.d.ts +36 -0
- package/types/graphql-detector.d.ts +39 -0
- package/types/http-engine.d.ts +80 -0
- package/types/incremental-diff.d.ts +116 -0
- package/types/index.d.ts +52 -0
- package/types/input-fuzzer.d.ts +30 -0
- package/types/interactive-probe.d.ts +144 -0
- package/types/job-queue.d.ts +308 -0
- package/types/js-coverage.d.ts +29 -0
- package/types/js-router-detector.d.ts +17 -0
- package/types/language-detector.d.ts +22 -0
- package/types/link-classifier.d.ts +23 -0
- package/types/live-view.d.ts +36 -0
- package/types/locator-extractor.d.ts +46 -0
- package/types/logger.d.ts +2 -0
- package/types/markdown-extract.d.ts +8 -0
- package/types/multi-context-handler.d.ts +55 -0
- package/types/native-crawler.d.ts +69 -0
- package/types/nested-window-crawler.d.ts +41 -0
- package/types/network-action-correlator.d.ts +47 -0
- package/types/network-observer.d.ts +49 -0
- package/types/network-throttle.d.ts +25 -0
- package/types/openapi-generator.d.ts +49 -0
- package/types/pdf-extractor.d.ts +28 -0
- package/types/performance-metrics-collector.d.ts +50 -0
- package/types/performance-metrics.d.ts +52 -0
- package/types/phash.d.ts +50 -0
- package/types/pii-scrubber.d.ts +21 -0
- package/types/playwright-recorder.d.ts +39 -0
- package/types/policies/crawl-safety.d.ts +9 -0
- package/types/profiles/domain-profile.d.ts +19 -0
- package/types/proxy.d.ts +50 -0
- package/types/rate-limiter.d.ts +31 -0
- package/types/redirect-tracker.d.ts +37 -0
- package/types/redis-frontier.d.ts +48 -0
- package/types/redis-queue.d.ts +48 -0
- package/types/response-cache.d.ts +38 -0
- package/types/responsive-detector.d.ts +29 -0
- package/types/retry-policy.d.ts +20 -0
- package/types/robots-txt.d.ts +9 -0
- package/types/screen-reader.d.ts +15 -0
- package/types/screenshot-masker.d.ts +28 -0
- package/types/seo-checker.d.ts +33 -0
- package/types/service-worker-interceptor.d.ts +36 -0
- package/types/session-capture.d.ts +39 -0
- package/types/session-export.d.ts +49 -0
- package/types/shadow-dom-crawler.d.ts +35 -0
- package/types/sitemap-writer.d.ts +21 -0
- package/types/sitemap.d.ts +51 -0
- package/types/skyvern.d.ts +56 -0
- package/types/sqs-queue.d.ts +13 -0
- package/types/sso-token.d.ts +29 -0
- package/types/state-graph.d.ts +59 -0
- package/types/stealth/human-behavior.d.ts +20 -0
- package/types/telemetry.d.ts +34 -0
- package/types/test-executor.d.ts +84 -0
- package/types/tls-fingerprint.d.ts +50 -0
- package/types/url-pattern-completer.d.ts +28 -0
- package/types/visual-diff-verdict.d.ts +40 -0
- package/types/webhook-notifier.d.ts +30 -0
- package/types/websocket-detector.d.ts +24 -0
- package/types/worker.d.ts +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@@ -2160,8 +2160,9 @@
|
|
2
|
+
|
|
3
|
+
const [, elements, nextLinks, atElements] = await Promise.all([
|
|
4
|
+
page.screenshot({ path: shotPath, fullPage: true })
|
|
5
|
+
- .then(() => AppBrain.saveScreenshot(opts.tenantId, opts.projectId, screen.id, shotPath, screen.version, 'DESKTOP')),
|
|
6
|
+
- extractElements(stagehand, page, elementLLM ?? undefined).catch(() => [] as Awaited<ReturnType<typeof extractElements>>),
|
|
7
|
+
+ .then(() => AppBrain.saveScreenshot(opts.tenantId, opts.projectId, screen.id, shotPath, screen.version, 'DESKTOP'))
|
|
8
|
+
+ .catch((err) => console.error('[crawler] page.screenshot failed:', err)),
|
|
9
|
+
+ extractElements(stagehand, page, elementLLM ?? undefined).catch((err) => { console.error('[crawler] extractElements failed:', err); return [] as Awaited<ReturnType<typeof extractElements>> }),
|
|
10
|
+
extractNavigationLinks(page).catch(() => [] as string[]),
|
|
11
|
+
stagehand.page.extractElements({
|
|
12
|
+
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import type { Page, Locator } from 'playwright';
|
|
2
|
+
|
|
3
|
+
// ── Types ─────────────────────────────────────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
export type EditFlowType = 'inline' | 'modal' | 'navigation' | 'unknown';
|
|
6
|
+
|
|
7
|
+
export interface CrudFlowCapture {
|
|
8
|
+
entityName: string;
|
|
9
|
+
createTrigger?: string;
|
|
10
|
+
editFlowType: EditFlowType;
|
|
11
|
+
editFields: Array<{ name: string; type: string; prefilledValue?: string }>;
|
|
12
|
+
deleteConfirmation?: { message: string; confirmLabel: string; cancelLabel: string };
|
|
13
|
+
createSuccessToast?: string;
|
|
14
|
+
editSuccessToast?: string;
|
|
15
|
+
rowCount: number;
|
|
16
|
+
hasDeleteButton: boolean;
|
|
17
|
+
hasEditButton: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CrudProbeResult {
|
|
21
|
+
flows: CrudFlowCapture[];
|
|
22
|
+
toastsObserved: Array<{ action: string; text: string; role: string }>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ── Internal: Toast observer ──────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
function injectToastObserver(page: Page): void {
|
|
28
|
+
page.evaluate(() => {
|
|
29
|
+
if ((window as any).__toastObserver) return;
|
|
30
|
+
|
|
31
|
+
(window as any).__capturedToasts = [] as Array<{ text: string; role: string }>;
|
|
32
|
+
|
|
33
|
+
const TOAST_CLASSES = ['toast', 'snackbar', 'notification'];
|
|
34
|
+
|
|
35
|
+
function matchesToast(el: Element): boolean {
|
|
36
|
+
const role = el.getAttribute('role') ?? '';
|
|
37
|
+
if (role === 'alert' || role === 'status') return true;
|
|
38
|
+
const cls = (el.getAttribute('class') ?? '').toLowerCase();
|
|
39
|
+
return TOAST_CLASSES.some((t) => cls.includes(t));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function captureNode(node: Node): void {
|
|
43
|
+
if (!(node instanceof Element)) return;
|
|
44
|
+
if (matchesToast(node)) {
|
|
45
|
+
const text = ((node as HTMLElement).innerText ?? '').replace(/\s+/g, ' ').trim();
|
|
46
|
+
const role = node.getAttribute('role') ?? 'alert';
|
|
47
|
+
if (text) (window as any).__capturedToasts.push({ text, role });
|
|
48
|
+
}
|
|
49
|
+
node.querySelectorAll('[role="alert"],[role="status"],[class*="toast"],[class*="Toast"],[class*="snackbar"],[class*="notification"]').forEach((child) => {
|
|
50
|
+
const text = ((child as HTMLElement).innerText ?? '').replace(/\s+/g, ' ').trim();
|
|
51
|
+
const role = child.getAttribute('role') ?? 'alert';
|
|
52
|
+
if (text) (window as any).__capturedToasts.push({ text, role });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const observer = new MutationObserver((mutations) => {
|
|
57
|
+
for (const m of mutations) {
|
|
58
|
+
m.addedNodes.forEach(captureNode);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
63
|
+
(window as any).__toastObserver = observer;
|
|
64
|
+
}).catch(() => undefined);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function collectCapturedToasts(page: Page): Promise<Array<{ text: string; role: string }>> {
|
|
68
|
+
try {
|
|
69
|
+
return await page.evaluate(() => {
|
|
70
|
+
const toasts: Array<{ text: string; role: string }> = (window as any).__capturedToasts ?? [];
|
|
71
|
+
(window as any).__capturedToasts = [];
|
|
72
|
+
return toasts;
|
|
73
|
+
});
|
|
74
|
+
} catch {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ── Internal: Button discovery ────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
interface CrudButtons {
|
|
82
|
+
editBtns: Locator[];
|
|
83
|
+
deleteBtns: Locator[];
|
|
84
|
+
createBtn: Locator | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function findCrudButtons(page: Page): Promise<CrudButtons> {
|
|
88
|
+
const editLocator = page.locator(
|
|
89
|
+
'button[aria-label*="edit" i], button[aria-label*="Edit"], button:has-text("Edit")'
|
|
90
|
+
);
|
|
91
|
+
const deleteLocator = page.locator(
|
|
92
|
+
'button[aria-label*="delete" i], button[aria-label*="Delete"], button:has-text("Delete")'
|
|
93
|
+
);
|
|
94
|
+
const createLocator = page.locator(
|
|
95
|
+
'button:has-text("New"), button:has-text("Create"), button:has-text("Add")'
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const [editCount, deleteCount, createCount] = await Promise.all([
|
|
99
|
+
editLocator.count().catch(() => 0),
|
|
100
|
+
deleteLocator.count().catch(() => 0),
|
|
101
|
+
createLocator.count().catch(() => 0),
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
const editBtns: Locator[] = [];
|
|
105
|
+
for (let i = 0; i < Math.min(editCount, 3); i++) {
|
|
106
|
+
editBtns.push(editLocator.nth(i));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const deleteBtns: Locator[] = [];
|
|
110
|
+
for (let i = 0; i < Math.min(deleteCount, 3); i++) {
|
|
111
|
+
deleteBtns.push(deleteLocator.nth(i));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const createBtn = createCount > 0 ? createLocator.first() : null;
|
|
115
|
+
|
|
116
|
+
return { editBtns, deleteBtns, createBtn };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ── Internal: Edit flow detection ─────────────────────────────────────────────
|
|
120
|
+
|
|
121
|
+
async function detectEditFlowType(page: Page, editButton: Locator): Promise<EditFlowType> {
|
|
122
|
+
try {
|
|
123
|
+
const urlBefore = page.url();
|
|
124
|
+
await editButton.click({ timeout: 2000 });
|
|
125
|
+
await page.waitForTimeout(600);
|
|
126
|
+
|
|
127
|
+
const urlAfter = page.url();
|
|
128
|
+
if (urlAfter !== urlBefore) {
|
|
129
|
+
await page.goBack().catch(() => undefined);
|
|
130
|
+
await page.waitForTimeout(300);
|
|
131
|
+
return 'navigation';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const dialogVisible = await page.locator('[role="dialog"]').first().isVisible().catch(() => false);
|
|
135
|
+
if (dialogVisible) {
|
|
136
|
+
await page.keyboard.press('Escape');
|
|
137
|
+
await page.waitForTimeout(300);
|
|
138
|
+
return 'modal';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const inlineInputCount = await page.locator('input:visible, textarea:visible').count().catch(() => 0);
|
|
142
|
+
if (inlineInputCount > 0) {
|
|
143
|
+
await page.keyboard.press('Escape');
|
|
144
|
+
await page.waitForTimeout(300);
|
|
145
|
+
return 'inline';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
await page.keyboard.press('Escape');
|
|
149
|
+
await page.waitForTimeout(300);
|
|
150
|
+
return 'unknown';
|
|
151
|
+
} catch {
|
|
152
|
+
try {
|
|
153
|
+
await page.keyboard.press('Escape');
|
|
154
|
+
} catch { /* ignore */ }
|
|
155
|
+
return 'unknown';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ── Internal: Modal field capture ─────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
async function captureEditModal(
|
|
162
|
+
page: Page
|
|
163
|
+
): Promise<Array<{ name: string; type: string; prefilledValue?: string }>> {
|
|
164
|
+
try {
|
|
165
|
+
const dialog = page.locator('[role="dialog"]').first();
|
|
166
|
+
const fields = dialog.locator('input, textarea, select');
|
|
167
|
+
const count = Math.min(await fields.count().catch(() => 0), 20);
|
|
168
|
+
|
|
169
|
+
const results: Array<{ name: string; type: string; prefilledValue?: string }> = [];
|
|
170
|
+
|
|
171
|
+
for (let i = 0; i < count; i++) {
|
|
172
|
+
try {
|
|
173
|
+
const field = fields.nth(i);
|
|
174
|
+
const tagName = await field.evaluate((el) => el.tagName.toLowerCase()).catch(() => 'input');
|
|
175
|
+
const inputType = await field.getAttribute('type').catch(() => null) ?? tagName;
|
|
176
|
+
const name =
|
|
177
|
+
(await field.getAttribute('name').catch(() => null)) ??
|
|
178
|
+
(await field.getAttribute('id').catch(() => null)) ??
|
|
179
|
+
(await field.getAttribute('aria-label').catch(() => null)) ??
|
|
180
|
+
`field_${i}`;
|
|
181
|
+
const prefilledValue = await field.inputValue().catch(() => undefined);
|
|
182
|
+
|
|
183
|
+
results.push({
|
|
184
|
+
name,
|
|
185
|
+
type: inputType,
|
|
186
|
+
prefilledValue: prefilledValue || undefined,
|
|
187
|
+
});
|
|
188
|
+
} catch { /* skip individual field errors */ }
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return results;
|
|
192
|
+
} catch {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ── Internal: Delete confirmation capture ─────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
async function captureDeleteConfirmation(
|
|
200
|
+
page: Page,
|
|
201
|
+
deleteBtn: Locator
|
|
202
|
+
): Promise<{ message: string; confirmLabel: string; cancelLabel: string } | null> {
|
|
203
|
+
try {
|
|
204
|
+
await deleteBtn.click({ timeout: 2000 });
|
|
205
|
+
|
|
206
|
+
const confirmDialog = page.locator('[role="alertdialog"], [role="dialog"]').first();
|
|
207
|
+
try {
|
|
208
|
+
await confirmDialog.waitFor({ state: 'visible', timeout: 2000 });
|
|
209
|
+
} catch {
|
|
210
|
+
await page.keyboard.press('Escape');
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const dialogText = await confirmDialog.evaluate((el) =>
|
|
215
|
+
(el as HTMLElement).innerText?.replace(/\s+/g, ' ').trim()
|
|
216
|
+
).catch(() => '');
|
|
217
|
+
|
|
218
|
+
const isDeleteDialog =
|
|
219
|
+
/delete|remove|are you sure|confirm/i.test(dialogText);
|
|
220
|
+
|
|
221
|
+
if (!isDeleteDialog) {
|
|
222
|
+
await page.keyboard.press('Escape');
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Capture button labels inside the dialog
|
|
227
|
+
const buttons = confirmDialog.locator('button');
|
|
228
|
+
const btnCount = await buttons.count().catch(() => 0);
|
|
229
|
+
const btnLabels: string[] = [];
|
|
230
|
+
for (let i = 0; i < btnCount; i++) {
|
|
231
|
+
try {
|
|
232
|
+
const label = await buttons.nth(i).innerText();
|
|
233
|
+
btnLabels.push(label.trim());
|
|
234
|
+
} catch { /* skip */ }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Heuristic: confirm = first destructive-looking label, cancel = cancel/no label
|
|
238
|
+
const confirmLabel =
|
|
239
|
+
btnLabels.find((l) => /delete|remove|yes|confirm/i.test(l)) ??
|
|
240
|
+
btnLabels[0] ??
|
|
241
|
+
'Confirm';
|
|
242
|
+
const cancelLabel =
|
|
243
|
+
btnLabels.find((l) => /cancel|no|keep|dismiss/i.test(l)) ??
|
|
244
|
+
btnLabels[btnLabels.length - 1] ??
|
|
245
|
+
'Cancel';
|
|
246
|
+
|
|
247
|
+
// CRITICAL: Always cancel — never actually delete data
|
|
248
|
+
await page.keyboard.press('Escape');
|
|
249
|
+
await page.waitForTimeout(300);
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
message: dialogText,
|
|
253
|
+
confirmLabel,
|
|
254
|
+
cancelLabel,
|
|
255
|
+
};
|
|
256
|
+
} catch {
|
|
257
|
+
try {
|
|
258
|
+
await page.keyboard.press('Escape');
|
|
259
|
+
} catch { /* ignore */ }
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ── Internal: Row count ───────────────────────────────────────────────────────
|
|
265
|
+
|
|
266
|
+
async function detectRowCount(page: Page): Promise<number> {
|
|
267
|
+
try {
|
|
268
|
+
// Try common table row patterns
|
|
269
|
+
const tableRows = await page.locator('table tbody tr').count().catch(() => 0);
|
|
270
|
+
if (tableRows > 0) return tableRows;
|
|
271
|
+
|
|
272
|
+
const listItems = await page.locator('[role="row"]').count().catch(() => 0);
|
|
273
|
+
if (listItems > 0) return listItems;
|
|
274
|
+
|
|
275
|
+
const dataItems = await page
|
|
276
|
+
.locator('[data-testid*="row"], [class*="row" i], [class*="item" i]')
|
|
277
|
+
.count()
|
|
278
|
+
.catch(() => 0);
|
|
279
|
+
return dataItems;
|
|
280
|
+
} catch {
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// ── Internal: Create trigger label ────────────────────────────────────────────
|
|
286
|
+
|
|
287
|
+
async function getCreateTriggerLabel(createBtn: Locator | null): Promise<string | undefined> {
|
|
288
|
+
if (!createBtn) return undefined;
|
|
289
|
+
try {
|
|
290
|
+
const label = await createBtn.innerText();
|
|
291
|
+
return label.trim() || undefined;
|
|
292
|
+
} catch {
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// ── Public: probeCrudFlows ────────────────────────────────────────────────────
|
|
298
|
+
|
|
299
|
+
export async function probeCrudFlows(
|
|
300
|
+
page: Page,
|
|
301
|
+
entityName = 'Entity'
|
|
302
|
+
): Promise<CrudProbeResult> {
|
|
303
|
+
const toastsObserved: Array<{ action: string; text: string; role: string }> = [];
|
|
304
|
+
|
|
305
|
+
// Step 1: Inject toast observer
|
|
306
|
+
injectToastObserver(page);
|
|
307
|
+
|
|
308
|
+
// Step 2: Find CRUD buttons
|
|
309
|
+
const { editBtns, deleteBtns, createBtn } = await findCrudButtons(page);
|
|
310
|
+
|
|
311
|
+
// Step 3: Row count
|
|
312
|
+
const rowCount = await detectRowCount(page);
|
|
313
|
+
|
|
314
|
+
// Step 4: Create trigger label
|
|
315
|
+
const createTrigger = await getCreateTriggerLabel(createBtn);
|
|
316
|
+
|
|
317
|
+
// Step 5: Probe edit flow (use first edit button)
|
|
318
|
+
let editFlowType: EditFlowType = 'unknown';
|
|
319
|
+
let editFields: Array<{ name: string; type: string; prefilledValue?: string }> = [];
|
|
320
|
+
|
|
321
|
+
if (editBtns.length > 0) {
|
|
322
|
+
try {
|
|
323
|
+
editFlowType = await detectEditFlowType(page, editBtns[0]);
|
|
324
|
+
|
|
325
|
+
if (editFlowType === 'modal') {
|
|
326
|
+
// Re-open to capture fields
|
|
327
|
+
try {
|
|
328
|
+
await editBtns[0].click({ timeout: 2000 });
|
|
329
|
+
await page.waitForTimeout(400);
|
|
330
|
+
const dialogVisible = await page
|
|
331
|
+
.locator('[role="dialog"]')
|
|
332
|
+
.first()
|
|
333
|
+
.isVisible()
|
|
334
|
+
.catch(() => false);
|
|
335
|
+
if (dialogVisible) {
|
|
336
|
+
editFields = await captureEditModal(page);
|
|
337
|
+
const editToasts = await collectCapturedToasts(page);
|
|
338
|
+
for (const t of editToasts) {
|
|
339
|
+
toastsObserved.push({ action: 'edit_open', ...t });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
await page.keyboard.press('Escape');
|
|
343
|
+
await page.waitForTimeout(300);
|
|
344
|
+
} catch { /* non-fatal */ }
|
|
345
|
+
}
|
|
346
|
+
} catch { /* non-fatal */ }
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Step 6: Probe delete confirmation (NEVER actually delete)
|
|
350
|
+
let deleteConfirmation: CrudFlowCapture['deleteConfirmation'];
|
|
351
|
+
|
|
352
|
+
if (deleteBtns.length > 0) {
|
|
353
|
+
try {
|
|
354
|
+
const result = await captureDeleteConfirmation(page, deleteBtns[0]);
|
|
355
|
+
if (result) {
|
|
356
|
+
deleteConfirmation = result;
|
|
357
|
+
const deleteToasts = await collectCapturedToasts(page);
|
|
358
|
+
for (const t of deleteToasts) {
|
|
359
|
+
toastsObserved.push({ action: 'delete_cancel', ...t });
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
} catch { /* non-fatal */ }
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Step 7: Collect any remaining toasts
|
|
366
|
+
const remainingToasts = await collectCapturedToasts(page);
|
|
367
|
+
for (const t of remainingToasts) {
|
|
368
|
+
toastsObserved.push({ action: 'ambient', ...t });
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const flow: CrudFlowCapture = {
|
|
372
|
+
entityName,
|
|
373
|
+
createTrigger,
|
|
374
|
+
editFlowType,
|
|
375
|
+
editFields,
|
|
376
|
+
deleteConfirmation,
|
|
377
|
+
rowCount,
|
|
378
|
+
hasDeleteButton: deleteBtns.length > 0,
|
|
379
|
+
hasEditButton: editBtns.length > 0,
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
return {
|
|
383
|
+
flows: [flow],
|
|
384
|
+
toastsObserved,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom JS injector — run user-provided JavaScript in the context of each crawled page.
|
|
3
|
+
*
|
|
4
|
+
* Use cases:
|
|
5
|
+
* - Extract custom data points not captured by standard extractors
|
|
6
|
+
* - Set localStorage/sessionStorage values before crawl
|
|
7
|
+
* - Override fetch() to intercept API calls
|
|
8
|
+
* - Simulate user events (keydown, focus, etc.)
|
|
9
|
+
* - Bypass specific anti-bot checks
|
|
10
|
+
*
|
|
11
|
+
* Security: scripts run in the page context (sandboxed by Chromium's renderer).
|
|
12
|
+
* They cannot access the Node.js process or file system.
|
|
13
|
+
* ZeTa validates scripts are strings before injection.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { Page } from 'playwright';
|
|
17
|
+
|
|
18
|
+
export interface JsInjectionOpts {
|
|
19
|
+
/** Script to run on every page BEFORE navigation (via page.addInitScript) */
|
|
20
|
+
initScript?: string;
|
|
21
|
+
/** Script to run on every page AFTER navigation completes (via page.evaluate) */
|
|
22
|
+
postLoadScript?: string;
|
|
23
|
+
/** Key-value pairs to set in localStorage before page load */
|
|
24
|
+
localStorage?: Record<string, string>;
|
|
25
|
+
/** Key-value pairs to set in sessionStorage before page load */
|
|
26
|
+
sessionStorage?: Record<string, string>;
|
|
27
|
+
/** Cookie key-value pairs to add before page load */
|
|
28
|
+
cookies?: Array<{ name: string; value: string; domain?: string; path?: string }>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface JsInjectionResult {
|
|
32
|
+
initScriptApplied: boolean;
|
|
33
|
+
postLoadResult: unknown;
|
|
34
|
+
storageSet: boolean;
|
|
35
|
+
cookiesSet: number;
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function injectCustomJs(page: Page, opts: JsInjectionOpts): Promise<JsInjectionResult> {
|
|
40
|
+
const result: JsInjectionResult = {
|
|
41
|
+
initScriptApplied: false,
|
|
42
|
+
postLoadResult: null,
|
|
43
|
+
storageSet: false,
|
|
44
|
+
cookiesSet: 0,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Set cookies via Playwright context
|
|
48
|
+
if (opts.cookies?.length) {
|
|
49
|
+
try {
|
|
50
|
+
await page.context().addCookies(
|
|
51
|
+
opts.cookies.map(c => ({ name: c.name, value: c.value, domain: c.domain ?? '', path: c.path ?? '/', url: page.url() || undefined }))
|
|
52
|
+
);
|
|
53
|
+
result.cookiesSet = opts.cookies.length;
|
|
54
|
+
} catch (e: any) {
|
|
55
|
+
result.error = `Cookie injection failed: ${e.message}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Init script (runs before page load on every navigation)
|
|
60
|
+
if (opts.initScript || opts.localStorage || opts.sessionStorage) {
|
|
61
|
+
const storageSetup = [
|
|
62
|
+
opts.localStorage ? `Object.entries(${JSON.stringify(opts.localStorage)}).forEach(([k,v])=>localStorage.setItem(k,v));` : '',
|
|
63
|
+
opts.sessionStorage ? `Object.entries(${JSON.stringify(opts.sessionStorage)}).forEach(([k,v])=>sessionStorage.setItem(k,v));` : '',
|
|
64
|
+
].filter(Boolean).join('\n');
|
|
65
|
+
|
|
66
|
+
const combinedInit = [storageSetup, opts.initScript ?? ''].filter(Boolean).join('\n');
|
|
67
|
+
try {
|
|
68
|
+
await page.addInitScript(combinedInit);
|
|
69
|
+
result.initScriptApplied = true;
|
|
70
|
+
result.storageSet = !!(opts.localStorage || opts.sessionStorage);
|
|
71
|
+
} catch (e: any) {
|
|
72
|
+
result.error = `Init script failed: ${e.message}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Post-load script (runs after navigation)
|
|
77
|
+
if (opts.postLoadScript) {
|
|
78
|
+
try {
|
|
79
|
+
result.postLoadResult = await page.evaluate(opts.postLoadScript);
|
|
80
|
+
} catch (e: any) {
|
|
81
|
+
result.error = `Post-load script failed: ${e.message}`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Safe string validator — ensures script is a string, not an object/function reference */
|
|
89
|
+
export function validateScript(script: unknown): string {
|
|
90
|
+
if (typeof script !== 'string') throw new Error('Script must be a string');
|
|
91
|
+
if (script.length > 50_000) throw new Error('Script too large (>50KB)');
|
|
92
|
+
return script;
|
|
93
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dark mode capture — screenshot pages in both light and dark color schemes.
|
|
3
|
+
*
|
|
4
|
+
* Uses Playwright's page.emulateMedia({ colorScheme: 'dark' }) to force dark mode,
|
|
5
|
+
* then captures a screenshot. Compares with light mode to determine if dark mode
|
|
6
|
+
* is supported (significant visual difference).
|
|
7
|
+
*
|
|
8
|
+
* Also detects prefers-color-scheme media query support in CSS.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Page } from 'playwright';
|
|
12
|
+
|
|
13
|
+
export interface DarkModeCapture {
|
|
14
|
+
url: string;
|
|
15
|
+
lightScreenshot?: Buffer;
|
|
16
|
+
darkScreenshot?: Buffer;
|
|
17
|
+
hasDarkMode: boolean;
|
|
18
|
+
hasCssDarkMode: boolean; // @media (prefers-color-scheme: dark) detected in stylesheets
|
|
19
|
+
backgroundColorLight?: string;
|
|
20
|
+
backgroundColorDark?: string;
|
|
21
|
+
capturedAt: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function getBackgroundColor(page: Page): Promise<string> {
|
|
25
|
+
try {
|
|
26
|
+
return await page.evaluate(() => {
|
|
27
|
+
const body = document.body;
|
|
28
|
+
return window.getComputedStyle(body).backgroundColor;
|
|
29
|
+
});
|
|
30
|
+
} catch {
|
|
31
|
+
return 'unknown';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function colorsAreDifferent(a: string, b: string): boolean {
|
|
36
|
+
if (a === b) return false;
|
|
37
|
+
if (a === 'unknown' || b === 'unknown') return false;
|
|
38
|
+
// Parse rgb(r, g, b) and compare luminance
|
|
39
|
+
const parse = (c: string) => {
|
|
40
|
+
const m = c.match(/\d+/g);
|
|
41
|
+
return m ? m.map(Number) : [0, 0, 0];
|
|
42
|
+
};
|
|
43
|
+
const [ar, ag, ab] = parse(a);
|
|
44
|
+
const [br, bg, bb] = parse(b);
|
|
45
|
+
const lumA = 0.299 * ar + 0.587 * ag + 0.114 * ab;
|
|
46
|
+
const lumB = 0.299 * br + 0.587 * bg + 0.114 * bb;
|
|
47
|
+
return Math.abs(lumA - lumB) > 30; // significant luminance difference
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function hasCssDarkModeSupport(page: Page): Promise<boolean> {
|
|
51
|
+
try {
|
|
52
|
+
return await page.evaluate(() => {
|
|
53
|
+
const sheets = Array.from(document.styleSheets);
|
|
54
|
+
for (const sheet of sheets) {
|
|
55
|
+
try {
|
|
56
|
+
const rules = Array.from(sheet.cssRules ?? []);
|
|
57
|
+
for (const rule of rules) {
|
|
58
|
+
if (rule instanceof CSSMediaRule && rule.conditionText?.includes('prefers-color-scheme')) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch { /* cross-origin stylesheet — skip */ }
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
});
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function captureDarkMode(
|
|
72
|
+
page: Page,
|
|
73
|
+
url: string,
|
|
74
|
+
opts: { takeScreenshots?: boolean } = {},
|
|
75
|
+
): Promise<DarkModeCapture> {
|
|
76
|
+
const capturedAt = new Date().toISOString();
|
|
77
|
+
const { takeScreenshots = false } = opts;
|
|
78
|
+
|
|
79
|
+
// Light mode
|
|
80
|
+
await page.emulateMedia({ colorScheme: 'light' }).catch(() => {});
|
|
81
|
+
const backgroundColorLight = await getBackgroundColor(page);
|
|
82
|
+
const hasCssDark = await hasCssDarkModeSupport(page);
|
|
83
|
+
const lightScreenshot = takeScreenshots
|
|
84
|
+
? await page.screenshot({ type: 'jpeg', quality: 60 }).catch(() => undefined)
|
|
85
|
+
: undefined;
|
|
86
|
+
|
|
87
|
+
// Dark mode
|
|
88
|
+
await page.emulateMedia({ colorScheme: 'dark' }).catch(() => {});
|
|
89
|
+
await page.waitForTimeout(300); // allow CSS transitions
|
|
90
|
+
const backgroundColorDark = await getBackgroundColor(page);
|
|
91
|
+
const darkScreenshot = takeScreenshots
|
|
92
|
+
? await page.screenshot({ type: 'jpeg', quality: 60 }).catch(() => undefined)
|
|
93
|
+
: undefined;
|
|
94
|
+
|
|
95
|
+
// Restore light mode
|
|
96
|
+
await page.emulateMedia({ colorScheme: 'light' }).catch(() => {});
|
|
97
|
+
|
|
98
|
+
const hasDarkMode = colorsAreDifferent(backgroundColorLight, backgroundColorDark) || hasCssDark;
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
url,
|
|
102
|
+
lightScreenshot,
|
|
103
|
+
darkScreenshot,
|
|
104
|
+
hasDarkMode,
|
|
105
|
+
hasCssDarkMode: hasCssDark,
|
|
106
|
+
backgroundColorLight,
|
|
107
|
+
backgroundColorDark,
|
|
108
|
+
capturedAt,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dead link detector — tracks broken links discovered during crawl.
|
|
3
|
+
*
|
|
4
|
+
* A "dead link" is a URL that:
|
|
5
|
+
* - Returns 404, 410, or other 4xx/5xx responses
|
|
6
|
+
* - Times out after maxRetries
|
|
7
|
+
* - Redirects to an error page (detected by title heuristic)
|
|
8
|
+
*
|
|
9
|
+
* Results: list of broken links with source page, status code, and anchor text.
|
|
10
|
+
* Used for: SEO audit export, test report enrichment.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface DeadLink {
|
|
14
|
+
url: string;
|
|
15
|
+
statusCode: number;
|
|
16
|
+
sourceUrl?: string;
|
|
17
|
+
anchorText?: string;
|
|
18
|
+
checkedAt: string;
|
|
19
|
+
reason: 'http-error' | 'timeout' | 'dns-error';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class DeadLinkTracker {
|
|
23
|
+
private deadLinks: DeadLink[] = [];
|
|
24
|
+
private checked = new Map<string, number>(); // url → statusCode
|
|
25
|
+
|
|
26
|
+
record(
|
|
27
|
+
url: string,
|
|
28
|
+
statusCode: number,
|
|
29
|
+
source?: { sourceUrl?: string; anchorText?: string },
|
|
30
|
+
): void {
|
|
31
|
+
if (this.checked.has(url)) return;
|
|
32
|
+
this.checked.set(url, statusCode);
|
|
33
|
+
if (statusCode >= 400) {
|
|
34
|
+
this.deadLinks.push({
|
|
35
|
+
url,
|
|
36
|
+
statusCode,
|
|
37
|
+
sourceUrl: source?.sourceUrl,
|
|
38
|
+
anchorText: source?.anchorText,
|
|
39
|
+
checkedAt: new Date().toISOString(),
|
|
40
|
+
reason: statusCode === 0 ? 'timeout' : 'http-error',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
recordTimeout(url: string, sourceUrl?: string): void {
|
|
46
|
+
if (this.checked.has(url)) return;
|
|
47
|
+
this.checked.set(url, 0);
|
|
48
|
+
this.deadLinks.push({ url, statusCode: 0, sourceUrl, checkedAt: new Date().toISOString(), reason: 'timeout' });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getDeadLinks(): DeadLink[] {
|
|
52
|
+
return [...this.deadLinks];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
isKnownBroken(url: string): boolean {
|
|
56
|
+
const code = this.checked.get(url);
|
|
57
|
+
return code !== undefined && code >= 400;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
stats(): { total: number; by404: number; by5xx: number; byTimeout: number } {
|
|
61
|
+
return {
|
|
62
|
+
total: this.deadLinks.length,
|
|
63
|
+
by404: this.deadLinks.filter(l => l.statusCode === 404).length,
|
|
64
|
+
by5xx: this.deadLinks.filter(l => l.statusCode >= 500).length,
|
|
65
|
+
byTimeout: this.deadLinks.filter(l => l.reason === 'timeout').length,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toCsv(): string {
|
|
70
|
+
const rows = [['URL', 'Status', 'Source URL', 'Anchor Text', 'Checked At']];
|
|
71
|
+
for (const l of this.deadLinks) {
|
|
72
|
+
rows.push([l.url, String(l.statusCode), l.sourceUrl ?? '', l.anchorText ?? '', l.checkedAt]);
|
|
73
|
+
}
|
|
74
|
+
return rows.map(r => r.map(c => `"${c.replace(/"/g, '""')}"`).join(',')).join('\n');
|
|
75
|
+
}
|
|
76
|
+
}
|