Skip to content

Commit a00e026

Browse files
feat(core): upgrade to next.js (#42)
Vite => Next.js Emotion => Tailwind
1 parent 7da3080 commit a00e026

File tree

131 files changed

+22700
-13135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+22700
-13135
lines changed

.github/workflows/gh-pages-deploy.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/playwright.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Playwright Tests
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
test:
6+
timeout-minutes: 60
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-node@v4
11+
with:
12+
node-version: lts/*
13+
- name: Install dependencies
14+
run: npm ci
15+
- name: Install Playwright Browsers
16+
run: npx playwright install --with-deps
17+
- name: Run Playwright tests
18+
run: npx playwright test
19+
- uses: actions/upload-artifact@v4
20+
if: ${{ !cancelled() }}
21+
with:
22+
name: playwright-report
23+
path: playwright-report/
24+
retention-days: 30

.github/workflows/pr-check.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ jobs:
2222
node-version: 22.13.0
2323

2424
- name: Install dependencies
25-
run: yarn install
25+
run: npm install
2626

2727
- name: Run linter
28-
run: yarn lint
28+
run: npm run lint
2929

3030
- name: Run type check
31-
run: yarn typecheck
31+
run: npm run typecheck
3232

3333
- name: Run unit tests
34-
run: yarn test
34+
run: npm run test
3535

3636
- name: Run build
37-
run: yarn build
37+
run: npm run build

.gitignore

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1-
# Logs
2-
logs
3-
*.log
1+
# dependencies
2+
/node_modules
3+
4+
# testing
5+
/coverage
6+
7+
# next.js
8+
/.next/
9+
/out/
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
*.pem
17+
18+
# debug
419
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
pnpm-debug.log*
8-
lerna-debug.log*
9-
10-
node_modules
11-
dist
12-
dist-ssr
13-
*.local
14-
15-
# Editor directories and files
16-
.vscode/*
17-
!.vscode/extensions.json
20+
21+
# env files (can opt-in for committing if needed)
22+
.env*
23+
24+
# vercel
25+
.vercel
26+
27+
# typescript
28+
*.tsbuildinfo
29+
next-env.d.ts
30+
31+
#IDEs
1832
.idea
19-
.DS_Store
20-
*.suo
21-
*.ntvs*
22-
*.njsproj
23-
*.sln
24-
*.sw?
25-
26-
.pnp.*
27-
.yarn/*
28-
!.yarn/patches
29-
!.yarn/plugins
30-
!.yarn/releases
31-
!.yarn/sdks
32-
!.yarn/versions
33+
.vscode
3334

3435
# Playwright
3536
/test-results/
@@ -39,3 +40,5 @@ dist-ssr
3940

4041
# Jest
4142
/coverage
43+
44+

.husky/commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
yarn commitlint --edit $1
1+
commitlint --edit $1

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
yarn lint-staged --allow-empty
1+
lint-staged --allow-empty

.lintstagedrc.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export default {
22
'*.{js,jsx,ts,tsx}': [
3-
'yarn prettier --write',
4-
'yarn eslint --fix',
5-
'yarn test',
6-
() => 'yarn typecheck',
3+
'prettier --write',
4+
'eslint --fix',
5+
'jest --passWithNoTests',
6+
() => 'npm run typecheck',
77
],
8-
'*.{json,css,scss,md}': ['yarn prettier --write', 'yarn eslint --fix'],
8+
'*.{json,css,scss,md}': ['prettier --write', 'eslint --fix'],
99
};

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ git clone [email protected]:vault-developer/event-loop-explorer.git
4343
4444
cd event-loop-explorer
4545
46-
yarn install
46+
npm install
4747
48-
yarn dev
48+
npm run dev
4949
```
5050

5151
### Future Plans:

app/(main)/header/header.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { ThemeToggle } from './themeToggle';
2+
import { Repeat, Github } from 'lucide-react';
3+
import { Button } from '@/components/chadcdn/button';
4+
import Link from 'next/link';
5+
6+
export function Header() {
7+
return (
8+
<div className="flex px-4 py-2 lg:px-6 lg:py-4 items-center justify-between border-b">
9+
<div className="flex items-center gap-2">
10+
<Repeat />
11+
<h2>Event loop explorer</h2>
12+
</div>
13+
14+
<div className="flex items-center gap-2">
15+
<Button asChild variant="ghost" size="iconBig">
16+
<Link
17+
href="https://github.com/vault-developer/event-loop-explorer"
18+
target="_blank"
19+
>
20+
<Github className="size-6" />
21+
</Link>
22+
</Button>
23+
<ThemeToggle />
24+
</div>
25+
</div>
26+
);
27+
}

app/(main)/header/themeToggle.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useTheme } from 'next-themes';
2+
import { Button } from '@/components/chadcdn/button';
3+
import { Moon, Sun } from 'lucide-react';
4+
5+
export function ThemeToggle() {
6+
const { setTheme, theme } = useTheme();
7+
const onToggle = () => setTheme(theme === 'light' ? 'dark' : 'light');
8+
9+
return (
10+
<Button variant="ghost" size="iconBig" onClick={onToggle}>
11+
<Sun
12+
className="absolute scale-100 dark:scale-0 rotate-0 dark:rotate-90 transition-all size-6"
13+
size={24}
14+
/>
15+
<Moon
16+
className="absolute scale-0 dark:scale-100 rotate-90 dark:rotate-0 transition-all size-6"
17+
size={24}
18+
/>
19+
<span className="sr-only">Toggle theme</span>
20+
</Button>
21+
);
22+
}

app/(main)/page.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use client';
2+
3+
import { Header } from './header/header';
4+
import { Configurator } from '@/app/(main)/sections/configurator/configurator';
5+
import { WebApi } from '@/app/(main)/sections/webApi';
6+
import { RequestAnimationFrame } from '@/app/(main)/sections/requestAnimaitionFrame';
7+
import { Callstack } from '@/app/(main)/sections/callstack';
8+
import { Console } from '@/app/(main)/sections/console';
9+
import { TasksQueue } from '@/app/(main)/sections/tasksQueue';
10+
import { MicrotasksQueue } from '@/app/(main)/sections/microtasksQueue';
11+
import { EventLoop } from '@/app/(main)/sections/eventLoop/eventLoop';
12+
13+
export default function Home() {
14+
return (
15+
<div className="flex flex-col grow">
16+
<Header />
17+
<div className="grow grid grid-cols-2 md:grid-cols-5 p-4 gap-4 lg:p-6 lg:gap-6">
18+
<div className="col-span-2 h-full grid grid-rows-5 gap-4 lg:gap-6">
19+
<div className="row-span-3 flex overflow-auto">
20+
<Configurator />
21+
</div>
22+
<div className="row-span-1 flex overflow-auto">
23+
<WebApi />
24+
</div>
25+
<div className="row-span-1 flex overflow-auto">
26+
<RequestAnimationFrame />
27+
</div>
28+
</div>
29+
<div className="col-span-2 md:col-span-1 h-full grid grid-rows-2 gap-4 lg:gap-6">
30+
<div className="row-span-1 flex overflow-auto">
31+
<Callstack />
32+
</div>
33+
<div className="row-span-1 flex overflow-auto">
34+
<Console />
35+
</div>
36+
</div>
37+
<div className="col-span-2 h-full grid grid-rows-5 gap-4 lg:gap-6">
38+
<div className="row-span-1 flex overflow-auto">
39+
<TasksQueue />
40+
</div>
41+
<div className="row-span-1 flex overflow-auto">
42+
<MicrotasksQueue />
43+
</div>
44+
<div className="row-span-3 flex overflow-auto">
45+
<EventLoop />
46+
</div>
47+
</div>
48+
</div>
49+
</div>
50+
);
51+
}

app/(main)/sections/callstack.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { FC } from 'react';
2+
import { InfoContainer } from '@/components/infoContainer';
3+
import { List } from '@/components/list';
4+
import { Card } from '@/components/card';
5+
import { useQueueManagerStore } from '@/store/store';
6+
7+
const description = (
8+
<>
9+
<p>
10+
A call stack is a mechanism for an interpreter to keep track of its place
11+
in a script that calls multiple functions — what function is currently
12+
being run and what functions are called from within that function, etc.
13+
</p>
14+
<p>
15+
When a script calls a function, the interpreter adds it to the call stack
16+
and then starts carrying out the function.
17+
</p>
18+
<p>
19+
When the current function is finished, the interpreter takes it off the
20+
stack and resumes execution where it left off in the last code listing.
21+
</p>
22+
<p>
23+
If the stack takes up more space than it was assigned, a &#34;stack
24+
overflow&#34; error is thrown.
25+
</p>
26+
</>
27+
);
28+
29+
export const Callstack: FC = () => {
30+
const stack = useQueueManagerStore((state) => state.callstack);
31+
32+
return (
33+
<InfoContainer title="Callstack" description={description}>
34+
<List data={stack} orientation="vertical" className="md:flex-col-reverse">
35+
{(el) => <Card text={el as (typeof stack)[0]} />}
36+
</List>
37+
</InfoContainer>
38+
);
39+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { FC, useState } from 'react';
2+
import { InfoContainer } from '@/components/infoContainer';
3+
import { Controls } from './controls';
4+
import { Editor } from './editor';
5+
import {
6+
DEFAULT_EXAMPLE_KEY,
7+
EXAMPLES,
8+
} from '@/app/(main)/sections/configurator/controls.data';
9+
10+
const description = (
11+
<>
12+
<p>
13+
This code editor allows you to write and visualize JavaScript code
14+
execution within the event loop.
15+
</p>
16+
<ul>
17+
<li>
18+
- select a pre-built example from the dropdown menu or write your own
19+
code from scratch.
20+
</li>
21+
<li>
22+
- use the speed scrollbar to control the execution speed and observe how
23+
the event loop processes your code.
24+
</li>
25+
<li>
26+
- pause the execution when needed to examine the state of the event loop
27+
at any given point.
28+
</li>
29+
</ul>
30+
</>
31+
);
32+
33+
export const Configurator: FC = () => {
34+
const [code, setCode] = useState(() => EXAMPLES[DEFAULT_EXAMPLE_KEY].code);
35+
36+
return (
37+
<InfoContainer title="Code Editor" description={description}>
38+
<Controls code={code} setCode={setCode} />
39+
<Editor code={code} setCode={setCode} />
40+
</InfoContainer>
41+
);
42+
};

0 commit comments

Comments
 (0)