mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Improve types for web workers (#502)
* Improve types for web workers * Move worker-loader config inline * Remove trailing spaces in translations
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
// We clamp high deltas so 30 fps is fairly ok
|
||||
var bgFps = 30;
|
||||
var desiredMsDelay = 1000 / bgFps;
|
||||
const bgFps = 30;
|
||||
const desiredMsDelay = 1000 / bgFps;
|
||||
|
||||
let lastTick = 0;
|
||||
let lastTick = performance.now();
|
||||
|
||||
function tick() {
|
||||
var now = performance.now();
|
||||
var delta = now - lastTick;
|
||||
const now = performance.now();
|
||||
const delta = now - lastTick;
|
||||
lastTick = now;
|
||||
|
||||
// @ts-ignore
|
||||
postMessage({ delta });
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,9 @@ function accessNestedPropertyReverse(obj, keys) {
|
||||
|
||||
const salt = accessNestedPropertyReverse(globalConfig, ["file", "info"]);
|
||||
|
||||
onmessage = function (event) {
|
||||
const { jobId, job, data } = event.data;
|
||||
onmessage = function ({ data: { jobId, job, data } }) {
|
||||
const result = performJob(job, data);
|
||||
|
||||
// @ts-ignore
|
||||
postMessage({
|
||||
jobId,
|
||||
result,
|
||||
});
|
||||
postMessage({ jobId, result });
|
||||
};
|
||||
|
||||
function performJob(job, data) {
|
||||
|
||||
8
src/js/webworkers/tsconfig.json
Normal file
8
src/js/webworkers/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["ES2018","WebWorker"]
|
||||
},
|
||||
"exclude": [],
|
||||
"extends": "../tsconfig",
|
||||
"include": ["*.worker.js"]
|
||||
}
|
||||
Reference in New Issue
Block a user