Merge pull request #4933 from laytan/js-open-binding

core/sys/wasm/js: add `open` binding to `window.open`
This commit is contained in:
gingerBill
2025-03-13 09:22:20 +00:00
committed by GitHub
2 changed files with 9 additions and 1 deletions

View File

@@ -9,4 +9,5 @@ foreign odin_env {
abort :: proc() -> ! ---
alert :: proc(msg: string) ---
evaluate :: proc(str: string) ---
}
open :: proc(url: string, name := "", specs := "") ---
}

View File

@@ -1431,6 +1431,13 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) {
abort: () => { Module.abort() },
evaluate: (str_ptr, str_len) => { eval.call(null, wasmMemoryInterface.loadString(str_ptr, str_len)); },
open: (url_ptr, url_len, name_ptr, name_len, specs_ptr, specs_len) => {
const url = wasmMemoryInterface.loadString(url_ptr, url_len);
const name = wasmMemoryInterface.loadString(name_ptr, name_len);
const specs = wasmMemoryInterface.loadString(specs_ptr, specs_len);
window.open(url, name, specs);
},
// return a bigint to be converted to i64
time_now: () => BigInt(Date.now()),
tick_now: () => performance.now(),