Preparing search index...

    Class BaseRecipeProviderAbstract

    Abstract base class for recipe providers

    Implements the RecipeProvider interface with common functionality for discovering, parsing, and fetching recipes from external websites. Subclasses must implement provider-specific methods for URL extraction.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    id: string

    Unique identifier for this provider

    name: string

    Display name for this provider

    logoUrl: string

    URL to the provider's logo image

    activeImageFetches: number = 0

    Currently active image fetch count

    pendingImageFetches: {
        url: string;
        onImageLoaded: (recipeUrl: string, imageUrl: string) => void;
        signal?: AbortSignal;
    }[] = []

    Queue of pending image fetch requests

    Methods

    • Discovers all recipe category URLs from the provider

      Parameters

      • baseUrl: string

        The provider's base URL

      • Optionalsignal: AbortSignal

        Optional abort signal for cancellation

      Returns Promise<string[]>

      Promise resolving to array of category page URLs

    • Extracts recipe links from an HTML page

      Parameters

      • html: string

        Raw HTML content of a page

      Returns { url: string; title?: string; imageUrl?: string }[]

      Array of discovered recipe links with optional title and image

    • Fetches and parses a single recipe from its URL

      Parameters

      • url: string

        URL of the recipe page to fetch

      • defaultPersons: number

        Default serving size if not specified in recipe

      • ignoredPatterns: IgnoredIngredientPatterns

        Patterns for ingredients to skip during parsing

      • Optionalsignal: AbortSignal

        Optional abort signal for cancellation

      Returns Promise<FetchedRecipe>

      Promise resolving to the fetched and converted recipe

      Error if recipe cannot be parsed

    • Returns the URL of the known placeholder image for this provider, if any

      Used by ImageRepair to detect recipes stored with placeholder content by comparing MD5 hashes of local files against the placeholder.

      Returns null | string

      The placeholder image URL, or null if this provider has no known placeholder

    • Returns true if this provider can handle the given recipe source URL

      Default implementation returns false. Subclasses should override to check whether the URL belongs to their domain.

      Parameters

      • _url: string

        Recipe source URL to test

      Returns boolean

      false by default

    • Fetches just the image URL for a recipe page on-demand

      Used for visibility-based lazy loading of images. Fetches the recipe page HTML and extracts the image URL from JSON-LD schema data.

      Parameters

      • url: string

        Recipe page URL to fetch image for

      • signal: AbortSignal

        Abort signal for cancellation

      Returns Promise<null | string>

      Promise resolving to image URL or null if not found/failed

    • Fetches HTML content from a URL with timeout handling

      Parameters

      • url: string

        URL to fetch

      • Optionalsignal: AbortSignal

        Optional abort signal for cancellation

      Returns Promise<string>

      Promise resolving to the HTML content

      Error if request fails or times out

    • Delays execution for rate limiting

      Parameters

      • ms: number

        Milliseconds to delay

      Returns Promise<void>

      Promise that resolves after the delay

    • Fetches a batch of category pages concurrently

      Parameters

      • urls: string[]
      • signal: undefined | AbortSignal

      Returns Promise<PromiseSettledResult<CategoryResult>[]>

    • Processes results from a batch of category page fetches

      Parameters

      Returns void

    • Adds discovered recipe links to state, avoiding duplicates

      Parameters

      • links: { url: string; title?: string; imageUrl?: string }[]
      • state: DiscoveryState
      • maxRecipes: undefined | number

      Returns void

    • Retries empty pages that appeared before the last successful page (likely rate-limited)

      Parameters

      • categoryUrls: string[]
      • state: DiscoveryState
      • maxRecipes: undefined | number
      • signal: undefined | AbortSignal

      Returns Promise<void>

    • Executes a single retry attempt for failed pages

      Parameters

      • pagesToRetry: string[]
      • state: DiscoveryState
      • maxRecipes: undefined | number
      • signal: undefined | AbortSignal
      • attempt: number

      Returns Promise<string[]>

    • Queues a recipe image fetch for background processing

      Adds the request to a queue and triggers processing. Uses a semaphore pattern to limit concurrent requests and prevent memory exhaustion.

      Parameters

      • url: string

        Recipe URL to fetch image for

      • onImageLoaded: (recipeUrl: string, imageUrl: string) => void

        Callback invoked when an image URL is found

      • Optionalsignal: AbortSignal

        Optional abort signal for cancellation

      Returns void

    • Processes queued image fetch requests with concurrency limiting

      Dequeues requests and executes them up to MAX_CONCURRENT_IMAGE_FETCHES at a time. Each completed request triggers queue processing to maintain throughput while preventing memory exhaustion.

      Returns void

    • Combines two abort signals into one

      Creates a new abort signal that triggers when either input signal aborts.

      Parameters

      • signal1: AbortSignal

        First abort signal

      • signal2: AbortSignal

        Second abort signal

      Returns AbortSignal

      Combined abort signal