@webtypen/webframez-react 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/http.cjs CHANGED
@@ -636,7 +636,8 @@ function createFileRouter(options) {
636
636
  model: fallback,
637
637
  head: {
638
638
  title: `${statusCode} - ${message}`
639
- }
639
+ },
640
+ context: errorProps
640
641
  };
641
642
  }
642
643
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -651,7 +652,8 @@ function createFileRouter(options) {
651
652
  model,
652
653
  contextModel,
653
654
  pageModel: errorNode,
654
- head: mergeHead(layoutHead, errorHead)
655
+ head: mergeHead(layoutHead, errorHead),
656
+ context: errorProps
655
657
  };
656
658
  }
657
659
  function normalizeMiddlewareNames(config) {
@@ -776,7 +778,8 @@ function createFileRouter(options) {
776
778
  model,
777
779
  contextModel,
778
780
  pageModel: pageNode,
779
- head: mergeHead(layoutHead, pageHead)
781
+ head: mergeHead(layoutHead, pageHead),
782
+ context: pageContext
780
783
  };
781
784
  } catch (error) {
782
785
  if (isRouteAbort(error)) {
@@ -796,6 +799,38 @@ function parseSearchParams(query) {
796
799
  }
797
800
 
798
801
  // src/http.ts
802
+ function attachResolvedContextToCoreRequest(req, context) {
803
+ if (!context) {
804
+ return;
805
+ }
806
+ const coreRequest = req.__webframezCoreRequest;
807
+ if (!coreRequest) {
808
+ return;
809
+ }
810
+ const data = context.data && typeof context.data === "object" ? context.data : void 0;
811
+ const env = data?.env;
812
+ const website = data?.website;
813
+ coreRequest.__webframezReactContext = {
814
+ pathname: context.pathname,
815
+ params: context.params,
816
+ request: context.request,
817
+ data: data ? {
818
+ env,
819
+ website,
820
+ is_env_website_request: data.is_env_website_request,
821
+ is_website_domain_request: data.is_website_domain_request,
822
+ website_base_path: data.website_base_path,
823
+ website_route_base_path: data.website_route_base_path,
824
+ website_transport_base_path: data.website_transport_base_path
825
+ } : void 0
826
+ };
827
+ if (!coreRequest.env && env) {
828
+ coreRequest.env = env;
829
+ }
830
+ if (!coreRequest.website && website) {
831
+ coreRequest.website = website;
832
+ }
833
+ }
799
834
  function createInitialHtmlErrorMarkup(message) {
800
835
  return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
801
836
  }
@@ -930,13 +965,31 @@ globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
930
965
  };
931
966
  function normalizeWebframezRequireCandidate(candidate) {
932
967
  const stagingMarker = path.join(".webframez-build", "");
933
- const appMarker = path.join("app", "");
968
+ const runtimeMarkers = [path.join("app", ""), path.join("modules", "")];
934
969
  const stagingIndex = candidate.indexOf(stagingMarker);
935
- const appIndex = candidate.indexOf(appMarker, stagingIndex >= 0 ? stagingIndex : 0);
936
- if (stagingIndex >= 0 && appIndex >= 0) {
937
- const runtimeCandidate = path.resolve(process.cwd(), candidate.slice(appIndex));
938
- if (fs.existsSync(runtimeCandidate)) {
939
- return runtimeCandidate;
970
+ if (stagingIndex >= 0) {
971
+ for (const runtimeMarker of runtimeMarkers) {
972
+ const markerIndex = candidate.indexOf(runtimeMarker, stagingIndex);
973
+ if (markerIndex < 0) {
974
+ continue;
975
+ }
976
+
977
+ const relativeRuntimePath = candidate.slice(markerIndex);
978
+ const runtimeCandidates = [
979
+ path.resolve(process.cwd(), relativeRuntimePath),
980
+ path.resolve(process.cwd(), "build", relativeRuntimePath)
981
+ ];
982
+ const cwdParts = process.cwd().split(path.sep);
983
+ const buildsIndex = cwdParts.lastIndexOf("builds");
984
+ if (buildsIndex > 0) {
985
+ const projectRoot = cwdParts.slice(0, buildsIndex).join(path.sep) || path.sep;
986
+ runtimeCandidates.push(path.resolve(projectRoot, "build", relativeRuntimePath));
987
+ }
988
+
989
+ const runtimeCandidate = runtimeCandidates.find((candidatePath) => fs.existsSync(candidatePath));
990
+ if (runtimeCandidate) {
991
+ return runtimeCandidate;
992
+ }
940
993
  }
941
994
  }
942
995
 
@@ -1626,6 +1679,7 @@ function createNodeRequestHandler(options) {
1626
1679
  request: requestContext
1627
1680
  })
1628
1681
  );
1682
+ attachResolvedContextToCoreRequest(req, resolved2.context);
1629
1683
  const payload = {
1630
1684
  model: resolved2.model,
1631
1685
  contextModel: resolved2.contextModel,
@@ -1700,6 +1754,7 @@ function createNodeRequestHandler(options) {
1700
1754
  )
1701
1755
  })
1702
1756
  );
