@uniflowed/router 0.34.0 → 0.35.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/action.js
CHANGED
|
@@ -294,7 +294,7 @@ export function registerServerAction<T>(fn: T, id: string): T {
|
|
|
294
294
|
*/
|
|
295
295
|
export function callServerReference(
|
|
296
296
|
reference: string,
|
|
297
|
-
args: $ReadOnlyArray<mixed>,
|
|
297
|
+
args : $ReadOnlyArray<mixed>,
|
|
298
298
|
): Promise<ActionValue | void> {
|
|
299
299
|
const hash = reference.indexOf("#");
|
|
300
300
|
const id = hash === -1 ? reference : reference.slice(0, hash);
|
|
@@ -311,7 +311,7 @@ function callServerActionFor(id: string, name: string): ServerActionFunction {
|
|
|
311
311
|
|
|
312
312
|
/** Call action `id`, named `name` in an error, with `args`. */
|
|
313
313
|
async function sendServerAction(
|
|
314
|
-
id: string,
|
|
314
|
+
id : string,
|
|
315
315
|
name: string,
|
|
316
316
|
args: $ReadOnlyArray<mixed>,
|
|
317
317
|
): Promise<ActionValue | void> {
|
|
@@ -392,10 +392,10 @@ async function sendServerAction(
|
|
|
392
392
|
* the router's runtime is client-rendering code that has no place there.
|
|
393
393
|
*/
|
|
394
394
|
async function followOutcome(
|
|
395
|
-
name: string,
|
|
396
|
-
outcome: string,
|
|
395
|
+
name : string,
|
|
396
|
+
outcome : string,
|
|
397
397
|
response: Response,
|
|
398
|
-
from: string,
|
|
398
|
+
from : string,
|
|
399
399
|
): Promise<ActionValue | void> {
|
|
400
400
|
switch (outcome) {
|
|
401
401
|
case "redirect": {
|
package/client.js
CHANGED
|
@@ -152,20 +152,20 @@ export type ApplicationRoot = { readonly unmount: () => void, ... };
|
|
|
152
152
|
* that stops a server action from navigating a router that is gone.
|
|
153
153
|
*/
|
|
154
154
|
export async function hydrate(options: {|
|
|
155
|
-
readonly App: React.ComponentType<AppProps>,
|
|
156
|
-
readonly routes: RouteTable["routes"],
|
|
157
|
-
readonly notFound: RouteTable["notFound"],
|
|
158
|
-
readonly errors: RouteTable["errors"],
|
|
159
|
-
readonly strictMode
|
|
160
|
-
readonly navigation
|
|
161
|
-
readonly basePath
|
|
155
|
+
readonly App : React.ComponentType<AppProps>,
|
|
156
|
+
readonly routes : RouteTable["routes"],
|
|
157
|
+
readonly notFound : RouteTable["notFound"],
|
|
158
|
+
readonly errors : RouteTable["errors"],
|
|
159
|
+
readonly strictMode? : boolean,
|
|
160
|
+
readonly navigation? : Navigation,
|
|
161
|
+
readonly basePath? : string,
|
|
162
162
|
readonly trailingSlash?: TrailingSlash,
|
|
163
|
-
readonly staleTime
|
|
163
|
+
readonly staleTime? : number,
|
|
164
164
|
|}): Promise<ApplicationRoot | null> {
|
|
165
165
|
const table: RouteTable = {
|
|
166
|
-
routes: options.routes,
|
|
166
|
+
routes : options.routes,
|
|
167
167
|
notFound: options.notFound,
|
|
168
|
-
errors: options.errors,
|
|
168
|
+
errors : options.errors,
|
|
169
169
|
};
|
|
170
170
|
installRoutes(table);
|
|
171
171
|
// Beside the table, and before anything renders. `"client"` when the entry
|
|
@@ -294,20 +294,20 @@ export async function hydrate(options: {|
|
|
|
294
294
|
* was mounted — for the reason `hydrate` gives.
|
|
295
295
|
*/
|
|
296
296
|
export async function render(options: {|
|
|
297
|
-
readonly App: React.ComponentType<AppProps>,
|
|
298
|
-
readonly routes: RouteTable["routes"],
|
|
299
|
-
readonly notFound: RouteTable["notFound"],
|
|
300
|
-
readonly errors: RouteTable["errors"],
|
|
301
|
-
readonly strictMode
|
|
302
|
-
readonly navigation
|
|
303
|
-
readonly basePath
|
|
297
|
+
readonly App : React.ComponentType<AppProps>,
|
|
298
|
+
readonly routes : RouteTable["routes"],
|
|
299
|
+
readonly notFound : RouteTable["notFound"],
|
|
300
|
+
readonly errors : RouteTable["errors"],
|
|
301
|
+
readonly strictMode? : boolean,
|
|
302
|
+
readonly navigation? : Navigation,
|
|
303
|
+
readonly basePath? : string,
|
|
304
304
|
readonly trailingSlash?: TrailingSlash,
|
|
305
|
-
readonly staleTime
|
|
305
|
+
readonly staleTime? : number,
|
|
306
306
|
|}): Promise<ApplicationRoot | null> {
|
|
307
307
|
const table: RouteTable = {
|
|
308
|
-
routes: options.routes,
|
|
308
|
+
routes : options.routes,
|
|
309
309
|
notFound: options.notFound,
|
|
310
|
-
errors: options.errors,
|
|
310
|
+
errors : options.errors,
|
|
311
311
|
};
|
|
312
312
|
installRoutes(table);
|
|
313
313
|
installNavigation(options.navigation ?? "client");
|
package/handler.js
CHANGED
|
@@ -91,10 +91,10 @@ export type HandlerModule = { readonly [method: string]: mixed };
|
|
|
91
91
|
|
|
92
92
|
/** One entry of the generated handler table. */
|
|
93
93
|
export type HandlerRecord = {|
|
|
94
|
-
readonly path: string,
|
|
94
|
+
readonly path : string,
|
|
95
95
|
readonly params: $ReadOnlyArray<{| readonly name: string, readonly catchAll: boolean |}>,
|
|
96
|
-
readonly file: string,
|
|
97
|
-
readonly load: () => Promise<HandlerModule>,
|
|
96
|
+
readonly file : string,
|
|
97
|
+
readonly load : () => Promise<HandlerModule>,
|
|
98
98
|
|};
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -179,9 +179,9 @@ export function createDispatcher(options: {| readonly handlers: $ReadOnlyArray<H
|
|
|
179
179
|
// body went out anyway.
|
|
180
180
|
if (method === "HEAD" && typeof module.HEAD !== "function") {
|
|
181
181
|
return new Response(null, {
|
|
182
|
-
status: response.status,
|
|
182
|
+
status : response.status,
|
|
183
183
|
statusText: response.statusText,
|
|
184
|
-
headers: response.headers,
|
|
184
|
+
headers : response.headers,
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
return response;
|
|
@@ -225,7 +225,7 @@ function methodNotAllowed(module: HandlerModule): Response {
|
|
|
225
225
|
// Filtered through `METHODS` rather than listed in insertion order, so the
|
|
226
226
|
// header reads in the conventional order however the module was written.
|
|
227
227
|
return new Response(null, {
|
|
228
|
-
status: 405,
|
|
228
|
+
status : 405,
|
|
229
229
|
headers: { allow: HANDLER_METHODS.filter((method) => own.has(method)).join(", ") },
|
|
230
230
|
});
|
|
231
231
|
}
|
package/http-client.js
CHANGED
|
@@ -9,28 +9,28 @@ import {
|
|
|
9
9
|
} from "./internal/action-wire.js";
|
|
10
10
|
|
|
11
11
|
export type RouteClientOptions = {|
|
|
12
|
-
readonly origin: string,
|
|
13
|
-
readonly getToken
|
|
14
|
-
readonly fetch
|
|
12
|
+
readonly origin : string,
|
|
13
|
+
readonly getToken? : () => Promise<string>,
|
|
14
|
+
readonly fetch? : (url: string, options: RequestOptions) => Promise<Response>,
|
|
15
15
|
readonly allowInsecureDevelopment?: boolean,
|
|
16
16
|
|};
|
|
17
17
|
|
|
18
18
|
export type RouteRequest = {|
|
|
19
|
-
readonly method
|
|
19
|
+
readonly method? : string,
|
|
20
20
|
readonly headers?: { readonly [string]: string },
|
|
21
|
-
readonly body
|
|
22
|
-
readonly signal
|
|
21
|
+
readonly body? : string,
|
|
22
|
+
readonly signal? : AbortSignal,
|
|
23
23
|
|};
|
|
24
24
|
|
|
25
25
|
type RequestOptions = {|
|
|
26
26
|
...RouteRequest,
|
|
27
27
|
readonly credentials: "omit",
|
|
28
|
-
readonly redirect: "error",
|
|
28
|
+
readonly redirect : "error",
|
|
29
29
|
|};
|
|
30
30
|
|
|
31
31
|
/** Fetch transport shared by generated typed route clients and native actions. */
|
|
32
32
|
export function createRouteClient(options: RouteClientOptions): (
|
|
33
|
-
path: string,
|
|
33
|
+
path : string,
|
|
34
34
|
request?: RouteRequest,
|
|
35
35
|
) => Promise<Response> {
|
|
36
36
|
const origin = new URL(options.origin);
|
|
@@ -93,9 +93,9 @@ export function createNativeActionClient(options: {|
|
|
|
93
93
|
const response = await send(path, {
|
|
94
94
|
method: "POST",
|
|
95
95
|
headers: {
|
|
96
|
-
[ACTION_HEADER]: id,
|
|
96
|
+
[ACTION_HEADER] : id,
|
|
97
97
|
"uf-native-action": "bearer-v1",
|
|
98
|
-
"content-type": ACTION_CONTENT_TYPE,
|
|
98
|
+
"content-type" : ACTION_CONTENT_TYPE,
|
|
99
99
|
},
|
|
100
100
|
body: encodeActionArguments(args),
|
|
101
101
|
});
|
package/index.js
CHANGED
|
@@ -118,9 +118,9 @@ export type PageProps<
|
|
|
118
118
|
TData = void,
|
|
119
119
|
TSearchParams = { readonly [string]: string },
|
|
120
120
|
> = {|
|
|
121
|
-
readonly params: TParams,
|
|
121
|
+
readonly params : TParams,
|
|
122
122
|
readonly searchParams: TSearchParams,
|
|
123
|
-
readonly data: TData,
|
|
123
|
+
readonly data : TData,
|
|
124
124
|
|};
|
|
125
125
|
|
|
126
126
|
/**
|
|
@@ -153,6 +153,6 @@ export type ErrorProps = {|
|
|
|
153
153
|
export type LayoutProps<
|
|
154
154
|
TParams extends { readonly [string]: string | $ReadOnlyArray<string> } = {},
|
|
155
155
|
> = {|
|
|
156
|
-
readonly params: TParams,
|
|
156
|
+
readonly params : TParams,
|
|
157
157
|
readonly children: React.Node,
|
|
158
158
|
|};
|
package/instrumentation.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
export type NavigationTiming = {|
|
|
4
|
-
readonly kind: "document" | "router",
|
|
4
|
+
readonly kind : "document" | "router",
|
|
5
5
|
readonly pathname: string,
|
|
6
6
|
readonly duration: number,
|
|
7
|
-
readonly status: "complete" | "error",
|
|
7
|
+
readonly status : "complete" | "error",
|
|
8
8
|
|};
|
|
9
9
|
|
|
10
10
|
export type ClientInstrumentation = {|
|
|
11
11
|
readonly register?: () => void | Promise<void>,
|
|
12
12
|
readonly onError?: (
|
|
13
|
-
error: mixed,
|
|
13
|
+
error : mixed,
|
|
14
14
|
context: {| readonly source: "error" | "unhandledrejection" | "navigation" | "startup" |},
|
|
15
15
|
) => void | Promise<void>,
|
|
16
16
|
readonly onNavigation?: (timing: NavigationTiming) => void | Promise<void>,
|
|
@@ -43,10 +43,10 @@ export async function installClientInstrumentation(hooks: ClientInstrumentation)
|
|
|
43
43
|
performanceObserver = new PerformanceObserver((list) => {
|
|
44
44
|
for (const entry of list.getEntries()) {
|
|
45
45
|
const timing: NavigationTiming = {
|
|
46
|
-
kind: "document",
|
|
46
|
+
kind : "document",
|
|
47
47
|
pathname: new URL(entry.name).pathname,
|
|
48
48
|
duration: entry.duration,
|
|
49
|
-
status: "complete",
|
|
49
|
+
status : "complete",
|
|
50
50
|
};
|
|
51
51
|
notify(() => hooks.onNavigation?.(timing));
|
|
52
52
|
}
|
|
@@ -204,7 +204,7 @@ export function createActionDispatcher(options: {|
|
|
|
204
204
|
const table = options.actions;
|
|
205
205
|
|
|
206
206
|
return async function callAction(
|
|
207
|
-
request: Request,
|
|
207
|
+
request : Request,
|
|
208
208
|
settings?: ActionDispatchOptions,
|
|
209
209
|
): Promise<Response | null> {
|
|
210
210
|
// The host's half of the contract, checked rather than assumed, exactly as
|
|
@@ -331,8 +331,8 @@ export function createActionDispatcher(options: {|
|
|
|
331
331
|
* reason.
|
|
332
332
|
*/
|
|
333
333
|
async function nativeFormPost(
|
|
334
|
-
table: $ReadOnlyArray<ActionRecord>,
|
|
335
|
-
request: Request,
|
|
334
|
+
table : $ReadOnlyArray<ActionRecord>,
|
|
335
|
+
request : Request,
|
|
336
336
|
postback: ?(formState: FormState) => Promise<Response>,
|
|
337
337
|
): Promise<Response | null> {
|
|
338
338
|
if (request.method.toUpperCase() !== "POST") {
|
|
@@ -404,7 +404,7 @@ async function nativeFormPost(
|
|
|
404
404
|
const status = routingStatus(error);
|
|
405
405
|
if (status != null) {
|
|
406
406
|
return new Response(`${status.text}\n`, {
|
|
407
|
-
status: status.code,
|
|
407
|
+
status : status.code,
|
|
408
408
|
headers: { "content-type": "text/plain; charset=utf-8", "cache-control": "no-store" },
|
|
409
409
|
});
|
|
410
410
|
}
|
|
@@ -439,7 +439,7 @@ async function nativeFormPost(
|
|
|
439
439
|
* forms that could drift from the first.
|
|
440
440
|
*/
|
|
441
441
|
function formArguments(post: FormPost): {|
|
|
442
|
-
readonly args: Array<ActionArgument>,
|
|
442
|
+
readonly args : Array<ActionArgument>,
|
|
443
443
|
readonly bound: number,
|
|
444
444
|
|} {
|
|
445
445
|
let bound: Array<ActionArgument> = [];
|
|
@@ -512,7 +512,7 @@ function routingOutcome(error: mixed): Response | null {
|
|
|
512
512
|
if (error instanceof RedirectError) {
|
|
513
513
|
const headers: { [string]: string } = {
|
|
514
514
|
"cache-control": "no-store",
|
|
515
|
-
location: addressOf(error.to),
|
|
515
|
+
location : addressOf(error.to),
|
|
516
516
|
};
|
|
517
517
|
headers[ACTION_OUTCOME_HEADER] = "redirect";
|
|
518
518
|
return new Response(null, { status: 204, headers });
|
|
@@ -554,7 +554,7 @@ function withOneLeadingSlash(path: string): string {
|
|
|
554
554
|
/** A `303 See Other`, which a browser follows with a `GET`. */
|
|
555
555
|
function seeOther(location: string): Response {
|
|
556
556
|
return new Response(null, {
|
|
557
|
-
status: 303,
|
|
557
|
+
status : 303,
|
|
558
558
|
headers: { location, "cache-control": "no-store" },
|
|
559
559
|
});
|
|
560
560
|
}
|
package/internal/action-wire.js
CHANGED
|
@@ -303,8 +303,8 @@ export function valueBudget(): ValueBudget {
|
|
|
303
303
|
* is on the call. Without one, the value has a budget of its own.
|
|
304
304
|
*/
|
|
305
305
|
export function checkActionValue(
|
|
306
|
-
root: mixed,
|
|
307
|
-
label: string,
|
|
306
|
+
root : mixed,
|
|
307
|
+
label : string,
|
|
308
308
|
budget?: ValueBudget = valueBudget(),
|
|
309
309
|
): void {
|
|
310
310
|
const stack: Array<Pending> = [{ value: root, path: label, depth: 0 }];
|
|
@@ -545,7 +545,7 @@ export function decodeActionArguments(text: string): Array<ActionArgument> {
|
|
|
545
545
|
*/
|
|
546
546
|
function decodeForm(
|
|
547
547
|
candidate: mixed,
|
|
548
|
-
args: $ReadOnlyArray<ActionArgument>,
|
|
548
|
+
args : $ReadOnlyArray<ActionArgument>,
|
|
549
549
|
): {| readonly index: number, readonly form: FormData |} {
|
|
550
550
|
if (typeof FormData === "undefined") {
|
|
551
551
|
throw new ActionValueError("the body", "carries a form, and this runtime has no FormData");
|
package/internal/base-path.js
CHANGED
|
@@ -29,7 +29,7 @@ export type TrailingSlash = "never" | "always" | "ignore";
|
|
|
29
29
|
|
|
30
30
|
/** What an entry installs. */
|
|
31
31
|
export type RoutingSettings = {|
|
|
32
|
-
readonly basePath
|
|
32
|
+
readonly basePath? : string,
|
|
33
33
|
readonly trailingSlash?: TrailingSlash,
|
|
34
34
|
|};
|
|
35
35
|
|
|
@@ -47,8 +47,8 @@ function publishBase(base: string): void {
|
|
|
47
47
|
// `globalThis[symbol]` is a computed property on a namespace, which Flow
|
|
48
48
|
// rejects. `Object.defineProperty` is the write the rest of the repo uses.
|
|
49
49
|
Object.defineProperty(globalThis, ROUTING_BASE, {
|
|
50
|
-
value: base,
|
|
51
|
-
writable: true,
|
|
50
|
+
value : base,
|
|
51
|
+
writable : true,
|
|
52
52
|
configurable: true,
|
|
53
53
|
});
|
|
54
54
|
}
|
package/internal/boundaries.js
CHANGED
|
@@ -236,7 +236,7 @@ export type BoundaryFinding = {|
|
|
|
236
236
|
*/
|
|
237
237
|
export function boundaryFindings(
|
|
238
238
|
boundaries: Map<string, RouteBoundary>,
|
|
239
|
-
document: Document,
|
|
239
|
+
document : Document,
|
|
240
240
|
): $ReadOnlyArray<BoundaryFinding> {
|
|
241
241
|
const findings: Array<BoundaryFinding> = [];
|
|
242
242
|
for (const boundary of boundaries.values()) {
|
|
@@ -259,8 +259,8 @@ export function boundaryFindings(
|
|
|
259
259
|
}
|
|
260
260
|
findings.push({
|
|
261
261
|
boundary,
|
|
262
|
-
owns: owned.slice(0, NAMED_LIMIT),
|
|
263
|
-
more: Math.max(0, owned.length - NAMED_LIMIT),
|
|
262
|
+
owns : owned.slice(0, NAMED_LIMIT),
|
|
263
|
+
more : Math.max(0, owned.length - NAMED_LIMIT),
|
|
264
264
|
rendered: true,
|
|
265
265
|
});
|
|
266
266
|
}
|
|
@@ -303,13 +303,13 @@ export function describeElement(element: Element): string {
|
|
|
303
303
|
* on it without opening this file.
|
|
304
304
|
*/
|
|
305
305
|
export function formatBoundaries(
|
|
306
|
-
path: string,
|
|
306
|
+
path : string,
|
|
307
307
|
findings: $ReadOnlyArray<BoundaryFinding>,
|
|
308
308
|
): {| readonly message: string, readonly detail: $ReadOnlyArray<string> |} {
|
|
309
309
|
const count = findings.length;
|
|
310
310
|
return {
|
|
311
311
|
message: `${count} ${count === 1 ? "boundary renders" : "boundaries render"} ${path}`,
|
|
312
|
-
detail: findings.map(describeFinding),
|
|
312
|
+
detail : findings.map(describeFinding),
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
|
|
@@ -373,9 +373,9 @@ function signature(boundaries: Map<string, RouteBoundary>): string {
|
|
|
373
373
|
* answer and the automatic one are the same sentence about the same page.
|
|
374
374
|
*/
|
|
375
375
|
export function reportBoundaries(
|
|
376
|
-
path: string,
|
|
376
|
+
path : string,
|
|
377
377
|
boundaries: Map<string, RouteBoundary>,
|
|
378
|
-
document: Document,
|
|
378
|
+
document : Document,
|
|
379
379
|
): $ReadOnlyArray<BoundaryFinding> {
|
|
380
380
|
const findings = boundaryFindings(boundaries, document);
|
|
381
381
|
const { message, detail } = formatBoundaries(path, findings);
|
|
@@ -463,7 +463,7 @@ function installOnDemand(): void {
|
|
|
463
463
|
}
|
|
464
464
|
return reportBoundaries(live.path, live.boundaries, document);
|
|
465
465
|
},
|
|
466
|
-
writable: true,
|
|
466
|
+
writable : true,
|
|
467
467
|
configurable: true,
|
|
468
468
|
});
|
|
469
469
|
}
|
|
@@ -40,17 +40,17 @@ export const ROOT_ERROR_ID: string = "error:root";
|
|
|
40
40
|
* is how many layouts are outside the boundary.
|
|
41
41
|
*/
|
|
42
42
|
export type RouteBoundary = {|
|
|
43
|
-
readonly id: string,
|
|
44
|
-
readonly kind: BoundaryKind,
|
|
45
|
-
readonly above: number,
|
|
43
|
+
readonly id : string,
|
|
44
|
+
readonly kind : BoundaryKind,
|
|
45
|
+
readonly above : number,
|
|
46
46
|
readonly source: ?string,
|
|
47
47
|
|};
|
|
48
48
|
|
|
49
49
|
/** The part of a resolved route the boundary map reads. */
|
|
50
50
|
type BoundedRoute = {
|
|
51
51
|
readonly errorBoundary: { readonly above: number, ... },
|
|
52
|
-
readonly loading: $ReadOnlyArray<{ readonly above: number, ... }>,
|
|
53
|
-
readonly error: mixed,
|
|
52
|
+
readonly loading : $ReadOnlyArray<{ readonly above: number, ... }>,
|
|
53
|
+
readonly error : mixed,
|
|
54
54
|
...
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -62,21 +62,21 @@ type BoundedRoute = {
|
|
|
62
62
|
* summaries walk the values.
|
|
63
63
|
*/
|
|
64
64
|
export function routeBoundaries(
|
|
65
|
-
resolved: BoundedRoute,
|
|
65
|
+
resolved : BoundedRoute,
|
|
66
66
|
errorSource: ?string,
|
|
67
67
|
): Map<string, RouteBoundary> {
|
|
68
68
|
const found: Map<string, RouteBoundary> = new Map();
|
|
69
69
|
found.set(ROOT_ERROR_ID, {
|
|
70
|
-
id: ROOT_ERROR_ID,
|
|
71
|
-
kind: "error",
|
|
72
|
-
above: 0,
|
|
70
|
+
id : ROOT_ERROR_ID,
|
|
71
|
+
kind : "error",
|
|
72
|
+
above : 0,
|
|
73
73
|
source: SYNTHESISED_SOURCE,
|
|
74
74
|
});
|
|
75
75
|
if (resolved.error == null) {
|
|
76
76
|
found.set(ROUTE_ERROR_ID, {
|
|
77
|
-
id: ROUTE_ERROR_ID,
|
|
78
|
-
kind: "error",
|
|
79
|
-
above: resolved.errorBoundary.above,
|
|
77
|
+
id : ROUTE_ERROR_ID,
|
|
78
|
+
kind : "error",
|
|
79
|
+
above : resolved.errorBoundary.above,
|
|
80
80
|
source: errorSource,
|
|
81
81
|
});
|
|
82
82
|
}
|
package/internal/compose.js
CHANGED
|
@@ -315,8 +315,8 @@ export function loadingComponent(module: LoadingModule): React.ComponentType<{||
|
|
|
315
315
|
export function insideTemplates(
|
|
316
316
|
element: React.Node,
|
|
317
317
|
resolved: {
|
|
318
|
-
readonly pathname: string,
|
|
319
|
-
readonly params: RouteParams,
|
|
318
|
+
readonly pathname : string,
|
|
319
|
+
readonly params : RouteParams,
|
|
320
320
|
readonly templates: $ReadOnlyArray<ResolvedTemplate>,
|
|
321
321
|
...
|
|
322
322
|
},
|
|
@@ -429,8 +429,8 @@ component SlotView(slot: ResolvedSlot, pathname: string, searchParams: SearchPar
|
|
|
429
429
|
// uf-lint-disable-next-line react-compiler/static-components
|
|
430
430
|
let element: React.Node = <Page params={slot.params} searchParams={query} data={undefined} />;
|
|
431
431
|
const templateContext = {
|
|
432
|
-
pathname: at,
|
|
433
|
-
params: slot.params,
|
|
432
|
+
pathname : at,
|
|
433
|
+
params : slot.params,
|
|
434
434
|
templates: slot.templates,
|
|
435
435
|
};
|
|
436
436
|
for (let depth = slot.layouts.length; depth >= 0; depth -= 1) {
|
package/internal/devtools.js
CHANGED
|
@@ -74,7 +74,7 @@ type HookWindow = {
|
|
|
74
74
|
*/
|
|
75
75
|
export function devtoolsProblem(win: HookWindow): {|
|
|
76
76
|
readonly message: string,
|
|
77
|
-
readonly detail: $ReadOnlyArray<string>,
|
|
77
|
+
readonly detail : $ReadOnlyArray<string>,
|
|
78
78
|
|} | null {
|
|
79
79
|
const hook = win[DEVTOOLS_HOOK];
|
|
80
80
|
if (hook == null || typeof hook !== "object") {
|
package/internal/diagnostics.js
CHANGED
|
@@ -92,18 +92,18 @@ export type DiagnosticSeverity = "error" | "warn" | "info";
|
|
|
92
92
|
*/
|
|
93
93
|
export type BrowserDiagnostic = {
|
|
94
94
|
readonly severity: DiagnosticSeverity,
|
|
95
|
-
readonly message: string,
|
|
96
|
-
readonly detail
|
|
97
|
-
readonly url
|
|
98
|
-
readonly file
|
|
99
|
-
readonly line
|
|
100
|
-
readonly column
|
|
95
|
+
readonly message : string,
|
|
96
|
+
readonly detail? : $ReadOnlyArray<string>,
|
|
97
|
+
readonly url? : string,
|
|
98
|
+
readonly file? : string,
|
|
99
|
+
readonly line? : number,
|
|
100
|
+
readonly column? : number,
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
/** The part of the browser this module needs. */
|
|
104
104
|
type ReportingWindow = {
|
|
105
105
|
readonly location?: { readonly href?: string, ... },
|
|
106
|
-
readonly fetch
|
|
106
|
+
readonly fetch? : (input: string, init: { ... }) => Promise<mixed>,
|
|
107
107
|
...
|
|
108
108
|
};
|
|
109
109
|
|
|
@@ -151,7 +151,7 @@ export function reportDiagnostic(diagnostic: BrowserDiagnostic, endpoint?: strin
|
|
|
151
151
|
method: "POST",
|
|
152
152
|
body,
|
|
153
153
|
keepalive: true,
|
|
154
|
-
headers: { "content-type": "application/json" },
|
|
154
|
+
headers : { "content-type": "application/json" },
|
|
155
155
|
}).then(noop, noop);
|
|
156
156
|
}
|
|
157
157
|
|
package/internal/error-view.js
CHANGED
|
@@ -34,9 +34,9 @@ component DefaultRouteError(error: RouteError, reset: () => void) {
|
|
|
34
34
|
const title = errorTitle(error);
|
|
35
35
|
const detail = match (error) {
|
|
36
36
|
{kind: "badRequest", ...} => "This page cannot answer the query in its address.",
|
|
37
|
-
{kind: "unauthorized"}
|
|
38
|
-
{kind: "forbidden"}
|
|
39
|
-
{kind: "thrown", ...}
|
|
37
|
+
{kind: "unauthorized"} => "This page needs you to be signed in.",
|
|
38
|
+
{kind: "forbidden"} => "You do not have access to this page.",
|
|
39
|
+
{kind: "thrown", ...} => "This page could not be rendered.",
|
|
40
40
|
};
|
|
41
41
|
return (
|
|
42
42
|
<main>
|
|
@@ -140,7 +140,7 @@ export component ErrorRoutePage(module: ?ErrorModule, error: RouteError) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
type RouteErrorBoundaryProps = {|
|
|
143
|
-
readonly module: ?ErrorModule,
|
|
143
|
+
readonly module : ?ErrorModule,
|
|
144
144
|
readonly resetKey: string,
|
|
145
145
|
readonly children: React.Node,
|
|
146
146
|
|};
|
|
@@ -209,8 +209,8 @@ export class RouteErrorBoundary extends React.Component<
|
|
|
209
209
|
}
|
|
210
210
|
const recover = () => {
|
|
211
211
|
this.setState((state) => ({
|
|
212
|
-
error: null,
|
|
213
|
-
notFound: false,
|
|
212
|
+
error : null,
|
|
213
|
+
notFound : false,
|
|
214
214
|
generation: state.generation + 1,
|
|
215
215
|
}));
|
|
216
216
|
};
|
|
@@ -134,8 +134,8 @@ export function installBrowserModules(): void {
|
|
|
134
134
|
// `parcelRequire` is exactly the global nothing declares. `Object`'s throws
|
|
135
135
|
// where this answers `false`, so the throw is kept.
|
|
136
136
|
const defined = Reflect.defineProperty(globalThis, "parcelRequire", {
|
|
137
|
-
value: parcelRequire,
|
|
138
|
-
writable: true,
|
|
137
|
+
value : parcelRequire,
|
|
138
|
+
writable : true,
|
|
139
139
|
configurable: true,
|
|
140
140
|
});
|
|
141
141
|
if (!defined) {
|
|
@@ -170,7 +170,7 @@ type ElementLike = interface {
|
|
|
170
170
|
*/
|
|
171
171
|
export function documentPayload(
|
|
172
172
|
document: DocumentLike,
|
|
173
|
-
observe: ?(callback: () => void) => (() => void) | null,
|
|
173
|
+
observe : ?(callback: () => void) => (() => void) | null,
|
|
174
174
|
): ReadableStream<Uint8Array> {
|
|
175
175
|
const seen: WeakSet<ElementLike> = new WeakSet();
|
|
176
176
|
let stop: (() => void) | null = null;
|
|
@@ -219,7 +219,7 @@ export function documentPayload(
|
|
|
219
219
|
/** Read the payload a document carries into its root value. */
|
|
220
220
|
export function readDocumentPayload(
|
|
221
221
|
document: DocumentLike,
|
|
222
|
-
observe: ?(callback: () => void) => (() => void) | null,
|
|
222
|
+
observe : ?(callback: () => void) => (() => void) | null,
|
|
223
223
|
): Promise<FlightRoot> {
|
|
224
224
|
requireServerComponentsReact(ENTRY);
|
|
225
225
|
return createFromReadableStream(documentPayload(document, observe));
|
|
@@ -241,7 +241,7 @@ export function readDocumentPayload(
|
|
|
241
241
|
* refusal — is a document, whatever its status.
|
|
242
242
|
*/
|
|
243
243
|
export async function fetchFlight(
|
|
244
|
-
url: string,
|
|
244
|
+
url : string,
|
|
245
245
|
options?: FlightFetchOptions,
|
|
246
246
|
): Promise<FetchedFlight> {
|
|
247
247
|
// Outside the `try` below, which answers every failure to fetch with a
|
|
@@ -294,7 +294,7 @@ export async function fetchFlight(
|
|
|
294
294
|
}
|
|
295
295
|
return {
|
|
296
296
|
kind: "flight",
|
|
297
|
-
url: `${document}${landed.search}`,
|
|
297
|
+
url : `${document}${landed.search}`,
|
|
298
298
|
root: createFromFetch(Promise.resolve(payload)),
|
|
299
299
|
};
|
|
300
300
|
}
|
package/internal/flight-rows.js
CHANGED
|
@@ -41,9 +41,9 @@ const ERROR_TAG = "E".charCodeAt(0);
|
|
|
41
41
|
/** One row's place in the payload. */
|
|
42
42
|
type Row = {|
|
|
43
43
|
readonly start: number,
|
|
44
|
-
readonly end: number,
|
|
45
|
-
readonly tag: number,
|
|
46
|
-
readonly body: number,
|
|
44
|
+
readonly end : number,
|
|
45
|
+
readonly tag : number,
|
|
46
|
+
readonly body : number,
|
|
47
47
|
|};
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -96,7 +96,7 @@ function rowsOf(bytes: Uint8Array): Array<Row> {
|
|
|
96
96
|
*/
|
|
97
97
|
export function withoutErrorRows(
|
|
98
98
|
payload: Uint8Array,
|
|
99
|
-
left: (digest: string) => boolean,
|
|
99
|
+
left : (digest: string) => boolean,
|
|
100
100
|
): {| readonly payload: Uint8Array, readonly removed: number |} {
|
|
101
101
|
const decoder = new TextDecoder();
|
|
102
102
|
const kept: Array<Uint8Array> = [];
|
package/internal/flight-ssr.js
CHANGED
|
@@ -69,8 +69,8 @@ export function installServerModules(load: ClientModuleLoader): void {
|
|
|
69
69
|
// `parcelRequire` is exactly the global nothing declares. `Object`'s throws
|
|
70
70
|
// where this answers `false`, so the throw is kept.
|
|
71
71
|
const defined = Reflect.defineProperty(globalThis, "parcelRequire", {
|
|
72
|
-
value: parcelRequire,
|
|
73
|
-
writable: true,
|
|
72
|
+
value : parcelRequire,
|
|
73
|
+
writable : true,
|
|
74
74
|
configurable: true,
|
|
75
75
|
});
|
|
76
76
|
if (!defined) {
|
|
@@ -88,7 +88,7 @@ export function installServerModules(load: ClientModuleLoader): void {
|
|
|
88
88
|
* "Connection closed", so the HTML renderer leaves each as a hole.
|
|
89
89
|
*/
|
|
90
90
|
export function readPayload(
|
|
91
|
-
stream: ReadableStream<Uint8Array>,
|
|
91
|
+
stream : ReadableStream<Uint8Array>,
|
|
92
92
|
options?: {| readonly partial?: boolean |},
|
|
93
93
|
): Promise<FlightRoot> {
|
|
94
94
|
requireServerComponentsReact(ENTRY);
|