diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-03-13 09:22:20 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-13 09:22:20 +0000 |
| commit | 408b3af5502d8f397e66ce77bd0e5724e562c0b9 (patch) | |
| tree | 3125652e3b46aa0bf4a914ea51bf386492250dc2 /core/sys/wasm | |
| parent | 35340de928508d7cb97121ba57a5e0773a443f3d (diff) | |
| parent | 6691acfa0358f60216d507b4d295dc7b289c397c (diff) | |
Merge pull request #4933 from laytan/js-open-binding
core/sys/wasm/js: add `open` binding to `window.open`
Diffstat (limited to 'core/sys/wasm')
| -rw-r--r-- | core/sys/wasm/js/general.odin | 3 | ||||
| -rw-r--r-- | core/sys/wasm/js/odin.js | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/core/sys/wasm/js/general.odin b/core/sys/wasm/js/general.odin index 4ed2ae298..22bb08e2b 100644 --- a/core/sys/wasm/js/general.odin +++ b/core/sys/wasm/js/general.odin @@ -9,4 +9,5 @@ foreign odin_env { abort :: proc() -> ! --- alert :: proc(msg: string) --- evaluate :: proc(str: string) --- -}
\ No newline at end of file + open :: proc(url: string, name := "", specs := "") --- +} diff --git a/core/sys/wasm/js/odin.js b/core/sys/wasm/js/odin.js index bfb3df530..4e3bb3c22 100644 --- a/core/sys/wasm/js/odin.js +++ b/core/sys/wasm/js/odin.js @@ -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(), |