Skip to content

Commit

Permalink
Merge pull request #39 from robertknight/typedoc
Browse files Browse the repository at this point in the history
Ensure all types used in public APIs are exported, add command to build API docs
  • Loading branch information
robertknight authored Jun 5, 2022
2 parents a08611e + c12d777 commit c88665f
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 13 deletions.
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
Loading

0 comments on commit c88665f

Please sign in to comment.