From 51a6fb65f0df3409eacffb297430840a0e326989 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Mon, 24 Jun 2024 23:33:31 +0700 Subject: [PATCH] fix(apis/websocket): don't bundle `tesseract.js` --- apis/websocket/after_build.ts | 3 --- apis/websocket/docs/2_running.md | 13 +++++++++++-- apis/websocket/package.json | 2 +- package.json | 5 +---- patches/tesseract.js@5.1.0.patch | 19 ------------------- 5 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 apis/websocket/after_build.ts delete mode 100644 patches/tesseract.js@5.1.0.patch diff --git a/apis/websocket/after_build.ts b/apis/websocket/after_build.ts deleted file mode 100644 index d7c41f7..0000000 --- a/apis/websocket/after_build.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as fs from 'fs' - -fs.cpSync('../../node_modules/tesseract.js', './dist/tesseract.js', { recursive: true }) diff --git a/apis/websocket/docs/2_running.md b/apis/websocket/docs/2_running.md index d96f449..5d3b99a 100644 --- a/apis/websocket/docs/2_running.md +++ b/apis/websocket/docs/2_running.md @@ -35,8 +35,17 @@ If you're looking to build and host the server somewhere else, you can run: bun bundle ``` -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`. +The files will be placed in the `dist` directory. **Configurations and `.env` files will NOT be copied automatically.** + +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 diff --git a/apis/websocket/package.json b/apis/websocket/package.json index c9fd4d2..5257e09 100755 --- a/apis/websocket/package.json +++ b/apis/websocket/package.json @@ -6,7 +6,7 @@ "description": "🧦 WebSocket API server for bots assisting ReVanced", "main": "dist/index.js", "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", "build": "bun bundle", "watch": "bun dev" diff --git a/package.json b/package.json index 906f196..99d2a3c 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,5 @@ "turbo": "^1.13.4", "typescript": "^5.5.2" }, - "trustedDependencies": ["@biomejs/biome", "esbuild", "lefthook", "tesseract.js"], - "patchedDependencies": { - "tesseract.js@5.1.0": "patches/tesseract.js@5.1.0.patch" - } + "trustedDependencies": ["@biomejs/biome", "esbuild", "lefthook"] } diff --git a/patches/tesseract.js@5.1.0.patch b/patches/tesseract.js@5.1.0.patch deleted file mode 100644 index 93ecfc3..0000000 --- a/patches/tesseract.js@5.1.0.patch +++ /dev/null @@ -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'), - };