diff --git a/.vscode/settings.json b/.vscode/settings.json index d1b4edb..f35ac99 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,8 @@ { "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode" -} \ No newline at end of file + "editor.defaultFormatter": "biomejs.biome", + "editor.codeActionsOnSave": { + "source.organizeImports.biome": "explicit", + "quickfix.biome": "explicit" + } +} diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 0000000..8a62a1d --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,18 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.7.2/schema.json", + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "semicolons": "asNeeded" + } + } +} \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index ea3c2b4..751f510 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/examples/react-native/ake b/examples/react-native/ake index 5a19021..de47e35 100644 --- a/examples/react-native/ake +++ b/examples/react-native/ake @@ -2,6 +2,10 @@ def main [] {} -def 'main build react-native' [] { +def 'main build' [] { chokidar '../../src/**/*.ts' build.ts -c 'bun run build.ts' --initial -} \ No newline at end of file +} + +def 'main start' [] } + +} diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json index 42d1e28..13a7f39 100644 --- a/packages/common/tsconfig.json +++ b/packages/common/tsconfig.json @@ -6,9 +6,6 @@ "#root/*": ["./*"] }, - "moduleSuffixes": [".browser", ""], - - // Enable latest features "lib": ["ESNext", "DOM"], "target": "ESNext", "module": "ESNext", diff --git a/packages/react-native/ake b/packages/react-native/ake new file mode 120000 index 0000000..128c252 --- /dev/null +++ b/packages/react-native/ake @@ -0,0 +1 @@ +../common/ake \ No newline at end of file diff --git a/packages/react-native/package.json b/packages/react-native/package.json new file mode 100644 index 0000000..967640e --- /dev/null +++ b/packages/react-native/package.json @@ -0,0 +1,29 @@ +{ + "name": "@gutenye/ocr-react-native", + "description": "High accurate text detection (OCR) Javascript/Typescript library that runs on Node.js, Browser, and React Native. Based on PaddleOCR and ONNX runtime", + "version": "1.2.1", + "type": "module", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/gutenye/ocr.git", + "directory": "packages/react-native" + }, + "exports": { + "react-native": "./src/index.ts", + "default": "./build/index.js" + }, + "files": [ + "src", + "build", + "tsconfig.json", + "!**/__tests__" + ], + "scripts": { + "prepublishOnly": "./ake build" + }, + "dependencies": { + "@gutenye/ocr-common": "^1.2.0", + "onnxruntime-react-native": "^1.17.3" + } +} diff --git a/packages/react-native/src/FileUtils.ts b/packages/react-native/src/FileUtils.ts new file mode 100644 index 0000000..7c0c336 --- /dev/null +++ b/packages/react-native/src/FileUtils.ts @@ -0,0 +1,5 @@ +import { FileUtilsBase } from '@gutenye/ocr-common' + +export class FileUtils extends FileUtilsBase { + static async read(path: string) {} +} diff --git a/packages/react-native/src/ImageRaw.ts b/packages/react-native/src/ImageRaw.ts new file mode 100644 index 0000000..29b3ef6 --- /dev/null +++ b/packages/react-native/src/ImageRaw.ts @@ -0,0 +1,18 @@ +import { ImageRawBase } from '@gutenye/ocr-common' +import type { ImageRawData, SizeOption, LineImage } from '@gutenye/ocr-common' + +export class ImageRaw extends ImageRawBase { + static async open(path: string): Promise {} + + constructor(imageRawData: ImageRawData) { + super(imageRawData) + } + + async write(path: string) {} + + async resize(size: SizeOption) {} + + async drawBox(lineImages: LineImage[]) {} + + async #apply(sharp: sharp.Sharp) {} +} diff --git a/packages/react-native/src/index.ts b/packages/react-native/src/index.ts new file mode 100644 index 0000000..50a54b1 --- /dev/null +++ b/packages/react-native/src/index.ts @@ -0,0 +1,9 @@ +import Ocr, { registerBackend } from '@gutenye/ocr-common' +import { FileUtils } from './FileUtils' +import { ImageRaw } from './ImageRaw' +import { InferenceSession } from 'onnxruntime-react-native' + +registerBackend({ FileUtils, ImageRaw, InferenceSession }) + +export * from '@gutenye/ocr-common' +export default Ocr diff --git a/packages/react-native/tsconfig.build.json b/packages/react-native/tsconfig.build.json new file mode 120000 index 0000000..7e3d8da --- /dev/null +++ b/packages/react-native/tsconfig.build.json @@ -0,0 +1 @@ +../common/tsconfig.build.json \ No newline at end of file diff --git a/packages/react-native/tsconfig.json b/packages/react-native/tsconfig.json new file mode 120000 index 0000000..e37858d --- /dev/null +++ b/packages/react-native/tsconfig.json @@ -0,0 +1 @@ +../common/tsconfig.json \ No newline at end of file