1757
+ attachResolvedContextToCoreRequest(req, resolved.context);
1703
1758
  const initialPayload = {
1704
1759
  model: resolved.model,
1705
1760
  head: resolved.head
package/dist/http.js CHANGED
@@ -616,7 +616,8 @@ function createFileRouter(options) {
616
616
  model: fallback,
617
617
  head: {
618
618
  title: `${statusCode} - ${message}`
619
- }
619
+ },
620
+ context: errorProps
620
621
  };
621
622
  }
622
623
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -631,7 +632,8 @@ function createFileRouter(options) {
631
632
  model,
632
633
  contextModel,
633
634
  pageModel: errorNode,
634
- head: mergeHead(layoutHead, errorHead)
635
+ head: mergeHead(layoutHead, errorHead),
636
+ context: errorProps
635
637
  };
636
638
  }
637
639
  function normalizeMiddlewareNames(config) {
@@ -756,7 +758,8 @@ function createFileRouter(options) {
756
758
  model,
757
759
  contextModel,
758
760
  pageModel: pageNode,
759
- head: mergeHead(layoutHead, pageHead)
761
+ head: mergeHead(layoutHead, pageHead),
762
+ context: pageContext
760
763
  };
761
764
  } catch (error) {
762
765
  if (isRouteAbort(error)) {
@@ -776,6 +779,38 @@ function parseSearchParams(query) {
776
779
  }
777
780
 
778
781
  // src/http.ts
782
+ function attachResolvedContextToCoreRequest(req, context) {
783
+ if (!context) {
784
+ return;
785
+ }
786
+ const coreRequest = req.__webframezCoreRequest;
787
+ if (!coreRequest) {
788
+ return;
789
+ }
790
+ const data = context.data && typeof context.data === "object" ? context.data : void 0;
791
+ const env = data?.env;
792
+ const website = data?.website;
793
+ coreRequest.__webframezReactContext = {
794
+ pathname: context.pathname,
795
+ params: context.params,
796
+ request: context.request,
797
+ data: data ? {
798
+ env,
799
+ website,
800
+ is_env_website_request: data.is_env_website_request,
801
+ is_website_domain_request: data.is_website_domain_request,
802
+ website_base_path: data.website_base_path,
803
+ website_route_base_path: data.website_route_base_path,
804
+ website_transport_base_path: data.website_transport_base_path
805
+ } : void 0
806
+ };
807
+ if (!coreRequest.env && env) {
808
+ coreRequest.env = env;
809
+ }
810
+ if (!coreRequest.website && website) {
811
+ coreRequest.website = website;
812
+ }
813
+ }
779
814
  function createInitialHtmlErrorMarkup(message) {
780
815
  return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
781
816
  }
@@ -910,13 +945,31 @@ globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
910
945
  };
911
946
  function normalizeWebframezRequireCandidate(candidate) {
912
947
  const stagingMarker = path.join(".webframez-build", "");
913
- const appMarker = path.join("app", "");
948
+ const runtimeMarkers = [path.join("app", ""), path.join("modules", "")];
914
949
  const stagingIndex = candidate.indexOf(stagingMarker);
915
- const appIndex = candidate.indexOf(appMarker, stagingIndex >= 0 ? stagingIndex : 0);
916
- if (stagingIndex >= 0 && appIndex >= 0) {
917
- const runtimeCandidate = path.resolve(process.cwd(), candidate.slice(appIndex));
918
- if (fs.existsSync(runtimeCandidate)) {
919
- return runtimeCandidate;
950
+ if (stagingIndex >= 0) {
951
+ for (const runtimeMarker of runtimeMarkers) {
952
+ const markerIndex = candidate.indexOf(runtimeMarker, stagingIndex);
953
+ if (markerIndex < 0) {
954
+ continue;
955
+ }
956
+
957
+ const relativeRuntimePath = candidate.slice(markerIndex);
958
+ const runtimeCandidates = [
959
+ path.resolve(process.cwd(), relativeRuntimePath),
960
+ path.resolve(process.cwd(), "build", relativeRuntimePath)
961
+ ];
962
+ const cwdParts = process.cwd().split(path.sep);
963
+ const buildsIndex = cwdParts.lastIndexOf("builds");
964
+ if (buildsIndex > 0) {
965
+ const projectRoot = cwdParts.slice(0, buildsIndex).join(path.sep) || path.sep;
966
+ runtimeCandidates.push(path.resolve(projectRoot, "build", relativeRuntimePath));
967
+ }
968
+
969
+ const runtimeCandidate = runtimeCandidates.find((candidatePath) => fs.existsSync(candidatePath));
970
+ if (runtimeCandidate) {
971
+ return runtimeCandidate;
972
+ }
920
973
  }
921
974
  }
922
975
 
@@ -1606,6 +1659,7 @@ function createNodeRequestHandler(options) {
1606
1659
  request: requestContext
1607
1660
  })
1608
1661
  );
1662
+ attachResolvedContextToCoreRequest(req, resolved2.context);
1609
1663
  const payload = {
1610
1664
  model: resolved2.model,
1611
1665
  contextModel: resolved2.contextModel,
@@ -1680,6 +1734,7 @@ function createNodeRequestHandler(options) {
1680
1734
  )
1681
1735
  })
1682
1736
  );
