Skip to content

Commit

Permalink
Localisation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDaGithubAccount committed Oct 27, 2024
1 parent b4d07bb commit 67afa84
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
46 changes: 1 addition & 45 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,7 @@
</head>
<body>
<canvas id="canvas"></canvas>
<script type="module">
import init, * as wasm_bindgen from './src.js';

function jsInit() {
console.log("Wasm module initialized");

if (typeof window.resize_callback === 'undefined' && typeof wasm_bindgen.resize_callback !== 'undefined') {
console.log("Setting resize callback");
window.resize_callback = wasm_bindgen.resize_callback;
}

const canvas = document.getElementById('canvas');

function resizeCanvas() {
const canvas = document.getElementById('canvas');
const width = window.innerWidth;
const height = window.innerHeight;
canvas.width = width;
canvas.height = height;

if (typeof window.resize_callback === 'function') {
window.resize_callback(width, height);
}
}

window.addEventListener('resize', resizeCanvas);
window.addEventListener('load', resizeCanvas);
}
init().then(() => {
jsInit();
}).catch(err => {
if (err.message.includes("Using exceptions for control flow")) {
console.warn("Ignoring expected Wasm initialization exception and proceeding.");
try {
jsInit();
} catch (err) {
console.error("Error in continuing initialisation:", err);
throw err;
}
} else {
console.error("Error initializing wasm module:", err);
throw err;
}
});
console.log("Wasm module initialization call made");
<script type="module" src="index.js">
</script>
</body>
</html>
44 changes: 44 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import init, * as wasm_bindgen from './src.js';

function jsInit() {
console.log("Wasm module initialized");

if (typeof window.resize_callback === 'undefined' && typeof wasm_bindgen.resize_callback !== 'undefined') {
console.log("Setting resize callback");
window.resize_callback = wasm_bindgen.resize_callback;
}

const canvas = document.getElementById('canvas');

function resizeCanvas() {
const canvas = document.getElementById('canvas');
const width = window.innerWidth;
const height = window.innerHeight;
canvas.width = width;
canvas.height = height;

if (typeof window.resize_callback === 'function') {
window.resize_callback(width, height);
}
}

window.addEventListener('resize', resizeCanvas);
window.addEventListener('load', resizeCanvas);
}
init().then(() => {
jsInit();
}).catch(err => {
if (err.message.includes("Using exceptions for control flow")) {
console.warn("Ignoring expected Wasm initialization exception and proceeding.");
try {
jsInit();
} catch (err) {
console.error("Error in continuing initialisation:", err);
throw err;
}
} else {
console.error("Error initializing wasm module:", err);
throw err;
}
});
console.log("Wasm module initialization call made");

0 comments on commit 67afa84

Please sign in to comment.