├── .gitignore ├── README.md ├── package.json ├── pages └── api │ └── [...route].ts ├── pnpm-lock.yaml ├── tsconfig.json └── wasm ├── Cargo.lock ├── Cargo.toml ├── pkg ├── package.json ├── wasm.d.ts ├── wasm.js ├── wasm_bg.wasm └── wasm_bg.wasm.d.ts └── src └── lib.rs /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | .vscode 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | .pnpm-debug.log* 28 | 29 | # local env files 30 | .env*.local 31 | 32 | # vercel 33 | .vercel 34 | 35 | # typescript 36 | *.tsbuildinfo 37 | next-env.d.ts 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vercel Edge Functions + Hono Router + Wasm + Rust 2 | 3 | This example shows the following: 4 | 5 | 1. You are able to write Rust code inside `wasm/src` 6 | 1. The Rust code gets compiled to WebAssembly 7 | 1. The WebAssembly code is used in an API Route using the Edge Runtime 8 | 1. This API Route can be deployed to [Vercel Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) 9 | 1. The [Hono Router](https://github.com/honojs/hono) is used to write all routes in a single API Route 10 | 11 | > **Note:** This example is using Next.js "headless" through the local dev server, using `next dev` to serve API Routes. It's _not_ doing any rendering of pages, so React is not being used. Why? [Hono](https://honojs.dev/) does not currently work with vanilla Vercel Edge Functions, which are served through `vercel dev`. Hono `v3` adds support for Next.js, which enabled me to create this example. 12 | 13 | ## Example 14 | 15 | - https://hono-rust-wasm.vercel.app/api/hello 16 | - https://hono-rust-wasm.vercel.app/api/world 17 | 18 | ## Running Locally 19 | 20 | ``` 21 | pnpm i 22 | pnpm dev 23 | ``` 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "next dev", 5 | "build": "next build", 6 | "start": "next start" 7 | }, 8 | "dependencies": { 9 | "hono": "3.0.0-rc.13", 10 | "next": "13.1.6", 11 | "react": "18.2.0", 12 | "react-dom": "18.2.0" 13 | }, 14 | "devDependencies": { 15 | "@types/node": "18.13.0", 16 | "@types/react": "18.0.28", 17 | "@types/react-dom": "18.0.10", 18 | "typescript": "4.9.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pages/api/[...route].ts: -------------------------------------------------------------------------------- 1 | //@ts-ignore 2 | import wasm from '../../wasm/pkg/wasm_bg.wasm?module'; 3 | 4 | import { Hono } from 'hono'; 5 | import { handle } from 'hono/nextjs'; 6 | 7 | export const config = { 8 | runtime: 'edge', 9 | }; 10 | 11 | const app = new Hono(); 12 | 13 | app.get('/hello', async (c) => { 14 | const { exports } = (await WebAssembly.instantiate(wasm)) as any; 15 | 16 | // Set up a place for a return value on the stack 17 | const retptr = exports.__wbindgen_add_to_stack_pointer(-16); 18 | 19 | exports.greet(retptr); 20 | 21 | // Cast the shared memory buffer to 32 bit words to retrieve the 22 | // pointer to the returned string and the string's length 23 | const memoryWords = new Int32Array(exports.memory.buffer); 24 | 25 | const str = memoryWords[retptr / 4 + 0]; 26 | const len = memoryWords[retptr / 4 + 1]; 27 | 28 | // Cast the shared memory buffer to octets to convert to a 29 | // JavaScript string 30 | const memoryBytes = new Uint8Array(exports.memory.buffer); 31 | const strBytes = memoryBytes.subarray(str, str + len); 32 | 33 | const greeting = new TextDecoder('utf-8', { 34 | ignoreBOM: true, 35 | fatal: true, 36 | }).decode(strBytes); 37 | 38 | // Clean up the stack and free the memory 39 | exports.__wbindgen_add_to_stack_pointer(16); 40 | exports.__wbindgen_free(str, len); 41 | 42 | return c.json({ 43 | message: greeting, 44 | }); 45 | }); 46 | 47 | app.get('/world', async (c) => { 48 | return c.json({ 49 | message: 'Another Route!', 50 | }); 51 | }); 52 | 53 | //@ts-ignore 54 | export default handle(app, '/api'); 55 | -------------------------------------------------------------------------------- /pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: 5.4 2 | 3 | specifiers: 4 | '@types/node': 18.13.0 5 | '@types/react': 18.0.28 6 | '@types/react-dom': 18.0.10 7 | hono: 3.0.0-rc.13 8 | next: 13.1.6 9 | react: 18.2.0 10 | react-dom: 18.2.0 11 | typescript: 4.9.5 12 | 13 | dependencies: 14 | hono: 3.0.0-rc.13 15 | next: 13.1.6_biqbaboplfbrettd7655fr4n2y 16 | react: 18.2.0 17 | react-dom: 18.2.0_react@18.2.0 18 | 19 | devDependencies: 20 | '@types/node': 18.13.0 21 | '@types/react': 18.0.28 22 | '@types/react-dom': 18.0.10 23 | typescript: 4.9.5 24 | 25 | packages: 26 | 27 | /@next/env/13.1.6: 28 | resolution: {integrity: sha512-s+W9Fdqh5MFk6ECrbnVmmAOwxKQuhGMT7xXHrkYIBMBcTiOqNWhv5KbJIboKR5STXxNXl32hllnvKaffzFaWQg==} 29 | dev: false 30 | 31 | /@next/swc-android-arm-eabi/13.1.6: 32 | resolution: {integrity: sha512-F3/6Z8LH/pGlPzR1AcjPFxx35mPqjE5xZcf+IL+KgbW9tMkp7CYi1y7qKrEWU7W4AumxX/8OINnDQWLiwLasLQ==} 33 | engines: {node: '>= 10'} 34 | cpu: [arm] 35 | os: [android] 36 | requiresBuild: true 37 | dev: false 38 | optional: true 39 | 40 | /@next/swc-android-arm64/13.1.6: 41 | resolution: {integrity: sha512-cMwQjnB8vrYkWyK/H0Rf2c2pKIH4RGjpKUDvbjVAit6SbwPDpmaijLio0LWFV3/tOnY6kvzbL62lndVA0mkYpw==} 42 | engines: {node: '>= 10'} 43 | cpu: [arm64] 44 | os: [android] 45 | requiresBuild: true 46 | dev: false 47 | optional: true 48 | 49 | /@next/swc-darwin-arm64/13.1.6: 50 | resolution: {integrity: sha512-KKRQH4DDE4kONXCvFMNBZGDb499Hs+xcFAwvj+rfSUssIDrZOlyfJNy55rH5t2Qxed1e4K80KEJgsxKQN1/fyw==} 51 | engines: {node: '>= 10'} 52 | cpu: [arm64] 53 | os: [darwin] 54 | requiresBuild: true 55 | dev: false 56 | optional: true 57 | 58 | /@next/swc-darwin-x64/13.1.6: 59 | resolution: {integrity: sha512-/uOky5PaZDoaU99ohjtNcDTJ6ks/gZ5ykTQDvNZDjIoCxFe3+t06bxsTPY6tAO6uEAw5f6vVFX5H5KLwhrkZCA==} 60 | engines: {node: '>= 10'} 61 | cpu: [x64] 62 | os: [darwin] 63 | requiresBuild: true 64 | dev: false 65 | optional: true 66 | 67 | /@next/swc-freebsd-x64/13.1.6: 68 | resolution: {integrity: sha512-qaEALZeV7to6weSXk3Br80wtFQ7cFTpos/q+m9XVRFggu+8Ib895XhMWdJBzew6aaOcMvYR6KQ6JmHA2/eMzWw==} 69 | engines: {node: '>= 10'} 70 | cpu: [x64] 71 | os: [freebsd] 72 | requiresBuild: true 73 | dev: false 74 | optional: true 75 | 76 | /@next/swc-linux-arm-gnueabihf/13.1.6: 77 | resolution: {integrity: sha512-OybkbC58A1wJ+JrJSOjGDvZzrVEQA4sprJejGqMwiZyLqhr9Eo8FXF0y6HL+m1CPCpPhXEHz/2xKoYsl16kNqw==} 78 | engines: {node: '>= 10'} 79 | cpu: [arm] 80 | os: [linux] 81 | requiresBuild: true 82 | dev: false 83 | optional: true 84 | 85 | /@next/swc-linux-arm64-gnu/13.1.6: 86 | resolution: {integrity: sha512-yCH+yDr7/4FDuWv6+GiYrPI9kcTAO3y48UmaIbrKy8ZJpi7RehJe3vIBRUmLrLaNDH3rY1rwoHi471NvR5J5NQ==} 87 | engines: {node: '>= 10'} 88 | cpu: [arm64] 89 | os: [linux] 90 | requiresBuild: true 91 | dev: false 92 | optional: true 93 | 94 | /@next/swc-linux-arm64-musl/13.1.6: 95 | resolution: {integrity: sha512-ECagB8LGX25P9Mrmlc7Q/TQBb9rGScxHbv/kLqqIWs2fIXy6Y/EiBBiM72NTwuXUFCNrWR4sjUPSooVBJJ3ESQ==} 96 | engines: {node: '>= 10'} 97 | cpu: [arm64] 98 | os: [linux] 99 | requiresBuild: true 100 | dev: false 101 | optional: true 102 | 103 | /@next/swc-linux-x64-gnu/13.1.6: 104 | resolution: {integrity: sha512-GT5w2mruk90V/I5g6ScuueE7fqj/d8Bui2qxdw6lFxmuTgMeol5rnzAv4uAoVQgClOUO/MULilzlODg9Ib3Y4Q==} 105 | engines: {node: '>= 10'} 106 | cpu: [x64] 107 | os: [linux] 108 | requiresBuild: true 109 | dev: false 110 | optional: true 111 | 112 | /@next/swc-linux-x64-musl/13.1.6: 113 | resolution: {integrity: sha512-keFD6KvwOPzmat4TCnlnuxJCQepPN+8j3Nw876FtULxo8005Y9Ghcl7ACcR8GoiKoddAq8gxNBrpjoxjQRHeAQ==} 114 | engines: {node: '>= 10'} 115 | cpu: [x64] 116 | os: [linux] 117 | requiresBuild: true 118 | dev: false 119 | optional: true 120 | 121 | /@next/swc-win32-arm64-msvc/13.1.6: 122 | resolution: {integrity: sha512-OwertslIiGQluFvHyRDzBCIB07qJjqabAmINlXUYt7/sY7Q7QPE8xVi5beBxX/rxTGPIbtyIe3faBE6Z2KywhQ==} 123 | engines: {node: '>= 10'} 124 | cpu: [arm64] 125 | os: [win32] 126 | requiresBuild: true 127 | dev: false 128 | optional: true 129 | 130 | /@next/swc-win32-ia32-msvc/13.1.6: 131 | resolution: {integrity: sha512-g8zowiuP8FxUR9zslPmlju7qYbs2XBtTLVSxVikPtUDQedhcls39uKYLvOOd1JZg0ehyhopobRoH1q+MHlIN/w==} 132 | engines: {node: '>= 10'} 133 | cpu: [ia32] 134 | os: [win32] 135 | requiresBuild: true 136 | dev: false 137 | optional: true 138 | 139 | /@next/swc-win32-x64-msvc/13.1.6: 140 | resolution: {integrity: sha512-Ls2OL9hi3YlJKGNdKv8k3X/lLgc3VmLG3a/DeTkAd+lAituJp8ZHmRmm9f9SL84fT3CotlzcgbdaCDfFwFA6bA==} 141 | engines: {node: '>= 10'} 142 | cpu: [x64] 143 | os: [win32] 144 | requiresBuild: true 145 | dev: false 146 | optional: true 147 | 148 | /@swc/helpers/0.4.14: 149 | resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} 150 | dependencies: 151 | tslib: 2.5.0 152 | dev: false 153 | 154 | /@types/node/18.13.0: 155 | resolution: {integrity: sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==} 156 | dev: true 157 | 158 | /@types/prop-types/15.7.5: 159 | resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} 160 | dev: true 161 | 162 | /@types/react-dom/18.0.10: 163 | resolution: {integrity: sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==} 164 | dependencies: 165 | '@types/react': 18.0.28 166 | dev: true 167 | 168 | /@types/react/18.0.28: 169 | resolution: {integrity: sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==} 170 | dependencies: 171 | '@types/prop-types': 15.7.5 172 | '@types/scheduler': 0.16.2 173 | csstype: 3.1.1 174 | dev: true 175 | 176 | /@types/scheduler/0.16.2: 177 | resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} 178 | dev: true 179 | 180 | /caniuse-lite/1.0.30001451: 181 | resolution: {integrity: sha512-XY7UbUpGRatZzoRft//5xOa69/1iGJRBlrieH6QYrkKLIFn3m7OVEJ81dSrKoy2BnKsdbX5cLrOispZNYo9v2w==} 182 | dev: false 183 | 184 | /client-only/0.0.1: 185 | resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} 186 | dev: false 187 | 188 | /csstype/3.1.1: 189 | resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==} 190 | dev: true 191 | 192 | /hono/3.0.0-rc.13: 193 | resolution: {integrity: sha512-lrbcCSRPUdELa60PDKe2GmSACS83BfvyBv8RYE2BFUFaHnXAQnr9lXtE5m/sJqaJ945C4Bzr+WoMGjaWHgs3AA==} 194 | engines: {node: '>=16.0.0'} 195 | dev: false 196 | 197 | /js-tokens/4.0.0: 198 | resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} 199 | dev: false 200 | 201 | /loose-envify/1.4.0: 202 | resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} 203 | hasBin: true 204 | dependencies: 205 | js-tokens: 4.0.0 206 | dev: false 207 | 208 | /nanoid/3.3.4: 209 | resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} 210 | engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} 211 | hasBin: true 212 | dev: false 213 | 214 | /next/13.1.6_biqbaboplfbrettd7655fr4n2y: 215 | resolution: {integrity: sha512-hHlbhKPj9pW+Cymvfzc15lvhaOZ54l+8sXDXJWm3OBNBzgrVj6hwGPmqqsXg40xO1Leq+kXpllzRPuncpC0Phw==} 216 | engines: {node: '>=14.6.0'} 217 | hasBin: true 218 | peerDependencies: 219 | fibers: '>= 3.1.0' 220 | node-sass: ^6.0.0 || ^7.0.0 221 | react: ^18.2.0 222 | react-dom: ^18.2.0 223 | sass: ^1.3.0 224 | peerDependenciesMeta: 225 | fibers: 226 | optional: true 227 | node-sass: 228 | optional: true 229 | sass: 230 | optional: true 231 | dependencies: 232 | '@next/env': 13.1.6 233 | '@swc/helpers': 0.4.14 234 | caniuse-lite: 1.0.30001451 235 | postcss: 8.4.14 236 | react: 18.2.0 237 | react-dom: 18.2.0_react@18.2.0 238 | styled-jsx: 5.1.1_react@18.2.0 239 | optionalDependencies: 240 | '@next/swc-android-arm-eabi': 13.1.6 241 | '@next/swc-android-arm64': 13.1.6 242 | '@next/swc-darwin-arm64': 13.1.6 243 | '@next/swc-darwin-x64': 13.1.6 244 | '@next/swc-freebsd-x64': 13.1.6 245 | '@next/swc-linux-arm-gnueabihf': 13.1.6 246 | '@next/swc-linux-arm64-gnu': 13.1.6 247 | '@next/swc-linux-arm64-musl': 13.1.6 248 | '@next/swc-linux-x64-gnu': 13.1.6 249 | '@next/swc-linux-x64-musl': 13.1.6 250 | '@next/swc-win32-arm64-msvc': 13.1.6 251 | '@next/swc-win32-ia32-msvc': 13.1.6 252 | '@next/swc-win32-x64-msvc': 13.1.6 253 | transitivePeerDependencies: 254 | - '@babel/core' 255 | - babel-plugin-macros 256 | dev: false 257 | 258 | /picocolors/1.0.0: 259 | resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} 260 | dev: false 261 | 262 | /postcss/8.4.14: 263 | resolution: {integrity: sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==} 264 | engines: {node: ^10 || ^12 || >=14} 265 | dependencies: 266 | nanoid: 3.3.4 267 | picocolors: 1.0.0 268 | source-map-js: 1.0.2 269 | dev: false 270 | 271 | /react-dom/18.2.0_react@18.2.0: 272 | resolution: {integrity: sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==} 273 | peerDependencies: 274 | react: ^18.2.0 275 | dependencies: 276 | loose-envify: 1.4.0 277 | react: 18.2.0 278 | scheduler: 0.23.0 279 | dev: false 280 | 281 | /react/18.2.0: 282 | resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==} 283 | engines: {node: '>=0.10.0'} 284 | dependencies: 285 | loose-envify: 1.4.0 286 | dev: false 287 | 288 | /scheduler/0.23.0: 289 | resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} 290 | dependencies: 291 | loose-envify: 1.4.0 292 | dev: false 293 | 294 | /source-map-js/1.0.2: 295 | resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} 296 | engines: {node: '>=0.10.0'} 297 | dev: false 298 | 299 | /styled-jsx/5.1.1_react@18.2.0: 300 | resolution: {integrity: sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==} 301 | engines: {node: '>= 12.0.0'} 302 | peerDependencies: 303 | '@babel/core': '*' 304 | babel-plugin-macros: '*' 305 | react: '>= 16.8.0 || 17.x.x || ^18.0.0-0' 306 | peerDependenciesMeta: 307 | '@babel/core': 308 | optional: true 309 | babel-plugin-macros: 310 | optional: true 311 | dependencies: 312 | client-only: 0.0.1 313 | react: 18.2.0 314 | dev: false 315 | 316 | /tslib/2.5.0: 317 | resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} 318 | dev: false 319 | 320 | /typescript/4.9.5: 321 | resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} 322 | engines: {node: '>=4.2.0'} 323 | hasBin: true 324 | dev: true 325 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "baseUrl": ".", 18 | "paths": { 19 | "@/*": ["./*"] 20 | } 21 | }, 22 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 23 | "exclude": ["node_modules"] 24 | } 25 | -------------------------------------------------------------------------------- /wasm/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "bumpalo" 7 | version = "3.11.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" 10 | 11 | [[package]] 12 | name = "cfg-if" 13 | version = "1.0.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 16 | 17 | [[package]] 18 | name = "log" 19 | version = "0.4.17" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 22 | dependencies = [ 23 | "cfg-if", 24 | ] 25 | 26 | [[package]] 27 | name = "once_cell" 28 | version = "1.13.1" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" 31 | 32 | [[package]] 33 | name = "proc-macro2" 34 | version = "1.0.43" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" 37 | dependencies = [ 38 | "unicode-ident", 39 | ] 40 | 41 | [[package]] 42 | name = "quote" 43 | version = "1.0.21" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 46 | dependencies = [ 47 | "proc-macro2", 48 | ] 49 | 50 | [[package]] 51 | name = "syn" 52 | version = "1.0.99" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" 55 | dependencies = [ 56 | "proc-macro2", 57 | "quote", 58 | "unicode-ident", 59 | ] 60 | 61 | [[package]] 62 | name = "unicode-ident" 63 | version = "1.0.3" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" 66 | 67 | [[package]] 68 | name = "wasm" 69 | version = "0.1.0" 70 | dependencies = [ 71 | "wasm-bindgen", 72 | ] 73 | 74 | [[package]] 75 | name = "wasm-bindgen" 76 | version = "0.2.82" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" 79 | dependencies = [ 80 | "cfg-if", 81 | "wasm-bindgen-macro", 82 | ] 83 | 84 | [[package]] 85 | name = "wasm-bindgen-backend" 86 | version = "0.2.82" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" 89 | dependencies = [ 90 | "bumpalo", 91 | "log", 92 | "once_cell", 93 | "proc-macro2", 94 | "quote", 95 | "syn", 96 | "wasm-bindgen-shared", 97 | ] 98 | 99 | [[package]] 100 | name = "wasm-bindgen-macro" 101 | version = "0.2.82" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" 104 | dependencies = [ 105 | "quote", 106 | "wasm-bindgen-macro-support", 107 | ] 108 | 109 | [[package]] 110 | name = "wasm-bindgen-macro-support" 111 | version = "0.2.82" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" 114 | dependencies = [ 115 | "proc-macro2", 116 | "quote", 117 | "syn", 118 | "wasm-bindgen-backend", 119 | "wasm-bindgen-shared", 120 | ] 121 | 122 | [[package]] 123 | name = "wasm-bindgen-shared" 124 | version = "0.2.82" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" 127 | -------------------------------------------------------------------------------- /wasm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wasm" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [lib] 7 | crate-type = ["cdylib", "rlib"] 8 | 9 | [dependencies] 10 | wasm-bindgen = "0.2.63" 11 | 12 | [profile.release] 13 | lto = true 14 | opt-level = "s" 15 | -------------------------------------------------------------------------------- /wasm/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wasm", 3 | "version": "0.1.0", 4 | "files": [ 5 | "wasm_bg.wasm", 6 | "wasm.js", 7 | "wasm_bg.js", 8 | "wasm.d.ts" 9 | ], 10 | "module": "wasm.js", 11 | "types": "wasm.d.ts", 12 | "sideEffects": false 13 | } 14 | -------------------------------------------------------------------------------- /wasm/pkg/wasm.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * @returns {string} 5 | */ 6 | export function greet(): string 7 | -------------------------------------------------------------------------------- /wasm/pkg/wasm.js: -------------------------------------------------------------------------------- 1 | import * as wasm from './wasm_bg.wasm'; 2 | export * from './wasm_bg.js.js'; 3 | -------------------------------------------------------------------------------- /wasm/pkg/wasm_bg.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leerob/hono-vercel-edge-functions/a87fa1b33edd8f0685af81281ea1f360729854e5/wasm/pkg/wasm_bg.wasm -------------------------------------------------------------------------------- /wasm/pkg/wasm_bg.wasm.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | export const memory: WebAssembly.Memory 4 | export function greet(a: number): void 5 | export function __wbindgen_add_to_stack_pointer(a: number): number 6 | export function __wbindgen_free(a: number, b: number): void 7 | -------------------------------------------------------------------------------- /wasm/src/lib.rs: -------------------------------------------------------------------------------- 1 | use wasm_bindgen::prelude::*; 2 | 3 | #[wasm_bindgen] 4 | pub fn greet() -> String { 5 | return "Hello, World!".to_string(); 6 | } 7 | --------------------------------------------------------------------------------