1737
+ attachResolvedContextToCoreRequest(req, resolved.context);
1683
1738
  const initialPayload = {
1684
1739
  model: resolved.model,
1685
1740
  head: resolved.head
package/dist/index.cjs CHANGED
@@ -671,7 +671,8 @@ function createFileRouter(options) {
671
671
  model: fallback,
672
672
  head: {
673
673
  title: `${statusCode} - ${message}`
674
- }
674
+ },
675
+ context: errorProps
675
676
  };
676
677
  }
677
678
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -686,7 +687,8 @@ function createFileRouter(options) {
686
687
  model,
687
688
  contextModel,
688
689
  pageModel: errorNode,
689
- head: mergeHead(layoutHead, errorHead)
690
+ head: mergeHead(layoutHead, errorHead),
691
+ context: errorProps
690
692
  };
691
693
  }
692
694
  function normalizeMiddlewareNames(config) {
@@ -811,7 +813,8 @@ function createFileRouter(options) {
811
813
  model,
812
814
  contextModel,
813
815
  pageModel: pageNode,
814
- head: mergeHead(layoutHead, pageHead)
816
+ head: mergeHead(layoutHead, pageHead),
817
+ context: pageContext
815
818
  };
816
819
  } catch (error) {
817
820
  if (isRouteAbort(error)) {
@@ -836,6 +839,38 @@ var import_node_path3 = __toESM(require("node:path"), 1);
836
839
  var import_node_url = require("node:url");
837
840
  var import_node_child_process = require("node:child_process");
838
841
  var import_node_zlib = require("node:zlib");
842
+ function attachResolvedContextToCoreRequest(req, context) {
843
+ if (!context) {
844
+ return;
845
+ }
846
+ const coreRequest = req.__webframezCoreRequest;
847
+ if (!coreRequest) {
848
+ return;
849
+ }
850
+ const data = context.data && typeof context.data === "object" ? context.data : void 0;
851
+ const env = data?.env;
852
+ const website = data?.website;
853
+ coreRequest.__webframezReactContext = {
854
+ pathname: context.pathname,
855
+ params: context.params,
856
+ request: context.request,
857
+ data: data ? {
858
+ env,
859
+ website,
860
+ is_env_website_request: data.is_env_website_request,
861
+ is_website_domain_request: data.is_website_domain_request,
862
+ website_base_path: data.website_base_path,
863
+ website_route_base_path: data.website_route_base_path,
864
+ website_transport_base_path: data.website_transport_base_path
865
+ } : void 0
866
+ };
867
+ if (!coreRequest.env && env) {
868
+ coreRequest.env = env;
869
+ }
870
+ if (!coreRequest.website && website) {
871
+ coreRequest.website = website;
872
+ }
873
+ }
839
874
  function createInitialHtmlErrorMarkup(message) {
840
875
  return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
841
876
  }
@@ -970,13 +1005,31 @@ globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
970
1005
  };
971
1006
  function normalizeWebframezRequireCandidate(candidate) {
972
1007
  const stagingMarker = path.join(".webframez-build", "");
973
- const appMarker = path.join("app", "");
1008
+ const runtimeMarkers = [path.join("app", ""), path.join("modules", "")];
974
1009
  const stagingIndex = candidate.indexOf(stagingMarker);
975
- const appIndex = candidate.indexOf(appMarker, stagingIndex >= 0 ? stagingIndex : 0);
976
- if (stagingIndex >= 0 && appIndex >= 0) {
977
- const runtimeCandidate = path.resolve(process.cwd(), candidate.slice(appIndex));
978
- if (fs.existsSync(runtimeCandidate)) {
979
- return runtimeCandidate;
1010
+ if (stagingIndex >= 0) {
1011
+ for (const runtimeMarker of runtimeMarkers) {
1012
+ const markerIndex = candidate.indexOf(runtimeMarker, stagingIndex);
1013
+ if (markerIndex < 0) {
1014
+ continue;
1015
+ }
1016
+
1017
+ const relativeRuntimePath = candidate.slice(markerIndex);
1018
+ const runtimeCandidates = [
1019
+ path.resolve(process.cwd(), relativeRuntimePath),
1020
+ path.resolve(process.cwd(), "build", relativeRuntimePath)
1021
+ ];
1022
+ const cwdParts = process.cwd().split(path.sep);
1023
+ const buildsIndex = cwdParts.lastIndexOf("builds");
1024
+ if (buildsIndex > 0) {
1025
+ const projectRoot = cwdParts.slice(0, buildsIndex).join(path.sep) || path.sep;
1026
+ runtimeCandidates.push(path.resolve(projectRoot, "build", relativeRuntimePath));
1027
+ }
1028
+
1029
+ const runtimeCandidate = runtimeCandidates.find((candidatePath) => fs.existsSync(candidatePath));
1030
+ if (runtimeCandidate) {
1031
+ return runtimeCandidate;
1032
+ }
980
1033
  }
981
1034
  }
982
1035
 
@@ -1666,6 +1719,7 @@ function createNodeRequestHandler(options) {
1666
1719
  request: requestContext
1667
1720
  })
1668
1721
  );
1722
+ attachResolvedContextToCoreRequest(req, resolved2.context);
1669
1723
  const payload = {
1670
1724
  model: resolved2.model,
1671
1725
  contextModel: resolved2.contextModel,
@@ -1740,6 +1794,7 @@ function createNodeRequestHandler(options) {
1740
1794
  )
1741
1795
  })
1742
1796
  );
