Commit 1fc8b98
[Feat] PaddleOCR.js (#17861)
* 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 parent 26d00a7 commit 1fc8b98
110 files changed
Lines changed: 17335 additions & 15 deletions
File tree
- .github/workflows
- docs/version3.x/deployment
- paddleocr-js
- apps/demo
- src
- docs
- packages/core
- src
- models
- pipelines
- ocr
- platform
- resources
- runtime
- types
- utils
- viz
- ocr
- worker
- test
- helpers
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
37 | 56 | | |
38 | 57 | | |
39 | 58 | | |
40 | 59 | | |
41 | | - | |
| 60 | + | |
42 | 61 | | |
43 | 62 | | |
44 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
0 commit comments