@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.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1
7
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
8
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
9
|
}) : x)(function(x) {
|
|
@@ -5,11 +11,88 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
11
|
return require.apply(this, arguments);
|
|
6
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
13
|
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// node_modules/@webtypen/webframez-core/dist/routing.js
|
|
35
|
+
var require_routing = __commonJS({
|
|
36
|
+
"node_modules/@webtypen/webframez-core/dist/routing.js"(exports) {
|
|
37
|
+
"use strict";
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.appRelativePath = exports.appPath = exports.getBasename = exports.normalizeBasename = void 0;
|
|
40
|
+
function normalizeBasename2(value) {
|
|
41
|
+
if (value == null || value === "" || value === "/")
|
|
42
|
+
return "";
|
|
43
|
+
if (typeof value !== "string")
|
|
44
|
+
throw new Error("Router basename must be a string.");
|
|
45
|
+
const base = value.trim().replace(/\/+$/, "");
|
|
46
|
+
if (!base && value.trim().length <= 1)
|
|
47
|
+
return "";
|
|
48
|
+
if (!/^\/(?:[A-Za-z0-9_~-]+(?:\.[A-Za-z0-9_~-]+)*)(?:\/[A-Za-z0-9_~-]+(?:\.[A-Za-z0-9_~-]+)*)*$/.test(base)) {
|
|
49
|
+
throw new Error("Router basename must be empty or an absolute path such as /my-app.");
|
|
50
|
+
}
|
|
51
|
+
return base;
|
|
52
|
+
}
|
|
53
|
+
exports.normalizeBasename = normalizeBasename2;
|
|
54
|
+
function getBasename2() {
|
|
55
|
+
var _a, _b, _c, _d;
|
|
56
|
+
const runtime = globalThis;
|
|
57
|
+
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 : "";
|
|
58
|
+
}
|
|
59
|
+
exports.getBasename = getBasename2;
|
|
60
|
+
function appPath2(value, basename = getBasename2()) {
|
|
61
|
+
const base = normalizeBasename2(basename);
|
|
62
|
+
if (!base || !value.startsWith("/") || value.startsWith("//") || hasBasename(value, base))
|
|
63
|
+
return value;
|
|
64
|
+
return base + value;
|
|
65
|
+
}
|
|
66
|
+
exports.appPath = appPath2;
|
|
67
|
+
function appRelativePath2(value, basename = getBasename2()) {
|
|
68
|
+
const base = normalizeBasename2(basename);
|
|
69
|
+
if (!base || !hasBasename(value, base))
|
|
70
|
+
return value;
|
|
71
|
+
const relative = value.slice(base.length);
|
|
72
|
+
return !relative || relative.startsWith("?") || relative.startsWith("#") ? "/" + relative : relative;
|
|
73
|
+
}
|
|
74
|
+
exports.appRelativePath = appRelativePath2;
|
|
75
|
+
function hasBasename(value, base) {
|
|
76
|
+
return value === base || value.startsWith(base + "/") || value.startsWith(base + "?") || value.startsWith(base + "#");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// node_modules/@webtypen/webframez-core/routing.js
|
|
82
|
+
var require_routing2 = __commonJS({
|
|
83
|
+
"node_modules/@webtypen/webframez-core/routing.js"(exports, module) {
|
|
84
|
+
module.exports = require_routing();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/paths.ts
|
|
89
|
+
var import_routing = __toESM(require_routing2(), 1);
|
|
8
90
|
|
|
9
91
|
// src/webframez-core.ts
|
|
10
92
|
import path4 from "node:path";
|
|
11
93
|
|
|
12
94
|
// src/http.ts
|
|
95
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
13
96
|
import fs2 from "node:fs";
|
|
14
97
|
import path3 from "node:path";
|
|
15
98
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -38,6 +121,8 @@ function createHTMLShell(options = {}) {
|
|
|
38
121
|
buildId = "",
|
|
39
122
|
headTags = "",
|
|
40
123
|
bodyClassName = "",
|
|
124
|
+
bodyStartHtml = "",
|
|
125
|
+
bodyEndHtml = "",
|
|
41
126
|
rootHtml = "",
|
|
42
127
|
initialFlightData = "",
|
|
43
128
|
basename = "",
|
|
@@ -87,7 +172,9 @@ function createHTMLShell(options = {}) {
|
|
|
87
172
|
${headTags}
|
|
88
173
|
</head>
|
|
89
174
|
<body${bodyClassName ? ` class="${bodyClassName.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">")}"` : ""}>
|
|
175
|
+
${bodyStartHtml}
|
|
90
176
|
<div id="root">${rootHtml}</div>
|
|
177
|
+
${bodyEndHtml}
|
|
91
178
|
<script>window.__RSC_ENDPOINT = "${rscEndpoint}";</script>
|
|
92
179
|
<script>window.__RSC_BASENAME = "${basename}";</script>
|
|
93
180
|
<script>window.__RSC_ROUTE_BASE_PATH = "${routeBasePath}";</script>
|
|
@@ -202,6 +289,12 @@ function normalizeHeadConfig(head, inheritedBasename) {
|
|
|
202
289
|
href: resolveHeadAssetUrl(link.href, effectiveBasename)
|
|
203
290
|
}));
|
|
204
291
|
}
|
|
292
|
+
if (normalizedHead.scripts) {
|
|
293
|
+
normalizedHead.scripts = normalizedHead.scripts.map((script) => ({
|
|
294
|
+
...script,
|
|
295
|
+
...script.src ? { src: resolveHeadAssetUrl(script.src, effectiveBasename) } : {}
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
205
298
|
return normalizedHead;
|
|
206
299
|
}
|
|
207
300
|
|
|
@@ -314,8 +407,7 @@ var FORCED_PACKAGE_REQUESTS = [
|
|
|
314
407
|
"react-server-dom-webpack",
|
|
315
408
|
"react-server-dom-webpack/server",
|
|
316
409
|
"react-server-dom-webpack/client",
|
|
317
|
-
"react-server-dom-webpack/client.node"
|
|
318
|
-
"scheduler"
|
|
410
|
+
"react-server-dom-webpack/client.node"
|
|
319
411
|
];
|
|
320
412
|
var forcedPackageResolutionInstalled = false;
|
|
321
413
|
function normalizePathname(pathname) {
|
|
@@ -454,7 +546,9 @@ function matchRoute(entry, pathname) {
|
|
|
454
546
|
function mergeHead(...configs) {
|
|
455
547
|
const merged = {
|
|
456
548
|
meta: [],
|
|
457
|
-
links: []
|
|
549
|
+
links: [],
|
|
550
|
+
scripts: [],
|
|
551
|
+
html: []
|
|
458
552
|
};
|
|
459
553
|
for (const candidate of configs) {
|
|
460
554
|
const config = normalizeHeadConfig(candidate, merged.basename);
|
|
@@ -489,9 +583,28 @@ function mergeHead(...configs) {
|
|
|
489
583
|
if (config.links) {
|
|
490
584
|
merged.links?.push(...config.links);
|
|
491
585
|
}
|
|
586
|
+
if (config.scripts) {
|
|
587
|
+
merged.scripts?.push(...config.scripts);
|
|
588
|
+
}
|
|
589
|
+
if (config.html) {
|
|
590
|
+
merged.html?.push(...Array.isArray(config.html) ? config.html : [config.html]);
|
|
591
|
+
}
|
|
592
|
+
if (config.bodyStartHtml) {
|
|
593
|
+
merged.bodyStartHtml = [merged.bodyStartHtml, config.bodyStartHtml].filter(Boolean).join("\n");
|
|
594
|
+
}
|
|
595
|
+
if (config.bodyEndHtml) {
|
|
596
|
+
merged.bodyEndHtml = [merged.bodyEndHtml, config.bodyEndHtml].filter(Boolean).join("\n");
|
|
597
|
+
}
|
|
492
598
|
}
|
|
493
599
|
return merged;
|
|
494
600
|
}
|
|
601
|
+
function renderGenericAttributes(entry, excluded = []) {
|
|
602
|
+
return Object.entries(entry).filter(
|
|
603
|
+
([key, value]) => !excluded.includes(key) && value !== void 0 && value !== null && value !== false
|
|
604
|
+
).map(
|
|
605
|
+
([key, value]) => value === true ? key : `${key}="${escapeHtml(String(value))}"`
|
|
606
|
+
).join(" ");
|
|
607
|
+
}
|
|
495
608
|
function renderHeadToString(head) {
|
|
496
609
|
const normalizedHead = normalizeHeadConfig(head) ?? head;
|
|
497
610
|
const tags = [];
|
|
@@ -513,6 +626,23 @@ function renderHeadToString(head) {
|
|
|
513
626
|
const attrs = Object.entries(link).filter(([, value]) => Boolean(value)).map(([key, value]) => `${key}="${escapeHtml(String(value))}"`).join(" ");
|
|
514
627
|
tags.push(`<link ${createManagedAttributes()} ${attrs} />`);
|
|
515
628
|
}
|
|
629
|
+
for (const script of normalizedHead.scripts ?? []) {
|
|
630
|
+
if (script.html) {
|
|
631
|
+
tags.push(script.html);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
const attrs = renderGenericAttributes(script, [
|
|
635
|
+
"content",
|
|
636
|
+
"html"
|
|
637
|
+
]);
|
|
638
|
+
const content = script.content ? String(script.content) : "";
|
|
639
|
+
tags.push(`<script ${createManagedAttributes()} ${attrs}>${content}</script>`);
|
|
640
|
+
}
|
|
641
|
+
for (const html of normalizedHead.html ?? []) {
|
|
642
|
+
if (typeof html === "string" && html.trim() !== "") {
|
|
643
|
+
tags.push(html);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
516
646
|
return tags.join("\n");
|
|
517
647
|
}
|
|
518
648
|
function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -598,6 +728,7 @@ function isRouteAbort(value) {
|
|
|
598
728
|
function createFileRouter(options) {
|
|
599
729
|
installForcedPackageResolution();
|
|
600
730
|
const pagesDir = options.pagesDir;
|
|
731
|
+
const onData = options.onData;
|
|
601
732
|
const layoutPath = path2.join(pagesDir, "layout.js");
|
|
602
733
|
const errorPath = path2.join(pagesDir, "errors.js");
|
|
603
734
|
const middlewaresPath = path2.join(pagesDir, "middlewares.js");
|
|
@@ -762,10 +893,16 @@ function createFileRouter(options) {
|
|
|
762
893
|
data: mergeRouteData(middlewareContext.data, pageData)
|
|
763
894
|
};
|
|
764
895
|
activeContext = pageContext;
|
|
765
|
-
const
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
|
|
896
|
+
const onDataResult = typeof onData === "function" ? await onData(pageContext) : void 0;
|
|
897
|
+
const eventContext = {
|
|
898
|
+
...pageContext,
|
|
899
|
+
data: mergeRouteData(pageContext.data, onDataResult)
|
|
900
|
+
};
|
|
901
|
+
activeContext = eventContext;
|
|
902
|
+
const pageNode = await pageModule.default(eventContext);
|
|
903
|
+
const layoutHead = layoutModule ? await resolveHead(layoutModule, eventContext) : void 0;
|
|
904
|
+
const pageHead = await resolveHead(pageModule, eventContext);
|
|
905
|
+
const layoutNode = layoutModule ? await layoutModule.default(eventContext) : null;
|
|
769
906
|
const model = layoutNode ? injectRouteChildren(layoutNode, pageNode) : pageNode;
|
|
770
907
|
const contextModel = layoutNode ? injectRouteChildren(layoutNode, /* @__PURE__ */ jsx(RouteChildren, {})) : void 0;
|
|
771
908
|
return {
|
|
@@ -774,7 +911,7 @@ function createFileRouter(options) {
|
|
|
774
911
|
contextModel,
|
|
775
912
|
pageModel: pageNode,
|
|
776
913
|
head: mergeHead(layoutHead, pageHead),
|
|
777
|
-
context:
|
|
914
|
+
context: eventContext
|
|
778
915
|
};
|
|
779
916
|
} catch (error) {
|
|
780
917
|
if (isRouteAbort(error)) {
|
|
@@ -921,6 +1058,7 @@ const rootParent = {
|
|
|
921
1058
|
path: process.cwd(),
|
|
922
1059
|
paths: Module._nodeModulePaths(process.cwd()),
|
|
923
1060
|
};
|
|
1061
|
+
// Transitive dependencies (e.g. scheduler) must resolve from their importer.
|
|
924
1062
|
const forcedPackageRequests = [
|
|
925
1063
|
"@webtypen/webframez-core",
|
|
926
1064
|
"@webtypen/webframez-react",
|
|
@@ -935,7 +1073,6 @@ const forcedPackageRequests = [
|
|
|
935
1073
|
"react-server-dom-webpack/server",
|
|
936
1074
|
"react-server-dom-webpack/client",
|
|
937
1075
|
"react-server-dom-webpack/client.node",
|
|
938
|
-
"scheduler"
|
|
939
1076
|
];
|
|
940
1077
|
|
|
941
1078
|
function shouldForcePackageResolution(request) {
|
|
@@ -1127,13 +1264,17 @@ async function renderHtmlFromFlightData(flightData, moduleMap) {
|
|
|
1127
1264
|
? payload.head.basename
|
|
1128
1265
|
: "";
|
|
1129
1266
|
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1267
|
+
const routingContext = globalThis.__WEBFRAMEZ_ROUTING_CONTEXT__ ??=
|
|
1268
|
+
new (require("node:async_hooks").AsyncLocalStorage)();
|
|
1269
|
+
return routingContext.run(basename, async () => {
|
|
1270
|
+
const previousBasename = globalThis.__RSC_BASENAME;
|
|
1271
|
+
globalThis.__RSC_BASENAME = basename;
|
|
1272
|
+
try {
|
|
1273
|
+
return await renderHtml(model);
|
|
1274
|
+
} finally {
|
|
1275
|
+
globalThis.__RSC_BASENAME = previousBasename;
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1137
1278
|
}
|
|
1138
1279
|
|
|
1139
1280
|
process.on("message", async (message) => {
|
|
@@ -1369,24 +1510,10 @@ ${stderrBuffer.trim()}` : "";
|
|
|
1369
1510
|
}
|
|
1370
1511
|
};
|
|
1371
1512
|
}
|
|
1513
|
+
var routingRuntime = globalThis;
|
|
1514
|
+
var basenameContext = routingRuntime.__WEBFRAMEZ_ROUTING_CONTEXT__ ??= new AsyncLocalStorage();
|
|
1372
1515
|
function withRequestBasename(basename, fn) {
|
|
1373
|
-
|
|
1374
|
-
const previous = target.__RSC_BASENAME;
|
|
1375
|
-
target.__RSC_BASENAME = basename;
|
|
1376
|
-
const finish = () => {
|
|
1377
|
-
target.__RSC_BASENAME = previous;
|
|
1378
|
-
};
|
|
1379
|
-
try {
|
|
1380
|
-
const result = fn();
|
|
1381
|
-
if (result && typeof result.then === "function") {
|
|
1382
|
-
return result.finally(finish);
|
|
1383
|
-
}
|
|
1384
|
-
finish();
|
|
1385
|
-
return result;
|
|
1386
|
-
} catch (error) {
|
|
1387
|
-
finish();
|
|
1388
|
-
throw error;
|
|
1389
|
-
}
|
|
1516
|
+
return basenameContext.run(basename, fn);
|
|
1390
1517
|
}
|
|
1391
1518
|
function parseCookies(rawCookieHeader) {
|
|
1392
1519
|
const raw = Array.isArray(rawCookieHeader) ? rawCookieHeader.join("; ") : rawCookieHeader ?? "";
|
|
@@ -1421,12 +1548,27 @@ function normalizeClientManifest(manifest, options) {
|
|
|
1421
1548
|
}
|
|
1422
1549
|
};
|
|
1423
1550
|
for (const [key, value] of Object.entries(manifest)) {
|
|
1551
|
+
const hashIndex = key.indexOf("#");
|
|
1552
|
+
const moduleKey = hashIndex < 0 ? key : key.slice(0, hashIndex);
|
|
1553
|
+
const exportSuffix = hashIndex < 0 ? "" : key.slice(hashIndex);
|
|
1554
|
+
if (!path3.isAbsolute(moduleKey) && !moduleKey.includes(":") && !moduleKey.startsWith("file://")) {
|
|
1555
|
+
const runtimePath = path3.resolve(options.cwd, moduleKey);
|
|
1556
|
+
const allowedRoots = [options.distRootDir, ...candidateNodeModulesDirs];
|
|
1557
|
+
const insideArtifact = allowedRoots.some((root) => {
|
|
1558
|
+
const relative = path3.relative(path3.resolve(root), runtimePath);
|
|
1559
|
+
return relative !== "" && relative !== ".." && !relative.startsWith(`..${path3.sep}`) && !path3.isAbsolute(relative);
|
|
1560
|
+
});
|
|
1561
|
+
if (insideArtifact) {
|
|
1562
|
+
addAlias(`${runtimePath}${exportSuffix}`, value);
|
|
1563
|
+
addAlias(`${pathToFileURL(runtimePath).href}${exportSuffix}`, value);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1424
1566
|
if (!key.startsWith("file://")) {
|
|
1425
1567
|
continue;
|
|
1426
1568
|
}
|
|
1427
1569
|
let absolutePath = "";
|
|
1428
1570
|
try {
|
|
1429
|
-
absolutePath = fileURLToPath(
|
|
1571
|
+
absolutePath = fileURLToPath(moduleKey);
|
|
1430
1572
|
} catch {
|
|
1431
1573
|
continue;
|
|
1432
1574
|
}
|
|
@@ -1437,13 +1579,13 @@ function normalizeClientManifest(manifest, options) {
|
|
|
1437
1579
|
}
|
|
1438
1580
|
const relativeModulePath = absolutePath.slice(markerIndex + marker.length);
|
|
1439
1581
|
const relativeModulePathPosix = relativeModulePath.split(path3.sep).join("/");
|
|
1440
|
-
addAlias(`./node_modules/${relativeModulePathPosix}`, value);
|
|
1441
|
-
addAlias(`node_modules/${relativeModulePathPosix}`, value);
|
|
1442
|
-
addAlias(absolutePath
|
|
1582
|
+
addAlias(`./node_modules/${relativeModulePathPosix}${exportSuffix}`, value);
|
|
1583
|
+
addAlias(`node_modules/${relativeModulePathPosix}${exportSuffix}`, value);
|
|
1584
|
+
addAlias(`${absolutePath}${exportSuffix}`, value);
|
|
1443
1585
|
for (const nodeModulesDir of candidateNodeModulesDirs) {
|
|
1444
1586
|
const aliasPath = path3.join(nodeModulesDir, relativeModulePath);
|
|
1445
|
-
addAlias(aliasPath
|
|
1446
|
-
addAlias(pathToFileURL(aliasPath).href
|
|
1587
|
+
addAlias(`${aliasPath}${exportSuffix}`, value);
|
|
1588
|
+
addAlias(`${pathToFileURL(aliasPath).href}${exportSuffix}`, value);
|
|
1447
1589
|
}
|
|
1448
1590
|
}
|
|
1449
1591
|
return normalized;
|
|
@@ -1588,16 +1730,16 @@ function createNodeRequestHandler(options) {
|
|
|
1588
1730
|
const manifestPath = path3.resolve(
|
|
1589
1731
|
options.manifestPath ?? path3.join(distRootDir, "react-client-manifest.json")
|
|
1590
1732
|
);
|
|
1591
|
-
const assetsPrefix = options.assetsPrefix ?? "/assets/";
|
|
1592
|
-
const rscPath = options.rscPath ?? "/rsc";
|
|
1593
|
-
const clientScriptUrl = options.clientScriptUrl ?? "/assets/client.js";
|
|
1594
1733
|
const basePath = normalizeBasePath(options.basePath);
|
|
1734
|
+
const assetsPrefix = options.assetsPrefix ?? `${basePath}/assets/`;
|
|
1735
|
+
const rscPath = options.rscPath ?? `${basePath}/rsc`;
|
|
1736
|
+
const clientScriptUrl = options.clientScriptUrl ?? `${basePath}/assets/client.js`;
|
|
1595
1737
|
const nodeEnv = process.env.NODE_ENV || "";
|
|
1596
1738
|
const runningInWatchMode = Array.isArray(process.execArgv) && process.execArgv.includes("--watch");
|
|
1597
1739
|
const liveReloadEnabled = options.liveReloadPath !== false && (nodeEnv === "development" || runningInWatchMode);
|
|
1598
1740
|
const liveReloadPath = !liveReloadEnabled ? "" : options.liveReloadPath ?? `${basePath || ""}/__webframez_live_reload`;
|
|
1599
1741
|
const liveReloadClients = /* @__PURE__ */ new Set();
|
|
1600
|
-
const router = createFileRouter({ pagesDir });
|
|
1742
|
+
const router = createFileRouter({ pagesDir, onData: options.onData });
|
|
1601
1743
|
const getManifestState = createManifestLoader({
|
|
1602
1744
|
distRootDir,
|
|
1603
1745
|
manifestPath,
|
|
@@ -1610,7 +1752,7 @@ function createNodeRequestHandler(options) {
|
|
|
1610
1752
|
process.once("exit", disposeInitialHtmlWorker);
|
|
1611
1753
|
process.once("SIGINT", disposeInitialHtmlWorker);
|
|
1612
1754
|
process.once("SIGTERM", disposeInitialHtmlWorker);
|
|
1613
|
-
|
|
1755
|
+
const handleRequest = async (req, res) => {
|
|
1614
1756
|
if (!req.url) {
|
|
1615
1757
|
res.statusCode = 400;
|
|
1616
1758
|
res.end("Bad request");
|
|
@@ -1674,6 +1816,7 @@ function createNodeRequestHandler(options) {
|
|
|
1674
1816
|
request: requestContext
|
|
1675
1817
|
})
|
|
1676
1818
|
);
|
|
1819
|
+
resolved2.head = { ...resolved2.head, basename: resolved2.head.basename ?? basePath };
|
|
1677
1820
|
attachResolvedContextToCoreRequest(req, resolved2.context);
|
|
1678
1821
|
const payload = {
|
|
1679
1822
|
model: resolved2.model,
|
|
@@ -1749,6 +1892,7 @@ function createNodeRequestHandler(options) {
|
|
|
1749
1892
|
)
|
|
1750
1893
|
})
|
|
1751
1894
|
);
|
|
1895
|
+
resolved.head = { ...resolved.head, basename: resolved.head.basename ?? basePath };
|
|
1752
1896
|
attachResolvedContextToCoreRequest(req, resolved.context);
|
|
1753
1897
|
const initialPayload = {
|
|
1754
1898
|
model: resolved.model,
|
|
@@ -1821,6 +1965,8 @@ function createNodeRequestHandler(options) {
|
|
|
1821
1965
|
initialFlightData,
|
|
1822
1966
|
basename: shellBasename,
|
|
1823
1967
|
routeBasePath: shellRouteBasePath,
|
|
1968
|
+
bodyStartHtml: resolved.head.bodyStartHtml || "",
|
|
1969
|
+
bodyEndHtml: resolved.head.bodyEndHtml || "",
|
|
1824
1970
|
liveReloadPath: liveReloadPath || void 0,
|
|
1825
1971
|
liveReloadServerId: liveReloadPath ? devServerId : void 0
|
|
1826
1972
|
}),
|
|
@@ -1832,6 +1978,7 @@ function createNodeRequestHandler(options) {
|
|
|
1832
1978
|
}
|
|
1833
1979
|
);
|
|
1834
1980
|
};
|
|
1981
|
+
return (req, res) => withRequestBasename(basePath, () => handleRequest(req, res));
|
|
1835
1982
|
}
|
|
1836
1983
|
|
|
1837
1984
|
// src/webframez-core.ts
|
|
@@ -1920,6 +2067,17 @@ function buildRenderDefaults(routePathValue) {
|
|
|
1920
2067
|
clientScriptUrl: `${mountPath}/assets/client.js`
|
|
1921
2068
|
};
|
|
1922
2069
|
}
|
|
2070
|
+
function runtimeRoutePaths(routePath, options, basename = (0, import_routing.getBasename)(), groupPrefix = "") {
|
|
2071
|
+
const localMount = normalizeMountPath(options.basePath ?? `${groupPrefix}${normalizeMountPath(routePath)}`);
|
|
2072
|
+
const basePath = normalizeMountPath((0, import_routing.appPath)(localMount, basename)).replace(/\/$/, "");
|
|
2073
|
+
return {
|
|
2074
|
+
basePath,
|
|
2075
|
+
assetsPrefix: options.assetsPrefix !== void 0 ? (0, import_routing.appPath)(options.assetsPrefix, basename) : `${basePath}/assets/`,
|
|
2076
|
+
rscPath: options.rscPath !== void 0 ? (0, import_routing.appPath)(options.rscPath, basename) : `${basePath}/rsc`,
|
|
2077
|
+
clientScriptUrl: options.clientScriptUrl !== void 0 ? (0, import_routing.appPath)(options.clientScriptUrl, basename) : `${basePath}/assets/client.js`,
|
|
2078
|
+
...typeof options.liveReloadPath === "string" ? { liveReloadPath: (0, import_routing.appPath)(options.liveReloadPath, basename) } : {}
|
|
2079
|
+
};
|
|
2080
|
+
}
|
|
1923
2081
|
async function waitForResponseFinish(res) {
|
|
1924
2082
|
if (res.writableEnded || res.destroyed) {
|
|
1925
2083
|
return;
|
|
@@ -2013,10 +2171,7 @@ function registerRouteRenderer(route, methodName) {
|
|
|
2013
2171
|
distRootDir: resolvedTarget.distRootDir,
|
|
2014
2172
|
pagesDir: resolvedTarget.pagesDir,
|
|
2015
2173
|
manifestPath: resolvedTarget.manifestPath,
|
|
2016
|
-
|
|
2017
|
-
assetsPrefix: assetsPrefix ?? defaults.assetsPrefix,
|
|
2018
|
-
rscPath: rscPath ?? defaults.rscPath,
|
|
2019
|
-
clientScriptUrl: clientScriptUrl ?? defaults.clientScriptUrl
|
|
2174
|
+
...runtimeRoutePaths(routePathValue, options, route.basename ?? (0, import_routing.getBasename)(), route.tempGroupPrefix ?? "")
|
|
2020
2175
|
});
|
|
2021
2176
|
const methods = normalizeMethods(method);
|
|
2022
2177
|
for (const currentMethod of methods) {
|
|
@@ -2058,13 +2213,11 @@ function resolveWebframezReactRouteOptions(routePathValue, options = {}) {
|
|
|
2058
2213
|
distRootDir,
|
|
2059
2214
|
pagesDir,
|
|
2060
2215
|
manifestPath,
|
|
2061
|
-
|
|
2062
|
-
rscPath: options.rscPath ?? defaults.rscPath,
|
|
2063
|
-
clientScriptUrl: options.clientScriptUrl ?? defaults.clientScriptUrl,
|
|
2216
|
+
...runtimeRoutePaths(routePathValue, options),
|
|
2064
2217
|
clientEntryPath: options.clientEntryPath ? resolveFromProjectRoot(options.clientEntryPath) : void 0,
|
|
2065
2218
|
styleSrcPath: options.styleSrcPath ? resolveFromProjectRoot(options.styleSrcPath) : defaults.styleSrcPath,
|
|
2066
|
-
|
|
2067
|
-
|
|
2219
|
+
liveReloadPath: typeof options.liveReloadPath === "string" ? (0, import_routing.appPath)(options.liveReloadPath) : options.liveReloadPath,
|
|
2220
|
+
onData: options.onData
|
|
2068
2221
|
};
|
|
2069
2222
|
}
|
|
2070
2223
|
function getRegisteredReactBuildTargets() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webtypen/webframez-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "TypeScript React RSC addition for @webtypen/webframez-core",
|
|
5
5
|
"homepage": "https://webtypen.de/",
|
|
6
6
|
"author": {
|
|
@@ -74,7 +74,12 @@
|
|
|
74
74
|
"./defaults/webpack.server": "./defaults/webpack.server.cjs",
|
|
75
75
|
"./defaults/tsconfig.server": "./defaults/tsconfig.server.json",
|
|
76
76
|
"./defaults/tsconfig.server.example": "./defaults/tsconfig.server.example.json",
|
|
77
|
-
"./cli": "./bin/webframez-react.mjs"
|
|
77
|
+
"./cli": "./bin/webframez-react.mjs",
|
|
78
|
+
"./paths": {
|
|
79
|
+
"types": "./dist/paths.d.ts",
|
|
80
|
+
"import": "./dist/paths.js",
|
|
81
|
+
"require": "./dist/paths.cjs"
|
|
82
|
+
}
|
|
78
83
|
},
|
|
79
84
|
"files": [
|
|
80
85
|
"dist",
|
|
@@ -88,10 +93,11 @@
|
|
|
88
93
|
"scripts": {
|
|
89
94
|
"clean": "rm -rf dist",
|
|
90
95
|
"build": "npm run clean && node scripts/build.mjs",
|
|
91
|
-
"build:watch": "node scripts/build.mjs --watch"
|
|
96
|
+
"build:watch": "node scripts/build.mjs --watch",
|
|
97
|
+
"test": "node --test tests/*.test.cjs"
|
|
92
98
|
},
|
|
93
99
|
"peerDependencies": {
|
|
94
|
-
"@webtypen/webframez-core": "
|
|
100
|
+
"@webtypen/webframez-core": "0.3.67",
|
|
95
101
|
"react": "^19.0.0 || >=0.0.0-0 <0.0.1",
|
|
96
102
|
"react-dom": "^19.0.0 || >=0.0.0-0 <0.0.1",
|
|
97
103
|
"react-server-dom-webpack": "^19.0.0 || >=0.0.0-0 <0.0.1"
|
|
@@ -102,9 +108,17 @@
|
|
|
102
108
|
}
|
|
103
109
|
},
|
|
104
110
|
"devDependencies": {
|
|
111
|
+
"@webtypen/webframez-core": "0.3.67",
|
|
105
112
|
"esbuild": "^0.20.2",
|
|
106
113
|
"react": "19.1.1",
|
|
107
114
|
"react-dom": "19.1.1",
|
|
108
115
|
"react-server-dom-webpack": "19.1.1"
|
|
116
|
+
},
|
|
117
|
+
"typesVersions": {
|
|
118
|
+
"*": {
|
|
119
|
+
"paths": [
|
|
120
|
+
"dist/paths.d.ts"
|
|
121
|
+
]
|
|
122
|
+
}
|
|
109
123
|
}
|
|
110
124
|
}
|