Skip to content

Commit

Permalink
this entire time i misspelled kernel as kernal
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanChaudhary committed Apr 29, 2024
1 parent 7cae16e commit 27ee06d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
36 changes: 18 additions & 18 deletions src/app/Computer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
}
Expand All @@ -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",
}
Expand All @@ -60,8 +60,8 @@
);
});
const loadComputerKernal = new Promise<void>((resolve) => {
computerKernal.addEventListener(
const loadComputerKernel = new Promise<void>((resolve) => {
computerKernel.addEventListener(
"message",
(e) => {
if (e.data.action === "loaded") {
Expand Down Expand Up @@ -99,38 +99,38 @@
);
});
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,
});
}
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 });
}
</script>

Expand Down Expand Up @@ -205,7 +205,7 @@
setTimeout(() => {
makeRedAfterwards = false;
}, 50);
computerKernal.postMessage({ action: "partialStop" });
computerKernel.postMessage({ action: "partialStop" });
break;
}
}
Expand All @@ -215,7 +215,7 @@
let hasInitRunner = false;
async function initRunner() {
const offscreenCanvas = computerScreen.transferControlToOffscreen();
computerKernal.postMessage(
computerKernel.postMessage(
{
action: "screenInit",
offscreenCanvas,
Expand All @@ -226,7 +226,7 @@
);
await new Promise<void>((resolve) => {
computerKernal.addEventListener(
computerKernel.addEventListener(
"message",
(e) => {
if (e.data.action === "ready") {
Expand All @@ -238,7 +238,7 @@
});
computerRunner.addEventListener("message", messageHandler);
computerKernal.addEventListener("message", messageHandler);
computerKernel.addEventListener("message", messageHandler);
hasInitRunner = true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/computer-kernal.ts → src/app/computer-kernel.ts
Original file line number Diff line number Diff line change
@@ -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" });
};
4 changes: 2 additions & 2 deletions src/core/builtins.rs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/core/builtins/runtime_worker.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 27ee06d

Please sign in to comment.