@kayjs/kay 2.0.0-beta.3 → 2.0.0-beta.4

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 (91) hide show
  1. package/llms.txt +42 -0
  2. package/package.json +24 -13
  3. package/src/build/bundle.ts +11 -51
  4. package/src/build/client-plugin.ts +108 -0
  5. package/src/build/compile.ts +4 -2
  6. package/src/build/graph.ts +16 -3
  7. package/src/build/index.ts +23 -15
  8. package/src/build/islands.ts +28 -30
  9. package/src/build/manifest.ts +6 -3
  10. package/src/build/report.ts +82 -13
  11. package/src/build/resolve.ts +6 -7
  12. package/src/build/routes.ts +12 -21
  13. package/src/build/server-entry.ts +1 -1
  14. package/src/cli/check.ts +49 -43
  15. package/src/cli/commands.ts +224 -0
  16. package/src/cli/index.ts +46 -302
  17. package/src/cli/new.ts +15 -509
  18. package/src/cli/upgrade-plugins.ts +168 -0
  19. package/src/cli/upgrade.ts +220 -0
  20. package/src/compiler/analyze.ts +319 -565
  21. package/src/compiler/ast.ts +39 -0
  22. package/src/compiler/data-keys.ts +233 -0
  23. package/src/compiler/dom.ts +18 -15
  24. package/src/compiler/interactivity.ts +174 -0
  25. package/src/compiler/mistakes.ts +19 -1
  26. package/src/compiler/server-only.ts +4 -1
  27. package/src/compiler/shared.ts +1 -1
  28. package/src/compiler/ssr.ts +28 -28
  29. package/src/context.ts +1 -1
  30. package/src/dev/index.ts +15 -23
  31. package/src/dom/extras.ts +43 -12
  32. package/src/dom/index.ts +25 -1
  33. package/src/index.ts +0 -13
  34. package/src/jsx-runtime.ts +1 -1
  35. package/src/plugins/context.ts +8 -6
  36. package/src/plugins/index.ts +2 -2
  37. package/src/plugins/load.ts +25 -2
  38. package/src/plugins/public.ts +6 -0
  39. package/src/plugins/services.ts +15 -3
  40. package/src/plugins/types.ts +7 -11
  41. package/src/server/action-registry.ts +10 -4
  42. package/src/server/action.ts +8 -2
  43. package/src/server/document.ts +13 -1
  44. package/src/server/errors.ts +7 -5
  45. package/src/server/index.ts +9 -10
  46. package/src/server/lifecycle.ts +22 -0
  47. package/src/server/plugin-host.ts +6 -8
  48. package/src/server/public.ts +15 -0
  49. package/src/server/request-scope.ts +22 -0
  50. package/src/server/stream.ts +4 -3
  51. package/src/ssr/context.ts +25 -0
  52. package/src/ssr/index.ts +10 -7
  53. package/src/test/browser.ts +180 -0
  54. package/src/test/index.ts +4 -1
  55. package/templates/_shared/AGENTS.md +5 -0
  56. package/templates/_shared/CLAUDE.md +1 -0
  57. package/templates/_shared/public/robots.txt +2 -0
  58. package/templates/_shared/tsconfig.json +19 -0
  59. package/templates/app/.env.example +4 -0
  60. package/templates/app/kay.config.ts +11 -0
  61. package/templates/app/package.json +20 -0
  62. package/templates/app/src/auth.ts +14 -0
  63. package/templates/app/src/routes/_layout.tsx +32 -0
  64. package/templates/app/src/routes/dashboard/_middleware.ts +3 -0
  65. package/templates/app/src/routes/dashboard/index.tsx +13 -0
  66. package/templates/app/src/routes/index.tsx +15 -0
  67. package/templates/app/src/routes/login.tsx +34 -0
  68. package/templates/app/src/styles/app.css +7 -0
  69. package/templates/blog/content/posts/welcome.md +9 -0
  70. package/templates/blog/kay.config.ts +23 -0
  71. package/templates/blog/package.json +21 -0
  72. package/templates/blog/src/posts.ts +26 -0
  73. package/templates/blog/src/routes/_layout.tsx +20 -0
  74. package/templates/blog/src/routes/blog/[slug].tsx +31 -0
  75. package/templates/blog/src/routes/index.tsx +29 -0
  76. package/templates/blog/src/styles/app.css +10 -0
  77. package/templates/fullstack/kay.config.ts +6 -0
  78. package/templates/fullstack/package.json +18 -0
  79. package/templates/fullstack/src/actions/greet.ts +19 -0
  80. package/templates/fullstack/src/components/Counter.tsx +10 -0
  81. package/templates/fullstack/src/components/GreetForm.tsx +26 -0
  82. package/templates/fullstack/src/routes/_layout.tsx +14 -0
  83. package/templates/fullstack/src/routes/api/health.ts +5 -0
  84. package/templates/fullstack/src/routes/index.tsx +13 -0
  85. package/templates/fullstack/src/styles/app.css +29 -0
  86. package/templates/minimal/kay.config.ts +6 -0
  87. package/templates/minimal/package.json +18 -0
  88. package/templates/minimal/src/components/Counter.tsx +10 -0
  89. package/templates/minimal/src/routes/_layout.tsx +14 -0
  90. package/templates/minimal/src/routes/index.tsx +11 -0
  91. package/templates/minimal/src/styles/app.css +22 -0
