Skip to content

[Feat] PaddleOCR.js#17861

Merged
Bobholamovic merged 78 commits into
PaddlePaddle:mainfrom
Bobholamovic:feat/paddleocr-js-subproject
Apr 20, 2026
Merged

[Feat] PaddleOCR.js#17861
Bobholamovic merged 78 commits into
PaddlePaddle:mainfrom
Bobholamovic:feat/paddleocr-js-subproject

Conversation

@Bobholamovic
Copy link
Copy Markdown
Member

No description provided.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Mar 26, 2026

Thanks for your contribution!

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
…-lib and opencv

Minimal .d.ts files covering only the APIs actually used by the project.

Made-with: Cursor
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
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
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
… 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
- 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
- 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
- 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
@@ -0,0 +1,80 @@
# Architecture
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这三个文档建议还是补充一个中文文档吧?另外总文档看是否要链一下这三个文档?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,这三个文档和项目代码结构强相关,放在mkdocs里会有些抽象,且mkdocs文档用户通常主要关心用法而不是子项目结构设计/二次开发,考虑作为子项目内部文档,在子项目的readme里保留链接。

@@ -0,0 +1,255 @@
import yaml from "js-yaml";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ts建议整体加一下版权信息?避免一些后续可能引发的问题

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread paddleocr-js/packages/core/README_cn.md Outdated
});
```

**自定义模型** — 资源描述:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自定义模型应满足的格式说明下?这里是否需要提供一个什么check机制,check通过后才可以使用。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

补充了说明,包括格式要求、内置check机制的反馈、以及得到标准模型格式的推荐办法(通过paddle2onnx)。

Comment thread docs/version3.x/deployment/browser.md Outdated

# 浏览器端部署

PaddleOCR 提供浏览器端推理 SDK PaddleOCR.js。开发者可以将 OCR 功能嵌入到浏览器中,实现离线推理。详情请参考 [PaddleOCR.js](https://github.com/PaddlePaddle/PaddleOCR/blob/main/paddleocr-js)。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paddleocr-js/以及paddleocr-js/packages/core/中的README还是建议可以直接在站点文档中显示,要不然可能会比较割裂。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,提供了一份适合在mkdocs站点阅读的文档

@Bobholamovic Bobholamovic merged commit 1fc8b98 into PaddlePaddle:main Apr 20, 2026
6 checks passed
@Bobholamovic Bobholamovic deleted the feat/paddleocr-js-subproject branch April 20, 2026 13:53
scyyh11 added a commit to scyyh11/PaddleOCR that referenced this pull request Apr 21, 2026
dorny/paths-filter defaults to the "some" predicate-quantifier, so
docs_only became true whenever any single file matched the patterns,
causing test-pr to be skipped on PRs that touched both a doc-like file
(any .yml/.md/.txt or an ignored subdir) and real code (e.g.
pyproject.toml). Switch to predicate-quantifier: every so the filter
only matches when all changed files are skippable, aligning with the
bash logic PaddlePaddle#17861 introduced for test_gpu.yml.

Signed-off-by: Bvicii <yizhanhuang2002@gmail.com>
scyyh11 added a commit to scyyh11/PaddleOCR that referenced this pull request Apr 21, 2026
dorny/paths-filter defaults to the "some" predicate-quantifier, so
docs_only became true whenever any single file matched the patterns,
causing test-pr to be skipped on PRs that touched both a doc-like file
(any .yml/.md/.txt or an ignored subdir) and real code (e.g.
pyproject.toml). Switch to predicate-quantifier: every so the filter
only matches when all changed files are skippable, aligning with the
bash logic PaddlePaddle#17861 introduced for test_gpu.yml.

Signed-off-by: Bvicii <yizhanhuang2002@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants