@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/internal/runtime.js
CHANGED
|
@@ -273,7 +273,7 @@ type ViewTransition = { readonly finished: Promise<mixed>, ... };
|
|
|
273
273
|
*/
|
|
274
274
|
interface ViewTransitionDocument {
|
|
275
275
|
readonly startViewTransition?: (update: () => mixed) => ViewTransition;
|
|
276
|
-
readonly documentElement: HTMLElement | null;
|
|
276
|
+
readonly documentElement : HTMLElement | null;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
/**
|
|
@@ -347,7 +347,7 @@ function withViewTransition(name: ?string, update: () => void): void {
|
|
|
347
347
|
/** How a navigation is performed. */
|
|
348
348
|
export type NavigateOptions = {|
|
|
349
349
|
readonly replace?: boolean,
|
|
350
|
-
readonly scroll
|
|
350
|
+
readonly scroll? : boolean,
|
|
351
351
|
/**
|
|
352
352
|
* Whether this navigation may animate. Defaults to `true`, which is what
|
|
353
353
|
* every navigation does.
|
|
@@ -364,12 +364,12 @@ export type NavigateOptions = {|
|
|
|
364
364
|
|
|
365
365
|
/** What `useRouter()` returns. */
|
|
366
366
|
export type Router = {|
|
|
367
|
-
readonly push: (to: string, options?: NavigateOptions) => Promise<void>,
|
|
368
|
-
readonly replace: (to: string) => Promise<void>,
|
|
367
|
+
readonly push : (to: string, options?: NavigateOptions) => Promise<void>,
|
|
368
|
+
readonly replace : (to: string) => Promise<void>,
|
|
369
369
|
readonly prefetch: (to: string) => Promise<void>,
|
|
370
|
-
readonly refresh: () => Promise<void>,
|
|
371
|
-
readonly back: () => void,
|
|
372
|
-
readonly forward: () => void,
|
|
370
|
+
readonly refresh : () => Promise<void>,
|
|
371
|
+
readonly back : () => void,
|
|
372
|
+
readonly forward : () => void,
|
|
373
373
|
|};
|
|
374
374
|
|
|
375
375
|
/**
|
|
@@ -570,12 +570,12 @@ export async function followActionRedirect(location: string, from: string): Prom
|
|
|
570
570
|
|
|
571
571
|
/** What `useRoute()` returns. */
|
|
572
572
|
export type RouteInfo = {|
|
|
573
|
-
readonly path: string,
|
|
574
|
-
readonly pathname: string,
|
|
575
|
-
readonly params: RouteParams,
|
|
573
|
+
readonly path : string,
|
|
574
|
+
readonly pathname : string,
|
|
575
|
+
readonly params : RouteParams,
|
|
576
576
|
readonly searchParams: SearchParams,
|
|
577
|
-
readonly data: mixed,
|
|
578
|
-
readonly pending: boolean,
|
|
577
|
+
readonly data : mixed,
|
|
578
|
+
readonly pending : boolean,
|
|
579
579
|
|};
|
|
580
580
|
|
|
581
581
|
/**
|
|
@@ -596,10 +596,10 @@ export type Navigation = "client" | "document";
|
|
|
596
596
|
* from its modules, which the browser composes itself.
|
|
597
597
|
*/
|
|
598
598
|
type RouterState = {|
|
|
599
|
-
readonly route: RouteState,
|
|
600
|
-
readonly view: RouteViewState,
|
|
601
|
-
readonly router: Router,
|
|
602
|
-
readonly pending: boolean,
|
|
599
|
+
readonly route : RouteState,
|
|
600
|
+
readonly view : RouteViewState,
|
|
601
|
+
readonly router : Router,
|
|
602
|
+
readonly pending : boolean,
|
|
603
603
|
readonly navigation: Navigation,
|
|
604
604
|
|};
|
|
605
605
|
|
|
@@ -708,9 +708,9 @@ export function routeTable(): RouteTable {
|
|
|
708
708
|
* modules instead. See ubugeeei-prod/uf#519.
|
|
709
709
|
*/
|
|
710
710
|
export type AppProps = {|
|
|
711
|
-
readonly url: string,
|
|
711
|
+
readonly url : string,
|
|
712
712
|
readonly initial?: ResolvedRoute,
|
|
713
|
-
readonly flight
|
|
713
|
+
readonly flight? : Promise<FlightRoot>,
|
|
714
714
|
|};
|
|
715
715
|
|
|
716
716
|
/**
|
|
@@ -760,9 +760,9 @@ function isBrowser(): boolean {
|
|
|
760
760
|
* that actually differs.
|
|
761
761
|
*/
|
|
762
762
|
export component RouterProvider(
|
|
763
|
-
url: string,
|
|
763
|
+
url : string,
|
|
764
764
|
initial?: ResolvedRoute,
|
|
765
|
-
flight
|
|
765
|
+
flight? : Promise<FlightRoot>,
|
|
766
766
|
children: React.Node,
|
|
767
767
|
) {
|
|
768
768
|
if (flight != null) {
|
|
@@ -868,7 +868,7 @@ function flightNavigationKey(pathname: string, search: string, from: ?string): s
|
|
|
868
868
|
*/
|
|
869
869
|
component ModuleRouter(url: string, initial: ResolvedRoute, children: React.Node) {
|
|
870
870
|
const [resolved, setResolved] = useState<ResolvedRoute>(initial);
|
|
871
|
-
const [pending,
|
|
871
|
+
const [pending, setPending] = useState<boolean>(false);
|
|
872
872
|
// Read once per render rather than per navigation: it is installed by the
|
|
873
873
|
// entry before the first render and never changes after it, and a `Link`
|
|
874
874
|
// that asked at click time would be asking a question whose answer decided
|
|
@@ -1087,7 +1087,7 @@ component ModuleRouter(url: string, initial: ResolvedRoute, children: React.Node
|
|
|
1087
1087
|
}, []);
|
|
1088
1088
|
|
|
1089
1089
|
const router: Router = {
|
|
1090
|
-
push: (to, options) => navigate(to, options),
|
|
1090
|
+
push : (to, options) => navigate(to, options),
|
|
1091
1091
|
replace: (to) => navigate(to, { replace: true }),
|
|
1092
1092
|
prefetch: async (to) => {
|
|
1093
1093
|
// A prefetch loads the modules the *next render* will need, and under
|
|
@@ -1214,7 +1214,7 @@ component ModuleRouter(url: string, initial: ResolvedRoute, children: React.Node
|
|
|
1214
1214
|
|
|
1215
1215
|
const value: RouterState = {
|
|
1216
1216
|
route: routeState(resolved),
|
|
1217
|
-
view: { kind: "modules", resolved },
|
|
1217
|
+
view : { kind: "modules", resolved },
|
|
1218
1218
|
router,
|
|
1219
1219
|
pending,
|
|
1220
1220
|
navigation,
|
|
@@ -1411,7 +1411,7 @@ component FlightRouter(flight: Promise<FlightRoot>, children: React.Node) {
|
|
|
1411
1411
|
}, []);
|
|
1412
1412
|
|
|
1413
1413
|
const router: Router = {
|
|
1414
|
-
push: (to, options) => navigate(to, options),
|
|
1414
|
+
push : (to, options) => navigate(to, options),
|
|
1415
1415
|
replace: (to) => navigate(to, { replace: true }),
|
|
1416
1416
|
prefetch: async (to) => {
|
|
1417
1417
|
// Under document navigation there is no next render in this page to
|
|
@@ -1518,7 +1518,7 @@ component FlightRouter(flight: Promise<FlightRoot>, children: React.Node) {
|
|
|
1518
1518
|
|
|
1519
1519
|
const value: RouterState = {
|
|
1520
1520
|
route: root.route,
|
|
1521
|
-
view: { kind: "flight", tree: root.tree },
|
|
1521
|
+
view : { kind: "flight", tree: root.tree },
|
|
1522
1522
|
router,
|
|
1523
1523
|
pending,
|
|
1524
1524
|
navigation,
|
|
@@ -1549,8 +1549,8 @@ const prefetchedFlights: Map<
|
|
|
1549
1549
|
* a payload React could not read.
|
|
1550
1550
|
*/
|
|
1551
1551
|
function keepFlight(
|
|
1552
|
-
key: string,
|
|
1553
|
-
fetched: Promise<FetchedFlight>,
|
|
1552
|
+
key : string,
|
|
1553
|
+
fetched : Promise<FetchedFlight>,
|
|
1554
1554
|
ordinaryKey?: string,
|
|
1555
1555
|
): Promise<FetchedFlight> {
|
|
1556
1556
|
if (!keepsNavigations()) {
|
|
@@ -1652,11 +1652,11 @@ export hook useRouterState(): RouterState {
|
|
|
1652
1652
|
export hook useRoute(): RouteInfo {
|
|
1653
1653
|
const { route, pending } = useRouterState();
|
|
1654
1654
|
return {
|
|
1655
|
-
path: route.path,
|
|
1656
|
-
pathname: route.pathname,
|
|
1657
|
-
params: route.params,
|
|
1655
|
+
path : route.path,
|
|
1656
|
+
pathname : route.pathname,
|
|
1657
|
+
params : route.params,
|
|
1658
1658
|
searchParams: route.searchParams,
|
|
1659
|
-
data: useResolvedData(route),
|
|
1659
|
+
data : useResolvedData(route),
|
|
1660
1660
|
pending,
|
|
1661
1661
|
};
|
|
1662
1662
|
}
|
|
@@ -2065,14 +2065,14 @@ export hook useLinkStatus(): {| readonly pending: boolean |} {
|
|
|
2065
2065
|
*/
|
|
2066
2066
|
export type LinkClickEvent = {
|
|
2067
2067
|
readonly defaultPrevented: boolean,
|
|
2068
|
-
readonly button: number,
|
|
2069
|
-
readonly altKey: boolean,
|
|
2070
|
-
readonly ctrlKey: boolean,
|
|
2071
|
-
readonly metaKey: boolean,
|
|
2072
|
-
readonly shiftKey: boolean,
|
|
2073
|
-
readonly currentTarget: mixed,
|
|
2074
|
-
readonly preventDefault: () => mixed,
|
|
2075
|
-
readonly stopPropagation: () => mixed,
|
|
2068
|
+
readonly button : number,
|
|
2069
|
+
readonly altKey : boolean,
|
|
2070
|
+
readonly ctrlKey : boolean,
|
|
2071
|
+
readonly metaKey : boolean,
|
|
2072
|
+
readonly shiftKey : boolean,
|
|
2073
|
+
readonly currentTarget : mixed,
|
|
2074
|
+
readonly preventDefault : () => mixed,
|
|
2075
|
+
readonly stopPropagation : () => mixed,
|
|
2076
2076
|
...
|
|
2077
2077
|
};
|
|
2078
2078
|
|
|
@@ -2102,20 +2102,20 @@ export type LinkClickEvent = {
|
|
|
2102
2102
|
* ordinary link.
|
|
2103
2103
|
*/
|
|
2104
2104
|
export component Link(
|
|
2105
|
-
to: string,
|
|
2106
|
-
prefetch
|
|
2107
|
-
replace
|
|
2105
|
+
to : string,
|
|
2106
|
+
prefetch? : LinkPrefetch = "intent",
|
|
2107
|
+
replace? : boolean = false,
|
|
2108
2108
|
transition?: boolean = true,
|
|
2109
|
-
children
|
|
2110
|
-
className
|
|
2111
|
-
onClick
|
|
2109
|
+
children? : React.Node,
|
|
2110
|
+
className? : string,
|
|
2111
|
+
onClick? : (event: LinkClickEvent) => mixed,
|
|
2112
2112
|
// `key` named out of the indexer: React never hands a component its key, and
|
|
2113
2113
|
// the rest is spread onto the anchor, where a `mixed` key would not do.
|
|
2114
2114
|
...rest: { readonly key?: empty, readonly [string]: mixed }
|
|
2115
2115
|
) {
|
|
2116
|
-
const { router, navigation }
|
|
2116
|
+
const { router, navigation } = useRouterState();
|
|
2117
2117
|
const [linkPending, startLinkTransition] = useTransition();
|
|
2118
|
-
const prefetched
|
|
2118
|
+
const prefetched = useRef(false);
|
|
2119
2119
|
const drives = navigation === "client";
|
|
2120
2120
|
|
|
2121
2121
|
const doPrefetch = () => {
|
|
@@ -68,7 +68,7 @@ export async function parseSearchParams(
|
|
|
68
68
|
*/
|
|
69
69
|
export function searchParamsInput(
|
|
70
70
|
description: Description,
|
|
71
|
-
query: SearchParamsAll,
|
|
71
|
+
query : SearchParamsAll,
|
|
72
72
|
): { readonly [string]: mixed } {
|
|
73
73
|
const fields = objectFields(description);
|
|
74
74
|
// Built as a `Map` and turned into an object once, by `Object.fromEntries`,
|
package/internal/shell.js
CHANGED
|
@@ -22,9 +22,9 @@ import { type DocumentShell, bodyOfText } from "./stream.js";
|
|
|
22
22
|
/** A redirect, as the finished document `prerender` answers with. */
|
|
23
23
|
export async function redirectResult(document: RenderResult): Promise<PrerenderResult> {
|
|
24
24
|
return {
|
|
25
|
-
status: document.status,
|
|
25
|
+
status : document.status,
|
|
26
26
|
headers: document.headers,
|
|
27
|
-
html: await document.text(),
|
|
27
|
+
html : await document.text(),
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -41,11 +41,11 @@ export function redirectDocument(error: RedirectError): RenderResult {
|
|
|
41
41
|
`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0; url=${target}"><title>Redirecting</title></head><body><a href="${target}">Redirecting…</a></body></html>\n`,
|
|
42
42
|
);
|
|
43
43
|
return {
|
|
44
|
-
status: error.permanent ? 308 : 307,
|
|
44
|
+
status : error.permanent ? 308 : 307,
|
|
45
45
|
headers: { Location: address },
|
|
46
|
-
pipe: body.pipe,
|
|
47
|
-
stream: body.stream,
|
|
48
|
-
text: body.text,
|
|
46
|
+
pipe : body.pipe,
|
|
47
|
+
stream : body.stream,
|
|
48
|
+
text : body.text,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -81,8 +81,8 @@ export function redirectDocument(error: RedirectError): RenderResult {
|
|
|
81
81
|
* looks. Hoisting the rendered one leaves the metadata with a single source.
|
|
82
82
|
*/
|
|
83
83
|
export function shellFor(
|
|
84
|
-
assets: RenderAssets,
|
|
85
|
-
nonce
|
|
84
|
+
assets : RenderAssets,
|
|
85
|
+
nonce? : string | null,
|
|
86
86
|
formState?: FormState,
|
|
87
87
|
): DocumentShell {
|
|
88
88
|
// A postback's form state goes first, before the client entry that reads it:
|
package/internal/stream.js
CHANGED
|
@@ -57,7 +57,7 @@ import { type StreamRecord, inspected } from "./inspector.js";
|
|
|
57
57
|
*/
|
|
58
58
|
export type WritableLike = {
|
|
59
59
|
readonly write: (chunk: string) => mixed,
|
|
60
|
-
readonly end: () => mixed,
|
|
60
|
+
readonly end : () => mixed,
|
|
61
61
|
...
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -89,14 +89,14 @@ export type DocumentBody = {|
|
|
|
89
89
|
* point of writing it down.
|
|
90
90
|
*/
|
|
91
91
|
type NodeDestination = {
|
|
92
|
-
readonly write: (chunk: string | Uint8Array) => boolean,
|
|
93
|
-
readonly end: () => mixed,
|
|
94
|
-
readonly destroy: (error?: mixed) => mixed,
|
|
95
|
-
readonly on: (event: string, listener: (...args: Array<mixed>) => mixed) => mixed,
|
|
96
|
-
readonly once: (event: string, listener: (...args: Array<mixed>) => mixed) => mixed,
|
|
97
|
-
readonly off: () => mixed,
|
|
92
|
+
readonly write : (chunk: string | Uint8Array) => boolean,
|
|
93
|
+
readonly end : () => mixed,
|
|
94
|
+
readonly destroy : (error?: mixed) => mixed,
|
|
95
|
+
readonly on : (event: string, listener: (...args: Array<mixed>) => mixed) => mixed,
|
|
96
|
+
readonly once : (event: string, listener: (...args: Array<mixed>) => mixed) => mixed,
|
|
97
|
+
readonly off : () => mixed,
|
|
98
98
|
readonly removeListener: () => mixed,
|
|
99
|
-
readonly emit: () => boolean,
|
|
99
|
+
readonly emit : () => boolean,
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
/** The controller a `ReadableStream` source is handed. */
|
|
@@ -107,7 +107,7 @@ type NodeDestination = {
|
|
|
107
107
|
* cannot type a value whose definition depends on itself without being told.
|
|
108
108
|
*/
|
|
109
109
|
type PipeableStream = {
|
|
110
|
-
readonly pipe: (destination: NodeDestination) => mixed,
|
|
110
|
+
readonly pipe : (destination: NodeDestination) => mixed,
|
|
111
111
|
readonly abort: (reason?: mixed) => void,
|
|
112
112
|
...
|
|
113
113
|
};
|
|
@@ -322,10 +322,10 @@ function queueDestination(queue: ChunkQueue): NodeDestination {
|
|
|
322
322
|
* once, and everything that belongs in it has to be in hand by then.
|
|
323
323
|
*/
|
|
324
324
|
async function* assembled(
|
|
325
|
-
chunks: AsyncGenerator<string, void, void>,
|
|
326
|
-
shell: DocumentShell,
|
|
325
|
+
chunks : AsyncGenerator<string, void, void>,
|
|
326
|
+
shell : DocumentShell,
|
|
327
327
|
transformHead?: (html: string) => Promise<string>,
|
|
328
|
-
layout
|
|
328
|
+
layout? : Layout,
|
|
329
329
|
): AsyncGenerator<string, void, void> {
|
|
330
330
|
let held = "";
|
|
331
331
|
let shape = "unknown";
|
|
@@ -725,7 +725,7 @@ export type RenderOptions = {|
|
|
|
725
725
|
* handed, head and all, and not React's own output on the way past.
|
|
726
726
|
*/
|
|
727
727
|
function outgoing(
|
|
728
|
-
chunks: AsyncGenerator<string, void, void>,
|
|
728
|
+
chunks : AsyncGenerator<string, void, void>,
|
|
729
729
|
onStream?: (record: StreamRecord) => void,
|
|
730
730
|
): AsyncGenerator<string, void, void> {
|
|
731
731
|
return onStream == null ? chunks : inspected(chunks, onStream, () => performance.now());
|
|
@@ -772,7 +772,7 @@ export function renderDocument(node: React.Node, options: RenderOptions): Promis
|
|
|
772
772
|
// the streaming runtime that reveals a boundary and patches a segment,
|
|
773
773
|
// and the bootstrap. uf nonces the scripts it writes itself; these are
|
|
774
774
|
// React's, and there is no other way to reach them.
|
|
775
|
-
nonce: options.nonce ?? undefined,
|
|
775
|
+
nonce : options.nonce ?? undefined,
|
|
776
776
|
formState: options.formState ?? null,
|
|
777
777
|
});
|
|
778
778
|
return;
|
|
@@ -799,9 +799,9 @@ export function renderDocument(node: React.Node, options: RenderOptions): Promis
|
|
|
799
799
|
type ReadableStreamRenderer = (
|
|
800
800
|
node: React.Node,
|
|
801
801
|
settings: {|
|
|
802
|
-
readonly onError: (error: mixed) => void,
|
|
803
|
-
readonly signal: AbortSignal,
|
|
804
|
-
readonly nonce
|
|
802
|
+
readonly onError : (error: mixed) => void,
|
|
803
|
+
readonly signal : AbortSignal,
|
|
804
|
+
readonly nonce? : string,
|
|
805
805
|
readonly formState?: FormState | null,
|
|
806
806
|
|},
|
|
807
807
|
) => Promise<ByteSource>;
|
|
@@ -823,15 +823,15 @@ type ReadableStreamRenderer = (
|
|
|
823
823
|
* disagreed.
|
|
824
824
|
*/
|
|
825
825
|
export function renderWithReadableStream(
|
|
826
|
-
render: ReadableStreamRenderer,
|
|
827
|
-
node: React.Node,
|
|
826
|
+
render : ReadableStreamRenderer,
|
|
827
|
+
node : React.Node,
|
|
828
828
|
options: RenderOptions,
|
|
829
829
|
): Promise<DocumentBody> {
|
|
830
830
|
const controller = new AbortController();
|
|
831
831
|
return render(node, {
|
|
832
|
-
onError: options.onError,
|
|
833
|
-
signal: controller.signal,
|
|
834
|
-
nonce: options.nonce ?? undefined,
|
|
832
|
+
onError : options.onError,
|
|
833
|
+
signal : controller.signal,
|
|
834
|
+
nonce : options.nonce ?? undefined,
|
|
835
835
|
formState: options.formState ?? null,
|
|
836
836
|
}).then((stream: ByteSource) =>
|
|
837
837
|
bodyOf(
|
|
@@ -960,9 +960,9 @@ export type PrerenderedShell = {|
|
|
|
960
960
|
export async function prerenderShell(
|
|
961
961
|
node: React.Node,
|
|
962
962
|
options: {|
|
|
963
|
-
readonly shell: DocumentShell,
|
|
963
|
+
readonly shell : DocumentShell,
|
|
964
964
|
readonly onError: (error: mixed) => void,
|
|
965
|
-
readonly settle: () => Promise<void>,
|
|
965
|
+
readonly settle : () => Promise<void>,
|
|
966
966
|
|},
|
|
967
967
|
): Promise<PrerenderedShell> {
|
|
968
968
|
const controller = new AbortController();
|
|
@@ -994,15 +994,15 @@ export async function prerenderShell(
|
|
|
994
994
|
// a document React wrote ends in its own, which `resume` writes again.
|
|
995
995
|
if (text.endsWith(options.shell.close)) {
|
|
996
996
|
return {
|
|
997
|
-
html: text.slice(0, text.length - options.shell.close.length),
|
|
998
|
-
close: options.shell.close,
|
|
997
|
+
html : text.slice(0, text.length - options.shell.close.length),
|
|
998
|
+
close : options.shell.close,
|
|
999
999
|
rootDepth: layout.rootDepth,
|
|
1000
1000
|
postponed,
|
|
1001
1001
|
};
|
|
1002
1002
|
}
|
|
1003
1003
|
return {
|
|
1004
|
-
html: text.replace(/<\/body>\s*<\/html>\s*$/i, ""),
|
|
1005
|
-
close: "",
|
|
1004
|
+
html : text.replace(/<\/body>\s*<\/html>\s*$/i, ""),
|
|
1005
|
+
close : "",
|
|
1006
1006
|
rootDepth: layout.rootDepth,
|
|
1007
1007
|
postponed,
|
|
1008
1008
|
};
|
|
@@ -1024,12 +1024,12 @@ export async function prerenderShell(
|
|
|
1024
1024
|
* own level, so the payload may follow it as soon as it exists.
|
|
1025
1025
|
*/
|
|
1026
1026
|
export function resumeDocument(
|
|
1027
|
-
node: React.Node,
|
|
1027
|
+
node : React.Node,
|
|
1028
1028
|
shell: PrerenderedShell,
|
|
1029
1029
|
options: {|
|
|
1030
|
-
readonly onError: (error: mixed) => void,
|
|
1031
|
-
readonly payload: ReadableStream<Uint8Array>,
|
|
1032
|
-
readonly nonce
|
|
1030
|
+
readonly onError : (error: mixed) => void,
|
|
1031
|
+
readonly payload : ReadableStream<Uint8Array>,
|
|
1032
|
+
readonly nonce? : string | null,
|
|
1033
1033
|
readonly onStream?: (record: StreamRecord) => void,
|
|
1034
1034
|
|},
|
|
1035
1035
|
): DocumentBody {
|
|
@@ -1039,8 +1039,8 @@ export function resumeDocument(
|
|
|
1039
1039
|
// for the shell to be read before it starts on the holes.
|
|
1040
1040
|
const resuming: Promise<ByteSource> = ReactDOMServer.resume(node, shell.postponed, {
|
|
1041
1041
|
onError: options.onError,
|
|
1042
|
-
signal: controller.signal,
|
|
1043
|
-
nonce: options.nonce ?? undefined,
|
|
1042
|
+
signal : controller.signal,
|
|
1043
|
+
nonce : options.nonce ?? undefined,
|
|
1044
1044
|
});
|
|
1045
1045
|
// A resume that fails before its first byte fails the stream below, once it
|
|
1046
1046
|
// is read; this keeps the rejection from being reported as unhandled while
|
|
@@ -1079,11 +1079,11 @@ type Layout = {|
|
|
|
1079
1079
|
|
|
1080
1080
|
/** [`assembled`] alone when there is no payload, and [`interleaved`] with one. */
|
|
1081
1081
|
function withPayload(
|
|
1082
|
-
chunks: AsyncGenerator<string, void, void>,
|
|
1083
|
-
shell: DocumentShell,
|
|
1082
|
+
chunks : AsyncGenerator<string, void, void>,
|
|
1083
|
+
shell : DocumentShell,
|
|
1084
1084
|
transformHead: ?(html: string) => Promise<string>,
|
|
1085
|
-
payload: ?ReadableStream<Uint8Array>,
|
|
1086
|
-
nonce
|
|
1085
|
+
payload : ?ReadableStream<Uint8Array>,
|
|
1086
|
+
nonce? : string | null,
|
|
1087
1087
|
): AsyncGenerator<string, void, void> {
|
|
1088
1088
|
if (payload == null) {
|
|
1089
1089
|
return assembled(chunks, shell, transformHead ?? undefined);
|
|
@@ -1158,9 +1158,9 @@ function withPayload(
|
|
|
1158
1158
|
* in the `finally`, which is where `return()` on this generator lands.
|
|
1159
1159
|
*/
|
|
1160
1160
|
async function* interleaved(
|
|
1161
|
-
chunks: AsyncGenerator<string, void, void>,
|
|
1161
|
+
chunks : AsyncGenerator<string, void, void>,
|
|
1162
1162
|
payload: ReadableStream<Uint8Array>,
|
|
1163
|
-
nonce
|
|
1163
|
+
nonce? : string | null,
|
|
1164
1164
|
layout?: Layout,
|
|
1165
1165
|
): AsyncGenerator<string, void, void> {
|
|
1166
1166
|
const encoder = createChunkEncoder(nonce);
|
|
@@ -1269,11 +1269,11 @@ type Boundary = {|
|
|
|
1269
1269
|
|};
|
|
1270
1270
|
|
|
1271
1271
|
const NOTHING_WRITTEN: Boundary = {
|
|
1272
|
-
safe: false,
|
|
1273
|
-
rawText: null,
|
|
1272
|
+
safe : false,
|
|
1273
|
+
rawText : null,
|
|
1274
1274
|
replaceable: 0,
|
|
1275
|
-
open: "",
|
|
1276
|
-
depth: null,
|
|
1275
|
+
open : "",
|
|
1276
|
+
depth : null,
|
|
1277
1277
|
};
|
|
1278
1278
|
|
|
1279
1279
|
/** Elements with no closing tag, for markup whose `/>` React did not write. */
|
package/middleware.js
CHANGED
|
@@ -332,8 +332,8 @@ function interceptionBase(header: string | null, base: URL): URL | null {
|
|
|
332
332
|
* only learns that the page underneath is not this request's to render.
|
|
333
333
|
*/
|
|
334
334
|
async function guardsAdmit(
|
|
335
|
-
table: $ReadOnlyArray<MiddlewareRecord>,
|
|
336
|
-
request: Request,
|
|
335
|
+
table : $ReadOnlyArray<MiddlewareRecord>,
|
|
336
|
+
request : Request,
|
|
337
337
|
underneath: URL,
|
|
338
338
|
): Promise<boolean> {
|
|
339
339
|
const asked = new Request(underneath.href, { method: "GET", headers: request.headers });
|
|
@@ -403,18 +403,18 @@ function withPathname(url: URL, pathname: string): URL {
|
|
|
403
403
|
function requestAt(request: Request, url: URL): Request {
|
|
404
404
|
const body = request.body;
|
|
405
405
|
return new Request(url.href, {
|
|
406
|
-
method: request.method,
|
|
406
|
+
method : request.method,
|
|
407
407
|
headers: request.headers,
|
|
408
408
|
body,
|
|
409
409
|
...(body == null ? {} : { duplex: "half" }),
|
|
410
|
-
signal: request.signal,
|
|
411
|
-
cache: request.cache,
|
|
412
|
-
credentials: request.credentials,
|
|
413
|
-
integrity: request.integrity,
|
|
414
|
-
keepalive: request.keepalive,
|
|
415
|
-
mode: request.mode,
|
|
416
|
-
redirect: request.redirect,
|
|
417
|
-
referrer: request.referrer,
|
|
410
|
+
signal : request.signal,
|
|
411
|
+
cache : request.cache,
|
|
412
|
+
credentials : request.credentials,
|
|
413
|
+
integrity : request.integrity,
|
|
414
|
+
keepalive : request.keepalive,
|
|
415
|
+
mode : request.mode,
|
|
416
|
+
redirect : request.redirect,
|
|
417
|
+
referrer : request.referrer,
|
|
418
418
|
referrerPolicy: request.referrerPolicy,
|
|
419
419
|
});
|
|
420
420
|
}
|
package/native-navigation.js
CHANGED
|
@@ -22,21 +22,21 @@ import { nativeTree, stateForPath, hrefFromState, paramsForPath } from "./intern
|
|
|
22
22
|
|
|
23
23
|
export interface NavigatorPair {
|
|
24
24
|
readonly Navigator: React.ComponentType<{ ... }>;
|
|
25
|
-
readonly Screen: React.ComponentType<{ ... }>;
|
|
25
|
+
readonly Screen : React.ComponentType<{ ... }>;
|
|
26
26
|
}
|
|
27
27
|
export type FileRouter = {
|
|
28
|
-
readonly push: (href: string) => void,
|
|
29
|
-
readonly replace: (href: string) => void,
|
|
30
|
-
readonly back: () => void,
|
|
28
|
+
readonly push : (href: string) => void,
|
|
29
|
+
readonly replace : (href: string) => void,
|
|
30
|
+
readonly back : () => void,
|
|
31
31
|
readonly prefetch: (href: string) => Promise<void>,
|
|
32
32
|
};
|
|
33
33
|
type Scope = {
|
|
34
|
-
tree: NativeTree,
|
|
35
|
-
node: NativeNode,
|
|
34
|
+
tree : NativeTree,
|
|
35
|
+
node : NativeNode,
|
|
36
36
|
screens: Map<NativeNode, React.ComponentType<{ ... }>>,
|
|
37
|
-
stack: NavigatorPair,
|
|
38
|
-
tabs: ?NavigatorPair,
|
|
39
|
-
router: FileRouter,
|
|
37
|
+
stack : NavigatorPair,
|
|
38
|
+
tabs : ?NavigatorPair,
|
|
39
|
+
router : FileRouter,
|
|
40
40
|
};
|
|
41
41
|
const ScopeContext: React.Context<Scope | null> = React.createContext(null);
|
|
42
42
|
|
|
@@ -51,12 +51,12 @@ function useScope(): Scope {
|
|
|
51
51
|
|
|
52
52
|
/** The application supplies its own React Navigation navigator factories. */
|
|
53
53
|
export function createNativeNavigation(options: {
|
|
54
|
-
table: RouteTable<>,
|
|
55
|
-
layouts: $ReadOnlyArray<NativeLayout>,
|
|
56
|
-
stack: NavigatorPair,
|
|
57
|
-
tabs
|
|
54
|
+
table : RouteTable<>,
|
|
55
|
+
layouts : $ReadOnlyArray<NativeLayout>,
|
|
56
|
+
stack : NavigatorPair,
|
|
57
|
+
tabs? : NavigatorPair,
|
|
58
58
|
initialHref?: string,
|
|
59
|
-
links
|
|
59
|
+
links? : NativeLinkSource,
|
|
60
60
|
}): { Root: React.ComponentType<{ ... }>, router: FileRouter, linking: { ... } } {
|
|
61
61
|
const { table, layouts, stack, tabs } = options;
|
|
62
62
|
const tree = nativeTree(table, layouts);
|
|
@@ -69,9 +69,9 @@ export function createNativeNavigation(options: {
|
|
|
69
69
|
return { names, payload: { ufHref: event.href, ufParams: event.params } };
|
|
70
70
|
};
|
|
71
71
|
function actionFor(
|
|
72
|
-
names: $ReadOnlyArray<string>,
|
|
72
|
+
names : $ReadOnlyArray<string>,
|
|
73
73
|
payload: NavigationPayload,
|
|
74
|
-
kind: "push" | "replace",
|
|
74
|
+
kind : "push" | "replace",
|
|
75
75
|
): { readonly [string]: mixed } {
|
|
76
76
|
if (!ref.isReady()) throw new Error("Native navigation: NavigationContainer is not ready");
|
|
77
77
|
let state: NavigationState = ref.getRootState();
|
|
@@ -95,7 +95,7 @@ export function createNativeNavigation(options: {
|
|
|
95
95
|
ref.dispatch(actionFor(names, payload, kind));
|
|
96
96
|
}
|
|
97
97
|
const router: FileRouter = {
|
|
98
|
-
push: (href) => navigate(href, "push"),
|
|
98
|
+
push : (href) => navigate(href, "push"),
|
|
99
99
|
replace: (href) => navigate(href, "replace"),
|
|
100
100
|
back: () => {
|
|
101
101
|
if (ref.canGoBack()) ref.goBack();
|
|
@@ -104,9 +104,9 @@ export function createNativeNavigation(options: {
|
|
|
104
104
|
};
|
|
105
105
|
const source = options.links == null ? null : createNativeLinking(table, options.links);
|
|
106
106
|
const linking = {
|
|
107
|
-
prefixes: [""],
|
|
107
|
+
prefixes : [""],
|
|
108
108
|
getInitialURL: source?.getInitialURL ?? (async () => null),
|
|
109
|
-
subscribe: source?.subscribe ?? (() => () => {}),
|
|
109
|
+
subscribe : source?.subscribe ?? (() => () => {}),
|
|
110
110
|
getStateFromPath: (href: string) => {
|
|
111
111
|
const { names, payload } = resolve(
|
|
112
112
|
href.startsWith("/") || /^[A-Za-z][A-Za-z0-9+.-]*:/.test(href) ? href : `/${href}`,
|
|
@@ -199,9 +199,9 @@ export function useParams(): { readonly [string]: string | $ReadOnlyArray<string
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
export component Link(
|
|
202
|
-
href: string,
|
|
202
|
+
href : string,
|
|
203
203
|
children: React.Node,
|
|
204
|
-
replace: boolean = false,
|
|
204
|
+
replace : boolean = false,
|
|
205
205
|
...props: { ... }
|
|
206
206
|
) {
|
|
207
207
|
const router = useNativeRouter();
|