Compare commits
No commits in common. "3ca53db260bbf7a51b504722856022e8ccf148ee" and "00814fa01c1acc5365c9421fe992ffe08df2f341" have entirely different histories.
3ca53db260
...
00814fa01c
|
@ -75,12 +75,6 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anyhow"
|
|
||||||
version = "1.0.64"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b9a8f622bcf6ff3df478e9deba3e03e4e04b300f8e6a139e192c05fa3490afc7"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-stream"
|
name = "async-stream"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
@ -1108,8 +1102,6 @@ dependencies = [
|
||||||
name = "lan_party_web"
|
name = "lan_party_web"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"js-sys",
|
|
||||||
"lan_party_core",
|
"lan_party_core",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -1118,7 +1110,6 @@ dependencies = [
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"yew",
|
"yew",
|
||||||
"yew-hooks",
|
|
||||||
"yew-router",
|
"yew-router",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3116,22 +3107,6 @@ dependencies = [
|
||||||
"yew-macro",
|
"yew-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "yew-hooks"
|
|
||||||
version = "0.1.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1807cd5bf44c34255534fc8a824b0d6c1022147affecbb7f10c6753f336e7309"
|
|
||||||
dependencies = [
|
|
||||||
"gloo",
|
|
||||||
"js-sys",
|
|
||||||
"log",
|
|
||||||
"serde",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"web-sys",
|
|
||||||
"yew",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yew-macro"
|
name = "yew-macro"
|
||||||
version = "0.19.3"
|
version = "0.19.3"
|
||||||
|
|
|
@ -15,6 +15,3 @@ wasm-bindgen-futures = "0.4"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
yew-hooks = "0.1"
|
|
||||||
anyhow = "1.0"
|
|
||||||
js-sys = "0.3"
|
|
||||||
|
|
|
@ -0,0 +1,693 @@
|
||||||
|
|
||||||
|
let wasm;
|
||||||
|
|
||||||
|
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||||
|
|
||||||
|
cachedTextDecoder.decode();
|
||||||
|
|
||||||
|
let cachedUint8Memory0 = new Uint8Array();
|
||||||
|
|
||||||
|
function getUint8Memory0() {
|
||||||
|
if (cachedUint8Memory0.byteLength === 0) {
|
||||||
|
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||||
|
}
|
||||||
|
return cachedUint8Memory0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStringFromWasm0(ptr, len) {
|
||||||
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||||
|
}
|
||||||
|
|
||||||
|
const heap = new Array(32).fill(undefined);
|
||||||
|
|
||||||
|
heap.push(undefined, null, true, false);
|
||||||
|
|
||||||
|
let heap_next = heap.length;
|
||||||
|
|
||||||
|
function addHeapObject(obj) {
|
||||||
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||||
|
const idx = heap_next;
|
||||||
|
heap_next = heap[idx];
|
||||||
|
|
||||||
|
heap[idx] = obj;
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getObject(idx) { return heap[idx]; }
|
||||||
|
|
||||||
|
let WASM_VECTOR_LEN = 0;
|
||||||
|
|
||||||
|
const cachedTextEncoder = new TextEncoder('utf-8');
|
||||||
|
|
||||||
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
||||||
|
? function (arg, view) {
|
||||||
|
return cachedTextEncoder.encodeInto(arg, view);
|
||||||
|
}
|
||||||
|
: function (arg, view) {
|
||||||
|
const buf = cachedTextEncoder.encode(arg);
|
||||||
|
view.set(buf);
|
||||||
|
return {
|
||||||
|
read: arg.length,
|
||||||
|
written: buf.length
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function passStringToWasm0(arg, malloc, realloc) {
|
||||||
|
|
||||||
|
if (realloc === undefined) {
|
||||||
|
const buf = cachedTextEncoder.encode(arg);
|
||||||
|
const ptr = malloc(buf.length);
|
||||||
|
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||||
|
WASM_VECTOR_LEN = buf.length;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
let len = arg.length;
|
||||||
|
let ptr = malloc(len);
|
||||||
|
|
||||||
|
const mem = getUint8Memory0();
|
||||||
|
|
||||||
|
let offset = 0;
|
||||||
|
|
||||||
|
for (; offset < len; offset++) {
|
||||||
|
const code = arg.charCodeAt(offset);
|
||||||
|
if (code > 0x7F) break;
|
||||||
|
mem[ptr + offset] = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset !== len) {
|
||||||
|
if (offset !== 0) {
|
||||||
|
arg = arg.slice(offset);
|
||||||
|
}
|
||||||
|
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
||||||
|
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
||||||
|
const ret = encodeString(arg, view);
|
||||||
|
|
||||||
|
offset += ret.written;
|
||||||
|
}
|
||||||
|
|
||||||
|
WASM_VECTOR_LEN = offset;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cachedInt32Memory0 = new Int32Array();
|
||||||
|
|
||||||
|
function getInt32Memory0() {
|
||||||
|
if (cachedInt32Memory0.byteLength === 0) {
|
||||||
|
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||||
|
}
|
||||||
|
return cachedInt32Memory0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLikeNone(x) {
|
||||||
|
return x === undefined || x === null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cachedFloat64Memory0 = new Float64Array();
|
||||||
|
|
||||||
|
function getFloat64Memory0() {
|
||||||
|
if (cachedFloat64Memory0.byteLength === 0) {
|
||||||
|
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
||||||
|
}
|
||||||
|
return cachedFloat64Memory0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropObject(idx) {
|
||||||
|
if (idx < 36) return;
|
||||||
|
heap[idx] = heap_next;
|
||||||
|
heap_next = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
function takeObject(idx) {
|
||||||
|
const ret = getObject(idx);
|
||||||
|
dropObject(idx);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
function debugString(val) {
|
||||||
|
// primitive types
|
||||||
|
const type = typeof val;
|
||||||
|
if (type == 'number' || type == 'boolean' || val == null) {
|
||||||
|
return `${val}`;
|
||||||
|
}
|
||||||
|
if (type == 'string') {
|
||||||
|
return `"${val}"`;
|
||||||
|
}
|
||||||
|
if (type == 'symbol') {
|
||||||
|
const description = val.description;
|
||||||
|
if (description == null) {
|
||||||
|
return 'Symbol';
|
||||||
|
} else {
|
||||||
|
return `Symbol(${description})`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == 'function') {
|
||||||
|
const name = val.name;
|
||||||
|
if (typeof name == 'string' && name.length > 0) {
|
||||||
|
return `Function(${name})`;
|
||||||
|
} else {
|
||||||
|
return 'Function';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// objects
|
||||||
|
if (Array.isArray(val)) {
|
||||||
|
const length = val.length;
|
||||||
|
let debug = '[';
|
||||||
|
if (length > 0) {
|
||||||
|
debug += debugString(val[0]);
|
||||||
|
}
|
||||||
|
for(let i = 1; i < length; i++) {
|
||||||
|
debug += ', ' + debugString(val[i]);
|
||||||
|
}
|
||||||
|
debug += ']';
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
// Test for built-in
|
||||||
|
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
||||||
|
let className;
|
||||||
|
if (builtInMatches.length > 1) {
|
||||||
|
className = builtInMatches[1];
|
||||||
|
} else {
|
||||||
|
// Failed to match the standard '[object ClassName]'
|
||||||
|
return toString.call(val);
|
||||||
|
}
|
||||||
|
if (className == 'Object') {
|
||||||
|
// we're a user defined class or Object
|
||||||
|
// JSON.stringify avoids problems with cycles, and is generally much
|
||||||
|
// easier than looping through ownProperties of `val`.
|
||||||
|
try {
|
||||||
|
return 'Object(' + JSON.stringify(val) + ')';
|
||||||
|
} catch (_) {
|
||||||
|
return 'Object';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// errors
|
||||||
|
if (val instanceof Error) {
|
||||||
|
return `${val.name}: ${val.message}\n${val.stack}`;
|
||||||
|
}
|
||||||
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeClosure(arg0, arg1, dtor, f) {
|
||||||
|
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
||||||
|
const real = (...args) => {
|
||||||
|
// First up with a closure we increment the internal reference
|
||||||
|
// count. This ensures that the Rust closure environment won't
|
||||||
|
// be deallocated while we're invoking it.
|
||||||
|
state.cnt++;
|
||||||
|
try {
|
||||||
|
return f(state.a, state.b, ...args);
|
||||||
|
} finally {
|
||||||
|
if (--state.cnt === 0) {
|
||||||
|
wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b);
|
||||||
|
state.a = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
real.original = state;
|
||||||
|
|
||||||
|
return real;
|
||||||
|
}
|
||||||
|
function __wbg_adapter_24(arg0, arg1, arg2) {
|
||||||
|
wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf2a95eaa6a1fe8eb(arg0, arg1, addHeapObject(arg2));
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeMutClosure(arg0, arg1, dtor, f) {
|
||||||
|
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
||||||
|
const real = (...args) => {
|
||||||
|
// First up with a closure we increment the internal reference
|
||||||
|
// count. This ensures that the Rust closure environment won't
|
||||||
|
// be deallocated while we're invoking it.
|
||||||
|
state.cnt++;
|
||||||
|
const a = state.a;
|
||||||
|
state.a = 0;
|
||||||
|
try {
|
||||||
|
return f(a, state.b, ...args);
|
||||||
|
} finally {
|
||||||
|
if (--state.cnt === 0) {
|
||||||
|
wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
state.a = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
real.original = state;
|
||||||
|
|
||||||
|
return real;
|
||||||
|
}
|
||||||
|
|
||||||
|
let stack_pointer = 32;
|
||||||
|
|
||||||
|
function addBorrowedObject(obj) {
|
||||||
|
if (stack_pointer == 1) throw new Error('out of js stack');
|
||||||
|
heap[--stack_pointer] = obj;
|
||||||
|
return stack_pointer;
|
||||||
|
}
|
||||||
|
function __wbg_adapter_27(arg0, arg1, arg2) {
|
||||||
|
try {
|
||||||
|
wasm._dyn_core__ops__function__FnMut___A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3700fed383a0f072(arg0, arg1, addBorrowedObject(arg2));
|
||||||
|
} finally {
|
||||||
|
heap[stack_pointer++] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
||||||
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0ff5f5f93b8ace87(arg0, arg1, addHeapObject(arg2));
|
||||||
|
}
|
||||||
|
|
||||||
|
let cachedUint32Memory0 = new Uint32Array();
|
||||||
|
|
||||||
|
function getUint32Memory0() {
|
||||||
|
if (cachedUint32Memory0.byteLength === 0) {
|
||||||
|
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
||||||
|
}
|
||||||
|
return cachedUint32Memory0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getArrayJsValueFromWasm0(ptr, len) {
|
||||||
|
const mem = getUint32Memory0();
|
||||||
|
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
||||||
|
const result = [];
|
||||||
|
for (let i = 0; i < slice.length; i++) {
|
||||||
|
result.push(takeObject(slice[i]));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleError(f, args) {
|
||||||
|
try {
|
||||||
|
return f.apply(this, args);
|
||||||
|
} catch (e) {
|
||||||
|
wasm.__wbindgen_exn_store(addHeapObject(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function load(module, imports) {
|
||||||
|
if (typeof Response === 'function' && module instanceof Response) {
|
||||||
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
||||||
|
try {
|
||||||
|
return await WebAssembly.instantiateStreaming(module, imports);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
if (module.headers.get('Content-Type') != 'application/wasm') {
|
||||||
|
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);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const bytes = await module.arrayBuffer();
|
||||||
|
return await WebAssembly.instantiate(bytes, imports);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const instance = await WebAssembly.instantiate(module, imports);
|
||||||
|
|
||||||
|
if (instance instanceof WebAssembly.Instance) {
|
||||||
|
return { instance, module };
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getImports() {
|
||||||
|
const imports = {};
|
||||||
|
imports.wbg = {};
|
||||||
|
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
||||||
|
const ret = getStringFromWasm0(arg0, arg1);
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
||||||
|
const ret = getObject(arg0);
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
|
||||||
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
|
||||||
|
const obj = getObject(arg1);
|
||||||
|
const ret = JSON.stringify(obj === undefined ? null : obj);
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
||||||
|
const ret = getObject(arg0) === undefined;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
||||||
|
const obj = getObject(arg1);
|
||||||
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
||||||
|
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_number_new = function(arg0) {
|
||||||
|
const ret = arg0;
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
|
||||||
|
try {
|
||||||
|
console.error(getStringFromWasm0(arg0, arg1));
|
||||||
|
} finally {
|
||||||
|
wasm.__wbindgen_free(arg0, arg1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_new_693216e109162396 = function() {
|
||||||
|
const ret = new Error();
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg1).stack;
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
||||||
|
takeObject(arg0);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
||||||
|
const obj = takeObject(arg0).original;
|
||||||
|
if (obj.cnt-- == 1) {
|
||||||
|
obj.a = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const ret = false;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_warn_921059440157e870 = function(arg0, arg1) {
|
||||||
|
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
|
||||||
|
wasm.__wbindgen_free(arg0, arg1 * 4);
|
||||||
|
console.warn(...v0);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_instanceof_Window_42f092928baaee84 = function(arg0) {
|
||||||
|
const ret = getObject(arg0) instanceof Window;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_document_15b2e504fb1556d6 = function(arg0) {
|
||||||
|
const ret = getObject(arg0).document;
|
||||||
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_location_312161fbd0cf64f0 = function(arg0) {
|
||||||
|
const ret = getObject(arg0).location;
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_history_cb2cdfbe20fef7ad = function() { return handleError(function (arg0) {
|
||||||
|
const ret = getObject(arg0).history;
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_fetch_9a5cb9d8a96004d0 = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg0).fetch(getObject(arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_body_5e6efc7a3c1b65f3 = function(arg0) {
|
||||||
|
const ret = getObject(arg0).body;
|
||||||
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_createElement_28fc3740fb11defb = function() { return handleError(function (arg0, arg1, arg2) {
|
||||||
|
const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_createElementNS_dd6cca2457c8c16c = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
const ret = getObject(arg0).createElementNS(arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_createTextNode_2ab1e3ebc34e2641 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = getObject(arg0).createTextNode(getStringFromWasm0(arg1, arg2));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_querySelector_73feab41810011dc = function() { return handleError(function (arg0, arg1, arg2) {
|
||||||
|
const ret = getObject(arg0).querySelector(getStringFromWasm0(arg1, arg2));
|
||||||
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_instanceof_HtmlInputElement_3fad42774bc62388 = function(arg0) {
|
||||||
|
const ret = getObject(arg0) instanceof HTMLInputElement;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_setchecked_a450b330df6b3fa5 = function(arg0, arg1) {
|
||||||
|
getObject(arg0).checked = arg1 !== 0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_value_30770021ca38e0db = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg1).value;
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_setvalue_7b7950dacc5eb607 = function(arg0, arg1, arg2) {
|
||||||
|
getObject(arg0).value = getStringFromWasm0(arg1, arg2);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_addEventListener_ec92ea1297eefdfc = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3), getObject(arg4));
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_removeEventListener_bfe676215a590711 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
getObject(arg0).removeEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3), arg4 !== 0);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_pushState_65b5fb0f30ca9d61 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
|
||||||
|
getObject(arg0).pushState(getObject(arg1), getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5));
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_parentElement_14138ef2ff0b9c88 = function(arg0) {
|
||||||
|
const ret = getObject(arg0).parentElement;
|
||||||
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_lastChild_2d1fa5efd0e0edcc = function(arg0) {
|
||||||
|
const ret = getObject(arg0).lastChild;
|
||||||
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_setnodeValue_59d46f408f89fd0b = function(arg0, arg1, arg2) {
|
||||||
|
getObject(arg0).nodeValue = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_appendChild_d21bac021b5bbfde = function() { return handleError(function (arg0, arg1) {
|
||||||
|
const ret = getObject(arg0).appendChild(getObject(arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_insertBefore_26dfd5eb687a3438 = function() { return handleError(function (arg0, arg1, arg2) {
|
||||||
|
const ret = getObject(arg0).insertBefore(getObject(arg1), getObject(arg2));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_removeChild_94b0c126b878241b = function() { return handleError(function (arg0, arg1) {
|
||||||
|
const ret = getObject(arg0).removeChild(getObject(arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_new_4cba26249c1686cd = function() { return handleError(function () {
|
||||||
|
const ret = new Headers();
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_append_9c6d4d7f71076e48 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_pathname_c08f1ef51f6ebba9 = function() { return handleError(function (arg0, arg1) {
|
||||||
|
const ret = getObject(arg1).pathname;
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_instanceof_Element_1714e50f9bda1d15 = function(arg0) {
|
||||||
|
const ret = getObject(arg0) instanceof Element;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_namespaceURI_b343a4afa454dd59 = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg1).namespaceURI;
|
||||||
|
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
var len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_removeAttribute_2d6e56b2f03aa57e = function() { return handleError(function (arg0, arg1, arg2) {
|
||||||
|
getObject(arg0).removeAttribute(getStringFromWasm0(arg1, arg2));
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_setAttribute_8cfc462c0dedd03b = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
getObject(arg0).setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_log_17733ab6fa45831d = function(arg0) {
|
||||||
|
console.log(getObject(arg0));
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_instanceof_Response_240e67e5796c3c6b = function(arg0) {
|
||||||
|
const ret = getObject(arg0) instanceof Response;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_json_30d916f3f34485ab = function() { return handleError(function (arg0) {
|
||||||
|
const ret = getObject(arg0).json();
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_pathname_8ed2fc02f98aeaaf = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg1).pathname;
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_new_d1d1300265e34170 = function() { return handleError(function (arg0, arg1) {
|
||||||
|
const ret = new URL(getStringFromWasm0(arg0, arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_value_eb32f706ae6bfab2 = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg1).value;
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_setvalue_3dd349be116107ce = function(arg0, arg1, arg2) {
|
||||||
|
getObject(arg0).value = getStringFromWasm0(arg1, arg2);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_instanceof_Event_8c74064684d03e14 = function(arg0) {
|
||||||
|
const ret = getObject(arg0) instanceof Event;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_target_68a5c10e2732a79e = function(arg0) {
|
||||||
|
const ret = getObject(arg0).target;
|
||||||
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_cancelBubble_aa216b328c490cb1 = function(arg0) {
|
||||||
|
const ret = getObject(arg0).cancelBubble;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_href_cae04ee9562fc683 = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg1).href;
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_newwithstrandinit_de7c409ec8538105 = function() { return handleError(function (arg0, arg1, arg2) {
|
||||||
|
const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_newnoargs_971e9a5abe185139 = function(arg0, arg1) {
|
||||||
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_call_33d7bcddbbfa394a = function() { return handleError(function (arg0, arg1) {
|
||||||
|
const ret = getObject(arg0).call(getObject(arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_valueOf_f83bee79f23e7b05 = function(arg0) {
|
||||||
|
const ret = getObject(arg0).valueOf();
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_is_43eb2f9708e964a9 = function(arg0, arg1) {
|
||||||
|
const ret = Object.is(getObject(arg0), getObject(arg1));
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_new_e6a9fecc2bf26696 = function() {
|
||||||
|
const ret = new Object();
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_resolve_0107b3a501450ba0 = function(arg0) {
|
||||||
|
const ret = Promise.resolve(getObject(arg0));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_then_18da6e5453572fc8 = function(arg0, arg1) {
|
||||||
|
const ret = getObject(arg0).then(getObject(arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_then_e5489f796341454b = function(arg0, arg1, arg2) {
|
||||||
|
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_globalThis_3348936ac49df00a = function() { return handleError(function () {
|
||||||
|
const ret = globalThis.globalThis;
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_self_fd00a1ef86d1b2ed = function() { return handleError(function () {
|
||||||
|
const ret = self.self;
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_window_6f6e346d8bbd61d7 = function() { return handleError(function () {
|
||||||
|
const ret = window.window;
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_global_67175caf56f55ca9 = function() { return handleError(function () {
|
||||||
|
const ret = global.global;
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_get_72332cd2bc57924c = function() { return handleError(function (arg0, arg1) {
|
||||||
|
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
||||||
|
return addHeapObject(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_set_2762e698c2f5b7e0 = function() { return handleError(function (arg0, arg1, arg2) {
|
||||||
|
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
||||||
|
return ret;
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
||||||
|
const ret = debugString(getObject(arg1));
|
||||||
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||||
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
||||||
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_closure_wrapper7414 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = makeClosure(arg0, arg1, 466, __wbg_adapter_24);
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_closure_wrapper8075 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = makeMutClosure(arg0, arg1, 520, __wbg_adapter_27);
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_closure_wrapper8354 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = makeMutClosure(arg0, arg1, 525, __wbg_adapter_30);
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
|
|
||||||
|
return imports;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initMemory(imports, maybe_memory) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function finalizeInit(instance, module) {
|
||||||
|
wasm = instance.exports;
|
||||||
|
init.__wbindgen_wasm_module = module;
|
||||||
|
cachedFloat64Memory0 = new Float64Array();
|
||||||
|
cachedInt32Memory0 = new Int32Array();
|
||||||
|
cachedUint32Memory0 = new Uint32Array();
|
||||||
|
cachedUint8Memory0 = new Uint8Array();
|
||||||
|
|
||||||
|
wasm.__wbindgen_start();
|
||||||
|
return wasm;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initSync(bytes) {
|
||||||
|
const imports = getImports();
|
||||||
|
|
||||||
|
initMemory(imports);
|
||||||
|
|
||||||
|
const module = new WebAssembly.Module(bytes);
|
||||||
|
const instance = new WebAssembly.Instance(module, imports);
|
||||||
|
|
||||||
|
return finalizeInit(instance, module);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function init(input) {
|
||||||
|
if (typeof input === 'undefined') {
|
||||||
|
input = new URL('index-8b6dadb5b2545aea_bg.wasm', import.meta.url);
|
||||||
|
}
|
||||||
|
const imports = getImports();
|
||||||
|
|
||||||
|
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
||||||
|
input = fetch(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
initMemory(imports);
|
||||||
|
|
||||||
|
const { instance, module } = await load(await input, imports);
|
||||||
|
|
||||||
|
return finalizeInit(instance, module);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { initSync }
|
||||||
|
export default init;
|
Binary file not shown.
|
@ -4,9 +4,9 @@
|
||||||
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet">
|
||||||
<title>Yew App</title>
|
<title>Yew App</title>
|
||||||
|
|
||||||
<link rel="preload" href="/index-167b3e062ee4dd95_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
<link rel="preload" href="/index-8b6dadb5b2545aea_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
||||||
<link rel="modulepreload" href="/index-167b3e062ee4dd95.js"></head>
|
<link rel="modulepreload" href="/index-8b6dadb5b2545aea.js"></head>
|
||||||
<body class="base theme-dark bg-gray-900 text-gray-400">
|
<body class="base theme-dark bg-gray-900 text-gray-400">
|
||||||
|
|
||||||
|
|
||||||
<script type="module">import init from '/index-167b3e062ee4dd95.js';init('/index-167b3e062ee4dd95_bg.wasm');</script></body></html>
|
<script type="module">import init from '/index-8b6dadb5b2545aea.js';init('/index-8b6dadb5b2545aea_bg.wasm');</script></body></html>
|
|
@ -45,7 +45,6 @@ pub struct Props {
|
||||||
#[function_component(Button)]
|
#[function_component(Button)]
|
||||||
pub fn button(props: &Props) -> Html {
|
pub fn button(props: &Props) -> Html {
|
||||||
let mut icon_class = Classes::from("mdi");
|
let mut icon_class = Classes::from("mdi");
|
||||||
icon_class.push("text-lg");
|
|
||||||
|
|
||||||
if !props.icon.is_empty() {
|
if !props.icon.is_empty() {
|
||||||
icon_class.push(&props.icon);
|
icon_class.push(&props.icon);
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
use lan_party_core::event::*;
|
|
||||||
use yew::prelude::*;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Properties, PartialEq)]
|
|
||||||
pub struct BlockProps {
|
|
||||||
children: Children,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[function_component(Block)]
|
|
||||||
pub fn block(props: &BlockProps) -> Html {
|
|
||||||
html! {
|
|
||||||
<div class="px-3 py-3 rounded-lg border-solid border-gray-800 border-2 my-3">
|
|
||||||
{for props.children.iter()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait RenderEvent {
|
|
||||||
fn view(&self) -> Html;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RenderEvent for String {
|
|
||||||
fn view(&self) -> Html {
|
|
||||||
html! { self }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RenderEvent for bool {
|
|
||||||
fn view(&self) -> Html {
|
|
||||||
html! {
|
|
||||||
<input type="checkbox" value={self.to_string()} disabled={true} />
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: RenderEvent> RenderEvent for Vec<T> {
|
|
||||||
fn view(&self) -> Html {
|
|
||||||
html! {
|
|
||||||
self.iter().map(|x| x.view()).collect::<Html>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: RenderEvent> RenderEvent for &[T] {
|
|
||||||
fn view(&self) -> Html {
|
|
||||||
html! {
|
|
||||||
self.iter().map(|x| x.view()).collect::<Html>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RenderEvent for lan_party_core::event::Event {
|
|
||||||
fn view(&self) -> Html {
|
|
||||||
html! {
|
|
||||||
<Block>
|
|
||||||
{ "Name: " }
|
|
||||||
{ self.name.view() }<br />
|
|
||||||
{ "Description: " }
|
|
||||||
{ self.description.view() }<br />
|
|
||||||
{ "Concluded: " }
|
|
||||||
{ self.concluded.view() }<br />
|
|
||||||
</Block>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,9 @@
|
||||||
mod button;
|
mod button;
|
||||||
mod event;
|
|
||||||
mod table;
|
mod table;
|
||||||
|
|
||||||
pub use button::Button;
|
pub use button::Button;
|
||||||
pub use event::RenderEvent;
|
|
||||||
pub use table::Table;
|
pub use table::Table;
|
||||||
use yew::{function_component, html, Children, Properties};
|
use yew::{function_component, html, Children, Html, Properties};
|
||||||
|
|
||||||
use wasm_bindgen::{JsCast, UnwrapThrowExt};
|
use wasm_bindgen::{JsCast, UnwrapThrowExt};
|
||||||
use web_sys::{Event, HtmlInputElement, InputEvent};
|
use web_sys::{Event, HtmlInputElement, InputEvent};
|
||||||
|
@ -14,32 +12,28 @@ use yew::prelude::*;
|
||||||
#[derive(Clone, PartialEq, Properties)]
|
#[derive(Clone, PartialEq, Properties)]
|
||||||
pub struct InputProps {
|
pub struct InputProps {
|
||||||
pub value: String,
|
pub value: String,
|
||||||
pub onchange: Callback<String>,
|
pub on_change: Callback<String>,
|
||||||
pub class: Classes,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_value_from_input_event(e: InputEvent) -> String {
|
fn get_value_from_input_event(e: InputEvent) -> String {
|
||||||
let event: Event = e.dyn_into().unwrap_throw();
|
let event: Event = e.dyn_into().unwrap_throw();
|
||||||
let event_target = event.target().unwrap_throw();
|
let event_target = event.target().unwrap_throw();
|
||||||
let target: HtmlInputElement = event_target.dyn_into().unwrap_throw();
|
let target: HtmlInputElement = event_target.dyn_into().unwrap_throw();
|
||||||
|
web_sys::console::log_1(&target.value().into());
|
||||||
target.value()
|
target.value()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Controlled Text Input Component
|
/// Controlled Text Input Component
|
||||||
#[function_component(TextInput)]
|
#[function_component(TextInput)]
|
||||||
pub fn text_input(props: &InputProps) -> Html {
|
pub fn text_input(props: &InputProps) -> Html {
|
||||||
let InputProps {
|
let InputProps { value, on_change } = props.clone();
|
||||||
value,
|
|
||||||
onchange,
|
|
||||||
class,
|
|
||||||
} = props.clone();
|
|
||||||
|
|
||||||
let oninput = Callback::from(move |input_event: InputEvent| {
|
let oninput = Callback::from(move |input_event: InputEvent| {
|
||||||
onchange.emit(get_value_from_input_event(input_event));
|
on_change.emit(get_value_from_input_event(input_event));
|
||||||
});
|
});
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
<input type="text" {class} {value} {oninput} />
|
<input type="text" class="mx-2 appearance-none block bg-gray-700 text-slate-400 border border-gray-600 rounded py-2 px-2 w-10 leading-tight focus:outline-none focus:ring-1 focus:ring-gray-500 focus:border-gray-500" {value} {oninput} />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,18 +47,3 @@ pub struct PageProps {
|
||||||
pub fn page(props: &PageProps) -> Html {
|
pub fn page(props: &PageProps) -> Html {
|
||||||
html! { <div class="max-w-7xl mx-auto">{ for props.children.iter() }</div> }
|
html! { <div class="max-w-7xl mx-auto">{ for props.children.iter() }</div> }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[function_component(Loading)]
|
|
||||||
pub fn loading() -> Html {
|
|
||||||
html! {
|
|
||||||
<svg role="status" class="inline h-8 w-8 animate-spin mr-2 text-gray-200 dark:text-gray-600 fill-gray-400"
|
|
||||||
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path
|
|
||||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
|
||||||
fill="currentColor" />
|
|
||||||
<path
|
|
||||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
|
||||||
fill="currentFill" />
|
|
||||||
</svg>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod components;
|
||||||
mod pages;
|
mod pages;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
use pages::{EventsPage, UsersPage};
|
use pages::UsersPage;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yew_router::prelude::*;
|
use yew_router::prelude::*;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ fn switch(routes: &Route) -> Html {
|
||||||
Route::Users => html! {
|
Route::Users => html! {
|
||||||
<UsersPage />
|
<UsersPage />
|
||||||
},
|
},
|
||||||
Route::Events => html! { <EventsPage /> },
|
Route::Events => html! { <h1>{ "Events" }</h1> },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
use crate::components::{Page, RenderEvent};
|
|
||||||
use yew::prelude::*;
|
|
||||||
use yew_hooks::*;
|
|
||||||
|
|
||||||
use crate::{clone, util::api_request};
|
|
||||||
|
|
||||||
#[function_component(EventsPage)]
|
|
||||||
pub fn events_page() -> Html {
|
|
||||||
let events: UseAsyncHandle<Vec<lan_party_core::event::Event>, _> = use_async(async move {
|
|
||||||
api_request::<_, Vec<lan_party_core::event::Event>>("GET", "/event", Option::<()>::None)
|
|
||||||
.await
|
|
||||||
.map(|inner| inner.unwrap())
|
|
||||||
.map_err(|_| "failed to load users")
|
|
||||||
});
|
|
||||||
|
|
||||||
clone!(events; use_effect_with_deps(move |_| {
|
|
||||||
if events.data.is_none() {
|
|
||||||
events.run();
|
|
||||||
}
|
|
||||||
|| ()
|
|
||||||
}, ()));
|
|
||||||
|
|
||||||
html! {
|
|
||||||
<Page>
|
|
||||||
{ if let Some(events) = &events.data {
|
|
||||||
events.view()
|
|
||||||
} else { html! {} }}
|
|
||||||
</Page>
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,3 @@
|
||||||
mod events;
|
|
||||||
mod users;
|
mod users;
|
||||||
|
|
||||||
pub use events::EventsPage;
|
|
||||||
pub use users::UsersPage;
|
pub use users::UsersPage;
|
||||||
|
|
|
@ -1,141 +1,107 @@
|
||||||
use crate::{
|
use crate::components::{Button, Page, Table, TextInput};
|
||||||
clone, clone_cb,
|
|
||||||
components::{Button, Loading, Page, Table, TextInput},
|
|
||||||
util::api_request,
|
|
||||||
};
|
|
||||||
use lan_party_core::user::User;
|
use lan_party_core::user::User;
|
||||||
use wasm_bindgen_futures::spawn_local;
|
use wasm_bindgen_futures::spawn_local;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yew_hooks::*;
|
|
||||||
|
|
||||||
#[function_component(UsersPage)]
|
#[derive(Debug, Default)]
|
||||||
pub fn users_page() -> Html {
|
pub struct UsersPage {
|
||||||
let headers = vec!["Username".into(), "Score".into(), "".into()];
|
headers: Vec<String>,
|
||||||
|
users: Vec<User>,
|
||||||
|
score_edit: Option<usize>,
|
||||||
|
current_score: String,
|
||||||
|
}
|
||||||
|
|
||||||
let new_username = use_state(|| String::new());
|
pub enum Msg {
|
||||||
let score_edit: UseStateHandle<Option<usize>> = use_state(|| Option::None);
|
UpdateList(Vec<User>),
|
||||||
let current_score = use_state(|| String::new());
|
UpdateScoreInput(String),
|
||||||
let users: UseAsyncHandle<Vec<User>, _> = use_async(async move {
|
UpdateScore(usize),
|
||||||
api_request::<_, Vec<User>>("GET", "/user", Option::<()>::None)
|
EditScore(usize),
|
||||||
.await
|
DeleteUser(usize),
|
||||||
.map(|inner| inner.unwrap())
|
}
|
||||||
.map_err(|_| "failed to load users")
|
|
||||||
});
|
|
||||||
|
|
||||||
clone!(users; use_effect_with_deps(move |_| {
|
impl Component for UsersPage {
|
||||||
if users.data.is_none() {
|
type Message = Msg;
|
||||||
users.run();
|
type Properties = ();
|
||||||
|
|
||||||
|
fn create(ctx: &Context<Self>) -> Self {
|
||||||
|
Self {
|
||||||
|
headers: vec!["Username".into(), "Score".into(), "".into()],
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|| ()
|
|
||||||
}, ()));
|
|
||||||
|
|
||||||
let oncheck = clone_cb!(score_edit, current_score, users; move |_| {
|
fn rendered(&mut self, ctx: &Context<Self>, first_render: bool) {
|
||||||
clone!(score_edit, users, current_score; {
|
let link = ctx.link().clone();
|
||||||
|
|
||||||
|
if first_render {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
if let (Some(score_edit), Some(users_inner)) = (*score_edit, &users.data) {
|
let res: Result<Vec<User>, _> =
|
||||||
if let Ok(score) = current_score.parse() {
|
crate::util::api_request("GET", "/user", Option::<()>::None).await;
|
||||||
let user: &User = &users_inner[score_edit];
|
link.send_message(Msg::UpdateList(res.unwrap()))
|
||||||
api_request::<_, ()>("POST", &format!("/user/{}/score", user.name), Some(score)).await.unwrap();
|
});
|
||||||
let mut cloned = users_inner.clone();
|
|
||||||
cloned[score_edit].score = score;
|
|
||||||
users.update(cloned);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
score_edit.set(None);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let onedit = clone_cb!(current_score, score_edit, users; i => move |_| {
|
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
|
||||||
if let Some(users) = &users.data {
|
match msg {
|
||||||
let user: &User = &users[i];
|
Msg::UpdateList(list) => {
|
||||||
current_score.set(user.score.to_string());
|
self.users = list;
|
||||||
score_edit.set(Some(i));
|
true
|
||||||
|
}
|
||||||
|
Msg::UpdateScoreInput(value) => {
|
||||||
|
self.current_score = value;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Msg::EditScore(i) => {
|
||||||
|
self.current_score = self.users[i].score.to_string();
|
||||||
|
self.score_edit = Some(i);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Msg::UpdateScore(i) => {
|
||||||
|
self.score_edit = None;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Msg::DeleteUser(i) => true,
|
||||||
|
_ => todo!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
let ondelete = clone_cb!(users; i => move |_| {
|
fn view(&self, ctx: &Context<Self>) -> Html {
|
||||||
clone!(users; {
|
let link = ctx.link().clone();
|
||||||
spawn_local(async move {
|
|
||||||
if let Some(users_inner) = &users.data {
|
|
||||||
let user: &User = &users_inner[i];
|
|
||||||
api_request::<_, ()>("DELETE", &format!("/user/{}", user.name), Option::<()>::None).await.unwrap();
|
|
||||||
let cloned = users_inner.iter().cloned().filter(|u| u.name != user.name).collect();
|
|
||||||
users.update(cloned);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let onadd = clone_cb!(new_username, users; move |_| {
|
|
||||||
clone!(new_username, users; {
|
|
||||||
spawn_local(async move {
|
|
||||||
if let Some(users_inner) = &users.data {
|
|
||||||
let user = api_request::<String, User>("POST", "/user", Some((*new_username).clone())).await.unwrap();
|
|
||||||
let mut cloned = users_inner.clone();
|
|
||||||
cloned.push(user.unwrap());
|
|
||||||
users.update(cloned);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
<Page>
|
<Page>
|
||||||
<Table headers={headers.clone()} loading=false rows={vec![]}>
|
<Table headers={self.headers.clone()} loading=false rows={vec![]}>
|
||||||
{ if let Some(users) = &users.data {
|
{self.users.iter().enumerate().map(|(i, user)| html! {
|
||||||
{users.iter().enumerate().map(move |(i, user)| html! {
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-slate-400">{&user.name}</td>
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-slate-400">{&user.name}</td>
|
||||||
<td class="whitespace-nowrap px-3 text-sm text-slate-400">
|
<td class="whitespace-nowrap px-3 text-sm text-slate-400">
|
||||||
{if Some(i) == *score_edit.clone() { html! {
|
{if Some(i) == self.score_edit { html! {
|
||||||
<>
|
<>
|
||||||
<span class="inline-block">
|
<span class="inline-block">
|
||||||
<TextInput
|
<TextInput
|
||||||
class={"mx-2 appearance-none block bg-gray-700 text-slate-400 border border-gray-600 rounded py-2 px-2 w-20 leading-tight focus:outline-none focus:ring-1 focus:ring-gray-500 focus:border-gray-500"}
|
on_change={link.callback(Msg::UpdateScoreInput)}
|
||||||
onchange={clone_cb!(current_score; move |value| current_score.set(value))}
|
value={self.current_score.clone()}
|
||||||
value={(*current_score).clone()}
|
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<Button icon={"mdi-check"} onclick={oncheck.clone()} />
|
<Button icon={"mdi-check"} onclick={link.callback(move |_| Msg::UpdateScore(i))} />
|
||||||
</>
|
</>
|
||||||
}} else { html! {
|
}} else { html! {
|
||||||
<>
|
<>
|
||||||
<span class="my-3 w-20">
|
<span class="my-3 w-20">
|
||||||
{user.score}
|
{user.score}
|
||||||
</span>
|
</span>
|
||||||
<Button icon={"mdi-pencil"} onclick={onedit.clone()(i)} />
|
<Button icon={"mdi-pencil"} onclick={link.callback(move |_| Msg::EditScore(i))} />
|
||||||
</>
|
</>
|
||||||
}}}
|
}}}
|
||||||
</td>
|
</td>
|
||||||
<td class="whitespace-nowrap py-4 text-sm text-slate-400">
|
<td class="whitespace-nowrap py-4 text-sm text-slate-400">
|
||||||
<Button icon={"mdi-delete"} onclick={ondelete.clone()(i)} />
|
<Button icon={"mdi-delete"} onclick={link.callback(move |_| Msg::DeleteUser(i))} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}).collect::<Html>()}
|
}).collect::<Html>()}
|
||||||
} else {
|
|
||||||
html! {
|
|
||||||
<div class="grid place-items-center">
|
|
||||||
<Loading />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
<tr>
|
|
||||||
<td class="whitespace-nowrap px-3 text-sm text-slate-400">
|
|
||||||
<span class="inline-block">
|
|
||||||
<TextInput
|
|
||||||
class={"mx-2 appearance-none block bg-gray-700 text-slate-400 border border-gray-600 rounded py-2 px-2 w-50 leading-tight focus:outline-none focus:ring-1 focus:ring-gray-500 focus:border-gray-500"}
|
|
||||||
onchange={clone_cb!(new_username; move |value| new_username.set(value))}
|
|
||||||
value={(*new_username).clone()}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-slate-400"></td>
|
|
||||||
<td class="whitespace-nowrap py-4 text-sm text-slate-400">
|
|
||||||
<Button icon={"mdi-plus"} onclick={onadd} />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</Table>
|
</Table>
|
||||||
</Page>
|
</Page>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,23 @@
|
||||||
use std::ops::Deref;
|
|
||||||
|
|
||||||
use anyhow::anyhow;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasm_bindgen::{prelude::*, JsCast};
|
use wasm_bindgen::{prelude::*, JsCast};
|
||||||
use wasm_bindgen_futures::JsFuture;
|
use wasm_bindgen_futures::JsFuture;
|
||||||
use web_sys::{Headers, Request, RequestInit, RequestMode, Response};
|
use web_sys::{Headers, Request, RequestInit, RequestMode, Response};
|
||||||
use yew::html::IntoPropValue;
|
|
||||||
|
|
||||||
#[derive(Error, Debug, Clone)]
|
#[derive(Error, Debug)]
|
||||||
pub enum JsError {
|
pub enum FetchError {
|
||||||
#[error("javascript error: {0}")]
|
#[error("javascript error")]
|
||||||
JsError(String),
|
JsError(JsValue),
|
||||||
|
#[error("failed to serialize json: {source:?}")]
|
||||||
|
SerializationError {
|
||||||
|
#[from]
|
||||||
|
source: serde_json::Error,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<JsValue> for JsError {
|
impl From<JsValue> for FetchError {
|
||||||
fn from(value: JsValue) -> Self {
|
fn from(value: JsValue) -> Self {
|
||||||
Self::JsError(
|
Self::JsError(value)
|
||||||
js_sys::JSON::stringify(&value)
|
|
||||||
.unwrap()
|
|
||||||
.as_string()
|
|
||||||
.unwrap(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,72 +25,29 @@ pub async fn api_request<B: Serialize, R: for<'a> Deserialize<'a>>(
|
||||||
method: &str,
|
method: &str,
|
||||||
endpoint: &str,
|
endpoint: &str,
|
||||||
body: Option<B>,
|
body: Option<B>,
|
||||||
) -> Result<Option<R>, anyhow::Error> {
|
) -> Result<R, FetchError> {
|
||||||
let api_key = "7de10bf6-278d-11ed-ad60-a8a15919d1b3";
|
let api_key = "7de10bf6-278d-11ed-ad60-a8a15919d1b3";
|
||||||
|
|
||||||
let mut req_opts = RequestInit::new();
|
let mut req_opts = RequestInit::new();
|
||||||
req_opts.method(method);
|
req_opts.method(method);
|
||||||
|
|
||||||
let headers = Headers::new().map_err(JsError::from)?;
|
let headers = Headers::new()?;
|
||||||
headers
|
headers.append("X-API-Key", api_key)?;
|
||||||
.append("X-API-Key", api_key)
|
|
||||||
.map_err(JsError::from)?;
|
|
||||||
req_opts.headers(&headers);
|
req_opts.headers(&headers);
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
let value = JsValue::from_serde(&body)?;
|
let value = JsValue::from_serde(&body)?;
|
||||||
req_opts.body(
|
req_opts.body(Some(&value));
|
||||||
js_sys::JSON::stringify(&value)
|
|
||||||
.ok()
|
|
||||||
.map(JsValue::from)
|
|
||||||
.as_ref(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
web_sys::console::log_1(&JsValue::from("here"));
|
|
||||||
|
|
||||||
let request = Request::new_with_str_and_init(
|
let request = Request::new_with_str_and_init(
|
||||||
&format!("http://localhost:8000/api/{}", endpoint),
|
&format!("http://localhost:8000/api/{}", endpoint),
|
||||||
&req_opts,
|
&req_opts,
|
||||||
)
|
)?;
|
||||||
.map_err(JsError::from)?;
|
|
||||||
|
|
||||||
let window = web_sys::window().unwrap();
|
let window = web_sys::window().unwrap();
|
||||||
let resp_value = JsFuture::from(window.fetch_with_request(&request))
|
let resp_value = JsFuture::from(window.fetch_with_request(&request)).await?;
|
||||||
.await
|
|
||||||
.map_err(JsError::from)?;
|
|
||||||
let resp: Response = resp_value.dyn_into().unwrap();
|
let resp: Response = resp_value.dyn_into().unwrap();
|
||||||
|
|
||||||
let json = resp.json().map_err(JsError::from)?;
|
Ok(JsFuture::from(resp.json()?).await?.into_serde()?)
|
||||||
|
|
||||||
if let Ok(data) = JsFuture::from(json).await.map_err(JsError::from) {
|
|
||||||
if let Ok(data) = data.into_serde() {
|
|
||||||
return Ok(Some(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! clone {
|
|
||||||
($($var:ident),* $(,)? ; $body:expr) => {{
|
|
||||||
$(let $var = $var.clone();)*
|
|
||||||
$body
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! clone_cb {
|
|
||||||
($($var:ident),* ; $body:expr) => {
|
|
||||||
clone!($($var,)* ; {
|
|
||||||
Callback::from($body)
|
|
||||||
})
|
|
||||||
};
|
|
||||||
($($var:ident),* ; $($param:ident),* => $body:expr) => {
|
|
||||||
clone!($($var,)* ; {
|
|
||||||
move |$($param,)*| {
|
|
||||||
Callback::from($body)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue