react-router 7.15.1 → 8.3.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/CHANGELOG.md +181 -2
- package/dist/development/dom-export.d.ts +6 -172
- package/dist/development/dom-export.js +12 -1007
- package/dist/development/index-react-server-client.d.ts +7 -4
- package/dist/development/index-react-server-client.js +8 -52
- package/dist/development/index-react-server.d.ts +1789 -1657
- package/dist/development/index-react-server.js +3074 -3674
- package/dist/development/index.d.ts +41 -1469
- package/dist/development/index.js +36 -2621
- package/dist/development/lib/actions.js +50 -0
- package/dist/development/lib/components.d.ts +1030 -0
- package/dist/development/lib/components.js +841 -0
- package/dist/development/lib/context.d.ts +83 -0
- package/dist/development/lib/context.js +41 -0
- package/dist/development/lib/dom/dom.d.ts +119 -0
- package/dist/development/lib/dom/dom.js +143 -0
- package/dist/development/lib/dom/lib.d.ts +2054 -0
- package/dist/development/lib/dom/lib.js +1272 -0
- package/dist/development/lib/dom/server.d.ts +138 -0
- package/dist/development/lib/dom/server.js +301 -0
- package/dist/development/lib/dom/ssr/components.d.ts +198 -0
- package/dist/development/lib/dom/ssr/components.js +589 -0
- package/dist/development/lib/dom/ssr/data.js +29 -0
- package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/development/lib/dom/ssr/fallback.js +33 -0
- package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/development/lib/dom/ssr/fog-of-war.js +185 -0
- package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/development/lib/dom/ssr/hydration.js +29 -0
- package/dist/development/lib/dom/ssr/invariant.js +16 -0
- package/dist/development/lib/dom/ssr/links.js +170 -0
- package/dist/development/lib/dom/ssr/markup.js +24 -0
- package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/development/lib/dom/ssr/routeModules.js +31 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +75 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.js +121 -0
- package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/development/lib/dom/ssr/routes.js +303 -0
- package/dist/development/lib/dom/ssr/server.d.ts +48 -0
- package/dist/development/lib/dom/ssr/server.js +69 -0
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/development/lib/dom-export/hydrated-router.js +150 -0
- package/dist/development/lib/errors.js +29 -0
- package/dist/development/lib/hooks.d.ts +974 -0
- package/dist/development/lib/hooks.js +1415 -0
- package/dist/development/lib/href.d.ts +36 -0
- package/dist/development/lib/href.js +70 -0
- package/dist/development/lib/router/history.d.ts +264 -0
- package/dist/development/lib/router/history.js +378 -0
- package/dist/development/lib/router/instrumentation.d.ts +111 -0
- package/dist/development/lib/router/instrumentation.js +290 -0
- package/dist/development/lib/router/links.d.ts +114 -0
- package/dist/development/lib/router/router.d.ts +663 -0
- package/dist/development/lib/router/router.js +2988 -0
- package/dist/development/lib/router/url.js +18 -0
- package/dist/development/lib/router/utils.d.ts +960 -0
- package/dist/development/lib/router/utils.js +881 -0
- package/dist/development/lib/rsc/browser.d.ts +137 -0
- package/dist/development/lib/rsc/browser.js +612 -0
- package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/development/lib/rsc/errorBoundaries.js +90 -0
- package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/development/lib/rsc/html-stream/browser.js +74 -0
- package/dist/development/lib/rsc/html-stream/server.js +97 -0
- package/dist/development/lib/rsc/route-modules.js +27 -0
- package/dist/development/lib/rsc/server.rsc.d.ts +224 -0
- package/dist/development/lib/rsc/server.ssr.d.ts +152 -0
- package/dist/development/lib/rsc/server.ssr.js +419 -0
- package/dist/development/lib/server-runtime/build.d.ts +66 -0
- package/dist/development/lib/server-runtime/cookies.d.ts +92 -0
- package/dist/development/lib/server-runtime/cookies.js +153 -0
- package/dist/development/lib/server-runtime/crypto.js +43 -0
- package/dist/development/lib/server-runtime/data.js +25 -0
- package/dist/development/lib/server-runtime/dev.d.ts +9 -0
- package/dist/development/lib/server-runtime/dev.js +26 -0
- package/dist/development/lib/server-runtime/entry.js +20 -0
- package/dist/development/lib/server-runtime/errors.js +75 -0
- package/dist/development/lib/server-runtime/headers.js +73 -0
- package/dist/development/lib/server-runtime/invariant.js +19 -0
- package/dist/development/lib/server-runtime/mode.d.ts +12 -0
- package/dist/development/lib/server-runtime/mode.js +25 -0
- package/dist/development/lib/server-runtime/routeMatching.js +28 -0
- package/dist/development/lib/server-runtime/routes.d.ts +13 -0
- package/dist/development/lib/server-runtime/routes.js +74 -0
- package/dist/development/lib/server-runtime/server.d.ts +22 -0
- package/dist/development/lib/server-runtime/server.js +364 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +53 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +58 -0
- package/dist/development/lib/server-runtime/sessions.d.ts +174 -0
- package/dist/development/lib/server-runtime/sessions.js +115 -0
- package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/development/lib/server-runtime/single-fetch.js +215 -0
- package/dist/development/lib/server-runtime/urls.js +28 -0
- package/dist/development/lib/server-runtime/warnings.js +20 -0
- package/dist/development/lib/types/future.d.ts +9 -0
- package/dist/development/lib/types/internal.d.ts +26 -177
- package/dist/development/lib/types/internal.js +3 -2
- package/dist/{production/register-Bsscfj79.d.ts → development/lib/types/register.d.ts} +9 -15
- package/dist/development/lib/types/route-data.d.ts +113 -0
- package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/development/lib/types/route-module.d.ts +19 -0
- package/dist/development/lib/types/serializes-to.d.ts +13 -0
- package/dist/development/lib/types/utils.d.ts +11 -0
- package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/development/vendor/turbo-stream-v2/utils.js +39 -0
- package/dist/production/dom-export.d.ts +6 -172
- package/dist/production/dom-export.js +12 -1007
- package/dist/production/index-react-server-client.d.ts +7 -4
- package/dist/production/index-react-server-client.js +8 -52
- package/dist/production/index-react-server.d.ts +1789 -1657
- package/dist/production/index-react-server.js +3065 -3674
- package/dist/production/index.d.ts +41 -1469
- package/dist/production/index.js +36 -2621
- package/dist/production/lib/actions.js +50 -0
- package/dist/production/lib/components.d.ts +1030 -0
- package/dist/production/lib/components.js +841 -0
- package/dist/production/lib/context.d.ts +83 -0
- package/dist/production/lib/context.js +41 -0
- package/dist/production/lib/dom/dom.d.ts +119 -0
- package/dist/production/lib/dom/dom.js +143 -0
- package/dist/production/lib/dom/lib.d.ts +2054 -0
- package/dist/production/lib/dom/lib.js +1272 -0
- package/dist/production/lib/dom/server.d.ts +138 -0
- package/dist/production/lib/dom/server.js +301 -0
- package/dist/production/lib/dom/ssr/components.d.ts +198 -0
- package/dist/production/lib/dom/ssr/components.js +589 -0
- package/dist/production/lib/dom/ssr/data.js +29 -0
- package/dist/production/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/production/lib/dom/ssr/fallback.js +23 -0
- package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/production/lib/dom/ssr/fog-of-war.js +185 -0
- package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/production/lib/dom/ssr/hydration.js +29 -0
- package/dist/production/lib/dom/ssr/invariant.js +16 -0
- package/dist/production/lib/dom/ssr/links.js +170 -0
- package/dist/production/lib/dom/ssr/markup.js +24 -0
- package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/production/lib/dom/ssr/routeModules.js +31 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +75 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.js +121 -0
- package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/production/lib/dom/ssr/routes.js +303 -0
- package/dist/production/lib/dom/ssr/server.d.ts +48 -0
- package/dist/production/lib/dom/ssr/server.js +69 -0
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/production/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/production/lib/dom-export/hydrated-router.js +150 -0
- package/dist/production/lib/errors.js +29 -0
- package/dist/production/lib/hooks.d.ts +974 -0
- package/dist/production/lib/hooks.js +1400 -0
- package/dist/production/lib/href.d.ts +36 -0
- package/dist/production/lib/href.js +70 -0
- package/dist/production/lib/router/history.d.ts +264 -0
- package/dist/production/lib/router/history.js +378 -0
- package/dist/production/lib/router/instrumentation.d.ts +111 -0
- package/dist/production/lib/router/instrumentation.js +290 -0
- package/dist/production/lib/router/links.d.ts +114 -0
- package/dist/production/lib/router/router.d.ts +663 -0
- package/dist/production/lib/router/router.js +2988 -0
- package/dist/production/lib/router/url.js +18 -0
- package/dist/production/lib/router/utils.d.ts +960 -0
- package/dist/production/lib/router/utils.js +872 -0
- package/dist/production/lib/rsc/browser.d.ts +137 -0
- package/dist/production/lib/rsc/browser.js +612 -0
- package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/production/lib/rsc/errorBoundaries.js +90 -0
- package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/production/lib/rsc/html-stream/browser.js +74 -0
- package/dist/production/lib/rsc/html-stream/server.js +97 -0
- package/dist/production/lib/rsc/route-modules.js +27 -0
- package/dist/production/lib/rsc/server.rsc.d.ts +224 -0
- package/dist/production/lib/rsc/server.ssr.d.ts +152 -0
- package/dist/production/lib/rsc/server.ssr.js +419 -0
- package/dist/production/lib/server-runtime/build.d.ts +66 -0
- package/dist/production/lib/server-runtime/cookies.d.ts +92 -0
- package/dist/production/lib/server-runtime/cookies.js +153 -0
- package/dist/production/lib/server-runtime/crypto.js +43 -0
- package/dist/production/lib/server-runtime/data.js +25 -0
- package/dist/production/lib/server-runtime/dev.d.ts +9 -0
- package/dist/production/lib/server-runtime/dev.js +26 -0
- package/dist/production/lib/server-runtime/entry.js +20 -0
- package/dist/production/lib/server-runtime/errors.js +75 -0
- package/dist/production/lib/server-runtime/headers.js +73 -0
- package/dist/production/lib/server-runtime/invariant.js +19 -0
- package/dist/production/lib/server-runtime/mode.d.ts +12 -0
- package/dist/production/lib/server-runtime/mode.js +25 -0
- package/dist/production/lib/server-runtime/routeMatching.js +28 -0
- package/dist/production/lib/server-runtime/routes.d.ts +13 -0
- package/dist/production/lib/server-runtime/routes.js +74 -0
- package/dist/production/lib/server-runtime/server.d.ts +22 -0
- package/dist/production/lib/server-runtime/server.js +364 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +53 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +58 -0
- package/dist/production/lib/server-runtime/sessions.d.ts +174 -0
- package/dist/production/lib/server-runtime/sessions.js +115 -0
- package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/production/lib/server-runtime/single-fetch.js +215 -0
- package/dist/production/lib/server-runtime/urls.js +28 -0
- package/dist/production/lib/server-runtime/warnings.js +20 -0
- package/dist/production/lib/types/future.d.ts +9 -0
- package/dist/production/lib/types/internal.d.ts +26 -177
- package/dist/production/lib/types/internal.js +3 -2
- package/dist/{development/register-Bsscfj79.d.ts → production/lib/types/register.d.ts} +9 -15
- package/dist/production/lib/types/route-data.d.ts +113 -0
- package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/production/lib/types/route-module.d.ts +19 -0
- package/dist/production/lib/types/serializes-to.d.ts +13 -0
- package/dist/production/lib/types/utils.d.ts +11 -0
- package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
- package/docs/explanation/backend-for-frontend.md +50 -0
- package/docs/explanation/code-splitting.md +77 -0
- package/docs/explanation/concurrency.md +135 -0
- package/docs/explanation/form-vs-fetcher.md +292 -0
- package/docs/explanation/hot-module-replacement.md +137 -0
- package/docs/explanation/hydration.md +14 -0
- package/docs/explanation/index-query-param.md +86 -0
- package/docs/explanation/index.md +4 -0
- package/docs/explanation/lazy-route-discovery.md +78 -0
- package/docs/explanation/location.md +6 -0
- package/docs/explanation/progressive-enhancement.md +150 -0
- package/docs/explanation/race-conditions.md +88 -0
- package/docs/explanation/react-transitions.md +160 -0
- package/docs/explanation/route-matching.md +7 -0
- package/docs/explanation/server-client-execution.md +4 -0
- package/docs/explanation/sessions-and-cookies.md +465 -0
- package/docs/explanation/special-files.md +16 -0
- package/docs/explanation/state-management.md +524 -0
- package/docs/explanation/styling.md +87 -0
- package/docs/explanation/type-safety.md +82 -0
- package/docs/how-to/accessibility.md +44 -0
- package/docs/how-to/client-data.md +199 -0
- package/docs/how-to/data-strategy.md +317 -0
- package/docs/how-to/error-boundary.md +231 -0
- package/docs/how-to/error-reporting.md +142 -0
- package/docs/how-to/fetchers.md +307 -0
- package/docs/how-to/file-route-conventions.md +410 -0
- package/docs/how-to/file-uploads.md +217 -0
- package/docs/how-to/form-validation.md +120 -0
- package/docs/how-to/headers.md +165 -0
- package/docs/how-to/index.md +4 -0
- package/docs/how-to/instrumentation.md +661 -0
- package/docs/how-to/meta.md +40 -0
- package/docs/how-to/middleware.md +647 -0
- package/docs/how-to/navigation-blocking.md +233 -0
- package/docs/how-to/optimize-revalidation.md +12 -0
- package/docs/how-to/pre-rendering.md +225 -0
- package/docs/how-to/presets.md +103 -0
- package/docs/how-to/react-server-components.md +951 -0
- package/docs/how-to/resource-routes.md +126 -0
- package/docs/how-to/route-module-type-safety.md +85 -0
- package/docs/how-to/search-params.md +4 -0
- package/docs/how-to/security.md +39 -0
- package/docs/how-to/server-bundles.md +66 -0
- package/docs/how-to/spa.md +120 -0
- package/docs/how-to/status.md +63 -0
- package/docs/how-to/suspense.md +132 -0
- package/docs/how-to/using-handle.md +117 -0
- package/docs/how-to/view-transitions.md +237 -0
- package/docs/how-to/webhook.md +50 -0
- package/docs/index.md +36 -0
- package/docs/start/data/actions.md +138 -0
- package/docs/start/data/custom.md +198 -0
- package/docs/start/data/data-loading.md +44 -0
- package/docs/start/data/index.md +4 -0
- package/docs/start/data/installation.md +56 -0
- package/docs/start/data/navigating.md +12 -0
- package/docs/start/data/pending-ui.md +12 -0
- package/docs/start/data/route-object.md +268 -0
- package/docs/start/data/routing.md +281 -0
- package/docs/start/data/testing.md +8 -0
- package/docs/start/declarative/index.md +4 -0
- package/docs/start/declarative/installation.md +43 -0
- package/docs/start/declarative/navigating.md +133 -0
- package/docs/start/declarative/routing.md +237 -0
- package/docs/start/declarative/url-values.md +65 -0
- package/docs/start/framework/actions.md +174 -0
- package/docs/start/framework/data-loading.md +201 -0
- package/docs/start/framework/deploying.md +104 -0
- package/docs/start/framework/index.md +4 -0
- package/docs/start/framework/installation.md +41 -0
- package/docs/start/framework/navigating.md +182 -0
- package/docs/start/framework/pending-ui.md +142 -0
- package/docs/start/framework/rendering.md +59 -0
- package/docs/start/framework/route-module.md +527 -0
- package/docs/start/framework/routing.md +362 -0
- package/docs/start/framework/testing.md +133 -0
- package/docs/start/index.md +4 -0
- package/docs/start/modes.md +200 -0
- package/docs/upgrading/component-routes.md +363 -0
- package/docs/upgrading/future.md +111 -0
- package/docs/upgrading/index.md +4 -0
- package/docs/upgrading/router-provider.md +445 -0
- package/docs/upgrading/v7.md +460 -0
- package/package.json +44 -87
- package/dist/development/browser-3AnU12UI.d.mts +0 -318
- package/dist/development/browser-BOdXz9dK.d.ts +0 -318
- package/dist/development/chunk-4N6VE7H7.mjs +0 -11528
- package/dist/development/chunk-4YRVXM2U.js +0 -188
- package/dist/development/chunk-66UKHEGQ.js +0 -1362
- package/dist/development/chunk-D6LUOGOQ.js +0 -10229
- package/dist/development/chunk-RJYABSBD.mjs +0 -2585
- package/dist/development/context-ByvtofY2.d.mts +0 -1771
- package/dist/development/data-BVUf681J.d.mts +0 -1732
- package/dist/development/data-BqZ2x964.d.ts +0 -1732
- package/dist/development/dom-export.d.mts +0 -172
- package/dist/development/dom-export.mjs +0 -1008
- package/dist/development/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/development/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/development/index-react-server-client.d.mts +0 -4
- package/dist/development/index-react-server-client.mjs +0 -59
- package/dist/development/index-react-server.d.mts +0 -2703
- package/dist/development/index-react-server.mjs +0 -3780
- package/dist/development/index.d.mts +0 -1472
- package/dist/development/index.mjs +0 -277
- package/dist/development/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/development/lib/types/internal.d.mts +0 -184
- package/dist/development/lib/types/internal.mjs +0 -10
- package/dist/development/register-Df8okEea.d.mts +0 -30
- package/dist/production/browser-3AnU12UI.d.mts +0 -318
- package/dist/production/browser-BOdXz9dK.d.ts +0 -318
- package/dist/production/chunk-6S4627ZB.mjs +0 -2585
- package/dist/production/chunk-HUBUW7R3.js +0 -10229
- package/dist/production/chunk-JAKZPQZC.mjs +0 -11528
- package/dist/production/chunk-PNZCCTKT.js +0 -1362
- package/dist/production/chunk-Y6IFXO7V.js +0 -188
- package/dist/production/context-ByvtofY2.d.mts +0 -1771
- package/dist/production/data-BVUf681J.d.mts +0 -1732
- package/dist/production/data-BqZ2x964.d.ts +0 -1732
- package/dist/production/dom-export.d.mts +0 -172
- package/dist/production/dom-export.mjs +0 -1008
- package/dist/production/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/production/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/production/index-react-server-client.d.mts +0 -4
- package/dist/production/index-react-server-client.mjs +0 -59
- package/dist/production/index-react-server.d.mts +0 -2703
- package/dist/production/index-react-server.mjs +0 -3780
- package/dist/production/index.d.mts +0 -1472
- package/dist/production/index.mjs +0 -277
- package/dist/production/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/production/lib/types/internal.d.mts +0 -184
- package/dist/production/lib/types/internal.mjs +0 -10
- package/dist/production/register-Df8okEea.d.mts +0 -30
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
|
|
2
|
+
import { CookieParseOptions as CookieParseOptions$1, CookieSerializeOptions as CookieSerializeOptions$1 } from "cookie-es";
|
|
3
|
+
|
|
4
|
+
//#region lib/server-runtime/cookies.d.ts
|
|
5
|
+
interface CookieSignatureOptions {
|
|
6
|
+
/**
|
|
7
|
+
* An array of secrets that may be used to sign/unsign the value of a cookie.
|
|
8
|
+
*
|
|
9
|
+
* The array makes it easy to rotate secrets. New secrets should be added to
|
|
10
|
+
* the beginning of the array. `cookie.serialize()` will always use the first
|
|
11
|
+
* value in the array, but `cookie.parse()` may use any of them so that
|
|
12
|
+
* cookies that were signed with older secrets still work.
|
|
13
|
+
*/
|
|
14
|
+
secrets?: string[];
|
|
15
|
+
}
|
|
16
|
+
type CookieOptions = CookieParseOptions$1 & CookieSerializeOptions$1 & CookieSignatureOptions;
|
|
17
|
+
/**
|
|
18
|
+
* A HTTP cookie.
|
|
19
|
+
*
|
|
20
|
+
* A Cookie is a logical container for metadata about a HTTP cookie; its name
|
|
21
|
+
* and options. But it doesn't contain a value. Instead, it has `parse()` and
|
|
22
|
+
* `serialize()` methods that allow a single instance to be reused for
|
|
23
|
+
* parsing/encoding multiple different values.
|
|
24
|
+
*
|
|
25
|
+
* @see https://remix.run/utils/cookies#cookie-api
|
|
26
|
+
*/
|
|
27
|
+
interface Cookie {
|
|
28
|
+
/**
|
|
29
|
+
* The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
|
|
30
|
+
*/
|
|
31
|
+
readonly name: string;
|
|
32
|
+
/**
|
|
33
|
+
* True if this cookie uses one or more secrets for verification.
|
|
34
|
+
*/
|
|
35
|
+
readonly isSigned: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The Date this cookie expires.
|
|
38
|
+
*
|
|
39
|
+
* Note: This is calculated at access time using `maxAge` when no `expires`
|
|
40
|
+
* option is provided to `createCookie()`.
|
|
41
|
+
*/
|
|
42
|
+
readonly expires?: Date;
|
|
43
|
+
/**
|
|
44
|
+
* Parses a raw `Cookie` header and returns the value of this cookie or
|
|
45
|
+
* `null` if it's not present.
|
|
46
|
+
*/
|
|
47
|
+
parse(cookieHeader: string | null, options?: CookieParseOptions$1): Promise<any>;
|
|
48
|
+
/**
|
|
49
|
+
* Serializes the given value to a string and returns the `Set-Cookie`
|
|
50
|
+
* header.
|
|
51
|
+
*/
|
|
52
|
+
serialize(value: any, options?: CookieSerializeOptions$1): Promise<string>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a logical container for managing a browser cookie from the server.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
* @category Utils
|
|
59
|
+
* @mode framework
|
|
60
|
+
* @mode data
|
|
61
|
+
* @param name The name of the cookie.
|
|
62
|
+
* @param cookieOptions Options for parsing and serializing the cookie.
|
|
63
|
+
* @returns A {@link Cookie} object for parsing and serializing the cookie.
|
|
64
|
+
*/
|
|
65
|
+
declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
|
66
|
+
/**
|
|
67
|
+
* A function that determines whether a value is a React Router {@link Cookie}
|
|
68
|
+
* object.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
* @category Utils
|
|
72
|
+
* @mode framework
|
|
73
|
+
* @mode data
|
|
74
|
+
* @param object The value to check.
|
|
75
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
76
|
+
* otherwise, `false`.
|
|
77
|
+
*/
|
|
78
|
+
type IsCookieFunction = (object: any) => object is Cookie;
|
|
79
|
+
/**
|
|
80
|
+
* Returns `true` if a value is a React Router {@link Cookie} object.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
* @category Utils
|
|
84
|
+
* @mode framework
|
|
85
|
+
* @mode data
|
|
86
|
+
* @param object The value to check.
|
|
87
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
88
|
+
* otherwise, `false`.
|
|
89
|
+
*/
|
|
90
|
+
declare const isCookie: IsCookieFunction;
|
|
91
|
+
//#endregion
|
|
92
|
+
export { Cookie, CookieOptions, type CookieParseOptions$1 as CookieParseOptions, type CookieSerializeOptions$1 as CookieSerializeOptions, CookieSignatureOptions, IsCookieFunction, createCookie, isCookie };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { warnOnce } from "./warnings.js";
|
|
12
|
+
import { sign, unsign } from "./crypto.js";
|
|
13
|
+
import { parse, serialize } from "cookie-es";
|
|
14
|
+
//#region lib/server-runtime/cookies.ts
|
|
15
|
+
/**
|
|
16
|
+
* Creates a logical container for managing a browser cookie from the server.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
* @category Utils
|
|
20
|
+
* @mode framework
|
|
21
|
+
* @mode data
|
|
22
|
+
* @param name The name of the cookie.
|
|
23
|
+
* @param cookieOptions Options for parsing and serializing the cookie.
|
|
24
|
+
* @returns A {@link Cookie} object for parsing and serializing the cookie.
|
|
25
|
+
*/
|
|
26
|
+
const createCookie = (name, cookieOptions = {}) => {
|
|
27
|
+
let { secrets = [], ...options } = {
|
|
28
|
+
path: "/",
|
|
29
|
+
sameSite: "lax",
|
|
30
|
+
...cookieOptions
|
|
31
|
+
};
|
|
32
|
+
warnOnceAboutExpiresCookie(name, options.expires);
|
|
33
|
+
return {
|
|
34
|
+
get name() {
|
|
35
|
+
return name;
|
|
36
|
+
},
|
|
37
|
+
get isSigned() {
|
|
38
|
+
return secrets.length > 0;
|
|
39
|
+
},
|
|
40
|
+
get expires() {
|
|
41
|
+
return typeof options.maxAge !== "undefined" ? new Date(Date.now() + options.maxAge * 1e3) : options.expires;
|
|
42
|
+
},
|
|
43
|
+
async parse(cookieHeader, parseOptions) {
|
|
44
|
+
if (!cookieHeader) return null;
|
|
45
|
+
let cookies = parse(cookieHeader, {
|
|
46
|
+
...options,
|
|
47
|
+
...parseOptions
|
|
48
|
+
});
|
|
49
|
+
if (name in cookies) {
|
|
50
|
+
let value = cookies[name];
|
|
51
|
+
if (typeof value === "string" && value !== "") return await decodeCookieValue(value, secrets);
|
|
52
|
+
else return "";
|
|
53
|
+
} else return null;
|
|
54
|
+
},
|
|
55
|
+
async serialize(value, serializeOptions) {
|
|
56
|
+
return serialize(name, value === "" ? "" : await encodeCookieValue(value, secrets), {
|
|
57
|
+
...options,
|
|
58
|
+
...serializeOptions
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Returns `true` if a value is a React Router {@link Cookie} object.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
* @category Utils
|
|
68
|
+
* @mode framework
|
|
69
|
+
* @mode data
|
|
70
|
+
* @param object The value to check.
|
|
71
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
72
|
+
* otherwise, `false`.
|
|
73
|
+
*/
|
|
74
|
+
const isCookie = (object) => {
|
|
75
|
+
return object != null && typeof object.name === "string" && typeof object.isSigned === "boolean" && typeof object.parse === "function" && typeof object.serialize === "function";
|
|
76
|
+
};
|
|
77
|
+
async function encodeCookieValue(value, secrets) {
|
|
78
|
+
let encoded = encodeData(value);
|
|
79
|
+
if (secrets.length > 0) encoded = await sign(encoded, secrets[0]);
|
|
80
|
+
return encoded;
|
|
81
|
+
}
|
|
82
|
+
async function decodeCookieValue(value, secrets) {
|
|
83
|
+
if (secrets.length > 0) {
|
|
84
|
+
for (let secret of secrets) {
|
|
85
|
+
let unsignedValue = await unsign(value, secret);
|
|
86
|
+
if (unsignedValue !== false) return decodeData(unsignedValue);
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return decodeData(value);
|
|
91
|
+
}
|
|
92
|
+
function encodeData(value) {
|
|
93
|
+
return btoa(myUnescape(encodeURIComponent(JSON.stringify(value))));
|
|
94
|
+
}
|
|
95
|
+
function decodeData(value) {
|
|
96
|
+
try {
|
|
97
|
+
return JSON.parse(decodeURIComponent(myEscape(atob(value))));
|
|
98
|
+
} catch (e) {
|
|
99
|
+
return {};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function myEscape(value) {
|
|
103
|
+
let str = value.toString();
|
|
104
|
+
let result = "";
|
|
105
|
+
let index = 0;
|
|
106
|
+
let chr, code;
|
|
107
|
+
while (index < str.length) {
|
|
108
|
+
chr = str.charAt(index++);
|
|
109
|
+
if (/[\w*+\-./@]/.exec(chr)) result += chr;
|
|
110
|
+
else {
|
|
111
|
+
code = chr.charCodeAt(0);
|
|
112
|
+
if (code < 256) result += "%" + hex(code, 2);
|
|
113
|
+
else result += "%u" + hex(code, 4).toUpperCase();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
function hex(code, length) {
|
|
119
|
+
let result = code.toString(16);
|
|
120
|
+
while (result.length < length) result = "0" + result;
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
function myUnescape(value) {
|
|
124
|
+
let str = value.toString();
|
|
125
|
+
let result = "";
|
|
126
|
+
let index = 0;
|
|
127
|
+
let chr, part;
|
|
128
|
+
while (index < str.length) {
|
|
129
|
+
chr = str.charAt(index++);
|
|
130
|
+
if (chr === "%") if (str.charAt(index) === "u") {
|
|
131
|
+
part = str.slice(index + 1, index + 5);
|
|
132
|
+
if (/^[\da-f]{4}$/i.exec(part)) {
|
|
133
|
+
result += String.fromCharCode(parseInt(part, 16));
|
|
134
|
+
index += 5;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
part = str.slice(index, index + 2);
|
|
139
|
+
if (/^[\da-f]{2}$/i.exec(part)) {
|
|
140
|
+
result += String.fromCharCode(parseInt(part, 16));
|
|
141
|
+
index += 2;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
result += chr;
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
function warnOnceAboutExpiresCookie(name, expires) {
|
|
150
|
+
warnOnce(!expires, `The "${name}" cookie has an "expires" property set. This will cause the expires value to not be updated when the session is committed. Instead, you should set the expires value when serializing the cookie. You can use \`commitSession(session, { expires })\` if using a session storage object, or \`cookie.serialize("value", { expires })\` if you're using the cookie directly.`);
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { createCookie, isCookie };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
//#region lib/server-runtime/crypto.ts
|
|
12
|
+
const encoder = /* @__PURE__ */ new TextEncoder();
|
|
13
|
+
const sign = async (value, secret) => {
|
|
14
|
+
let data = encoder.encode(value);
|
|
15
|
+
let key = await createKey(secret, ["sign"]);
|
|
16
|
+
let signature = await crypto.subtle.sign("HMAC", key, data);
|
|
17
|
+
let hash = btoa(String.fromCharCode(...new Uint8Array(signature))).replace(/=+$/, "");
|
|
18
|
+
return value + "." + hash;
|
|
19
|
+
};
|
|
20
|
+
const unsign = async (cookie, secret) => {
|
|
21
|
+
let index = cookie.lastIndexOf(".");
|
|
22
|
+
let value = cookie.slice(0, index);
|
|
23
|
+
let hash = cookie.slice(index + 1);
|
|
24
|
+
let data = encoder.encode(value);
|
|
25
|
+
let key = await createKey(secret, ["verify"]);
|
|
26
|
+
try {
|
|
27
|
+
let signature = byteStringToUint8Array(atob(hash));
|
|
28
|
+
return await crypto.subtle.verify("HMAC", key, signature, data) ? value : false;
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const createKey = async (secret, usages) => crypto.subtle.importKey("raw", encoder.encode(secret), {
|
|
34
|
+
name: "HMAC",
|
|
35
|
+
hash: "SHA-256"
|
|
36
|
+
}, false, usages);
|
|
37
|
+
function byteStringToUint8Array(byteString) {
|
|
38
|
+
let array = new Uint8Array(byteString.length);
|
|
39
|
+
for (let i = 0; i < byteString.length; i++) array[i] = byteString.charCodeAt(i);
|
|
40
|
+
return array;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { sign, unsign };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { isDataWithResponseInit, isRedirectStatusCode } from "../router/router.js";
|
|
12
|
+
//#region lib/server-runtime/data.ts
|
|
13
|
+
async function callRouteHandler(handler, args) {
|
|
14
|
+
let result = await handler({
|
|
15
|
+
request: args.request,
|
|
16
|
+
url: args.url,
|
|
17
|
+
params: args.params,
|
|
18
|
+
context: args.context,
|
|
19
|
+
pattern: args.pattern
|
|
20
|
+
});
|
|
21
|
+
if (isDataWithResponseInit(result) && result.init && result.init.status && isRedirectStatusCode(result.init.status)) throw new Response(null, result.init);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { callRouteHandler };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
//#region lib/server-runtime/dev.d.ts
|
|
3
|
+
type DevServerHooks = {
|
|
4
|
+
getCriticalCss?: (pathname: string) => Promise<string | undefined>;
|
|
5
|
+
processRequestError?: (error: unknown) => void;
|
|
6
|
+
};
|
|
7
|
+
declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { setDevServerHooks };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
//#region lib/server-runtime/dev.ts
|
|
12
|
+
const globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
13
|
+
function setDevServerHooks(devServerHooks) {
|
|
14
|
+
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
15
|
+
}
|
|
16
|
+
function getDevServerHooks() {
|
|
17
|
+
return globalThis[globalDevServerHooksKey];
|
|
18
|
+
}
|
|
19
|
+
function getBuildTimeHeader(request, headerName) {
|
|
20
|
+
if (typeof process !== "undefined") try {
|
|
21
|
+
if (process.env.hasOwnProperty("IS_RR_BUILD_REQUEST") && process.env.IS_RR_BUILD_REQUEST === "yes") return request.headers.get(headerName);
|
|
22
|
+
} catch (e) {}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { getBuildTimeHeader, getDevServerHooks, setDevServerHooks };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
//#region lib/server-runtime/entry.ts
|
|
12
|
+
function createEntryRouteModules(manifest) {
|
|
13
|
+
return Object.keys(manifest).reduce((memo, routeId) => {
|
|
14
|
+
let route = manifest[routeId];
|
|
15
|
+
if (route) memo[routeId] = route.module;
|
|
16
|
+
return memo;
|
|
17
|
+
}, {});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { createEntryRouteModules };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import "./mode.js";
|
|
12
|
+
//#region lib/server-runtime/errors.ts
|
|
13
|
+
/**
|
|
14
|
+
* This thing probably warrants some explanation.
|
|
15
|
+
*
|
|
16
|
+
* The whole point here is to emulate componentDidCatch for server rendering and
|
|
17
|
+
* data loading. It can get tricky. React can do this on component boundaries
|
|
18
|
+
* but doesn't support it for server rendering or data loading. We know enough
|
|
19
|
+
* with nested routes to be able to emulate the behavior (because we know them
|
|
20
|
+
* statically before rendering.)
|
|
21
|
+
*
|
|
22
|
+
* Each route can export an `ErrorBoundary`.
|
|
23
|
+
*
|
|
24
|
+
* - When rendering throws an error, the nearest error boundary will render
|
|
25
|
+
* (normal react componentDidCatch). This will be the route's own boundary, but
|
|
26
|
+
* if none is provided, it will bubble up to the parents.
|
|
27
|
+
* - When data loading throws an error, the nearest error boundary will render
|
|
28
|
+
* - When performing an action, the nearest error boundary for the action's
|
|
29
|
+
* route tree will render (no redirect happens)
|
|
30
|
+
*
|
|
31
|
+
* During normal react rendering, we do nothing special, just normal
|
|
32
|
+
* componentDidCatch.
|
|
33
|
+
*
|
|
34
|
+
* For server rendering, we mutate `renderBoundaryRouteId` to know the last
|
|
35
|
+
* layout that has an error boundary that tried to render. This emulates which
|
|
36
|
+
* layout would catch a thrown error. If the rendering fails, we catch the error
|
|
37
|
+
* on the server, and go again a second time with the emulator holding on to the
|
|
38
|
+
* information it needs to render the same error boundary as a dynamically
|
|
39
|
+
* thrown render error.
|
|
40
|
+
*
|
|
41
|
+
* When data loading, server or client side, we use the emulator to likewise
|
|
42
|
+
* hang on to the error and re-render at the appropriate layout (where a thrown
|
|
43
|
+
* error would have been caught by cDC).
|
|
44
|
+
*
|
|
45
|
+
* When actions throw, it all works the same. There's an edge case to be aware
|
|
46
|
+
* of though. Actions normally are required to redirect, but in the case of
|
|
47
|
+
* errors, we render the action's route with the emulator holding on to the
|
|
48
|
+
* error. If during this render a parent route/loader throws we ignore that new
|
|
49
|
+
* error and render the action's original error as deeply as possible. In other
|
|
50
|
+
* words, we simply ignore the new error and use the action's error in place
|
|
51
|
+
* because it came first, and that just wouldn't be fair to let errors cut in
|
|
52
|
+
* line.
|
|
53
|
+
*/
|
|
54
|
+
function sanitizeError(error, serverMode) {
|
|
55
|
+
if (error instanceof Error && serverMode !== "development") {
|
|
56
|
+
let sanitized = /* @__PURE__ */ new Error("Unexpected Server Error");
|
|
57
|
+
sanitized.stack = void 0;
|
|
58
|
+
return sanitized;
|
|
59
|
+
}
|
|
60
|
+
return error;
|
|
61
|
+
}
|
|
62
|
+
function sanitizeErrors(errors, serverMode) {
|
|
63
|
+
return Object.entries(errors).reduce((acc, [routeId, error]) => {
|
|
64
|
+
return Object.assign(acc, { [routeId]: sanitizeError(error, serverMode) });
|
|
65
|
+
}, {});
|
|
66
|
+
}
|
|
67
|
+
function serializeError(error, serverMode) {
|
|
68
|
+
let sanitized = sanitizeError(error, serverMode);
|
|
69
|
+
return {
|
|
70
|
+
message: sanitized.message,
|
|
71
|
+
stack: sanitized.stack
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { sanitizeError, sanitizeErrors, serializeError };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import invariant from "./invariant.js";
|
|
12
|
+
import { splitSetCookieString } from "cookie-es";
|
|
13
|
+
//#region lib/server-runtime/headers.ts
|
|
14
|
+
function getDocumentHeaders(context, build) {
|
|
15
|
+
return getDocumentHeadersImpl(context, (m) => {
|
|
16
|
+
let route = build.routes[m.route.id];
|
|
17
|
+
invariant(route, `Route with id "${m.route.id}" not found in build`);
|
|
18
|
+
return route.module.headers;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function getDocumentHeadersImpl(context, getRouteHeadersFn, _defaultHeaders) {
|
|
22
|
+
let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
|
|
23
|
+
let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
|
|
24
|
+
let errorHeaders;
|
|
25
|
+
if (boundaryIdx >= 0) {
|
|
26
|
+
let { actionHeaders, actionData, loaderHeaders, loaderData } = context;
|
|
27
|
+
context.matches.slice(boundaryIdx).some((match) => {
|
|
28
|
+
let id = match.route.id;
|
|
29
|
+
if (actionHeaders[id] && (!actionData || !actionData.hasOwnProperty(id))) errorHeaders = actionHeaders[id];
|
|
30
|
+
else if (loaderHeaders[id] && !loaderData.hasOwnProperty(id)) errorHeaders = loaderHeaders[id];
|
|
31
|
+
return errorHeaders != null;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const defaultHeaders = new Headers(_defaultHeaders);
|
|
35
|
+
return matches.reduce((parentHeaders, match, idx) => {
|
|
36
|
+
let { id } = match.route;
|
|
37
|
+
let loaderHeaders = context.loaderHeaders[id] || new Headers();
|
|
38
|
+
let actionHeaders = context.actionHeaders[id] || new Headers();
|
|
39
|
+
let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
|
|
40
|
+
let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
|
|
41
|
+
let headersFn = getRouteHeadersFn(match);
|
|
42
|
+
if (headersFn == null) {
|
|
43
|
+
let headers = new Headers(parentHeaders);
|
|
44
|
+
if (includeErrorCookies) prependCookies(errorHeaders, headers);
|
|
45
|
+
prependCookies(actionHeaders, headers);
|
|
46
|
+
prependCookies(loaderHeaders, headers);
|
|
47
|
+
return headers;
|
|
48
|
+
}
|
|
49
|
+
let headers = new Headers(typeof headersFn === "function" ? headersFn({
|
|
50
|
+
loaderHeaders,
|
|
51
|
+
parentHeaders,
|
|
52
|
+
actionHeaders,
|
|
53
|
+
errorHeaders: includeErrorHeaders ? errorHeaders : void 0
|
|
54
|
+
}) : headersFn);
|
|
55
|
+
if (includeErrorCookies) prependCookies(errorHeaders, headers);
|
|
56
|
+
prependCookies(actionHeaders, headers);
|
|
57
|
+
prependCookies(loaderHeaders, headers);
|
|
58
|
+
prependCookies(parentHeaders, headers);
|
|
59
|
+
return headers;
|
|
60
|
+
}, new Headers(defaultHeaders));
|
|
61
|
+
}
|
|
62
|
+
function prependCookies(parentHeaders, childHeaders) {
|
|
63
|
+
let parentSetCookieString = parentHeaders.get("Set-Cookie");
|
|
64
|
+
if (parentSetCookieString) {
|
|
65
|
+
let cookies = splitSetCookieString(parentSetCookieString);
|
|
66
|
+
let childCookies = new Set(childHeaders.getSetCookie());
|
|
67
|
+
cookies.forEach((cookie) => {
|
|
68
|
+
if (!childCookies.has(cookie)) childHeaders.append("Set-Cookie", cookie);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { getDocumentHeaders };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
//#region lib/server-runtime/invariant.ts
|
|
12
|
+
function invariant(value, message) {
|
|
13
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
14
|
+
console.error("The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose");
|
|
15
|
+
throw new Error(message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { invariant as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
//#region lib/server-runtime/mode.ts
|
|
12
|
+
/**
|
|
13
|
+
* The mode to use when running the server.
|
|
14
|
+
*/
|
|
15
|
+
let ServerMode = /* @__PURE__ */ function(ServerMode) {
|
|
16
|
+
ServerMode["Development"] = "development";
|
|
17
|
+
ServerMode["Production"] = "production";
|
|
18
|
+
ServerMode["Test"] = "test";
|
|
19
|
+
return ServerMode;
|
|
20
|
+
}({});
|
|
21
|
+
function isServerMode(value) {
|
|
22
|
+
return value === "development" || value === "production" || value === "test";
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ServerMode, isServerMode };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.3.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { matchRoutesImpl } from "../router/utils.js";
|
|
12
|
+
import invariant from "./invariant.js";
|
|
13
|
+
//#region lib/server-runtime/routeMatching.ts
|
|
14
|
+
function matchServerRoutes(manifest, dataRoutes, branches, pathname, basename) {
|
|
15
|
+
let matches = matchRoutesImpl(dataRoutes, pathname, basename ?? "/", false, branches);
|
|
16
|
+
if (!matches) return null;
|
|
17
|
+
return matches.map((match) => {
|
|
18
|
+
let route = manifest[match.route.id];
|
|
19
|
+
invariant(route, `Route with id "${match.route.id}" not found in manifest.`);
|
|
20
|
+
return {
|
|
21
|
+
params: match.params,
|
|
22
|
+
pathname: match.pathname,
|
|
23
|
+
route
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { matchServerRoutes };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { RouteManifest } from "../router/utils.js";
|
|
3
|
+
import { ServerRouteModule } from "../dom/ssr/routeModules.js";
|
|
4
|
+
import { Route } from "../dom/ssr/routes.js";
|
|
5
|
+
|
|
6
|
+
//#region lib/server-runtime/routes.d.ts
|
|
7
|
+
type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
|
|
8
|
+
interface ServerRoute extends Route {
|
|
9
|
+
children: ServerRoute[];
|
|
10
|
+
module: ServerRouteModule;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ServerRouteManifest };
|