@hazae41/bobine 0.0.13 → 0.0.18

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/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  A blockchain in your garage
4
4
 
5
- https://bobine.tech/
5
+ ```bash
6
+ npm install -g @hazae41/bobine
7
+ ```
6
8
 
7
- [**📦 NPM**](https://www.npmjs.com/package/@hazae41/bobine) • [**📦 JSR**](https://jsr.io/@hazae41/bobine)
9
+ [**🌐 Website**](https://bobine.tech/) • [**📦 NPM**](https://www.npmjs.com/package/@hazae41/bobine)
8
10
 
9
11
  ## Features
10
12
 
@@ -24,7 +26,7 @@ https://bobine.tech/
24
26
  Install the binary with Deno
25
27
 
26
28
  ```bash
27
- deno install -gf -A jsr:@hazae41/bobine
29
+ deno install -gf -A npm:@hazae41/bobine
28
30
  ```
29
31
 
30
32
  Generate an Ed25519 keypair by running the following code in your browser/deno/node/bun console
@@ -1,3 +1,4 @@
1
+ /// <reference lib="webworker" />
1
2
  import { RpcMethodNotFoundError } from "@hazae41/jsonrpc";
2
3
  import { connect } from "@tursodatabase/database";
3
4
  import { runAsImmediateOrThrow } from "../../libs/sql/mod.js";
@@ -1,3 +1,4 @@
1
+ /// <reference lib="deno.ns" />
1
2
  import { readFileSync } from "node:fs";
2
3
  import process from "node:process";
3
4
  import { serveWithEnv } from "./mod.js";
@@ -1,4 +1,5 @@
1
1
  // deno-lint-ignore-file no-explicit-any no-unused-vars ban-unused-ignore
2
+ /// <reference lib="webworker" />
2
3
  import { Readable, Writable } from "@hazae41/binary";
3
4
  import { RpcErr, RpcError, RpcMethodNotFoundError, RpcOk } from "@hazae41/jsonrpc";
4
5
  import * as Wasm from "@hazae41/wasm";
@@ -68,7 +69,7 @@ function run(module, method, params, mode, maxsparks) {
68
69
  throw new Error("Aborted");
69
70
  },
70
71
  uuid: () => {
71
- return Uint8Array.fromHex("8a8f19d1de0e4fcd9ab15cd7ed5de6dd");
72
+ return "17fa1cb5-c5af-4cfd-9bea-1a36590b890d";
72
73
  }
73
74
  };
74
75
  imports["sparks"] = {
@@ -116,15 +117,21 @@ function run(module, method, params, mode, maxsparks) {
116
117
  from_base16: (text) => {
117
118
  return Uint8Array.fromHex(text);
118
119
  },
119
- to_base16: (bytes) => {
120
- return bytes.toHex();
120
+ to_base16: (blob) => {
121
+ return blob.toHex();
121
122
  },
122
123
  from_base64: (text) => {
123
124
  return Uint8Array.fromBase64(text);
124
125
  },
125
- to_base64: (bytes) => {
126
- return bytes.toBase64();
126
+ to_base64: (blob) => {
127
+ return blob.toBase64();
127
128
  },
129
+ encode: (value) => {
130
+ return pack_encode(value);
131
+ },
132
+ decode: (blob) => {
133
+ return pack_decode(blob);
134
+ }
128
135
  };
129
136
  imports["texts"] = {
130
137
  length: (text) => {
@@ -247,6 +254,19 @@ function run(module, method, params, mode, maxsparks) {
247
254
  }
248
255
  };
249
256
  imports["modules"] = {
257
+ self: () => {
258
+ return module;
259
+ },
260
+ load: (module) => {
261
+ return readFileSync(`${config.scripts.path}/${module}.wasm`);
262
+ },
263
+ call: (module, method, params) => {
264
+ if (exports[module] == null)
265
+ load(module);
266
+ if (typeof exports[module][method] !== "function")
267
+ throw new Error("Not found");
268
+ return exports[module][method](...params);
269
+ },
250
270
  create: (wasmAsBytes, saltAsBytes) => {
251
271
  const packAsBytes = pack_encode([wasmAsBytes, saltAsBytes]);
252
272
  const digestOfWasmAsBytes = sha256_digest(wasmAsBytes);
@@ -257,22 +277,7 @@ function run(module, method, params, mode, maxsparks) {
257
277
  writeFileSync(`${config.scripts.path}/${digestOfWasmAsHex}.wasm`, wasmAsBytes);
258
278
  if (!existsSync(`${config.scripts.path}/${digestOfPackAsHex}.wasm`))
259
279
  symlinkSync(`./${digestOfWasmAsHex}.wasm`, `${config.scripts.path}/${digestOfPackAsHex}.wasm`, "file");
260
- return digestOfPackAsBytes;
261
- },
262
- call: (moduleAsBytes, methodAsBytes, paramsAsPack) => {
263
- const moduleAsString = moduleAsBytes.toHex();
264
- const methodAsString = new TextDecoder().decode(methodAsBytes);
265
- if (exports[moduleAsString] == null)
266
- load(moduleAsString);
267
- if (typeof exports[moduleAsString][methodAsString] !== "function")
268
- throw new Error("Not found");
269
- return exports[moduleAsString][methodAsString](...paramsAsPack);
270
- },
271
- load: (moduleAsBytes) => {
272
- return readFileSync(`${config.scripts.path}/${moduleAsBytes.toHex()}.wasm`);
273
- },
274
- self: () => {
275
- return Uint8Array.fromHex(module);
280
+ return digestOfPackAsHex;
276
281
  }
277
282
  };
278
283
  imports["storage"] = {
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@hazae41/bobine",
4
- "version": "0.0.13",
4
+ "version": "0.0.18",
5
5
  "description": "A blockchain in your garage",
6
6
  "repository": "github:hazae41/bobine",
7
7
  "author": "hazae41",
8
8
  "license": "MIT",
9
9
  "scripts": {
10
10
  "examine": "deno lint ./src && deno check ./src && deno test -R ./src",
11
- "version": "deno -RW ./x.vsync.ts && git add deno.json",
12
- "prepare": "deno -RW ./x.dsync.ts && deno install",
13
11
  "prepack": "rm -rf ./out && tsc && tscousin",
14
- "produce": "deno run -A ./src/mod.ts serve --env=./.env.local",
15
- "develop": "deno run -A ./src/mod.ts serve --env=./.env.local --dev"
12
+ "produce": "deno run -A --sloppy-imports ./src/mod.ts serve --env=./.env.local",
13
+ "develop": "deno run -A --sloppy-imports ./src/mod.ts serve --env=./.env.local --dev"
16
14
  },
17
15
  "files": [
18
16
  "./out"