1797
+ attachResolvedContextToCoreRequest(req, resolved.context);
1743
1798
  const initialPayload = {
1744
1799
  model: resolved.model,
1745
1800
  head: resolved.head
@@ -2021,7 +2076,13 @@ function registerRouteRenderer(route, methodName) {
2021
2076
  `Route.${methodName} only supports node/http requests`
2022
2077
  );
2023
2078
  }
2024
- await handleNodeRequest(req.message, res.res);
2079
+ const message = req.message;
2080
+ message.__webframezCoreRequest = req;
2081
+ try {
2082
+ await handleNodeRequest(message, res.res);
2083
+ } finally {
2084
+ delete message.__webframezCoreRequest;
2085
+ }
2025
2086
  await waitForResponseFinish(res.res);
2026
2087
  },
2027
2088
  routeOptions
package/dist/index.js CHANGED
@@ -632,7 +632,8 @@ function createFileRouter(options) {
632
632
  model: fallback,
633
633
  head: {
634
634
  title: `${statusCode} - ${message}`
635
- }
635
+ },
636
+ context: errorProps
636
637
  };
637
638
  }
638
639
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -647,7 +648,8 @@ function createFileRouter(options) {
647
648
  model,
648
649
  contextModel,
649
650
  pageModel: errorNode,
650
- head: mergeHead(layoutHead, errorHead)
651
+ head: mergeHead(layoutHead, errorHead),
652
+ context: errorProps
651
653
  };
652
654
  }
653
655
  function normalizeMiddlewareNames(config) {
@@ -772,7 +774,8 @@ function createFileRouter(options) {
772
774
  model,
773
775
  contextModel,
774
776
  pageModel: pageNode,
775
- head: mergeHead(layoutHead, pageHead)
777
+ head: mergeHead(layoutHead, pageHead),
778
+ context: pageContext
776
779
  };
777
780
  } catch (error) {
778
781
  if (isRouteAbort(error)) {
@@ -802,6 +805,38 @@ import {
802
805
  createGzip,
803
806
  gzipSync
804
807
  } from "node:zlib";
808
+ function attachResolvedContextToCoreRequest(req, context) {
809
+ if (!context) {
810
+ return;
811
+ }
812
+ const coreRequest = req.__webframezCoreRequest;
813
+ if (!coreRequest) {
814
+ return;
815
+ }
816
+ const data = context.data && typeof context.data === "object" ? context.data : void 0;
817
+ const env = data?.env;
818
+ const website = data?.website;
819
+ coreRequest.__webframezReactContext = {
820
+ pathname: context.pathname,
821
+ params: context.params,
822
+ request: context.request,
823
+ data: data ? {
824
+ env,
825
+ website,
826
+ is_env_website_request: data.is_env_website_request,
827
+ is_website_domain_request: data.is_website_domain_request,
828
+ website_base_path: data.website_base_path,
829
+ website_route_base_path: data.website_route_base_path,
830
+ website_transport_base_path: data.website_transport_base_path
831
+ } : void 0
832
+ };
833
+ if (!coreRequest.env && env) {
834
+ coreRequest.env = env;
835
+ }
836
+ if (!coreRequest.website && website) {
837
+ coreRequest.website = website;
838
+ }
839
+ }
805
840
  function createInitialHtmlErrorMarkup(message) {
806
841
  return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
807
842
  }
@@ -936,13 +971,31 @@ globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
936
971
  };
937
972
  function normalizeWebframezRequireCandidate(candidate) {
938
973
  const stagingMarker = path.join(".webframez-build", "");
939
- const appMarker = path.join("app", "");
974
+ const runtimeMarkers = [path.join("app", ""), path.join("modules", "")];
940
975
  const stagingIndex = candidate.indexOf(stagingMarker);
941
- const appIndex = candidate.indexOf(appMarker, stagingIndex >= 0 ? stagingIndex : 0);
942
- if (stagingIndex >= 0 && appIndex >= 0) {
943
- const runtimeCandidate = path.resolve(process.cwd(), candidate.slice(appIndex));
944
- if (fs.existsSync(runtimeCandidate)) {
945
- return runtimeCandidate;
976
+ if (stagingIndex >= 0) {
977
+ for (const runtimeMarker of runtimeMarkers) {
978
+ const markerIndex = candidate.indexOf(runtimeMarker, stagingIndex);
979
+ if (markerIndex < 0) {
980
+ continue;
981
+ }
982
+
983
+ const relativeRuntimePath = candidate.slice(markerIndex);
984
+ const runtimeCandidates = [
985
+ path.resolve(process.cwd(), relativeRuntimePath),
986
+ path.resolve(process.cwd(), "build", relativeRuntimePath)
987
+ ];
988
+ const cwdParts = process.cwd().split(path.sep);
989
+ const buildsIndex = cwdParts.lastIndexOf("builds");
990
+ if (buildsIndex > 0) {
991
+ const projectRoot = cwdParts.slice(0, buildsIndex).join(path.sep) || path.sep;
992
+ runtimeCandidates.push(path.resolve(projectRoot, "build", relativeRuntimePath));
993
+ }
994
+
995
+ const runtimeCandidate = runtimeCandidates.find((candidatePath) => fs.existsSync(candidatePath));
996
+ if (runtimeCandidate) {
997
+ return runtimeCandidate;
998
+ }
946
999
  }
947
1000
  }
948
1001
 
@@ -1632,6 +1685,7 @@ function createNodeRequestHandler(options) {
1632
1685
  request: requestContext
1633
1686
  })
1634
1687
  );
1688
+ attachResolvedContextToCoreRequest(req, resolved2.context);
1635
1689
  const payload = {
1636
1690
  model: resolved2.model,
1637
1691
  contextModel: resolved2.contextModel,
@@ -1706,6 +1760,7 @@ function createNodeRequestHandler(options) {
1706
1760
  )
1707
1761
  })
1708
1762
  );
1763
+ attachResolvedContextToCoreRequest(req, resolved.context);
1709
1764
  const initialPayload = {
1710
1765
  model: resolved.model,
1711
1766
  head: resolved.head
@@ -1987,7 +2042,13 @@ function registerRouteRenderer(route, methodName) {
1987
2042
  `Route.${methodName} only supports node/http requests`
1988
2043
  );
1989
2044
  }
1990
- await handleNodeRequest(req.message, res.res);
2045
+ const message = req.message;
2046
+ message.__webframezCoreRequest = req;
2047
+ try {
2048
+ await handleNodeRequest(message, res.res);
2049
+ } finally {
2050
+ delete message.__webframezCoreRequest;
2051
+ }
1991
2052
  await waitForResponseFinish(res.res);
1992
2053
  },
1993
2054
  routeOptions
package/dist/router.cjs CHANGED
@@ -520,7 +520,8 @@ function createFileRouter(options) {
520
520
  model: fallback,
521
521
  head: {
522
522
  title: `${statusCode} - ${message}`
523
- }
523
+ },
524
+ context: errorProps
524
525
  };
525
526
  }
526
527
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -535,7 +536,8 @@ function createFileRouter(options) {
535
536
  model,
536
537
  contextModel,
537
538
  pageModel: errorNode,
538
- head: mergeHead(layoutHead, errorHead)
539
+ head: mergeHead(layoutHead, errorHead),
540
+ context: errorProps
539
541
  };
540
542
  }
