wao 0.40.2 → 0.41.0

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.
Files changed (74) hide show
  1. package/cjs/accounts-web.js +25 -0
  2. package/cjs/accounts.js +38 -0
  3. package/cjs/adaptor-base.js +504 -287
  4. package/cjs/adaptor-cf.js +42 -0
  5. package/cjs/ao-loader.js +1 -1
  6. package/cjs/ao.js +18 -6
  7. package/cjs/aoconnect-base.js +1010 -546
  8. package/cjs/aoconnect-cf.js +24 -0
  9. package/cjs/ar-remote.js +277 -0
  10. package/cjs/armem-base.js +822 -211
  11. package/cjs/armem-cf.js +128 -0
  12. package/cjs/armem.js +11 -5
  13. package/cjs/bar.js +511 -173
  14. package/cjs/car.js +37 -0
  15. package/cjs/cf-env.js +54 -0
  16. package/cjs/cf.js +76 -0
  17. package/cjs/cli.js +12 -6
  18. package/cjs/create.js +1 -1
  19. package/cjs/devs.js +53 -0
  20. package/cjs/dodb.js +116 -0
  21. package/cjs/hb.js +136 -53
  22. package/cjs/hyperbeam.js +85 -44
  23. package/cjs/keygen.js +94 -0
  24. package/cjs/run.js +4 -1
  25. package/cjs/server.js +40 -9
  26. package/cjs/storage-multi.js +525 -0
  27. package/cjs/tgql-d1.js +664 -0
  28. package/cjs/tgql.js +293 -172
  29. package/cjs/workspace/.claude/agents/tester.md +2 -2
  30. package/cjs/workspace/.claude/skills/build/SKILL.md +2 -2
  31. package/cjs/workspace/.claude/skills/test/SKILL.md +3 -2
  32. package/cjs/workspace/CLAUDE.md +2 -2
  33. package/cjs/workspace/README.md +1 -1
  34. package/cjs/workspace/docs/debug.md +9 -4
  35. package/cjs/workspace/docs/hyperbeam-devices.md +50 -1
  36. package/cjs/workspace/package.json +3 -3
  37. package/esm/accounts-web.js +14 -0
  38. package/esm/accounts.js +27 -0
  39. package/esm/adaptor-base.js +129 -31
  40. package/esm/adaptor-cf.js +11 -0
  41. package/esm/ao-loader.js +1 -1
  42. package/esm/ao.js +21 -2
  43. package/esm/aoconnect-base.js +248 -7
  44. package/esm/aoconnect-cf.js +9 -0
  45. package/esm/ar-remote.js +87 -0
  46. package/esm/armem-base.js +304 -53
  47. package/esm/armem-cf.js +67 -0
  48. package/esm/armem.js +7 -2
  49. package/esm/bar.js +126 -16
  50. package/esm/car.js +10 -0
  51. package/esm/cf-env.js +29 -0
  52. package/esm/cf.js +11 -0
  53. package/esm/cli.js +6 -2
  54. package/esm/create.js +1 -1
  55. package/esm/devs.js +15 -0
  56. package/esm/dodb.js +26 -0
  57. package/esm/hb.js +93 -16
  58. package/esm/hyperbeam.js +68 -30
  59. package/esm/keygen.js +47 -0
  60. package/esm/run.js +4 -1
  61. package/esm/server.js +29 -9
  62. package/esm/storage-multi.js +183 -0
  63. package/esm/tgql-d1.js +407 -0
  64. package/esm/tgql.js +29 -10
  65. package/esm/workspace/.claude/agents/tester.md +2 -2
  66. package/esm/workspace/.claude/skills/build/SKILL.md +2 -2
  67. package/esm/workspace/.claude/skills/test/SKILL.md +3 -2
  68. package/esm/workspace/CLAUDE.md +2 -2
  69. package/esm/workspace/README.md +1 -1
  70. package/esm/workspace/docs/debug.md +9 -4
  71. package/esm/workspace/docs/hyperbeam-devices.md +50 -1
  72. package/esm/workspace/package.json +3 -3
  73. package/package.json +10 -3
  74. package/postinstall.cjs +84 -0
@@ -3,9 +3,9 @@
3
3
  "version": "0.0.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "test": "node --experimental-wasm-memory64 --test --test-concurrency=1",
7
- "test-only": "node --experimental-wasm-memory64 --test-only --test-concurrency=1",
8
- "test-all": "node --experimental-wasm-memory64 --test --test-concurrency=1 test/**/*.test.js",
6
+ "test": "node --test --test-concurrency=1",
7
+ "test-only": "node --test-only --test-concurrency=1",
8
+ "test-all": "node --test --test-concurrency=1 test/**/*.test.js",
9
9
  "start": "trap 'kill $(jobs -p)' EXIT; node dashboard/server.js & cd dashboard && npx vite",
10
10
  "start:api": "node dashboard/server.js",
