File size: 5,873 Bytes
4083225 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
* react-router v7.14.2
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkX5SKXJ4Ajs = require('./chunk-X5SKXJ4A.js');
// lib/dom/ssr/hydration.tsx
function getHydrationData({
state,
routes,
getRouteInfo,
location,
basename,
isSpaMode
}) {
let hydrationData = {
...state,
loaderData: { ...state.loaderData }
};
let initialMatches = _chunkX5SKXJ4Ajs.matchRoutes.call(void 0, routes, location, basename);
if (initialMatches) {
for (let match of initialMatches) {
let routeId = match.route.id;
let routeInfo = getRouteInfo(routeId);
if (_chunkX5SKXJ4Ajs.shouldHydrateRouteLoader.call(void 0,
routeId,
routeInfo.clientLoader,
routeInfo.hasLoader,
isSpaMode
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
delete hydrationData.loaderData[routeId];
} else if (!routeInfo.hasLoader) {
hydrationData.loaderData[routeId] = null;
}
}
}
return hydrationData;
}
// lib/rsc/errorBoundaries.tsx
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var RSCRouterGlobalErrorBoundary = class extends _react2.default.Component {
constructor(props) {
super(props);
this.state = { error: null, location: props.location };
}
static getDerivedStateFromError(error) {
return { error };
}
static getDerivedStateFromProps(props, state) {
if (state.location !== props.location) {
return { error: null, location: props.location };
}
return { error: state.error, location: state.location };
}
render() {
if (this.state.error) {
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
error: this.state.error,
renderAppShell: true
}
);
} else {
return this.props.children;
}
}
};
function ErrorWrapper({
renderAppShell,
title,
children
}) {
if (!renderAppShell) {
return children;
}
return /* @__PURE__ */ _react2.default.createElement("html", { lang: "en" }, /* @__PURE__ */ _react2.default.createElement("head", null, /* @__PURE__ */ _react2.default.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ _react2.default.createElement(
"meta",
{
name: "viewport",
content: "width=device-width,initial-scale=1,viewport-fit=cover"
}
), /* @__PURE__ */ _react2.default.createElement("title", null, title)), /* @__PURE__ */ _react2.default.createElement("body", null, /* @__PURE__ */ _react2.default.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children)));
}
function RSCDefaultRootErrorBoundaryImpl({
error,
renderAppShell
}) {
console.error(error);
let heyDeveloper = /* @__PURE__ */ _react2.default.createElement(
"script",
{
dangerouslySetInnerHTML: {
__html: `
console.log(
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
);
`
}
}
);
if (_chunkX5SKXJ4Ajs.isRouteErrorResponse.call(void 0, error)) {
return /* @__PURE__ */ _react2.default.createElement(
ErrorWrapper,
{
renderAppShell,
title: "Unhandled Thrown Response!"
},
/* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
_chunkX5SKXJ4Ajs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
);
}
let errorInstance;
if (error instanceof Error) {
errorInstance = error;
} else {
let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
errorInstance = new Error(errorString);
}
return /* @__PURE__ */ _react2.default.createElement(ErrorWrapper, { renderAppShell, title: "Application Error!" }, /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"), /* @__PURE__ */ _react2.default.createElement(
"pre",
{
style: {
padding: "2rem",
background: "hsla(10, 50%, 50%, 0.1)",
color: "red",
overflow: "auto"
}
},
errorInstance.stack
), heyDeveloper);
}
function RSCDefaultRootErrorBoundary({
hasRootLayout
}) {
let error = _chunkX5SKXJ4Ajs.useRouteError.call(void 0, );
if (hasRootLayout === void 0) {
throw new Error("Missing 'hasRootLayout' prop");
}
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
renderAppShell: !hasRootLayout,
error
}
);
}
// lib/rsc/route-modules.ts
function createRSCRouteModules(payload) {
const routeModules = {};
for (const match of payload.matches) {
populateRSCRouteModules(routeModules, match);
}
return routeModules;
}
function populateRSCRouteModules(routeModules, matches) {
matches = Array.isArray(matches) ? matches : [matches];
for (const match of matches) {
routeModules[match.id] = {
links: match.links,
meta: match.meta,
default: noopComponent
};
}
}
var noopComponent = () => null;
exports.getHydrationData = getHydrationData; exports.RSCRouterGlobalErrorBoundary = RSCRouterGlobalErrorBoundary; exports.RSCDefaultRootErrorBoundary = RSCDefaultRootErrorBoundary; exports.createRSCRouteModules = createRSCRouteModules; exports.populateRSCRouteModules = populateRSCRouteModules;
|