Merge branch 'main' into v0.4

This commit is contained in:
ading2210 2024-03-04 14:00:04 -05:00
commit 96ff9c337a
3 changed files with 53 additions and 5 deletions

View file

@ -30,6 +30,7 @@ var event_loop = null;
var active_requests = 0;
var wasm_ready = false;
var version_dict = null;
var api = null;
const libcurl_version = "__library_version__";
function check_loaded(check_websocket) {
@ -231,7 +232,7 @@ async function libcurl_fetch(url, params={}) {
function set_websocket_url(url) {
websocket_url = url;
if (!Module.websocket) {
if (!Module.websocket && ENVIRONMENT_IS_WEB) {
document.addEventListener("libcurl_load", () => {
set_websocket_url(url);
});
@ -256,8 +257,11 @@ function main() {
_init_curl();
set_websocket_url(websocket_url);
let load_event = new Event("libcurl_load");
document.dispatchEvent(load_event);
if (ENVIRONMENT_IS_WEB) {
let load_event = new Event("libcurl_load");
document.dispatchEvent(load_event);
}
api.onload();
}
function load_wasm(url) {
@ -267,7 +271,7 @@ function load_wasm(url) {
}
Module.onRuntimeInitialized = main;
return {
api = {
fetch: libcurl_fetch,
set_websocket: set_websocket_url,
load_wasm: load_wasm,
@ -286,6 +290,10 @@ return {
set stdout(callback) {out = callback},
get stderr() {return err},
set stderr(callback) {err = callback},
}
onload() {}
};
return api;
})()