@@ -0,0 +1,26 @@
1
+ import { signal } from '@kayjs/kay'
2
+ import { greet } from '../actions/greet'
3
+
4
+ export function GreetForm() {
5
+ const name = signal('')
6
+ const reply = signal('')
7
+
8
+ async function onSubmit(e: SubmitEvent) {
9
+ e.preventDefault()
10
+ const res = await greet({ name: name.value })
11
+ reply.value = res.ok ? res.data.message : res.error
12
+ }
13
+
14
+ return (
15
+ <form class="greet-form" action={greet.url} method="post" onSubmit={onSubmit}>
16
+ <input
17
+ name="name"
18
+ placeholder="Your name"
19
+ value={name.value}
20
+ onInput={(e) => { name.value = (e.target as HTMLInputElement).value }}
21
+ />
22
+ <button type="submit">Greet</button>
23
+ {reply.value && <span>{reply.value}</span>}
24
+ </form>
25
+ )
26
+ }
@@ -0,0 +1,14 @@
1
+ import type { KayChild } from '@kayjs/kay'
2
+ import { Head } from '@kayjs/kay'
3
+ import '../styles/app.css'
4
+
5
+ export default function Layout({ children }: { children: KayChild }) {
6
+ return (
7
+ <>
8
+ <Head>
9
+ <title>__APP_NAME__</title>
10
+ </Head>
11
+ <main>{children}</main>
12
+ </>
13
+ )
14
+ }
@@ -0,0 +1,5 @@
1
+ import type { RequestContext } from '@kayjs/kay/server'
2
+
3
+ export function GET(ctx: RequestContext) {
4
+ return ctx.json({ ok: true, runtime: 'bun' })
5
+ }
@@ -0,0 +1,13 @@
1
+ import { Counter } from '../components/Counter'
2
+ import { GreetForm } from '../components/GreetForm'
3
+
4
+ export default async function Home() {
5
+ return (
6
+ <section>
7
+ <h1>Welcome to Kay</h1>
8
+ <p>Zero-directive islands, Standard-Schema actions, and Bun speed.</p>
9
+ <Counter initial={0} />
10
+ <GreetForm />
11
+ </section>
12
+ )
13
+ }
@@ -0,0 +1,29 @@
1
+ *, *::before, *::after { box-sizing: border-box; }
2
+ body {
3
+ margin: 0;
4
+ font-family: system-ui, -apple-system, sans-serif;
5
+ line-height: 1.6;
6
+ color: #111827;
7
+ background: #fafafa;
8
+ }
9
+ main {
10
+ max-width: 44rem;
11
+ margin: 4rem auto;
12
+ padding: 0 1.5rem;
13
+ }
14
+ button {
15
+ font: inherit;
16
+ padding: 0.5rem 1rem;
17
+ border-radius: 6px;
18
+ border: 1px solid #d1d5db;
19
+ background: #fff;
20
+ cursor: pointer;
21
+ }
22
+ button:hover { background: #f3f4f6; }
23
+
24
+ .greet-form {
25
+ margin-top: 1.5rem;
26
+ display: flex;
27
+ gap: 0.5rem;
28
+ align-items: center;
29
+ }
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from '@kayjs/kay/config'
2
+
3
+ export default defineConfig({
4
+ lang: 'en',
5
+ plugins: [],
6
+ })
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "__APP_NAME__",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "kay dev",
7
+ "build": "kay build",
8
+ "start": "kay start",
9
+ "check": "kay check"
10
+ },
11
+ "dependencies": {
12
+ "@kayjs/kay": "__KAY_VERSION__"
13
+ },
14
+ "devDependencies": {
15
+ "@types/bun": "latest",
16
+ "typescript": "^6.0.3"
17
+ }
18
+ }
@@ -0,0 +1,10 @@
1
+ import { signal } from '@kayjs/kay'
2
+
3
+ export function Counter({ initial = 0 }: { initial?: number }) {
4
+ const count = signal(initial)
5
+ return (
6
+ <button type="button" onClick={() => count.value++}>
7
+ Count: {count.value}
8
+ </button>
9
+ )
10
+ }
@@ -0,0 +1,14 @@
1
+ import type { KayChild } from '@kayjs/kay'
2
+ import { Head } from '@kayjs/kay'
3
+ import '../styles/app.css'
4
+
5
+ export default function Layout({ children }: { children: KayChild }) {
6
+ return (
7
+ <>
8
+ <Head>
9
+ <title>__APP_NAME__</title>
10
+ </Head>
11
+ <main>{children}</main>
12
+ </>
13
+ )
14
+ }
@@ -0,0 +1,11 @@
1
+ import { Counter } from '../components/Counter'
2
+
3
+ export default async function Home() {
4
+ return (
5
+ <section>
6
+ <h1>Welcome to Kay</h1>
7
+ <p>Zero-directive islands, native TSX, and Bun speed.</p>
8
+ <Counter initial={0} />
9
+ </section>
10
+ )
11
+ }
@@ -0,0 +1,22 @@
1
+ *, *::before, *::after { box-sizing: border-box; }
2
+ body {
3
+ margin: 0;
4
+ font-family: system-ui, -apple-system, sans-serif;
5
+ line-height: 1.6;
6
+ color: #111827;
7
+ background: #fafafa;
8
+ }
9
+ main {
10
+ max-width: 44rem;
11
+ margin: 4rem auto;
12
+ padding: 0 1.5rem;
13
+ }
14
+ button {
15
+ font: inherit;
16
+ padding: 0.5rem 1rem;
17
+ border-radius: 6px;
18
+ border: 1px solid #d1d5db;
19
+ background: #fff;
20
+ cursor: pointer;
21
+ }
22
+ button:hover { background: #f3f4f6; }