@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/README.md +61 -0
- package/defaults/webpack.client.cjs +6 -2
- package/dist/client.cjs +1 -1
- package/dist/client.js +1 -1
- package/dist/http.cjs +134 -46
- package/dist/http.d.ts +5 -0
- package/dist/http.js +131 -45
- package/dist/index.cjs +207 -53
- package/dist/index.d.ts +2 -0
- package/dist/index.js +227 -53
- package/dist/navigation.cjs +80 -15
- package/dist/navigation.d.ts +1 -1
- package/dist/navigation.js +92 -15
- package/dist/paths.cjs +102 -0
- package/dist/paths.d.ts +4 -0
- package/dist/paths.js +92 -0
- package/dist/router.cjs +58 -8
- package/dist/router.d.ts +8 -2
- package/dist/router.js +58 -8
- package/dist/types.d.ts +24 -0
- package/dist/webframez-core.cjs +186 -53
- package/dist/webframez-core.d.ts +2 -8
- package/dist/webframez-core.js +206 -53
- package/package.json +18 -4
package/dist/webframez-core.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/webframez-core.ts
|
|
30
87
|
var webframez_core_exports = {};
|
|
31
88
|
__export(webframez_core_exports, {
|
|
@@ -36,9 +93,15 @@ __export(webframez_core_exports, {
|
|
|
36
93
|
setupWebframezCoreReactRoute: () => setupWebframezCoreReactRoute
|
|
37
94
|
});
|
|
38
95
|
module.exports = __toCommonJS(webframez_core_exports);
|
|
96
|
+
|
|
97
|
+
// src/paths.ts
|
|
98
|
+
var import_routing = __toESM(require_routing2(), 1);
|
|
99
|
+
|
|
100
|
+
// src/webframez-core.ts
|
|
39
101
|
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
40
102
|
|
|
41
103
|
// src/http.ts
|
|
104
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
42
105
|
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
43
106
|
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
44
107
|
var import_node_url = require("node:url");
|
|
@@ -62,6 +125,8 @@ function createHTMLShell(options = {}) {
|
|
|
62
125
|
buildId = "",
|
|
63
126
|
headTags = "",
|
|
64
127
|
bodyClassName = "",
|
|
128
|
+
bodyStartHtml = "",
|
|
129
|
+
bodyEndHtml = "",
|
|
65
130
|
rootHtml = "",
|
|
66
131
|
initialFlightData = "",
|
|
67
132
|
basename = "",
|
|
@@ -111,7 +176,9 @@ function createHTMLShell(options = {}) {
|
|
|
111
176
|
${headTags}
|
|
112
177
|
</head>
|
|
113
178
|
<body${bodyClassName ? ` class="${bodyClassName.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">")}"` : ""}>
|
|
179
|
+
${bodyStartHtml}
|
|
114
180
|
<div id="root">${rootHtml}</div>
|
|
181
|
+
${bodyEndHtml}
|
|
115
182
|
<script>window.__RSC_ENDPOINT = "${rscEndpoint}";</script>
|
|
116
183
|
<script>window.__RSC_BASENAME = "${basename}";</script>
|
|
117
184
|
<script>window.__RSC_ROUTE_BASE_PATH = "${routeBasePath}";</script>
|
|
@@ -226,6 +293,12 @@ function normalizeHeadConfig(head, inheritedBasename) {
|
|
|
226
293
|
href: resolveHeadAssetUrl(link.href, effectiveBasename)
|
|
227
294
|
}));
|
|
228
295
|
}
|
|
296
|
+
if (normalizedHead.scripts) {
|
|
297
|
+
normalizedHead.scripts = normalizedHead.scripts.map((script) => ({
|
|
298
|
+
...script,
|
|
299
|
+
...script.src ? { src: resolveHeadAssetUrl(script.src, effectiveBasename) } : {}
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
229
302
|
return normalizedHead;
|
|
230
303
|
}
|
|
231
304
|
|
|
@@ -338,8 +411,7 @@ var FORCED_PACKAGE_REQUESTS = [
|
|
|
338
411
|
"react-server-dom-webpack",
|
|
339
412
|
"react-server-dom-webpack/server",
|
|
340
413
|
"react-server-dom-webpack/client",
|
|
341
|
-
"react-server-dom-webpack/client.node"
|
|
342
|
-
"scheduler"
|
|
414
|
+
"react-server-dom-webpack/client.node"
|
|
343
415
|
];
|
|
344
416
|
var forcedPackageResolutionInstalled = false;
|
|
345
417
|
function normalizePathname(pathname) {
|
|
@@ -478,7 +550,9 @@ function matchRoute(entry, pathname) {
|
|
|
478
550
|
function mergeHead(...configs) {
|
|
479
551
|
const merged = {
|
|
480
552
|
meta: [],
|
|
481
|
-
links: []
|
|
553
|
+
links: [],
|
|
554
|
+
scripts: [],
|
|
555
|
+
html: []
|
|
482
556
|
};
|
|
483
557
|
for (const candidate of configs) {
|
|
484
558
|
const config = normalizeHeadConfig(candidate, merged.basename);
|
|
@@ -513,9 +587,28 @@ function mergeHead(...configs) {
|
|
|
513
587
|
if (config.links) {
|
|
514
588
|
merged.links?.push(...config.links);
|
|
515
589
|
}
|
|
590
|
+
if (config.scripts) {
|
|
591
|
+
merged.scripts?.push(...config.scripts);
|
|
592
|
+
}
|
|
593
|
+
if (config.html) {
|
|
594
|
+
merged.html?.push(...Array.isArray(config.html) ? config.html : [config.html]);
|
|
595
|
+
}
|
|
596
|
+
if (config.bodyStartHtml) {
|
|
597
|
+
merged.bodyStartHtml = [merged.bodyStartHtml, config.bodyStartHtml].filter(Boolean).join("\n");
|
|
598
|
+
}
|
|
599
|
+
if (config.bodyEndHtml) {
|
|
600
|
+
merged.bodyEndHtml = [merged.bodyEndHtml, config.bodyEndHtml].filter(Boolean).join("\n");
|
|
601
|
+
}
|
|
516
602
|
}
|
|
517
603
|
return merged;
|
|
518
604
|
}
|
|
605
|
+
function renderGenericAttributes(entry, excluded = []) {
|
|
606
|
+
return Object.entries(entry).filter(
|
|
607
|
+
([key, value]) => !excluded.includes(key) && value !== void 0 && value !== null && value !== false
|
|
608
|
+
).map(
|
|
609
|
+
([key, value]) => value === true ? key : `${key}="${escapeHtml(String(value))}"`
|
|
610
|
+
).join(" ");
|
|
611
|
+
}
|
|
519
612
|
function renderHeadToString(head) {
|
|
520
613
|
const normalizedHead = normalizeHeadConfig(head) ?? head;
|
|
521
614
|
const tags = [];
|
|
@@ -537,6 +630,23 @@ function renderHeadToString(head) {
|
|
|
537
630
|
const attrs = Object.entries(link).filter(([, value]) => Boolean(value)).map(([key, value]) => `${key}="${escapeHtml(String(value))}"`).join(" ");
|
|
538
631
|
tags.push(`<link ${createManagedAttributes()} ${attrs} />`);
|
|
539
632
|
}
|
|
633
|
+
for (const script of normalizedHead.scripts ?? []) {
|
|
634
|
+
if (script.html) {
|
|
635
|
+
tags.push(script.html);
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
const attrs = renderGenericAttributes(script, [
|
|
639
|
+
"content",
|
|
640
|
+
"html"
|
|
641
|
+
]);
|
|
642
|
+
const content = script.content ? String(script.content) : "";
|
|
643
|
+
tags.push(`<script ${createManagedAttributes()} ${attrs}>${content}</script>`);
|
|
644
|
+
}
|
|
645
|
+
for (const html of normalizedHead.html ?? []) {
|
|
646
|
+
if (typeof html === "string" && html.trim() !== "") {
|
|
647
|
+
tags.push(html);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
540
650
|
return tags.join("\n");
|
|
541
651
|
}
|
|
542
652
|
function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -622,6 +732,7 @@ function isRouteAbort(value) {
|
|
|
622
732
|
function createFileRouter(options) {
|
|
623
733
|
installForcedPackageResolution();
|
|
624
734
|
const pagesDir = options.pagesDir;
|
|
735
|
+
const onData = options.onData;
|
|
625
736
|
const layoutPath = import_node_path2.default.join(pagesDir, "layout.js");
|
|
626
737
|
const errorPath = import_node_path2.default.join(pagesDir, "errors.js");
|
|
627
738
|
const middlewaresPath = import_node_path2.default.join(pagesDir, "middlewares.js");
|
|
@@ -786,10 +897,16 @@ function createFileRouter(options) {
|
|
|
786
897
|
data: mergeRouteData(middlewareContext.data, pageData)
|
|
787
898
|
};
|
|
788
899
|
activeContext = pageContext;
|
|
789
|
-
const
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
900
|
+
const onDataResult = typeof onData === "function" ? await onData(pageContext) : void 0;
|
|
901
|
+
const eventContext = {
|
|
902
|
+
...pageContext,
|
|
903
|
+
data: mergeRouteData(pageContext.data, onDataResult)
|
|
904
|
+
};
|
|
905
|
+
activeContext = eventContext;
|
|
906
|
+
const pageNode = await pageModule.default(eventContext);
|
|
907
|
+
const layoutHead = layoutModule ? await resolveHead(layoutModule, eventContext) : void 0;
|
|
908
|
+
const pageHead = await resolveHead(pageModule, eventContext);
|
|
909
|
+
const layoutNode = layoutModule ? await layoutModule.default(eventContext) : null;
|
|
793
910
|
const model = layoutNode ? injectRouteChildren(layoutNode, pageNode) : pageNode;
|
|
794
911
|
const contextModel = layoutNode ? injectRouteChildren(layoutNode, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteChildren, {})) : void 0;
|
|
795
912
|
return {
|
|
@@ -798,7 +915,7 @@ function createFileRouter(options) {
|
|
|
798
915
|
contextModel,
|
|
799
916
|
pageModel: pageNode,
|
|
800
917
|
head: mergeHead(layoutHead, pageHead),
|
|
801
|
-
context:
|
|
918
|
+
context: eventContext
|
|
802
919
|
};
|
|
803
920
|
} catch (error) {
|
|
804
921
|
if (isRouteAbort(error)) {
|
|
@@ -945,6 +1062,7 @@ const rootParent = {
|
|
|
945
1062
|
path: process.cwd(),
|
|
946
1063
|
paths: Module._nodeModulePaths(process.cwd()),
|
|
947
1064
|
};
|
|
1065
|
+
// Transitive dependencies (e.g. scheduler) must resolve from their importer.
|
|
948
1066
|
const forcedPackageRequests = [
|
|
949
1067
|
"@webtypen/webframez-core",
|
|
950
1068
|
"@webtypen/webframez-react",
|
|
@@ -959,7 +1077,6 @@ const forcedPackageRequests = [
|
|
|
959
1077
|
"react-server-dom-webpack/server",
|
|
960
1078
|
"react-server-dom-webpack/client",
|
|
961
1079
|
"react-server-dom-webpack/client.node",
|
|
962
|
-
"scheduler"
|
|
963
1080
|
];
|
|
964
1081
|
|
|
965
1082
|
function shouldForcePackageResolution(request) {
|
|
@@ -1151,13 +1268,17 @@ async function renderHtmlFromFlightData(flightData, moduleMap) {
|
|
|
1151
1268
|
? payload.head.basename
|
|
1152
1269
|
: "";
|
|
1153
1270
|
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1271
|
+
const routingContext = globalThis.__WEBFRAMEZ_ROUTING_CONTEXT__ ??=
|
|
1272
|
+
new (require("node:async_hooks").AsyncLocalStorage)();
|
|
1273
|
+
return routingContext.run(basename, async () => {
|
|
1274
|
+
const previousBasename = globalThis.__RSC_BASENAME;
|
|
1275
|
+
globalThis.__RSC_BASENAME = basename;
|
|
1276
|
+
try {
|
|
1277
|
+
return await renderHtml(model);
|
|
1278
|
+
} finally {
|
|
1279
|
+
globalThis.__RSC_BASENAME = previousBasename;
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1161
1282
|
}
|
|
1162
1283
|
|
|
1163
1284
|
process.on("message", async (message) => {
|
|
@@ -1393,24 +1514,10 @@ ${stderrBuffer.trim()}` : "";
|
|
|
1393
1514
|
}
|
|
1394
1515
|
};
|
|
1395
1516
|
}
|
|
1517
|
+
var routingRuntime = globalThis;
|
|
1518
|
+
var basenameContext = routingRuntime.__WEBFRAMEZ_ROUTING_CONTEXT__ ??= new import_node_async_hooks.AsyncLocalStorage();
|
|
1396
1519
|
function withRequestBasename(basename, fn) {
|
|
1397
|
-
|
|
1398
|
-
const previous = target.__RSC_BASENAME;
|
|
1399
|
-
target.__RSC_BASENAME = basename;
|
|
1400
|
-
const finish = () => {
|
|
1401
|
-
target.__RSC_BASENAME = previous;
|
|
1402
|
-
};
|
|
1403
|
-
try {
|
|
1404
|
-
const result = fn();
|
|
1405
|
-
if (result && typeof result.then === "function") {
|
|
1406
|
-
return result.finally(finish);
|
|
1407
|
-
}
|
|
1408
|
-
finish();
|
|
1409
|
-
return result;
|
|
1410
|
-
} catch (error) {
|
|
1411
|
-
finish();
|
|
1412
|
-
throw error;
|
|
1413
|
-
}
|
|
1520
|
+
return basenameContext.run(basename, fn);
|
|
1414
1521
|
}
|
|
1415
1522
|
function parseCookies(rawCookieHeader) {
|
|
1416
1523
|
const raw = Array.isArray(rawCookieHeader) ? rawCookieHeader.join("; ") : rawCookieHeader ?? "";
|
|
@@ -1445,12 +1552,27 @@ function normalizeClientManifest(manifest, options) {
|
|
|
1445
1552
|
}
|
|
1446
1553
|
};
|
|
1447
1554
|
for (const [key, value] of Object.entries(manifest)) {
|
|
1555
|
+
const hashIndex = key.indexOf("#");
|
|
1556
|
+
const moduleKey = hashIndex < 0 ? key : key.slice(0, hashIndex);
|
|
1557
|
+
const exportSuffix = hashIndex < 0 ? "" : key.slice(hashIndex);
|
|
1558
|
+
if (!import_node_path3.default.isAbsolute(moduleKey) && !moduleKey.includes(":") && !moduleKey.startsWith("file://")) {
|
|
1559
|
+
const runtimePath = import_node_path3.default.resolve(options.cwd, moduleKey);
|
|
1560
|
+
const allowedRoots = [options.distRootDir, ...candidateNodeModulesDirs];
|
|
1561
|
+
const insideArtifact = allowedRoots.some((root) => {
|
|
1562
|
+
const relative = import_node_path3.default.relative(import_node_path3.default.resolve(root), runtimePath);
|
|
1563
|
+
return relative !== "" && relative !== ".." && !relative.startsWith(`..${import_node_path3.default.sep}`) && !import_node_path3.default.isAbsolute(relative);
|
|
1564
|
+
});
|
|
1565
|
+
if (insideArtifact) {
|
|
1566
|
+
addAlias(`${runtimePath}${exportSuffix}`, value);
|
|
1567
|
+
addAlias(`${(0, import_node_url.pathToFileURL)(runtimePath).href}${exportSuffix}`, value);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1448
1570
|
if (!key.startsWith("file://")) {
|
|
1449
1571
|
continue;
|
|
1450
1572
|
}
|
|
1451
1573
|
let absolutePath = "";
|
|
1452
1574
|
try {
|
|
1453
|
-
absolutePath = (0, import_node_url.fileURLToPath)(
|
|
1575
|
+
absolutePath = (0, import_node_url.fileURLToPath)(moduleKey);
|
|
1454
1576
|
} catch {
|
|
1455
1577
|
continue;
|
|
1456
1578
|
}
|
|
@@ -1461,13 +1583,13 @@ function normalizeClientManifest(manifest, options) {
|
|
|
1461
1583
|
}
|
|
1462
1584
|
const relativeModulePath = absolutePath.slice(markerIndex + marker.length);
|
|
1463
1585
|
const relativeModulePathPosix = relativeModulePath.split(import_node_path3.default.sep).join("/");
|
|
1464
|
-
addAlias(`./node_modules/${relativeModulePathPosix}`, value);
|
|
1465
|
-
addAlias(`node_modules/${relativeModulePathPosix}`, value);
|
|
1466
|
-
addAlias(absolutePath
|
|
1586
|
+
addAlias(`./node_modules/${relativeModulePathPosix}${exportSuffix}`, value);
|
|
1587
|
+
addAlias(`node_modules/${relativeModulePathPosix}${exportSuffix}`, value);
|
|
1588
|
+
addAlias(`${absolutePath}${exportSuffix}`, value);
|
|
1467
1589
|
for (const nodeModulesDir of candidateNodeModulesDirs) {
|
|
1468
1590
|
const aliasPath = import_node_path3.default.join(nodeModulesDir, relativeModulePath);
|
|
1469
|
-
addAlias(aliasPath
|
|
1470
|
-
addAlias((0, import_node_url.pathToFileURL)(aliasPath).href
|
|
1591
|
+
addAlias(`${aliasPath}${exportSuffix}`, value);
|
|
1592
|
+
addAlias(`${(0, import_node_url.pathToFileURL)(aliasPath).href}${exportSuffix}`, value);
|
|
1471
1593
|
}
|
|
1472
1594
|
}
|
|
1473
1595
|
return normalized;
|
|
@@ -1612,16 +1734,16 @@ function createNodeRequestHandler(options) {
|
|
|
1612
1734
|
const manifestPath = import_node_path3.default.resolve(
|
|
1613
1735
|
options.manifestPath ?? import_node_path3.default.join(distRootDir, "react-client-manifest.json")
|
|
1614
1736
|
);
|
|
1615
|
-
const assetsPrefix = options.assetsPrefix ?? "/assets/";
|
|
1616
|
-
const rscPath = options.rscPath ?? "/rsc";
|
|
1617
|
-
const clientScriptUrl = options.clientScriptUrl ?? "/assets/client.js";
|
|
1618
1737
|
const basePath = normalizeBasePath(options.basePath);
|
|
1738
|
+
const assetsPrefix = options.assetsPrefix ?? `${basePath}/assets/`;
|
|
1739
|
+
const rscPath = options.rscPath ?? `${basePath}/rsc`;
|
|
1740
|
+
const clientScriptUrl = options.clientScriptUrl ?? `${basePath}/assets/client.js`;
|
|
1619
1741
|
const nodeEnv = process.env.NODE_ENV || "";
|
|
1620
1742
|
const runningInWatchMode = Array.isArray(process.execArgv) && process.execArgv.includes("--watch");
|
|
1621
1743
|
const liveReloadEnabled = options.liveReloadPath !== false && (nodeEnv === "development" || runningInWatchMode);
|
|
1622
1744
|
const liveReloadPath = !liveReloadEnabled ? "" : options.liveReloadPath ?? `${basePath || ""}/__webframez_live_reload`;
|
|
1623
1745
|
const liveReloadClients = /* @__PURE__ */ new Set();
|
|
1624
|
-
const router = createFileRouter({ pagesDir });
|
|
1746
|
+
const router = createFileRouter({ pagesDir, onData: options.onData });
|
|
1625
1747
|
const getManifestState = createManifestLoader({
|
|
1626
1748
|
distRootDir,
|
|
1627
1749
|
manifestPath,
|
|
@@ -1634,7 +1756,7 @@ function createNodeRequestHandler(options) {
|
|
|
1634
1756
|
process.once("exit", disposeInitialHtmlWorker);
|
|
1635
1757
|
process.once("SIGINT", disposeInitialHtmlWorker);
|
|
1636
1758
|
process.once("SIGTERM", disposeInitialHtmlWorker);
|
|
1637
|
-
|
|
1759
|
+
const handleRequest = async (req, res) => {
|
|
1638
1760
|
if (!req.url) {
|
|
1639
1761
|
res.statusCode = 400;
|
|
1640
1762
|
res.end("Bad request");
|
|
@@ -1698,6 +1820,7 @@ function createNodeRequestHandler(options) {
|
|
|
1698
1820
|
request: requestContext
|
|
1699
1821
|
})
|
|
1700
1822
|
);
|
|
1823
|
+
resolved2.head = { ...resolved2.head, basename: resolved2.head.basename ?? basePath };
|
|
1701
1824
|
attachResolvedContextToCoreRequest(req, resolved2.context);
|
|
1702
1825
|
const payload = {
|
|
1703
1826
|
model: resolved2.model,
|
|
@@ -1773,6 +1896,7 @@ function createNodeRequestHandler(options) {
|
|
|
1773
1896
|
)
|
|
1774
1897
|
})
|
|
1775
1898
|
);
|
|
1899
|
+
resolved.head = { ...resolved.head, basename: resolved.head.basename ?? basePath };
|
|
1776
1900
|
attachResolvedContextToCoreRequest(req, resolved.context);
|
|
1777
1901
|
const initialPayload = {
|
|
1778
1902
|
model: resolved.model,
|
|
@@ -1845,6 +1969,8 @@ function createNodeRequestHandler(options) {
|
|
|
1845
1969
|
initialFlightData,
|
|
1846
1970
|
basename: shellBasename,
|
|
1847
1971
|
routeBasePath: shellRouteBasePath,
|
|
1972
|
+
bodyStartHtml: resolved.head.bodyStartHtml || "",
|
|
1973
|
+
bodyEndHtml: resolved.head.bodyEndHtml || "",
|
|
1848
1974
|
liveReloadPath: liveReloadPath || void 0,
|
|
1849
1975
|
liveReloadServerId: liveReloadPath ? devServerId : void 0
|
|
1850
1976
|
}),
|
|
@@ -1856,6 +1982,7 @@ function createNodeRequestHandler(options) {
|
|
|
1856
1982
|
}
|
|
1857
1983
|
);
|
|
1858
1984
|
};
|
|
1985
|
+
return (req, res) => withRequestBasename(basePath, () => handleRequest(req, res));
|
|
1859
1986
|
}
|
|
1860
1987
|
|
|
1861
1988
|
// src/webframez-core.ts
|
|
@@ -1944,6 +2071,17 @@ function buildRenderDefaults(routePathValue) {
|
|
|
1944
2071
|
clientScriptUrl: `${mountPath}/assets/client.js`
|
|
1945
2072
|
};
|
|
1946
2073
|
}
|
|
2074
|
+
function runtimeRoutePaths(routePath, options, basename = (0, import_routing.getBasename)(), groupPrefix = "") {
|
|
2075
|
+
const localMount = normalizeMountPath(options.basePath ?? `${groupPrefix}${normalizeMountPath(routePath)}`);
|
|
2076
|
+
const basePath = normalizeMountPath((0, import_routing.appPath)(localMount, basename)).replace(/\/$/, "");
|
|
2077
|
+
return {
|
|
2078
|
+
basePath,
|
|
2079
|
+
assetsPrefix: options.assetsPrefix !== void 0 ? (0, import_routing.appPath)(options.assetsPrefix, basename) : `${basePath}/assets/`,
|
|
2080
|
+
rscPath: options.rscPath !== void 0 ? (0, import_routing.appPath)(options.rscPath, basename) : `${basePath}/rsc`,
|
|
2081
|
+
clientScriptUrl: options.clientScriptUrl !== void 0 ? (0, import_routing.appPath)(options.clientScriptUrl, basename) : `${basePath}/assets/client.js`,
|
|
2082
|
+
...typeof options.liveReloadPath === "string" ? { liveReloadPath: (0, import_routing.appPath)(options.liveReloadPath, basename) } : {}
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
1947
2085
|
async function waitForResponseFinish(res) {
|
|
1948
2086
|
if (res.writableEnded || res.destroyed) {
|
|
1949
2087
|
return;
|
|
@@ -2037,10 +2175,7 @@ function registerRouteRenderer(route, methodName) {
|
|
|
2037
2175
|
distRootDir: resolvedTarget.distRootDir,
|
|
2038
2176
|
pagesDir: resolvedTarget.pagesDir,
|
|
2039
2177
|
manifestPath: resolvedTarget.manifestPath,
|
|
2040
|
-
|
|
2041
|
-
assetsPrefix: assetsPrefix ?? defaults.assetsPrefix,
|
|
2042
|
-
rscPath: rscPath ?? defaults.rscPath,
|
|
2043
|
-
clientScriptUrl: clientScriptUrl ?? defaults.clientScriptUrl
|
|
2178
|
+
...runtimeRoutePaths(routePathValue, options, route.basename ?? (0, import_routing.getBasename)(), route.tempGroupPrefix ?? "")
|
|
2044
2179
|
});
|
|
2045
2180
|
const methods = normalizeMethods(method);
|
|
2046
2181
|
for (const currentMethod of methods) {
|
|
@@ -2082,13 +2217,11 @@ function resolveWebframezReactRouteOptions(routePathValue, options = {}) {
|
|
|
2082
2217
|
distRootDir,
|
|
2083
2218
|
pagesDir,
|
|
2084
2219
|
manifestPath,
|
|
2085
|
-
|
|
2086
|
-
rscPath: options.rscPath ?? defaults.rscPath,
|
|
2087
|
-
clientScriptUrl: options.clientScriptUrl ?? defaults.clientScriptUrl,
|
|
2220
|
+
...runtimeRoutePaths(routePathValue, options),
|
|
2088
2221
|
clientEntryPath: options.clientEntryPath ? resolveFromProjectRoot(options.clientEntryPath) : void 0,
|
|
2089
2222
|
styleSrcPath: options.styleSrcPath ? resolveFromProjectRoot(options.styleSrcPath) : defaults.styleSrcPath,
|
|
2090
|
-
|
|
2091
|
-
|
|
2223
|
+
liveReloadPath: typeof options.liveReloadPath === "string" ? (0, import_routing.appPath)(options.liveReloadPath) : options.liveReloadPath,
|
|
2224
|
+
onData: options.onData
|
|
2092
2225
|
};
|
|
2093
2226
|
}
|
|
2094
2227
|
function getRegisteredReactBuildTargets() {
|
package/dist/webframez-core.d.ts
CHANGED
|
@@ -39,14 +39,8 @@ export interface WebframezCoreRouteFacadeExtensions {
|
|
|
39
39
|
reactRender(path: string, options?: WebframezCoreReactRenderRouteOptions): void;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare module "webframez-core" {
|
|
47
|
-
interface RouteFacade extends WebframezCoreRouteFacadeExtensions {}
|
|
48
|
-
}
|
|
49
|
-
|
|
42
|
+
// Augment the defining module; the package root re-exports this same class.
|
|
43
|
+
// Also augmenting the root creates conflicting polymorphic `this` types.
|
|
50
44
|
declare module "@webtypen/webframez-core/dist/Router/Route" {
|
|
51
45
|
interface RouteFacade extends WebframezCoreRouteFacadeExtensions {}
|
|
52
46
|
}
|