@linebridge/engine-neo 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/install.mjs ADDED
@@ -0,0 +1,73 @@
1
+ import fs from "fs"
2
+ import path from "path"
3
+ import os from "os"
4
+ import https from "https"
5
+ import { fileURLToPath } from "url"
6
+
7
+ const __filename = fileURLToPath(import.meta.url)
8
+ const __dirname = path.dirname(__filename)
9
+
10
+ const platform = os.platform()
11
+ const arch = os.arch()
12
+ const pkgJson = JSON.parse(
13
+ fs.readFileSync(path.join(__dirname, "package.json"), "utf8"),
14
+ )
15
+
16
+ const REPO = "ragestudio/linebridge"
17
+ const VERSION = process.env.npm_package_version || pkgJson.version
18
+
19
+ const BIN_NAME = `uws-wrapper-${platform}-${arch}.node`
20
+ const DOWNLOAD_URL = `https://github.com/${REPO}/releases/download/engine-neo-v${VERSION}/${BIN_NAME}`
21
+ const DEST_FILE = path.join(__dirname, "uws-wrapper.node")
22
+
23
+ function downloadBinary(url, dest) {
24
+ return new Promise((resolve, reject) => {
25
+ console.log(`Downloading binary [${url}]`)
26
+ https
27
+ .get(url, (res) => {
28
+ if (res.statusCode === 302 || res.statusCode === 301) {
29
+ return downloadBinary(res.headers.location, dest)
30
+ .then(resolve)
31
+ .catch(reject)
32
+ }
33
+ if (res.statusCode !== 200) {
34
+ return reject(new Error(`status code: ${res.statusCode}`))
35
+ }
36
+
37
+ fs.mkdirSync(path.dirname(dest), { recursive: true })
38
+ const file = fs.createWriteStream(dest)
39
+ res.pipe(file)
40
+
41
+ file.on("finish", () => {
42
+ file.close()
43
+ resolve()
44
+ })
45
+ file.on("error", (err) => {
46
+ fs.unlink(dest, () => reject(err))
47
+ })
48
+ })
49
+ .on("error", reject)
50
+ })
51
+ }
52
+
53
+ async function main() {
54
+ if (
55
+ fs.existsSync(path.join(__dirname), ".experimental") &&
56
+ !process.argv.includes("--force")
57
+ )
58
+ return
59
+
60
+ try {
61
+ console.log("Downloading engine binary...", {
62
+ url: DOWNLOAD_URL,
63
+ dest: DEST_FILE,
64
+ })
65
+ await downloadBinary(DOWNLOAD_URL, DEST_FILE)
66
+ console.log("Successfully downloaded pre-built binary.")
67
+ process.exit(0)
68
+ } catch (err) {
69
+ console.error("❌ Failed to download engine binary:", err.message)
70
+ }
71
+ }
72
+
73
+ main()
package/lib/engine.d.ts CHANGED
@@ -89,7 +89,7 @@ export declare class NeoEngine extends EngineAdaptor {
89
89
  */
90
90
  num_of_subscribers(topic: UWS.RecognizedString): number | undefined;
91
91
  /** Incoming HTTP request handler. Bound to the engine instance. */
92
- on_request: (native_req: import("uWebSockets.js").HttpRequest, native_res: import("uWebSockets.js").HttpResponse, route: Route<any, "server"[]>, socket?: import("uWebSockets.js").us_socket_context_t | null | undefined) => any;
92
+ on_request: (native_req: HttpRequest, native_res: HttpResponse, route: Route<any, "server"[]>, socket?: any) => any;
93
93
  /** Middleware/route iteration loop. Bound to the engine instance. */
94
94
  request_iterator: (request: Request<any>, response: Response<any>, route: Route<Server<"neo">, "server"[]>, allMiddlewares: Handler<HandlerKind>[], cursor?: number | undefined) => Promise<void>;
95
95
  /**
package/lib/request.d.ts CHANGED
@@ -98,11 +98,11 @@ export default class Request<TServer = Server<any>> implements BaseHttpRequest {
98
98
  /**
99
99
  * Signs a string with a secret using the same algorithm as `cookie-signature`.
100
100
  */
101
- sign(string: string, secret: string): string;
101
+ sign(string: string, secret: string): any;
102
102
  /**
103
103
  * Unsigns a signed value. Returns the original string or `undefined` on failure.
104
104
  */
105
- unsign(signed_value: string, secret: string): string | undefined;
105
+ unsign(signed_value: string, secret: string): any;
106
106
  /**
107
107
  * Starts the body parser by registering a uWS `onData` callback.
108
108
  *
package/lib/utils.d.ts CHANGED
@@ -10,5 +10,5 @@ declare function wrap_object(original: any, target: any): void;
10
10
  * @param {BufferEncoding} encoding
11
11
  * @returns {String} String
12
12
  */
13
- declare function array_buffer_to_string(array_buffer: ArrayBuffer, encoding?: BufferEncoding): string;
13
+ declare function array_buffer_to_string(array_buffer: ArrayBuffer, encoding?: BufferEncoding): any;
14
14
  export { array_buffer_to_string, wrap_object };
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@linebridge/engine-neo",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "author": "ragestudio",
8
8
  "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ragestudio/linebridge.git",
12
+ "directory": "engines/neo"
13
+ },
9
14
  "type": "module",
10
15
  "main": "./lib/index.js",
11
16
  "types": "./lib/index.d.ts",
@@ -28,5 +33,8 @@
28
33
  "fast-querystring": "^1.1.2",
29
34
  "mime-types": "^3.0.2",
30
35
  "tseep": "^1.3.1"
36
+ },
37
+ "scripts": {
38
+ "install": "node install.mjs"
31
39
  }
32
40
  }
package/uws-wrapper.node DELETED
Binary file