npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bhanquier/template-ocr

v0.1.5

Published

OCR providers and Google Cloud Vision REST client for template pipelines

Readme

@bhanquier/template-ocr

OCR mutualisé pour les pipelines templates : abstraction fournisseurs (alignée sur @bhanquier/template-core), client Google Cloud Vision via l’API REST images:annotate (sans SDK), parsing minimal de fullTextAnnotation (blocs + boîtes englobantes).

Extraction depuis Voodoo

| Source Voodoo (non modifiée) | Contenu porté ici | |----------------------------|-------------------| | packages/template-ocr/src/index.ts | OcrEngine, StubOcrProvider, OcrRecognizeInput, OcrProvider, unions de fournisseurs alignées sur OcrResult | | packages/web/lib/ocr/ocr-service.ts | recognizeWithGoogleVision (DOCUMENT_TEXT_DETECTION + TEXT_DETECTION), helpers extractTextFromBlock / verticesToBoundingBox, projection vers OcrResult | | packages/web/lib/services/pdf-template-analyzer.ts | Non inclus : rendu PDF → PNG (Playwright), heuristiques de blocs métier, branding — à garder côté app ou module séparé ; ce paquet ne dépend pas de Playwright |

Hors périmètre volontaire

  • packages/database/.../GoogleVisionProvider.ts : autre contrat (IAIProvider, jetons OAuth / service account, orchestration « smart inbox »). Ce paquet cible la clé API REST et le flux « template PDF / image » ; fusionner imposerait une couche d’adaptation produit. À réévaluer si l’on unifie les deux contrats côté TrustAkt.

Configuration

  • Clé API : variable d’environnement GOOGLE_VISION_API_KEY, ou option apiKey (recommandé en tests et pour éviter la dépendance implicite à process.env).
  • Fetch : fetch injectable (options.fetch) pour les tests et environnements non standards.

API principale

  • recognizeWithGoogleVision(input, options) — image encodée en Uint8Array, résultat structuré (blocks, dimensions, confidence, etc.).
  • imagesAnnotate(body, options) — appel bas niveau si vous composez vos propres features (ex. TEXT_DETECTION + LOGO_DETECTION pour un analyseur type facture).
  • GoogleVisionOcrProvider — implémente OcrProvider pour OcrEngine (retourne OcrResult agrégé).
  • googleVisionStructuredToOcrResult — passage au type OcrResult de @bhanquier/template-core.
  • parseFullTextAnnotation / extractTextFromBlock / verticesToBoundingBox — si vous parsez déjà une réponse JSON Vision.

PDF → image

Ce paquet n’embarque pas Playwright ni de rasterisation PDF. Le flux type (comme dans Voodoo pdf-template-analyzer) est :

  1. Côté application : PDF → PNG/WebP (Playwright, pdftoppm, service interne, etc.).
  2. Ici : octets image → recognizeWithGoogleVision({ content }).

Cela évite d’alourdir les consommateurs qui n’ont besoin que de l’OCR sur une image déjà produite.

Lien avec le template-service / SDK

Les produits (Kontrakt, Voodoo) peuvent enchaîner : analyse de fichier → (optionnel) étape PDF → image → ce module → enrichissement canonical / analysis_notes côté service. Le SDK @bhanquier/template-sdk reste agnostique : branchez template-ocr dans votre couche orchestration si vous exposez Vision côté backend.

Limites

  • Coût et quotas Google Vision appliqués par Google ; pas de retry intégré.
  • tables dans le résultat structuré est toujours [] pour ce flux (identique au comportement historique Voodoo pour Vision).
  • Confiance agrégée : moyenne des confidences de blocs lorsque présentes, sinon heuristique proche de l’existant (~0,98 si blocs présents).