@webtypen/webframez-react 0.0.48 → 0.0.50

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/index.cjs CHANGED
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
7
10
  var __export = (target, all) => {
8
11
  for (var name in all)
9
12
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,6 +29,60 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
29
  ));
27
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
31
 
32
+ // node_modules/@webtypen/webframez-core/dist/routing.js
33
+ var require_routing = __commonJS({
34
+ "node_modules/@webtypen/webframez-core/dist/routing.js"(exports2) {
35
+ "use strict";
36
+ Object.defineProperty(exports2, "__esModule", { value: true });
37
+ exports2.appRelativePath = exports2.appPath = exports2.getBasename = exports2.normalizeBasename = void 0;
38
+ function normalizeBasename2(value) {
39
+ if (value == null || value === "" || value === "/")
40
+ return "";
41
+ if (typeof value !== "string")
42
+ throw new Error("Router basename must be a string.");
43
+ const base = value.trim().replace(/\/+$/, "");
44
+ if (!base && value.trim().length <= 1)
45
+ return "";
46
+ if (!/^\/(?:[A-Za-z0-9_~-]+(?:\.[A-Za-z0-9_~-]+)*)(?:\/[A-Za-z0-9_~-]+(?:\.[A-Za-z0-9_~-]+)*)*$/.test(base)) {
47
+ throw new Error("Router basename must be empty or an absolute path such as /my-app.");
48
+ }
49
+ return base;
50
+ }
51
+ exports2.normalizeBasename = normalizeBasename2;
52
+ function getBasename2() {
53
+ var _a, _b, _c, _d;
54
+ const runtime = globalThis;
55
+ return (_d = (_c = (_b = (_a = runtime.__WEBFRAMEZ_ROUTING_CONTEXT__) === null || _a === void 0 ? void 0 : _a.getStore()) !== null && _b !== void 0 ? _b : runtime.__RSC_BASENAME) !== null && _c !== void 0 ? _c : runtime.__WEBFRAMEZ_ROUTER_BASENAME__) !== null && _d !== void 0 ? _d : "";
56
+ }
57
+ exports2.getBasename = getBasename2;
58
+ function appPath2(value, basename = getBasename2()) {
59
+ const base = normalizeBasename2(basename);
60
+ if (!base || !value.startsWith("/") || value.startsWith("//") || hasBasename(value, base))
61
+ return value;
62
+ return base + value;
63
+ }
64
+ exports2.appPath = appPath2;
65
+ function appRelativePath2(value, basename = getBasename2()) {
66
+ const base = normalizeBasename2(basename);
67
+ if (!base || !hasBasename(value, base))
68
+ return value;
69
+ const relative = value.slice(base.length);
70
+ return !relative || relative.startsWith("?") || relative.startsWith("#") ? "/" + relative : relative;
71
+ }
72
+ exports2.appRelativePath = appRelativePath2;
73
+ function hasBasename(value, base) {
74
+ return value === base || value.startsWith(base + "/") || value.startsWith(base + "?") || value.startsWith(base + "#");
75
+ }
76
+ }
77
+ });
78
+
79
+ // node_modules/@webtypen/webframez-core/routing.js
80
+ var require_routing2 = __commonJS({
81
+ "node_modules/@webtypen/webframez-core/routing.js"(exports2, module2) {
82
+ module2.exports = require_routing();
83
+ }
84
+ });
85
+
29
86
  // src/index.ts
30
87
  var src_exports = {};
