A repo for my personal website
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adding web assembly code

+191
+25
pkg/cbf_site.d.ts
··· 1 + /* tslint:disable */ 2 + /* eslint-disable */ 3 + /** 4 + * @param {string} name 5 + */ 6 + export function greet(name: string): void; 7 + 8 + export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; 9 + 10 + export interface InitOutput { 11 + readonly memory: WebAssembly.Memory; 12 + readonly greet: (a: number, b: number) => void; 13 + readonly __wbindgen_malloc: (a: number) => number; 14 + readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; 15 + } 16 + 17 + /** 18 + * If `module_or_path` is {RequestInfo} or {URL}, makes a request and 19 + * for everything else, calls `WebAssembly.instantiate` directly. 20 + * 21 + * @param {InitInput | Promise<InitInput>} module_or_path 22 + * 23 + * @returns {Promise<InitOutput>} 24 + */ 25 + export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
+139
pkg/cbf_site.js
··· 1 + 2 + let wasm; 3 + 4 + let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 5 + 6 + cachedTextDecoder.decode(); 7 + 8 + let cachegetUint8Memory0 = null; 9 + function getUint8Memory0() { 10 + if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { 11 + cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); 12 + } 13 + return cachegetUint8Memory0; 14 + } 15 + 16 + function getStringFromWasm0(ptr, len) { 17 + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); 18 + } 19 + 20 + let WASM_VECTOR_LEN = 0; 21 + 22 + let cachedTextEncoder = new TextEncoder('utf-8'); 23 + 24 + const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' 25 + ? function (arg, view) { 26 + return cachedTextEncoder.encodeInto(arg, view); 27 + } 28 + : function (arg, view) { 29 + const buf = cachedTextEncoder.encode(arg); 30 + view.set(buf); 31 + return { 32 + read: arg.length, 33 + written: buf.length 34 + }; 35 + }); 36 + 37 + function passStringToWasm0(arg, malloc, realloc) { 38 + 39 + if (realloc === undefined) { 40 + const buf = cachedTextEncoder.encode(arg); 41 + const ptr = malloc(buf.length); 42 + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); 43 + WASM_VECTOR_LEN = buf.length; 44 + return ptr; 45 + } 46 + 47 + let len = arg.length; 48 + let ptr = malloc(len); 49 + 50 + const mem = getUint8Memory0(); 51 + 52 + let offset = 0; 53 + 54 + for (; offset < len; offset++) { 55 + const code = arg.charCodeAt(offset); 56 + if (code > 0x7F) break; 57 + mem[ptr + offset] = code; 58 + } 59 + 60 + if (offset !== len) { 61 + if (offset !== 0) { 62 + arg = arg.slice(offset); 63 + } 64 + ptr = realloc(ptr, len, len = offset + arg.length * 3); 65 + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); 66 + const ret = encodeString(arg, view); 67 + 68 + offset += ret.written; 69 + } 70 + 71 + WASM_VECTOR_LEN = offset; 72 + return ptr; 73 + } 74 + /** 75 + * @param {string} name 76 + */ 77 + export function greet(name) { 78 + var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 79 + var len0 = WASM_VECTOR_LEN; 80 + wasm.greet(ptr0, len0); 81 + } 82 + 83 + async function load(module, imports) { 84 + if (typeof Response === 'function' && module instanceof Response) { 85 + if (typeof WebAssembly.instantiateStreaming === 'function') { 86 + try { 87 + return await WebAssembly.instantiateStreaming(module, imports); 88 + 89 + } catch (e) { 90 + if (module.headers.get('Content-Type') != 'application/wasm') { 91 + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); 92 + 93 + } else { 94 + throw e; 95 + } 96 + } 97 + } 98 + 99 + const bytes = await module.arrayBuffer(); 100 + return await WebAssembly.instantiate(bytes, imports); 101 + 102 + } else { 103 + const instance = await WebAssembly.instantiate(module, imports); 104 + 105 + if (instance instanceof WebAssembly.Instance) { 106 + return { instance, module }; 107 + 108 + } else { 109 + return instance; 110 + } 111 + } 112 + } 113 + 114 + async function init(input) { 115 + if (typeof input === 'undefined') { 116 + input = new URL('cbf_site_bg.wasm', import.meta.url); 117 + } 118 + const imports = {}; 119 + imports.wbg = {}; 120 + imports.wbg.__wbg_alert_3a8f0682e84a4a6b = function(arg0, arg1) { 121 + alert(getStringFromWasm0(arg0, arg1)); 122 + }; 123 + 124 + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { 125 + input = fetch(input); 126 + } 127 + 128 + 129 + 130 + const { instance, module } = await load(await input, imports); 131 + 132 + wasm = instance.exports; 133 + init.__wbindgen_wasm_module = module; 134 + 135 + return wasm; 136 + } 137 + 138 + export default init; 139 +
pkg/cbf_site_bg.wasm

This is a binary file and will not be displayed.

+6
pkg/cbf_site_bg.wasm.d.ts
··· 1 + /* tslint:disable */ 2 + /* eslint-disable */ 3 + export const memory: WebAssembly.Memory; 4 + export function greet(a: number, b: number): void; 5 + export function __wbindgen_malloc(a: number): number; 6 + export function __wbindgen_realloc(a: number, b: number, c: number): number;
+21
pkg/package.json
··· 1 + { 2 + "name": "cbf-site", 3 + "collaborators": [ 4 + "Cass Forest <cityboundforest@gmail.com>" 5 + ], 6 + "description": "My personal website built with WebAssembly and Rust", 7 + "version": "0.1.0", 8 + "license": "MIT/Apache-2.0", 9 + "repository": { 10 + "type": "git", 11 + "url": "https://github.com/skeetcha/skeetcha.github.io" 12 + }, 13 + "files": [ 14 + "cbf_site_bg.wasm", 15 + "cbf_site.js", 16 + "cbf_site.d.ts" 17 + ], 18 + "module": "cbf_site.js", 19 + "types": "cbf_site.d.ts", 20 + "sideEffects": false 21 + }