11
11
  "keygen": "node scripts/keygen.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.40.2",
3
+ "version": "0.41.0",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"
@@ -25,6 +25,10 @@
25
25
  "require": "./cjs/web.js",
26
26
  "import": "./esm/web.js"
27
27
  },
28
+ "./cf": {
29
+ "require": "./cjs/cf.js",
30
+ "import": "./esm/cf.js"
31
+ },
28
32
  "./signer": {
29
33
  "require": "./cjs/signer.js",
30
34
  "import": "./esm/signer.js"
@@ -67,9 +71,12 @@
67
71
  "@babel/cli": "^7.24.8",
68
72
  "@babel/core": "^7.25.2",
69
73
  "@babel/plugin-transform-modules-commonjs": "^7.24.8",
70
- "@babel/preset-env": "^7.25.3"
74
+ "@babel/preset-env": "^7.25.3",
75
+ "patch-package": "^8.0.1",
76
+ "postinstall-postinstall": "^2.1.0"
71
77
  },
72
78
  "scripts": {
73
- "server": "node --experimental-wasm-memory64 cjs/run.js"
79
+ "server": "node cjs/run.js",
80
+ "postinstall": "node postinstall.cjs || true"
74
81
  }
75
82
  }
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ // Patch @permaweb/ao-loader@0.0.44 for Node 24+ wasm-memory64.
3
+ //
4
+ // patch-package can't reach ao-loader when it's hoisted out of
5
+ // node_modules/wao/node_modules/ (the default on modern npm). This script
6
+ // locates ao-loader via require.resolve and applies the same growMemory
7
+ // patch inline — idempotent, safe to run on already-patched files,
8
+ // fail-open if the file looks different from upstream.
9
+
10
+ const fs = require("fs")
11
+ const path = require("path")
12
+
13
+ function findAoLoader() {
14
+ try {
15
+ return require.resolve("@permaweb/ao-loader/dist/index.cjs", {
16
+ paths: [process.cwd(), __dirname, path.resolve(__dirname, "..")],
17
+ })
18
+ } catch (_) {}
19
+ // Fall back to scanning the closest node_modules/.
20
+ let dir = path.resolve(__dirname, "..")
21
+ while (dir !== "/" && dir !== "") {
22
+ const candidate = path.join(dir, "node_modules", "@permaweb", "ao-loader", "dist", "index.cjs")
23
+ if (fs.existsSync(candidate)) return candidate
24
+ dir = path.dirname(dir)
25
+ }
26
+ return null
27
+ }
28
+
29
+ const target = findAoLoader()
30
+ if (!target) {
31
+ // Either ao-loader isn't installed (the consumer doesn't need it) or
32
+ // we couldn't locate it — fail-open.
33
+ process.exit(0)
34
+ }
35
+
36
+ const src = fs.readFileSync(target, "utf8")
37
+
38
+ if (src.includes("Node 24+ wasm-memory64")) {
39
+ // Already patched.
40
+ process.exit(0)
41
+ }
42
+
43
+ const OLD = ` var growMemory = (size) => {
44
+ var b = wasmMemory.buffer;
45
+ var pages = (size - b.byteLength + 65535) / 65536;
46
+ try {
47
+ wasmMemory.grow(pages);
48
+ updateMemoryViews();
49
+ return 1;
50
+ } catch (e) {
51
+ err(\`growMemory: Attempted to grow heap from \${b.byteLength} bytes to \${size} bytes, but got error: \${e}\`);
52
+ }
53
+ };`
54
+
55
+ const NEW = ` var growMemory = (size) => {
56
+ var b = wasmMemory.buffer;
57
+ // Node 24+ wasm-memory64: wasmMemory.grow needs an integer page
58
+ // count, and if the underlying memory is memory64, grow() expects
59
+ // a BigInt (Number args are rejected). Compute as integer pages,
60
+ // then try BigInt first and fall back to Number for memory32.
61
+ var pages = Math.ceil((size - b.byteLength + 65535) / 65536);
62
+ try {
63
+ try {
64
+ wasmMemory.grow(BigInt(pages));
65
+ } catch (_e) {
66
+ wasmMemory.grow(pages);
67
+ }
68
+ updateMemoryViews();
69
+ return 1;
70
+ } catch (e) {
71
+ err(\`growMemory: Attempted to grow heap from \${b.byteLength} bytes to \${size} bytes, but got error: \${e}\`);
72
+ }
73
+ };`
74
+
75
+ if (!src.includes(OLD)) {
76
+ // File doesn't match the expected upstream — likely a newer ao-loader
77
+ // version where the fix has been applied differently or upstream
78
+ // rewrote the function. Fail-open.
79
+ process.exit(0)
80
+ }
81
+
82
+ const out = src.split(OLD).join(NEW)
83
+ fs.writeFileSync(target, out)
84
+ console.error("wao postinstall: patched @permaweb/ao-loader growMemory for Node 24+ wasm-memory64")