toiljs 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/build/cli/.tsbuildinfo +1 -1
  2. package/build/cli/create.js +75 -61
  3. package/build/client/.tsbuildinfo +1 -1
  4. package/build/client/channel/channel.d.ts +23 -0
  5. package/build/client/channel/channel.js +94 -0
  6. package/build/client/head/head.d.ts +26 -0
  7. package/build/client/head/head.js +87 -0
  8. package/build/client/index.d.ts +17 -17
  9. package/build/client/index.js +10 -10
  10. package/build/client/navigation/Link.d.ts +8 -0
  11. package/build/client/navigation/Link.js +44 -0
  12. package/build/client/navigation/NavLink.d.ts +14 -0
  13. package/build/client/navigation/NavLink.js +37 -0
  14. package/build/client/navigation/navigation.d.ts +13 -0
  15. package/build/client/navigation/navigation.js +97 -0
  16. package/build/client/navigation/prefetch.d.ts +11 -0
  17. package/build/client/navigation/prefetch.js +100 -0
  18. package/build/client/navigation/scroll.d.ts +8 -0
  19. package/build/client/navigation/scroll.js +36 -0
  20. package/build/client/routing/Router.d.ts +7 -0
  21. package/build/client/routing/Router.js +55 -0
  22. package/build/client/routing/error-boundary.d.ts +16 -0
  23. package/build/client/routing/error-boundary.js +19 -0
  24. package/build/client/routing/hooks.d.ts +17 -0
  25. package/build/client/routing/hooks.js +48 -0
  26. package/build/client/routing/lazy.d.ts +16 -0
  27. package/build/client/routing/lazy.js +53 -0
  28. package/build/client/routing/match.d.ts +2 -0
  29. package/build/client/routing/match.js +32 -0
  30. package/build/client/routing/mount.d.ts +2 -0
  31. package/build/client/routing/mount.js +13 -0
  32. package/build/client/routing/params-context.d.ts +2 -0
  33. package/build/client/routing/params-context.js +2 -0
  34. package/build/compiler/.tsbuildinfo +1 -1
  35. package/build/compiler/config.js +10 -1
  36. package/build/compiler/generate.js +18 -8
  37. package/build/compiler/plugin.js +14 -0
  38. package/examples/basic/client/components/HoneycombBackground.tsx +162 -0
  39. package/examples/basic/client/layout.tsx +12 -8
  40. package/examples/basic/client/public/favicon.ico +0 -0
  41. package/examples/basic/client/public/index.html +2 -1
  42. package/package.json +2 -2
  43. package/src/cli/create.ts +100 -73
  44. package/src/client/index.ts +17 -17
  45. package/src/client/{NavLink.tsx → navigation/NavLink.tsx} +1 -1
  46. package/src/client/{prefetch.ts → navigation/prefetch.ts} +2 -2
  47. package/src/client/{Router.tsx → routing/Router.tsx} +3 -3
  48. package/src/client/{error-boundary.tsx → routing/error-boundary.tsx} +1 -1
  49. package/src/client/{hooks.ts → routing/hooks.ts} +2 -2
  50. package/src/client/{lazy.ts → routing/lazy.ts} +1 -1
  51. package/src/client/{mount.tsx → routing/mount.tsx} +3 -3
  52. package/src/compiler/config.ts +11 -2
  53. package/src/compiler/generate.ts +24 -8
  54. package/src/compiler/plugin.ts +19 -0
  55. package/templates/app/client/404.tsx +11 -0
  56. package/templates/app/client/components/.gitkeep +1 -0
  57. package/templates/app/client/components/Footer.tsx +8 -0
  58. package/templates/app/client/components/HoneycombBackground.tsx +162 -0
  59. package/templates/app/client/layout.tsx +53 -0
  60. package/templates/app/client/public/favicon.ico +0 -0
  61. package/templates/app/client/public/images/.gitkeep +1 -0
  62. package/templates/app/client/public/images/logo.svg +37 -0
  63. package/templates/app/client/public/index.html +16 -0
  64. package/templates/app/client/public/robots.txt +2 -0
  65. package/templates/app/client/routes/about.tsx +11 -0
  66. package/templates/app/client/routes/blog/[id].tsx +12 -0
  67. package/templates/app/client/routes/docs/[...slug].tsx +12 -0
  68. package/templates/app/client/routes/get-started.tsx +84 -0
  69. package/templates/app/client/routes/index.tsx +80 -0
  70. package/templates/app/client/routes/io.tsx +24 -0
  71. package/templates/app/client/styles/main.css +461 -0
  72. package/templates/app/client/toil.tsx +7 -0
  73. package/test/channel.test.ts +1 -1
  74. package/test/head.test.ts +1 -1
  75. package/test/navlink.test.ts +1 -1
  76. package/test/routes.test.ts +1 -1
  77. /package/src/client/{channel.ts → channel/channel.ts} +0 -0
  78. /package/src/client/{head.ts → head/head.ts} +0 -0
  79. /package/src/client/{Link.tsx → navigation/Link.tsx} +0 -0
  80. /package/src/client/{navigation.ts → navigation/navigation.ts} +0 -0
  81. /package/src/client/{scroll.ts → navigation/scroll.ts} +0 -0
  82. /package/src/client/{match.ts → routing/match.ts} +0 -0
  83. /package/src/client/{params-context.ts → routing/params-context.ts} +0 -0
