@webtypen/webframez-react 0.0.16 → 0.0.17
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 +119 -64
- package/dist/http.js +119 -64
- package/dist/index.cjs +119 -64
- package/dist/index.js +119 -64
- package/dist/router.cjs +7 -4
- package/dist/router.js +7 -4
- package/dist/webframez-core.cjs +119 -64
- package/dist/webframez-core.js +119 -64
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -136,28 +136,6 @@ function renderRSCToString(payload, options = {}) {
|
|
|
136
136
|
stream.pipe(writable);
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
function createReadableStreamFromString(value) {
|
|
140
|
-
const encoder = new TextEncoder();
|
|
141
|
-
return new ReadableStream({
|
|
142
|
-
start(controller) {
|
|
143
|
-
controller.enqueue(encoder.encode(value));
|
|
144
|
-
controller.close();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
async function renderHtmlFromFlightData(flightData, options) {
|
|
149
|
-
const appRequire = (0, import_node_module.createRequire)(import_node_path.default.join(process.cwd(), "__webframez_react_server__.js"));
|
|
150
|
-
const reactDomPkg = appRequire.resolve("react-dom/package.json");
|
|
151
|
-
const { renderToString } = appRequire(import_node_path.default.join(import_node_path.default.dirname(reactDomPkg), "server.node.js"));
|
|
152
|
-
const model = await (0, import_client.createFromReadableStream)(createReadableStreamFromString(flightData), {
|
|
153
|
-
serverConsumerManifest: {
|
|
154
|
-
moduleMap: options.moduleMap ?? {},
|
|
155
|
-
serverModuleMap: null,
|
|
156
|
-
moduleLoading: null
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return renderToString(model);
|
|
160
|
-
}
|
|
161
139
|
function sendRSC(res, model, options = {}) {
|
|
162
140
|
const {
|
|
163
141
|
moduleMap = {},
|
|
@@ -265,9 +243,6 @@ function injectRouteChildren(node, routeChildren) {
|
|
|
265
243
|
|
|
266
244
|
// src/file-router.tsx
|
|
267
245
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
268
|
-
var ROOT_RUNTIME_REQUIRE = import_node_module2.default.createRequire(
|
|
269
|
-
import_node_path2.default.join(process.cwd(), "__webframez_react_runtime__.js")
|
|
270
|
-
);
|
|
271
246
|
var FORCED_PACKAGE_REQUESTS = [
|
|
272
247
|
"@webtypen/webframez-core",
|
|
273
248
|
"@webtypen/webframez-react",
|
|
@@ -344,10 +319,16 @@ function installForcedPackageResolution() {
|
|
|
344
319
|
}
|
|
345
320
|
const moduleWithPrivateResolver = import_node_module2.default;
|
|
346
321
|
const originalResolveFilename = moduleWithPrivateResolver._resolveFilename;
|
|
322
|
+
const rootParent = {
|
|
323
|
+
id: "__webframez_react_runtime__",
|
|
324
|
+
filename: import_node_path2.default.join(process.cwd(), "__webframez_react_runtime__.js"),
|
|
325
|
+
path: process.cwd(),
|
|
326
|
+
paths: moduleWithPrivateResolver._nodeModulePaths(process.cwd())
|
|
327
|
+
};
|
|
347
328
|
moduleWithPrivateResolver._resolveFilename = function patchedResolveFilename(request, parent, isMain, options) {
|
|
348
329
|
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
349
330
|
try {
|
|
350
|
-
return
|
|
331
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
351
332
|
} catch {
|
|
352
333
|
}
|
|
353
334
|
}
|
|
@@ -690,39 +671,46 @@ var INITIAL_HTML_WORKER_SCRIPT = `
|
|
|
690
671
|
const path = require("node:path");
|
|
691
672
|
const Module = require("node:module");
|
|
692
673
|
const { Writable } = require("node:stream");
|
|
674
|
+
const { createFromReadableStream } = require("react-server-dom-webpack/client.node");
|
|
693
675
|
|
|
694
676
|
const pagesDir = process.env.WEBFRAMEZ_REACT_PAGES_DIR || "";
|
|
695
677
|
if (!pagesDir) {
|
|
696
678
|
throw new Error("Missing WEBFRAMEZ_REACT_PAGES_DIR");
|
|
697
679
|
}
|
|
698
680
|
|
|
699
|
-
const rootRequire = Module.createRequire(path.join(process.cwd(), "__webframez_react_worker__.js"));
|
|
700
681
|
const originalResolveFilename = Module._resolveFilename;
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
682
|
+
const rootParent = {
|
|
683
|
+
id: "__webframez_react_worker__",
|
|
684
|
+
filename: path.join(process.cwd(), "__webframez_react_worker__.js"),
|
|
685
|
+
path: process.cwd(),
|
|
686
|
+
paths: Module._nodeModulePaths(process.cwd()),
|
|
687
|
+
};
|
|
688
|
+
const forcedPackageRequests = [
|
|
689
|
+
"@webtypen/webframez-core",
|
|
690
|
+
"@webtypen/webframez-react",
|
|
691
|
+
"react",
|
|
692
|
+
"react/jsx-runtime",
|
|
693
|
+
"react/jsx-dev-runtime",
|
|
694
|
+
"react-dom",
|
|
695
|
+
"react-dom/client",
|
|
696
|
+
"react-dom/server",
|
|
697
|
+
"react-dom/server.node",
|
|
698
|
+
"react-server-dom-webpack",
|
|
699
|
+
"react-server-dom-webpack/server",
|
|
700
|
+
"react-server-dom-webpack/client",
|
|
701
|
+
"react-server-dom-webpack/client.node",
|
|
702
|
+
"scheduler"
|
|
703
|
+
];
|
|
704
|
+
|
|
705
|
+
function shouldForcePackageResolution(request) {
|
|
706
|
+
return forcedPackageRequests.some((candidate) =>
|
|
707
|
+
request === candidate || request.startsWith(candidate + "/")
|
|
708
|
+
);
|
|
709
|
+
}
|
|
717
710
|
|
|
718
711
|
Module._resolveFilename = function(request, parent, isMain, options) {
|
|
719
|
-
if (
|
|
720
|
-
return
|
|
721
|
-
}
|
|
722
|
-
for (const forcedRequest of forcedResolutions.keys()) {
|
|
723
|
-
if (request.startsWith(forcedRequest + "/")) {
|
|
724
|
-
return rootRequire.resolve(request);
|
|
725
|
-
}
|
|
712
|
+
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
713
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
726
714
|
}
|
|
727
715
|
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
728
716
|
};
|
|
@@ -769,21 +757,58 @@ function renderHtml(model) {
|
|
|
769
757
|
});
|
|
770
758
|
}
|
|
771
759
|
|
|
760
|
+
function createReadableStreamFromString(value) {
|
|
761
|
+
const encoder = new TextEncoder();
|
|
762
|
+
|
|
763
|
+
return new ReadableStream({
|
|
764
|
+
start(controller) {
|
|
765
|
+
controller.enqueue(encoder.encode(value));
|
|
766
|
+
controller.close();
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
async function renderHtmlFromFlightData(flightData, moduleMap) {
|
|
772
|
+
const model = await createFromReadableStream(createReadableStreamFromString(flightData), {
|
|
773
|
+
serverConsumerManifest: {
|
|
774
|
+
moduleMap: moduleMap || {},
|
|
775
|
+
serverModuleMap: null,
|
|
776
|
+
moduleLoading: null
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
return renderHtml(model);
|
|
781
|
+
}
|
|
782
|
+
|
|
772
783
|
process.on("message", async (message) => {
|
|
773
|
-
if (!message || message.type !== "render") {
|
|
784
|
+
if (!message || (message.type !== "render-route" && message.type !== "render-flight")) {
|
|
774
785
|
return;
|
|
775
786
|
}
|
|
776
787
|
|
|
777
|
-
const previousBasename = globalThis.__RSC_BASENAME;
|
|
778
|
-
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
779
|
-
|
|
780
788
|
try {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
789
|
+
let html = "";
|
|
790
|
+
|
|
791
|
+
if (message.type === "render-route") {
|
|
792
|
+
const previousBasename = globalThis.__RSC_BASENAME;
|
|
793
|
+
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
794
|
+
|
|
795
|
+
try {
|
|
796
|
+
const resolved = await router.resolve({
|
|
797
|
+
pathname: message.payload.pathname,
|
|
798
|
+
searchParams: message.payload.searchParams || {},
|
|
799
|
+
cookies: message.payload.cookies || {},
|
|
800
|
+
});
|
|
801
|
+
html = await renderHtml(resolved.model);
|
|
802
|
+
} finally {
|
|
803
|
+
globalThis.__RSC_BASENAME = previousBasename;
|
|
804
|
+
}
|
|
805
|
+
} else {
|
|
806
|
+
html = await renderHtmlFromFlightData(
|
|
807
|
+
message.payload.flightData || "",
|
|
808
|
+
message.payload.moduleMap || {},
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
|
|
787
812
|
if (typeof process.send === "function") {
|
|
788
813
|
process.send({ id: message.id, ok: true, html });
|
|
789
814
|
}
|
|
@@ -794,8 +819,6 @@ process.on("message", async (message) => {
|
|
|
794
819
|
if (typeof process.send === "function") {
|
|
795
820
|
process.send({ id: message.id, ok: false, error: formatted });
|
|
796
821
|
}
|
|
797
|
-
} finally {
|
|
798
|
-
globalThis.__RSC_BASENAME = previousBasename;
|
|
799
822
|
}
|
|
800
823
|
});
|
|
801
824
|
`;
|
|
@@ -907,7 +930,35 @@ ${stderrBuffer.trim()}` : "";
|
|
|
907
930
|
pending.set(requestId, { resolve, reject, timeout });
|
|
908
931
|
const request = {
|
|
909
932
|
id: requestId,
|
|
910
|
-
type: "render",
|
|
933
|
+
type: "render-route",
|
|
934
|
+
payload
|
|
935
|
+
};
|
|
936
|
+
activeChild.send(request, (error) => {
|
|
937
|
+
if (!error) {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
const entry = pending.get(requestId);
|
|
941
|
+
if (!entry) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
pending.delete(requestId);
|
|
945
|
+
clearTimeout(entry.timeout);
|
|
946
|
+
entry.reject(error instanceof Error ? error : new Error(String(error)));
|
|
947
|
+
});
|
|
948
|
+
});
|
|
949
|
+
},
|
|
950
|
+
renderFromFlightData(payload) {
|
|
951
|
+
const activeChild = startWorker();
|
|
952
|
+
const requestId = nextRequestId++;
|
|
953
|
+
return new Promise((resolve, reject) => {
|
|
954
|
+
const timeout = setTimeout(() => {
|
|
955
|
+
rejectPending(new Error("[webframez-react] Initial HTML worker timed out"));
|
|
956
|
+
stopWorker();
|
|
957
|
+
}, 1e4);
|
|
958
|
+
pending.set(requestId, { resolve, reject, timeout });
|
|
959
|
+
const request = {
|
|
960
|
+
id: requestId,
|
|
961
|
+
type: "render-flight",
|
|
911
962
|
payload
|
|
912
963
|
};
|
|
913
964
|
activeChild.send(request, (error) => {
|
|
@@ -1158,7 +1209,11 @@ function createNodeRequestHandler(options) {
|
|
|
1158
1209
|
} catch (retryError) {
|
|
1159
1210
|
console.error("[webframez-react] Retry for initial HTML failed", retryError);
|
|
1160
1211
|
try {
|
|
1161
|
-
|
|
1212
|
+
initialHtmlWorker.dispose();
|
|
1213
|
+
rootHtml = await initialHtmlWorker.renderFromFlightData({
|
|
1214
|
+
flightData: initialFlightData,
|
|
1215
|
+
moduleMap
|
|
1216
|
+
});
|
|
1162
1217
|
} catch (flightRenderError) {
|
|
1163
1218
|
console.error("[webframez-react] Flight-to-HTML render failed", flightRenderError);
|
|
1164
1219
|
res.statusCode = 500;
|
package/dist/index.js
CHANGED
|
@@ -100,28 +100,6 @@ function renderRSCToString(payload, options = {}) {
|
|
|
100
100
|
stream.pipe(writable);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
function createReadableStreamFromString(value) {
|
|
104
|
-
const encoder = new TextEncoder();
|
|
105
|
-
return new ReadableStream({
|
|
106
|
-
start(controller) {
|
|
107
|
-
controller.enqueue(encoder.encode(value));
|
|
108
|
-
controller.close();
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
async function renderHtmlFromFlightData(flightData, options) {
|
|
113
|
-
const appRequire = createRequire(path.join(process.cwd(), "__webframez_react_server__.js"));
|
|
114
|
-
const reactDomPkg = appRequire.resolve("react-dom/package.json");
|
|
115
|
-
const { renderToString } = appRequire(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
116
|
-
const model = await createFromReadableStream(createReadableStreamFromString(flightData), {
|
|
117
|
-
serverConsumerManifest: {
|
|
118
|
-
moduleMap: options.moduleMap ?? {},
|
|
119
|
-
serverModuleMap: null,
|
|
120
|
-
moduleLoading: null
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return renderToString(model);
|
|
124
|
-
}
|
|
125
103
|
function sendRSC(res, model, options = {}) {
|
|
126
104
|
const {
|
|
127
105
|
moduleMap = {},
|
|
@@ -229,9 +207,6 @@ function injectRouteChildren(node, routeChildren) {
|
|
|
229
207
|
|
|
230
208
|
// src/file-router.tsx
|
|
231
209
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
232
|
-
var ROOT_RUNTIME_REQUIRE = Module.createRequire(
|
|
233
|
-
path2.join(process.cwd(), "__webframez_react_runtime__.js")
|
|
234
|
-
);
|
|
235
210
|
var FORCED_PACKAGE_REQUESTS = [
|
|
236
211
|
"@webtypen/webframez-core",
|
|
237
212
|
"@webtypen/webframez-react",
|
|
@@ -308,10 +283,16 @@ function installForcedPackageResolution() {
|
|
|
308
283
|
}
|
|
309
284
|
const moduleWithPrivateResolver = Module;
|
|
310
285
|
const originalResolveFilename = moduleWithPrivateResolver._resolveFilename;
|
|
286
|
+
const rootParent = {
|
|
287
|
+
id: "__webframez_react_runtime__",
|
|
288
|
+
filename: path2.join(process.cwd(), "__webframez_react_runtime__.js"),
|
|
289
|
+
path: process.cwd(),
|
|
290
|
+
paths: moduleWithPrivateResolver._nodeModulePaths(process.cwd())
|
|
291
|
+
};
|
|
311
292
|
moduleWithPrivateResolver._resolveFilename = function patchedResolveFilename(request, parent, isMain, options) {
|
|
312
293
|
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
313
294
|
try {
|
|
314
|
-
return
|
|
295
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
315
296
|
} catch {
|
|
316
297
|
}
|
|
317
298
|
}
|
|
@@ -654,39 +635,46 @@ var INITIAL_HTML_WORKER_SCRIPT = `
|
|
|
654
635
|
const path = require("node:path");
|
|
655
636
|
const Module = require("node:module");
|
|
656
637
|
const { Writable } = require("node:stream");
|
|
638
|
+
const { createFromReadableStream } = require("react-server-dom-webpack/client.node");
|
|
657
639
|
|
|
658
640
|
const pagesDir = process.env.WEBFRAMEZ_REACT_PAGES_DIR || "";
|
|
659
641
|
if (!pagesDir) {
|
|
660
642
|
throw new Error("Missing WEBFRAMEZ_REACT_PAGES_DIR");
|
|
661
643
|
}
|
|
662
644
|
|
|
663
|
-
const rootRequire = Module.createRequire(path.join(process.cwd(), "__webframez_react_worker__.js"));
|
|
664
645
|
const originalResolveFilename = Module._resolveFilename;
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
646
|
+
const rootParent = {
|
|
647
|
+
id: "__webframez_react_worker__",
|
|
648
|
+
filename: path.join(process.cwd(), "__webframez_react_worker__.js"),
|
|
649
|
+
path: process.cwd(),
|
|
650
|
+
paths: Module._nodeModulePaths(process.cwd()),
|
|
651
|
+
};
|
|
652
|
+
const forcedPackageRequests = [
|
|
653
|
+
"@webtypen/webframez-core",
|
|
654
|
+
"@webtypen/webframez-react",
|
|
655
|
+
"react",
|
|
656
|
+
"react/jsx-runtime",
|
|
657
|
+
"react/jsx-dev-runtime",
|
|
658
|
+
"react-dom",
|
|
659
|
+
"react-dom/client",
|
|
660
|
+
"react-dom/server",
|
|
661
|
+
"react-dom/server.node",
|
|
662
|
+
"react-server-dom-webpack",
|
|
663
|
+
"react-server-dom-webpack/server",
|
|
664
|
+
"react-server-dom-webpack/client",
|
|
665
|
+
"react-server-dom-webpack/client.node",
|
|
666
|
+
"scheduler"
|
|
667
|
+
];
|
|
668
|
+
|
|
669
|
+
function shouldForcePackageResolution(request) {
|
|
670
|
+
return forcedPackageRequests.some((candidate) =>
|
|
671
|
+
request === candidate || request.startsWith(candidate + "/")
|
|
672
|
+
);
|
|
673
|
+
}
|
|
681
674
|
|
|
682
675
|
Module._resolveFilename = function(request, parent, isMain, options) {
|
|
683
|
-
if (
|
|
684
|
-
return
|
|
685
|
-
}
|
|
686
|
-
for (const forcedRequest of forcedResolutions.keys()) {
|
|
687
|
-
if (request.startsWith(forcedRequest + "/")) {
|
|
688
|
-
return rootRequire.resolve(request);
|
|
689
|
-
}
|
|
676
|
+
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
677
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
690
678
|
}
|
|
691
679
|
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
692
680
|
};
|
|
@@ -733,21 +721,58 @@ function renderHtml(model) {
|
|
|
733
721
|
});
|
|
734
722
|
}
|
|
735
723
|
|
|
724
|
+
function createReadableStreamFromString(value) {
|
|
725
|
+
const encoder = new TextEncoder();
|
|
726
|
+
|
|
727
|
+
return new ReadableStream({
|
|
728
|
+
start(controller) {
|
|
729
|
+
controller.enqueue(encoder.encode(value));
|
|
730
|
+
controller.close();
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
async function renderHtmlFromFlightData(flightData, moduleMap) {
|
|
736
|
+
const model = await createFromReadableStream(createReadableStreamFromString(flightData), {
|
|
737
|
+
serverConsumerManifest: {
|
|
738
|
+
moduleMap: moduleMap || {},
|
|
739
|
+
serverModuleMap: null,
|
|
740
|
+
moduleLoading: null
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
return renderHtml(model);
|
|
745
|
+
}
|
|
746
|
+
|
|
736
747
|
process.on("message", async (message) => {
|
|
737
|
-
if (!message || message.type !== "render") {
|
|
748
|
+
if (!message || (message.type !== "render-route" && message.type !== "render-flight")) {
|
|
738
749
|
return;
|
|
739
750
|
}
|
|
740
751
|
|
|
741
|
-
const previousBasename = globalThis.__RSC_BASENAME;
|
|
742
|
-
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
743
|
-
|
|
744
752
|
try {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
753
|
+
let html = "";
|
|
754
|
+
|
|
755
|
+
if (message.type === "render-route") {
|
|
756
|
+
const previousBasename = globalThis.__RSC_BASENAME;
|
|
757
|
+
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
758
|
+
|
|
759
|
+
try {
|
|
760
|
+
const resolved = await router.resolve({
|
|
761
|
+
pathname: message.payload.pathname,
|
|
762
|
+
searchParams: message.payload.searchParams || {},
|
|
763
|
+
cookies: message.payload.cookies || {},
|
|
764
|
+
});
|
|
765
|
+
html = await renderHtml(resolved.model);
|
|
766
|
+
} finally {
|
|
767
|
+
globalThis.__RSC_BASENAME = previousBasename;
|
|
768
|
+
}
|
|
769
|
+
} else {
|
|
770
|
+
html = await renderHtmlFromFlightData(
|
|
771
|
+
message.payload.flightData || "",
|
|
772
|
+
message.payload.moduleMap || {},
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
|
|
751
776
|
if (typeof process.send === "function") {
|
|
752
777
|
process.send({ id: message.id, ok: true, html });
|
|
753
778
|
}
|
|
@@ -758,8 +783,6 @@ process.on("message", async (message) => {
|
|
|
758
783
|
if (typeof process.send === "function") {
|
|
759
784
|
process.send({ id: message.id, ok: false, error: formatted });
|
|
760
785
|
}
|
|
761
|
-
} finally {
|
|
762
|
-
globalThis.__RSC_BASENAME = previousBasename;
|
|
763
786
|
}
|
|
764
787
|
});
|
|
765
788
|
`;
|
|
@@ -871,7 +894,35 @@ ${stderrBuffer.trim()}` : "";
|
|
|
871
894
|
pending.set(requestId, { resolve, reject, timeout });
|
|
872
895
|
const request = {
|
|
873
896
|
id: requestId,
|
|
874
|
-
type: "render",
|
|
897
|
+
type: "render-route",
|
|
898
|
+
payload
|
|
899
|
+
};
|
|
900
|
+
activeChild.send(request, (error) => {
|
|
901
|
+
if (!error) {
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
const entry = pending.get(requestId);
|
|
905
|
+
if (!entry) {
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
pending.delete(requestId);
|
|
909
|
+
clearTimeout(entry.timeout);
|
|
910
|
+
entry.reject(error instanceof Error ? error : new Error(String(error)));
|
|
911
|
+
});
|
|
912
|
+
});
|
|
913
|
+
},
|
|
914
|
+
renderFromFlightData(payload) {
|
|
915
|
+
const activeChild = startWorker();
|
|
916
|
+
const requestId = nextRequestId++;
|
|
917
|
+
return new Promise((resolve, reject) => {
|
|
918
|
+
const timeout = setTimeout(() => {
|
|
919
|
+
rejectPending(new Error("[webframez-react] Initial HTML worker timed out"));
|
|
920
|
+
stopWorker();
|
|
921
|
+
}, 1e4);
|
|
922
|
+
pending.set(requestId, { resolve, reject, timeout });
|
|
923
|
+
const request = {
|
|
924
|
+
id: requestId,
|
|
925
|
+
type: "render-flight",
|
|
875
926
|
payload
|
|
876
927
|
};
|
|
877
928
|
activeChild.send(request, (error) => {
|
|
@@ -1122,7 +1173,11 @@ function createNodeRequestHandler(options) {
|
|
|
1122
1173
|
} catch (retryError) {
|
|
1123
1174
|
console.error("[webframez-react] Retry for initial HTML failed", retryError);
|
|
1124
1175
|
try {
|
|
1125
|
-
|
|
1176
|
+
initialHtmlWorker.dispose();
|
|
1177
|
+
rootHtml = await initialHtmlWorker.renderFromFlightData({
|
|
1178
|
+
flightData: initialFlightData,
|
|
1179
|
+
moduleMap
|
|
1180
|
+
});
|
|
1126
1181
|
} catch (flightRenderError) {
|
|
1127
1182
|
console.error("[webframez-react] Flight-to-HTML render failed", flightRenderError);
|
|
1128
1183
|
res.statusCode = 500;
|
package/dist/router.cjs
CHANGED
|
@@ -101,9 +101,6 @@ function injectRouteChildren(node, routeChildren) {
|
|
|
101
101
|
|
|
102
102
|
// src/file-router.tsx
|
|
103
103
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
104
|
-
var ROOT_RUNTIME_REQUIRE = import_node_module.default.createRequire(
|
|
105
|
-
import_node_path.default.join(process.cwd(), "__webframez_react_runtime__.js")
|
|
106
|
-
);
|
|
107
104
|
var FORCED_PACKAGE_REQUESTS = [
|
|
108
105
|
"@webtypen/webframez-core",
|
|
109
106
|
"@webtypen/webframez-react",
|
|
@@ -180,10 +177,16 @@ function installForcedPackageResolution() {
|
|
|
180
177
|
}
|
|
181
178
|
const moduleWithPrivateResolver = import_node_module.default;
|
|
182
179
|
const originalResolveFilename = moduleWithPrivateResolver._resolveFilename;
|
|
180
|
+
const rootParent = {
|
|
181
|
+
id: "__webframez_react_runtime__",
|
|
182
|
+
filename: import_node_path.default.join(process.cwd(), "__webframez_react_runtime__.js"),
|
|
183
|
+
path: process.cwd(),
|
|
184
|
+
paths: moduleWithPrivateResolver._nodeModulePaths(process.cwd())
|
|
185
|
+
};
|
|
183
186
|
moduleWithPrivateResolver._resolveFilename = function patchedResolveFilename(request, parent, isMain, options) {
|
|
184
187
|
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
185
188
|
try {
|
|
186
|
-
return
|
|
189
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
187
190
|
} catch {
|
|
188
191
|
}
|
|
189
192
|
}
|
package/dist/router.js
CHANGED
|
@@ -71,9 +71,6 @@ function injectRouteChildren(node, routeChildren) {
|
|
|
71
71
|
|
|
72
72
|
// src/file-router.tsx
|
|
73
73
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
74
|
-
var ROOT_RUNTIME_REQUIRE = Module.createRequire(
|
|
75
|
-
path.join(process.cwd(), "__webframez_react_runtime__.js")
|
|
76
|
-
);
|
|
77
74
|
var FORCED_PACKAGE_REQUESTS = [
|
|
78
75
|
"@webtypen/webframez-core",
|
|
79
76
|
"@webtypen/webframez-react",
|
|
@@ -150,10 +147,16 @@ function installForcedPackageResolution() {
|
|
|
150
147
|
}
|
|
151
148
|
const moduleWithPrivateResolver = Module;
|
|
152
149
|
const originalResolveFilename = moduleWithPrivateResolver._resolveFilename;
|
|
150
|
+
const rootParent = {
|
|
151
|
+
id: "__webframez_react_runtime__",
|
|
152
|
+
filename: path.join(process.cwd(), "__webframez_react_runtime__.js"),
|
|
153
|
+
path: process.cwd(),
|
|
154
|
+
paths: moduleWithPrivateResolver._nodeModulePaths(process.cwd())
|
|
155
|
+
};
|
|
153
156
|
moduleWithPrivateResolver._resolveFilename = function patchedResolveFilename(request, parent, isMain, options) {
|
|
154
157
|
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
155
158
|
try {
|
|
156
|
-
return
|
|
159
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
157
160
|
} catch {
|
|
158
161
|
}
|
|
159
162
|
}
|