@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/http.cjs
CHANGED
|
@@ -131,28 +131,6 @@ function renderRSCToString(payload, options = {}) {
|
|
|
131
131
|
stream.pipe(writable);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
function createReadableStreamFromString(value) {
|
|
135
|
-
const encoder = new TextEncoder();
|
|
136
|
-
return new ReadableStream({
|
|
137
|
-
start(controller) {
|
|
138
|
-
controller.enqueue(encoder.encode(value));
|
|
139
|
-
controller.close();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
async function renderHtmlFromFlightData(flightData, options) {
|
|
144
|
-
const appRequire = (0, import_node_module.createRequire)(import_node_path.default.join(process.cwd(), "__webframez_react_server__.js"));
|
|
145
|
-
const reactDomPkg = appRequire.resolve("react-dom/package.json");
|
|
146
|
-
const { renderToString } = appRequire(import_node_path.default.join(import_node_path.default.dirname(reactDomPkg), "server.node.js"));
|
|
147
|
-
const model = await (0, import_client.createFromReadableStream)(createReadableStreamFromString(flightData), {
|
|
148
|
-
serverConsumerManifest: {
|
|
149
|
-
moduleMap: options.moduleMap ?? {},
|
|
150
|
-
serverModuleMap: null,
|
|
151
|
-
moduleLoading: null
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
return renderToString(model);
|
|
155
|
-
}
|
|
156
134
|
function sendRSC(res, model, options = {}) {
|
|
157
135
|
const {
|
|
158
136
|
moduleMap = {},
|
|
@@ -232,9 +210,6 @@ function injectRouteChildren(node, routeChildren) {
|
|
|
232
210
|
|
|
233
211
|
// src/file-router.tsx
|
|
234
212
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
235
|
-
var ROOT_RUNTIME_REQUIRE = import_node_module2.default.createRequire(
|
|
236
|
-
import_node_path2.default.join(process.cwd(), "__webframez_react_runtime__.js")
|
|
237
|
-
);
|
|
238
213
|
var FORCED_PACKAGE_REQUESTS = [
|
|
239
214
|
"@webtypen/webframez-core",
|
|
240
215
|
"@webtypen/webframez-react",
|
|
@@ -311,10 +286,16 @@ function installForcedPackageResolution() {
|
|
|
311
286
|
}
|
|
312
287
|
const moduleWithPrivateResolver = import_node_module2.default;
|
|
313
288
|
const originalResolveFilename = moduleWithPrivateResolver._resolveFilename;
|
|
289
|
+
const rootParent = {
|
|
290
|
+
id: "__webframez_react_runtime__",
|
|
291
|
+
filename: import_node_path2.default.join(process.cwd(), "__webframez_react_runtime__.js"),
|
|
292
|
+
path: process.cwd(),
|
|
293
|
+
paths: moduleWithPrivateResolver._nodeModulePaths(process.cwd())
|
|
294
|
+
};
|
|
314
295
|
moduleWithPrivateResolver._resolveFilename = function patchedResolveFilename(request, parent, isMain, options) {
|
|
315
296
|
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
316
297
|
try {
|
|
317
|
-
return
|
|
298
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
318
299
|
} catch {
|
|
319
300
|
}
|
|
320
301
|
}
|
|
@@ -653,39 +634,46 @@ var INITIAL_HTML_WORKER_SCRIPT = `
|
|
|
653
634
|
const path = require("node:path");
|
|
654
635
|
const Module = require("node:module");
|
|
655
636
|
const { Writable } = require("node:stream");
|
|
637
|
+
const { createFromReadableStream } = require("react-server-dom-webpack/client.node");
|
|
656
638
|
|
|
657
639
|
const pagesDir = process.env.WEBFRAMEZ_REACT_PAGES_DIR || "";
|
|
658
640
|
if (!pagesDir) {
|
|
659
641
|
throw new Error("Missing WEBFRAMEZ_REACT_PAGES_DIR");
|
|
660
642
|
}
|
|
661
643
|
|
|
662
|
-
const rootRequire = Module.createRequire(path.join(process.cwd(), "__webframez_react_worker__.js"));
|
|
663
644
|
const originalResolveFilename = Module._resolveFilename;
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
645
|
+
const rootParent = {
|
|
646
|
+
id: "__webframez_react_worker__",
|
|
647
|
+
filename: path.join(process.cwd(), "__webframez_react_worker__.js"),
|
|
648
|
+
path: process.cwd(),
|
|
649
|
+
paths: Module._nodeModulePaths(process.cwd()),
|
|
650
|
+
};
|
|
651
|
+
const forcedPackageRequests = [
|
|
652
|
+
"@webtypen/webframez-core",
|
|
653
|
+
"@webtypen/webframez-react",
|
|
654
|
+
"react",
|
|
655
|
+
"react/jsx-runtime",
|
|
656
|
+
"react/jsx-dev-runtime",
|
|
657
|
+
"react-dom",
|
|
658
|
+
"react-dom/client",
|
|
659
|
+
"react-dom/server",
|
|
660
|
+
"react-dom/server.node",
|
|
661
|
+
"react-server-dom-webpack",
|
|
662
|
+
"react-server-dom-webpack/server",
|
|
663
|
+
"react-server-dom-webpack/client",
|
|
664
|
+
"react-server-dom-webpack/client.node",
|
|
665
|
+
"scheduler"
|
|
666
|
+
];
|
|
667
|
+
|
|
668
|
+
function shouldForcePackageResolution(request) {
|
|
669
|
+
return forcedPackageRequests.some((candidate) =>
|
|
670
|
+
request === candidate || request.startsWith(candidate + "/")
|
|
671
|
+
);
|
|
672
|
+
}
|
|
680
673
|
|
|
681
674
|
Module._resolveFilename = function(request, parent, isMain, options) {
|
|
682
|
-
if (
|
|
683
|
-
return
|
|
684
|
-
}
|
|
685
|
-
for (const forcedRequest of forcedResolutions.keys()) {
|
|
686
|
-
if (request.startsWith(forcedRequest + "/")) {
|
|
687
|
-
return rootRequire.resolve(request);
|
|
688
|
-
}
|
|
675
|
+
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
676
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
689
677
|
}
|
|
690
678
|
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
691
679
|
};
|
|
@@ -732,21 +720,58 @@ function renderHtml(model) {
|
|
|
732
720
|
});
|
|
733
721
|
}
|
|
734
722
|
|
|
723
|
+
function createReadableStreamFromString(value) {
|
|
724
|
+
const encoder = new TextEncoder();
|
|
725
|
+
|
|
726
|
+
return new ReadableStream({
|
|
727
|
+
start(controller) {
|
|
728
|
+
controller.enqueue(encoder.encode(value));
|
|
729
|
+
controller.close();
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
async function renderHtmlFromFlightData(flightData, moduleMap) {
|
|
735
|
+
const model = await createFromReadableStream(createReadableStreamFromString(flightData), {
|
|
736
|
+
serverConsumerManifest: {
|
|
737
|
+
moduleMap: moduleMap || {},
|
|
738
|
+
serverModuleMap: null,
|
|
739
|
+
moduleLoading: null
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
return renderHtml(model);
|
|
744
|
+
}
|
|
745
|
+
|
|
735
746
|
process.on("message", async (message) => {
|
|
736
|
-
if (!message || message.type !== "render") {
|
|
747
|
+
if (!message || (message.type !== "render-route" && message.type !== "render-flight")) {
|
|
737
748
|
return;
|
|
738
749
|
}
|
|
739
750
|
|
|
740
|
-
const previousBasename = globalThis.__RSC_BASENAME;
|
|
741
|
-
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
742
|
-
|
|
743
751
|
try {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
752
|
+
let html = "";
|
|
753
|
+
|
|
754
|
+
if (message.type === "render-route") {
|
|
755
|
+
const previousBasename = globalThis.__RSC_BASENAME;
|
|
756
|
+
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
757
|
+
|
|
758
|
+
try {
|
|
759
|
+
const resolved = await router.resolve({
|
|
760
|
+
pathname: message.payload.pathname,
|
|
761
|
+
searchParams: message.payload.searchParams || {},
|
|
762
|
+
cookies: message.payload.cookies || {},
|
|
763
|
+
});
|
|
764
|
+
html = await renderHtml(resolved.model);
|
|
765
|
+
} finally {
|
|
766
|
+
globalThis.__RSC_BASENAME = previousBasename;
|
|
767
|
+
}
|
|
768
|
+
} else {
|
|
769
|
+
html = await renderHtmlFromFlightData(
|
|
770
|
+
message.payload.flightData || "",
|
|
771
|
+
message.payload.moduleMap || {},
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
|
|
750
775
|
if (typeof process.send === "function") {
|
|
751
776
|
process.send({ id: message.id, ok: true, html });
|
|
752
777
|
}
|
|
@@ -757,8 +782,6 @@ process.on("message", async (message) => {
|
|
|
757
782
|
if (typeof process.send === "function") {
|
|
758
783
|
process.send({ id: message.id, ok: false, error: formatted });
|
|
759
784
|
}
|
|
760
|
-
} finally {
|
|
761
|
-
globalThis.__RSC_BASENAME = previousBasename;
|
|
762
785
|
}
|
|
763
786
|
});
|
|
764
787
|
`;
|
|
@@ -870,7 +893,35 @@ ${stderrBuffer.trim()}` : "";
|
|
|
870
893
|
pending.set(requestId, { resolve, reject, timeout });
|
|
871
894
|
const request = {
|
|
872
895
|
id: requestId,
|
|
873
|
-
type: "render",
|
|
896
|
+
type: "render-route",
|
|
897
|
+
payload
|
|
898
|
+
};
|
|
899
|
+
activeChild.send(request, (error) => {
|
|
900
|
+
if (!error) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
const entry = pending.get(requestId);
|
|
904
|
+
if (!entry) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
pending.delete(requestId);
|
|
908
|
+
clearTimeout(entry.timeout);
|
|
909
|
+
entry.reject(error instanceof Error ? error : new Error(String(error)));
|
|
910
|
+
});
|
|
911
|
+
});
|
|
912
|
+
},
|
|
913
|
+
renderFromFlightData(payload) {
|
|
914
|
+
const activeChild = startWorker();
|
|
915
|
+
const requestId = nextRequestId++;
|
|
916
|
+
return new Promise((resolve, reject) => {
|
|
917
|
+
const timeout = setTimeout(() => {
|
|
918
|
+
rejectPending(new Error("[webframez-react] Initial HTML worker timed out"));
|
|
919
|
+
stopWorker();
|
|
920
|
+
}, 1e4);
|
|
921
|
+
pending.set(requestId, { resolve, reject, timeout });
|
|
922
|
+
const request = {
|
|
923
|
+
id: requestId,
|
|
924
|
+
type: "render-flight",
|
|
874
925
|
payload
|
|
875
926
|
};
|
|
876
927
|
activeChild.send(request, (error) => {
|
|
@@ -1121,7 +1172,11 @@ function createNodeRequestHandler(options) {
|
|
|
1121
1172
|
} catch (retryError) {
|
|
1122
1173
|
console.error("[webframez-react] Retry for initial HTML failed", retryError);
|
|
1123
1174
|
try {
|
|
1124
|
-
|
|
1175
|
+
initialHtmlWorker.dispose();
|
|
1176
|
+
rootHtml = await initialHtmlWorker.renderFromFlightData({
|
|
1177
|
+
flightData: initialFlightData,
|
|
1178
|
+
moduleMap
|
|
1179
|
+
});
|
|
1125
1180
|
} catch (flightRenderError) {
|
|
1126
1181
|
console.error("[webframez-react] Flight-to-HTML render failed", flightRenderError);
|
|
1127
1182
|
res.statusCode = 500;
|
package/dist/http.js
CHANGED
|
@@ -106,28 +106,6 @@ function renderRSCToString(payload, options = {}) {
|
|
|
106
106
|
stream.pipe(writable);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
function createReadableStreamFromString(value) {
|
|
110
|
-
const encoder = new TextEncoder();
|
|
111
|
-
return new ReadableStream({
|
|
112
|
-
start(controller) {
|
|
113
|
-
controller.enqueue(encoder.encode(value));
|
|
114
|
-
controller.close();
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
async function renderHtmlFromFlightData(flightData, options) {
|
|
119
|
-
const appRequire = createRequire(path.join(process.cwd(), "__webframez_react_server__.js"));
|
|
120
|
-
const reactDomPkg = appRequire.resolve("react-dom/package.json");
|
|
121
|
-
const { renderToString } = appRequire(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
122
|
-
const model = await createFromReadableStream(createReadableStreamFromString(flightData), {
|
|
123
|
-
serverConsumerManifest: {
|
|
124
|
-
moduleMap: options.moduleMap ?? {},
|
|
125
|
-
serverModuleMap: null,
|
|
126
|
-
moduleLoading: null
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return renderToString(model);
|
|
130
|
-
}
|
|
131
109
|
function sendRSC(res, model, options = {}) {
|
|
132
110
|
const {
|
|
133
111
|
moduleMap = {},
|
|
@@ -207,9 +185,6 @@ function injectRouteChildren(node, routeChildren) {
|
|
|
207
185
|
|
|
208
186
|
// src/file-router.tsx
|
|
209
187
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
210
|
-
var ROOT_RUNTIME_REQUIRE = Module.createRequire(
|
|
211
|
-
path2.join(process.cwd(), "__webframez_react_runtime__.js")
|
|
212
|
-
);
|
|
213
188
|
var FORCED_PACKAGE_REQUESTS = [
|
|
214
189
|
"@webtypen/webframez-core",
|
|
215
190
|
"@webtypen/webframez-react",
|
|
@@ -286,10 +261,16 @@ function installForcedPackageResolution() {
|
|
|
286
261
|
}
|
|
287
262
|
const moduleWithPrivateResolver = Module;
|
|
288
263
|
const originalResolveFilename = moduleWithPrivateResolver._resolveFilename;
|
|
264
|
+
const rootParent = {
|
|
265
|
+
id: "__webframez_react_runtime__",
|
|
266
|
+
filename: path2.join(process.cwd(), "__webframez_react_runtime__.js"),
|
|
267
|
+
path: process.cwd(),
|
|
268
|
+
paths: moduleWithPrivateResolver._nodeModulePaths(process.cwd())
|
|
269
|
+
};
|
|
289
270
|
moduleWithPrivateResolver._resolveFilename = function patchedResolveFilename(request, parent, isMain, options) {
|
|
290
271
|
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
291
272
|
try {
|
|
292
|
-
return
|
|
273
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
293
274
|
} catch {
|
|
294
275
|
}
|
|
295
276
|
}
|
|
@@ -628,39 +609,46 @@ var INITIAL_HTML_WORKER_SCRIPT = `
|
|
|
628
609
|
const path = require("node:path");
|
|
629
610
|
const Module = require("node:module");
|
|
630
611
|
const { Writable } = require("node:stream");
|
|
612
|
+
const { createFromReadableStream } = require("react-server-dom-webpack/client.node");
|
|
631
613
|
|
|
632
614
|
const pagesDir = process.env.WEBFRAMEZ_REACT_PAGES_DIR || "";
|
|
633
615
|
if (!pagesDir) {
|
|
634
616
|
throw new Error("Missing WEBFRAMEZ_REACT_PAGES_DIR");
|
|
635
617
|
}
|
|
636
618
|
|
|
637
|
-
const rootRequire = Module.createRequire(path.join(process.cwd(), "__webframez_react_worker__.js"));
|
|
638
619
|
const originalResolveFilename = Module._resolveFilename;
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
620
|
+
const rootParent = {
|
|
621
|
+
id: "__webframez_react_worker__",
|
|
622
|
+
filename: path.join(process.cwd(), "__webframez_react_worker__.js"),
|
|
623
|
+
path: process.cwd(),
|
|
624
|
+
paths: Module._nodeModulePaths(process.cwd()),
|
|
625
|
+
};
|
|
626
|
+
const forcedPackageRequests = [
|
|
627
|
+
"@webtypen/webframez-core",
|
|
628
|
+
"@webtypen/webframez-react",
|
|
629
|
+
"react",
|
|
630
|
+
"react/jsx-runtime",
|
|
631
|
+
"react/jsx-dev-runtime",
|
|
632
|
+
"react-dom",
|
|
633
|
+
"react-dom/client",
|
|
634
|
+
"react-dom/server",
|
|
635
|
+
"react-dom/server.node",
|
|
636
|
+
"react-server-dom-webpack",
|
|
637
|
+
"react-server-dom-webpack/server",
|
|
638
|
+
"react-server-dom-webpack/client",
|
|
639
|
+
"react-server-dom-webpack/client.node",
|
|
640
|
+
"scheduler"
|
|
641
|
+
];
|
|
642
|
+
|
|
643
|
+
function shouldForcePackageResolution(request) {
|
|
644
|
+
return forcedPackageRequests.some((candidate) =>
|
|
645
|
+
request === candidate || request.startsWith(candidate + "/")
|
|
646
|
+
);
|
|
647
|
+
}
|
|
655
648
|
|
|
656
649
|
Module._resolveFilename = function(request, parent, isMain, options) {
|
|
657
|
-
if (
|
|
658
|
-
return
|
|
659
|
-
}
|
|
660
|
-
for (const forcedRequest of forcedResolutions.keys()) {
|
|
661
|
-
if (request.startsWith(forcedRequest + "/")) {
|
|
662
|
-
return rootRequire.resolve(request);
|
|
663
|
-
}
|
|
650
|
+
if (typeof request === "string" && shouldForcePackageResolution(request)) {
|
|
651
|
+
return originalResolveFilename.call(this, request, rootParent, false, options);
|
|
664
652
|
}
|
|
665
653
|
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
666
654
|
};
|
|
@@ -707,21 +695,58 @@ function renderHtml(model) {
|
|
|
707
695
|
});
|
|
708
696
|
}
|
|
709
697
|
|
|
698
|
+
function createReadableStreamFromString(value) {
|
|
699
|
+
const encoder = new TextEncoder();
|
|
700
|
+
|
|
701
|
+
return new ReadableStream({
|
|
702
|
+
start(controller) {
|
|
703
|
+
controller.enqueue(encoder.encode(value));
|
|
704
|
+
controller.close();
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
async function renderHtmlFromFlightData(flightData, moduleMap) {
|
|
710
|
+
const model = await createFromReadableStream(createReadableStreamFromString(flightData), {
|
|
711
|
+
serverConsumerManifest: {
|
|
712
|
+
moduleMap: moduleMap || {},
|
|
713
|
+
serverModuleMap: null,
|
|
714
|
+
moduleLoading: null
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
return renderHtml(model);
|
|
719
|
+
}
|
|
720
|
+
|
|
710
721
|
process.on("message", async (message) => {
|
|
711
|
-
if (!message || message.type !== "render") {
|
|
722
|
+
if (!message || (message.type !== "render-route" && message.type !== "render-flight")) {
|
|
712
723
|
return;
|
|
713
724
|
}
|
|
714
725
|
|
|
715
|
-
const previousBasename = globalThis.__RSC_BASENAME;
|
|
716
|
-
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
717
|
-
|
|
718
726
|
try {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
727
|
+
let html = "";
|
|
728
|
+
|
|
729
|
+
if (message.type === "render-route") {
|
|
730
|
+
const previousBasename = globalThis.__RSC_BASENAME;
|
|
731
|
+
globalThis.__RSC_BASENAME = message.payload.basename || "";
|
|
732
|
+
|
|
733
|
+
try {
|
|
734
|
+
const resolved = await router.resolve({
|
|
735
|
+
pathname: message.payload.pathname,
|
|
736
|
+
searchParams: message.payload.searchParams || {},
|
|
737
|
+
cookies: message.payload.cookies || {},
|
|
738
|
+
});
|
|
739
|
+
html = await renderHtml(resolved.model);
|
|
740
|
+
} finally {
|
|
741
|
+
globalThis.__RSC_BASENAME = previousBasename;
|
|
742
|
+
}
|
|
743
|
+
} else {
|
|
744
|
+
html = await renderHtmlFromFlightData(
|
|
745
|
+
message.payload.flightData || "",
|
|
746
|
+
message.payload.moduleMap || {},
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
|
|
725
750
|
if (typeof process.send === "function") {
|
|
726
751
|
process.send({ id: message.id, ok: true, html });
|
|
727
752
|
}
|
|
@@ -732,8 +757,6 @@ process.on("message", async (message) => {
|
|
|
732
757
|
if (typeof process.send === "function") {
|
|
733
758
|
process.send({ id: message.id, ok: false, error: formatted });
|
|
734
759
|
}
|
|
735
|
-
} finally {
|
|
736
|
-
globalThis.__RSC_BASENAME = previousBasename;
|
|
737
760
|
}
|
|
738
761
|
});
|
|
739
762
|
`;
|
|
@@ -845,7 +868,35 @@ ${stderrBuffer.trim()}` : "";
|
|
|
845
868
|
pending.set(requestId, { resolve, reject, timeout });
|
|
846
869
|
const request = {
|
|
847
870
|
id: requestId,
|
|
848
|
-
type: "render",
|
|
871
|
+
type: "render-route",
|
|
872
|
+
payload
|
|
873
|
+
};
|
|
874
|
+
activeChild.send(request, (error) => {
|
|
875
|
+
if (!error) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
const entry = pending.get(requestId);
|
|
879
|
+
if (!entry) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
pending.delete(requestId);
|
|
883
|
+
clearTimeout(entry.timeout);
|
|
884
|
+
entry.reject(error instanceof Error ? error : new Error(String(error)));
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
},
|
|
888
|
+
renderFromFlightData(payload) {
|
|
889
|
+
const activeChild = startWorker();
|
|
890
|
+
const requestId = nextRequestId++;
|
|
891
|
+
return new Promise((resolve, reject) => {
|
|
892
|
+
const timeout = setTimeout(() => {
|
|
893
|
+
rejectPending(new Error("[webframez-react] Initial HTML worker timed out"));
|
|
894
|
+
stopWorker();
|
|
895
|
+
}, 1e4);
|
|
896
|
+
pending.set(requestId, { resolve, reject, timeout });
|
|
897
|
+
const request = {
|
|
898
|
+
id: requestId,
|
|
899
|
+
type: "render-flight",
|
|
849
900
|
payload
|
|
850
901
|
};
|
|
851
902
|
activeChild.send(request, (error) => {
|
|
@@ -1096,7 +1147,11 @@ function createNodeRequestHandler(options) {
|
|
|
1096
1147
|
} catch (retryError) {
|
|
1097
1148
|
console.error("[webframez-react] Retry for initial HTML failed", retryError);
|
|
1098
1149
|
try {
|
|
1099
|
-
|
|
1150
|
+
initialHtmlWorker.dispose();
|
|
1151
|
+
rootHtml = await initialHtmlWorker.renderFromFlightData({
|
|
1152
|
+
flightData: initialFlightData,
|
|
1153
|
+
moduleMap
|
|
1154
|
+
});
|
|
1100
1155
|
} catch (flightRenderError) {
|
|
1101
1156
|
console.error("[webframez-react] Flight-to-HTML render failed", flightRenderError);
|
|
1102
1157
|
res.statusCode = 500;
|