@@ -0,0 +1,162 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ const HEX_R = 34;
4
+ const GAP = 3;
5
+ const DRAW_R = HEX_R - GAP;
6
+ const GLOW_DIST = 140;
7
+
8
+ function tracePath(ctx: CanvasRenderingContext2D, cx: number, cy: number, r: number) {
9
+ ctx.beginPath();
10
+
11
+ for (let i = 0; i < 6; i++) {
12
+ const a = (Math.PI / 3) * i - Math.PI / 6;
13
+ const x = cx + r * Math.cos(a);
14
+ const y = cy + r * Math.sin(a);
15
+
16
+ if (i === 0) {
17
+ ctx.moveTo(x, y);
18
+ } else {
19
+ ctx.lineTo(x, y);
20
+ }
21
+ }
22
+
23
+ ctx.closePath();
24
+ }
25
+
26
+ function buildGrid(w: number, h: number): Array<{ x: number; y: number }> {
27
+ const colW = Math.sqrt(3) * HEX_R;
28
+
29
+ const rowH = HEX_R * 1.5;
30
+ const cols = Math.ceil(w / colW) + 2;
31
+ const rows = Math.ceil(h / rowH) + 2;
32
+ const hexes: Array<{ x: number; y: number }> = [];
33
+
34
+ for (let row = -1; row < rows; row++) {
35
+ for (let col = -1; col < cols; col++) {
36
+ hexes.push({
37
+ x: col * colW + (row % 2 !== 0 ? colW / 2 : 0),
38
+ y: row * rowH,
39
+ });
40
+ }
41
+ }
42
+
43
+ return hexes;
44
+ }
45
+
46
+ export default function HoneycombBackground() {
47
+ const canvasRef = useRef<HTMLCanvasElement>(null);
48
+ const mouse = useRef({ x: -9999, y: -9999 });
49
+
50
+ useEffect(() => {
51
+ const canvas = canvasRef.current;
52
+
53
+ if (!canvas) return;
54
+
55
+ const ctx = canvas.getContext('2d');
56
+
57
+ if (!ctx) return;
58
+
59
+ const dpr = window.devicePixelRatio || 1;
60
+ let hexes: Array<{ x: number; y: number }> = [];
61
+ let raf: number;
62
+
63
+ function resize() {
64
+ if (!canvas || !ctx) return;
65
+
66
+ const w = window.innerWidth;
67
+ const h = window.innerHeight;
68
+ canvas.width = w * dpr;
69
+ canvas.height = h * dpr;
70
+ canvas.style.width = `${w}px`;
71
+ canvas.style.height = `${h}px`;
72
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
73
+ hexes = buildGrid(w, h);
74
+ }
75
+
76
+ function draw() {
77
+ if (!ctx) return;
78
+
79
+ const w = window.innerWidth;
80
+ const h = window.innerHeight;
81
+ ctx.clearRect(0, 0, w, h);
82
+
83
+ const mx = mouse.current.x;
84
+ const my = mouse.current.y;
85
+
86
+ for (const { x, y } of hexes) {
87
+ const dist = Math.hypot(x - mx, y - my);
88
+ const t = Math.max(0, 1 - dist / GLOW_DIST);
89
+ const ease = t * t * (3 - 2 * t);
90
+
91
+ tracePath(ctx, x, y, DRAW_R);
92
+
93
+ ctx.fillStyle = 'rgba(255,255,255,0.018)';
94
+ ctx.fill();
95
+
96
+ if (ease > 0) {
97
+ ctx.fillStyle = `rgba(72,148,255,${ease * 0.025})`;
98
+ ctx.fill();
99
+ }
100
+
101
+ ctx.strokeStyle = 'rgba(255,255,255,0.055)';
102
+ ctx.lineWidth = 1;
103
+ ctx.stroke();
104
+
105
+ if (ease > 0) {
106
+ ctx.save();
107
+ ctx.shadowColor = `rgba(72,148,255,${ease * 0.2})`;
108
+ ctx.shadowBlur = 8 * ease;
109
+ ctx.strokeStyle = `rgba(120,180,255,${ease * 0.2})`;
110
+ ctx.lineWidth = 1 + ease * 0.4;
111
+ ctx.stroke();
112
+ ctx.restore();
113
+ }
114
+ }
115
+
116
+ raf = requestAnimationFrame(draw);
117
+ }
118
+
119
+ resize();
120
+ draw();
121
+
122
+ const onResize = () => {
123
+ cancelAnimationFrame(raf);
124
+ resize();
125
+ draw();
126
+ };
127
+
128
+ const onMove = (e: MouseEvent) => {
129
+ mouse.current = { x: e.clientX, y: e.clientY };
130
+ };
131
+
132
+ const onLeave = () => {
133
+ mouse.current = { x: -9999, y: -9999 };
134
+ };
135
+
136
+ window.addEventListener('resize', onResize);
137
+ window.addEventListener('mousemove', onMove);
138
+ document.addEventListener('mouseleave', onLeave);
139
+
140
+ return () => {
141
+ cancelAnimationFrame(raf);
142
+ window.removeEventListener('resize', onResize);
143
+ window.removeEventListener('mousemove', onMove);
144
+ document.removeEventListener('mouseleave', onLeave);
145
+ };
146
+ }, []);
147
+
148
+ return (
149
+ <canvas
150
+ ref={canvasRef}
151
+ style={{
152
+ position: 'fixed',
153
+ inset: 0,
154
+ width: '100%',
155
+ height: '100%',
156
+ pointerEvents: 'none',
157
+ zIndex: 0,
158
+ }}
159
+ />
160
+ );
161
+ }
162
+
@@ -0,0 +1,53 @@
1
+ import { type ReactNode } from 'react';
2
+ import Footer from './components/Footer';
3
+ import HoneycombBackground from './components/HoneycombBackground';
4
+
5
+ const GitHubIcon = () => (
6
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
7
+ <path d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.489.5.092.682-.217.682-.482 0-.237-.009-.868-.013-1.703-2.782.604-3.369-1.341-3.369-1.341-.454-1.154-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0 1 12 6.836a9.59 9.59 0 0 1 2.504.337c1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.202 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.743 0 .267.18.579.688.481C19.138 20.163 22 16.418 22 12c0-5.523-4.477-10-10-10z" />
8
+ </svg>
9
+ );
10
+
11
+ export default function Layout({ children }: { children?: ReactNode }) {
12
+ return (
13
+ <div className="app">
14
+ <HoneycombBackground />
15
+ <Toil.Head
16
+ titleTemplate="%s By Dacely"
17
+ title="ToilJS"
18
+ meta={[{ name: 'description', content: 'The most performant React framework.' }]}
19
+ />
20
+ <header className="nav">
21
+ <Toil.Link href="/" className="nav-logo">
22
+ <img src="images/logo.svg" alt="ToilJS" width={28} height={28} />
23
+ <span>ToilJS</span>
24
+ </Toil.Link>
25
+
26
+ <nav className="nav-center">
27
+ <Toil.NavLink href="/" end className="nav-center-link">
28
+ Home
29
+ </Toil.NavLink>
30
+ <Toil.NavLink href="/get-started" className="nav-center-link">
31
+ Get Started
32
+ </Toil.NavLink>
33
+ </nav>
34
+
35
+ <nav className="nav-links">
36
+ <Toil.Link href="https://toil.org/docs">Docs</Toil.Link>
37
+ <a
38
+ href="https://github.com/btc-vision/toiljs"
39
+ target="_blank"
40
+ rel="noopener noreferrer"
41
+ className="nav-github">
42
+ <GitHubIcon />
43
+ GitHub
44
+ </a>
45
+ </nav>
46
+ </header>
47
+
48
+ <main className="content">{children}</main>
49
+
50
+ <Footer />
51
+ </div>
52
+ );
53
+ }
@@ -0,0 +1 @@
1
+ # Place images and other static assets here; served at /images/*.
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500">
3
+ <!-- Generator: Adobe Illustrator 30.4.0, SVG Export Plug-In . SVG Version: 2.1.4 Build 226) -->
4
+ <defs>
5
+ <style>
6
+ .st0 {
7
+ fill: #fff;
8
+ }
9
+
10
+ .st1 {
11
+ fill: url(#linear-gradient1);
12
+ }
13
+
14
+ .st2 {
15
+ fill: url(#linear-gradient);
16
+ }
17
+ </style>
18
+ <linearGradient id="linear-gradient" x1="43.27" y1="43.27" x2="467.12" y2="467.12" gradientUnits="userSpaceOnUse">
19
+ <stop offset="0" stop-color="#6990ff"/>
20
+ <stop offset=".03" stop-color="#6479f9"/>
21
+ <stop offset=".08" stop-color="#5d57f0"/>
22
+ <stop offset=".12" stop-color="#583de9"/>
23
+ <stop offset=".17" stop-color="#542ae3"/>
24
+ <stop offset=".23" stop-color="#521ee0"/>
25
+ <stop offset=".28" stop-color="#521be0"/>
26
+ <stop offset=".66" stop-color="#6900f4"/>
27
+ <stop offset="1" stop-color="#7f00f6"/>
28
+ </linearGradient>
29
+ <linearGradient id="linear-gradient1" x1="149.99" y1="355.49" x2="149.99" y2="0" gradientUnits="userSpaceOnUse">
30
+ <stop offset=".15" stop-color="#6990ff" stop-opacity=".6"/>
31
+ <stop offset=".55" stop-color="#531ae1"/>
32
+ </linearGradient>
33
+ </defs>
34
+ <rect class="st2" width="500" height="500" rx="130" ry="130"/>
35
+ <path class="st1" d="M299.98,0L0,355.49v-225.49C0,58.2,58.2,0,130,0h169.98Z"/>
36
+ <path class="st0" d="M106.17,111.11h285.24c9.9,0,16.7,9.96,13.09,19.18l-17.98,45.96c-2.11,5.39-7.31,8.94-13.09,8.94h-74.65c-7.76,0-14.06,6.29-14.06,14.06v214.94c0,7.76-6.29,14.06-14.06,14.06h-45.96c-7.76,0-14.06-6.29-14.06-14.06v-217.25c0-7.76-6.29-14.06-14.06-14.06h-73.66c-5.82,0-11.04-3.59-13.12-9.02l-16.76-43.64c-3.54-9.21,3.26-19.1,13.12-19.1Z"/>
37
+ </svg>
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <meta name="theme-color" content="#080D11" />
7
+ <link rel="icon" type="image/x-icon" href="/favicon.ico" />
8
+ <title>ToilJS By Dacely</title>
9
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
10
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
11
+ <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800;900&display=swap" rel="stylesheet" />
12
+ </head>
13
+ <body>
14
+ <div id="root"></div>
15
+ </body>
16
+ </html>
@@ -0,0 +1,2 @@
1
+ User-agent: *
2
+ Allow: /
@@ -0,0 +1,11 @@
1
+ export default function About() {
2
+ return (
3
+ <main>
4
+ <h1>About</h1>
5
+ <p>
6
+ This page is served by <code>client/routes/about.tsx</code>.
7
+ </p>
8
+ <Toil.Link href="/">Back home</Toil.Link>
9
+ </main>
10
+ );
11
+ }
@@ -0,0 +1,12 @@
1
+ export default function BlogPost() {
2
+ const { id } = Toil.useParams();
3
+ return (
4
+ <main>
5
+ <h1>Blog post {id}</h1>
6
+ <p>
7
+ Dynamic route from <code>client/routes/blog/[id].tsx</code>.
8
+ </p>
9
+ <Toil.Link href="/">Back home</Toil.Link>
10
+ </main>
11
+ );
12
+ }
@@ -0,0 +1,12 @@
1
+ export default function Docs() {
2
+ const { slug } = Toil.useParams();
3
+ return (
4
+ <main>
5
+ <h1>Docs</h1>
6
+ <p>
7
+ Catch-all route <code>client/routes/docs/[...slug].tsx</code> matched: <code>{slug}</code>
8
+ </p>
9
+ <Toil.Link href="/">Back home</Toil.Link>
10
+ </main>
11
+ );
12
+ }
@@ -0,0 +1,84 @@
1
+ export default function GetStarted() {
2
+ return (
3
+ <div className="gs-page">
4
+
5
+ {/* Hero */}
6
+ <div className="gs-hero">
7
+ <h1 className="gs-title">Get Started</h1>
8
+ <p className="gs-desc">Everything you need to build your first ToilJS app.</p>
9
+ </div>
10
+
11
+
12
+ {/* Info grid */}
13
+ <section className="gs-section">
14
+ <h2 className="gs-section-title">Project Structure</h2>
15
+ <div className="gs-grid">
16
+
17
+ <div className="gs-card gs-card--accent1">
18
+ <div className="gs-card-icon">
19
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg>
20
+ </div>
21
+ <h3>File-based Routing</h3>
22
+ <p>Every <code>.tsx</code> file in <code>client/routes/</code> becomes a route. No config required.</p>
23
+ <pre><code>{`index.tsx → /
24
+ about.tsx → /about
25
+ [id].tsx → /:id
26
+ [...slug].tsx → /*`}</code></pre>
27
+ </div>
28
+
29
+ <div className="gs-card gs-card--accent2">
30
+ <div className="gs-card-icon">
31
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/></svg>
32
+ </div>
33
+ <h3>Public Folder</h3>
34
+ <p>Files in <code>public/</code> are copied as-is to the build root. Reference them with an absolute path.</p>
35
+ <pre><code>{`public/images/logo.svg
36
+ → /images/logo.svg`}</code></pre>
37
+ </div>
38
+
39
+ <div className="gs-card gs-card--accent3">
40
+ <div className="gs-card-icon">
41
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg>
42
+ </div>
43
+ <h3>Layout</h3>
44
+ <p><code>client/layout.tsx</code> wraps every page. Use it for your nav, footer, providers, and global styles.</p>
45
+ </div>
46
+
47
+ <div className="gs-card gs-card--accent4">
48
+ <div className="gs-card-icon">
49
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>
50
+ </div>
51
+ <h3>Entry Point</h3>
52
+ <p><code>client/toil.tsx</code> is the app entry. Import global CSS and call <code>Toil.mount()</code> — runs once on startup.</p>
53
+ </div>
54
+
55
+ </div>
56
+ </section>
57
+
58
+ {/* Navigation section */}
59
+ <section className="gs-section">
60
+ <h2 className="gs-section-title">Navigation</h2>
61
+ <div className="gs-card gs-card--flat">
62
+ <div className="gs-card-icon">
63
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
64
+ </div>
65
+ <h3>Use <code>{'<Toil.Link>'}</code> for client-side navigation</h3>
66
+ <p>Avoids full page reloads and keeps transitions instant. Use a regular <code>{'<a>'}</code> only for external links.</p>
67
+ <pre><code>{`// ✅ Internal navigation
68
+ <Toil.Link href="/about">About</Toil.Link>
69
+
70
+ // ✅ External link
71
+ <a href="https://toil.org" target="_blank">Docs</a>`}</code></pre>
72
+ </div>
73
+ </section>
74
+
75
+ <div className="gs-actions">
76
+ <Toil.Link href="/" className="btn btn-secondary">← Back home</Toil.Link>
77
+ <a href="https://toil.org/docs" target="_blank" rel="noopener noreferrer" className="btn btn-primary">
78
+ Read the Docs
79
+ </a>
80
+ </div>
81
+
82
+ </div>
83
+ );
84
+ }
@@ -0,0 +1,80 @@
1
+ const GitHubIcon = () => (
2
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
3
+ <path d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.489.5.092.682-.217.682-.482 0-.237-.009-.868-.013-1.703-2.782.604-3.369-1.341-3.369-1.341-.454-1.154-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0 1 12 6.836a9.59 9.59 0 0 1 2.504.337c1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.202 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.743 0 .267.18.579.688.481C19.138 20.163 22 16.418 22 12c0-5.523-4.477-10-10-10z" />
4
+ </svg>
5
+ );
6
+
7
+ const icons = {
8
+ hmr: (
9
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
10
+ <polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />
11
+ </svg>
12
+ ),
13
+ routing: (
14
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
15
+ <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" />
16
+ </svg>
17
+ ),
18
+ typescript: (
19
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
20
+ <rect x="2" y="2" width="20" height="20" rx="3" fill="currentColor" />
21
+ <path d="M13.5 12H15.5V18H17V12H19V10.5H13.5V12Z" fill="var(--bg)" />
22
+ <path d="M11 10.5C9.07 10.5 7.5 12.07 7.5 14C7.5 15.45 8.38 16.69 9.65 17.23L7.5 18H11C12.93 18 14.5 16.43 14.5 14.5C14.5 13.26 13.86 12.17 12.9 11.55C12.42 11.22 11.73 10.5 11 10.5ZM11 12C12.1 12 13 12.9 13 14C13 15.1 12.1 16 11 16H9.72C9.28 15.57 9 14.81 9 14C9 12.9 9.9 12 11 12Z" fill="var(--bg)" />
23
+ </svg>
24
+ ),
25
+ builds: (
26
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
27
+ <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" />
28
+ <polyline points="3.27 6.96 12 12.01 20.73 6.96" />
29
+ <line x1="12" y1="22.08" x2="12" y2="12" />
30
+ </svg>
31
+ ),
32
+ };
33
+
34
+ const features = [
35
+ { icon: icons.hmr, label: 'Instant HMR' },
36
+ { icon: icons.routing, label: 'File Routing' },
37
+ { icon: icons.typescript, label: 'TypeScript' },
38
+ { icon: icons.builds, label: 'Optimized Builds' },
39
+ ];
40
+
41
+ export default function Home() {
42
+ return (
43
+ <section className="hero">
44
+ <div className="hero-logo">
45
+ <img src="images/logo.svg" className="hero-logo-glow" alt="" aria-hidden="true" width={96} height={96} />
46
+ <img src="images/logo.svg" className="hero-logo-img" alt="ToilJS" width={96} height={96} />
47
+ </div>
48
+
49
+ <h1 className="hero-title">ToilJS</h1>
50
+
51
+ <p className="hero-tagline">
52
+ Next-gen React.<br />
53
+ <span>Zero config.</span>
54
+ </p>
55
+
56
+ <p className="hero-desc">
57
+ File-based routing, blazing-fast HMR, and full TypeScript.
58
+ <br />All powered by Vite.
59
+ </p>
60
+
61
+ <ul className="features">
62
+ {features.map(f => (
63
+ <li key={f.label} className="feature-badge">
64
+ {f.icon}{f.label}
65
+ </li>
66
+ ))}
67
+ </ul>
68
+
69
+ <div className="hero-cta">
70
+ <Toil.Link href="/get-started" className="btn btn-primary">
71
+ Get Started
72
+ </Toil.Link>
73
+ <a className="btn btn-secondary" href="https://github.com/btc-vision/toiljs" target="_blank" rel="noopener noreferrer">
74
+ <GitHubIcon />
75
+ GitHub
76
+ </a>
77
+ </div>
78
+ </section>
79
+ );
80
+ }
@@ -0,0 +1,24 @@
1
+ export default function IoDemo() {
2
+ const writer = new BinaryWriter();
3
+ writer.writeU32(42);
4
+ writer.writeStringWithLength('hello toil');
5
+ const bytes = writer.getBuffer();
6
+
7
+ const reader = new BinaryReader(bytes);
8
+ const n = reader.readU32();
9
+ const s = reader.readStringWithLength();
10
+
11
+ const seen = new FastSet<bigint>();
12
+ seen.add(1n).add(2n).add(1n);
13
+
14
+ return (
15
+ <main>
16
+ <h1>Native IO</h1>
17
+ <p>
18
+ <code>new BinaryWriter()</code> with no import — round-tripped {n} and &quot;{s}&quot; through{' '}
19
+ {bytes.length} bytes; FastSet size {seen.size}.
20
+ </p>
21
+ <Toil.Link href="/">Back home</Toil.Link>
22
+ </main>
23
+ );
24
+ }