30 lines
		
	
	
		
			985 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			985 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
# Build script for WASM-compatible OpenRPC client
 | 
						|
 | 
						|
set -e
 | 
						|
 | 
						|
echo "Building WASM OpenRPC client..."
 | 
						|
 | 
						|
# Check if wasm-pack is installed
 | 
						|
if ! command -v wasm-pack &> /dev/null; then
 | 
						|
    echo "wasm-pack is not installed. Installing..."
 | 
						|
    curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
 | 
						|
fi
 | 
						|
 | 
						|
# Build the WASM package
 | 
						|
echo "Building WASM package..."
 | 
						|
wasm-pack build --target web --out-dir pkg-wasm
 | 
						|
 | 
						|
echo "WASM build complete! Package available in pkg-wasm/"
 | 
						|
echo ""
 | 
						|
echo "To use in a web project:"
 | 
						|
echo "1. Copy the pkg-wasm directory to your web project"
 | 
						|
echo "2. Import the module in your JavaScript:"
 | 
						|
echo "   import init, { WasmSupervisorClient, create_client, create_job } from './pkg-wasm/hero_supervisor_openrpc_client_wasm.js';"
 | 
						|
echo "3. Initialize the WASM module:"
 | 
						|
echo "   await init();"
 | 
						|
echo "4. Create and use the client:"
 | 
						|
echo "   const client = create_client('http://localhost:3030');"
 | 
						|
echo "   const runners = await client.list_runners();"
 |