fix(apis/websocket): don't bundle tesseract.js

This commit is contained in:
PalmDevs
2024-06-24 23:33:31 +07:00
parent 3b2596e748
commit 51a6fb65f0
5 changed files with 13 additions and 29 deletions

View File

@@ -1,3 +0,0 @@
import * as fs from 'fs'
fs.cpSync('../../node_modules/tesseract.js', './dist/tesseract.js', { recursive: true })

View File

@@ -35,8 +35,17 @@ If you're looking to build and host the server somewhere else, you can run:
bun bundle bun bundle
``` ```
The files will be placed in the `dist` directory. **Configurations and `.env` files will NOT be copied automatically.** The files will be placed in the `dist` directory. **Configurations and `.env` files will NOT be copied automatically.**
You can run these files using the command `bun run index.js`.
To start up the server, you'll need to install `tesseract.js` first.
```sh
bun install tesseract.js
# or
bun install tesseract.js -g
# Run the server
bun run index.js
```
## ⏭️ What's next ## ⏭️ What's next

View File

@@ -6,7 +6,7 @@
"description": "🧦 WebSocket API server for bots assisting ReVanced", "description": "🧦 WebSocket API server for bots assisting ReVanced",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"bundle": "bun build src/index.ts --outdir=dist --target=bun && bun run after_build.ts", "bundle": "bun build src/index.ts --outdir=dist --target=bun -e tesseract.js",
"dev": "bun run src/index.ts --watch", "dev": "bun run src/index.ts --watch",
"build": "bun bundle", "build": "bun bundle",
"watch": "bun dev" "watch": "bun dev"

View File

@@ -41,8 +41,5 @@
"turbo": "^1.13.4", "turbo": "^1.13.4",
"typescript": "^5.5.2" "typescript": "^5.5.2"
}, },
"trustedDependencies": ["@biomejs/biome", "esbuild", "lefthook", "tesseract.js"], "trustedDependencies": ["@biomejs/biome", "esbuild", "lefthook"]
"patchedDependencies": {
"tesseract.js@5.1.0": "patches/tesseract.js@5.1.0.patch"
}
} }

View File

@@ -1,19 +0,0 @@
diff --git a/src/worker/node/defaultOptions.js b/src/worker/node/defaultOptions.js
index 053c1e3e3b561b2e5b5e3609e9c6b509b1661f11..407242f5576f8d888644ab28ff169599a79bf4dd 100644
--- a/src/worker/node/defaultOptions.js
+++ b/src/worker/node/defaultOptions.js
@@ -1,10 +1,13 @@
const path = require('path');
+const fs = require('fs');
const defaultOptions = require('../../constants/defaultOptions');
+const defaultPath = path.join(import.meta.dir, '..', '..', 'worker-script', 'node', 'index.js')
+
/*
* Default options for node worker
*/
module.exports = {
...defaultOptions,
- workerPath: path.join(__dirname, '..', '..', 'worker-script', 'node', 'index.js'),
+ workerPath: fs.existsSync(defaultPath) ? defaultPath : path.join(import.meta.dir, 'tesseract.js', 'src', 'worker-script', 'node', 'index.js'),
};