541
543
  function normalizeMiddlewareNames(config) {
@@ -660,7 +662,8 @@ function createFileRouter(options) {
660
662
  model,
661
663
  contextModel,
662
664
  pageModel: pageNode,
663
- head: mergeHead(layoutHead, pageHead)
665
+ head: mergeHead(layoutHead, pageHead),
666
+ context: pageContext
664
667
  };
665
668
  } catch (error) {
666
669
  if (isRouteAbort(error)) {
package/dist/router.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import type { ReactNode } from "react";
2
- import type { HeadConfig, RouteSearchParams } from "./types";
2
+ import type { HeadConfig, RouteContext, RouteRequestContext, RouteSearchParams } from "./types";
3
3
 
4
4
  export type ResolvedRoute = {
5
5
  statusCode: number;
6
6
  model: ReactNode;
7
7
  head: HeadConfig;
8
+ context: RouteContext;
8
9
  contextModel?: ReactNode;
9
10
  pageModel?: ReactNode;
10
11
  };
@@ -14,6 +15,7 @@ export function createFileRouter(options: { pagesDir: string }): {
14
15
  pathname: string;
15
16
  searchParams: RouteSearchParams;
16
17
  cookies?: Record<string, string>;
18
+ request?: RouteRequestContext;
17
19
  }): Promise<ResolvedRoute>;
18
20
  readSearchParams(urlSearchParams: URLSearchParams): RouteSearchParams;
19
21
  };
package/dist/router.js CHANGED
@@ -490,7 +490,8 @@ function createFileRouter(options) {
490
490
  model: fallback,
491
491
  head: {
492
492
  title: `${statusCode} - ${message}`
493
- }
493
+ },
494
+ context: errorProps
494
495
  };
495
496
  }
496
497
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -505,7 +506,8 @@ function createFileRouter(options) {
505
506
  model,
506
507
  contextModel,
507
508
  pageModel: errorNode,
508
- head: mergeHead(layoutHead, errorHead)
509
+ head: mergeHead(layoutHead, errorHead),
510
+ context: errorProps
509
511
  };
510
512
  }
511
513
  function normalizeMiddlewareNames(config) {
@@ -630,7 +632,8 @@ function createFileRouter(options) {
630
632
  model,
631
633
  contextModel,
632
634
  pageModel: pageNode,
633
- head: mergeHead(layoutHead, pageHead)
635
+ head: mergeHead(layoutHead, pageHead),
636
+ context: pageContext
634
637
  };
635
638
  } catch (error) {
636
639
  if (isRouteAbort(error)) {
@@ -643,7 +643,8 @@ function createFileRouter(options) {
643
643
  model: fallback,
644
644
  head: {
645
645
  title: `${statusCode} - ${message}`
646
- }
646
+ },
647
+ context: errorProps
647
648
  };
648
649
  }
649
650
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -658,7 +659,8 @@ function createFileRouter(options) {
658
659
  model,
659
660
  contextModel,
660
661
  pageModel: errorNode,
661
- head: mergeHead(layoutHead, errorHead)
662
+ head: mergeHead(layoutHead, errorHead),
663
+ context: errorProps
662
664
  };
663
665
  }
