@k8ordo/framework 1.0.0 → 1.2.0

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.
package/docs/GUIDE.md CHANGED
@@ -141,8 +141,9 @@ a glob, `.k8ordo/**/*.ts` (an entry naming only the dot-directory leaves its
141
141
  files out), and `href()`'s paths and a page's `params` are typed, and with
142
142
  that export every message's locales. The generated files import without file
143
143
  extensions, so they resolve under `moduleResolution: "bundler"`, as Vite
144
- does. A fresh clone has no `.k8ordo/` until `vite build` or `vite dev`
145
- writes it, so CI runs the build before `tsc`
144
+ does. A fresh clone has no `.k8ordo/` until `vite dev` or `vite build`
145
+ writes it, or `k8ordo generate`, which writes it and builds nothing — what
146
+ CI runs before `tsc`
146
147
  ([The generated files](references/routing.md#the-generated-files)).
147
148
 
148
149
  ```tsx
@@ -234,9 +235,15 @@ The package is split by where the code runs.
234
235
  `dist/server.js` runs, for a server of your own to import. A static build
235
236
  it serves as a static host does, its `_redirects` applied.
236
237
  - `@k8ordo/framework/vercel` — `vercel()`, the plugin that writes a build
237
- of either mode for Vercel.
238
+ of either mode for Vercel, and the types `VercelOptions` and
239
+ `VercelRoute`. Under static mode it also takes routes of your own,
240
+ `beforeFiles` and `beforeNotFound`.
238
241
  - `@k8ordo/framework/generated` — what the generated `.k8ordo/` files
239
242
  import. Not for code written by hand.
243
+ - `k8ordo generate` — the package's command, run in the application's
244
+ directory: writes `.k8ordo/` from its Vite config and builds nothing, for
245
+ `tsc` where a build cannot run
246
+ ([The generated files](references/routing.md#the-generated-files)).
240
247
 
241
248
  `/server` needs nothing from Node but `AsyncLocalStorage`, so it goes
242
249
  wherever the handler goes, and `/serve` is apart from it for that reason.
@@ -245,10 +252,22 @@ dev dependencies.
245
252
 
246
253
  ## The options
247
254
 
248
- `framework()` takes `mode`, which is required, and `routesDir`, the route
249
- directory (default `src/routes`). Three more describe files, so only
250
- `mode: 'static'` takes them — passing them with `mode: 'server'` is a type
251
- error:
255
+ `framework()` takes `mode`, which is required, `routesDir`, the route
256
+ directory (default `src/routes`), and `reactCompiler`, in either mode.
257
+
258
+ `reactCompiler: true` compiles the client components with React Compiler —
259
+ the Rust one, `oxc-transform-react`, through `@vitejs/plugin-react`'s
260
+ `compiler` — in `vite dev` and in the build. Install it beside the framework
261
+ as a dev dependency, in the range the package's README gives under Peer
262
+ Dependencies. Without it, `vite dev` and `vite build` stop as soon as they
263
+ read the config, with React's plugin's own error
264
+ (`React Compiler requires the optional …`), which names
265
+ `react({ compiler: true })`: the option the framework sets for you. Only
266
+ what runs in the browser is compiled; Server Components, and the HTML a
267
+ client component renders on the server, are left as written.
268
+
269
+ Three more describe files, so only `mode: 'static'` takes them — passing
270
+ them with `mode: 'server'` is a type error:
252
271
 
253
272
  - `paths` — the pathnames of routes with parameters, and where a
254
273
  `fallback.tsx`'s shell stands
package/docs/llms.txt CHANGED
@@ -52,16 +52,20 @@ Start with GUIDE.md, then follow the reference most relevant to the task.
52
52
  - [Design Guide](GUIDE.md): choosing a mode and what static mode refuses,
53
53
  setup (install, `vite.config.ts`, `tsconfig.json`, the root layout as the
54
54
  document), `vite dev` and `vite preview` against a static build, the
55
- entries, and the plugin's options.
55
+ entries, and the plugin's options — `reactCompiler` among them, React
56
+ Compiler on the client components, which needs `oxc-transform-react`
57
+ installed.
56
58
 
57
59
  ## References
58
60
 
59
61
  - [Routing](references/routing.md): the `routes/` grammar and every refusal
60
62
  the build names, where a `fallback.tsx` may sit, how a page is sent in
61
- each mode, `loading.tsx`, `route.ts` (methods and `405` under server
63
+ each mode (each page loads only its own client components and CSS, and
64
+ the browser renders once they have loaded), `loading.tsx`, `route.ts` (methods and `405` under server
62
65
  mode, a file under static mode), the generated `.k8ordo/` files (the
63
66
  route table, and the `Register`s: the table's, and `@k8ordo/i18n`'s when
64
- `src/i18n.ts` exports `locales` by name), titles,
67
+ `src/i18n.ts` exports `locales` by name) and `k8ordo generate`, which
68
+ writes them before `tsc` without a build, titles,
65
69
  and fetching the next page ahead (`data-k8ordo-prefetch`).
66
70
  - [Parameters](references/params.md): `paramsSchema` — a refused value is a
67
71
  pathname the pattern does not answer — and, under static mode, the `paths`
@@ -103,7 +107,8 @@ Start with GUIDE.md, then follow the reference most relevant to the task.
103
107
  `node dist/server.js` (`PORT`, `HOST`, every dependency bundled in, and
104
108
  `resolve.external` for one that cannot be), `serve` (compression, `ETag`,
105
109
  `Range`), the request handler under Node.js, Bun, Deno and Cloudflare
106
- Workers, the same-origin rule for a `POST`, and `vercel()` in either mode;
110
+ Workers, the same-origin rule for a `POST`, and `vercel()` in either mode,
111
+ with routes of your own under static mode;
107
112
  a tab opened before a deploy, and Vite's `base`.
108
113
 
109
114
  ## Entry points
@@ -130,7 +135,7 @@ Start with GUIDE.md, then follow the reference most relevant to the task.
130
135
  `<head>`, with the hashes of the framework's own inline scripts on that
131
136
  page added to `script-src` (or `default-src` made into it) and
132
137
  `script-src-elem`; a policy with `'strict-dynamic'`, `frame-ancestors`,
133
- `report-uri` or `sandbox` is refused. `FrameworkOptions` is
138
+ `report-uri`, `report-to` or `sandbox` is refused. `FrameworkOptions` is
134
139
  `StaticOptions | ServerOptions`. This entry loads Vite and is for
135
140
  `vite.config.ts` only.
136
141
  - `@k8ordo/framework/server` — server mode only; a static build refuses any
@@ -179,7 +184,26 @@ Start with GUIDE.md, then follow the reference most relevant to the task.
179
184
  `.vercel/output/` (Build Output API v3) for `vercel build` /
180
185
  `vercel deploy --prebuilt` — the client build as static files at Vite's
181
186
  `base` (`assets/` immutable), and under server mode the request handler
182
- as one streaming Node.js function; under static mode no function, and the
183
- shells' rewrites as routes tried after the files, then `404.html`.
187
+ as one streaming Node.js function; under static mode no function, the
188
+ shells' rewrites as routes tried after the files, then `404.html`, and
189
+ each file a `route.ts` wrote served with the `Content-Type` its `GET`
190
+ answered (`overrides`) where other hosts go by its extension.
191
+ Under static mode `vercel({ beforeFiles, beforeNotFound })` also takes
192
+ routes of the application's own (`VercelRoute`: `src`, `dest`, `status`,
193
+ `headers`, `continue`, `check`, `caseSensitive`, `has`), written as given
194
+ before the files and before `404.html`; Vercel alone applies them,
195
+ matching `src` against the whole pathname (`^/posts/.+$`, not
196
+ `^/posts/`).
184
197
  - `@k8ordo/framework/generated` — what the generated `.k8ordo/` files
185
198
  import (`defineRoutes`, `Register`, …). Not for code written by hand.
199
+ - `k8ordo generate` — the package's one command (its `bin`), run in the
200
+ application's directory: resolves the Vite config there as `vite build`
201
+ does and writes `.k8ordo/` as the build does when it begins, then stops —
202
+ no environment built, no page rendered, `paths` never called — so CI
203
+ runs it before `tsc` without the data a build reads. A `routes/` with
204
+ the problems the build names under
205
+ `routes/ is not a valid pathname space:` fails it the same way (exit
206
+ code 1), with nothing written. What `mode: 'static'` refuses on top of
207
+ those — a `guard.ts`, a `route.ts` answering more than `GET`, a page
208
+ reading `search`, an `export *`, a Server Action, whatever `paths`
209
+ returns — it does not check, so its success is not the build's.
@@ -91,9 +91,18 @@ page — one that reached it from content — is refused. The framework's module
91
91
  script is allowed by where it comes from (`'self'`), since nothing in a file
92
92
  can sign it, which is why the build refuses a policy with `'strict-dynamic'`.
93
93
  It refuses `frame-ancestors`, `report-uri` and `sandbox` too, which a
94
- `<meta>` ignores: set those as headers at the host. Without `csp`, no policy
95
- is written. There is no `nonce()` for this mode: what an application signed
96
- with it would land in the file, and make every build differ.
94
+ `<meta>` ignores: set those as headers at the host. It refuses `report-to`
95
+ as well: the endpoint it names is defined only by a `Reporting-Endpoints`
96
+ response header, so set a policy that reports as a header at the host.
97
+ That header cannot carry the hashes the build adds page by page, and a
98
+ script runs only where every policy allows it: wherever the header decides
99
+ a script element — `script-src` (`default-src` without it) and
100
+ `script-src-elem` — allow `'self'` and `'unsafe-inline'` with no hash or
101
+ nonce beside them (either turns `'unsafe-inline'` off), and keep `csp`,
102
+ without `report-to`, for the `<meta>`, which allows inline scripts only by
103
+ hash. Without `csp`, no policy is written. There is no `nonce()` for this
104
+ mode: what an application signed with it would land in the file, and make
105
+ every build differ.
97
106
 
98
107
  A `fallback.tsx`'s shell draws its page in the browser from data the
99
108
  browser fetches
@@ -505,6 +505,163 @@ case-sensitively, as the route table matches; then `404.html` under a `404`,
505
505
  when the build wrote one. `vercel()` writes them once the last page is
506
506
  written, whichever side of `framework()` it sits.
507
507
 
508
+ **A file a `route.ts` wrote is served with the type its `GET` answered**,
509
+ the `Content-Type` `vite dev` sends, written as that file's entry in the
510
+ `overrides` of `config.json`: a feed at `blog/feed` is
511
+ `application/rss+xml`, not the `application/octet-stream` of a file with no
512
+ extension. The type is written even where the extension says the same, so
513
+ no file is left to the type Vercel gives an extension; only a `GET` that
514
+ named none — a body of bytes with no `Content-Type` — leaves its file to it.
515
+ `vite preview` and `serve` still go by the extension
516
+ ([A route.ts under static mode](routing.md#under-static-mode)).
517
+
518
+ ### Routes of your own
519
+
520
+ Under `mode: 'static'`, `vercel()` also takes routes of the application's
521
+ own, in the language Vercel's Build Output API reads — `src`, a regular
522
+ expression for the pathname, with `dest`, `status`, `headers`, `continue`,
523
+ `check`, `caseSensitive` and `has` — and writes them into
524
+ `.vercel/output/config.json` as given, in two places among its own:
525
+
526
+ ```text
527
+ ...beforeFiles
528
+ { handle: 'filesystem' } the files
529
+ ...the shells' rewrites
530
+ ...beforeNotFound
531
+ 404.html under a 404 when the build wrote one
532
+ { handle: 'hit' }
533
+ assets/ sent immutable
534
+ ```
535
+
536
+ `beforeFiles` is tried before any file, so it is where headers for every
537
+ answer go, and a redirect or a rewrite that has to win over a file that is
538
+ there. `beforeNotFound` is tried once neither a file nor a shell answered,
539
+ so a catch-all of yours there never hides a shell: it is where a URL the
540
+ build wrote nothing for is proxied to another origin, or answered with a 404
541
+ of another body.
542
+
543
+ ```ts
544
+ // vite.config.ts
545
+ import { vercel } from '@k8ordo/framework/vercel';
546
+ import { framework } from '@k8ordo/framework/vite';
547
+ import { defineConfig } from 'vite';
548
+
549
+ const acceptsMarkdown = [
550
+ { type: 'header', key: 'accept', value: '.*text/markdown.*' },
551
+ ] as const;
552
+
553
+ export default defineConfig({
554
+ plugins: [
555
+ framework({ mode: 'static' }),
556
+ vercel({
557
+ beforeFiles: [
558
+ {
559
+ src: '^/.*$',
560
+ headers: { 'X-Content-Type-Options': 'nosniff' },
561
+ continue: true,
562
+ },
563
+ {
564
+ src: '^/((?:[^/]+/)*[^/]+)/$',
565
+ status: 308,
566
+ headers: { Location: '/$1' },
567
+ },
568
+ {
569
+ src: '^/posts/([a-z0-9-]+)$',
570
+ has: acceptsMarkdown,
571
+ dest: '/posts/$1/article.md',
572
+ check: true,
573
+ caseSensitive: true,
574
+ },
575
+ {
576
+ src: '^/feed$',
577
+ headers: { 'Vercel-CDN-Cache-Control': 'max-age=3600' },
578
+ continue: true,
579
+ caseSensitive: true,
580
+ },
581
+ ],
582
+ beforeNotFound: [
583
+ {
584
+ src: '^/feed$',
585
+ dest: 'https://api.example.com/feed',
586
+ caseSensitive: true,
587
+ },
588
+ {
589
+ src: '^/.*$',
590
+ has: acceptsMarkdown,
591
+ dest: '/not-found.md',
592
+ status: 404,
593
+ },
594
+ ],
595
+ }),
596
+ ],
597
+ });
598
+ ```
599
+
600
+ - A route that only adds headers says `continue: true`, and comes before
601
+ the route that answers: an answering route ends the matching. What
602
+ `beforeFiles` adds this way is on every answer the routes lead to — a
603
+ file, a redirect, `404.html`, a `dest` with a `status`, an answer proxied
604
+ from another origin.
605
+ - The redirect takes the trailing slash off and keeps the query:
606
+ `/about/?x=1` goes to `/about?x=1`, which Vercel answers from
607
+ `about/index.html` as it is. Its pattern takes no empty segment, so it
608
+ never answers with `Location: //evil.test`, which a browser reads as
609
+ another origin. Vercel itself answers `//evil.test/` before any route, with
610
+ a 308 to `/evil.test/` that carries none of your headers.
611
+ - `check: true` looks for `dest` among the files. When none is there, the
612
+ matching goes on with `dest` as the pathname: `beforeNotFound` sees
613
+ `/posts/nope/article.md`, not `/posts/nope`. Here a `route.ts` at
614
+ `routes/posts/[slug]/article.md/` wrote each post's markdown beside its
615
+ page, and a client asking for markdown is answered with it. Have `paths`
616
+ give the pages and their markdown from one list of posts, so no post is
617
+ written without the other.
618
+ - `has` matches the header's text against `value`, a regular expression,
619
+ and negotiates nothing: `.*text/markdown.*` takes
620
+ `Accept: text/markdown, text/html;q=0.9`, and not a browser's
621
+ `text/html,application/xhtml+xml,*/*;q=0.8`, though `*/*` would take
622
+ markdown.
623
+ - A proxy is two routes: its headers ahead of the files, and the `dest` that
624
+ answers after them. The `dest` is asked with the request's query:
625
+ `/feed?page=2` fetches `https://api.example.com/feed?page=2`.
626
+ - `dest` with `status` answers with that file under that status, as the
627
+ build's own `404.html` route does.
628
+
629
+ What to keep in mind:
630
+
631
+ - **`src` matches the whole pathname**, never just its start, and never the
632
+ query: `^/posts/` does not match `/posts/first`, and `^/posts/.+$` does.
633
+ - **Only Vercel applies them.** `vite dev`, `vite preview` and `serve`
634
+ answer as if they were not there — no header, no redirect, nothing decided
635
+ by `Accept` — since an imitation of Vercel's routing that differed from it
636
+ would pass locally and fail once deployed. A URL only a route of yours
637
+ answers is a 404 there.
638
+ - **No `Cache-Control` in a route every path takes.** It reaches every file
639
+ too, those under `assets/` among them, which `vercel()` marks `immutable`
640
+ in the `hit` phase, after yours. Give a `Cache-Control` a `src` that names
641
+ the paths it is for.
642
+ - **Vercel matches `src` regardless of case** unless the route says
643
+ `caseSensitive: true`, while the routes `vercel()` writes itself are
644
+ case-sensitive, as the route table is. A route without it answers
645
+ `/POSTS/first` as well.
646
+ - **`has` names a header in lowercase**, as Vercel compares it. `vercel()`
647
+ refuses another spelling when it is called:
648
+
649
+ ```text
650
+ vercel() route ^/posts/([a-z0-9-]+)$ has the header key "Accept" — write it lowercase ("accept"), as Vercel compares it
651
+ ```
652
+
653
+ - **Nothing else is checked.** The routes are written as given — under a
654
+ `base` their `src` and `dest` carry it — and their patterns are Vercel's
655
+ (PCRE), which JavaScript's `RegExp` would misjudge, so a mistake shows once
656
+ deployed. Try a change on a preview deployment first.
657
+ - **Static mode only.** Under `mode: 'server'` the request handler answers
658
+ every URL no file names, and a `guard.ts` or a `route.ts` decides what it
659
+ sends. The build refuses them there:
660
+
661
+ ```text
662
+ vercel() takes beforeFiles and beforeNotFound under mode: 'static' only — under mode: 'server' the handler answers every URL no file names
663
+ ```
664
+
508
665
  ## A tab opened before a deploy
509
666
 
510
667
  A tab keeps running the script it loaded, while every payload it fetches
@@ -98,16 +98,30 @@ as it checks every route file's.
98
98
 
99
99
  ## How a page is sent
100
100
 
101
+ **Each page loads its own.** `page.tsx`, `not-found.tsx`, `route.ts` and
102
+ `fallback.tsx` are imported when a request reaches them, so the client
103
+ components each renders and the CSS each imports — its Server Components'
104
+ CSS Modules included — go only to the pages that render it. What a
105
+ `layout.tsx`, `error.tsx` or `loading.tsx` imports, every page below it
106
+ loads: import CSS every page needs in the root layout. A route file imported
107
+ from anywhere else — a layout importing an export of a page — is in every
108
+ page again, and the build warns, naming it.
109
+
101
110
  **Under `mode: 'server'` an async page answers, then streams.** The document
102
111
  waits for the page's own component — its data — before anything is sent,
103
112
  because the page may still say `notFound()`
104
113
  ([Errors](errors.md#a-page-that-is-not-there)); what the page puts under a
105
114
  `<Suspense>` follows in the same response as it arrives. The browser hydrates
106
- when the last of it is in place, not before: a boundary still on its way
107
- cannot be hydrated, and a context that changes as the page hydrates — a
108
- colour scheme read from the browser — would make React render it again
109
- beside the copy still streaming in. Until then the page is what it is
110
- without JavaScript: links load documents and forms post.
115
+ when the last of it is in place and the client components it renders have
116
+ loaded, not before: a boundary still on its way cannot be hydrated, and a
117
+ context that changes as the page hydrates — a colour scheme read from the
118
+ browser — would make React render it again beside the copy still streaming
119
+ in, or put a boundary's fallback in place of a component still loading.
120
+ Until then the page is what it is without JavaScript: links load documents
121
+ and forms post. A client navigation likewise keeps the page on screen until
122
+ the next one's client components have loaded; what the next page puts under
123
+ a `<Suspense>` of its own — a `loading.tsx` is one — shows its fallback until
124
+ it arrives.
111
125
 
112
126
  **Under `mode: 'static'` a file is written whole.** The build waits for every
113
127
  `<Suspense>` boundary on the page and writes each in place, so a file never
@@ -280,10 +294,14 @@ with params needs `paths`, as a page's does
280
294
  ([Parameters](params.md#routes-with-parameters)) — with a request whose
281
295
  origin is `site` when that option is given (an RSS feed's links are
282
296
  absolute), and writes what it answered as the file at that pathname:
283
- `dist/client/feed.xml`. A static host then serves it with the type its
284
- extension says. The `GET` has to answer `200`; anything else stops the build
285
- naming the pathname. A file answers nothing but `GET`, so a `route.ts`
286
- exporting another method is refused by name, in the build and in `vite dev`:
297
+ `dist/client/feed.xml`. A file keeps no type of its own, so a static host
298
+ serves it with the type its extension says — `vite preview` and `serve` too,
299
+ which send a file with no extension as `application/octet-stream`. On
300
+ Vercel, `vercel()` serves it with the `Content-Type` its `GET` answered, the
301
+ type `vite dev` sends ([Deploying to Vercel](deploy.md#deploying-to-vercel)).
302
+ The `GET` has to answer `200`; anything else stops the build naming the
303
+ pathname. A file answers nothing but `GET`, so a `route.ts` exporting
304
+ another method is refused by name, in the build and in `vite dev`:
287
305
 
288
306
  ```
289
307
  static build writes a route.ts as the file its GET answers, and a file cannot answer another method — these export one:
@@ -299,6 +317,11 @@ A `route.ts` at `/` cannot be a file (the host serves `/` from `index.html`),
299
317
  nor one with pages written below it, which would need a directory of the same
300
318
  name. What it writes is not a page, so `sitemap.xml` leaves it out.
301
319
 
320
+ Name the type in the `Response`. A string body with none is sent as
321
+ `text/plain;charset=UTF-8` — the `Response` sets it — so a `sitemap.xml`
322
+ returned that way is plain text on Vercel and in `vite dev`, whatever its
323
+ extension says. `vite dev` shows it before a deploy does.
324
+
302
325
  ## The generated files
303
326
 
304
327
  The framework writes `.k8ordo/` and keeps it in step with the directories.
@@ -309,12 +332,14 @@ source, so it is yours to read:
309
332
  // .k8ordo/routes.gen.ts
310
333
  import { defineRoutes } from '@k8ordo/framework/generated';
311
334
  import type { ParamsOf, ParsedParams } from '@k8ordo/framework/generated';
335
+ import { lazy } from 'react';
312
336
  import type { ComponentType, ReactNode } from 'react';
313
337
 
314
338
  import layout from '../src/routes/layout';
315
- import page from '../src/routes/page';
316
- import products_id_page from '../src/routes/products/[id]/page';
317
- import products_page from '../src/routes/products/page';
339
+
340
+ const page = () => import('../src/routes/page');
341
+ const products_page = () => import('../src/routes/products/page');
342
+ const products_id_page = () => import('../src/routes/products/[id]/page');
318
343
 
319
344
  type Page<P extends string, S extends readonly unknown[] = []> = ComponentType<{
320
345
  params: ParsedParams<P, S>;
@@ -330,6 +355,12 @@ export const paramSchemas = {} as const;
330
355
 
331
356
  export const searchReaders = {} as const;
332
357
 
358
+ export const pageModules = {
359
+ '/': page,
360
+ '/products': products_page,
361
+ '/products/:id': products_id_page,
362
+ } as const;
363
+
333
364
  export const routeModules = {} as const;
334
365
 
335
366
  export const guards = {} as const;
@@ -342,11 +373,11 @@ export const routes = defineRoutes({
342
373
  '/': {
343
374
  layout: layout satisfies Layout<'/'>,
344
375
  children: {
345
- '/': page satisfies Page<'/'>,
376
+ '/': lazy(page) satisfies Page<'/'>,
346
377
  '/products': {
347
378
  children: {
348
- '/': products_page satisfies Page<'/products'>,
349
- '/:id': products_id_page satisfies Page<'/products/:id'>,
379
+ '/': lazy(products_page) satisfies Page<'/products'>,
380
+ '/:id': lazy(products_id_page) satisfies Page<'/products/:id'>,
350
381
  },
351
382
  },
352
383
  },
@@ -356,20 +387,24 @@ export const routes = defineRoutes({
356
387
 
357
388
  Each `satisfies` checks a route file's props against the pattern its directory
358
389
  puts it under — a type check, so `tsc` reports a mismatch and `vite build`,
359
- which does not type-check, passes. Under `mode: 'server'` the `Page` and
390
+ which does not type-check, passes. A page and a not-found stand in `routes`
391
+ as `lazy()` over what imports them: `pageModules` lists, per pattern, what
392
+ imports the page or the not-found that answers it, and the handler renders
393
+ what it imported in that place. Under `mode: 'server'` the `Page` and
360
394
  `Layout` types also carry `request`, typed by `RouteRequest` from
361
395
  `@k8ordo/framework/server`. `redirects` is where each `redirect.ts`
362
396
  sends the visitor once the walk of `routes` reaches its pattern,
363
397
  `paramSchemas` holds, per page pattern, the schemas it runs when the walk
364
- reaches that pattern, before the page renders, `routeModules` the `route.ts`
365
- that answers a pattern (the place of each, and of each `redirect.ts`, in
366
- `routes` is held by a component that renders nothing), `guards` the
367
- `guard.ts` files that run before a pattern answers, outer first,
398
+ reaches that pattern, before the page renders — a page's own read off the
399
+ page once the walk has imported it — `routeModules` what imports the
400
+ `route.ts` that answers a pattern (the place of each, and of each
401
+ `redirect.ts`, in `routes` is held by a component that renders nothing),
402
+ `guards` the `guard.ts` files that run before a pattern answers, outer first,
368
403
  `searchReaders` what reads the search for a page that exports `search`, and
369
- `fallbacks`, under `mode: 'static'`, the `fallback.tsx` beside a page and the
370
- parameters its shell may leave to the browser (under `mode: 'server'` it is
371
- always empty, and no `fallback.tsx` is imported); all six are empty here
372
- because no route file declares any.
404
+ `fallbacks`, under `mode: 'static'`, what imports the `fallback.tsx` beside a
405
+ page and the parameters its shell may leave to the browser (under
406
+ `mode: 'server'` it is always empty, and no `fallback.tsx` is imported); all
407
+ six are empty here because no route file declares any.
373
408
 
374
409
  `.k8ordo/register.gen.ts` registers that table with the framework — and with
375
410
  `@k8ordo/state` when the application depends on it — so typed paths work
@@ -417,12 +452,26 @@ Neither file names `@k8ordo/router`: they import from
417
452
  `@k8ordo/framework/generated`, so the application's code, generated or not,
418
453
  reads only the framework.
419
454
 
420
- `vite build` and `vite dev` write both files as they start, and nothing else
421
- does, so a fresh clone — a CI checkout among them — has neither until one of
422
- them runs. Run the build before `tsc`:
423
-
424
- ```bash
425
- vite build && tsc --noEmit
455
+ `vite build` and `vite dev` write both files as they start, so a fresh
456
+ clone — a CI checkout among them — has neither until something writes them.
457
+ `k8ordo generate`, the package's command, writes them and stops there: it
458
+ reads the Vite config in the working directory as `vite build` does, so the
459
+ `mode` and `routesDir` given to `framework()` are the ones it uses, then
460
+ builds nothing and renders no page — `paths` is never called, and nothing a
461
+ page reads is touched. A `routes/` with the problems of
462
+ [What the build refuses](#what-the-build-refuses) fails it as it fails the
463
+ build, with `routes/ is not a valid pathname space:` and every problem
464
+ named, and nothing is written. What `mode: 'static'` refuses on top of
465
+ those — a `guard.ts`, a `route.ts` answering more than `GET`, a page
466
+ reading `search`, an `export *`, a Server Action, whatever `paths`
467
+ returns — it does not check, so its success is not the build's. Run it
468
+ before `tsc`; it is also how a CI job without the data a build reads — the
469
+ database behind `paths`, say — has the types:
470
+
471
+ ```yaml
472
+ # .github/workflows/ci.yml, in the application's directory
473
+ - run: pnpm exec k8ordo generate
474
+ - run: pnpm exec tsc --noEmit
426
475
  ```
427
476
 
428
477
  Without the files, `tsc` checks against no table: `href` takes any string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k8ordo/framework",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "The k8ordo framework: routes/ compiled into React Server Components, run with or without a server.",
5
5
  "keywords": [
6
6
  "k8ordo",
@@ -23,6 +23,9 @@
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/k35o/k8ordo.git"
25
25
  },
26
+ "bin": {
27
+ "k8ordo": "./dist/cli.mjs"
28
+ },
26
29
  "files": [
27
30
  "dist/**",
28
31
  "docs/**"
@@ -62,7 +65,7 @@
62
65
  },
63
66
  "dependencies": {
64
67
  "@vitejs/plugin-react": "6.1.2",
65
- "@vitejs/plugin-rsc": "0.5.36",
68
+ "@vitejs/plugin-rsc": "0.5.38",
66
69
  "compressible": "2.0.18",
67
70
  "fresh": "2.0.0",
68
71
  "mime-types": "3.0.2",
@@ -73,26 +76,33 @@
73
76
  "devDependencies": {
74
77
  "@arethetypeswrong/cli": "0.18.5",
75
78
  "@k8ordo/framework-engine": "^0.1.1",
76
- "@k8ordo/router": "^1.0.0",
79
+ "@k8ordo/router": "^1.2.0",
77
80
  "@types/compressible": "2.0.3",
78
81
  "@types/fresh": "0.5.3",
79
82
  "@types/mime-types": "3.0.1",
80
83
  "@types/range-parser": "1.2.7",
81
84
  "@types/react": "19.3.0",
85
+ "oxc-transform-react": "0.152.0",
82
86
  "publint": "0.3.25",
83
- "react": "19.3.0",
84
- "react-dom": "19.3.0",
87
+ "react": "19.3.1",
88
+ "react-dom": "19.3.1",
85
89
  "typescript": "7.0.2",
86
- "vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
87
- "vite-plus": "1.1.0",
88
- "vitest": "5.0.3"
90
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
91
+ "vite-plus": "1.3.0",
92
+ "vitest": "5.0.5"
89
93
  },
90
94
  "peerDependencies": {
91
- "@k8ordo/router": "^1.0.0",
95
+ "@k8ordo/router": "^1.2.0",
96
+ "oxc-transform-react": "^0.152.0",
92
97
  "react": ">=19.3.0",
93
98
  "react-dom": ">=19.3.0",
94
99
  "vite": ">=8.0.0"
95
100
  },
101
+ "peerDependenciesMeta": {
102
+ "oxc-transform-react": {
103
+ "optional": true
104
+ }
105
+ },
96
106
  "engines": {
97
107
  "node": ">=24.0.0"
98
108
  },