From 27ee06d3d5f9d3ad7948ba62f4f7407163b92139 Mon Sep 17 00:00:00 2001 From: Arhan Chaudhary Date: Sun, 28 Apr 2024 20:10:40 -0400 Subject: [PATCH] this entire time i misspelled kernel as kernal --- src/app/Computer.svelte | 36 +++++++++---------- ...{computer-kernal.ts => computer-kernel.ts} | 6 ++-- src/core/builtins.rs | 4 +-- .../{kernal_worker.rs => kernel_worker.rs} | 2 +- .../hardware_info.rs | 0 .../runtime.rs | 0 .../screen.rs | 0 src/core/builtins/runtime_worker.rs | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) rename src/app/{computer-kernal.ts => computer-kernel.ts} (54%) rename src/core/builtins/{kernal_worker.rs => kernel_worker.rs} (98%) rename src/core/builtins/{kernal_worker => kernel_worker}/hardware_info.rs (100%) rename src/core/builtins/{kernal_worker => kernel_worker}/runtime.rs (100%) rename src/core/builtins/{kernal_worker => kernel_worker}/screen.rs (100%) diff --git a/src/app/Computer.svelte b/src/app/Computer.svelte index 40580041..d424e647 100644 --- a/src/app/Computer.svelte +++ b/src/app/Computer.svelte @@ -18,7 +18,7 @@ }); let computerRunner: Worker; - let computerKernal: Worker; + let computerKernel: Worker; // https://github.com/Menci/vite-plugin-top-level-await?tab=readme-ov-file#workers if (import.meta.env.DEV) { computerRunner = new Worker( @@ -27,8 +27,8 @@ type: "module", } ); - computerKernal = new Worker( - new URL("computer-kernal.ts", import.meta.url), + computerKernel = new Worker( + new URL("computer-kernel.ts", import.meta.url), { type: "module", } @@ -40,8 +40,8 @@ type: "classic", } ); - computerKernal = new Worker( - new URL("computer-kernal.ts", import.meta.url), + computerKernel = new Worker( + new URL("computer-kernel.ts", import.meta.url), { type: "classic", } @@ -60,8 +60,8 @@ ); }); - const loadComputerKernal = new Promise((resolve) => { - computerKernal.addEventListener( + const loadComputerKernel = new Promise((resolve) => { + computerKernel.addEventListener( "message", (e) => { if (e.data.action === "loaded") { @@ -99,17 +99,17 @@ ); }); - await Promise.all([loadJackOS, loadComputerRuntime, loadComputerKernal]); + await Promise.all([loadJackOS, loadComputerRuntime, loadComputerKernel]); export function startComputer() { computerIsRunning.set(true); computerRunner.postMessage(undefined); - computerKernal.postMessage({ action: "partialStart" }); + computerKernel.postMessage({ action: "partialStart" }); } export function resetAndStartComputer(machineCode: string[]) { computerIsRunning.set(true); computerRunner.postMessage(undefined); - computerKernal.postMessage({ + computerKernel.postMessage({ action: "resetAndPartialStart", machineCode, }); @@ -117,20 +117,20 @@ export function stopAndResetComputer() { computerIsRunning.set(false); - computerKernal.postMessage({ action: "stopAndReset" }); + computerKernel.postMessage({ action: "stopAndReset" }); } export function stopComputer() { computerIsRunning.set(false); - computerKernal.postMessage({ action: "stop" }); + computerKernel.postMessage({ action: "stop" }); } export function speedComputer(speedPercentage: number) { - computerKernal.postMessage({ action: "speed", speedPercentage }); + computerKernel.postMessage({ action: "speed", speedPercentage }); } function keyboardComputer(keyValue: number) { - computerKernal.postMessage({ action: "keyboard", keyValue }); + computerKernel.postMessage({ action: "keyboard", keyValue }); } @@ -205,7 +205,7 @@ setTimeout(() => { makeRedAfterwards = false; }, 50); - computerKernal.postMessage({ action: "partialStop" }); + computerKernel.postMessage({ action: "partialStop" }); break; } } @@ -215,7 +215,7 @@ let hasInitRunner = false; async function initRunner() { const offscreenCanvas = computerScreen.transferControlToOffscreen(); - computerKernal.postMessage( + computerKernel.postMessage( { action: "screenInit", offscreenCanvas, @@ -226,7 +226,7 @@ ); await new Promise((resolve) => { - computerKernal.addEventListener( + computerKernel.addEventListener( "message", (e) => { if (e.data.action === "ready") { @@ -238,7 +238,7 @@ }); computerRunner.addEventListener("message", messageHandler); - computerKernal.addEventListener("message", messageHandler); + computerKernel.addEventListener("message", messageHandler); hasInitRunner = true; } diff --git a/src/app/computer-kernal.ts b/src/app/computer-kernel.ts similarity index 54% rename from src/app/computer-kernal.ts rename to src/app/computer-kernel.ts index 3e9555ce..2a16107d 100644 --- a/src/app/computer-kernal.ts +++ b/src/app/computer-kernel.ts @@ -1,8 +1,8 @@ -import runtimeInit, { kernalHandleMessage } from "nand-core"; +import runtimeInit, { kernelHandleMessage } from "nand-core"; self.postMessage({ action: "loaded" }); self.onmessage = async (e) => { await runtimeInit(e.data.wasmModule, e.data.wasmMemory); - kernalHandleMessage(e.data); - self.onmessage = (e) => kernalHandleMessage(e.data); + kernelHandleMessage(e.data); + self.onmessage = (e) => kernelHandleMessage(e.data); self.postMessage({ action: "ready" }); }; diff --git a/src/core/builtins.rs b/src/core/builtins.rs index f553d576..36bd67bf 100644 --- a/src/core/builtins.rs +++ b/src/core/builtins.rs @@ -1,5 +1,5 @@ pub mod hardware; +pub mod kernel_worker; pub mod memory; -pub mod utils; mod runtime_worker; -pub mod kernal_worker; +pub mod utils; diff --git a/src/core/builtins/kernal_worker.rs b/src/core/builtins/kernel_worker.rs similarity index 98% rename from src/core/builtins/kernal_worker.rs rename to src/core/builtins/kernel_worker.rs index 28c7afd4..a70a61b6 100644 --- a/src/core/builtins/kernal_worker.rs +++ b/src/core/builtins/kernel_worker.rs @@ -8,7 +8,7 @@ mod hardware_info; pub mod runtime; mod screen; -#[wasm_bindgen(js_name = kernalHandleMessage)] +#[wasm_bindgen(js_name = kernelHandleMessage)] pub fn handle_message(message: JsValue) { let received_worker_message: ReceivedWorkerMessage = serde_wasm_bindgen::from_value(message).unwrap(); diff --git a/src/core/builtins/kernal_worker/hardware_info.rs b/src/core/builtins/kernel_worker/hardware_info.rs similarity index 100% rename from src/core/builtins/kernal_worker/hardware_info.rs rename to src/core/builtins/kernel_worker/hardware_info.rs diff --git a/src/core/builtins/kernal_worker/runtime.rs b/src/core/builtins/kernel_worker/runtime.rs similarity index 100% rename from src/core/builtins/kernal_worker/runtime.rs rename to src/core/builtins/kernel_worker/runtime.rs diff --git a/src/core/builtins/kernal_worker/screen.rs b/src/core/builtins/kernel_worker/screen.rs similarity index 100% rename from src/core/builtins/kernal_worker/screen.rs rename to src/core/builtins/kernel_worker/screen.rs diff --git a/src/core/builtins/runtime_worker.rs b/src/core/builtins/runtime_worker.rs index 85497f1c..b7f19bf0 100644 --- a/src/core/builtins/runtime_worker.rs +++ b/src/core/builtins/runtime_worker.rs @@ -1,5 +1,5 @@ use super::hardware; -use super::kernal_worker::runtime::ALL_STEPS_PER_LOOP; +use super::kernel_worker::runtime::ALL_STEPS_PER_LOOP; use super::utils::{js_api, sync_cell}; use crate::architecture; use serde::Serialize;