664
666
  function normalizeMiddlewareNames(config) {
@@ -783,7 +785,8 @@ function createFileRouter(options) {
783
785
  model,
784
786
  contextModel,
785
787
  pageModel: pageNode,
786
- head: mergeHead(layoutHead, pageHead)
788
+ head: mergeHead(layoutHead, pageHead),
789
+ context: pageContext
787
790
  };
788
791
  } catch (error) {
789
792
  if (isRouteAbort(error)) {
@@ -803,6 +806,38 @@ function parseSearchParams(query) {
803
806
  }
804
807
 
805
808
  // src/http.ts
809
+ function attachResolvedContextToCoreRequest(req, context) {
810
+ if (!context) {
811
+ return;
812
+ }
813
+ const coreRequest = req.__webframezCoreRequest;
814
+ if (!coreRequest) {
815
+ return;
816
+ }
817
+ const data = context.data && typeof context.data === "object" ? context.data : void 0;
818
+ const env = data?.env;
819
+ const website = data?.website;
820
+ coreRequest.__webframezReactContext = {
821
+ pathname: context.pathname,
822
+ params: context.params,
823
+ request: context.request,
824
+ data: data ? {
825
+ env,
826
+ website,
827
+ is_env_website_request: data.is_env_website_request,
828
+ is_website_domain_request: data.is_website_domain_request,
829
+ website_base_path: data.website_base_path,
830
+ website_route_base_path: data.website_route_base_path,
831
+ website_transport_base_path: data.website_transport_base_path
832
+ } : void 0
833
+ };
834
+ if (!coreRequest.env && env) {
835
+ coreRequest.env = env;
836
+ }
837
+ if (!coreRequest.website && website) {
838
+ coreRequest.website = website;
839
+ }
840
+ }
806
841
  function createInitialHtmlErrorMarkup(message) {
807
842
  return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
808
843
  }
@@ -937,13 +972,31 @@ globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
937
972
  };
938
973
  function normalizeWebframezRequireCandidate(candidate) {
939
974
  const stagingMarker = path.join(".webframez-build", "");
940
- const appMarker = path.join("app", "");
975
+ const runtimeMarkers = [path.join("app", ""), path.join("modules", "")];
941
976
  const stagingIndex = candidate.indexOf(stagingMarker);
942
- const appIndex = candidate.indexOf(appMarker, stagingIndex >= 0 ? stagingIndex : 0);
943
- if (stagingIndex >= 0 && appIndex >= 0) {
944
- const runtimeCandidate = path.resolve(process.cwd(), candidate.slice(appIndex));
945
- if (fs.existsSync(runtimeCandidate)) {
946
- return runtimeCandidate;
977
+ if (stagingIndex >= 0) {
978
+ for (const runtimeMarker of runtimeMarkers) {
979
+ const markerIndex = candidate.indexOf(runtimeMarker, stagingIndex);
980
+ if (markerIndex < 0) {
981
+ continue;
982
+ }
983
+
984
+ const relativeRuntimePath = candidate.slice(markerIndex);
985
+ const runtimeCandidates = [
986
+ path.resolve(process.cwd(), relativeRuntimePath),
987
+ path.resolve(process.cwd(), "build", relativeRuntimePath)
988
+ ];
989
+ const cwdParts = process.cwd().split(path.sep);
990
+ const buildsIndex = cwdParts.lastIndexOf("builds");
991
+ if (buildsIndex > 0) {
992
+ const projectRoot = cwdParts.slice(0, buildsIndex).join(path.sep) || path.sep;
993
+ runtimeCandidates.push(path.resolve(projectRoot, "build", relativeRuntimePath));
994
+ }
995
+
996
+ const runtimeCandidate = runtimeCandidates.find((candidatePath) => fs.existsSync(candidatePath));
997
+ if (runtimeCandidate) {
998
+ return runtimeCandidate;
999
+ }
947
1000
  }
948
1001
  }
949
1002
 
@@ -1633,6 +1686,7 @@ function createNodeRequestHandler(options) {
1633
1686
  request: requestContext
1634
1687
  })
1635
1688
  );
1689
+ attachResolvedContextToCoreRequest(req, resolved2.context);
1636
1690
  const payload = {
1637
1691
  model: resolved2.model,
1638
1692
  contextModel: resolved2.contextModel,
@@ -1707,6 +1761,7 @@ function createNodeRequestHandler(options) {
1707
1761
  )
1708
1762
  })
1709
1763
  );
1764
+ attachResolvedContextToCoreRequest(req, resolved.context);
1710
1765
  const initialPayload = {
1711
1766
  model: resolved.model,
1712
1767
  head: resolved.head
@@ -1987,7 +2042,13 @@ function registerRouteRenderer(route, methodName) {
1987
2042
  `Route.${methodName} only supports node/http requests`
1988
2043
  );
1989
2044
  }
1990
- await handleNodeRequest(req.message, res.res);
2045
+ const message = req.message;
2046
+ message.__webframezCoreRequest = req;
2047
+ try {
2048
+ await handleNodeRequest(message, res.res);
2049
+ } finally {
2050
+ delete message.__webframezCoreRequest;
2051
+ }
1991
2052
  await waitForResponseFinish(res.res);
1992
2053
  },
1993
2054
  routeOptions
@@ -619,7 +619,8 @@ function createFileRouter(options) {
619
619
  model: fallback,
620
620
  head: {
621
621
  title: `${statusCode} - ${message}`
622
- }
622
+ },
623
+ context: errorProps
623
624
  };
624
625
  }
625
626
  const errorModule = resolveModule(errorPath, pagesDir);
@@ -634,7 +635,8 @@ function createFileRouter(options) {
634
635
  model,
635
636
  contextModel,
636
637
  pageModel: errorNode,
637
- head: mergeHead(layoutHead, errorHead)
638
+ head: mergeHead(layoutHead, errorHead),
639
+ context: errorProps
638
640
  };
639
641
  }
