@evocrawl/rs
Advanced tools
+241
| /* auto-generated by NAPI-RS */ | ||
| /* eslint-disable */ | ||
| export declare class DocumentConverter { | ||
| constructor() | ||
| convertBufferToHtml(data: Uint8Array, docType: DocumentType): string | ||
| } | ||
| export interface AttributeSelector { | ||
| selector: string | ||
| attribute: string | ||
| } | ||
| /** | ||
| * Compute engpicker verdict using Levenshtein distance to compare tlsclient vs chrome-cdp results. | ||
| * | ||
| * Chrome-CDP is the gold standard. We compare tlsclient markdown against it to determine | ||
| * if tlsclient is sufficient for scraping this site (i.e., JS rendering not required). | ||
| * | ||
| * Arguments: | ||
| * - results: scrape results for each URL | ||
| * - similarity_threshold: minimum similarity (0.0-1.0) for tlsclient to be considered sufficient | ||
| * - success_rate_threshold: minimum ratio of successful comparisons for a definitive verdict | ||
| * - cdp_failure_threshold: maximum ratio of CDP failures before verdict becomes uncertain | ||
| */ | ||
| export declare function computeEngpickerVerdict(results: Array<EngpickerUrlResult>, similarityThreshold: number, successRateThreshold: number, cdpFailureThreshold: number): Promise<EngpickerVerdict> | ||
| /** | ||
| * Fast metadata-only detection: page count, title, type, confidence. | ||
| * Skips text extraction, markdown generation, and layout analysis. | ||
| * Pass `ctx` (NativeContext) for structured tracing with scrape_id/url. | ||
| */ | ||
| export declare function detectPdf(path: string, ctx?: NativeContext | undefined | null): PdfProcessResult | ||
| export declare const enum DocumentType { | ||
| Doc = 0, | ||
| Docx = 1, | ||
| Rtf = 2, | ||
| Odt = 3, | ||
| Xlsx = 4 | ||
| } | ||
| /** Final verdict enum */ | ||
| export declare const enum EngpickerFinalVerdict { | ||
| /** tlsclient is sufficient for this site */ | ||
| TlsClientOk = 'TlsClientOk', | ||
| /** Chrome CDP is required for proper rendering */ | ||
| ChromeCdpRequired = 'ChromeCdpRequired', | ||
| /** Too many CDP failures to determine verdict */ | ||
| Uncertain = 'Uncertain' | ||
| } | ||
| /** Result of evaluating a single URL across different engines */ | ||
| export interface EngpickerUrlResult { | ||
| url: string | ||
| cdpBasicMarkdown?: string | ||
| cdpBasicSuccess: boolean | ||
| cdpStealthMarkdown?: string | ||
| cdpStealthSuccess: boolean | ||
| tlsBasicMarkdown?: string | ||
| tlsBasicSuccess: boolean | ||
| tlsStealthMarkdown?: string | ||
| tlsStealthSuccess: boolean | ||
| } | ||
| /** Verdict for a single URL */ | ||
| export interface EngpickerUrlVerdict { | ||
| url: string | ||
| tlsClientSufficient: boolean | ||
| cdpFailed: boolean | ||
| similarity?: number | ||
| reason: string | ||
| } | ||
| /** Final verdict result */ | ||
| export interface EngpickerVerdict { | ||
| urlVerdicts: Array<EngpickerUrlVerdict> | ||
| tlsClientOkCount: number | ||
| chromeCdpRequiredCount: number | ||
| cdpFailedCount: number | ||
| totalUrls: number | ||
| verdict: EngpickerFinalVerdict | ||
| } | ||
| /** Extract specified attributes from HTML elements matching selectors. */ | ||
| export declare function extractAttributes(html: string, options: ExtractAttributesOptions): Promise<Array<ExtractedAttributeResult>> | ||
| export interface ExtractAttributesOptions { | ||
| selectors: Array<AttributeSelector> | ||
| } | ||
| /** Extract the base href from HTML document. */ | ||
| export declare function extractBaseHref(html: string, url: string): Promise<string> | ||
| export interface ExtractedAttributeResult { | ||
| selector: string | ||
| attribute: string | ||
| values: Array<string> | ||
| } | ||
| /** Extract all image URLs from HTML document. */ | ||
| export declare function extractImages(html: string, baseUrl: string): Promise<Array<string>> | ||
| /** Extract all links from HTML document. */ | ||
| export declare function extractLinks(html?: string | undefined | null): Promise<Array<string>> | ||
| /** Extract metadata from HTML document. */ | ||
| export declare function extractMetadata(html?: string | undefined | null): Promise<Record<string, any>> | ||
| /** Filter links based on crawling rules and constraints. */ | ||
| export declare function filterLinks(data: FilterLinksCall): Promise<FilterLinksResult> | ||
| export interface FilterLinksCall { | ||
| links: Array<string> | ||
| limit?: number | ||
| maxDepth: number | ||
| baseUrl: string | ||
| initialUrl: string | ||
| regexOnFullUrl: boolean | ||
| excludes: Array<string> | ||
| includes: Array<string> | ||
| allowBackwardCrawling: boolean | ||
| ignoreRobotsTxt: boolean | ||
| robotsTxt: string | ||
| allowExternalContentLinks: boolean | ||
| allowSubdomains: boolean | ||
| } | ||
| export interface FilterLinksResult { | ||
| links: Array<string> | ||
| denialReasons: Record<string, string> | ||
| } | ||
| /** Filter a single URL based on crawling rules and constraints. */ | ||
| export declare function filterUrl(data: FilterUrlCall): Promise<FilterUrlResult> | ||
| export interface FilterUrlCall { | ||
| href: string | ||
| url: string | ||
| baseUrl: string | ||
| excludes: Array<string> | ||
| ignoreRobotsTxt: boolean | ||
| robotsTxt: string | ||
| allowExternalContentLinks: boolean | ||
| allowSubdomains: boolean | ||
| } | ||
| export interface FilterUrlResult { | ||
| allowed: boolean | ||
| url?: string | ||
| denialReason?: string | ||
| } | ||
| /** Extract inner text content from HTML body. */ | ||
| export declare function getInnerJson(html: string): Promise<string> | ||
| /** Context passed from TypeScript to continue the trace. */ | ||
| export interface NativeContext { | ||
| scrapeId: string | ||
| url: string | ||
| } | ||
| /** A single log entry captured during Rust execution. */ | ||
| export interface NativeLogEntry { | ||
| level: string | ||
| target: string | ||
| message: string | ||
| fields: any | ||
| timestampMs: number | ||
| } | ||
| export interface ParsedSitemap { | ||
| urlset?: SitemapUrlset | ||
| sitemapindex?: SitemapIndex | ||
| } | ||
| /** Parse XML sitemap content into structured data. */ | ||
| export declare function parseSitemapXml(xmlContent: string): Promise<ParsedSitemap> | ||
| export interface PdfProcessResult { | ||
| pdfType: string | ||
| markdown?: string | ||
| pageCount: number | ||
| processingTimeMs: number | ||
| pagesNeedingOcr: Array<number> | ||
| title?: string | ||
| confidence: number | ||
| isComplex: boolean | ||
| logs: Array<NativeLogEntry> | ||
| } | ||
| /** Process multi-line links in markdown. */ | ||
| export declare function postProcessMarkdown(markdown: string): Promise<string> | ||
| /** | ||
| * Process a PDF file: detect type, extract text + markdown if text-based. | ||
| * When `max_pages` is provided, only the first N pages are extracted. | ||
| * Pass `ctx` (NativeContext) for structured tracing with scrape_id/url. | ||
| */ | ||
| export declare function processPdf(path: string, maxPages?: number | undefined | null, ctx?: NativeContext | undefined | null): PdfProcessResult | ||
| /** Process sitemap XML and extract crawling instructions. */ | ||
| export declare function processSitemap(xmlContent: string): Promise<SitemapProcessingResult> | ||
| export interface SitemapEntry { | ||
| loc: Array<string> | ||
| } | ||
| export interface SitemapIndex { | ||
| sitemap: Array<SitemapEntry> | ||
| } | ||
| export interface SitemapInstruction { | ||
| action: string | ||
| urls: Array<string> | ||
| count: number | ||
| } | ||
| export interface SitemapProcessingResult { | ||
| instructions: Array<SitemapInstruction> | ||
| totalCount: number | ||
| } | ||
| export interface SitemapUrl { | ||
| loc: Array<string> | ||
| } | ||
| export interface SitemapUrlset { | ||
| url: Array<SitemapUrl> | ||
| } | ||
| /** Transform and clean HTML content based on provided options. */ | ||
| export declare function transformHtml(opts: TransformHtmlOptions): Promise<string> | ||
| export interface TransformHtmlOptions { | ||
| html: string | ||
| url: string | ||
| includeTags: Array<string> | ||
| excludeTags: Array<string> | ||
| onlyMainContent: boolean | ||
| omceSignatures?: Array<string> | ||
| } |
+596
| // prettier-ignore | ||
| /* eslint-disable */ | ||
| // @ts-nocheck | ||
| /* auto-generated by NAPI-RS */ | ||
| const { readFileSync } = require('node:fs') | ||
| let nativeBinding = null | ||
| const loadErrors = [] | ||
| const isMusl = () => { | ||
| let musl = false | ||
| if (process.platform === 'linux') { | ||
| musl = isMuslFromFilesystem() | ||
| if (musl === null) { | ||
| musl = isMuslFromReport() | ||
| } | ||
| if (musl === null) { | ||
| musl = isMuslFromChildProcess() | ||
| } | ||
| } | ||
| return musl | ||
| } | ||
| const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-') | ||
| const isMuslFromFilesystem = () => { | ||
| try { | ||
| return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl') | ||
| } catch { | ||
| return null | ||
| } | ||
| } | ||
| const isMuslFromReport = () => { | ||
| let report = null | ||
| if (typeof process.report?.getReport === 'function') { | ||
| process.report.excludeNetwork = true | ||
| report = process.report.getReport() | ||
| } | ||
| if (!report) { | ||
| return null | ||
| } | ||
| if (report.header && report.header.glibcVersionRuntime) { | ||
| return false | ||
| } | ||
| if (Array.isArray(report.sharedObjects)) { | ||
| if (report.sharedObjects.some(isFileMusl)) { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
| const isMuslFromChildProcess = () => { | ||
| try { | ||
| return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl') | ||
| } catch (e) { | ||
| // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false | ||
| return false | ||
| } | ||
| } | ||
| function requireNative() { | ||
| if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { | ||
| try { | ||
| return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); | ||
| } catch (err) { | ||
| loadErrors.push(err) | ||
| } | ||
| } else if (process.platform === 'android') { | ||
| if (process.arch === 'arm64') { | ||
| try { | ||
| return require('./evocrawl-rs.android-arm64.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-android-arm64') | ||
| const bindingPackageVersion = require('@evocrawl/rs-android-arm64/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else if (process.arch === 'arm') { | ||
| try { | ||
| return require('./evocrawl-rs.android-arm-eabi.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-android-arm-eabi') | ||
| const bindingPackageVersion = require('@evocrawl/rs-android-arm-eabi/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) | ||
| } | ||
| } else if (process.platform === 'win32') { | ||
| if (process.arch === 'x64') { | ||
| if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { | ||
| try { | ||
| return require('./evocrawl-rs.win32-x64-gnu.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-win32-x64-gnu') | ||
| const bindingPackageVersion = require('@evocrawl/rs-win32-x64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| try { | ||
| return require('./evocrawl-rs.win32-x64-msvc.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-win32-x64-msvc') | ||
| const bindingPackageVersion = require('@evocrawl/rs-win32-x64-msvc/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } | ||
| } else if (process.arch === 'ia32') { | ||
| try { | ||
| return require('./evocrawl-rs.win32-ia32-msvc.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-win32-ia32-msvc') | ||
| const bindingPackageVersion = require('@evocrawl/rs-win32-ia32-msvc/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else if (process.arch === 'arm64') { | ||
| try { | ||
| return require('./evocrawl-rs.win32-arm64-msvc.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-win32-arm64-msvc') | ||
| const bindingPackageVersion = require('@evocrawl/rs-win32-arm64-msvc/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) | ||
| } | ||
| } else if (process.platform === 'darwin') { | ||
| try { | ||
| return require('./evocrawl-rs.darwin-universal.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-darwin-universal') | ||
| const bindingPackageVersion = require('@evocrawl/rs-darwin-universal/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| if (process.arch === 'x64') { | ||
| try { | ||
| return require('./evocrawl-rs.darwin-x64.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-darwin-x64') | ||
| const bindingPackageVersion = require('@evocrawl/rs-darwin-x64/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else if (process.arch === 'arm64') { | ||
| try { | ||
| return require('./evocrawl-rs.darwin-arm64.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-darwin-arm64') | ||
| const bindingPackageVersion = require('@evocrawl/rs-darwin-arm64/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) | ||
| } | ||
| } else if (process.platform === 'freebsd') { | ||
| if (process.arch === 'x64') { | ||
| try { | ||
| return require('./evocrawl-rs.freebsd-x64.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-freebsd-x64') | ||
| const bindingPackageVersion = require('@evocrawl/rs-freebsd-x64/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else if (process.arch === 'arm64') { | ||
| try { | ||
| return require('./evocrawl-rs.freebsd-arm64.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-freebsd-arm64') | ||
| const bindingPackageVersion = require('@evocrawl/rs-freebsd-arm64/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) | ||
| } | ||
| } else if (process.platform === 'linux') { | ||
| if (process.arch === 'x64') { | ||
| if (isMusl()) { | ||
| try { | ||
| return require('./evocrawl-rs.linux-x64-musl.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-x64-musl') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-x64-musl/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| try { | ||
| return require('./evocrawl-rs.linux-x64-gnu.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-x64-gnu') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-x64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } | ||
| } else if (process.arch === 'arm64') { | ||
| if (isMusl()) { | ||
| try { | ||
| return require('./evocrawl-rs.linux-arm64-musl.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-arm64-musl') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-arm64-musl/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| try { | ||
| return require('./evocrawl-rs.linux-arm64-gnu.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-arm64-gnu') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-arm64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } | ||
| } else if (process.arch === 'arm') { | ||
| if (isMusl()) { | ||
| try { | ||
| return require('./evocrawl-rs.linux-arm-musleabihf.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-arm-musleabihf') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-arm-musleabihf/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| try { | ||
| return require('./evocrawl-rs.linux-arm-gnueabihf.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-arm-gnueabihf') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-arm-gnueabihf/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } | ||
| } else if (process.arch === 'loong64') { | ||
| if (isMusl()) { | ||
| try { | ||
| return require('./evocrawl-rs.linux-loong64-musl.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-loong64-musl') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-loong64-musl/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| try { | ||
| return require('./evocrawl-rs.linux-loong64-gnu.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-loong64-gnu') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-loong64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } | ||
| } else if (process.arch === 'riscv64') { | ||
| if (isMusl()) { | ||
| try { | ||
| return require('./evocrawl-rs.linux-riscv64-musl.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-riscv64-musl') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-riscv64-musl/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| try { | ||
| return require('./evocrawl-rs.linux-riscv64-gnu.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-riscv64-gnu') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-riscv64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } | ||
| } else if (process.arch === 'ppc64') { | ||
| try { | ||
| return require('./evocrawl-rs.linux-ppc64-gnu.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-ppc64-gnu') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-ppc64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else if (process.arch === 's390x') { | ||
| try { | ||
| return require('./evocrawl-rs.linux-s390x-gnu.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-linux-s390x-gnu') | ||
| const bindingPackageVersion = require('@evocrawl/rs-linux-s390x-gnu/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) | ||
| } | ||
| } else if (process.platform === 'openharmony') { | ||
| if (process.arch === 'arm64') { | ||
| try { | ||
| return require('./evocrawl-rs.openharmony-arm64.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-openharmony-arm64') | ||
| const bindingPackageVersion = require('@evocrawl/rs-openharmony-arm64/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else if (process.arch === 'x64') { | ||
| try { | ||
| return require('./evocrawl-rs.openharmony-x64.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-openharmony-x64') | ||
| const bindingPackageVersion = require('@evocrawl/rs-openharmony-x64/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else if (process.arch === 'arm') { | ||
| try { | ||
| return require('./evocrawl-rs.openharmony-arm.node') | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| try { | ||
| const binding = require('@evocrawl/rs-openharmony-arm') | ||
| const bindingPackageVersion = require('@evocrawl/rs-openharmony-arm/package.json').version | ||
| if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| return binding | ||
| } catch (e) { | ||
| loadErrors.push(e) | ||
| } | ||
| } else { | ||
| loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)) | ||
| } | ||
| } else { | ||
| loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) | ||
| } | ||
| } | ||
| nativeBinding = requireNative() | ||
| if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { | ||
| let wasiBinding = null | ||
| let wasiBindingError = null | ||
| try { | ||
| wasiBinding = require('./evocrawl-rs.wasi.cjs') | ||
| nativeBinding = wasiBinding | ||
| } catch (err) { | ||
| if (process.env.NAPI_RS_FORCE_WASI) { | ||
| wasiBindingError = err | ||
| } | ||
| } | ||
| if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { | ||
| try { | ||
| wasiBinding = require('@evocrawl/rs-wasm32-wasi') | ||
| nativeBinding = wasiBinding | ||
| } catch (err) { | ||
| if (process.env.NAPI_RS_FORCE_WASI) { | ||
| if (!wasiBindingError) { | ||
| wasiBindingError = err | ||
| } else { | ||
| wasiBindingError.cause = err | ||
| } | ||
| loadErrors.push(err) | ||
| } | ||
| } | ||
| } | ||
| if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { | ||
| const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') | ||
| error.cause = wasiBindingError | ||
| throw error | ||
| } | ||
| } | ||
| if (!nativeBinding) { | ||
| if (loadErrors.length > 0) { | ||
| throw new Error( | ||
| `Cannot find native binding. ` + | ||
| `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + | ||
| 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', | ||
| { | ||
| cause: loadErrors.reduce((err, cur) => { | ||
| cur.cause = err | ||
| return cur | ||
| }), | ||
| }, | ||
| ) | ||
| } | ||
| throw new Error(`Failed to load native binding`) | ||
| } | ||
| module.exports = nativeBinding | ||
| module.exports.DocumentConverter = nativeBinding.DocumentConverter | ||
| module.exports.computeEngpickerVerdict = nativeBinding.computeEngpickerVerdict | ||
| module.exports.detectPdf = nativeBinding.detectPdf | ||
| module.exports.DocumentType = nativeBinding.DocumentType | ||
| module.exports.EngpickerFinalVerdict = nativeBinding.EngpickerFinalVerdict | ||
| module.exports.extractAttributes = nativeBinding.extractAttributes | ||
| module.exports.extractBaseHref = nativeBinding.extractBaseHref | ||
| module.exports.extractImages = nativeBinding.extractImages | ||
| module.exports.extractLinks = nativeBinding.extractLinks | ||
| module.exports.extractMetadata = nativeBinding.extractMetadata | ||
| module.exports.filterLinks = nativeBinding.filterLinks | ||
| module.exports.filterUrl = nativeBinding.filterUrl | ||
| module.exports.getInnerJson = nativeBinding.getInnerJson | ||
| module.exports.parseSitemapXml = nativeBinding.parseSitemapXml | ||
| module.exports.postProcessMarkdown = nativeBinding.postProcessMarkdown | ||
| module.exports.processPdf = nativeBinding.processPdf | ||
| module.exports.processSitemap = nativeBinding.processSitemap | ||
| module.exports.transformHtml = nativeBinding.transformHtml |
+5
-5
| { | ||
| "name": "@evocrawl/rs", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "Template project for writing node package with napi-rs", | ||
@@ -71,7 +71,7 @@ "main": "index.js", | ||
| "optionalDependencies": { | ||
| "@evocrawl/rs-win32-x64-msvc": "1.0.1", | ||
| "@evocrawl/rs-darwin-x64": "1.0.1", | ||
| "@evocrawl/rs-linux-x64-gnu": "1.0.1", | ||
| "@evocrawl/rs-darwin-arm64": "1.0.1" | ||
| "@evocrawl/rs-win32-x64-msvc": "1.0.2", | ||
| "@evocrawl/rs-darwin-x64": "1.0.2", | ||
| "@evocrawl/rs-linux-x64-gnu": "1.0.2", | ||
| "@evocrawl/rs-darwin-arm64": "1.0.2" | ||
| } | ||
| } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
37121
639.31%4
100%788
Infinity%63
Infinity%2
100%