Browse Source

Add syntax highlighting in egui web fetch example

pull/92/head
Emil Ernerfeldt 4 years ago
parent
commit
07e96ca17f
  1. 160
      Cargo.lock
  2. 20
      docs/example.html
  3. 304
      docs/example_web.js
  4. BIN
      docs/example_web_bg.wasm
  5. 5
      docs/index.html
  6. 4
      egui_web/src/fetch.rs
  7. 3
      example_web/Cargo.toml
  8. 106
      example_web/src/example_app.rs

160
Cargo.lock

@ -38,6 +38,15 @@ dependencies = [
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
dependencies = [
"memchr",
]
[[package]]
name = "andrew"
version = "0.3.1"
@ -94,6 +103,37 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bincode"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d"
dependencies = [
"byteorder",
"serde",
]
[[package]]
name = "bit-set"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bitflags"
version = "1.2.1"
@ -648,9 +688,32 @@ dependencies = [
"js-sys",
"serde",
"serde_json",
"syntect",
"wasm-bindgen",
]
[[package]]
name = "fancy-regex"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae91abf6555234338687bb47913978d275539235fcb77ba9863b779090b42b14"
dependencies = [
"bit-set",
"regex",
]
[[package]]
name = "flate2"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129"
dependencies = [
"cfg-if 1.0.0",
"crc32fast",
"libc",
"miniz_oxide 0.4.3",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -821,6 +884,15 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177"
[[package]]
name = "hashbrown"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
dependencies = [
"autocfg",
]
[[package]]
name = "hermit-abi"
version = "0.1.17"
@ -852,6 +924,16 @@ dependencies = [
"png",
]
[[package]]
name = "indexmap"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e47a3566dd4fd4eec714ae6ceabdee0caec795be835c223d92c2d40f1e8cf1c"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "instant"
version = "0.1.9"
@ -953,6 +1035,21 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "line-wrap"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
dependencies = [
"safemem",
]
[[package]]
name = "linked-hash-map"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
name = "lock_api"
version = "0.4.2"
@ -1325,6 +1422,20 @@ version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "plist"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dc57ccf442c7414b790e8e7b72fb4d776a66c7680129360946d9aaa6f5311e9"
dependencies = [
"base64",
"chrono",
"indexmap",
"line-wrap",
"serde",
"xml-rs",
]
[[package]]
name = "plotters"
version = "0.2.15"
@ -1432,7 +1543,10 @@ version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
@ -1481,6 +1595,12 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "safemem"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
[[package]]
name = "same-file"
version = "1.0.6"
@ -1617,6 +1737,28 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "syntect"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5"
dependencies = [
"bincode",
"bitflags",
"fancy-regex",
"flate2",
"fnv",
"lazy_static",
"lazycell",
"plist",
"regex-syntax",
"serde",
"serde_derive",
"serde_json",
"walkdir",
"yaml-rust",
]
[[package]]
name = "takeable-option"
version = "0.5.0"
@ -1652,6 +1794,15 @@ dependencies = [
"syn",
]
[[package]]
name = "thread_local"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
dependencies = [
"lazy_static",
]
[[package]]
name = "time"
version = "0.1.44"
@ -2040,3 +2191,12 @@ name = "xml-rs"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"
[[package]]
name = "yaml-rust"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d"
dependencies = [
"linked-hash-map",
]

20
docs/example.html

@ -14,7 +14,7 @@
}
body {
background: #101010;
background: #202020;
}
/* Allow canvas to fill entire web page: */
@ -24,14 +24,22 @@
margin: 0 !important;
padding: 0 !important;
}
/* Center canvas vertically and horizontally: */
canvas {
margin-right: auto;
margin-left: auto;
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<!--
THis is where the app will show up.
The WASM code will resize this to cover the entire screen.
-->
<!-- The WASM code will resize this dynamically -->
<canvas id="the_canvas_id"></canvas>
<script>
@ -58,7 +66,7 @@
.then(on_wasm_loaded)["catch"](console.error);
function on_wasm_loaded() {
// This call installs a bunch of callbacks and then return
// This call installs a bunch of callbacks and then returns.
wasm_bindgen.start("the_canvas_id");
}
</script>

304
docs/example_web.js

@ -213,35 +213,35 @@ function makeMutClosure(arg0, arg1, dtor, f) {
return real;
}
function __wbg_adapter_26(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdf96b8ee714f1c46(arg0, arg1);
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha6040ef78a20dc3d(arg0, arg1);
}
function __wbg_adapter_29(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ab34346949ecee9(arg0, arg1, addHeapObject(arg2));
function __wbg_adapter_29(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb636d883df42a5fe(arg0, arg1);
}
function __wbg_adapter_32(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ab34346949ecee9(arg0, arg1, addHeapObject(arg2));
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h09606316665c66a3(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_35(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ab34346949ecee9(arg0, arg1, addHeapObject(arg2));
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h09606316665c66a3(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_38(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ab34346949ecee9(arg0, arg1, addHeapObject(arg2));
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h09606316665c66a3(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_41(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h48aae558e546c91e(arg0, arg1);
function __wbg_adapter_41(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h09606316665c66a3(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_44(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ab34346949ecee9(arg0, arg1, addHeapObject(arg2));
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h09606316665c66a3(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_47(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf7aa4fb686f03bd6(arg0, arg1, addHeapObject(arg2));
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h12005363cbd858d6(arg0, arg1, addHeapObject(arg2));
}
/**
@ -333,63 +333,63 @@ async function init(input) {
var ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_Window_adf3196bdc02b386 = function(arg0) {
imports.wbg.__wbg_instanceof_Window_49f532f06a9786ee = function(arg0) {
var ret = getObject(arg0) instanceof Window;
return ret;
};
imports.wbg.__wbg_document_6cc8d0b87c0a99b9 = function(arg0) {
imports.wbg.__wbg_document_c0366b39e4f4c89a = function(arg0) {
var ret = getObject(arg0).document;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_location_9b924f46d7090431 = function(arg0) {
imports.wbg.__wbg_location_c1e50a6e4c53d45c = function(arg0) {
var ret = getObject(arg0).location;
return addHeapObject(ret);
};
imports.wbg.__wbg_navigator_71c234326c0a2ebb = function(arg0) {
imports.wbg.__wbg_navigator_95ba9cd684cf90aa = function(arg0) {
var ret = getObject(arg0).navigator;
return addHeapObject(ret);
};
imports.wbg.__wbg_innerWidth_60241abd729ed26f = handleError(function(arg0) {
imports.wbg.__wbg_innerWidth_cea04a991524ea87 = handleError(function(arg0) {
var ret = getObject(arg0).innerWidth;
return addHeapObject(ret);
});
imports.wbg.__wbg_innerHeight_2f860a67225f1fbd = handleError(function(arg0) {
imports.wbg.__wbg_innerHeight_83651dca462998d1 = handleError(function(arg0) {
var ret = getObject(arg0).innerHeight;
return addHeapObject(ret);
});
imports.wbg.__wbg_devicePixelRatio_599d41a9267fa1ca = function(arg0) {
imports.wbg.__wbg_devicePixelRatio_268c49438a600d53 = function(arg0) {
var ret = getObject(arg0).devicePixelRatio;
return ret;
};
imports.wbg.__wbg_performance_8594a974edffb1dc = function(arg0) {
imports.wbg.__wbg_performance_87e4f3b6f966469f = function(arg0) {
var ret = getObject(arg0).performance;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_localStorage_47e8ad68b9e5dcb9 = handleError(function(arg0) {
imports.wbg.__wbg_localStorage_a6fd83fc300473fc = handleError(function(arg0) {
var ret = getObject(arg0).localStorage;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
});
imports.wbg.__wbg_open_7e3a4789bd559091 = handleError(function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_open_f355af0fd051a9d8 = handleError(function(arg0, arg1, arg2, arg3, arg4) {
var ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
});
imports.wbg.__wbg_requestAnimationFrame_89935c9d6ac25d2f = handleError(function(arg0, arg1) {
imports.wbg.__wbg_requestAnimationFrame_ef0e2294dc8b1088 = handleError(function(arg0, arg1) {
var ret = getObject(arg0).requestAnimationFrame(getObject(arg1));
return ret;
});
imports.wbg.__wbg_fetch_91f098921cc7cca8 = function(arg0, arg1) {
imports.wbg.__wbg_fetch_f532e04b8fe49aa0 = function(arg0, arg1) {
var ret = getObject(arg0).fetch(getObject(arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_setInterval_06df6f1ebeafd66f = handleError(function(arg0, arg1, arg2) {
imports.wbg.__wbg_setInterval_a7f9e1aa48a6feb8 = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).setInterval(getObject(arg1), arg2);
return ret;
});
imports.wbg.__wbg_body_8c888fe47d81765f = function(arg0) {
imports.wbg.__wbg_body_c8cb19d760637268 = function(arg0) {
var ret = getObject(arg0).body;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_getElementById_0cb6ad9511b1efc0 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_getElementById_15aef17a620252b4 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
@ -397,393 +397,393 @@ async function init(input) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_setProperty_42eabadfcd7d6199 = handleError(function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_setProperty_46b9bd1b0fad730b = handleError(function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
});
imports.wbg.__wbg_addEventListener_9e7b0c3f65ebc0d7 = handleError(function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_addEventListener_6a37bc32387cb66d = handleError(function(arg0, arg1, arg2, arg3) {
getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
});
imports.wbg.__wbg_getItem_cb17cd47353971da = handleError(function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_getItem_400dba7536e6a1d8 = handleError(function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg1).getItem(getStringFromWasm0(arg2, arg3));
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_setItem_71df4161bb87d575 = handleError(function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_setItem_57767b71f09c3545 = handleError(function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).setItem(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
});
imports.wbg.__wbg_writeText_f87e9b63346a7e47 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_writeText_f3dba2a1b4785c80 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).writeText(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
};
imports.wbg.__wbg_get_d015313eb9359d3a = handleError(function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_get_f7c7868f719f98ec = handleError(function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg1).get(getStringFromWasm0(arg2, arg3));
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_set_e0c72ee4d5eea3d5 = handleError(function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_set_76c6c83392bce553 = handleError(function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
});
imports.wbg.__wbg_deltaX_ee242e8414135d41 = function(arg0) {
imports.wbg.__wbg_deltaX_5fac4f36a42e6ec9 = function(arg0) {
var ret = getObject(arg0).deltaX;
return ret;
};
imports.wbg.__wbg_deltaY_35bf8632b9f25820 = function(arg0) {
imports.wbg.__wbg_deltaY_2722120e563d3160 = function(arg0) {
var ret = getObject(arg0).deltaY;
return ret;
};
imports.wbg.__wbg_instanceof_Response_328c03967a8e8902 = function(arg0) {
imports.wbg.__wbg_instanceof_Response_f52c65c389890639 = function(arg0) {
var ret = getObject(arg0) instanceof Response;
return ret;
};
imports.wbg.__wbg_url_67bbdafba8ff6e85 = function(arg0, arg1) {
imports.wbg.__wbg_url_87c62d9fe8f97de1 = function(arg0, arg1) {
var ret = getObject(arg1).url;
var ptr0 = 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_status_eb6dbb31556c329f = function(arg0) {
imports.wbg.__wbg_status_f3cb2b4d20a23f59 = function(arg0) {
var ret = getObject(arg0).status;
return ret;
};
imports.wbg.__wbg_ok_7f500542a5af3b60 = function(arg0) {
imports.wbg.__wbg_ok_c20643e0a45dc5a0 = function(arg0) {
var ret = getObject(arg0).ok;
return ret;
};
imports.wbg.__wbg_statusText_99a522577dbca4cb = function(arg0, arg1) {
imports.wbg.__wbg_statusText_76ce672b84096caf = function(arg0, arg1) {
var ret = getObject(arg1).statusText;
var ptr0 = 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_headers_c736e1fe38752cff = function(arg0) {
imports.wbg.__wbg_headers_6fafb2c7669a8ac5 = function(arg0) {
var ret = getObject(arg0).headers;
return addHeapObject(ret);
};
imports.wbg.__wbg_arrayBuffer_dc33ab7b8cdf0d63 = handleError(function(arg0) {
imports.wbg.__wbg_arrayBuffer_0ba17dfaad804b6f = handleError(function(arg0) {
var ret = getObject(arg0).arrayBuffer();
return addHeapObject(ret);
});
imports.wbg.__wbg_now_49847177a6d1d57e = function(arg0) {
imports.wbg.__wbg_now_7628760b7b640632 = function(arg0) {
var ret = getObject(arg0).now();
return ret;
};
imports.wbg.__wbg_headers_d4301f4888b4640a = function(arg0) {
imports.wbg.__wbg_headers_5f70b64960218e2f = function(arg0) {
var ret = getObject(arg0).headers;
return addHeapObject(ret);
};
imports.wbg.__wbg_newwithstrandinit_d1de1bfcd175e38a = handleError(function(arg0, arg1, arg2) {
imports.wbg.__wbg_newwithstrandinit_11debb554792e043 = handleError(function(arg0, arg1, arg2) {
var ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
return addHeapObject(ret);
});
imports.wbg.__wbg_instanceof_HtmlCanvasElement_4f5b5ec6cd53ccf3 = function(arg0) {
imports.wbg.__wbg_instanceof_HtmlCanvasElement_7bd3ee7838f11fc3 = function(arg0) {
var ret = getObject(arg0) instanceof HTMLCanvasElement;
return ret;
};
imports.wbg.__wbg_width_a22f9855caa54b53 = function(arg0) {
imports.wbg.__wbg_width_0efa4604d41c58c5 = function(arg0) {
var ret = getObject(arg0).width;
return ret;
};
imports.wbg.__wbg_setwidth_5f26a8ba9dbfa0d0 = function(arg0, arg1) {
imports.wbg.__wbg_setwidth_1d0e975feecff3ef = function(arg0, arg1) {
getObject(arg0).width = arg1 >>> 0;
};
imports.wbg.__wbg_height_9a404a6b3c61c7ef = function(arg0) {
imports.wbg.__wbg_height_aa24e3fef658c4a8 = function(arg0) {
var ret = getObject(arg0).height;
return ret;
};
imports.wbg.__wbg_setheight_70f62727aa9383c2 = function(arg0, arg1) {
imports.wbg.__wbg_setheight_7758ee3ff5c65474 = function(arg0, arg1) {
getObject(arg0).height = arg1 >>> 0;
};
imports.wbg.__wbg_getContext_37ca0870acb096d9 = handleError(function(arg0, arg1, arg2) {
imports.wbg.__wbg_getContext_3db9399e6dc524ff = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
});
imports.wbg.__wbg_pageX_234547d8f89fd3d0 = function(arg0) {
imports.wbg.__wbg_pageX_7d397506a4ad73f2 = function(arg0) {
var ret = getObject(arg0).pageX;
return ret;
};
imports.wbg.__wbg_pageY_4f94b607e8f1a8a2 = function(arg0) {
imports.wbg.__wbg_pageY_83f6542b172abf6f = function(arg0) {
var ret = getObject(arg0).pageY;
return ret;
};
imports.wbg.__wbg_clipboardData_d3dc621a701f9c49 = function(arg0) {
imports.wbg.__wbg_clipboardData_503a7e4407c6231c = function(arg0) {
var ret = getObject(arg0).clipboardData;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_getData_0a2347233cf89d01 = handleError(function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_getData_10c8cb329803d2b8 = handleError(function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg1).getData(getStringFromWasm0(arg2, arg3));
var ptr0 = 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_keyCode_689d196ab65a93d7 = function(arg0) {
imports.wbg.__wbg_keyCode_47f9e9228bc483bf = function(arg0) {
var ret = getObject(arg0).keyCode;
return ret;
};
imports.wbg.__wbg_altKey_1b58e09f218a0f4b = function(arg0) {
imports.wbg.__wbg_altKey_8a59e1cf32636010 = function(arg0) {
var ret = getObject(arg0).altKey;
return ret;
};
imports.wbg.__wbg_ctrlKey_f080ec163dcc2703 = function(arg0) {
imports.wbg.__wbg_ctrlKey_17377b46ca5a072d = function(arg0) {
var ret = getObject(arg0).ctrlKey;
return ret;
};
imports.wbg.__wbg_shiftKey_d11f615955404512 = function(arg0) {
imports.wbg.__wbg_shiftKey_09be9a7e6cad7a99 = function(arg0) {
var ret = getObject(arg0).shiftKey;
return ret;
};
imports.wbg.__wbg_metaKey_9bc40bb1d5972ef2 = function(arg0) {
imports.wbg.__wbg_metaKey_a707288e6c45a0e0 = function(arg0) {
var ret = getObject(arg0).metaKey;
return ret;
};
imports.wbg.__wbg_isComposing_c0f97b8c3f5992b5 = function(arg0) {
imports.wbg.__wbg_isComposing_15a35cffb04ab10f = function(arg0) {
var ret = getObject(arg0).isComposing;
return ret;
};
imports.wbg.__wbg_key_590d4d2a765d1b58 = function(arg0, arg1) {
imports.wbg.__wbg_key_d9b602f48baca7bc = function(arg0, arg1) {
var ret = getObject(arg1).key;
var ptr0 = 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_get_814461b8584a55e7 = function(arg0, arg1) {
imports.wbg.__wbg_get_3315e8e7e59a2c40 = function(arg0, arg1) {
var ret = getObject(arg0)[arg1 >>> 0];
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_getBoundingClientRect_c6d612c06726983e = function(arg0) {
imports.wbg.__wbg_getBoundingClientRect_505844bd8eb35668 = function(arg0) {
var ret = getObject(arg0).getBoundingClientRect();
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_WebGlRenderingContext_a37cc8c6016098e4 = function(arg0) {
imports.wbg.__wbg_instanceof_WebGlRenderingContext_ef4e51c6e4133d85 = function(arg0) {
var ret = getObject(arg0) instanceof WebGLRenderingContext;
return ret;
};
imports.wbg.__wbg_bufferData_0690087420a9f115 = function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_bufferData_dc5899657e9f1803 = function(arg0, arg1, arg2, arg3) {
getObject(arg0).bufferData(arg1 >>> 0, getObject(arg2), arg3 >>> 0);
};
imports.wbg.__wbg_texImage2D_8d677a54ab75452c = handleError(function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
imports.wbg.__wbg_texImage2D_a4011abffe0229fb = handleError(function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10));
});
imports.wbg.__wbg_activeTexture_7246ae8c464868b4 = function(arg0, arg1) {
imports.wbg.__wbg_activeTexture_a51ec6273de88bc6 = function(arg0, arg1) {
getObject(arg0).activeTexture(arg1 >>> 0);
};
imports.wbg.__wbg_attachShader_d213e7ecd3432f4a = function(arg0, arg1, arg2) {
imports.wbg.__wbg_attachShader_0dd248f6ab98fcf2 = function(arg0, arg1, arg2) {
getObject(arg0).attachShader(getObject(arg1), getObject(arg2));
};
imports.wbg.__wbg_bindBuffer_f0ba4bbfd5b08434 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_bindBuffer_1ceb83e9674e812a = function(arg0, arg1, arg2) {
getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2));
};
imports.wbg.__wbg_bindTexture_c00656e6f0530ee7 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_bindTexture_6121e6db3f879582 = function(arg0, arg1, arg2) {
getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2));
};
imports.wbg.__wbg_blendFunc_c7c9cda2a0e4b97f = function(arg0, arg1, arg2) {
imports.wbg.__wbg_blendFunc_34a6bb31770822c5 = function(arg0, arg1, arg2) {
getObject(arg0).blendFunc(arg1 >>> 0, arg2 >>> 0);
};
imports.wbg.__wbg_clear_c9cc14c37d12a838 = function(arg0, arg1) {
imports.wbg.__wbg_clear_f6b2dd48aeed2752 = function(arg0, arg1) {
getObject(arg0).clear(arg1 >>> 0);
};
imports.wbg.__wbg_clearColor_73695d8d401f87e6 = function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_clearColor_89f7819aa9f80129 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).clearColor(arg1, arg2, arg3, arg4);
};
imports.wbg.__wbg_compileShader_961db910485f4a76 = function(arg0, arg1) {
imports.wbg.__wbg_compileShader_28bdbafe4445d24b = function(arg0, arg1) {
getObject(arg0).compileShader(getObject(arg1));
};
imports.wbg.__wbg_createBuffer_4deb008968921e7f = function(arg0) {
imports.wbg.__wbg_createBuffer_acedc3831832a280 = function(arg0) {
var ret = getObject(arg0).createBuffer();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_createProgram_b502951c403f671a = function(arg0) {
imports.wbg.__wbg_createProgram_7e2f44b7b74694d4 = function(arg0) {
var ret = getObject(arg0).createProgram();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_createShader_7bd4296ba9c32133 = function(arg0, arg1) {
imports.wbg.__wbg_createShader_64c474f1d1d0c1f8 = function(arg0, arg1) {
var ret = getObject(arg0).createShader(arg1 >>> 0);
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_createTexture_e0437703d5b41f24 = function(arg0) {
imports.wbg.__wbg_createTexture_0a156dab1efc3499 = function(arg0) {
var ret = getObject(arg0).createTexture();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_disable_6d4d32f05b00518e = function(arg0, arg1) {
imports.wbg.__wbg_disable_5b9c6f74d5efd3a5 = function(arg0, arg1) {
getObject(arg0).disable(arg1 >>> 0);
};
imports.wbg.__wbg_drawElements_b22db7173101346e = function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_drawElements_3eb5ba8a511ce0f0 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).drawElements(arg1 >>> 0, arg2, arg3 >>> 0, arg4);
};
imports.wbg.__wbg_enable_700dbd1724c67920 = function(arg0, arg1) {
imports.wbg.__wbg_enable_87f39f6396535e1f = function(arg0, arg1) {
getObject(arg0).enable(arg1 >>> 0);
};
imports.wbg.__wbg_enableVertexAttribArray_4b6614b028d442ff = function(arg0, arg1) {
imports.wbg.__wbg_enableVertexAttribArray_f29c8dde9c8c5cf5 = function(arg0, arg1) {
getObject(arg0).enableVertexAttribArray(arg1 >>> 0);
};
imports.wbg.__wbg_getAttribLocation_98ff7fc515cda07d = function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_getAttribLocation_ba61f837da80e249 = function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3));
return ret;
};
imports.wbg.__wbg_getProgramInfoLog_a84afc629d343c75 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_getProgramInfoLog_aacf06c959070653 = function(arg0, arg1, arg2) {
var ret = getObject(arg1).getProgramInfoLog(getObject(arg2));
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_getProgramParameter_327111ebb2bca7fb = function(arg0, arg1, arg2) {
imports.wbg.__wbg_getProgramParameter_a89bf14502c109f7 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_getShaderInfoLog_a9529ee3f2ebd3e0 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_getShaderInfoLog_1eb885f2468e2429 = function(arg0, arg1, arg2) {
var ret = getObject(arg1).getShaderInfoLog(getObject(arg2));
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_getShaderParameter_d7853b2d4822ad9f = function(arg0, arg1, arg2) {
imports.wbg.__wbg_getShaderParameter_99510442d33c6589 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_getUniformLocation_55700686ebe625a9 = function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_getUniformLocation_ca853de4f2f9270d = function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_linkProgram_7c29f15a5150d174 = function(arg0, arg1) {
imports.wbg.__wbg_linkProgram_46a36cb158f10676 = function(arg0, arg1) {
getObject(arg0).linkProgram(getObject(arg1));
};
imports.wbg.__wbg_scissor_5d19639b621ab86f = function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_scissor_59172d697cc43dc8 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).scissor(arg1, arg2, arg3, arg4);
};
imports.wbg.__wbg_shaderSource_bf6be2cc97a14fc1 = function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_shaderSource_700ae72fca39850d = function(arg0, arg1, arg2, arg3) {
getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3));
};
imports.wbg.__wbg_texParameteri_c9ce5bb9e350c6cd = function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_texParameteri_e45f3977eb998137 = function(arg0, arg1, arg2, arg3) {
getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
};
imports.wbg.__wbg_uniform1i_bbbce4278738d73e = function(arg0, arg1, arg2) {
imports.wbg.__wbg_uniform1i_e76b668973ae0655 = function(arg0, arg1, arg2) {
getObject(arg0).uniform1i(getObject(arg1), arg2);
};
imports.wbg.__wbg_uniform2f_aaa7fe970579cfd3 = function(arg0, arg1, arg2, arg3) {
imports.wbg.__wbg_uniform2f_6298542797865c61 = function(arg0, arg1, arg2, arg3) {
getObject(arg0).uniform2f(getObject(arg1), arg2, arg3);
};
imports.wbg.__wbg_useProgram_51f7808f5955c03a = function(arg0, arg1) {
imports.wbg.__wbg_useProgram_d63a57db0571e803 = function(arg0, arg1) {
getObject(arg0).useProgram(getObject(arg1));
};
imports.wbg.__wbg_vertexAttribPointer_76ddec1ed8425967 = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
imports.wbg.__wbg_vertexAttribPointer_b4b829a4f5a3778e = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6);
};
imports.wbg.__wbg_viewport_dd0dedc488a8dba4 = function(arg0, arg1, arg2, arg3, arg4) {
imports.wbg.__wbg_viewport_54305c74f5668b33 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).viewport(arg1, arg2, arg3, arg4);
};
imports.wbg.__wbg_log_3bafd82835c6de6d = function(arg0) {
console.log(getObject(arg0));
imports.wbg.__wbg_error_e325755affc8634b = function(arg0) {
console.error(getObject(arg0));
};
imports.wbg.__wbg_warn_d05e82888b7fad05 = function(arg0) {
imports.wbg.__wbg_warn_9e92ccdc67085e1b = function(arg0) {
console.warn(getObject(arg0));
};
imports.wbg.__wbg_style_9a41d46c005f7596 = function(arg0) {
imports.wbg.__wbg_style_9b773f0fc441eddc = function(arg0) {
var ret = getObject(arg0).style;
return addHeapObject(ret);
};
imports.wbg.__wbg_preventDefault_93d06688748bfc14 = function(arg0) {
imports.wbg.__wbg_preventDefault_9aab6c264e5df3ee = function(arg0) {
getObject(arg0).preventDefault();
};
imports.wbg.__wbg_stopPropagation_a47dd3b6ffe6b400 = function(arg0) {
imports.wbg.__wbg_stopPropagation_697200010cec9b7e = function(arg0) {
getObject(arg0).stopPropagation();
};
imports.wbg.__wbg_touches_1cfb9ad18bd08588 = function(arg0) {
imports.wbg.__wbg_touches_3d22a22deb0f5409 = function(arg0) {
var ret = getObject(arg0).touches;
return addHeapObject(ret);
};
imports.wbg.__wbg_top_a6f8db7db6d2bf17 = function(arg0) {
imports.wbg.__wbg_top_80a2533bf82e7a3e = function(arg0) {
var ret = getObject(arg0).top;
return ret;
};
imports.wbg.__wbg_left_b19dce37a1320f04 = function(arg0) {
imports.wbg.__wbg_left_479514b443c100f4 = function(arg0) {
var ret = getObject(arg0).left;
return ret;
};
imports.wbg.__wbg_clipboard_7862c97f3561ff94 = function(arg0) {
imports.wbg.__wbg_clipboard_a2f55b432ef7d0b0 = function(arg0) {
var ret = getObject(arg0).clipboard;
return addHeapObject(ret);
};
imports.wbg.__wbg_hash_1e68d402e53cef74 = handleError(function(arg0, arg1) {
imports.wbg.__wbg_hash_6e2c452e02822d19 = handleError(function(arg0, arg1) {
var ret = getObject(arg1).hash;
var ptr0 = 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_clientX_c1a2c3a6a07188a2 = function(arg0) {
imports.wbg.__wbg_clientX_3a14a1583294607f = function(arg0) {
var ret = getObject(arg0).clientX;
return ret;
};
imports.wbg.__wbg_clientY_090f8ba07f76875d = function(arg0) {
imports.wbg.__wbg_clientY_4b4a322b80551002 = function(arg0) {
var ret = getObject(arg0).clientY;
return ret;
};
imports.wbg.__wbg_call_8e95613cc6524977 = handleError(function(arg0, arg1) {
imports.wbg.__wbg_call_951bd0c6d815d6f1 = handleError(function(arg0, arg1) {
var ret = getObject(arg0).call(getObject(arg1));
return addHeapObject(ret);
});
imports.wbg.__wbg_newnoargs_f3b8a801d5d4b079 = function(arg0, arg1) {
imports.wbg.__wbg_newnoargs_7c6bd521992b4022 = function(arg0, arg1) {
var ret = new Function(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_getHours_551ae9f419d47a3b = function(arg0) {
imports.wbg.__wbg_getHours_3dd5c65c39f8b9b6 = function(arg0) {
var ret = getObject(arg0).getHours();
return ret;
};
imports.wbg.__wbg_getMilliseconds_c188d73c551e97d1 = function(arg0) {
imports.wbg.__wbg_getMilliseconds_6a8f7d8a5dae61b1 = function(arg0) {
var ret = getObject(arg0).getMilliseconds();
return ret;
};
imports.wbg.__wbg_getMinutes_054a5442be4b9aa6 = function(arg0) {
imports.wbg.__wbg_getMinutes_37175b451da6ea22 = function(arg0) {
var ret = getObject(arg0).getMinutes();
return ret;
};
imports.wbg.__wbg_getSeconds_9cda850b6648721a = function(arg0) {
imports.wbg.__wbg_getSeconds_cea5a5592039b5ba = function(arg0) {
var ret = getObject(arg0).getSeconds();
return ret;
};
imports.wbg.__wbg_new0_a3af66503e735141 = function() {
imports.wbg.__wbg_new0_abd359df4aeb5b55 = function() {
var ret = new Date();
return addHeapObject(ret);
};
imports.wbg.__wbg_new_3e06d4f36713e4cb = function() {
imports.wbg.__wbg_new_ba07d0daa0e4677e = function() {
var ret = new Object();
return addHeapObject(ret);
};
imports.wbg.__wbg_resolve_2529512c3bb73938 = function(arg0) {
imports.wbg.__wbg_resolve_6e61e640925a0db9 = function(arg0) {
var ret = Promise.resolve(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_then_4a7a614abbbe6d81 = function(arg0, arg1) {
imports.wbg.__wbg_then_dd3785597974798a = function(arg0, arg1) {
var ret = getObject(arg0).then(getObject(arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_then_3b7ac098cfda2fa5 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_then_0f957e0f4c3e537a = function(arg0, arg1, arg2) {
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
return addHeapObject(ret);
};
imports.wbg.__wbg_self_07b2f89e82ceb76d = handleError(function() {
imports.wbg.__wbg_self_6baf3a3aa7b63415 = handleError(function() {
var ret = self.self;
return addHeapObject(ret);
});
imports.wbg.__wbg_window_ba85d88572adc0dc = handleError(function() {
imports.wbg.__wbg_window_63fc4027b66c265b = handleError(function() {
var ret = window.window;
return addHeapObject(ret);
});
imports.wbg.__wbg_globalThis_b9277fc37e201fe5 = handleError(function() {
imports.wbg.__wbg_globalThis_513fb247e8e4e6d2 = handleError(function() {
var ret = globalThis.globalThis;
return addHeapObject(ret);
});
imports.wbg.__wbg_global_e16303fe83e1d57f = handleError(function() {
imports.wbg.__wbg_global_b87245cd886d7113 = handleError(function() {
var ret = global.global;
return addHeapObject(ret);
});
@ -791,46 +791,46 @@ async function init(input) {
var ret = getObject(arg0) === undefined;
return ret;
};
imports.wbg.__wbg_buffer_49131c283a06686f = function(arg0) {
imports.wbg.__wbg_buffer_3f12a1c608c6d04e = function(arg0) {
var ret = getObject(arg0).buffer;
return addHeapObject(ret);
};
imports.wbg.__wbg_new_20cc9c1e8e319ac2 = function(arg0) {
imports.wbg.__wbg_new_b43247aed67bdcb6 = function(arg0) {
var ret = new Int16Array(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_new_9b295d24cf1d706f = function(arg0) {
imports.wbg.__wbg_new_c6c0228e6d22a2f9 = function(arg0) {
var ret = new Uint8Array(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_set_3bb960a9975f3cd2 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_set_b91afac9fd216d99 = function(arg0, arg1, arg2) {
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
};
imports.wbg.__wbg_length_2b13641a9d906653 = function(arg0) {
imports.wbg.__wbg_length_c645e7c02233b440 = function(arg0) {
var ret = getObject(arg0).length;
return ret;
};
imports.wbg.__wbg_new_79f4487112eba5a7 = function(arg0) {
imports.wbg.__wbg_new_2863e4d532e8dfb4 = function(arg0) {
var ret = new Float32Array(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_subarray_4cf58941ccdff8e8 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_subarray_099195a64c29d8a3 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_subarray_4eaeb3de00cf1955 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_subarray_02e2fcfa6b285cb2 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_subarray_f5aa665f0873e6e8 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_subarray_f5deb93e9cb33975 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_Memory_8d2ddec6afb83aaa = function(arg0) {
imports.wbg.__wbg_instanceof_Memory_fdb0928d3f70cd49 = function(arg0) {
var ret = getObject(arg0) instanceof WebAssembly.Memory;
return ret;
};
imports.wbg.__wbg_set_304f2ec1a3ab3b79 = handleError(function(arg0, arg1, arg2) {
imports.wbg.__wbg_set_9bdd413385146137 = handleError(function(arg0, arg1, arg2) {
var ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
return ret;
});
@ -870,36 +870,36 @@ async function init(input) {
var ret = wasm.memory;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper747 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 211, __wbg_adapter_26);
imports.wbg.__wbindgen_closure_wrapper1679 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 450, __wbg_adapter_26);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper748 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 211, __wbg_adapter_29);
imports.wbg.__wbindgen_closure_wrapper1680 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 450, __wbg_adapter_29);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper750 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 211, __wbg_adapter_32);
imports.wbg.__wbindgen_closure_wrapper1682 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 450, __wbg_adapter_32);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper752 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 211, __wbg_adapter_35);
imports.wbg.__wbindgen_closure_wrapper1684 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 450, __wbg_adapter_35);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper754 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 211, __wbg_adapter_38);
imports.wbg.__wbindgen_closure_wrapper1686 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 450, __wbg_adapter_38);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper756 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 211, __wbg_adapter_41);
imports.wbg.__wbindgen_closure_wrapper1688 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 450, __wbg_adapter_41);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper759 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 211, __wbg_adapter_44);
imports.wbg.__wbindgen_closure_wrapper1691 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 450, __wbg_adapter_44);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper1498 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 251, __wbg_adapter_47);
imports.wbg.__wbindgen_closure_wrapper2574 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 530, __wbg_adapter_47);
return addHeapObject(ret);
};

BIN
docs/example_web_bg.wasm

Binary file not shown.

5
docs/index.html

@ -14,6 +14,7 @@
}
body {
/* Background color for what is not covered by the canvas, and where the canvas is translucent. */
background: #202020;
}
@ -39,7 +40,7 @@
</head>
<body>
<!-- The WASM code will resize this to cover the entire screen -->
<!-- The WASM code will resize this dynamically -->
<canvas id="the_canvas_id"></canvas>
<script>
@ -66,7 +67,7 @@
.then(on_wasm_loaded)["catch"](console.error);
function on_wasm_loaded() {
// This call installs a bunch of callbacks and then return
// This call installs a bunch of callbacks and then returns.
wasm_bindgen.start("the_canvas_id");
}
</script>

4
egui_web/src/fetch.rs

@ -67,7 +67,9 @@ async fn fetch_jsvalue(method: &str, url: &str) -> Result<Response, JsValue> {
.flatten()
.unwrap_or_default();
let text = if header_content_type.starts_with("text") {
let text = if header_content_type.starts_with("text")
|| header_content_type == "application/javascript"
{
String::from_utf8(bytes.clone()).ok()
} else {
None

3
example_web/Cargo.toml

@ -11,8 +11,9 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
egui = { path = "../egui", features = ["serde"] }
egui_web = { path = "../egui_web" }
image = { version = "0.23", default_features=false, features=["jpeg", "png"] }
image = { version = "0.23", default_features = false, features = ["jpeg", "png"] }
js-sys = "0.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
syntect = { version = "4", default_features = false, features = ["default-fancy"] }
wasm-bindgen = "0.2"

106
example_web/src/example_app.rs

@ -7,6 +7,9 @@ struct Resource {
/// If set, the response was an image.
image: Option<Image>,
/// If set, the response was text with some supported syntax highlighting (e.g. ".rs" or ".md").
colored_text: Option<ColoredText>,
}
impl Resource {
@ -16,7 +19,14 @@ impl Resource {
} else {
None
};
Self { response, image }
let colored_text = syntax_highlighting(&response);
Self {
response,
image,
colored_text,
}
}
}
@ -55,17 +65,16 @@ impl egui::app::App for ExampleApp {
}
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Egui Example App");
ui.heading("Egui Fetch Example");
ui.add(egui::github_link_file!(
"https://github.com/emilk/egui/blob/master/",
"(source code)"
));
if ui_url(ui, &mut self.url) {
if let Some(url) = ui_url(ui, &mut self.url) {
let repaint_signal = integration_context.repaint_signal.clone();
let (sender, receiver) = std::sync::mpsc::channel();
self.in_progress = Some(receiver);
let url = self.url.clone();
egui_web::spawn_future(async move {
sender.send(egui_web::fetch::get(&url).await).ok();
repaint_signal.request_repaint();
@ -91,7 +100,7 @@ impl egui::app::App for ExampleApp {
}
}
fn ui_url(ui: &mut egui::Ui, url: &mut String) -> bool {
fn ui_url(ui: &mut egui::Ui, url: &mut String) -> Option<String> {
let mut trigger_fetch = false;
ui.horizontal(|ui| {
@ -100,6 +109,8 @@ fn ui_url(ui: &mut egui::Ui, url: &mut String) -> bool {
trigger_fetch |= ui.button("GET").clicked;
});
ui.label("HINT: paste the url of this page into the field above!");
ui.horizontal(|ui| {
if ui.button("Source code for this example").clicked {
*url = format!(
@ -117,7 +128,11 @@ fn ui_url(ui: &mut egui::Ui, url: &mut String) -> bool {
}
});
trigger_fetch
if trigger_fetch {
Some(url.clone())
} else {
None
}
}
fn ui_resouce(
@ -126,7 +141,11 @@ fn ui_resouce(
tex_mngr: &mut TexMngr,
resource: &Resource,
) {
let Resource { response, image } = resource;
let Resource {
response,
image,
colored_text,
} = resource;
ui.monospace(format!("url: {}", response.url));
ui.monospace(format!(
@ -139,26 +158,89 @@ fn ui_resouce(
response.bytes.len() as f32 / 1000.0
));
if let Some(text) = &response.text {
let tooltip = "Click to copy the response body";
if ui.button("📋").on_hover_text(tooltip).clicked {
ui.output().copied_text = text.clone();
}
}
ui.separator();
egui::ScrollArea::auto_sized().show(ui, |ui| {
if let Some(image) = image {
if let Some(texture_id) = tex_mngr.texture(integration_context, &response.url, &image) {
let size = egui::Vec2::new(image.size.0 as f32, image.size.1 as f32);
ui.image(texture_id, size);
}
} else if let Some(colored_text) = colored_text {
colored_text.ui(ui);
} else if let Some(text) = &response.text {
ui.monospace("Body:");
ui.separator();
egui::ScrollArea::auto_sized().show(ui, |ui| {
ui.monospace(text);
});
} else {
ui.monospace("[binary]");
}
});
}
// ----------------------------------------------------------------------------
// Syntax highlighting:
fn syntax_highlighting(response: &Response) -> Option<ColoredText> {
let text = response.text.as_ref()?;
let extension_and_rest: Vec<&str> = response.url.rsplitn(2, '.').collect();
let extension = extension_and_rest.get(0)?;
ColoredText::text_with_extension(text, extension)
}
/// Lines of text fragments
struct ColoredText(Vec<Vec<(syntect::highlighting::Style, String)>>);
impl ColoredText {
/// e.g. `text_with_extension("fn foo() {}", "rs")
pub fn text_with_extension(text: &str, extension: &str) -> Option<ColoredText> {
use syntect::easy::HighlightLines;
use syntect::highlighting::ThemeSet;
use syntect::parsing::SyntaxSet;
use syntect::util::LinesWithEndings;
let ps = SyntaxSet::load_defaults_newlines(); // should be cached and reused
let ts = ThemeSet::load_defaults(); // should be cached and reused
let syntax = ps.find_syntax_by_extension(extension)?;
let mut h = HighlightLines::new(syntax, &ts.themes["base16-mocha.dark"]);
let lines = LinesWithEndings::from(&text)
.map(|line| {
h.highlight(line, &ps)
.into_iter()
.map(|(style, range)| (style, range.trim_end_matches('\n').to_owned()))
.collect()
})
.collect();
Some(ColoredText(lines))
}
pub fn ui(&self, ui: &mut egui::Ui) {
for line in &self.0 {
ui.horizontal_wrapped_for_text(egui::TextStyle::Monospace, |ui| {
ui.style_mut().spacing.item_spacing.x = 0.0;
for (style, range) in line {
let fg = style.foreground;
let text_color = egui::Srgba::from_rgb(fg.r, fg.g, fg.b);
ui.add(egui::Label::new(range).monospace().text_color(text_color));
}
});
}
}
}
// ----------------------------------------------------------------------------
// Texture/image handling is very manual at the moment.
/// Immediate mode texture managers that supports at most one texture at the time :)
/// Immediate mode texture manager that supports at most one texture at the time :)
#[derive(Default)]
struct TexMngr {
loaded_url: String,

Loading…
Cancel
Save