31
88
  __export(src_exports, {
@@ -35,10 +92,12 @@ __export(src_exports, {
35
92
  createHTMLShell: () => createHTMLShell,
36
93
  createNodeRequestHandler: () => createNodeRequestHandler,
37
94
  createRSCHandler: () => createRSCHandler,
95
+ disposeReactHtmlRenderer: () => disposeReactHtmlRenderer,
38
96
  getRegisteredReactBuildTargets: () => getRegisteredReactBuildTargets,
39
97
  initWebframezReact: () => initWebframezReact,
40
98
  parseSearchParams: () => parseSearchParams,
41
99
  renderHeadToString: () => renderHeadToString,
100
+ renderReactToHtml: () => renderReactToHtml,
42
101
  resolveWebframezReactRouteOptions: () => resolveWebframezReactRouteOptions,
43
102
  sendRSC: () => sendRSC,
44
103
  setupWebframezCoreReactRoute: () => setupWebframezCoreReactRoute
@@ -62,6 +121,8 @@ function createHTMLShell(options = {}) {
62
121
  buildId = "",
63
122
  headTags = "",
64
123
  bodyClassName = "",
124
+ bodyStartHtml = "",
125
+ bodyEndHtml = "",
65
126
  rootHtml = "",
66
127
  initialFlightData = "",
67
128
  basename = "",
@@ -111,7 +172,9 @@ function createHTMLShell(options = {}) {
111
172
  ${headTags}
112
173
  </head>
113
174
  <body${bodyClassName ? ` class="${bodyClassName.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}"` : ""}>
175
+ ${bodyStartHtml}
114
176
  <div id="root">${rootHtml}</div>
177
+ ${bodyEndHtml}
115
178
  <script>window.__RSC_ENDPOINT = "${rscEndpoint}";</script>
116
179
  <script>window.__RSC_BASENAME = "${basename}";</script>
117
180
  <script>window.__RSC_ROUTE_BASE_PATH = "${routeBasePath}";</script>
@@ -254,6 +317,12 @@ function normalizeHeadConfig(head, inheritedBasename) {
254
317
  href: resolveHeadAssetUrl(link.href, effectiveBasename)
255
318
  }));
256
319
  }
320
+ if (normalizedHead.scripts) {
321
+ normalizedHead.scripts = normalizedHead.scripts.map((script) => ({
322
+ ...script,
323
+ ...script.src ? { src: resolveHeadAssetUrl(script.src, effectiveBasename) } : {}
324
+ }));
325
+ }
257
326
  return normalizedHead;
258
327
  }
259
328
 
@@ -366,8 +435,7 @@ var FORCED_PACKAGE_REQUESTS = [
366
435
  "react-server-dom-webpack",
367
436
  "react-server-dom-webpack/server",
368
437
  "react-server-dom-webpack/client",
369
- "react-server-dom-webpack/client.node",
370
- "scheduler"
438
+ "react-server-dom-webpack/client.node"
371
439
  ];
372
440
  var forcedPackageResolutionInstalled = false;
373
441
  function normalizePathname(pathname) {
@@ -506,7 +574,9 @@ function matchRoute(entry, pathname) {
506
574
  function mergeHead(...configs) {
507
575
  const merged = {
508
576
  meta: [],
509
- links: []
577
+ links: [],
578
+ scripts: [],
579
+ html: []
510
580
  };
511
581
  for (const candidate of configs) {
512
582
  const config = normalizeHeadConfig(candidate, merged.basename);
@@ -541,9 +611,28 @@ function mergeHead(...configs) {
541
611
  if (config.links) {
542
612
  merged.links?.push(...config.links);
543
613
  }
614
+ if (config.scripts) {
615
+ merged.scripts?.push(...config.scripts);
616
+ }
617
+ if (config.html) {
618
+ merged.html?.push(...Array.isArray(config.html) ? config.html : [config.html]);
619
+ }
620
+ if (config.bodyStartHtml) {
621
+ merged.bodyStartHtml = [merged.bodyStartHtml, config.bodyStartHtml].filter(Boolean).join("\n");
622
+ }
623
+ if (config.bodyEndHtml) {
624
+ merged.bodyEndHtml = [merged.bodyEndHtml, config.bodyEndHtml].filter(Boolean).join("\n");
625
+ }
544
626
  }
545
627
  return merged;
546
628
  }
629
+ function renderGenericAttributes(entry, excluded = []) {
630
+ return Object.entries(entry).filter(
631
+ ([key, value]) => !excluded.includes(key) && value !== void 0 && value !== null && value !== false
632
+ ).map(
633
+ ([key, value]) => value === true ? key : `${key}="${escapeHtml(String(value))}"`
634
+ ).join(" ");
635
+ }
547
636
  function renderHeadToString(head) {
548
637
  const normalizedHead = normalizeHeadConfig(head) ?? head;
549
638
  const tags = [];
@@ -565,6 +654,23 @@ function renderHeadToString(head) {
565
654
  const attrs = Object.entries(link).filter(([, value]) => Boolean(value)).map(([key, value]) => `${key}="${escapeHtml(String(value))}"`).join(" ");
566
655
  tags.push(`<link ${createManagedAttributes()} ${attrs} />`);
567
656
  }
657
+ for (const script of normalizedHead.scripts ?? []) {
658
+ if (script.html) {
659
+ tags.push(script.html);
660
+ continue;
661
+ }
662
+ const attrs = renderGenericAttributes(script, [
663
+ "content",
664
+ "html"
665
+ ]);
666
+ const content = script.content ? String(script.content) : "";
667
+ tags.push(`<script ${createManagedAttributes()} ${attrs}>${content}</script>`);
668
+ }
669
+ for (const html of normalizedHead.html ?? []) {
670
+ if (typeof html === "string" && html.trim() !== "") {
671
+ tags.push(html);
672
+ }
673
+ }
568
674
  return tags.join("\n");
569
675
  }
570
676
  function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
@@ -650,6 +756,7 @@ function isRouteAbort(value) {
650
756
  function createFileRouter(options) {
651
757
  installForcedPackageResolution();
652
758
  const pagesDir = options.pagesDir;
759
+ const onData = options.onData;
653
760
  const layoutPath = import_node_path2.default.join(pagesDir, "layout.js");
654
761
  const errorPath = import_node_path2.default.join(pagesDir, "errors.js");
655
762
  const middlewaresPath = import_node_path2.default.join(pagesDir, "middlewares.js");
@@ -814,10 +921,16 @@ function createFileRouter(options) {
814
921
  data: mergeRouteData(middlewareContext.data, pageData)
815
922
  };
816
923
  activeContext = pageContext;
817
- const pageNode = await pageModule.default(pageContext);
818
- const layoutHead = layoutModule ? await resolveHead(layoutModule, pageContext) : void 0;
819
- const pageHead = await resolveHead(pageModule, pageContext);
820
- const layoutNode = layoutModule ? await layoutModule.default(pageContext) : null;
924
+ const onDataResult = typeof onData === "function" ? await onData(pageContext) : void 0;
925
+ const eventContext = {
926
+ ...pageContext,
927
+ data: mergeRouteData(pageContext.data, onDataResult)
928
+ };
929
+ activeContext = eventContext;
930
+ const pageNode = await pageModule.default(eventContext);
931
+ const layoutHead = layoutModule ? await resolveHead(layoutModule, eventContext) : void 0;
932
+ const pageHead = await resolveHead(pageModule, eventContext);
933
+ const layoutNode = layoutModule ? await layoutModule.default(eventContext) : null;
821
934
  const model = layoutNode ? injectRouteChildren(layoutNode, pageNode) : pageNode;
822
935
  const contextModel = layoutNode ? injectRouteChildren(layoutNode, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteChildren, {})) : void 0;
823
936
  return {
@@ -826,7 +939,7 @@ function createFileRouter(options) {
826
939
  contextModel,
827
940
  pageModel: pageNode,
828
941
  head: mergeHead(layoutHead, pageHead),
829
- context: pageContext
942
+ context: eventContext
830
943
  };
831
944
  } catch (error) {
832
945
  if (isRouteAbort(error)) {
@@ -846,6 +959,7 @@ function parseSearchParams(query) {
846
959
  }
847
960
 
848
961
  // src/http.ts
962
+ var import_node_async_hooks = require("node:async_hooks");
849
963
  var import_node_fs2 = __toESM(require("node:fs"), 1);
850
964
  var import_node_path3 = __toESM(require("node:path"), 1);
851
965
  var import_node_url = require("node:url");
@@ -978,6 +1092,7 @@ const rootParent = {
978
1092
  path: process.cwd(),
979
1093
  paths: Module._nodeModulePaths(process.cwd()),
980
1094
  };
1095
+ // Transitive dependencies (e.g. scheduler) must resolve from their importer.
981
1096
  const forcedPackageRequests = [
982
1097
  "@webtypen/webframez-core",
983
1098
  "@webtypen/webframez-react",
@@ -992,7 +1107,6 @@ const forcedPackageRequests = [
992
1107
  "react-server-dom-webpack/server",
993
1108
  "react-server-dom-webpack/client",
994
1109
  "react-server-dom-webpack/client.node",
995
- "scheduler"
996
1110
  ];
997
1111
 
998
1112
  function shouldForcePackageResolution(request) {
@@ -1184,13 +1298,17 @@ async function renderHtmlFromFlightData(flightData, moduleMap) {
1184
1298
  ? payload.head.basename
1185
1299
  : "";
1186
1300
 
1187
- const previousBasename = globalThis.__RSC_BASENAME;
1188
- globalThis.__RSC_BASENAME = basename;
1189
- try {
1190
- return await renderHtml(model);
1191
- } finally {
1192
- globalThis.__RSC_BASENAME = previousBasename;
1193
- }
1301
+ const routingContext = globalThis.__WEBFRAMEZ_ROUTING_CONTEXT__ ??=
1302
+ new (require("node:async_hooks").AsyncLocalStorage)();
1303
+ return routingContext.run(basename, async () => {
1304
+ const previousBasename = globalThis.__RSC_BASENAME;
1305
+ globalThis.__RSC_BASENAME = basename;
1306
+ try {
1307
+ return await renderHtml(model);
1308
+ } finally {
1309
+ globalThis.__RSC_BASENAME = previousBasename;
1310
+ }
1311
+ });
1194
1312
  }
1195
1313
 
1196
1314
  process.on("message", async (message) => {
@@ -1426,24 +1544,10 @@ ${stderrBuffer.trim()}` : "";
1426
1544
  }
1427
1545
  };
1428
1546
  }
1547
+ var routingRuntime = globalThis;
1548
+ var basenameContext = routingRuntime.__WEBFRAMEZ_ROUTING_CONTEXT__ ??= new import_node_async_hooks.AsyncLocalStorage();
1429
1549
  function withRequestBasename(basename, fn) {
1430
- const target = globalThis;
1431
- const previous = target.__RSC_BASENAME;
1432
- target.__RSC_BASENAME = basename;
1433
- const finish = () => {
1434
- target.__RSC_BASENAME = previous;
1435
- };
1436
- try {
1437
- const result = fn();
1438
- if (result && typeof result.then === "function") {
1439
- return result.finally(finish);
1440
- }
1441
- finish();
1442
- return result;
1443
- } catch (error) {
1444
- finish();
1445
- throw error;
1446
- }
1550
+ return basenameContext.run(basename, fn);
1447
1551
  }
1448
1552
  function parseCookies(rawCookieHeader) {
1449
1553
  const raw = Array.isArray(rawCookieHeader) ? rawCookieHeader.join("; ") : rawCookieHeader ?? "";
@@ -1478,12 +1582,27 @@ function normalizeClientManifest(manifest, options) {
1478
1582
  }
1479
1583
  };
1480
1584
  for (const [key, value] of Object.entries(manifest)) {
1585
+ const hashIndex = key.indexOf("#");
1586
+ const moduleKey = hashIndex < 0 ? key : key.slice(0, hashIndex);
1587
+ const exportSuffix = hashIndex < 0 ? "" : key.slice(hashIndex);
1588
+ if (!import_node_path3.default.isAbsolute(moduleKey) && !moduleKey.includes(":") && !moduleKey.startsWith("file://")) {
1589
+ const runtimePath = import_node_path3.default.resolve(options.cwd, moduleKey);
1590
+ const allowedRoots = [options.distRootDir, ...candidateNodeModulesDirs];
1591
+ const insideArtifact = allowedRoots.some((root) => {
1592
+ const relative = import_node_path3.default.relative(import_node_path3.default.resolve(root), runtimePath);
1593
+ return relative !== "" && relative !== ".." && !relative.startsWith(`..${import_node_path3.default.sep}`) && !import_node_path3.default.isAbsolute(relative);
1594
+ });
1595
+ if (insideArtifact) {
1596
+ addAlias(`${runtimePath}${exportSuffix}`, value);
1597
+ addAlias(`${(0, import_node_url.pathToFileURL)(runtimePath).href}${exportSuffix}`, value);
1598
+ }
1599
+ }
1481
1600
  if (!key.startsWith("file://")) {
1482
1601
  continue;
1483
1602
  }
1484
1603
  let absolutePath = "";
1485
1604
  try {
1486
- absolutePath = (0, import_node_url.fileURLToPath)(key);
1605
+ absolutePath = (0, import_node_url.fileURLToPath)(moduleKey);
1487
1606
  } catch {
1488
1607
  continue;
1489
1608
  }
@@ -1494,13 +1613,13 @@ function normalizeClientManifest(manifest, options) {
1494
1613
  }
1495
1614
  const relativeModulePath = absolutePath.slice(markerIndex + marker.length);
1496
1615
  const relativeModulePathPosix = relativeModulePath.split(import_node_path3.default.sep).join("/");
1497
- addAlias(`./node_modules/${relativeModulePathPosix}`, value);
1498
- addAlias(`node_modules/${relativeModulePathPosix}`, value);
1499
- addAlias(absolutePath, value);
1616
+ addAlias(`./node_modules/${relativeModulePathPosix}${exportSuffix}`, value);
1617
+ addAlias(`node_modules/${relativeModulePathPosix}${exportSuffix}`, value);
1618
+ addAlias(`${absolutePath}${exportSuffix}`, value);
1500
1619
  for (const nodeModulesDir of candidateNodeModulesDirs) {
1501
1620
  const aliasPath = import_node_path3.default.join(nodeModulesDir, relativeModulePath);
1502
- addAlias(aliasPath, value);
1503
- addAlias((0, import_node_url.pathToFileURL)(aliasPath).href, value);
1621
+ addAlias(`${aliasPath}${exportSuffix}`, value);
1622
+ addAlias(`${(0, import_node_url.pathToFileURL)(aliasPath).href}${exportSuffix}`, value);
1504
1623
  }
1505
1624
  }
1506
1625
  return normalized;
@@ -1645,16 +1764,16 @@ function createNodeRequestHandler(options) {
1645
1764
  const manifestPath = import_node_path3.default.resolve(
1646
1765
  options.manifestPath ?? import_node_path3.default.join(distRootDir, "react-client-manifest.json")
1647
1766
  );
1648
- const assetsPrefix = options.assetsPrefix ?? "/assets/";
1649
- const rscPath = options.rscPath ?? "/rsc";
1650
- const clientScriptUrl = options.clientScriptUrl ?? "/assets/client.js";
1651
1767
  const basePath = normalizeBasePath(options.basePath);
1768
+ const assetsPrefix = options.assetsPrefix ?? `${basePath}/assets/`;
1769
+ const rscPath = options.rscPath ?? `${basePath}/rsc`;
1770
+ const clientScriptUrl = options.clientScriptUrl ?? `${basePath}/assets/client.js`;
1652
1771
  const nodeEnv = process.env.NODE_ENV || "";
1653
1772
  const runningInWatchMode = Array.isArray(process.execArgv) && process.execArgv.includes("--watch");
1654
1773
  const liveReloadEnabled = options.liveReloadPath !== false && (nodeEnv === "development" || runningInWatchMode);
1655
1774
  const liveReloadPath = !liveReloadEnabled ? "" : options.liveReloadPath ?? `${basePath || ""}/__webframez_live_reload`;
1656
1775
  const liveReloadClients = /* @__PURE__ */ new Set();
1657
- const router = createFileRouter({ pagesDir });
1776
+ const router = createFileRouter({ pagesDir, onData: options.onData });
1658
1777
  const getManifestState = createManifestLoader({
1659
1778
  distRootDir,
1660
1779
  manifestPath,
@@ -1667,7 +1786,7 @@ function createNodeRequestHandler(options) {
1667
1786
  process.once("exit", disposeInitialHtmlWorker);
1668
1787
  process.once("SIGINT", disposeInitialHtmlWorker);
1669
1788
  process.once("SIGTERM", disposeInitialHtmlWorker);
1670
- return async function handleRequest(req, res) {
1789
+ const handleRequest = async (req, res) => {
1671
1790
  if (!req.url) {
1672
1791
  res.statusCode = 400;
1673
1792
  res.end("Bad request");
@@ -1731,6 +1850,7 @@ function createNodeRequestHandler(options) {
1731
1850
  request: requestContext
1732
1851
  })
1733
1852
  );
1853
+ resolved2.head = { ...resolved2.head, basename: resolved2.head.basename ?? basePath };
1734
1854
  attachResolvedContextToCoreRequest(req, resolved2.context);
1735
1855
  const payload = {
1736
1856
  model: resolved2.model,
@@ -1806,6 +1926,7 @@ function createNodeRequestHandler(options) {
1806
1926
  )
1807
1927
  })
1808
1928
  );
1929
+ resolved.head = { ...resolved.head, basename: resolved.head.basename ?? basePath };
1809
1930
  attachResolvedContextToCoreRequest(req, resolved.context);
1810
1931
  const initialPayload = {
1811
1932
  model: resolved.model,
@@ -1878,6 +1999,8 @@ function createNodeRequestHandler(options) {
1878
1999
  initialFlightData,
1879
2000
  basename: shellBasename,
1880
2001
  routeBasePath: shellRouteBasePath,
2002
+ bodyStartHtml: resolved.head.bodyStartHtml || "",
2003
+ bodyEndHtml: resolved.head.bodyEndHtml || "",
1881
2004
  liveReloadPath: liveReloadPath || void 0,
1882
2005
  liveReloadServerId: liveReloadPath ? devServerId : void 0
1883
2006
  }),
@@ -1889,7 +2012,30 @@ function createNodeRequestHandler(options) {
1889
2012
  }
1890
2013
  );
1891
2014
  };
2015
+ return (req, res) => withRequestBasename(basePath, () => handleRequest(req, res));
1892
2016
  }
2017
+ var standaloneHtmlWorker;
2018
+ async function renderReactToHtml(element) {
2019
+ if (!standaloneHtmlWorker) {
2020
+ standaloneHtmlWorker = createInitialHtmlWorker(process.cwd());
2021
+ process.once("exit", disposeReactHtmlRenderer);
2022
+ }
2023
+ const flightData = await renderRSCToString({ model: element }, {
2024
+ moduleMap: {},
2025
+ onError: (error) => {
2026
+ console.error("[webframez-react] HTML render failed", error);
2027
+ }
2028
+ });
2029
+ return standaloneHtmlWorker.renderFromFlightData({ flightData, moduleMap: {} });
2030
+ }
2031
+ function disposeReactHtmlRenderer() {
2032
+ process.removeListener("exit", disposeReactHtmlRenderer);
2033
+ standaloneHtmlWorker?.dispose();
2034
+ standaloneHtmlWorker = void 0;
2035
+ }
2036
+
2037
+ // src/paths.ts
2038
+ var import_routing = __toESM(require_routing2(), 1);
1893
2039
 
1894
2040
  // src/webframez-core.ts
1895
2041
  var import_node_path4 = __toESM(require("node:path"), 1);
@@ -1978,6 +2124,17 @@ function buildRenderDefaults(routePathValue) {
1978
2124
  clientScriptUrl: `${mountPath}/assets/client.js`
1979
2125
  };
1980
2126
  }
2127
+ function runtimeRoutePaths(routePath, options, basename = (0, import_routing.getBasename)(), groupPrefix = "") {
2128
+ const localMount = normalizeMountPath(options.basePath ?? `${groupPrefix}${normalizeMountPath(routePath)}`);
2129
+ const basePath = normalizeMountPath((0, import_routing.appPath)(localMount, basename)).replace(/\/$/, "");
2130
+ return {
2131
+ basePath,
2132
+ assetsPrefix: options.assetsPrefix !== void 0 ? (0, import_routing.appPath)(options.assetsPrefix, basename) : `${basePath}/assets/`,
2133
+ rscPath: options.rscPath !== void 0 ? (0, import_routing.appPath)(options.rscPath, basename) : `${basePath}/rsc`,
2134
+ clientScriptUrl: options.clientScriptUrl !== void 0 ? (0, import_routing.appPath)(options.clientScriptUrl, basename) : `${basePath}/assets/client.js`,
2135
+ ...typeof options.liveReloadPath === "string" ? { liveReloadPath: (0, import_routing.appPath)(options.liveReloadPath, basename) } : {}
2136
+ };
2137
+ }
1981
2138
  async function waitForResponseFinish(res) {
1982
2139
  if (res.writableEnded || res.destroyed) {
1983
2140
  return;
@@ -2071,10 +2228,7 @@ function registerRouteRenderer(route, methodName) {
2071
2228
  distRootDir: resolvedTarget.distRootDir,
2072
2229
  pagesDir: resolvedTarget.pagesDir,
2073
2230
  manifestPath: resolvedTarget.manifestPath,
2074
- basePath: basePath ?? defaults.basePath,
2075
- assetsPrefix: assetsPrefix ?? defaults.assetsPrefix,
2076
- rscPath: rscPath ?? defaults.rscPath,
2077
- clientScriptUrl: clientScriptUrl ?? defaults.clientScriptUrl
2231
+ ...runtimeRoutePaths(routePathValue, options, route.basename ?? (0, import_routing.getBasename)(), route.tempGroupPrefix ?? "")
2078
2232
  });
2079
2233
  const methods = normalizeMethods(method);
2080
2234
  for (const currentMethod of methods) {
@@ -2116,13 +2270,11 @@ function resolveWebframezReactRouteOptions(routePathValue, options = {}) {
2116
2270
  distRootDir,
2117
2271
  pagesDir,
2118
2272
  manifestPath,
2119
- assetsPrefix: options.assetsPrefix ?? defaults.assetsPrefix,
2120
- rscPath: options.rscPath ?? defaults.rscPath,
2121
- clientScriptUrl: options.clientScriptUrl ?? defaults.clientScriptUrl,
2273
+ ...runtimeRoutePaths(routePathValue, options),
2122
2274
  clientEntryPath: options.clientEntryPath ? resolveFromProjectRoot(options.clientEntryPath) : void 0,
2123
2275
  styleSrcPath: options.styleSrcPath ? resolveFromProjectRoot(options.styleSrcPath) : defaults.styleSrcPath,
2124
- basePath: options.basePath ?? defaults.basePath,
2125
- liveReloadPath: options.liveReloadPath
2276
+ liveReloadPath: typeof options.liveReloadPath === "string" ? (0, import_routing.appPath)(options.liveReloadPath) : options.liveReloadPath,
2277
+ onData: options.onData
2126
2278
  };
2127
2279
  }
2128
2280
  function getRegisteredReactBuildTargets() {
@@ -2154,10 +2306,12 @@ var setupWebframezCoreReactRoute = initWebframezReact;
2154
2306
  createHTMLShell,
2155
2307
  createNodeRequestHandler,
2156
2308
  createRSCHandler,
2309
+ disposeReactHtmlRenderer,
2157
2310
  getRegisteredReactBuildTargets,
2158
2311
  initWebframezReact,
2159
2312
  parseSearchParams,
2160
2313
  renderHeadToString,
2314
+ renderReactToHtml,
2161
2315
  resolveWebframezReactRouteOptions,
2162
2316
  sendRSC,
2163
2317
  setupWebframezCoreReactRoute
package/dist/index.d.ts CHANGED
@@ -25,3 +25,5 @@ export function createRSCHandler(options: {
25
25
  export function createNodeRequestHandler(
26
26
  options: CreateNodeHandlerOptions
27
27
  ): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
28
+
29
+ export { renderReactToHtml, disposeReactHtmlRenderer } from "./http";