react-router 0.0.0-experimental-4b4fa8f64 → 0.0.0-experimental-3a78179d9
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/dist/development/{chunk-G3AQ4NNI.mjs → chunk-43OR65FG.mjs} +116 -2
- package/dist/{production/chunk-YO5D6Y62.mjs → development/chunk-JQSU6UVP.mjs} +64 -59
- package/dist/{production/chunk-74NB5IDV.js → development/chunk-KYWUDRNV.js} +270 -156
- package/dist/development/{chunk-Q7HNP3VW.js → chunk-LSC6IOJZ.js} +1 -1
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.js +1 -1
- package/dist/development/index-react-server.mjs +1 -1
- package/dist/development/index.js +158 -153
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/{development/chunk-SJAJQKS7.mjs → production/chunk-2P4VZNA4.mjs} +64 -59
- package/dist/production/{chunk-RPAK5ITH.js → chunk-5VXD2SKX.js} +1 -1
- package/dist/{development/chunk-VOUG624U.js → production/chunk-OGMUJOJB.js} +270 -156
- package/dist/production/{chunk-NTPV7XCD.mjs → chunk-VJWBY2OY.mjs} +116 -2
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.js +1 -1
- package/dist/production/index-react-server.mjs +1 -1
- package/dist/production/index.js +158 -153
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-3a78179d9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -5653,6 +5653,119 @@ var Deferred = class {
|
|
|
5653
5653
|
});
|
|
5654
5654
|
}
|
|
5655
5655
|
};
|
|
5656
|
+
function shallowDiff(a, b) {
|
|
5657
|
+
if (a === b) {
|
|
5658
|
+
return false;
|
|
5659
|
+
}
|
|
5660
|
+
let aKeys = Object.keys(a);
|
|
5661
|
+
let bKeys = Object.keys(b);
|
|
5662
|
+
if (aKeys.length !== bKeys.length) {
|
|
5663
|
+
return true;
|
|
5664
|
+
}
|
|
5665
|
+
for (let key of aKeys) {
|
|
5666
|
+
if (a[key] !== b[key]) {
|
|
5667
|
+
return true;
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5670
|
+
return false;
|
|
5671
|
+
}
|
|
5672
|
+
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
5673
|
+
router,
|
|
5674
|
+
flushSync: reactDomFlushSyncImpl,
|
|
5675
|
+
unstable_onError
|
|
5676
|
+
}) {
|
|
5677
|
+
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
5678
|
+
let [revalidating, startRevalidation] = React3.useTransition();
|
|
5679
|
+
let [state, setState] = React3.useState(router.state);
|
|
5680
|
+
router.__setPendingRerender = (promise) => startRevalidation(
|
|
5681
|
+
// @ts-expect-error - need react 19 types for this to be async
|
|
5682
|
+
async () => {
|
|
5683
|
+
const rerender = await promise;
|
|
5684
|
+
startRevalidation(() => {
|
|
5685
|
+
rerender();
|
|
5686
|
+
});
|
|
5687
|
+
}
|
|
5688
|
+
);
|
|
5689
|
+
let navigator = React3.useMemo(() => {
|
|
5690
|
+
return {
|
|
5691
|
+
createHref: router.createHref,
|
|
5692
|
+
encodeLocation: router.encodeLocation,
|
|
5693
|
+
go: (n) => router.navigate(n),
|
|
5694
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
5695
|
+
state: state2,
|
|
5696
|
+
preventScrollReset: opts?.preventScrollReset
|
|
5697
|
+
}),
|
|
5698
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
5699
|
+
replace: true,
|
|
5700
|
+
state: state2,
|
|
5701
|
+
preventScrollReset: opts?.preventScrollReset
|
|
5702
|
+
})
|
|
5703
|
+
};
|
|
5704
|
+
}, [router]);
|
|
5705
|
+
let basename = router.basename || "/";
|
|
5706
|
+
let dataRouterContext = React3.useMemo(
|
|
5707
|
+
() => ({
|
|
5708
|
+
router,
|
|
5709
|
+
navigator,
|
|
5710
|
+
static: false,
|
|
5711
|
+
basename,
|
|
5712
|
+
unstable_onError
|
|
5713
|
+
}),
|
|
5714
|
+
[router, navigator, basename, unstable_onError]
|
|
5715
|
+
);
|
|
5716
|
+
React3.useLayoutEffect(() => {
|
|
5717
|
+
return router.subscribe(
|
|
5718
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
5719
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
5720
|
+
if (fetcher.data !== void 0) {
|
|
5721
|
+
fetcherData.current.set(key, fetcher.data);
|
|
5722
|
+
}
|
|
5723
|
+
});
|
|
5724
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
5725
|
+
const diff = shallowDiff(state, newState);
|
|
5726
|
+
if (!diff) return;
|
|
5727
|
+
if (flushSync) {
|
|
5728
|
+
if (reactDomFlushSyncImpl) {
|
|
5729
|
+
reactDomFlushSyncImpl(() => setState(newState));
|
|
5730
|
+
} else {
|
|
5731
|
+
setState(newState);
|
|
5732
|
+
}
|
|
5733
|
+
} else {
|
|
5734
|
+
React3.startTransition(() => {
|
|
5735
|
+
setState(newState);
|
|
5736
|
+
});
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
);
|
|
5740
|
+
}, [router, reactDomFlushSyncImpl, state]);
|
|
5741
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(
|
|
5742
|
+
DataRouterStateContext.Provider,
|
|
5743
|
+
{
|
|
5744
|
+
value: {
|
|
5745
|
+
...state,
|
|
5746
|
+
revalidation: revalidating ? "loading" : state.revalidation
|
|
5747
|
+
}
|
|
5748
|
+
},
|
|
5749
|
+
/* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(
|
|
5750
|
+
Router,
|
|
5751
|
+
{
|
|
5752
|
+
basename,
|
|
5753
|
+
location: state.location,
|
|
5754
|
+
navigationType: state.historyAction,
|
|
5755
|
+
navigator
|
|
5756
|
+
},
|
|
5757
|
+
/* @__PURE__ */ React3.createElement(
|
|
5758
|
+
MemoizedDataRoutes,
|
|
5759
|
+
{
|
|
5760
|
+
routes: router.routes,
|
|
5761
|
+
future: router.future,
|
|
5762
|
+
state,
|
|
5763
|
+
unstable_onError
|
|
5764
|
+
}
|
|
5765
|
+
)
|
|
5766
|
+
))
|
|
5767
|
+
)), null);
|
|
5768
|
+
}
|
|
5656
5769
|
function RouterProvider({
|
|
5657
5770
|
router,
|
|
5658
5771
|
flushSync: reactDomFlushSyncImpl,
|
|
@@ -8997,7 +9110,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
8997
9110
|
try {
|
|
8998
9111
|
if (isBrowser) {
|
|
8999
9112
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9000
|
-
"0.0.0-experimental-
|
|
9113
|
+
"0.0.0-experimental-3a78179d9";
|
|
9001
9114
|
}
|
|
9002
9115
|
} catch (e) {
|
|
9003
9116
|
}
|
|
@@ -10159,6 +10272,7 @@ export {
|
|
|
10159
10272
|
mapRouteProperties,
|
|
10160
10273
|
hydrationRouteProperties,
|
|
10161
10274
|
createMemoryRouter,
|
|
10275
|
+
UNSTABLE_TransitionEnabledRouterProvider,
|
|
10162
10276
|
RouterProvider,
|
|
10163
10277
|
MemoryRouter,
|
|
10164
10278
|
Navigate,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-3a78179d9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
SingleFetchRedirectSymbol,
|
|
23
23
|
StaticRouterProvider,
|
|
24
24
|
StreamTransfer,
|
|
25
|
+
UNSTABLE_TransitionEnabledRouterProvider,
|
|
25
26
|
convertRoutesToDataRoutes,
|
|
26
27
|
createBrowserHistory,
|
|
27
28
|
createContext,
|
|
@@ -59,7 +60,7 @@ import {
|
|
|
59
60
|
withComponentProps,
|
|
60
61
|
withErrorBoundaryProps,
|
|
61
62
|
withHydrateFallbackProps
|
|
62
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-43OR65FG.mjs";
|
|
63
64
|
|
|
64
65
|
// lib/dom/ssr/server.tsx
|
|
65
66
|
import * as React from "react";
|
|
@@ -1856,7 +1857,7 @@ function createCallServer({
|
|
|
1856
1857
|
return async (id, args) => {
|
|
1857
1858
|
let actionId = globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
|
|
1858
1859
|
const temporaryReferences = createTemporaryReferenceSet();
|
|
1859
|
-
const
|
|
1860
|
+
const payloadPromise = fetchImplementation(
|
|
1860
1861
|
new Request(location.href, {
|
|
1861
1862
|
body: await encodeReply(args, { temporaryReferences }),
|
|
1862
1863
|
method: "POST",
|
|
@@ -1865,44 +1866,45 @@ function createCallServer({
|
|
|
1865
1866
|
"rsc-action-id": id
|
|
1866
1867
|
}
|
|
1867
1868
|
})
|
|
1868
|
-
)
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1872
|
-
const payload = await createFromReadableStream(response.body, {
|
|
1873
|
-
temporaryReferences
|
|
1874
|
-
});
|
|
1875
|
-
if (payload.type === "redirect") {
|
|
1876
|
-
if (payload.reload) {
|
|
1877
|
-
window.location.href = payload.location;
|
|
1878
|
-
return;
|
|
1869
|
+
).then((response) => {
|
|
1870
|
+
if (!response.body) {
|
|
1871
|
+
throw new Error("No response body");
|
|
1879
1872
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1873
|
+
return createFromReadableStream(response.body, {
|
|
1874
|
+
temporaryReferences
|
|
1882
1875
|
});
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1876
|
+
});
|
|
1877
|
+
globalVar.__reactRouterDataRouter.__setPendingRerender(
|
|
1878
|
+
Promise.resolve(payloadPromise).then(async (payload) => {
|
|
1879
|
+
if (payload.type === "redirect") {
|
|
1880
|
+
if (payload.reload) {
|
|
1881
|
+
window.location.href = payload.location;
|
|
1882
|
+
return () => {
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
return () => {
|
|
1886
|
+
globalVar.__reactRouterDataRouter.navigate(payload.location, {
|
|
1887
|
+
replace: payload.replace
|
|
1888
|
+
});
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
if (payload.type !== "action") {
|
|
1892
|
+
throw new Error("Unexpected payload type");
|
|
1893
|
+
}
|
|
1894
|
+
const rerender = await payload.rerender;
|
|
1895
|
+
if (rerender && landedActionId < actionId && globalVar.__routerActionID <= actionId) {
|
|
1896
|
+
if (rerender.type === "redirect") {
|
|
1897
|
+
if (rerender.reload) {
|
|
1898
|
+
window.location.href = rerender.location;
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
return () => {
|
|
1901
1902
|
globalVar.__reactRouterDataRouter.navigate(rerender.location, {
|
|
1902
1903
|
replace: rerender.replace
|
|
1903
1904
|
});
|
|
1904
|
-
|
|
1905
|
-
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
return () => {
|
|
1906
1908
|
let lastMatch;
|
|
1907
1909
|
for (const match of rerender.matches) {
|
|
1908
1910
|
globalVar.__reactRouterDataRouter.patchRoutes(
|
|
@@ -1913,29 +1915,32 @@ function createCallServer({
|
|
|
1913
1915
|
lastMatch = match;
|
|
1914
1916
|
}
|
|
1915
1917
|
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
1916
|
-
{
|
|
1918
|
+
{
|
|
1919
|
+
loaderData: Object.assign(
|
|
1920
|
+
{},
|
|
1921
|
+
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
1922
|
+
rerender.loaderData
|
|
1923
|
+
),
|
|
1924
|
+
errors: rerender.errors ? Object.assign(
|
|
1925
|
+
{},
|
|
1926
|
+
globalVar.__reactRouterDataRouter.state.errors,
|
|
1927
|
+
rerender.errors
|
|
1928
|
+
) : null
|
|
1929
|
+
}
|
|
1917
1930
|
);
|
|
1918
|
-
|
|
1919
|
-
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
1920
|
-
{
|
|
1921
|
-
loaderData: Object.assign(
|
|
1922
|
-
{},
|
|
1923
|
-
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
1924
|
-
rerender.loaderData
|
|
1925
|
-
),
|
|
1926
|
-
errors: rerender.errors ? Object.assign(
|
|
1927
|
-
{},
|
|
1928
|
-
globalVar.__reactRouterDataRouter.state.errors,
|
|
1929
|
-
rerender.errors
|
|
1930
|
-
) : null
|
|
1931
|
-
}
|
|
1932
|
-
);
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1931
|
+
};
|
|
1935
1932
|
}
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1933
|
+
return () => {
|
|
1934
|
+
};
|
|
1935
|
+
}).catch(() => {
|
|
1936
|
+
})
|
|
1937
|
+
);
|
|
1938
|
+
return payloadPromise.then((payload) => {
|
|
1939
|
+
if (payload.type !== "action" && payload.type !== "redirect") {
|
|
1940
|
+
throw new Error("Unexpected payload type");
|
|
1941
|
+
}
|
|
1942
|
+
return payload.actionResult;
|
|
1943
|
+
});
|
|
1939
1944
|
};
|
|
1940
1945
|
}
|
|
1941
1946
|
function createRouterFromPayload({
|
|
@@ -2302,7 +2307,7 @@ function RSCHydratedRouter({
|
|
|
2302
2307
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2303
2308
|
routeModules
|
|
2304
2309
|
};
|
|
2305
|
-
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(
|
|
2310
|
+
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(UNSTABLE_TransitionEnabledRouterProvider, { router, flushSync: ReactDOM.flushSync }))));
|
|
2306
2311
|
}
|
|
2307
2312
|
function createRouteFromServerManifest(match, payload) {
|
|
2308
2313
|
let hasInitialData = payload && match.id in payload.loaderData;
|
|
@@ -2654,7 +2659,7 @@ async function routeRSCServerRequest({
|
|
|
2654
2659
|
}
|
|
2655
2660
|
const html = await renderHTML(getPayload);
|
|
2656
2661
|
const headers = new Headers(serverResponse.headers);
|
|
2657
|
-
headers.set("Content-Type", "text/html
|
|
2662
|
+
headers.set("Content-Type", "text/html");
|
|
2658
2663
|
if (!hydrate) {
|
|
2659
2664
|
return new Response(html, {
|
|
2660
2665
|
status: serverResponse.status,
|