@hazae41/turbine 0.1.4 → 0.1.6

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.
@@ -32,7 +32,6 @@ export async function main(args) {
32
32
  console.log("Starting...");
33
33
  const worker = await RpcWorkerClient.spawn(uuid, path);
34
34
  const server = new Server(worker);
35
- await server.setup();
36
35
  Deno.serve({ hostname: "0.0.0.0", port }, (request) => server.respond(request));
37
36
  }
38
37
  if (import.meta.main) {
@@ -9,7 +9,6 @@ export declare class Server {
9
9
  readonly worker: RpcWorkerClient;
10
10
  readonly subserver: RpcServer;
11
11
  constructor(worker: RpcWorkerClient);
12
- setup(): Promise<void>;
13
12
  respond(request: Request): Promise<any>;
14
13
  }
15
14
  /**
@@ -21,6 +20,5 @@ export declare class RpcServer {
21
20
  readonly seens: Set<string>;
22
21
  readonly mutex: Mutex<undefined>;
23
22
  constructor(worker: RpcWorkerClient);
24
- setup(): Promise<void>;
25
23
  respond(request: RpcRequestInit): Promise<RpcErr | RpcOk<string>>;
26
24
  }
@@ -53,6 +53,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
53
53
  import { RpcPaymentError } from "@hazae41/bobine";
54
54
  import { RpcErr, RpcError, RpcInvalidParamsError, RpcMethodNotFoundError, RpcOk } from "@hazae41/jsonrpc";
55
55
  import { Mutex } from "@hazae41/mutex";
56
+ import { Packed } from "@hazae41/webpack";
56
57
  /**
57
58
  * Translates HTTP or WebSocket into JSON-RPC
58
59
  */
@@ -63,9 +64,6 @@ export class Server {
63
64
  this.worker = worker;
64
65
  this.subserver = new RpcServer(worker);
65
66
  }
66
- async setup() {
67
- await this.subserver.setup();
68
- }
69
67
  async respond(request) {
70
68
  const response = await this.#route(request);
71
69
  response.headers.set("Access-Control-Allow-Origin", "*");
@@ -102,9 +100,6 @@ export class RpcServer {
102
100
  constructor(worker) {
103
101
  this.worker = worker;
104
102
  }
105
- async setup() {
106
- await this.worker.setup();
107
- }
108
103
  async respond(request) {
109
104
  try {
110
105
  return new RpcOk(request.id, await this.#route(request));
@@ -170,7 +165,7 @@ export class RpcServer {
170
165
  const proven = new Uint8Array(await crypto.subtle.digest("SHA-256", effort));
171
166
  const target = (2n ** 256n) / BigInt("0x" + proven.toHex());
172
167
  const result = await this.worker.execute(module, method, params, target);
173
- return result.toHex();
168
+ return Packed.encode(result).toHex();
174
169
  }
175
170
  catch (e_2) {
176
171
  env_2.error = e_2;
@@ -203,7 +198,7 @@ export class RpcServer {
203
198
  const proven = new Uint8Array(await crypto.subtle.digest("SHA-256", effort));
204
199
  const target = (2n ** 256n) / BigInt("0x" + proven.toHex());
205
200
  const result = await this.worker.simulate(module, method, params, target);
206
- return result.toHex();
201
+ return Packed.encode(result).toHex();
207
202
  }
208
203
  catch (e_3) {
209
204
  env_3.error = e_3;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@hazae41/turbine",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "description": "Bobine over HTTP and WebSocket",
6
6
  "repository": "github:hazae41/turbine",
7
7
  "author": "hazae41",
@@ -22,14 +22,16 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@hazae41/bobine": "^0.1.2",
25
+ "@hazae41/binary": "^2.1.1",
26
+ "@hazae41/bobine": "^0.1.7",
26
27
  "@hazae41/jsonrpc": "^1.2.1",
27
- "@hazae41/mutex": "^3.0.1"
28
+ "@hazae41/mutex": "^3.0.1",
29
+ "@hazae41/webpack": "^1.0.1"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@hazae41/phobos": "^2.0.16",
31
33
  "@hazae41/tscousin": "^1.0.28",
32
- "@types/node": "^26.6.6",
34
+ "@types/node": "^26.6.11",
33
35
  "typescript": "^7.0.2"
34
36
  },
35
37
  "keywords": [