Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mio-19 committed Sep 19, 2024
1 parent 1d16083 commit 7be4cd2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 63 deletions.
24 changes: 24 additions & 0 deletions site/app/components/Repl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useEffect, useRef } from "react";
import { XTerm } from "@pablo-lion/xterm-react";
import { WebLinksAddon } from '@xterm/addon-web-links';
import { Terminal } from '@xterm/xterm';
import { startRepl } from "../../generated/main.mjs";

export default function Repl() {
/* eslint-disable @typescript-eslint/no-explicit-any */
const xtermRef = useRef<any>(null);

useEffect(() => {
if (xtermRef.current) {
const terminal = xtermRef.current.terminal as Terminal;
terminal.loadAddon(new WebLinksAddon());
startRepl(terminal);
}
}, []);

return (
<div className="w-full h-96 bg-black rounded">
<XTerm ref={xtermRef} />
</div>
);
}
70 changes: 7 additions & 63 deletions site/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
'use client';

import { useEffect, useRef } from "react";
import Image from "next/image";
import { XTerm } from "@pablo-lion/xterm-react";
import { WebLinksAddon } from '@xterm/addon-web-links';
import { startRepl } from "../generated/main.mjs";
import "../types/main.d.ts";
import dynamic from 'next/dynamic';

export default function Home() {
const xtermRef = useRef(null);

useEffect(() => {
if (xtermRef.current) {
const terminal = xtermRef.current.terminal;
terminal.loadAddon(new WebLinksAddon());
startRepl(terminal);
}
}, []);
const Repl = dynamic(() => import('./components/Repl'), {
ssr: false
})

export default function Home() {
return (
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
Expand All @@ -30,56 +20,10 @@ export default function Home() {
priority
/>
<h1 className="text-2xl font-bold">Chester: A Programming Language</h1>
<div className="w-full h-96 bg-black rounded">
<XTerm ref={xtermRef} />
</div>
<Repl />
</main>
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="https://nextjs.org/icons/file.svg"
alt="File icon"
width={16}
height={16}
/>
Learn
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="https://nextjs.org/icons/window.svg"
alt="Window icon"
width={16}
height={16}
/>
Examples
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="https://nextjs.org/icons/globe.svg"
alt="Globe icon"
width={16}
height={16}
/>
Go to nextjs.org →
</a>
{/* Footer content remains the same */}
</footer>
</div>
);
Expand Down
6 changes: 6 additions & 0 deletions site/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const nextConfig = {
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.output.globalObject = 'this';
}
return config;
},
};

export default nextConfig;

0 comments on commit 7be4cd2

Please sign in to comment.