Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all types used in public APIs are exported, add command to build API docs #39

Merged
merged 3 commits into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ checkformat:
typecheck:
node_modules/.bin/tsc

.PHONY: api-docs
api-docs:
node_modules/.bin/typedoc --excludePrivate --out docs/api/ src/index.ts

.PHONY: test
test: third_party/tessdata_fast
node_modules/.bin/mocha
Expand Down
197 changes: 197 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"prettier": "^2.6.2",
"rollup": "^2.73.0",
"sharp": "^0.30.4",
"typedoc": "^0.22.17",
"typescript": "^4.6.4"
},
"dependencies": {
Expand Down
15 changes: 14 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
export { OCRClient } from "./ocr-client";

export type { OCRClientInit } from "./ocr-client";

export { createOCREngine, layoutFlags, supportsFastBuild } from "./ocr-engine";
export type { BoxItem, Orientation, TextItem, TextUnit } from "./ocr-engine";

export type {
CreateOCREngineOptions,
BoxItem,
IntRect,
OCREngine,
Orientation,
ProgressListener,
TextItem,
TextUnit,
} from "./ocr-engine";
14 changes: 9 additions & 5 deletions src/ocr-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import * as comlink from "comlink";

import type { BoxItem, Orientation, TextItem, TextUnit } from "./ocr-engine";
import type {
BoxItem,
Orientation,
ProgressListener,
TextItem,
TextUnit,
} from "./ocr-engine";

// Although this import is Node-specific, it is tiny and doesn't import any
// Node libs, so can be included in a bundle that runs in non-Node environments.
Expand All @@ -18,8 +24,6 @@ function createWebWorker(url: string) {
return new Worker(url);
}

type ProgressListener = (progress: number) => void;

export type OCRClientInit = {
/**
* Callback that creates the worker. The default implementation creates a Web Worker.
Expand Down Expand Up @@ -213,11 +217,11 @@ export class OCRClient {
return engine.getOrientation();
}

_addProgressListener(listener: ProgressListener) {
private _addProgressListener(listener: ProgressListener) {
this._progressListeners.push(listener);
}

_removeProgressListener(listener: ProgressListener) {
private _removeProgressListener(listener: ProgressListener) {
this._progressListeners = this._progressListeners.filter(
(l) => l !== listener
);
Expand Down