This commit is contained in:
2025-10-29 21:14:44 -07:00
parent 667624d0ca
commit 965253386a
13 changed files with 146 additions and 58 deletions

View File

@@ -2,6 +2,7 @@
import { useEffect, useState } from "react";
import dynamic from "next/dynamic";
import { loadAllWasm } from "@/utils/wasmLoader";
const Playground = dynamic(() => import("@/components/Playground"), {
ssr: false,
@@ -20,14 +21,7 @@ const Playground = dynamic(() => import("@/components/Playground"), {
}}
>
<div>
Loading{" "}
<a
href="https://github.com/rhaiscript/playground"
target="_blank"
>
Rhai Playground
</a>
...
Loading WASM...
</div>
</div>
),
@@ -35,12 +29,24 @@ const Playground = dynamic(() => import("@/components/Playground"), {
export default function Home() {
const [isClient, setIsClient] = useState(false);
const [isWasmLoaded, setIsWasmLoaded] = useState(false);
useEffect(() => {
setIsClient(true);
// Load all WASM modules
loadAllWasm()
.then(() => {
setIsWasmLoaded(true);
})
.catch((error) => {
console.error('Failed to load WASM modules:', error);
// Still allow the app to load, but WASM features may not work
setIsWasmLoaded(true);
});
}, []);
if (!isClient) {
if (!isClient || !isWasmLoaded) {
return (
<div
id="loading"