mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2026-08-28 20:08:54 +08:00
1fc8b98180
* chore: import paddleocr-js subproject skeleton Made-with: Cursor * refactor: rename internal paddleocr-js workspaces Made-with: Cursor * fix: remove stale paddleocr-js workspace lock entries Made-with: Cursor * docs: rewrite paddleocr-js subproject docs Made-with: Cursor * test: fix ocr shared lint regression Made-with: Cursor * chore: add low-coupling paddleocr-js host integration Made-with: Cursor * Update docs * Add langchain-paddleocr to skip gpu condition * Skip subprojects * Update lock * docs(paddleocr-js): add TypeScript migration design spec Made-with: Cursor * docs(paddleocr-js): add TypeScript migration implementation plan Made-with: Cursor * build(paddleocr-js): add TypeScript toolchain and build infrastructure Set up the TypeScript migration foundation: - Add TypeScript, vite-plugin-dts, and type definitions as devDependencies - Create tsconfig.json files (core, test, root project references) - Configure Vite library build with ES/CJS/UMD outputs and .d.ts generation - Update package.json entry points from src/ to dist/ with proper exports map - Replace plain JS ESLint config with typescript-eslint strict type-checked rules - Update Vitest coverage to target .ts files - Add typecheck script, engines, keywords across workspace packages Made-with: Cursor * fix(paddleocr-js): exclude config files from strict TS lint, reorder exports types-first Made-with: Cursor * refactor(paddleocr-js): add third-party type declarations for clipper-lib and opencv Minimal .d.ts files covering only the APIs actually used by the project. Made-with: Cursor * refactor(paddleocr-js): convert Layer 0-1 modules to TypeScript Converts utils/common, worker/protocol, pipelines/ocr/default-config, pipelines/ocr/runtime-params, runtime/opencv, runtime/ort, runtime/index, and models/common from .js to .ts with full type annotations. Made-with: Cursor * refactor(paddleocr-js): convert Layer 2 modules to TypeScript Converts models/det, models/rec, models/index, resources/tar, resources/cache, resources/registry, resources/standard-model, resources/index, platform/browser, and platform/worker from .js to .ts with interfaces for all model configs, results, and platform types. Made-with: Cursor * refactor(paddleocr-js): convert Layer 3-4 modules to TypeScript Converts worker/client, worker/entry, pipelines/ocr/config, pipelines/ocr/shared, pipelines/ocr/core, pipelines/ocr/worker-backed, and pipelines/ocr/worker-entry from .js to .ts with full type annotations for pipeline options, results, and initialization state. Made-with: Cursor * refactor(paddleocr-js): convert Layer 5 modules to TypeScript and add types/index.ts Converts pipelines/ocr/index, pipelines/index, and src/index from .js to .ts. Creates src/types/index.ts re-exporting all public-facing types. Fixes all TypeScript errors (strict mode + verbatimModuleSyntax clean). Made-with: Cursor * refactor(paddleocr-js): convert test files to TypeScript - Renamed all 29 test files from .js to .ts - Added type annotations to test helpers and mocks - Fixed barrel import in core.ts to maintain mock interceptability - Restored createWorker: null in resolveWorkerOptions for API contract - Updated public-api test to import from source directly All 154 tests pass. Made-with: Cursor * fix(paddleocr-js): fix Vite build worker format and demo alias - Add worker.format: 'es' to core vite config (fixes UMD build conflict) - Add resolve alias in demo vite config to resolve paddleocr-js to source Made-with: Cursor * fix(paddleocr-js): resolve all ESLint strict type-checked errors - Remove unnecessary optional chains, type assertions, and type conversions - Remove unused type imports - Fix floating promises, non-Error throws, and catch variable types - Widen SourceToMatFn to accept sync or async returns - Update tests to match sync dispose() and sourcePayloadToMat() 96 lint errors -> 0. All 154 tests pass. Made-with: Cursor * Update docs * Remove AI docs * Update node version bound * Polish typing * Fix bugs * Fix doc * Rename paddleocr-js to @paddleocr/paddleocr-js * FIx CI * Fix CI bug * Fix git workflow * Add viz utility design spec for paddleocr-js Design document for an optional visualization module exported via @paddleocr/paddleocr-js/viz subpath. Renders side-by-side composite images (source + detection boxes | white panel + recognized text) with custom font support and Blob export for browser download. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs(viz): add implementation plan for viz utility 11-task TDD plan covering types, color generation, canvas factory, font management, box drawing, text drawing, side-by-side assembly, OcrVisualizer class, subpath entry, build config, and final check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(viz): add foundational types for viz utility Define RgbColor, FontConfig, BoxStyleOptions, and OcrVisualizerOptions interfaces that will be shared across all viz module files. Include type-level test coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(viz): add deterministic color generation via LCG Extract the Linear Congruential Generator color function from the demo app into the core viz utility so all consumers produce visually consistent box colors for the same detection index. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add canvas factory abstraction for viz module Provides createCanvas, getContext2D, and canvasToBlob that abstract over OffscreenCanvas vs HTMLCanvasElement differences, enabling the viz module to work in both main-thread and web worker contexts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add font management utilities for viz (Task 4) Implement loadFontFace/removeFontFace wrappers around the browser FontFace API, with full test coverage using jsdom mocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add draw-boxes panel for viz module (Task 5) Draws the left panel of the side-by-side OCR visualization: source image overlaid with colored detection box polygons. Uses save/restore for clean state management and supports custom color functions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(viz): add right-panel text drawing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(viz): add side-by-side composite assembly Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(viz): add OcrVisualizer class and renderOcrToBlob Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(viz): add subpath entry point and public exports Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * build(viz): add viz subpath entry to Vite build and package.json exports Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore(viz): fix lint and formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(viz): update demo app and docs for viz module - Replace demo's local deterministicColor with viz module import - Add "Download Result" button to demo using OcrVisualizer.toBlob() - Document viz subpath in README.md and README_cn.md - Add viz to Package Layout and API sections Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: improve viz module, core SDK internals, and test coverage - Refine draw-boxes rendering and font loading in viz module - Improve type exports and internal module organization across models, pipelines, resources, runtime, platform, and worker layers - Update test suite for cache, models, pipeline, runtime, worker-backed, and worker-client modules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: fix documentation accuracy across 6 files and add changeset - Move visualization section before API reference in SDK READMEs (EN/CN) - Add deterministicColor usage description to viz docs - Add src/viz, src/types, src/utils to package layout sections - Fix ESLint rule level: test files use recommendedTypeChecked - Remove non-existent index.umd.js; add viz.mjs/viz.cjs to build outputs - Correct worker WASM inflation size from ~78 MB to ~50 MB - Add changeset for 0.2.0 minor release Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: release @paddleocr/paddleocr-js v0.2.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add paths mapping to tsconfig.eslint.json and demo tsconfig Add @paddleocr/paddleocr-js and @paddleocr/paddleocr-js/viz paths to tsconfig.eslint.json so IDE ESLint can resolve SDK types without depending on workspace symlinks. Also add the viz subpath mapping to apps/demo/tsconfig.json. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add viz subpath alias to demo Vite dev config Vite resolve.alias needs an explicit entry for the viz subpath — tsconfig paths only affect TypeScript, not Vite's module resolution. The more specific path is listed first to avoid prefix matching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(demo): replace canvas rendering with viz module side-by-side output Use OcrVisualizer.toBlob() to render detection boxes and recognized text as a composite image displayed via <img>, replacing the manual canvas drawing and removing the Download Result button. Configure PingFang SC font from CDN for proper CJK text rendering in visualizations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix bugs * Remove superpowers docs * Fix bugs * Fix bug * Refactor * Fix bugs * refactor: move cropByPoly from models/det to pipelines/ocr/crop Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: unify DetModel interface to predict(cv, mats, overrides) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: unify RecModel interface to predict(cv, mats, overrides) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: restructure getOcrRuntimeParams return into { det, rec, pipeline } Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: simplify OcrPipelineRunner.predict to pure orchestration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Refactor * Fix code style * Fix and update * Fix and update * Bump to 0.3.0 * Remove v6 * Bump to v0.3.1 * Fix default paramter * variant -> preset * Add to mkdocs * Update docs and add license headers * Remove unused --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1.3 KiB
1.3 KiB
PaddleOCR.js
English | 简体中文
PaddleOCR 官方浏览器 OCR SDK 与演示应用。
项目结构
| 路径 | 作用 |
|---|---|
packages/core/ |
浏览器 SDK 源码;发布到 npm 时的包名为 @paddleocr/paddleocr-js |
apps/demo/ |
依赖该 SDK 的 Vite 演示应用 |
本地开发与演示
npm install
npm run dev:demo
其他常用命令:
npm run build
npm run test
npm run typecheck
npm run check
按 workspace 作用域:
npm run build --workspace packages/core
npm run build --workspace apps/demo
文档
| 说明 | 链接 |
|---|---|
| 架构说明 | architecture_cn.md |
| 开发指南 | development_cn.md |
| Monorepo 约定 | monorepo_cn.md |
| SDK 包 README | packages/core/README_cn.md |
致谢
- ONNX Runtime Web:提供浏览器端 ONNX 推理能力
- OpenCV.js:提供浏览器端图像处理能力