@k8ordo/framework 2.3.1 → 3.0.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/README.md +25 -12
- package/dist/generated.d.mts +2 -1
- package/dist/headers-BxB_jJVk.mjs +73 -0
- package/dist/index.d.mts +2 -1
- package/dist/paths-type-DtsL8JuC.d.mts +19 -0
- package/dist/runtime/app-router.mjs +20 -7
- package/dist/runtime/client-files.d.mts +6 -5
- package/dist/runtime/client-files.mjs +17 -9
- package/dist/runtime/client-ready.d.mts +7 -1
- package/dist/runtime/client-ready.mjs +2 -1
- package/dist/runtime/entry.rsc.d.mts +27 -1
- package/dist/runtime/entry.rsc.mjs +66 -9
- package/dist/runtime/entry.ssr.d.mts +6 -1
- package/dist/runtime/entry.ssr.mjs +8 -3
- package/dist/runtime/payload.d.mts +19 -4
- package/dist/runtime/payload.mjs +20 -5
- package/dist/runtime/prefetch.d.mts +29 -8
- package/dist/runtime/prefetch.mjs +95 -24
- package/dist/serve.mjs +5 -3
- package/dist/{static-DnbgGIoy.d.mts → static-c-nX9Juk.d.mts} +11 -17
- package/dist/{static-file-BAjwBMMl.mjs → static-file-BEk_xO5y.mjs} +157 -24
- package/dist/{static-host-B-1fAfAw.mjs → static-host-CyAmsL_7.mjs} +1 -1
- package/dist/vercel.d.mts +1 -1
- package/dist/vercel.mjs +30 -15
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +231 -111
- package/docs/GUIDE.md +26 -27
- package/docs/llms.txt +37 -28
- package/docs/references/deploy.md +69 -9
- package/docs/references/errors.md +39 -2
- package/docs/references/params.md +166 -127
- package/docs/references/routing.md +192 -49
- package/package.json +9 -9
- package/dist/shared-dir-CNXFRZgP.mjs +0 -9
|
@@ -29,11 +29,12 @@ src/lib/ every other module, flat
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
- `page.tsx`, `layout.tsx`, `not-found.tsx`, `error.tsx`, `loading.tsx`,
|
|
32
|
-
`fallback.tsx`, `redirect.ts`, `guard.ts` and `route.ts` are
|
|
33
|
-
filenames the grammar accepts. `mode: 'static'` refuses
|
|
34
|
-
([Choosing a mode](../GUIDE.md#what-static-mode-refuses)), and
|
|
35
|
-
`mode: 'server'` never renders `fallback.tsx
|
|
36
|
-
|
|
32
|
+
`fallback.tsx`, `paths.ts`, `redirect.ts`, `guard.ts` and `route.ts` are
|
|
33
|
+
the only filenames the grammar accepts. `mode: 'static'` refuses
|
|
34
|
+
`guard.ts` ([Choosing a mode](../GUIDE.md#what-static-mode-refuses)), and
|
|
35
|
+
`mode: 'server'` never renders `fallback.tsx` and never reads `paths.ts`,
|
|
36
|
+
though it checks where each sits
|
|
37
|
+
([Values the build did not write](#values-the-build-did-not-write)). Any
|
|
37
38
|
other file is refused: components live outside `routes/` in
|
|
38
39
|
`src/components/` and every other module — Server Actions, schemas, state
|
|
39
40
|
definitions, data, helpers — in `src/lib/`, and a route file imports them
|
|
@@ -53,9 +54,10 @@ src/lib/ every other module, flat
|
|
|
53
54
|
receive `request` ([Reading the request](guards.md#reading-the-request)).
|
|
54
55
|
- A parameter's values arrive with the request under `mode: 'server'`, and
|
|
55
56
|
need no list. Under `mode: 'static'` the build has no request to take them
|
|
56
|
-
from, and
|
|
57
|
+
from, and a `paths.ts` in the parameter's directory returns them, for
|
|
58
|
+
every route below it
|
|
57
59
|
([Routes with parameters](params.md#routes-with-parameters)); a
|
|
58
|
-
`fallback.tsx` beside the page answers the ones it does not
|
|
60
|
+
`fallback.tsx` beside the page answers the ones it does not return.
|
|
59
61
|
|
|
60
62
|
```tsx
|
|
61
63
|
// src/routes/products/[id]/page.tsx
|
|
@@ -194,8 +196,9 @@ Such a script runs before any of the page's CSS has loaded: it can set a
|
|
|
194
196
|
class or an attribute on `<html>`, but a style it computes reads none of
|
|
195
197
|
that CSS. A script with a `src` or a `type` stays where React wrote it, and
|
|
196
198
|
so does one inside a `<noscript>` or a `<template>`, and every script in
|
|
197
|
-
`<body>`. Under `mode: 'static'` the policy's `<meta>`
|
|
198
|
-
`<
|
|
199
|
+
`<body>`. Under `mode: 'static'` the policy's `<meta>` comes right after
|
|
200
|
+
the `<meta charSet>` that opens `<head>` (first in `<head>` when there is
|
|
201
|
+
none), ahead of the moved scripts, so the policy covers them
|
|
199
202
|
([Content Security Policy](csp.md#static-mode-hashes-in-a-meta)).
|
|
200
203
|
|
|
201
204
|
## What the build refuses
|
|
@@ -204,7 +207,7 @@ Every problem is reported, not just the first, and each names the file:
|
|
|
204
207
|
|
|
205
208
|
| routes/ contains | error |
|
|
206
209
|
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
207
|
-
| `products/helper.ts` | `routes/ holds only page.tsx, layout.tsx, not-found.tsx, error.tsx, redirect.ts, guard.ts, route.ts, loading.tsx, fallback.tsx — move "helper.ts" out of routes/`
|
|
210
|
+
| `products/helper.ts` | `routes/ holds only page.tsx, layout.tsx, not-found.tsx, error.tsx, redirect.ts, guard.ts, route.ts, loading.tsx, fallback.tsx, paths.ts — move "helper.ts" out of routes/` |
|
|
208
211
|
| `[123]/page.tsx` | `"[123]" is not a valid param directory — use [name] with a letter or underscore first` |
|
|
209
212
|
| `pro ducts/page.tsx` | `"pro ducts" cannot be a URL segment — use letters, digits, . _ ~ or -` |
|
|
210
213
|
| `[id]/things/[id]/page.tsx` | `":id" is already taken by an ancestor — params must be unique within a path` |
|
|
@@ -221,7 +224,8 @@ Every problem is reported, not just the first, and each names the file:
|
|
|
221
224
|
| `feed/[id]/route.ts` and `feed/[id]/fallback.tsx` | `fallback.tsx stands in for the page.tsx beside it, and "feed/[id]" has none` |
|
|
222
225
|
| `posts/[id]/layout.tsx` beside `posts/[id]/fallback.tsx` | `fallback.tsx cannot sit beside layout.tsx — that layout receives every parameter of "posts/[id]", so no shell could leave one to the browser; move the layout one directory up, or into page.tsx and fallback.tsx` |
|
|
223
226
|
| `about/page.tsx` and `about/fallback.tsx` | `fallback.tsx stands in for values the build did not write, and "/about" has no parameter; remove it` |
|
|
224
|
-
| `[locale]/layout.tsx` above `[locale]/about/fallback.tsx` | `fallback.tsx has nothing to leave to the browser — [locale]/layout.tsx receives every parameter of "/:locale/about"; remove fallback.tsx and
|
|
227
|
+
| `[locale]/layout.tsx` above `[locale]/about/fallback.tsx` | `fallback.tsx has nothing to leave to the browser — [locale]/layout.tsx receives every parameter of "/:locale/about"; remove fallback.tsx and return the values from a paths.ts` |
|
|
228
|
+
| `posts/paths.ts` | `paths.ts gives the values of its directory's parameter, and "posts" is not a [param] directory — move it into the parameter's directory` |
|
|
225
229
|
|
|
226
230
|
The generated table lists literal segments before parameters, so `about/`
|
|
227
231
|
beside `[slug]/` is reachable without saying anything. A route group holds
|
|
@@ -229,16 +233,39 @@ both kinds under one key and the table cannot interleave across it, which is
|
|
|
229
233
|
the one shape where a declared route can still be shadowed — so it is reported
|
|
230
234
|
rather than shipped.
|
|
231
235
|
|
|
232
|
-
The `fallback.tsx` rows hold in both modes, so switching
|
|
233
|
-
change to the files. `mode: 'static'` refuses more on top of
|
|
234
|
-
needs a request
|
|
235
|
-
|
|
236
|
+
The `fallback.tsx` and `paths.ts` rows hold in both modes, so switching
|
|
237
|
+
modes needs no change to the files. `mode: 'static'` refuses more on top of
|
|
238
|
+
these: whatever needs a request
|
|
239
|
+
([What static mode refuses](../GUIDE.md#what-static-mode-refuses)), a
|
|
240
|
+
parameter no `paths.ts` gives values to
|
|
241
|
+
([Routes with parameters](params.md#routes-with-parameters)), and a shell
|
|
242
|
+
standing where it cannot
|
|
236
243
|
([What else stops the build](params.md#what-else-stops-the-build)).
|
|
237
244
|
|
|
245
|
+
## The values of a parameter
|
|
246
|
+
|
|
247
|
+
Under `mode: 'static'`, a `paths.ts` is what the build asks for the values
|
|
248
|
+
a parameter takes: its default export, a function typed `Paths<Pattern>`,
|
|
249
|
+
returns them, and every page, `route.ts` and `redirect.ts` below its
|
|
250
|
+
directory is written once per value. What it is handed, what a value is and
|
|
251
|
+
where it runs are in
|
|
252
|
+
[Routes with parameters](params.md#routes-with-parameters); the grammar's
|
|
253
|
+
part is where it may sit.
|
|
254
|
+
|
|
255
|
+
- **In a `[param]` directory**, whose parameter it gives values to. In the
|
|
256
|
+
root, a literal directory or a group it is refused.
|
|
257
|
+
- **With or without a `page.tsx` beside it.** The values are for whatever
|
|
258
|
+
sits below: `[locale]/paths.ts` beside only a `layout.tsx` gives the
|
|
259
|
+
locale of every page under it.
|
|
260
|
+
- **With or without a `fallback.tsx` beside it.** With both, the values
|
|
261
|
+
returned are written as pages and the shell answers the rest.
|
|
262
|
+
|
|
263
|
+
Under `mode: 'server'` it is not read, and nothing of it is built.
|
|
264
|
+
|
|
238
265
|
## Values the build did not write
|
|
239
266
|
|
|
240
267
|
Under `mode: 'static'`, a `fallback.tsx` beside a `page.tsx` is what the
|
|
241
|
-
values `paths`
|
|
268
|
+
values no `paths.ts` returns are answered with: a shell, the layouts above
|
|
242
269
|
written as HTML with the `fallback.tsx` in the page's place, which a host
|
|
243
270
|
serves for any such value and the browser fills in from the URL. What it
|
|
244
271
|
renders, how it reads the value and what it costs are in
|
|
@@ -250,7 +277,8 @@ the grammar's part is where it may sit.
|
|
|
250
277
|
- **Under a pattern with a parameter**, at least one of which no layout
|
|
251
278
|
above it receives. A layout above is written into the shell once, as
|
|
252
279
|
HTML, for every value the shell answers, so a parameter it receives is one
|
|
253
|
-
the shell has to know —
|
|
280
|
+
the shell has to know — given by a `paths.ts` in that parameter's
|
|
281
|
+
directory, which puts a shell below each of its values
|
|
254
282
|
(`/ja/posts/:id`). The parameters left to the browser are the rest.
|
|
255
283
|
- **With no `layout.tsx` beside it.** That layout would receive every
|
|
256
284
|
parameter, and leave the browser none. Move it one directory up, where it
|
|
@@ -259,9 +287,9 @@ the grammar's part is where it may sit.
|
|
|
259
287
|
|
|
260
288
|
It receives no props, and an `error.tsx` or `loading.tsx` beside it or above
|
|
261
289
|
wraps it as it wraps the page. It answers its own page's pattern and nothing
|
|
262
|
-
below it: `posts/[id]/comments/page.tsx`
|
|
263
|
-
a `fallback.tsx` of its own, and a
|
|
264
|
-
|
|
290
|
+
below it: `posts/[id]/comments/page.tsx` is written for the values
|
|
291
|
+
`posts/[id]/paths.ts` returns, or keeps a `fallback.tsx` of its own, and a
|
|
292
|
+
`redirect.ts` or `route.ts` there answers only the values returned.
|
|
265
293
|
|
|
266
294
|
Under `mode: 'server'` every value is rendered by its page, per request, and
|
|
267
295
|
nothing of a `fallback.tsx` is built.
|
|
@@ -361,8 +389,8 @@ as much as a guard does: [`cookies()`](guards.md#cookies),
|
|
|
361
389
|
### Under static mode
|
|
362
390
|
|
|
363
391
|
The build calls its `GET` once for each pathname the site has — a pattern
|
|
364
|
-
with params
|
|
365
|
-
([Parameters](params.md#routes-with-parameters)) — with a request whose
|
|
392
|
+
with params takes its values from the `paths.ts` files above it, as a
|
|
393
|
+
page's does ([Parameters](params.md#routes-with-parameters)) — with a request whose
|
|
366
394
|
origin is `site` when that option is given (an RSS feed's links are
|
|
367
395
|
absolute), and writes what it answered as the file at that pathname:
|
|
368
396
|
`dist/client/feed.xml`. A file keeps no type of its own, so a static host
|
|
@@ -388,20 +416,22 @@ A `route.ts` at `/` cannot be a file (the host serves `/` from `index.html`),
|
|
|
388
416
|
nor one with pages written below it, which would need a directory of the same
|
|
389
417
|
name. What it writes is not a page, so `sitemap.xml` leaves it out.
|
|
390
418
|
|
|
391
|
-
Nor can a `route.ts` write a file the build writes itself — `
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
419
|
+
Nor can a `route.ts` write a file the build writes itself — `404.html`
|
|
420
|
+
beside a `not-found.tsx`, `_redirects` when there are shells,
|
|
421
|
+
`client-files.json`, a page's `index.html` or `index.rsc` — since one would
|
|
422
|
+
replace the other. It stops before it renders anything, naming every such
|
|
423
|
+
`route.ts` in one error, each beside what is in its way:
|
|
396
424
|
|
|
397
425
|
```
|
|
398
426
|
static build writes a route.ts as the file its GET answers, and these cannot be written — remove the route.ts, or what else is written there:
|
|
399
|
-
|
|
427
|
+
client-files.json: src/routes/client-files.json/route.ts, and the build lists there what each page loads beyond its payload
|
|
400
428
|
```
|
|
401
429
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
430
|
+
`sitemap.xml` is the exception: a `route.ts` there is the application's own
|
|
431
|
+
list of the site, with the dates and priorities only it knows, so the build
|
|
432
|
+
writes none of its own and leaves the file to it — `site` given or not. Keep
|
|
433
|
+
`site` all the same: it is the origin of the `request.url` every `route.ts`
|
|
434
|
+
is handed, which a sitemap's absolute URLs are built from. Rules of your own for a host go in
|
|
405
435
|
`public/_redirects`, which the build adds to its own. `vite dev` does not
|
|
406
436
|
stop: only the build writes the files.
|
|
407
437
|
|
|
@@ -457,6 +487,8 @@ export const redirects = {} as const;
|
|
|
457
487
|
|
|
458
488
|
export const fallbacks = {} as const;
|
|
459
489
|
|
|
490
|
+
export const paths = {} as const;
|
|
491
|
+
|
|
460
492
|
export const routes = defineRoutes({
|
|
461
493
|
'/': {
|
|
462
494
|
layout: layout satisfies Layout<'/'>,
|
|
@@ -491,8 +523,11 @@ page once the walk has imported it — `routeModules` what imports the
|
|
|
491
523
|
`searchReaders` what reads the search for a page that exports `search`, and
|
|
492
524
|
`fallbacks`, under `mode: 'static'`, what imports the `fallback.tsx` beside a
|
|
493
525
|
page and the parameters its shell may leave to the browser (under
|
|
494
|
-
`mode: 'server'` it is always empty, and no `fallback.tsx` is imported)
|
|
495
|
-
|
|
526
|
+
`mode: 'server'` it is always empty, and no `fallback.tsx` is imported), and
|
|
527
|
+
`paths`, under `mode: 'static'`, what imports each `paths.ts`, by its file,
|
|
528
|
+
each checked against `Paths` of its directory's pattern in a `PathsChecks`
|
|
529
|
+
type (under `mode: 'server'` it too is empty); all seven are empty here
|
|
530
|
+
because no route file declares any.
|
|
496
531
|
|
|
497
532
|
`.k8ordo/register.gen.ts` registers that table with the framework — and with
|
|
498
533
|
`@k8ordo/state` when the application depends on it — so typed paths work
|
|
@@ -545,16 +580,16 @@ clone — a CI checkout among them — has neither until something writes them.
|
|
|
545
580
|
`k8ordo generate`, the package's command, writes them and stops there: it
|
|
546
581
|
reads the Vite config in the working directory as `vite build` does, so the
|
|
547
582
|
`mode` and `routesDir` given to `framework()` are the ones it uses, then
|
|
548
|
-
builds nothing and renders no page — `paths` is
|
|
583
|
+
builds nothing and renders no page — no `paths.ts` is read, and nothing a
|
|
549
584
|
page reads is touched. A `routes/` with the problems of
|
|
550
585
|
[What the build refuses](#what-the-build-refuses) fails it as it fails the
|
|
551
586
|
build, with `routes/ is not a valid pathname space:` and every problem
|
|
552
587
|
named, and nothing is written. What `mode: 'static'` refuses on top of
|
|
553
588
|
those — a `guard.ts`, a `route.ts` answering more than `GET`, a page
|
|
554
|
-
reading `search`, an `export *`, a Server Action, whatever `paths`
|
|
589
|
+
reading `search`, an `export *`, a Server Action, whatever a `paths.ts`
|
|
555
590
|
returns — it does not check, so its success is not the build's. Run it
|
|
556
591
|
before `tsc`; it is also how a CI job without the data a build reads — the
|
|
557
|
-
database behind `paths`, say — has the types:
|
|
592
|
+
database behind a `paths.ts`, say — has the types:
|
|
558
593
|
|
|
559
594
|
```yaml
|
|
560
595
|
# .github/workflows/ci.yml, in the application's directory
|
|
@@ -591,6 +626,96 @@ Keep one `<title>` on screen at a time: the root layout renders none, each
|
|
|
591
626
|
page renders its own, and `not-found.tsx` renders one too. Two titles at once
|
|
592
627
|
is not a fallback chain — React renders both.
|
|
593
628
|
|
|
629
|
+
## Counting page views
|
|
630
|
+
|
|
631
|
+
A page change here is not a document load, and it is not `pushState`
|
|
632
|
+
either — the router commits it through the Navigation API — so an analytics
|
|
633
|
+
script that counts only loads, or that watches the History API, misses
|
|
634
|
+
it. The platform says when a page change is done: `navigatesuccess` fires
|
|
635
|
+
once the new page is on screen, its `<title>` in place.
|
|
636
|
+
|
|
637
|
+
```tsx
|
|
638
|
+
'use client';
|
|
639
|
+
|
|
640
|
+
import { useEffect } from 'react';
|
|
641
|
+
|
|
642
|
+
export function PageViews() {
|
|
643
|
+
useEffect(() => {
|
|
644
|
+
let counted = location.pathname;
|
|
645
|
+
const count = () => {
|
|
646
|
+
// a search or a fragment that moved is a navigation too
|
|
647
|
+
if (location.pathname === counted) return;
|
|
648
|
+
counted = location.pathname;
|
|
649
|
+
gtag('event', 'page_view', {
|
|
650
|
+
page_location: location.href,
|
|
651
|
+
page_title: document.title,
|
|
652
|
+
});
|
|
653
|
+
};
|
|
654
|
+
navigation.addEventListener('navigatesuccess', count);
|
|
655
|
+
return () => {
|
|
656
|
+
navigation.removeEventListener('navigatesuccess', count);
|
|
657
|
+
};
|
|
658
|
+
}, []);
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
Render it from the root layout; the same listener works from a plain
|
|
664
|
+
script with no React at all. `usePathname()` is not the moment to count
|
|
665
|
+
from: it follows the URL, which the router commits before the next page
|
|
666
|
+
arrives, so the title read then is still the page being left. Turn off the
|
|
667
|
+
tool's own counting of history changes as well — going back and forward
|
|
668
|
+
still fires `popstate`, and those views would be counted twice.
|
|
669
|
+
|
|
670
|
+
## MDX
|
|
671
|
+
|
|
672
|
+
The framework compiles no MDX; an application adds a compiler as a Vite
|
|
673
|
+
plugin, ahead of `framework()` and before the framework's own transforms see
|
|
674
|
+
the file:
|
|
675
|
+
|
|
676
|
+
```ts
|
|
677
|
+
// vite.config.ts
|
|
678
|
+
import { framework } from '@k8ordo/framework/vite';
|
|
679
|
+
import mdx from '@mdx-js/rollup';
|
|
680
|
+
import { defineConfig } from 'vite';
|
|
681
|
+
|
|
682
|
+
export default defineConfig({
|
|
683
|
+
plugins: [{ enforce: 'pre', ...mdx() }, framework({ mode: 'static' })],
|
|
684
|
+
});
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
An `.mdx` file is then a module whose default export is a Server Component,
|
|
688
|
+
imported like any other — statically, or late through `import.meta.glob` so
|
|
689
|
+
each page reads only its own:
|
|
690
|
+
|
|
691
|
+
```tsx
|
|
692
|
+
// src/routes/posts/[slug]/page.tsx
|
|
693
|
+
const posts = import.meta.glob<{ default: ComponentType }>(
|
|
694
|
+
'../../../content/*.mdx',
|
|
695
|
+
);
|
|
696
|
+
|
|
697
|
+
export default async function PostPage({ params }: PageProps<'/posts/:slug'>) {
|
|
698
|
+
const load = posts[`../../../content/${params.slug}.mdx`];
|
|
699
|
+
if (load === undefined) notFound();
|
|
700
|
+
const { default: Post } = await load();
|
|
701
|
+
return <Post />;
|
|
702
|
+
}
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
**CSS an `.mdx` file imports reaches the pages that render it**, as a `.tsx`
|
|
706
|
+
module's does: `import './post.module.css'` or `import 'katex/dist/katex.css'`
|
|
707
|
+
at the top of the file is linked in the HTML of the pages rendering that
|
|
708
|
+
file's default export, and of no other. No query on the import is needed.
|
|
709
|
+
(`?vite-rsc-css-export=default`, the RSC plugin's own, still works and is
|
|
710
|
+
left alone.)
|
|
711
|
+
|
|
712
|
+
The stylesheets ride on the component the module exports, in an `.mdx` as in
|
|
713
|
+
a `.tsx`: a module that imports CSS and exports only a table of components
|
|
714
|
+
(`export const components = { h1: Heading }`) for another module to render
|
|
715
|
+
carries none of it to the page. Export a component that renders with the
|
|
716
|
+
table — `export function Article({ children })` — from the module that
|
|
717
|
+
imports the CSS.
|
|
718
|
+
|
|
594
719
|
## Fetching the next page ahead
|
|
595
720
|
|
|
596
721
|
The client runtime listens on the whole document for a pointer moving onto a
|
|
@@ -605,10 +730,14 @@ with them their stylesheets, which apply to the page on screen from then on
|
|
|
605
730
|
A touch screen has no hover, and a tap's press and click come together,
|
|
606
731
|
leaving nothing to fetch ahead in. So under `mode: 'static'`, where the
|
|
607
732
|
primary pointer is coarse (`(pointer: coarse)`), the runtime fetches the
|
|
608
|
-
links on screen instead:
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
733
|
+
links on screen instead: once the document's `load` event has fired, each
|
|
734
|
+
link that has stayed on screen for a second, one at a time in the order
|
|
735
|
+
they appeared, at low fetch priority, passing over a link that left the
|
|
736
|
+
screen before its turn. While a page change loads it fetches nothing more,
|
|
737
|
+
and cancels a prefetch on its way to another page, so the page being
|
|
738
|
+
loaded has the connection to itself; that link is fetched first once the
|
|
739
|
+
new page shows. Under `mode: 'server'` it does not — every link a visitor
|
|
740
|
+
scrolls past would be a render on the server.
|
|
612
741
|
|
|
613
742
|
Only a link a click would load in place is fetched: the same origin and below
|
|
614
743
|
Vite's `base`, no `download`, no `target` other than `_self`, and not the
|
|
@@ -652,15 +781,29 @@ navigation when another overtakes it, unless a later navigation is waiting
|
|
|
652
781
|
for it too — the same as a fetch the navigation had started itself.
|
|
653
782
|
|
|
654
783
|
Under `mode: 'static'` the build also writes `client-files.json`: for each
|
|
655
|
-
page, the scripts and stylesheets its client components need
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
784
|
+
page, the scripts and stylesheets its client components need and the
|
|
785
|
+
stylesheets its Server Components link, less those every page loads. The
|
|
786
|
+
runtime reads it at low priority once the document runs, and whenever it
|
|
787
|
+
asks for a page's payload — a prefetch or a navigation — it links that
|
|
788
|
+
page's files at the same moment and at the payload's priority
|
|
789
|
+
(`<link rel="modulepreload">` for a script, `<link rel="preload"
|
|
790
|
+
as="style">` for a stylesheet) instead of waiting for the payload to name
|
|
791
|
+
them, a round trip later. The links on screen are fetched only once the
|
|
792
|
+
list has been read. A stylesheet still applies only once the page that
|
|
793
|
+
needs it is shown, and the page waits for it: a client component's once
|
|
794
|
+
that component loads, a Server Component's once it has arrived. A page the
|
|
795
|
+
list leaves out — a shell's value, or a host that lost the file — loads as
|
|
796
|
+
it would without one, its Server Components' stylesheets fetched as its
|
|
797
|
+
payload names them.
|
|
798
|
+
|
|
799
|
+
A page fetched ahead has its stylesheets fetched too, and they apply only
|
|
800
|
+
once the page is visited. Until then Chromium logs that the file "was
|
|
801
|
+
preloaded using link preload but not used within a few seconds", once per
|
|
802
|
+
file — more of them under a touch screen, where the links on screen are
|
|
803
|
+
fetched ahead. The warning is harmless: a visit uses what was fetched.
|
|
804
|
+
`<link rel="prefetch">`, which would not warn, is not in Safari, so it is
|
|
805
|
+
not used. Mark a long list `data-k8ordo-prefetch="false"` to fetch, and
|
|
806
|
+
warn, less.
|
|
664
807
|
|
|
665
808
|
Under `mode: 'server'` a prefetch is a render, as a navigation is — the
|
|
666
809
|
reason to mark a link to an expensive page. The platform's Speculation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k8ordo/framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"registry": "https://registry.npmjs.org"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@vitejs/plugin-react": "6.1
|
|
68
|
-
"@vitejs/plugin-rsc": "0.5.
|
|
67
|
+
"@vitejs/plugin-react": "6.2.1",
|
|
68
|
+
"@vitejs/plugin-rsc": "0.5.39",
|
|
69
69
|
"compressible": "2.0.18",
|
|
70
70
|
"fresh": "2.0.0",
|
|
71
71
|
"mime-types": "3.0.2",
|
|
@@ -75,25 +75,25 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@arethetypeswrong/cli": "0.18.5",
|
|
78
|
-
"@k8ordo/framework-engine": "^0.1.
|
|
79
|
-
"@k8ordo/router": "^
|
|
78
|
+
"@k8ordo/framework-engine": "^0.1.3",
|
|
79
|
+
"@k8ordo/router": "^3.0.0",
|
|
80
80
|
"@types/compressible": "2.0.3",
|
|
81
81
|
"@types/fresh": "0.5.3",
|
|
82
82
|
"@types/mime-types": "3.0.1",
|
|
83
83
|
"@types/range-parser": "1.2.7",
|
|
84
84
|
"@types/react": "19.3.0",
|
|
85
|
-
"oxc-transform-react": "0.
|
|
85
|
+
"oxc-transform-react": "0.156.0",
|
|
86
86
|
"publint": "0.3.25",
|
|
87
87
|
"react": "19.3.1",
|
|
88
88
|
"react-dom": "19.3.1",
|
|
89
89
|
"typescript": "7.0.2",
|
|
90
90
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
91
91
|
"vite-plus": "1.4.0",
|
|
92
|
-
"vitest": "5.0
|
|
92
|
+
"vitest": "5.1.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@k8ordo/router": "^
|
|
96
|
-
"oxc-transform-react": "
|
|
95
|
+
"@k8ordo/router": "^3.0.0",
|
|
96
|
+
"oxc-transform-react": ">=0.152.0 <0.157.0",
|
|
97
97
|
"react": ">=19.3.0",
|
|
98
98
|
"react-dom": ">=19.3.0",
|
|
99
99
|
"vite": ">=8.1.0"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
// ../framework-engine/dist/plugin/shared-dir.mjs
|
|
3
|
-
/** The deepest directory holding both `a` and `b`. */
|
|
4
|
-
const sharedDir = (a, b) => {
|
|
5
|
-
let dir = a;
|
|
6
|
-
while (path.relative(dir, b).startsWith("..")) dir = path.dirname(dir);
|
|
7
|
-
return dir;
|
|
8
|
-
};
|
|
9
|
-
export { sharedDir as t };
|