Skip to main content

WebAssembly SDK

The WebAssembly SDK brings HulyaSync to the browser at near-native performance. Compiled from the Rust SDK using wasm-pack. For operator computation, call the REST API.

Build from Rust

cargo install wasm-pack
cd zeq-os-hub/sdk/rust
wasm-pack build --target web --out-dir ../wasm/pkg

Installation

npm install @zeq-os/wasm

Quick Start

<!DOCTYPE html>
<html>
<head><title>Zeq OS WASM</title></head>
<body>
<script type="module">
import init, { HulyaSync } from './pkg/zeq_os.js';

const BASE = 'http://localhost';

async function main() {
await init();

// ── Local HulyaSync — no server, no auth ────────────────────────────────
const sync = new HulyaSync();

const phase = sync.current_phase();
const zeqond = sync.get_zeqond();
const ko42 = sync.ko42_automatic();
console.log(`Phase: ${phase.toFixed(4)} Zeqond: ${zeqond} KO42: ${ko42.toFixed(6)}`);

// Zeq Equation modulation: R(t) = S(t) × [1 + α·sin(2πft)]
const g = 9.80665;
console.log(`g modulated: ${sync.modulate(g).toFixed(6)}`);
console.log(sync.daemon_tick());

// ── Browse operators — public, no auth ──────────────────────────────────
const { operators } = await fetch(`${BASE}/api/zeq/operators`).then(r => r.json());
operators.slice(0, 3).forEach(op =>
console.log(`${op.id.padEnd(6)} ${op.name.padEnd(30)} ${op.equation}`)
);

// ── Execute operator — requires account ──────────────────────────────────
const token = localStorage.getItem('zeq_token');
const result = await fetch(`${BASE}/api/zeq/operators/execute?operator=NM21`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ params: { G: 6.674e-11, m1: 5.97e24, m2: 7.35e22, r: 3.84e8 } })
}).then(r => r.json());
console.log(`F = ${result.value.toExponential(3)} N`);

// ── 7-Step Wizard — requires account ─────────────────────────────────────
const state = await fetch(`${BASE}/api/7step/run`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ query: 'photon energy at 5e14 Hz', operators: ['KO42', 'QM10'], mode: 'basic' })
}).then(r => r.json());
console.log(`Operators: ${state.selected_operators} Master sum: ${state.master_sum}`);
}

main();
</script>
</body>
</html>

npm Package

import init, { HulyaSync } from '@zeq-os/wasm';

await init();

const sync = new HulyaSync();
console.log(`Phase: ${sync.current_phase()}`);
console.log(`KO42: ${sync.ko42_automatic()}`);
console.log(`g mod: ${sync.modulate(9.80665)}`);

HulyaSync API (WASM)

The WASM module exposes the same API as the Rust SDK:

// From @zeq-os/wasm (TypeScript declarations)
export class HulyaSync {
current_phase(): number; // [0, 1)
current_phase_radians(): number; // [0, 2π)
modulate(value: number): number; // R(t) = S(t)[1 + α·sin(2πft)]
ko42_automatic(): number; // α · sin(2π × 1.287 × t)
get_zeqond(): bigint; // Zeqond count since epoch
daemon_tick(): string; // Daemon announcement
}

Performance

Running locally in the browser:

  • HulyaPulse phase calculation: sub-microsecond
  • Modulation per value: ~100ns
  • Daemon tick string: <1ms

No network latency for temporal operations — only computation calls hit the server.

Architecture

sdk/wasm/
├── README.md
└── pkg/ (generated by wasm-pack)
├── zeq_os.js # JavaScript bindings
├── zeq_os_bg.wasm # Compiled WASM binary
└── zeq_os.d.ts # TypeScript declarations