@uniflowed/router 0.34.0 → 0.36.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/action.js +5 -5
- package/client.js +20 -20
- package/handler.js +6 -6
- package/http-client.js +10 -10
- package/index.js +3 -3
- package/instrumentation.js +5 -5
- package/internal/action-endpoint.js +7 -7
- package/internal/action-wire.js +3 -3
- package/internal/base-path.js +3 -3
- package/internal/boundaries.js +8 -8
- package/internal/boundary-data.js +12 -12
- package/internal/compose.js +4 -4
- package/internal/devtools.js +1 -1
- package/internal/diagnostics.js +8 -8
- package/internal/error-view.js +6 -6
- package/internal/flight-browser.js +6 -6
- package/internal/flight-rows.js +4 -4
- package/internal/flight-ssr.js +3 -3
- package/internal/flight.js +26 -26
- package/internal/form-action.js +11 -11
- package/internal/hydrate-options.js +1 -1
- package/internal/hydration.js +37 -37
- package/internal/inspector.js +15 -15
- package/internal/native-links.js +3 -3
- package/internal/native-tree.js +11 -11
- package/internal/navigation-cache.js +12 -12
- package/internal/payload-rows.js +2 -2
- package/internal/payload.js +10 -10
- package/internal/resolve.js +103 -103
- package/internal/resolved-summary.js +76 -76
- package/internal/routing.js +52 -52
- package/internal/runtime.js +47 -47
- package/internal/search-params.js +1 -1
- package/internal/shell.js +8 -8
- package/internal/stream.js +44 -44
- package/middleware.js +11 -11
- package/native-navigation.js +21 -21
- package/native.js +45 -45
- package/package.json +4 -4
- package/rsc-client.js +5 -5
- package/rsc-ssr.js +31 -31
- package/rsc.js +17 -17
- package/server-components.js +5 -5
- package/server.js +33 -33
- package/testing.js +62 -62
package/native.js
CHANGED
|
@@ -35,12 +35,12 @@ export type { NativeLinkSource } from "./internal/native-links.js";
|
|
|
35
35
|
export type NativeNavigationKind = "push" | "replace" | "prefetch";
|
|
36
36
|
|
|
37
37
|
export type NativeNavigationEvent = {|
|
|
38
|
-
readonly kind: NativeNavigationKind,
|
|
39
|
-
readonly href: string,
|
|
38
|
+
readonly kind : NativeNavigationKind,
|
|
39
|
+
readonly href : string,
|
|
40
40
|
readonly pathname: string,
|
|
41
|
-
readonly search: string,
|
|
42
|
-
readonly route: string,
|
|
43
|
-
readonly params: RouteParams,
|
|
41
|
+
readonly search : string,
|
|
42
|
+
readonly route : string,
|
|
43
|
+
readonly params : RouteParams,
|
|
44
44
|
|};
|
|
45
45
|
|
|
46
46
|
export type NativeScreenMap = {
|
|
@@ -49,8 +49,8 @@ export type NativeScreenMap = {
|
|
|
49
49
|
|
|
50
50
|
export type NativeScreenEntry = {|
|
|
51
51
|
readonly screen: string,
|
|
52
|
-
readonly route: string,
|
|
53
|
-
readonly file: string,
|
|
52
|
+
readonly route : string,
|
|
53
|
+
readonly file : string,
|
|
54
54
|
|};
|
|
55
55
|
|
|
56
56
|
export type NativeScreenManifest = {|
|
|
@@ -68,42 +68,42 @@ export type NativeScreenManifestOptions = {|
|
|
|
68
68
|
|};
|
|
69
69
|
|
|
70
70
|
export type NativeScreenPayload = {|
|
|
71
|
-
readonly screen: string,
|
|
72
|
-
readonly href: string,
|
|
71
|
+
readonly screen : string,
|
|
72
|
+
readonly href : string,
|
|
73
73
|
readonly pathname: string,
|
|
74
|
-
readonly search: string,
|
|
75
|
-
readonly route: string,
|
|
76
|
-
readonly params: RouteParams,
|
|
74
|
+
readonly search : string,
|
|
75
|
+
readonly route : string,
|
|
76
|
+
readonly params : RouteParams,
|
|
77
77
|
|};
|
|
78
78
|
|
|
79
79
|
export type NativeScreenNavigationState = {|
|
|
80
|
-
readonly params: RouteParams,
|
|
81
|
-
readonly href: string,
|
|
80
|
+
readonly params : RouteParams,
|
|
81
|
+
readonly href : string,
|
|
82
82
|
readonly pathname: string,
|
|
83
|
-
readonly search: string,
|
|
84
|
-
readonly route: string,
|
|
83
|
+
readonly search : string,
|
|
84
|
+
readonly route : string,
|
|
85
85
|
|};
|
|
86
86
|
|
|
87
87
|
export type NativeNavigator = {|
|
|
88
|
-
readonly push
|
|
89
|
-
readonly replace
|
|
88
|
+
readonly push? : (event: NativeNavigationEvent) => mixed | Promise<mixed>,
|
|
89
|
+
readonly replace? : (event: NativeNavigationEvent) => mixed | Promise<mixed>,
|
|
90
90
|
readonly prefetch?: (event: NativeNavigationEvent) => mixed | Promise<mixed>,
|
|
91
91
|
|};
|
|
92
92
|
|
|
93
93
|
export type NativeScreenNavigator = {|
|
|
94
|
-
readonly push
|
|
94
|
+
readonly push? : (screen: string, state: NativeScreenNavigationState) => mixed | Promise<mixed>,
|
|
95
95
|
readonly replace?: (screen: string, state: NativeScreenNavigationState) => mixed | Promise<mixed>,
|
|
96
96
|
readonly prefetch?: (
|
|
97
97
|
screen: string,
|
|
98
|
-
state: NativeScreenNavigationState,
|
|
98
|
+
state : NativeScreenNavigationState,
|
|
99
99
|
) => mixed | Promise<mixed>,
|
|
100
100
|
|};
|
|
101
101
|
|
|
102
102
|
export type NativeRouter = {|
|
|
103
|
-
readonly push: (to: string) => Promise<void>,
|
|
104
|
-
readonly replace: (to: string) => Promise<void>,
|
|
103
|
+
readonly push : (to: string) => Promise<void>,
|
|
104
|
+
readonly replace : (to: string) => Promise<void>,
|
|
105
105
|
readonly prefetch: (to: string) => Promise<void>,
|
|
106
|
-
readonly resolve: (to: string, kind?: NativeNavigationKind) => NativeNavigationEvent,
|
|
106
|
+
readonly resolve : (to: string, kind?: NativeNavigationKind) => NativeNavigationEvent,
|
|
107
107
|
|};
|
|
108
108
|
|
|
109
109
|
export type NativeNavigationErrorCode =
|
|
@@ -131,7 +131,7 @@ export class NativeNavigationError extends Error {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export function createNativeRouter(
|
|
134
|
-
table: RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
134
|
+
table : RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
135
135
|
navigator: NativeNavigator,
|
|
136
136
|
): NativeRouter {
|
|
137
137
|
const resolve = (to: string, kind?: NativeNavigationKind = "push"): NativeNavigationEvent =>
|
|
@@ -158,12 +158,12 @@ export function createNativeRouter(
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
export function createNativeScreenRouter(
|
|
161
|
-
table: RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
162
|
-
screens: NativeScreenMap,
|
|
161
|
+
table : RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
162
|
+
screens : NativeScreenMap,
|
|
163
163
|
navigator: NativeScreenNavigator,
|
|
164
164
|
): NativeRouter {
|
|
165
165
|
return createNativeRouter(table, {
|
|
166
|
-
push: (event) => invokeScreenNavigator(navigator, screens, event),
|
|
166
|
+
push : (event) => invokeScreenNavigator(navigator, screens, event),
|
|
167
167
|
replace: (event) => invokeScreenNavigator(navigator, screens, event),
|
|
168
168
|
prefetch: (event) => {
|
|
169
169
|
if (typeof navigator.prefetch !== "function") return;
|
|
@@ -173,7 +173,7 @@ export function createNativeScreenRouter(
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export function createNativeScreenManifest(
|
|
176
|
-
table: RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
176
|
+
table : RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
177
177
|
options?: NativeScreenManifestOptions,
|
|
178
178
|
): NativeScreenManifest {
|
|
179
179
|
const screens: { [string]: string } = {};
|
|
@@ -224,7 +224,7 @@ export function nativeScreenName(routePath: string): string {
|
|
|
224
224
|
|
|
225
225
|
export function resolveNativeNavigation(
|
|
226
226
|
table: RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
227
|
-
to: string,
|
|
227
|
+
to : string,
|
|
228
228
|
kind?: NativeNavigationKind = "push",
|
|
229
229
|
): NativeNavigationEvent {
|
|
230
230
|
const href = normalizeNativeHref(to, table);
|
|
@@ -251,13 +251,13 @@ export function resolveNativeNavigation(
|
|
|
251
251
|
href,
|
|
252
252
|
pathname,
|
|
253
253
|
search,
|
|
254
|
-
route: matched.route.path,
|
|
254
|
+
route : matched.route.path,
|
|
255
255
|
params: matched.params,
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
export function nativeScreenPayload(
|
|
260
|
-
event: NativeNavigationEvent,
|
|
260
|
+
event : NativeNavigationEvent,
|
|
261
261
|
screens: NativeScreenMap,
|
|
262
262
|
): NativeScreenPayload {
|
|
263
263
|
const screen = screens[event.route];
|
|
@@ -271,11 +271,11 @@ export function nativeScreenPayload(
|
|
|
271
271
|
}
|
|
272
272
|
return {
|
|
273
273
|
screen,
|
|
274
|
-
href: event.href,
|
|
274
|
+
href : event.href,
|
|
275
275
|
pathname: event.pathname,
|
|
276
|
-
search: event.search,
|
|
277
|
-
route: event.route,
|
|
278
|
-
params: event.params,
|
|
276
|
+
search : event.search,
|
|
277
|
+
route : event.route,
|
|
278
|
+
params : event.params,
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
|
|
@@ -283,16 +283,16 @@ export function nativeScreenNavigationState(
|
|
|
283
283
|
payload: NativeScreenPayload,
|
|
284
284
|
): NativeScreenNavigationState {
|
|
285
285
|
return {
|
|
286
|
-
params: payload.params,
|
|
287
|
-
href: payload.href,
|
|
286
|
+
params : payload.params,
|
|
287
|
+
href : payload.href,
|
|
288
288
|
pathname: payload.pathname,
|
|
289
|
-
search: payload.search,
|
|
290
|
-
route: payload.route,
|
|
289
|
+
search : payload.search,
|
|
290
|
+
route : payload.route,
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
function normalizeNativeHref(
|
|
295
|
-
to: string,
|
|
295
|
+
to : string,
|
|
296
296
|
table: RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
297
297
|
): string {
|
|
298
298
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(to) || to.startsWith("//")) {
|
|
@@ -322,7 +322,7 @@ function normalizeNativeHref(
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
function screenNameFor(
|
|
325
|
-
route: RouteRecord<mixed, mixed, mixed, mixed, mixed>,
|
|
325
|
+
route : RouteRecord<mixed, mixed, mixed, mixed, mixed>,
|
|
326
326
|
options?: NativeScreenManifestOptions,
|
|
327
327
|
): string {
|
|
328
328
|
const screen =
|
|
@@ -354,7 +354,7 @@ function titlePart(segment: string): string {
|
|
|
354
354
|
|
|
355
355
|
async function invokeNavigator(
|
|
356
356
|
navigator: NativeNavigator,
|
|
357
|
-
event: NativeNavigationEvent,
|
|
357
|
+
event : NativeNavigationEvent,
|
|
358
358
|
): Promise<void> {
|
|
359
359
|
if (event.kind === "push") {
|
|
360
360
|
if (typeof navigator.push !== "function") {
|
|
@@ -382,8 +382,8 @@ function missingMethod(event: NativeNavigationEvent): NativeNavigationError {
|
|
|
382
382
|
|
|
383
383
|
async function invokeScreenNavigator(
|
|
384
384
|
navigator: NativeScreenNavigator,
|
|
385
|
-
screens: NativeScreenMap,
|
|
386
|
-
event: NativeNavigationEvent,
|
|
385
|
+
screens : NativeScreenMap,
|
|
386
|
+
event : NativeNavigationEvent,
|
|
387
387
|
): Promise<void> {
|
|
388
388
|
const payload = nativeScreenPayload(event, screens);
|
|
389
389
|
const state = nativeScreenNavigationState(payload);
|
|
@@ -408,7 +408,7 @@ async function invokeScreenNavigator(
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
async function loadNativeRoute(
|
|
411
|
-
table: RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
411
|
+
table : RouteTable<mixed, mixed, mixed, mixed, mixed>,
|
|
412
412
|
pathname: string,
|
|
413
413
|
): Promise<void> {
|
|
414
414
|
const matched = matchRoute(table.routes, pathname);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniflowed/router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "The file-system router for Flow React applications: matching, layouts, loaders, navigation, server rendering and hydration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@uniflowed/hooks": "0.
|
|
77
|
-
"@uniflowed/server": "0.
|
|
78
|
-
"@uniflowed/validator": "0.
|
|
76
|
+
"@uniflowed/hooks": "0.36.0",
|
|
77
|
+
"@uniflowed/server": "0.36.0",
|
|
78
|
+
"@uniflowed/validator": "0.36.0"
|
|
79
79
|
}
|
|
80
80
|
}
|
package/rsc-client.js
CHANGED
|
@@ -75,12 +75,12 @@ export { acceptHotRouteModules, refreshForHotUpdate } from "./internal/runtime.j
|
|
|
75
75
|
* version it found; see `./internal/react-version.js`.
|
|
76
76
|
*/
|
|
77
77
|
export async function hydrateFlight(options: {|
|
|
78
|
-
readonly App: React.ComponentType<AppProps>,
|
|
79
|
-
readonly strictMode
|
|
80
|
-
readonly navigation
|
|
81
|
-
readonly basePath
|
|
78
|
+
readonly App : React.ComponentType<AppProps>,
|
|
79
|
+
readonly strictMode? : boolean,
|
|
80
|
+
readonly navigation? : Navigation,
|
|
81
|
+
readonly basePath? : string,
|
|
82
82
|
readonly trailingSlash?: TrailingSlash,
|
|
83
|
-
readonly staleTime
|
|
83
|
+
readonly staleTime? : number,
|
|
84
84
|
|}): Promise<void> {
|
|
85
85
|
requireServerComponentsReact("@uniflowed/router/rsc/client");
|
|
86
86
|
installNavigation(options.navigation ?? "client");
|
package/rsc-ssr.js
CHANGED
|
@@ -113,13 +113,13 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
113
113
|
*/
|
|
114
114
|
async function documentOf(
|
|
115
115
|
stream: ReadableStream<Uint8Array>,
|
|
116
|
-
url: string,
|
|
116
|
+
url : string,
|
|
117
117
|
assets: RenderAssets,
|
|
118
118
|
settings: {|
|
|
119
|
-
readonly onError: (error: mixed) => void,
|
|
119
|
+
readonly onError : (error: mixed) => void,
|
|
120
120
|
readonly transformHead?: (html: string) => Promise<string>,
|
|
121
|
-
readonly onStream
|
|
122
|
-
readonly formState
|
|
121
|
+
readonly onStream? : (record: StreamRecord) => void,
|
|
122
|
+
readonly formState? : FormState,
|
|
123
123
|
|},
|
|
124
124
|
): Promise<DocumentBody> {
|
|
125
125
|
const [forHtml, forBrowser] = stream.tee();
|
|
@@ -130,11 +130,11 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
130
130
|
const nonce = currentNonce();
|
|
131
131
|
try {
|
|
132
132
|
return await renderDocument(<App url={url} flight={readPayload(forHtml)} />, {
|
|
133
|
-
shell: shellFor(assets, nonce, settings.formState),
|
|
134
|
-
onError: settings.onError,
|
|
133
|
+
shell : shellFor(assets, nonce, settings.formState),
|
|
134
|
+
onError : settings.onError,
|
|
135
135
|
transformHead: settings.transformHead,
|
|
136
|
-
onStream: settings.onStream,
|
|
137
|
-
payload: forBrowser,
|
|
136
|
+
onStream : settings.onStream,
|
|
137
|
+
payload : forBrowser,
|
|
138
138
|
nonce,
|
|
139
139
|
formState: settings.formState,
|
|
140
140
|
});
|
|
@@ -145,8 +145,8 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
async function render(
|
|
148
|
-
url: string,
|
|
149
|
-
assets: RenderAssets,
|
|
148
|
+
url : string,
|
|
149
|
+
assets : RenderAssets,
|
|
150
150
|
settings?: RenderOptions,
|
|
151
151
|
): Promise<RenderResult> {
|
|
152
152
|
const report = settings?.onError ?? ((_error: mixed) => {});
|
|
@@ -249,8 +249,8 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
async function prerender(
|
|
252
|
-
url: string,
|
|
253
|
-
assets: RenderAssets,
|
|
252
|
+
url : string,
|
|
253
|
+
assets : RenderAssets,
|
|
254
254
|
settings?: RenderOptions,
|
|
255
255
|
): Promise<PrerenderResult> {
|
|
256
256
|
const report = settings?.onError ?? ((_error: mixed) => {});
|
|
@@ -319,7 +319,7 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
319
319
|
return redirectResult(redirectDocument(cause));
|
|
320
320
|
}
|
|
321
321
|
const recovered = await renderFlight(url, {
|
|
322
|
-
defer: false,
|
|
322
|
+
defer : false,
|
|
323
323
|
failure: { error: cause },
|
|
324
324
|
onError: onServerError,
|
|
325
325
|
});
|
|
@@ -363,10 +363,10 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
363
363
|
*/
|
|
364
364
|
async function partialDocumentOf(
|
|
365
365
|
payload: Uint8Array,
|
|
366
|
-
url: string,
|
|
367
|
-
assets: RenderAssets,
|
|
366
|
+
url : string,
|
|
367
|
+
assets : RenderAssets,
|
|
368
368
|
onError: (error: mixed) => void,
|
|
369
|
-
reads: $ReadOnlyArray<string>,
|
|
369
|
+
reads : $ReadOnlyArray<string>,
|
|
370
370
|
): Promise<PrerenderedShell | null> {
|
|
371
371
|
try {
|
|
372
372
|
await staticDocumentOf(payload, url, assets, onError);
|
|
@@ -405,9 +405,9 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
405
405
|
* with the shell is the same markup.
|
|
406
406
|
*/
|
|
407
407
|
async function resume(
|
|
408
|
-
url: string,
|
|
409
|
-
assets: RenderAssets,
|
|
410
|
-
shell: PrerenderedShell,
|
|
408
|
+
url : string,
|
|
409
|
+
assets : RenderAssets,
|
|
410
|
+
shell : PrerenderedShell,
|
|
411
411
|
settings?: RenderOptions,
|
|
412
412
|
): Promise<RenderResult> {
|
|
413
413
|
const report = settings?.onError ?? ((_error: mixed) => {});
|
|
@@ -435,8 +435,8 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
435
435
|
report(error);
|
|
436
436
|
}
|
|
437
437
|
},
|
|
438
|
-
payload: forBrowser,
|
|
439
|
-
nonce: currentNonce(),
|
|
438
|
+
payload : forBrowser,
|
|
439
|
+
nonce : currentNonce(),
|
|
440
440
|
onStream: send == null ? undefined : streamReporter(url, send),
|
|
441
441
|
});
|
|
442
442
|
return { status: 200, pipe: body.pipe, stream: body.stream, text: body.text };
|
|
@@ -445,8 +445,8 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
445
445
|
/** A finished document for a finished payload, with the payload written into it. */
|
|
446
446
|
function staticDocumentOf(
|
|
447
447
|
payload: Uint8Array,
|
|
448
|
-
url: string,
|
|
449
|
-
assets: RenderAssets,
|
|
448
|
+
url : string,
|
|
449
|
+
assets : RenderAssets,
|
|
450
450
|
onError: (error: mixed) => void,
|
|
451
451
|
): Promise<string> {
|
|
452
452
|
return prerenderDocument(<App url={url} flight={readPayload(streamOf(payload))} />, {
|
|
@@ -459,15 +459,15 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
459
459
|
async function flight(
|
|
460
460
|
url: string,
|
|
461
461
|
settings?: {|
|
|
462
|
-
readonly onError
|
|
462
|
+
readonly onError? : (error: mixed) => void,
|
|
463
463
|
readonly interceptedFrom?: string,
|
|
464
|
-
readonly notFound
|
|
464
|
+
readonly notFound? : boolean,
|
|
465
465
|
|},
|
|
466
466
|
): Promise<FlightResponse> {
|
|
467
467
|
const rendered = await renderFlight(url, {
|
|
468
|
-
onError: settings?.onError,
|
|
468
|
+
onError : settings?.onError,
|
|
469
469
|
interceptedFrom: settings?.interceptedFrom,
|
|
470
|
-
notFound: settings?.notFound,
|
|
470
|
+
notFound : settings?.notFound,
|
|
471
471
|
});
|
|
472
472
|
if (rendered.kind === "redirect") {
|
|
473
473
|
const { location } = rendered;
|
|
@@ -477,16 +477,16 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
477
477
|
// loads the URL as a document instead.
|
|
478
478
|
const onThisOrigin = location.startsWith("/") && !location.startsWith("//");
|
|
479
479
|
return {
|
|
480
|
-
status: rendered.status,
|
|
480
|
+
status : rendered.status,
|
|
481
481
|
headers: { location: onThisOrigin ? flightUrl(addressOf(location)) : location },
|
|
482
|
-
stream: null,
|
|
482
|
+
stream : null,
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
485
|
return {
|
|
486
486
|
status: rendered.status,
|
|
487
487
|
headers: {
|
|
488
488
|
"content-type": FLIGHT_CONTENT_TYPE,
|
|
489
|
-
vary: `${INTERCEPTED_FROM_HEADER}, ${NOT_FOUND_HEADER}`,
|
|
489
|
+
vary : `${INTERCEPTED_FROM_HEADER}, ${NOT_FOUND_HEADER}`,
|
|
490
490
|
// The payload carries the page's strings as they were rendered — a
|
|
491
491
|
// comment body with `<img onerror>` in it included — and its URL is one
|
|
492
492
|
// anybody can open as a document. `text/x-component` is not a type a
|
|
@@ -495,7 +495,7 @@ export function createDocumentRenderer(options: DocumentRendererOptions): Render
|
|
|
495
495
|
"x-content-type-options": "nosniff",
|
|
496
496
|
},
|
|
497
497
|
stream: rendered.stream,
|
|
498
|
-
error: rendered.failure,
|
|
498
|
+
error : rendered.failure,
|
|
499
499
|
};
|
|
500
500
|
}
|
|
501
501
|
|
package/rsc.js
CHANGED
|
@@ -172,7 +172,7 @@ export type FlightOptions = {|
|
|
|
172
172
|
export type FlightRender =
|
|
173
173
|
| {| readonly kind: "redirect", readonly status: 307 | 308, readonly location: string |}
|
|
174
174
|
| {|
|
|
175
|
-
readonly kind: "route",
|
|
175
|
+
readonly kind : "route",
|
|
176
176
|
readonly status: 200 | 400 | 401 | 403 | 404 | 500,
|
|
177
177
|
/** The payload, as React writes it. Read exactly once. */
|
|
178
178
|
readonly stream: ReadableStream<Uint8Array>,
|
|
@@ -207,9 +207,9 @@ const CLIENT_REFERENCE: symbol = Symbol.for("react.client.reference");
|
|
|
207
207
|
* — and it is `virtual:uf/routes` as this graph generates it.
|
|
208
208
|
*/
|
|
209
209
|
export function createFlightRenderer(options: {|
|
|
210
|
-
readonly routes: RouteTable["routes"],
|
|
210
|
+
readonly routes : RouteTable["routes"],
|
|
211
211
|
readonly notFound: RouteTable["notFound"],
|
|
212
|
-
readonly errors: RouteTable["errors"],
|
|
212
|
+
readonly errors : RouteTable["errors"],
|
|
213
213
|
/**
|
|
214
214
|
* The build's deployment id, written into every payload's root so that a
|
|
215
215
|
* page on another build can tell — including from a payload that was
|
|
@@ -222,9 +222,9 @@ export function createFlightRenderer(options: {|
|
|
|
222
222
|
// and React's Flight renderer would only say so from inside a render.
|
|
223
223
|
requireServerComponentsReact("@uniflowed/router/rsc");
|
|
224
224
|
const table: RouteTable = {
|
|
225
|
-
routes: options.routes,
|
|
225
|
+
routes : options.routes,
|
|
226
226
|
notFound: options.notFound,
|
|
227
|
-
errors: options.errors,
|
|
227
|
+
errors : options.errors,
|
|
228
228
|
};
|
|
229
229
|
|
|
230
230
|
return async function renderFlight(url: string, settings?: FlightOptions): Promise<FlightRender> {
|
|
@@ -285,7 +285,7 @@ export function createFlightRenderer(options: {|
|
|
|
285
285
|
// Handed over as it is, so that the digest it returns reaches the row.
|
|
286
286
|
// Our callback preserves React's console fallback when none was given.
|
|
287
287
|
onError: report,
|
|
288
|
-
signal: settings?.signal,
|
|
288
|
+
signal : settings?.signal,
|
|
289
289
|
}),
|
|
290
290
|
);
|
|
291
291
|
return { kind: "route", status: route.status, stream, failure };
|
|
@@ -294,8 +294,8 @@ export function createFlightRenderer(options: {|
|
|
|
294
294
|
|
|
295
295
|
async function resolveFlightInterception(
|
|
296
296
|
table: RouteTable,
|
|
297
|
-
url: string,
|
|
298
|
-
from: ?string,
|
|
297
|
+
url : string,
|
|
298
|
+
from : ?string,
|
|
299
299
|
defer: boolean,
|
|
300
300
|
): Promise<?ResolvedRoute> {
|
|
301
301
|
const baseUrl = usableInterceptionBase(from);
|
|
@@ -305,7 +305,7 @@ async function resolveFlightInterception(
|
|
|
305
305
|
try {
|
|
306
306
|
const base = await resolveMatch(table, baseUrl, {
|
|
307
307
|
defer,
|
|
308
|
-
onMatch: noteRoute,
|
|
308
|
+
onMatch : noteRoute,
|
|
309
309
|
runLoader: traceLoader,
|
|
310
310
|
});
|
|
311
311
|
return await resolveInterception(table, base, url);
|
|
@@ -378,10 +378,10 @@ component RoutePage(page: PageModule, params: RouteParams, searchParams: mixed,
|
|
|
378
378
|
* browser's `AwaitedPage` already uses for the same wait.
|
|
379
379
|
*/
|
|
380
380
|
component DeferredPage(
|
|
381
|
-
page: PageModule,
|
|
382
|
-
params: RouteParams,
|
|
381
|
+
page : PageModule,
|
|
382
|
+
params : RouteParams,
|
|
383
383
|
searchParams: mixed,
|
|
384
|
-
loader: Promise<mixed>,
|
|
384
|
+
loader : Promise<mixed>,
|
|
385
385
|
) {
|
|
386
386
|
return <RoutePage page={page} params={params} searchParams={searchParams} data={use(loader)} />;
|
|
387
387
|
}
|
|
@@ -401,9 +401,9 @@ function forTheBrowser(resolved: ResolvedRoute, file: string | null): ResolvedRo
|
|
|
401
401
|
...resolved,
|
|
402
402
|
// Only an `Error` has React's production rule of carrying no message; see
|
|
403
403
|
// `crossableRouteError`.
|
|
404
|
-
error: crossableRouteError(resolved.error),
|
|
404
|
+
error : crossableRouteError(resolved.error),
|
|
405
405
|
errorBoundary: { above: boundary.above, module: clientErrorModule(boundary.module, file) },
|
|
406
|
-
slots: resolved.slots.map(slotForTheBrowser),
|
|
406
|
+
slots : resolved.slots.map(slotForTheBrowser),
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
409
|
|
|
@@ -455,8 +455,8 @@ function renderFailure(resolved: ResolvedRoute): mixed {
|
|
|
455
455
|
}
|
|
456
456
|
return match (resolved.error) {
|
|
457
457
|
{kind: "thrown", error: const error} => error,
|
|
458
|
-
{kind: "badRequest", ...}
|
|
459
|
-
{kind: "unauthorized"}
|
|
460
|
-
{kind: "forbidden"}
|
|
458
|
+
{kind: "badRequest", ...} => undefined,
|
|
459
|
+
{kind: "unauthorized"} => undefined,
|
|
460
|
+
{kind: "forbidden"} => undefined,
|
|
461
461
|
};
|
|
462
462
|
}
|
package/server-components.js
CHANGED
|
@@ -111,12 +111,12 @@ export { resolveFailure, resolveMatch } from "./internal/resolve.js";
|
|
|
111
111
|
export hook useRoute(): RouteInfo {
|
|
112
112
|
const route = serverRoute("useRoute");
|
|
113
113
|
return {
|
|
114
|
-
path: route.path,
|
|
115
|
-
pathname: route.pathname,
|
|
116
|
-
params: route.params,
|
|
114
|
+
path : route.path,
|
|
115
|
+
pathname : route.pathname,
|
|
116
|
+
params : route.params,
|
|
117
117
|
searchParams: route.searchParams,
|
|
118
|
-
data: route.deferred == null ? route.data : use(route.deferred),
|
|
119
|
-
pending: false,
|
|
118
|
+
data : route.deferred == null ? route.data : use(route.deferred),
|
|
119
|
+
pending : false,
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
|