640
642
  function normalizeMiddlewareNames(config) {
@@ -759,7 +761,8 @@ function createFileRouter(options) {
759
761
  model,
760
762
  contextModel,
761
763
  pageModel: pageNode,
762
- head: mergeHead(layoutHead, pageHead)
764
+ head: mergeHead(layoutHead, pageHead),
765
+ context: pageContext
763
766
  };
764
767
  } catch (error) {
765
768
  if (isRouteAbort(error)) {
@@ -779,6 +782,38 @@ function parseSearchParams(query) {
779
782
  }
780
783
 
781
784
  // src/http.ts
785
+ function attachResolvedContextToCoreRequest(req, context) {
786
+ if (!context) {
787
+ return;
788
+ }
789
+ const coreRequest = req.__webframezCoreRequest;
790
+ if (!coreRequest) {
791
+ return;
792
+ }
793
+ const data = context.data && typeof context.data === "object" ? context.data : void 0;
794
+ const env = data?.env;
795
+ const website = data?.website;
796
+ coreRequest.__webframezReactContext = {
797
+ pathname: context.pathname,
798
+ params: context.params,
799
+ request: context.request,
800
+ data: data ? {
801
+ env,
802
+ website,
803
+ is_env_website_request: data.is_env_website_request,
804
+ is_website_domain_request: data.is_website_domain_request,
805
+ website_base_path: data.website_base_path,
806
+ website_route_base_path: data.website_route_base_path,
807
+ website_transport_base_path: data.website_transport_base_path
808
+ } : void 0
809
+ };
810
+ if (!coreRequest.env && env) {
811
+ coreRequest.env = env;
812
+ }
813
+ if (!coreRequest.website && website) {
814
+ coreRequest.website = website;
815
+ }
816
+ }
782
817
  function createInitialHtmlErrorMarkup(message) {
783
818
  return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
784
819
  }
@@ -913,13 +948,31 @@ globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
913
948
  };
914
949
  function normalizeWebframezRequireCandidate(candidate) {
915
950
  const stagingMarker = path.join(".webframez-build", "");
916
- const appMarker = path.join("app", "");
951
+ const runtimeMarkers = [path.join("app", ""), path.join("modules", "")];
917
952
  const stagingIndex = candidate.indexOf(stagingMarker);
918
- const appIndex = candidate.indexOf(appMarker, stagingIndex >= 0 ? stagingIndex : 0);
919
- if (stagingIndex >= 0 && appIndex >= 0) {
920
- const runtimeCandidate = path.resolve(process.cwd(), candidate.slice(appIndex));
921
- if (fs.existsSync(runtimeCandidate)) {
922
- return runtimeCandidate;
953
+ if (stagingIndex >= 0) {
954
+ for (const runtimeMarker of runtimeMarkers) {
955
+ const markerIndex = candidate.indexOf(runtimeMarker, stagingIndex);
956
+ if (markerIndex < 0) {
957
+ continue;
958
+ }
959
+
960
+ const relativeRuntimePath = candidate.slice(markerIndex);
961
+ const runtimeCandidates = [
962
+ path.resolve(process.cwd(), relativeRuntimePath),
963
+ path.resolve(process.cwd(), "build", relativeRuntimePath)
964
+ ];
965
+ const cwdParts = process.cwd().split(path.sep);
966
+ const buildsIndex = cwdParts.lastIndexOf("builds");
967
+ if (buildsIndex > 0) {
968
+ const projectRoot = cwdParts.slice(0, buildsIndex).join(path.sep) || path.sep;
969
+ runtimeCandidates.push(path.resolve(projectRoot, "build", relativeRuntimePath));
970
+ }
971
+
972
+ const runtimeCandidate = runtimeCandidates.find((candidatePath) => fs.existsSync(candidatePath));
973
+ if (runtimeCandidate) {
974
+ return runtimeCandidate;
975
+ }
923
976
  }
924
977
  }
925
978
 
@@ -1609,6 +1662,7 @@ function createNodeRequestHandler(options) {
1609
1662
  request: requestContext
1610
1663
  })
1611
1664
  );
1665
+ attachResolvedContextToCoreRequest(req, resolved2.context);
1612
1666
  const payload = {
1613
1667
  model: resolved2.model,
1614
1668
  contextModel: resolved2.contextModel,
@@ -1683,6 +1737,7 @@ function createNodeRequestHandler(options) {
1683
1737
  )
1684
1738
  })
1685
1739
  );
1740
+ attachResolvedContextToCoreRequest(req, resolved.context);
1686
1741
  const initialPayload = {
1687
1742
  model: resolved.model,
1688
1743
  head: resolved.head
@@ -1963,7 +2018,13 @@ function registerRouteRenderer(route, methodName) {
1963
2018
  `Route.${methodName} only supports node/http requests`
1964
2019
  );
1965
2020
  }
1966
- await handleNodeRequest(req.message, res.res);
2021
+ const message = req.message;
2022
+ message.__webframezCoreRequest = req;
2023
+ try {
2024
+ await handleNodeRequest(message, res.res);
2025
+ } finally {
2026
+ delete message.__webframezCoreRequest;
2027
+ }
1967
2028
  await waitForResponseFinish(res.res);
1968
2029
  },
1969
2030
  routeOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-react",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "TypeScript React RSC addition for @webtypen/webframez-core",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "author": {