@cedarjs/router 0.0.4
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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/ActivePageContext.d.ts +15 -0
- package/dist/ActivePageContext.d.ts.map +1 -0
- package/dist/ActivePageContext.js +17 -0
- package/dist/AuthenticatedRoute.d.ts +11 -0
- package/dist/AuthenticatedRoute.d.ts.map +1 -0
- package/dist/AuthenticatedRoute.js +49 -0
- package/dist/PageLoadingContext.d.ts +14 -0
- package/dist/PageLoadingContext.d.ts.map +1 -0
- package/dist/PageLoadingContext.js +29 -0
- package/dist/Route.d.ts +32 -0
- package/dist/Route.d.ts.map +1 -0
- package/dist/Route.js +7 -0
- package/dist/Set.d.ts +58 -0
- package/dist/Set.d.ts.map +1 -0
- package/dist/Set.js +28 -0
- package/dist/a11yUtils.d.ts +14 -0
- package/dist/a11yUtils.d.ts.map +1 -0
- package/dist/a11yUtils.js +35 -0
- package/dist/active-route-loader.d.ts +12 -0
- package/dist/active-route-loader.d.ts.map +1 -0
- package/dist/active-route-loader.js +82 -0
- package/dist/analyzeRoutes.d.ts +44 -0
- package/dist/analyzeRoutes.d.ts.map +1 -0
- package/dist/analyzeRoutes.js +128 -0
- package/dist/cjs/ActivePageContext.d.ts +15 -0
- package/dist/cjs/ActivePageContext.d.ts.map +1 -0
- package/dist/cjs/ActivePageContext.js +42 -0
- package/dist/cjs/AuthenticatedRoute.d.ts +11 -0
- package/dist/cjs/AuthenticatedRoute.d.ts.map +1 -0
- package/dist/cjs/AuthenticatedRoute.js +83 -0
- package/dist/cjs/PageLoadingContext.d.ts +14 -0
- package/dist/cjs/PageLoadingContext.d.ts.map +1 -0
- package/dist/cjs/PageLoadingContext.js +64 -0
- package/dist/cjs/Route.d.ts +32 -0
- package/dist/cjs/Route.d.ts.map +1 -0
- package/dist/cjs/Route.js +41 -0
- package/dist/cjs/Set.d.ts +58 -0
- package/dist/cjs/Set.d.ts.map +1 -0
- package/dist/cjs/Set.js +67 -0
- package/dist/cjs/a11yUtils.d.ts +14 -0
- package/dist/cjs/a11yUtils.d.ts.map +1 -0
- package/dist/cjs/a11yUtils.js +61 -0
- package/dist/cjs/active-route-loader.d.ts +12 -0
- package/dist/cjs/active-route-loader.d.ts.map +1 -0
- package/dist/cjs/active-route-loader.js +116 -0
- package/dist/cjs/analyzeRoutes.d.ts +44 -0
- package/dist/cjs/analyzeRoutes.d.ts.map +1 -0
- package/dist/cjs/analyzeRoutes.js +143 -0
- package/dist/cjs/createNamedContext.d.ts +3 -0
- package/dist/cjs/createNamedContext.d.ts.map +1 -0
- package/dist/cjs/createNamedContext.js +33 -0
- package/dist/cjs/dummyComponent.d.ts +3 -0
- package/dist/cjs/dummyComponent.d.ts.map +1 -0
- package/dist/cjs/dummyComponent.js +24 -0
- package/dist/cjs/history.d.ts +24 -0
- package/dist/cjs/history.d.ts.map +1 -0
- package/dist/cjs/history.js +146 -0
- package/dist/cjs/index.d.ts +35 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +110 -0
- package/dist/cjs/link.d.ts +9 -0
- package/dist/cjs/link.d.ts.map +1 -0
- package/dist/cjs/link.js +62 -0
- package/dist/cjs/location.d.ts +28 -0
- package/dist/cjs/location.d.ts.map +1 -0
- package/dist/cjs/location.js +110 -0
- package/dist/cjs/namedRoutes.d.ts +3 -0
- package/dist/cjs/namedRoutes.d.ts.map +1 -0
- package/dist/cjs/namedRoutes.js +28 -0
- package/dist/cjs/navLink.d.ts +11 -0
- package/dist/cjs/navLink.d.ts.map +1 -0
- package/dist/cjs/navLink.js +70 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/page.d.ts +28 -0
- package/dist/cjs/page.d.ts.map +1 -0
- package/dist/cjs/page.js +42 -0
- package/dist/cjs/params.d.ts +13 -0
- package/dist/cjs/params.d.ts.map +1 -0
- package/dist/cjs/params.js +64 -0
- package/dist/cjs/react-util.d.ts +3 -0
- package/dist/cjs/react-util.d.ts.map +1 -0
- package/dist/cjs/react-util.js +37 -0
- package/dist/cjs/redirect.d.ts +12 -0
- package/dist/cjs/redirect.d.ts.map +1 -0
- package/dist/cjs/redirect.js +35 -0
- package/dist/cjs/route-announcement.d.ts +13 -0
- package/dist/cjs/route-announcement.d.ts.map +1 -0
- package/dist/cjs/route-announcement.js +61 -0
- package/dist/cjs/route-focus.d.ts +12 -0
- package/dist/cjs/route-focus.d.ts.map +1 -0
- package/dist/cjs/route-focus.js +36 -0
- package/dist/cjs/route-validators.d.ts +21 -0
- package/dist/cjs/route-validators.d.ts.map +1 -0
- package/dist/cjs/route-validators.js +71 -0
- package/dist/cjs/routeParamsTypes.d.ts +49 -0
- package/dist/cjs/routeParamsTypes.d.ts.map +1 -0
- package/dist/cjs/routeParamsTypes.js +16 -0
- package/dist/cjs/router-context.d.ts +21 -0
- package/dist/cjs/router-context.d.ts.map +1 -0
- package/dist/cjs/router-context.js +69 -0
- package/dist/cjs/router.d.ts +11 -0
- package/dist/cjs/router.d.ts.map +1 -0
- package/dist/cjs/router.js +207 -0
- package/dist/cjs/rsc/ClientRouter.d.ts +4 -0
- package/dist/cjs/rsc/ClientRouter.d.ts.map +1 -0
- package/dist/cjs/rsc/ClientRouter.js +90 -0
- package/dist/cjs/rsc/RscCache.d.ts +23 -0
- package/dist/cjs/rsc/RscCache.d.ts.map +1 -0
- package/dist/cjs/rsc/RscCache.js +110 -0
- package/dist/cjs/rsc/RscRoutes.d.ts +7 -0
- package/dist/cjs/rsc/RscRoutes.d.ts.map +1 -0
- package/dist/cjs/rsc/RscRoutes.js +124 -0
- package/dist/cjs/rsc/ServerRouteLoader.d.ts +12 -0
- package/dist/cjs/rsc/ServerRouteLoader.d.ts.map +1 -0
- package/dist/cjs/rsc/ServerRouteLoader.js +65 -0
- package/dist/cjs/rsc/ServerRouter.d.ts +11 -0
- package/dist/cjs/rsc/ServerRouter.d.ts.map +1 -0
- package/dist/cjs/rsc/ServerRouter.js +170 -0
- package/dist/cjs/rsc/SsrRouter.d.ts +4 -0
- package/dist/cjs/rsc/SsrRouter.d.ts.map +1 -0
- package/dist/cjs/rsc/SsrRouter.js +56 -0
- package/dist/cjs/rsc/clientSsr.d.ts +2 -0
- package/dist/cjs/rsc/clientSsr.d.ts.map +1 -0
- package/dist/cjs/rsc/clientSsr.js +114 -0
- package/dist/cjs/rsc/rscCss.d.ts +2 -0
- package/dist/cjs/rsc/rscCss.d.ts.map +1 -0
- package/dist/cjs/rsc/rscCss.js +94 -0
- package/dist/cjs/rsc/ssrModuleMap.d.ts +14 -0
- package/dist/cjs/rsc/ssrModuleMap.d.ts.map +1 -0
- package/dist/cjs/rsc/ssrModuleMap.js +49 -0
- package/dist/cjs/rsc/utils.d.ts +20 -0
- package/dist/cjs/rsc/utils.d.ts.map +1 -0
- package/dist/cjs/rsc/utils.js +68 -0
- package/dist/cjs/rsc-link.d.ts +6 -0
- package/dist/cjs/rsc-link.d.ts.map +1 -0
- package/dist/cjs/rsc-link.js +41 -0
- package/dist/cjs/skipNav.d.ts +81 -0
- package/dist/cjs/skipNav.d.ts.map +1 -0
- package/dist/cjs/skipNav.js +69 -0
- package/dist/cjs/splash-page.d.ts +12 -0
- package/dist/cjs/splash-page.d.ts.map +1 -0
- package/dist/cjs/splash-page.js +515 -0
- package/dist/cjs/useBlocker.d.ts +11 -0
- package/dist/cjs/useBlocker.d.ts.map +1 -0
- package/dist/cjs/useBlocker.js +65 -0
- package/dist/cjs/useIsMounted.d.ts +2 -0
- package/dist/cjs/useIsMounted.d.ts.map +1 -0
- package/dist/cjs/useIsMounted.js +37 -0
- package/dist/cjs/useMatch.d.ts +43 -0
- package/dist/cjs/useMatch.d.ts.map +1 -0
- package/dist/cjs/useMatch.js +72 -0
- package/dist/cjs/useRouteName.d.ts +3 -0
- package/dist/cjs/useRouteName.d.ts.map +1 -0
- package/dist/cjs/useRouteName.js +40 -0
- package/dist/cjs/useRoutePaths.d.ts +4 -0
- package/dist/cjs/useRoutePaths.d.ts.map +1 -0
- package/dist/cjs/useRoutePaths.js +50 -0
- package/dist/cjs/util.d.ts +121 -0
- package/dist/cjs/util.d.ts.map +1 -0
- package/dist/cjs/util.js +214 -0
- package/dist/createNamedContext.d.ts +3 -0
- package/dist/createNamedContext.d.ts.map +1 -0
- package/dist/createNamedContext.js +9 -0
- package/dist/dummyComponent.d.ts +3 -0
- package/dist/dummyComponent.d.ts.map +1 -0
- package/dist/dummyComponent.js +4 -0
- package/dist/history.d.ts +24 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +118 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/link.d.ts +9 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +28 -0
- package/dist/location.d.ts +28 -0
- package/dist/location.d.ts.map +1 -0
- package/dist/location.js +74 -0
- package/dist/namedRoutes.d.ts +3 -0
- package/dist/namedRoutes.d.ts.map +1 -0
- package/dist/namedRoutes.js +4 -0
- package/dist/navLink.d.ts +11 -0
- package/dist/navLink.d.ts.map +1 -0
- package/dist/navLink.js +36 -0
- package/dist/page.d.ts +28 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +17 -0
- package/dist/params.d.ts +13 -0
- package/dist/params.d.ts.map +1 -0
- package/dist/params.js +28 -0
- package/dist/react-util.d.ts +3 -0
- package/dist/react-util.d.ts.map +1 -0
- package/dist/react-util.js +13 -0
- package/dist/redirect.d.ts +12 -0
- package/dist/redirect.d.ts.map +1 -0
- package/dist/redirect.js +11 -0
- package/dist/route-announcement.d.ts +13 -0
- package/dist/route-announcement.d.ts.map +1 -0
- package/dist/route-announcement.js +31 -0
- package/dist/route-focus.d.ts +12 -0
- package/dist/route-focus.d.ts.map +1 -0
- package/dist/route-focus.js +6 -0
- package/dist/route-validators.d.ts +21 -0
- package/dist/route-validators.d.ts.map +1 -0
- package/dist/route-validators.js +44 -0
- package/dist/routeParamsTypes.d.ts +49 -0
- package/dist/routeParamsTypes.d.ts.map +1 -0
- package/dist/routeParamsTypes.js +0 -0
- package/dist/router-context.d.ts +21 -0
- package/dist/router-context.d.ts.map +1 -0
- package/dist/router-context.js +34 -0
- package/dist/router.d.ts +11 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +173 -0
- package/dist/rsc/ClientRouter.d.ts +4 -0
- package/dist/rsc/ClientRouter.d.ts.map +1 -0
- package/dist/rsc/ClientRouter.js +56 -0
- package/dist/rsc/RscCache.d.ts +23 -0
- package/dist/rsc/RscCache.d.ts.map +1 -0
- package/dist/rsc/RscCache.js +86 -0
- package/dist/rsc/RscRoutes.d.ts +7 -0
- package/dist/rsc/RscRoutes.d.ts.map +1 -0
- package/dist/rsc/RscRoutes.js +100 -0
- package/dist/rsc/ServerRouteLoader.d.ts +12 -0
- package/dist/rsc/ServerRouteLoader.d.ts.map +1 -0
- package/dist/rsc/ServerRouteLoader.js +31 -0
- package/dist/rsc/ServerRouter.d.ts +11 -0
- package/dist/rsc/ServerRouter.d.ts.map +1 -0
- package/dist/rsc/ServerRouter.js +136 -0
- package/dist/rsc/SsrRouter.d.ts +4 -0
- package/dist/rsc/SsrRouter.d.ts.map +1 -0
- package/dist/rsc/SsrRouter.js +22 -0
- package/dist/rsc/clientSsr.d.ts +2 -0
- package/dist/rsc/clientSsr.d.ts.map +1 -0
- package/dist/rsc/clientSsr.js +80 -0
- package/dist/rsc/rscCss.d.ts +2 -0
- package/dist/rsc/rscCss.d.ts.map +1 -0
- package/dist/rsc/rscCss.js +60 -0
- package/dist/rsc/ssrModuleMap.d.ts +14 -0
- package/dist/rsc/ssrModuleMap.d.ts.map +1 -0
- package/dist/rsc/ssrModuleMap.js +25 -0
- package/dist/rsc/utils.d.ts +20 -0
- package/dist/rsc/utils.d.ts.map +1 -0
- package/dist/rsc/utils.js +31 -0
- package/dist/rsc-link.d.ts +6 -0
- package/dist/rsc-link.d.ts.map +1 -0
- package/dist/rsc-link.js +7 -0
- package/dist/skipNav.d.ts +81 -0
- package/dist/skipNav.d.ts.map +1 -0
- package/dist/skipNav.js +34 -0
- package/dist/splash-page.d.ts +12 -0
- package/dist/splash-page.d.ts.map +1 -0
- package/dist/splash-page.js +481 -0
- package/dist/useBlocker.d.ts +11 -0
- package/dist/useBlocker.d.ts.map +1 -0
- package/dist/useBlocker.js +41 -0
- package/dist/useIsMounted.d.ts +2 -0
- package/dist/useIsMounted.d.ts.map +1 -0
- package/dist/useIsMounted.js +13 -0
- package/dist/useMatch.d.ts +43 -0
- package/dist/useMatch.d.ts.map +1 -0
- package/dist/useMatch.js +48 -0
- package/dist/useRouteName.d.ts +3 -0
- package/dist/useRouteName.d.ts.map +1 -0
- package/dist/useRouteName.js +16 -0
- package/dist/useRoutePaths.d.ts +4 -0
- package/dist/useRoutePaths.d.ts.map +1 -0
- package/dist/useRoutePaths.js +25 -0
- package/dist/util.d.ts +121 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +183 -0
- package/package.json +127 -0
- package/skip-nav.css +31 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerRouter.d.ts","sourceRoot":"","sources":["../../../src/rsc/ServerRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,0BAA0B,EAAE,QAAQ,GAAG,iBAAiB,CAAC;IACtE,eAAe,CAAC,EAAE,oBAAoB,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4GxC,CAAA"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ServerRouter_exports = {};
|
|
30
|
+
__export(ServerRouter_exports, {
|
|
31
|
+
Router: () => Router
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(ServerRouter_exports);
|
|
34
|
+
var import_react = __toESM(require("react"), 1);
|
|
35
|
+
var import_server_store = require("@cedarjs/server-store");
|
|
36
|
+
var import_analyzeRoutes = require("../analyzeRoutes.js");
|
|
37
|
+
var import_namedRoutes = require("../namedRoutes.js");
|
|
38
|
+
var import_page = require("../page.js");
|
|
39
|
+
var import_splash_page = require("../splash-page.js");
|
|
40
|
+
var import_util = require("../util.js");
|
|
41
|
+
var import_ServerRouteLoader = require("./ServerRouteLoader.js");
|
|
42
|
+
const Router = ({ paramTypes, children }) => {
|
|
43
|
+
const location = (0, import_server_store.getLocation)();
|
|
44
|
+
console.log("ServerRouter.tsx location", location);
|
|
45
|
+
const analyzedRoutes = (0, import_analyzeRoutes.analyzeRoutes)(children, {
|
|
46
|
+
currentPathName: location.pathname,
|
|
47
|
+
// @TODO We haven't handled this with SSR/Streaming yet.
|
|
48
|
+
// May need a babel plugin to extract userParamTypes from Routes.tsx
|
|
49
|
+
userParamTypes: paramTypes
|
|
50
|
+
});
|
|
51
|
+
const {
|
|
52
|
+
pathRouteMap,
|
|
53
|
+
hasRootRoute,
|
|
54
|
+
namedRoutesMap,
|
|
55
|
+
NotFoundPage,
|
|
56
|
+
activeRoutePath
|
|
57
|
+
} = analyzedRoutes;
|
|
58
|
+
Object.assign(import_namedRoutes.namedRoutes, namedRoutesMap);
|
|
59
|
+
const hasGeneratedRoutes = Object.keys(import_namedRoutes.namedRoutes).length > 0;
|
|
60
|
+
const shouldShowSplash = !hasRootRoute && location.pathname === "/" || !hasGeneratedRoutes;
|
|
61
|
+
if (shouldShowSplash && typeof import_splash_page.SplashPage !== "undefined") {
|
|
62
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
63
|
+
import_splash_page.SplashPage,
|
|
64
|
+
{
|
|
65
|
+
hasGeneratedRoutes,
|
|
66
|
+
allStandardRoutes: pathRouteMap
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (!activeRoutePath) {
|
|
71
|
+
if (NotFoundPage) {
|
|
72
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
73
|
+
import_ServerRouteLoader.ServerRouteLoader,
|
|
74
|
+
{
|
|
75
|
+
spec: (0, import_page.normalizePage)(NotFoundPage),
|
|
76
|
+
path: location.pathname
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const { path, page, name, redirect, whileLoadingPage, sets } = pathRouteMap[activeRoutePath];
|
|
83
|
+
if (!path) {
|
|
84
|
+
throw new Error(`Route "${name}" needs to specify a path`);
|
|
85
|
+
}
|
|
86
|
+
(0, import_util.validatePath)(path, name || path);
|
|
87
|
+
const { params: pathParams } = (0, import_util.matchPath)(path, location.pathname, {
|
|
88
|
+
userParamTypes: paramTypes
|
|
89
|
+
});
|
|
90
|
+
const searchParams = (0, import_util.parseSearch)(location.search);
|
|
91
|
+
const allParams = { ...searchParams, ...pathParams };
|
|
92
|
+
let redirectPath = void 0;
|
|
93
|
+
if (redirect) {
|
|
94
|
+
if (redirect.startsWith("/")) {
|
|
95
|
+
redirectPath = (0, import_util.replaceParams)(redirect, allParams);
|
|
96
|
+
} else {
|
|
97
|
+
const redirectRouteObject = Object.values(pathRouteMap).find(
|
|
98
|
+
(route) => route.name === redirect
|
|
99
|
+
);
|
|
100
|
+
if (!redirectRouteObject) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`Redirect target route "${redirect}" does not exist for route "${name}"`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
redirectPath = (0, import_util.replaceParams)(redirectRouteObject.path, allParams);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, !redirectPath && page && /* @__PURE__ */ import_react.default.createElement(
|
|
109
|
+
WrappedPage,
|
|
110
|
+
{
|
|
111
|
+
sets,
|
|
112
|
+
routeLoaderElement: /* @__PURE__ */ import_react.default.createElement(
|
|
113
|
+
import_ServerRouteLoader.ServerRouteLoader,
|
|
114
|
+
{
|
|
115
|
+
path,
|
|
116
|
+
spec: (0, import_page.normalizePage)(page),
|
|
117
|
+
params: allParams,
|
|
118
|
+
whileLoadingPage
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
));
|
|
123
|
+
};
|
|
124
|
+
function hasRole(requiredRoles) {
|
|
125
|
+
const { roles } = (0, import_server_store.getAuthState)();
|
|
126
|
+
const requiredRolesArray = Array.isArray(requiredRoles) ? requiredRoles : [requiredRoles];
|
|
127
|
+
return requiredRolesArray.some((role) => roles.includes(role));
|
|
128
|
+
}
|
|
129
|
+
const AuthenticatedRoute = ({
|
|
130
|
+
children,
|
|
131
|
+
roles
|
|
132
|
+
}) => {
|
|
133
|
+
const { isAuthenticated } = (0, import_server_store.getAuthState)();
|
|
134
|
+
const isAuthorized = isAuthenticated && (!roles || hasRole(roles));
|
|
135
|
+
if (isAuthorized) {
|
|
136
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, children);
|
|
137
|
+
}
|
|
138
|
+
if (!isAuthenticated) {
|
|
139
|
+
throw new Error("401 Unauthorized");
|
|
140
|
+
}
|
|
141
|
+
throw new Error("403 Forbidden");
|
|
142
|
+
};
|
|
143
|
+
const WrappedPage = ({ routeLoaderElement, sets }) => {
|
|
144
|
+
if (!sets || sets.length === 0) {
|
|
145
|
+
return routeLoaderElement;
|
|
146
|
+
}
|
|
147
|
+
return sets.reduceRight((acc, set) => {
|
|
148
|
+
let wrapped = set.wrappers.reduceRight((acc2, Wrapper, index) => {
|
|
149
|
+
return import_react.default.createElement(
|
|
150
|
+
Wrapper,
|
|
151
|
+
{ ...set.props, key: set.id + "-" + index },
|
|
152
|
+
acc2
|
|
153
|
+
);
|
|
154
|
+
}, acc);
|
|
155
|
+
if (set.isPrivate) {
|
|
156
|
+
const unauthenticated = set.props.unauthenticated;
|
|
157
|
+
if (!unauthenticated || typeof unauthenticated !== "string") {
|
|
158
|
+
throw new Error(
|
|
159
|
+
"You must specify an `unauthenticated` route when using PrivateSet"
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
wrapped = /* @__PURE__ */ import_react.default.createElement(AuthenticatedRoute, { ...set.props, unauthenticated }, wrapped);
|
|
163
|
+
}
|
|
164
|
+
return wrapped;
|
|
165
|
+
}, routeLoaderElement);
|
|
166
|
+
};
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
Router
|
|
170
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SsrRouter.d.ts","sourceRoot":"","sources":["../../../src/rsc/SsrRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI/C,eAAO,MAAM,MAAM,6BAA8B,WAAW,sBAQ3D,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var SsrRouter_exports = {};
|
|
30
|
+
__export(SsrRouter_exports, {
|
|
31
|
+
Router: () => Router
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(SsrRouter_exports);
|
|
34
|
+
var import_react = __toESM(require("react"), 1);
|
|
35
|
+
var import_analyzeRoutes = require("../analyzeRoutes.js");
|
|
36
|
+
var import_location = require("../location.js");
|
|
37
|
+
var import_namedRoutes = require("../namedRoutes.js");
|
|
38
|
+
var import_clientSsr = require("./clientSsr.js");
|
|
39
|
+
const Router = ({ paramTypes, children }) => {
|
|
40
|
+
return /* @__PURE__ */ import_react.default.createElement(import_location.LocationProvider, null, /* @__PURE__ */ import_react.default.createElement(LocationAwareRouter, { paramTypes }, children));
|
|
41
|
+
};
|
|
42
|
+
const LocationAwareRouter = ({ paramTypes, children }) => {
|
|
43
|
+
const { pathname } = (0, import_location.useLocation)();
|
|
44
|
+
const { namedRoutesMap } = (0, import_react.useMemo)(() => {
|
|
45
|
+
return (0, import_analyzeRoutes.analyzeRoutes)(children, {
|
|
46
|
+
currentPathName: pathname,
|
|
47
|
+
userParamTypes: paramTypes
|
|
48
|
+
});
|
|
49
|
+
}, [pathname, children, paramTypes]);
|
|
50
|
+
Object.assign(import_namedRoutes.namedRoutes, namedRoutesMap);
|
|
51
|
+
return (0, import_clientSsr.renderRoutesSsr)(pathname);
|
|
52
|
+
};
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
Router
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientSsr.d.ts","sourceRoot":"","sources":["../../../src/rsc/clientSsr.ts"],"names":[],"mappings":"AAuEA,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,gBA2DrD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var clientSsr_exports = {};
|
|
30
|
+
__export(clientSsr_exports, {
|
|
31
|
+
renderRoutesSsr: () => renderRoutesSsr
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(clientSsr_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
36
|
+
var import_ssrModuleMap = require("./ssrModuleMap.js");
|
|
37
|
+
var import_utils = require("./utils.js");
|
|
38
|
+
var import_utils2 = require("./utils.js");
|
|
39
|
+
async function getEntries() {
|
|
40
|
+
const entriesPath = (0, import_project_config.getPaths)().web.distRscEntries;
|
|
41
|
+
const entries = await import((0, import_utils2.makeFilePath)(entriesPath));
|
|
42
|
+
return entries;
|
|
43
|
+
}
|
|
44
|
+
async function getRoutesComponent() {
|
|
45
|
+
const { serverEntries } = await getEntries();
|
|
46
|
+
const entryPath = import_node_path.default.join(
|
|
47
|
+
(0, import_project_config.getPaths)().web.distRsc,
|
|
48
|
+
serverEntries["__rwjs__Routes"]
|
|
49
|
+
);
|
|
50
|
+
console.log("getRoutesComponent entryPath", entryPath);
|
|
51
|
+
const routesModule = await import((0, import_utils2.makeFilePath)(entryPath));
|
|
52
|
+
return routesModule.default;
|
|
53
|
+
}
|
|
54
|
+
function resolveClientEntryForProd(filePath, clientEntries) {
|
|
55
|
+
const basePath = (0, import_project_config.getPaths)().web.distSsr;
|
|
56
|
+
const entriesFile = (0, import_project_config.getPaths)().web.distRscEntries;
|
|
57
|
+
const baseDir = import_node_path.default.dirname(entriesFile);
|
|
58
|
+
const absoluteClientEntries = Object.fromEntries(
|
|
59
|
+
Object.entries(clientEntries).map(([key, val]) => {
|
|
60
|
+
let fullKey = import_node_path.default.join(baseDir, key);
|
|
61
|
+
if (process.platform === "win32") {
|
|
62
|
+
fullKey = fullKey.replaceAll("\\", "/");
|
|
63
|
+
}
|
|
64
|
+
return [fullKey, basePath + import_node_path.default.sep + val];
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
const filePathSlash = filePath.replaceAll("\\", "/");
|
|
68
|
+
const clientEntry = absoluteClientEntries[filePathSlash];
|
|
69
|
+
console.log("resolveClientEntryForProd during SSR - clientEntry", clientEntry);
|
|
70
|
+
if (!clientEntry) {
|
|
71
|
+
if (absoluteClientEntries["*"] === "*") {
|
|
72
|
+
return basePath + import_node_path.default.relative((0, import_project_config.getPaths)().base, filePathSlash);
|
|
73
|
+
}
|
|
74
|
+
throw new Error("No client entry found for " + filePathSlash);
|
|
75
|
+
}
|
|
76
|
+
return clientEntry;
|
|
77
|
+
}
|
|
78
|
+
const rscCache = /* @__PURE__ */ new Map();
|
|
79
|
+
async function renderRoutesSsr(pathname) {
|
|
80
|
+
console.log("renderRoutesSsr pathname", pathname);
|
|
81
|
+
const cached = rscCache.get(pathname);
|
|
82
|
+
if (cached) {
|
|
83
|
+
return cached;
|
|
84
|
+
}
|
|
85
|
+
const Routes = await getRoutesComponent();
|
|
86
|
+
console.log("clientSsr.ts getEntries()", await getEntries());
|
|
87
|
+
const clientEntries = (await getEntries()).ssrEntries;
|
|
88
|
+
const bundlerConfig = new Proxy(
|
|
89
|
+
{},
|
|
90
|
+
{
|
|
91
|
+
get(_target, encodedId) {
|
|
92
|
+
console.log("Proxy get encodedId", encodedId);
|
|
93
|
+
const [filePath, name] = encodedId.split("#");
|
|
94
|
+
const id = resolveClientEntryForProd(filePath, clientEntries);
|
|
95
|
+
console.log("clientSsr.ts::Proxy id", id);
|
|
96
|
+
return { id, chunks: [id], name, async: true };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
const { createElement } = await (0, import_utils.importReact)();
|
|
101
|
+
const { renderToReadableStream } = await (0, import_utils.importRsdwServer)();
|
|
102
|
+
console.log("clientSsr.ts right before renderToReadableStream");
|
|
103
|
+
const stream = renderToReadableStream(createElement(Routes), bundlerConfig);
|
|
104
|
+
const { createFromReadableStream } = await (0, import_utils.importRsdwClient)();
|
|
105
|
+
const data = createFromReadableStream(stream, {
|
|
106
|
+
ssrManifest: { moduleMap: import_ssrModuleMap.moduleMap, moduleLoading: null }
|
|
107
|
+
});
|
|
108
|
+
rscCache.set(pathname, data);
|
|
109
|
+
return data;
|
|
110
|
+
}
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
renderRoutesSsr
|
|
114
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rscCss.d.ts","sourceRoot":"","sources":["../../../src/rsc/rscCss.ts"],"names":[],"mappings":"AAaA,wBAAgB,6BAA6B,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,kBAiCrE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var rscCss_exports = {};
|
|
30
|
+
__export(rscCss_exports, {
|
|
31
|
+
getRscStylesheetLinkGenerator: () => getRscStylesheetLinkGenerator
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(rscCss_exports);
|
|
34
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
+
function getRscStylesheetLinkGenerator(existingLinks) {
|
|
38
|
+
const clientBuildManifestPath = import_node_path.default.join(
|
|
39
|
+
(0, import_project_config.getPaths)().web.distBrowser,
|
|
40
|
+
"client-build-manifest.json"
|
|
41
|
+
);
|
|
42
|
+
const clientBuildManifest = JSON.parse(
|
|
43
|
+
import_node_fs.default.readFileSync(clientBuildManifestPath, "utf-8")
|
|
44
|
+
);
|
|
45
|
+
const clientCss = extractCssMappingFromManifest(clientBuildManifest);
|
|
46
|
+
const serverBuildManifestPath = import_node_path.default.join(
|
|
47
|
+
(0, import_project_config.getPaths)().web.distRsc,
|
|
48
|
+
"server-build-manifest.json"
|
|
49
|
+
);
|
|
50
|
+
const serverBuildManifest = JSON.parse(
|
|
51
|
+
import_node_fs.default.readFileSync(serverBuildManifestPath, "utf-8")
|
|
52
|
+
);
|
|
53
|
+
const serverCss = extractCssMappingFromManifest(serverBuildManifest);
|
|
54
|
+
const allCss = /* @__PURE__ */ new Set();
|
|
55
|
+
for (const cssList of clientCss.values()) {
|
|
56
|
+
for (const css of cssList) {
|
|
57
|
+
allCss.add(css);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const cssList of serverCss.values()) {
|
|
61
|
+
for (const css of cssList) {
|
|
62
|
+
allCss.add(css);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const cssLinks = Array.from(allCss);
|
|
66
|
+
return () => [...existingLinks || [], ...cssLinks];
|
|
67
|
+
}
|
|
68
|
+
function extractCssMappingFromManifest(manifest) {
|
|
69
|
+
const manifestCss = /* @__PURE__ */ new Map();
|
|
70
|
+
const lookupCssAssets = (id) => {
|
|
71
|
+
const assets = [];
|
|
72
|
+
const asset = manifest[id];
|
|
73
|
+
if (!asset) {
|
|
74
|
+
return assets;
|
|
75
|
+
}
|
|
76
|
+
if (asset.css) {
|
|
77
|
+
assets.push(...asset.css);
|
|
78
|
+
}
|
|
79
|
+
if (asset.imports) {
|
|
80
|
+
for (const importId of asset.imports) {
|
|
81
|
+
assets.push(...lookupCssAssets(importId));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return assets;
|
|
85
|
+
};
|
|
86
|
+
for (const key of Object.keys(manifest)) {
|
|
87
|
+
manifestCss.set(key, lookupCssAssets(key));
|
|
88
|
+
}
|
|
89
|
+
return manifestCss;
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
getRscStylesheetLinkGenerator
|
|
94
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type SSRModuleMap = null | {
|
|
2
|
+
[clientId: string]: {
|
|
3
|
+
[clientExportName: string]: ClientReferenceManifestEntry;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
type ClientReferenceManifestEntry = ImportManifestEntry;
|
|
7
|
+
type ImportManifestEntry = {
|
|
8
|
+
id: string;
|
|
9
|
+
chunks: string[];
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const moduleMap: SSRModuleMap;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=ssrModuleMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssrModuleMap.d.ts","sourceRoot":"","sources":["../../../src/rsc/ssrModuleMap.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG,IAAI,GAAG;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG;QAClB,CAAC,gBAAgB,EAAE,MAAM,GAAG,4BAA4B,CAAA;KACzD,CAAA;CACF,CAAA;AACD,KAAK,4BAA4B,GAAG,mBAAmB,CAAA;AACvD,KAAK,mBAAmB,GAAG;IACzB,EAAE,EAAE,MAAM,CAAA;IAEV,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAMD,eAAO,MAAM,SAAS,EAAE,YAuBvB,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ssrModuleMap_exports = {};
|
|
20
|
+
__export(ssrModuleMap_exports, {
|
|
21
|
+
moduleMap: () => moduleMap
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ssrModuleMap_exports);
|
|
24
|
+
var import_utils = require("./utils.js");
|
|
25
|
+
const moduleMap = new Proxy(
|
|
26
|
+
{},
|
|
27
|
+
{
|
|
28
|
+
get(_target, filePath) {
|
|
29
|
+
return new Proxy(
|
|
30
|
+
{},
|
|
31
|
+
{
|
|
32
|
+
get(_target2, name) {
|
|
33
|
+
filePath = (0, import_utils.makeFilePath)(filePath);
|
|
34
|
+
const manifestEntry = {
|
|
35
|
+
id: filePath,
|
|
36
|
+
chunks: [filePath],
|
|
37
|
+
name
|
|
38
|
+
};
|
|
39
|
+
return manifestEntry;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
moduleMap
|
|
49
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { default as RSDWClientModule } from 'react-server-dom-webpack/client.edge';
|
|
2
|
+
import type { default as RSDWServerModule } from 'react-server-dom-webpack/server.edge';
|
|
3
|
+
type RSDWClientType = typeof RSDWClientModule;
|
|
4
|
+
type RSDWServerType = typeof RSDWServerModule;
|
|
5
|
+
export declare function makeFilePath(path: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* See vite/streamHelpers.ts.
|
|
8
|
+
*
|
|
9
|
+
* This function ensures we load the same version of rsdw_client to prevent multiple instances of React
|
|
10
|
+
*/
|
|
11
|
+
export declare function importReact(): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* See vite/streamHelpers.ts.
|
|
14
|
+
*
|
|
15
|
+
* This function ensures we load the same version of rsdw_client to prevent multiple instances of React
|
|
16
|
+
*/
|
|
17
|
+
export declare function importRsdwClient(): Promise<RSDWClientType>;
|
|
18
|
+
export declare function importRsdwServer(): Promise<RSDWServerType>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/rsc/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AACvF,OAAO,KAAK,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAIvF,KAAK,cAAc,GAAG,OAAO,gBAAgB,CAAA;AAC7C,KAAK,cAAc,GAAG,OAAO,gBAAgB,CAAA;AAE7C,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAExC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,iBAKhC;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,cAAc,CAAC,CAOhE;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,cAAc,CAAC,CAWhE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var utils_exports = {};
|
|
30
|
+
__export(utils_exports, {
|
|
31
|
+
importReact: () => importReact,
|
|
32
|
+
importRsdwClient: () => importRsdwClient,
|
|
33
|
+
importRsdwServer: () => importRsdwServer,
|
|
34
|
+
makeFilePath: () => makeFilePath
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(utils_exports);
|
|
37
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
38
|
+
var import_node_url = require("node:url");
|
|
39
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
40
|
+
function makeFilePath(path2) {
|
|
41
|
+
return (0, import_node_url.pathToFileURL)(path2).href;
|
|
42
|
+
}
|
|
43
|
+
async function importReact() {
|
|
44
|
+
const distSsr = (0, import_project_config.getPaths)().web.distSsr;
|
|
45
|
+
const reactPath = makeFilePath(import_node_path.default.join(distSsr, "__rwjs__react.mjs"));
|
|
46
|
+
return (await import(reactPath)).default;
|
|
47
|
+
}
|
|
48
|
+
async function importRsdwClient() {
|
|
49
|
+
const distSsr = (0, import_project_config.getPaths)().web.distSsr;
|
|
50
|
+
const rsdwClientPath = makeFilePath(
|
|
51
|
+
import_node_path.default.join(distSsr, "__rwjs__rsdw-client.mjs")
|
|
52
|
+
);
|
|
53
|
+
return (await import(rsdwClientPath)).default;
|
|
54
|
+
}
|
|
55
|
+
async function importRsdwServer() {
|
|
56
|
+
const dynamicImport = "";
|
|
57
|
+
return import(
|
|
58
|
+
/* @vite-ignore */
|
|
59
|
+
dynamicImport + "react-server-dom-webpack/server.edge"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
importReact,
|
|
65
|
+
importRsdwClient,
|
|
66
|
+
importRsdwServer,
|
|
67
|
+
makeFilePath
|
|
68
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface LinkProps {
|
|
3
|
+
to: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.AnchorHTMLAttributes<HTMLAnchorElement> & React.RefAttributes<HTMLAnchorElement>>;
|
|
6
|
+
//# sourceMappingURL=rsc-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc-link.d.ts","sourceRoot":"","sources":["../../src/rsc-link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;CACX;AAmBD,eAAO,MAAM,IAAI,qIAKf,CAAA"}
|