@uniflowed/router 0.33.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/internal/flight.js
CHANGED
|
@@ -39,26 +39,26 @@ import type { Metadata, ResolvedRoute } from "./resolve.js";
|
|
|
39
39
|
* message in development and replaced by React's own sentence in a build.
|
|
40
40
|
*/
|
|
41
41
|
export type RouteState = {|
|
|
42
|
-
readonly pathname: string,
|
|
43
|
-
readonly search: string,
|
|
44
|
-
readonly path: string,
|
|
45
|
-
readonly params: RouteParams,
|
|
42
|
+
readonly pathname : string,
|
|
43
|
+
readonly search : string,
|
|
44
|
+
readonly path : string,
|
|
45
|
+
readonly params : RouteParams,
|
|
46
46
|
readonly searchParams: SearchParams,
|
|
47
47
|
/** What the loader returned, once it has. `undefined` while `deferred` is set. */
|
|
48
48
|
readonly data: mixed,
|
|
49
49
|
/** The loader still running, as a promise the browser can `use`. */
|
|
50
|
-
readonly deferred: ?Promise<mixed>,
|
|
51
|
-
readonly metadata: Metadata,
|
|
50
|
+
readonly deferred : ?Promise<mixed>,
|
|
51
|
+
readonly metadata : Metadata,
|
|
52
52
|
readonly viewTransition: ?string,
|
|
53
|
-
readonly status: 200 | 400 | 401 | 403 | 404 | 500,
|
|
54
|
-
readonly error: ?RouteError,
|
|
55
|
-
readonly interception
|
|
53
|
+
readonly status : 200 | 400 | 401 | 403 | 404 | 500,
|
|
54
|
+
readonly error : ?RouteError,
|
|
55
|
+
readonly interception? : ?FlightInterception,
|
|
56
56
|
|};
|
|
57
57
|
|
|
58
58
|
/** Row 0 of a route's payload: the route, and the tree it rendered. */
|
|
59
59
|
export type FlightRoot = {|
|
|
60
60
|
readonly route: RouteState,
|
|
61
|
-
readonly tree: Node,
|
|
61
|
+
readonly tree : Node,
|
|
62
62
|
/**
|
|
63
63
|
* The build that rendered it, when the build has an id.
|
|
64
64
|
*
|
|
@@ -73,8 +73,8 @@ export type FlightRoot = {|
|
|
|
73
73
|
/** The intercepted URL a Flight payload rendered, and the page it rendered over. */
|
|
74
74
|
export type FlightInterception = {|
|
|
75
75
|
readonly pathname: string,
|
|
76
|
-
readonly search: string,
|
|
77
|
-
readonly from: string,
|
|
76
|
+
readonly search : string,
|
|
77
|
+
readonly from : string,
|
|
78
78
|
|};
|
|
79
79
|
|
|
80
80
|
/** What the browser may send with a payload request. */
|
|
@@ -102,7 +102,7 @@ export type FetchedFlight =
|
|
|
102
102
|
| {|
|
|
103
103
|
readonly kind: "flight",
|
|
104
104
|
/** The route the server answered for: a redirect's target, when there was one. */
|
|
105
|
-
readonly url: string,
|
|
105
|
+
readonly url : string,
|
|
106
106
|
readonly root: Promise<FlightRoot>,
|
|
107
107
|
|}
|
|
108
108
|
| {|
|
|
@@ -112,7 +112,7 @@ export type FetchedFlight =
|
|
|
112
112
|
* document.
|
|
113
113
|
*/
|
|
114
114
|
readonly kind: "document",
|
|
115
|
-
readonly url: string,
|
|
115
|
+
readonly url : string,
|
|
116
116
|
|};
|
|
117
117
|
|
|
118
118
|
/**
|
|
@@ -152,24 +152,24 @@ export function crossableRouteError(error: ?RouteError): ?RouteError {
|
|
|
152
152
|
export function routeState(resolved: ResolvedRoute): RouteState {
|
|
153
153
|
const interception = resolved.interception;
|
|
154
154
|
return {
|
|
155
|
-
pathname: resolved.pathname,
|
|
156
|
-
search: resolved.search,
|
|
157
|
-
path: resolved.path,
|
|
158
|
-
params: resolved.params,
|
|
159
|
-
searchParams: resolved.searchParams,
|
|
160
|
-
data: resolved.data,
|
|
161
|
-
deferred: resolved.deferred,
|
|
162
|
-
metadata: resolved.metadata,
|
|
155
|
+
pathname : resolved.pathname,
|
|
156
|
+
search : resolved.search,
|
|
157
|
+
path : resolved.path,
|
|
158
|
+
params : resolved.params,
|
|
159
|
+
searchParams : resolved.searchParams,
|
|
160
|
+
data : resolved.data,
|
|
161
|
+
deferred : resolved.deferred,
|
|
162
|
+
metadata : resolved.metadata,
|
|
163
163
|
viewTransition: resolved.viewTransition,
|
|
164
|
-
status: resolved.status,
|
|
165
|
-
error: resolved.error,
|
|
164
|
+
status : resolved.status,
|
|
165
|
+
error : resolved.error,
|
|
166
166
|
interception:
|
|
167
167
|
interception == null
|
|
168
168
|
? null
|
|
169
169
|
: {
|
|
170
170
|
pathname: interception.pathname,
|
|
171
|
-
search: interception.search,
|
|
172
|
-
from: interception.base.pathname + interception.base.search,
|
|
171
|
+
search : interception.search,
|
|
172
|
+
from : interception.base.pathname + interception.base.search,
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
175
|
}
|
package/internal/form-action.js
CHANGED
|
@@ -61,10 +61,10 @@ export const FORM_ACTION_CONTENT_TYPE = "application/x-www-form-urlencoded";
|
|
|
61
61
|
|
|
62
62
|
/** What `$$FORM_ACTION` answers, in the shape React reads. */
|
|
63
63
|
export type FormActionFields = {|
|
|
64
|
-
readonly name: string,
|
|
65
|
-
readonly method: "POST",
|
|
64
|
+
readonly name : string,
|
|
65
|
+
readonly method : "POST",
|
|
66
66
|
readonly encType: string,
|
|
67
|
-
readonly data: FormData,
|
|
67
|
+
readonly data : FormData,
|
|
68
68
|
|};
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -92,8 +92,8 @@ export type FormState = [mixed, string, string, number];
|
|
|
92
92
|
* network call in the browser.
|
|
93
93
|
*/
|
|
94
94
|
export function withFormAction<T extends (...args: $ReadOnlyArray<empty>) => mixed>(
|
|
95
|
-
fn: T,
|
|
96
|
-
id: string,
|
|
95
|
+
fn : T,
|
|
96
|
+
id : string,
|
|
97
97
|
bound: $ReadOnlyArray<mixed>,
|
|
98
98
|
): T {
|
|
99
99
|
const define = (name: string, value: mixed) => {
|
|
@@ -125,8 +125,8 @@ export function withFormAction<T extends (...args: $ReadOnlyArray<empty>) => mix
|
|
|
125
125
|
* so an unencodable state costs the pre-hydration submit and nothing else.
|
|
126
126
|
*/
|
|
127
127
|
export function formFields(
|
|
128
|
-
id: string,
|
|
129
|
-
bound: $ReadOnlyArray<mixed>,
|
|
128
|
+
id : string,
|
|
129
|
+
bound : $ReadOnlyArray<mixed>,
|
|
130
130
|
prefix: string,
|
|
131
131
|
): FormActionFields {
|
|
132
132
|
const data = new FormData();
|
|
@@ -135,8 +135,8 @@ export function formFields(
|
|
|
135
135
|
data.append(`${FORM_BOUND_FIELD}${prefix}`, encodeActionArguments(bound));
|
|
136
136
|
}
|
|
137
137
|
return {
|
|
138
|
-
name: `${FORM_REF_FIELD}${prefix}`,
|
|
139
|
-
method: "POST",
|
|
138
|
+
name : `${FORM_REF_FIELD}${prefix}`,
|
|
139
|
+
method : "POST",
|
|
140
140
|
encType: FORM_ACTION_CONTENT_TYPE,
|
|
141
141
|
data,
|
|
142
142
|
};
|
|
@@ -184,8 +184,8 @@ export function readFormPost(fields: URLSearchParams): FormPost | null {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
return {
|
|
187
|
-
id: fields.get(`${FORM_ID_FIELD}${prefix}`),
|
|
188
|
-
bound: fields.get(`${FORM_BOUND_FIELD}${prefix}`),
|
|
187
|
+
id : fields.get(`${FORM_ID_FIELD}${prefix}`),
|
|
188
|
+
bound : fields.get(`${FORM_BOUND_FIELD}${prefix}`),
|
|
189
189
|
stateKey: fields.get(FORM_STATE_KEY_FIELD),
|
|
190
190
|
entries,
|
|
191
191
|
};
|
|
@@ -21,7 +21,7 @@ type HydrationOptions = {| onRecoverableError?: Recovery, formState?: FormState
|
|
|
21
21
|
* hook starts from the action's result instead of its initial state.
|
|
22
22
|
*/
|
|
23
23
|
export function hydrationOptions(
|
|
24
|
-
recovery: ?Recovery,
|
|
24
|
+
recovery : ?Recovery,
|
|
25
25
|
formState: FormState | void,
|
|
26
26
|
): HydrationOptions | void {
|
|
27
27
|
// React's default reporter dispatches a global error for a boundary it
|
package/internal/hydration.js
CHANGED
|
@@ -135,7 +135,7 @@ export type HydrationDifference = {|
|
|
|
135
135
|
export type HydrationReport = {|
|
|
136
136
|
/** React's own message, kept because it is the thing people search for. */
|
|
137
137
|
readonly message: string,
|
|
138
|
-
readonly cause: HydrationCause,
|
|
138
|
+
readonly cause : HydrationCause,
|
|
139
139
|
/** One sentence saying what that cause means, in the reader's own page. */
|
|
140
140
|
readonly explanation: string,
|
|
141
141
|
/** What to do about it. Empty for `unknown`, which has no advice worth giving. */
|
|
@@ -178,7 +178,7 @@ const COMMENT_NODE = 8;
|
|
|
178
178
|
|
|
179
179
|
type DetachedHeadStyle = {|
|
|
180
180
|
readonly anchor: Comment,
|
|
181
|
-
readonly style: HTMLStyleElement,
|
|
181
|
+
readonly style : HTMLStyleElement,
|
|
182
182
|
|};
|
|
183
183
|
|
|
184
184
|
/**
|
|
@@ -291,9 +291,9 @@ function serialize(container: Node): string | null {
|
|
|
291
291
|
* has ever been about it.
|
|
292
292
|
*/
|
|
293
293
|
function parseServerMarkup(
|
|
294
|
-
markup: string,
|
|
294
|
+
markup : string,
|
|
295
295
|
container: Node,
|
|
296
|
-
document: Document,
|
|
296
|
+
document : Document,
|
|
297
297
|
): {| server: $ReadOnlyArray<Node>, client: $ReadOnlyArray<Node> |} | null {
|
|
298
298
|
const asDocument = container as $FlowFixMe as { documentElement?: ?Element, ... };
|
|
299
299
|
const live = asDocument.documentElement;
|
|
@@ -399,11 +399,11 @@ function firstDifference(
|
|
|
399
399
|
}
|
|
400
400
|
if (frame.kind === "unmatched") {
|
|
401
401
|
return {
|
|
402
|
-
kind: frame.server == null ? "extra" : "missing",
|
|
403
|
-
path: frame.path,
|
|
402
|
+
kind : frame.server == null ? "extra" : "missing",
|
|
403
|
+
path : frame.path,
|
|
404
404
|
attribute: null,
|
|
405
|
-
server: frame.server == null ? null : show(frame.server),
|
|
406
|
-
client: frame.client == null ? null : show(frame.client),
|
|
405
|
+
server : frame.server == null ? null : show(frame.server),
|
|
406
|
+
client : frame.client == null ? null : show(frame.client),
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
409
|
|
|
@@ -413,8 +413,8 @@ function firstDifference(
|
|
|
413
413
|
kind: "node-type",
|
|
414
414
|
path,
|
|
415
415
|
attribute: null,
|
|
416
|
-
server: show(server),
|
|
417
|
-
client: show(client),
|
|
416
|
+
server : show(server),
|
|
417
|
+
client : show(client),
|
|
418
418
|
};
|
|
419
419
|
}
|
|
420
420
|
if (server.nodeType === TEXT_NODE || server.nodeType === COMMENT_NODE) {
|
|
@@ -423,8 +423,8 @@ function firstDifference(
|
|
|
423
423
|
kind: "text",
|
|
424
424
|
path,
|
|
425
425
|
attribute: null,
|
|
426
|
-
server: show(server),
|
|
427
|
-
client: show(client),
|
|
426
|
+
server : show(server),
|
|
427
|
+
client : show(client),
|
|
428
428
|
};
|
|
429
429
|
}
|
|
430
430
|
continue;
|
|
@@ -460,11 +460,11 @@ function firstDifference(
|
|
|
460
460
|
* document order, with a marker where one side runs out before the other.
|
|
461
461
|
*/
|
|
462
462
|
function pushChildren(
|
|
463
|
-
stack: Array<Frame>,
|
|
463
|
+
stack : Array<Frame>,
|
|
464
464
|
server: $ReadOnlyArray<Node>,
|
|
465
465
|
client: $ReadOnlyArray<Node>,
|
|
466
|
-
path: string,
|
|
467
|
-
depth: number,
|
|
466
|
+
path : string,
|
|
467
|
+
depth : number,
|
|
468
468
|
): void {
|
|
469
469
|
const most = Math.max(server.length, client.length);
|
|
470
470
|
for (let index = most - 1; index >= 0; index -= 1) {
|
|
@@ -473,18 +473,18 @@ function pushChildren(
|
|
|
473
473
|
if (onServer == null || onClient == null) {
|
|
474
474
|
const present = onServer ?? onClient;
|
|
475
475
|
stack.push({
|
|
476
|
-
kind: "unmatched",
|
|
476
|
+
kind : "unmatched",
|
|
477
477
|
server: onServer,
|
|
478
478
|
client: onClient,
|
|
479
|
-
path: present == null ? path : join(path, present, index),
|
|
479
|
+
path : present == null ? path : join(path, present, index),
|
|
480
480
|
});
|
|
481
481
|
continue;
|
|
482
482
|
}
|
|
483
483
|
stack.push({
|
|
484
|
-
kind: "pair",
|
|
484
|
+
kind : "pair",
|
|
485
485
|
server: onServer,
|
|
486
486
|
client: onClient,
|
|
487
|
-
path: join(path, onServer, index),
|
|
487
|
+
path : join(path, onServer, index),
|
|
488
488
|
depth,
|
|
489
489
|
});
|
|
490
490
|
}
|
|
@@ -615,15 +615,15 @@ function classify(message: string, difference: HydrationDifference | null): Hydr
|
|
|
615
615
|
// Every kind is named, so a kind added to `DifferenceKind` stops this file
|
|
616
616
|
// compiling rather than arriving in somebody's overlay as "unknown".
|
|
617
617
|
return match (difference.kind) {
|
|
618
|
-
"extra" | "missing"
|
|
618
|
+
"extra" | "missing" => "browser-only",
|
|
619
619
|
// Text on one side and whitespace on the other is a node that only one
|
|
620
620
|
// render produced, not two renders that disagreed about a value.
|
|
621
621
|
"text" if (server.trim() === "" || client.trim() === "") => "browser-only",
|
|
622
|
-
"text"
|
|
623
|
-
"attribute" if (oneSided)
|
|
624
|
-
"attribute"
|
|
622
|
+
"text" => sameShape(server, client) ? "variable-input" : "unknown",
|
|
623
|
+
"attribute" if (oneSided) => "browser-only",
|
|
624
|
+
"attribute" => sameShape(server, client) ? "variable-input" : "unknown",
|
|
625
625
|
// The two trees hold different nodes here, which says nothing about why.
|
|
626
|
-
"node-type" | "tag"
|
|
626
|
+
"node-type" | "tag" => "unknown",
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
629
|
|
|
@@ -655,10 +655,10 @@ const REMEDIES: { readonly [HydrationCause]: string } = {
|
|
|
655
655
|
* global.
|
|
656
656
|
*/
|
|
657
657
|
export function hydrationReport(input: {|
|
|
658
|
-
readonly message: string,
|
|
659
|
-
readonly serverMarkup: string | null,
|
|
660
|
-
readonly container: Node | null,
|
|
661
|
-
readonly document: Document,
|
|
658
|
+
readonly message : string,
|
|
659
|
+
readonly serverMarkup : string | null,
|
|
660
|
+
readonly container : Node | null,
|
|
661
|
+
readonly document : Document,
|
|
662
662
|
readonly componentStack: string | null,
|
|
663
663
|
|}): HydrationReport {
|
|
664
664
|
const components = componentsOf(input.componentStack);
|
|
@@ -668,7 +668,7 @@ export function hydrationReport(input: {|
|
|
|
668
668
|
message: input.message,
|
|
669
669
|
cause,
|
|
670
670
|
explanation: EXPLANATIONS[cause],
|
|
671
|
-
remedy: REMEDIES[cause],
|
|
671
|
+
remedy : REMEDIES[cause],
|
|
672
672
|
difference,
|
|
673
673
|
components,
|
|
674
674
|
note,
|
|
@@ -676,10 +676,10 @@ export function hydrationReport(input: {|
|
|
|
676
676
|
}
|
|
677
677
|
|
|
678
678
|
function compare(input: {|
|
|
679
|
-
readonly message: string,
|
|
680
|
-
readonly serverMarkup: string | null,
|
|
681
|
-
readonly container: Node | null,
|
|
682
|
-
readonly document: Document,
|
|
679
|
+
readonly message : string,
|
|
680
|
+
readonly serverMarkup : string | null,
|
|
681
|
+
readonly container : Node | null,
|
|
682
|
+
readonly document : Document,
|
|
683
683
|
readonly componentStack: string | null,
|
|
684
684
|
|}): {| difference: HydrationDifference | null, note: string | null |} {
|
|
685
685
|
if (input.serverMarkup == null || input.container == null) {
|
|
@@ -1031,9 +1031,9 @@ function paragraph(document: Document, text: string, className: string | null):
|
|
|
1031
1031
|
* all. See ubugeeei-prod/uf#583.
|
|
1032
1032
|
*/
|
|
1033
1033
|
export function hydrationErrorHandler(
|
|
1034
|
-
container: Node,
|
|
1034
|
+
container : Node,
|
|
1035
1035
|
serverMarkup: string | null,
|
|
1036
|
-
document: Document,
|
|
1036
|
+
document : Document,
|
|
1037
1037
|
): (error: mixed, info: { componentStack?: ?string, ... }) => void {
|
|
1038
1038
|
return (error, info) => {
|
|
1039
1039
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1074,8 +1074,8 @@ export function hydrationErrorHandler(
|
|
|
1074
1074
|
const [headlineLine, ...rest] = text.split("\n");
|
|
1075
1075
|
reportDiagnostic({
|
|
1076
1076
|
severity: "error",
|
|
1077
|
-
message: headlineLine,
|
|
1078
|
-
detail: rest,
|
|
1077
|
+
message : headlineLine,
|
|
1078
|
+
detail : rest,
|
|
1079
1079
|
});
|
|
1080
1080
|
};
|
|
1081
1081
|
}
|
package/internal/inspector.js
CHANGED
|
@@ -132,10 +132,10 @@ const COMPLETE_MARKER = '$RC("';
|
|
|
132
132
|
* never saw — one past [`LABEL_SCAN_BYTES`], or split across two chunks.
|
|
133
133
|
*/
|
|
134
134
|
export type StreamedBoundary = {|
|
|
135
|
-
readonly id: string,
|
|
135
|
+
readonly id : string,
|
|
136
136
|
readonly fallback: ?string,
|
|
137
|
-
readonly built: $ReadOnlyArray<string>,
|
|
138
|
-
readonly more: number,
|
|
137
|
+
readonly built : $ReadOnlyArray<string>,
|
|
138
|
+
readonly more : number,
|
|
139
139
|
|};
|
|
140
140
|
|
|
141
141
|
/** One chunk of one document, as it went out. */
|
|
@@ -154,20 +154,20 @@ export type StreamedChunk = {|
|
|
|
154
154
|
export type StreamRecord = {|
|
|
155
155
|
readonly chunks: $ReadOnlyArray<StreamedChunk>,
|
|
156
156
|
/** Chunks past [`CHUNK_LIMIT`], which are counted and not described. */
|
|
157
|
-
readonly more: number,
|
|
157
|
+
readonly more : number,
|
|
158
158
|
readonly bytes: number,
|
|
159
159
|
|};
|
|
160
160
|
|
|
161
161
|
/** A recorder, over one document. */
|
|
162
162
|
export type StreamRecorder = {|
|
|
163
|
-
readonly chunk: (text: string) => void,
|
|
163
|
+
readonly chunk : (text: string) => void,
|
|
164
164
|
readonly finish: () => StreamRecord,
|
|
165
165
|
|};
|
|
166
166
|
|
|
167
167
|
/** What the reporter hands `uf dev` to print. */
|
|
168
168
|
export type StreamDiagnostic = {|
|
|
169
169
|
readonly message: string,
|
|
170
|
-
readonly detail: $ReadOnlyArray<string>,
|
|
170
|
+
readonly detail : $ReadOnlyArray<string>,
|
|
171
171
|
|};
|
|
172
172
|
|
|
173
173
|
/**
|
|
@@ -206,9 +206,9 @@ export function inspectStream(now: () => number): StreamRecorder {
|
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
chunks.push({
|
|
209
|
-
index: count,
|
|
210
|
-
at: first == null ? 0 : Math.max(0, Math.round(at - first)),
|
|
211
|
-
bytes: size,
|
|
209
|
+
index : count,
|
|
210
|
+
at : first == null ? 0 : Math.max(0, Math.round(at - first)),
|
|
211
|
+
bytes : size,
|
|
212
212
|
boundaries: completedIn(text, labels),
|
|
213
213
|
});
|
|
214
214
|
},
|
|
@@ -232,7 +232,7 @@ export function inspectStream(now: () => number): StreamRecorder {
|
|
|
232
232
|
export async function* inspected(
|
|
233
233
|
chunks: AsyncGenerator<string, void, void>,
|
|
234
234
|
report: (record: StreamRecord) => void,
|
|
235
|
-
now: () => number,
|
|
235
|
+
now : () => number,
|
|
236
236
|
): AsyncGenerator<string, void, void> {
|
|
237
237
|
const recorder = inspectStream(now);
|
|
238
238
|
try {
|
|
@@ -307,10 +307,10 @@ function completedIn(chunk: string, labels: Map<string, string>): $ReadOnlyArray
|
|
|
307
307
|
}
|
|
308
308
|
const built = builtBy(chunk, ids.content);
|
|
309
309
|
found.push({
|
|
310
|
-
id: ids.boundary,
|
|
310
|
+
id : ids.boundary,
|
|
311
311
|
fallback: labels.get(ids.boundary) ?? null,
|
|
312
|
-
built: built.slice(0, NAMED_LIMIT),
|
|
313
|
-
more: Math.max(0, built.length - NAMED_LIMIT),
|
|
312
|
+
built : built.slice(0, NAMED_LIMIT),
|
|
313
|
+
more : Math.max(0, built.length - NAMED_LIMIT),
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
316
|
return found;
|
|
@@ -319,7 +319,7 @@ function completedIn(chunk: string, labels: Map<string, string>): $ReadOnlyArray
|
|
|
319
319
|
/** The two quoted ids of a `$RC(…)` call whose first quote has been passed. */
|
|
320
320
|
function argumentPair(
|
|
321
321
|
chunk: string,
|
|
322
|
-
from: number,
|
|
322
|
+
from : number,
|
|
323
323
|
): {| readonly boundary: string, readonly content: string |} | null {
|
|
324
324
|
const boundaryEnd = chunk.indexOf('"', from);
|
|
325
325
|
if (boundaryEnd === -1 || !chunk.startsWith(',"', boundaryEnd + 1)) {
|
|
@@ -332,7 +332,7 @@ function argumentPair(
|
|
|
332
332
|
}
|
|
333
333
|
return {
|
|
334
334
|
boundary: chunk.slice(from, boundaryEnd),
|
|
335
|
-
content: chunk.slice(contentAt, contentEnd),
|
|
335
|
+
content : chunk.slice(contentAt, contentEnd),
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
|
package/internal/native-links.js
CHANGED
|
@@ -28,18 +28,18 @@ export function nativeLinkHref(table: Table, to: string): string | null {
|
|
|
28
28
|
export type NativeLinkSource = {|
|
|
29
29
|
readonly getInitialURL: () => Promise<string | null>,
|
|
30
30
|
readonly addEventListener: (
|
|
31
|
-
event: "url",
|
|
31
|
+
event : "url",
|
|
32
32
|
listener: (event: {| url: string |}) => void,
|
|
33
33
|
) => {| remove: () => void |},
|
|
34
34
|
|};
|
|
35
35
|
|
|
36
36
|
/** Pass React Native's Linking; rejected links stay with the OS/browser. */
|
|
37
37
|
export function createNativeLinking(
|
|
38
|
-
table: Table,
|
|
38
|
+
table : Table,
|
|
39
39
|
source: NativeLinkSource,
|
|
40
40
|
): {|
|
|
41
41
|
getInitialURL: () => Promise<string | null>,
|
|
42
|
-
subscribe: (listener: (href: string) => void) => () => void,
|
|
42
|
+
subscribe : (listener: (href: string) => void) => () => void,
|
|
43
43
|
|} {
|
|
44
44
|
let last: string | null = null;
|
|
45
45
|
let deliveredAt = -Infinity;
|
package/internal/native-tree.js
CHANGED
|
@@ -3,13 +3,13 @@ import type { RouteModule, RouteTable } from "./routing.js";
|
|
|
3
3
|
|
|
4
4
|
export type NativeLayout = {
|
|
5
5
|
readonly segment: string,
|
|
6
|
-
readonly file: string,
|
|
7
|
-
readonly module: RouteModule<>,
|
|
6
|
+
readonly file : string,
|
|
7
|
+
readonly module : RouteModule<>,
|
|
8
8
|
};
|
|
9
9
|
export type NativeNode = {
|
|
10
|
-
name: string,
|
|
11
|
-
module: ?RouteModule<>,
|
|
12
|
-
layout: boolean,
|
|
10
|
+
name : string,
|
|
11
|
+
module : ?RouteModule<>,
|
|
12
|
+
layout : boolean,
|
|
13
13
|
children: Array<NativeNode>,
|
|
14
14
|
};
|
|
15
15
|
export type NativeTree = { root: NativeNode, paths: Map<string, $ReadOnlyArray<string>> };
|
|
@@ -46,22 +46,22 @@ export function nativeTree(table: RouteTable<>, layouts: $ReadOnlyArray<NativeLa
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export type NavigationPayload = {
|
|
49
|
-
readonly ufHref: string,
|
|
49
|
+
readonly ufHref : string,
|
|
50
50
|
readonly ufParams: { readonly [string]: string | $ReadOnlyArray<string> },
|
|
51
51
|
};
|
|
52
52
|
export type NavigationState = {
|
|
53
|
-
readonly key
|
|
54
|
-
readonly type
|
|
53
|
+
readonly key? : string,
|
|
54
|
+
readonly type? : string,
|
|
55
55
|
readonly index?: number,
|
|
56
56
|
readonly routes: $ReadOnlyArray<{
|
|
57
|
-
readonly name: string,
|
|
57
|
+
readonly name : string,
|
|
58
58
|
readonly params?: NavigationPayload,
|
|
59
|
-
readonly state
|
|
59
|
+
readonly state? : NavigationState,
|
|
60
60
|
}>,
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
export function stateForPath(
|
|
64
|
-
names: $ReadOnlyArray<string>,
|
|
64
|
+
names : $ReadOnlyArray<string>,
|
|
65
65
|
payload: NavigationPayload,
|
|
66
66
|
): NavigationState {
|
|
67
67
|
const [name, ...rest] = names;
|
|
@@ -64,7 +64,7 @@ export function installStaleTime(seconds: number): void {
|
|
|
64
64
|
if (import.meta.hot != null) {
|
|
65
65
|
Object.defineProperty(globalThis as $FlowFixMe, "__UF_NAVIGATION_CACHE__", {
|
|
66
66
|
configurable: true,
|
|
67
|
-
value: inspectNavigationCache,
|
|
67
|
+
value : inspectNavigationCache,
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
if (staleTimeMs === 0) {
|
|
@@ -90,18 +90,18 @@ export type NavigationCache<T> = {|
|
|
|
90
90
|
readonly store: (key: string, value: T) => void,
|
|
91
91
|
/** Drop what `key` keeps, if it is still `value`. */
|
|
92
92
|
readonly forget: (key: string, value: T) => void,
|
|
93
|
-
readonly clear: () => void,
|
|
93
|
+
readonly clear : () => void,
|
|
94
94
|
/** How many routes are kept, fresh or not. */
|
|
95
|
-
readonly size: () => number,
|
|
95
|
+
readonly size : () => number,
|
|
96
96
|
readonly inspect: () => $ReadOnlyArray<NavigationCacheEntry>,
|
|
97
97
|
|};
|
|
98
98
|
|
|
99
99
|
/** Metadata only: inspecting the cache never exposes loader or Flight data. */
|
|
100
100
|
export type NavigationCacheEntry = {|
|
|
101
|
-
readonly key: string,
|
|
101
|
+
readonly key : string,
|
|
102
102
|
readonly cachedAt: number,
|
|
103
|
-
readonly staleAt: number,
|
|
104
|
-
readonly fresh: boolean,
|
|
103
|
+
readonly staleAt : number,
|
|
104
|
+
readonly fresh : boolean,
|
|
105
105
|
|};
|
|
106
106
|
|
|
107
107
|
function createNavigationCache<T>(): NavigationCache<T> {
|
|
@@ -148,8 +148,8 @@ function createNavigationCache<T>(): NavigationCache<T> {
|
|
|
148
148
|
return Array.from(entries, ([key, entry]) => ({
|
|
149
149
|
key,
|
|
150
150
|
cachedAt: entry.at,
|
|
151
|
-
staleAt: entry.at + staleTimeMs,
|
|
152
|
-
fresh: now - entry.at < staleTimeMs,
|
|
151
|
+
staleAt : entry.at + staleTimeMs,
|
|
152
|
+
fresh : now - entry.at < staleTimeMs,
|
|
153
153
|
}));
|
|
154
154
|
},
|
|
155
155
|
};
|
|
@@ -164,13 +164,13 @@ export const routeNavigations: NavigationCache<Promise<ResolvedRoute>> = createN
|
|
|
164
164
|
/** A fresh snapshot for the development console, without reading an entry. */
|
|
165
165
|
export function inspectNavigationCache(): {|
|
|
166
166
|
readonly staleTime: number,
|
|
167
|
-
readonly flight: $ReadOnlyArray<NavigationCacheEntry>,
|
|
168
|
-
readonly routes: $ReadOnlyArray<NavigationCacheEntry>,
|
|
167
|
+
readonly flight : $ReadOnlyArray<NavigationCacheEntry>,
|
|
168
|
+
readonly routes : $ReadOnlyArray<NavigationCacheEntry>,
|
|
169
169
|
|} {
|
|
170
170
|
return {
|
|
171
171
|
staleTime: staleTimeMs / 1000,
|
|
172
|
-
flight: flightNavigations.inspect(),
|
|
173
|
-
routes: routeNavigations.inspect(),
|
|
172
|
+
flight : flightNavigations.inspect(),
|
|
173
|
+
routes : routeNavigations.inspect(),
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
|
package/internal/payload-rows.js
CHANGED
|
@@ -96,8 +96,8 @@ type ElementLike = interface {
|
|
|
96
96
|
/** One row the page is waiting for. */
|
|
97
97
|
type Slot = {|
|
|
98
98
|
readonly promise: Promise<mixed>,
|
|
99
|
-
readonly settle: (message: PayloadRowMessage) => void,
|
|
100
|
-
arrived: boolean,
|
|
99
|
+
readonly settle : (message: PayloadRowMessage) => void,
|
|
100
|
+
arrived : boolean,
|
|
101
101
|
|};
|
|
102
102
|
|
|
103
103
|
/**
|
package/internal/payload.js
CHANGED
|
@@ -264,8 +264,8 @@ function setKey(target: { [string]: mixed }, key: string, value: mixed): void {
|
|
|
264
264
|
if (key === "__proto__") {
|
|
265
265
|
Object.defineProperty(target, key, {
|
|
266
266
|
value,
|
|
267
|
-
writable: true,
|
|
268
|
-
enumerable: true,
|
|
267
|
+
writable : true,
|
|
268
|
+
enumerable : true,
|
|
269
269
|
configurable: true,
|
|
270
270
|
});
|
|
271
271
|
return;
|
|
@@ -276,9 +276,9 @@ function setKey(target: { [string]: mixed }, key: string, value: mixed): void {
|
|
|
276
276
|
/** One entry of an explicit walk stack, with the slot to write the result into. */
|
|
277
277
|
type Frame = {|
|
|
278
278
|
readonly value: mixed,
|
|
279
|
-
readonly path: string,
|
|
279
|
+
readonly path : string,
|
|
280
280
|
readonly depth: number,
|
|
281
|
-
readonly emit: (encoded: mixed) => void,
|
|
281
|
+
readonly emit : (encoded: mixed) => void,
|
|
282
282
|
|};
|
|
283
283
|
|
|
284
284
|
/**
|
|
@@ -348,7 +348,7 @@ export function encodePayload(root: mixed, label: string): EncodedPayload {
|
|
|
348
348
|
const stack: Array<Frame> = [
|
|
349
349
|
{
|
|
350
350
|
value: root,
|
|
351
|
-
path: label,
|
|
351
|
+
path : label,
|
|
352
352
|
depth: 0,
|
|
353
353
|
emit: (encoded) => {
|
|
354
354
|
model = encoded;
|
|
@@ -388,7 +388,7 @@ export function encodePayload(root: mixed, label: string): EncodedPayload {
|
|
|
388
388
|
for (let index = value.length - 1; index >= 0; index -= 1) {
|
|
389
389
|
stack.push({
|
|
390
390
|
value: value[index],
|
|
391
|
-
path: `${path}[${String(index)}]`,
|
|
391
|
+
path : `${path}[${String(index)}]`,
|
|
392
392
|
depth: depth + 1,
|
|
393
393
|
emit: (child) => {
|
|
394
394
|
encoded[index] = child;
|
|
@@ -411,7 +411,7 @@ export function encodePayload(root: mixed, label: string): EncodedPayload {
|
|
|
411
411
|
const key = keys[index];
|
|
412
412
|
stack.push({
|
|
413
413
|
value: source[key],
|
|
414
|
-
path: `${path}.${key}`,
|
|
414
|
+
path : `${path}.${key}`,
|
|
415
415
|
depth: depth + 1,
|
|
416
416
|
emit: (child) => {
|
|
417
417
|
setKey(encoded, key, child);
|
|
@@ -468,7 +468,7 @@ export function decodePayload(root: mixed, resolve: RowResolver, label: string):
|
|
|
468
468
|
const stack: Array<Frame> = [
|
|
469
469
|
{
|
|
470
470
|
value: root,
|
|
471
|
-
path: label,
|
|
471
|
+
path : label,
|
|
472
472
|
depth: 0,
|
|
473
473
|
emit: (value) => {
|
|
474
474
|
out = value;
|
|
@@ -496,7 +496,7 @@ export function decodePayload(root: mixed, resolve: RowResolver, label: string):
|
|
|
496
496
|
for (let index = value.length - 1; index >= 0; index -= 1) {
|
|
497
497
|
stack.push({
|
|
498
498
|
value: value[index],
|
|
499
|
-
path: `${path}[${String(index)}]`,
|
|
499
|
+
path : `${path}[${String(index)}]`,
|
|
500
500
|
depth: depth + 1,
|
|
501
501
|
emit: (child) => {
|
|
502
502
|
rebuilt[index] = child;
|
|
@@ -517,7 +517,7 @@ export function decodePayload(root: mixed, resolve: RowResolver, label: string):
|
|
|
517
517
|
const key = keys[index];
|
|
518
518
|
stack.push({
|
|
519
519
|
value: source[key],
|
|
520
|
-
path: `${path}.${key}`,
|
|
520
|
+
path : `${path}.${key}`,
|
|
521
521
|
depth: depth + 1,
|
|
522
522
|
emit: (child) => {
|
|
523
523
|
setKey(rebuilt, key, child);
|