mirror of
https://github.com/Drop-OSS/wry-cef.git
synced 2026-01-30 20:55:24 +01:00
24 lines
968 B
JavaScript
24 lines
968 B
JavaScript
// Copyright 2020-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
if (window.location.pathname.startsWith('/custom_protocol_page2')) {
|
|
console.log("hello from javascript in page2");
|
|
} else {
|
|
console.log("hello from javascript in page1");
|
|
|
|
if (typeof WebAssembly.instantiateStreaming !== 'undefined') {
|
|
WebAssembly.instantiateStreaming(fetch("/custom_protocol_wasm.wasm"))
|
|
.then(wasm => {
|
|
console.log(wasm.instance.exports.main()); // should log 42
|
|
});
|
|
} else {
|
|
// Older WKWebView may not support `WebAssembly.instantiateStreaming` yet.
|
|
fetch("/custom_protocol_wasm.wasm")
|
|
.then(response => response.arrayBuffer())
|
|
.then(bytes => WebAssembly.instantiate(bytes))
|
|
.then(wasm => {
|
|
console.log(wasm.instance.exports.main()); // should log 42
|
|
});
|
|
}
|
|
}
|