diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7d39dcb80..44067aab9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -71,7 +71,7 @@ minotaur = "2.+" nullAway = "0.10.25" spotless = "6.23.3" taskTree = "2.1.1" -teavm = "0.10.0-SQUID.3" +teavm = "0.10.0-SQUID.4" vanillaExtract = "0.1.2" versionCatalogUpdate = "0.8.1" @@ -154,6 +154,7 @@ minotaur = { module = "com.modrinth.minotaur:Minotaur", version.ref = "minotaur" nullAway = { module = "com.uber.nullaway:nullaway", version.ref = "nullAway" } spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } teavm-classlib = { module = "org.teavm:teavm-classlib", version.ref = "teavm" } +teavm-core = { module = "org.teavm:teavm-core", version.ref = "teavm" } teavm-jso = { module = "org.teavm:teavm-jso", version.ref = "teavm" } teavm-jso-apis = { module = "org.teavm:teavm-jso-apis", version.ref = "teavm" } teavm-jso-impl = { module = "org.teavm:teavm-jso-impl", version.ref = "teavm" } diff --git a/projects/web/build.gradle.kts b/projects/web/build.gradle.kts index 25f0838b6..19d83ceb4 100644 --- a/projects/web/build.gradle.kts +++ b/projects/web/build.gradle.kts @@ -29,6 +29,7 @@ dependencies { implementation(libs.guava) implementation(libs.netty.http) implementation(libs.slf4j) + runtimeOnly(libs.teavm.core) // Contains the TeaVM runtime "builderCompileOnly"(libs.bundles.annotations) "builderImplementation"(libs.bundles.teavm.tooling) diff --git a/projects/web/src/builder/java/cc/tweaked/web/builder/TransformingClassLoader.java b/projects/web/src/builder/java/cc/tweaked/web/builder/TransformingClassLoader.java index fe2a0a00f..123e81d7a 100644 --- a/projects/web/src/builder/java/cc/tweaked/web/builder/TransformingClassLoader.java +++ b/projects/web/src/builder/java/cc/tweaked/web/builder/TransformingClassLoader.java @@ -95,13 +95,18 @@ public class TransformingClassLoader extends ClassLoader { @Override public @Nullable InputStream getResourceAsStream(String name) { - if (!name.endsWith(".class")) return super.getResourceAsStream(name); + if (!name.endsWith(".class") || name.startsWith("java/") || name.startsWith("javax/")) { + return super.getResourceAsStream(name); + } var lastFile = this.lastFile; if (lastFile != null && lastFile.name().equals(name)) return new ByteArrayInputStream(lastFile.contents()); var path = findFile(name); - if (path == null) return null; + if (path == null) { + System.out.printf("Cannot find %s. Falling back to system class loader.\n", name); + return super.getResourceAsStream(name); + } ClassReader reader; try (var stream = Files.newInputStream(path)) { diff --git a/projects/web/src/frontend/emu/computer.ts b/projects/web/src/frontend/emu/computer.ts index 2e93fa362..dc14b0e91 100644 --- a/projects/web/src/frontend/emu/computer.ts +++ b/projects/web/src/frontend/emu/computer.ts @@ -72,6 +72,10 @@ class EmulatedComputer implements ComputerDisplay, ComputerActionable { for (const callback of this.callbacks) callback(computer); }) .catch(e => { + console.error(e); + + if (this.terminal.sizeX === 0 || this.terminal.sizeY === 0) this.terminal.resize(51, 19); + const width = this.terminal.sizeX; const fg = "0".repeat(width); const bg = "e".repeat(width); @@ -83,6 +87,8 @@ class EmulatedComputer implements ComputerDisplay, ComputerActionable { this.terminal.fore[y] = fg; this.terminal.back[y] = bg; } + + this.flushTerminal(); }); }