hadars 0.3.1 → 0.3.2
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 +2 -0
- package/dist/{chunk-2KJRDPCN.js → chunk-2J2L2H3H.js} +9 -9
- package/dist/{chunk-LY5MTHFV.js → chunk-TV37IMRB.js} +50 -51
- package/dist/cli.js +70 -67
- package/dist/cloudflare.cjs +56 -57
- package/dist/cloudflare.js +2 -2
- package/dist/lambda.cjs +58 -65
- package/dist/lambda.js +4 -10
- package/dist/slim-react/index.cjs +50 -51
- package/dist/slim-react/index.js +1 -1
- package/dist/ssr-render-worker.js +46 -47
- package/dist/ssr-watch.js +9 -6
- package/package.json +2 -2
- package/src/build.ts +9 -5
- package/src/lambda.ts +7 -14
- package/src/slim-react/render.ts +39 -25
- package/src/slim-react/renderContext.ts +34 -11
- package/src/utils/rspack.ts +9 -6
- package/src/utils/ssrHandler.ts +13 -8
package/dist/cloudflare.cjs
CHANGED
|
@@ -283,7 +283,16 @@ function componentCalledUseId() {
|
|
|
283
283
|
function snapshotContext() {
|
|
284
284
|
const st = s();
|
|
285
285
|
const ctx = st.currentTreeContext;
|
|
286
|
-
|
|
286
|
+
const depth = _treeDepth;
|
|
287
|
+
return {
|
|
288
|
+
tree: { id: ctx.id, overflow: ctx.overflow },
|
|
289
|
+
localId: st.localIdCounter,
|
|
290
|
+
treeDepth: depth,
|
|
291
|
+
// Snapshot the live stack so that popTreeContext reads correct saved values
|
|
292
|
+
// even if another concurrent render's resetRenderState stomped the arrays.
|
|
293
|
+
idStack: _treeIdStack.slice(0, depth),
|
|
294
|
+
ovStack: _treeOvStack.slice(0, depth)
|
|
295
|
+
};
|
|
287
296
|
}
|
|
288
297
|
function restoreContext(snap) {
|
|
289
298
|
const st = s();
|
|
@@ -292,6 +301,10 @@ function restoreContext(snap) {
|
|
|
292
301
|
ctx.overflow = snap.tree.overflow;
|
|
293
302
|
st.localIdCounter = snap.localId;
|
|
294
303
|
_treeDepth = snap.treeDepth;
|
|
304
|
+
for (let i = 0; i < snap.treeDepth; i++) {
|
|
305
|
+
_treeIdStack[i] = snap.idStack[i];
|
|
306
|
+
_treeOvStack[i] = snap.ovStack[i];
|
|
307
|
+
}
|
|
295
308
|
}
|
|
296
309
|
function getTreeId() {
|
|
297
310
|
const { id, overflow } = s().currentTreeContext;
|
|
@@ -405,6 +418,14 @@ function restoreDispatcher(prev) {
|
|
|
405
418
|
}
|
|
406
419
|
|
|
407
420
|
// src/slim-react/render.ts
|
|
421
|
+
function captureRenderCtx() {
|
|
422
|
+
return { m: captureMap(), u: captureUnsuspend(), t: snapshotContext() };
|
|
423
|
+
}
|
|
424
|
+
function restoreRenderCtx(ctx) {
|
|
425
|
+
swapContextMap(ctx.m);
|
|
426
|
+
restoreUnsuspend(ctx.u);
|
|
427
|
+
restoreContext(ctx.t);
|
|
428
|
+
}
|
|
408
429
|
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
409
430
|
"area",
|
|
410
431
|
"base",
|
|
@@ -848,11 +869,9 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
848
869
|
if (e && typeof e.then === "function") {
|
|
849
870
|
if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
|
|
850
871
|
patchPromiseStatus(e);
|
|
851
|
-
const
|
|
852
|
-
const u = captureUnsuspend();
|
|
872
|
+
const rctx = captureRenderCtx();
|
|
853
873
|
return e.then(() => {
|
|
854
|
-
|
|
855
|
-
restoreUnsuspend(u);
|
|
874
|
+
restoreRenderCtx(rctx);
|
|
856
875
|
return renderComponent(type, props, writer, isSvg, _suspenseRetries + 1);
|
|
857
876
|
});
|
|
858
877
|
}
|
|
@@ -889,17 +908,14 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
889
908
|
};
|
|
890
909
|
const r2 = renderChildren(props.children, writer, isSvg);
|
|
891
910
|
if (r2 && typeof r2.then === "function") {
|
|
892
|
-
const
|
|
893
|
-
const u = captureUnsuspend();
|
|
911
|
+
const rctx = captureRenderCtx();
|
|
894
912
|
return r2.then(
|
|
895
913
|
() => {
|
|
896
|
-
|
|
897
|
-
restoreUnsuspend(u);
|
|
914
|
+
restoreRenderCtx(rctx);
|
|
898
915
|
finish();
|
|
899
916
|
},
|
|
900
917
|
(e) => {
|
|
901
|
-
|
|
902
|
-
restoreUnsuspend(u);
|
|
918
|
+
restoreRenderCtx(rctx);
|
|
903
919
|
finish();
|
|
904
920
|
throw e;
|
|
905
921
|
}
|
|
@@ -928,11 +944,9 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
928
944
|
if (e && typeof e.then === "function") {
|
|
929
945
|
if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
|
|
930
946
|
patchPromiseStatus(e);
|
|
931
|
-
const
|
|
932
|
-
const u = captureUnsuspend();
|
|
947
|
+
const rctx = captureRenderCtx();
|
|
933
948
|
return e.then(() => {
|
|
934
|
-
|
|
935
|
-
restoreUnsuspend(u);
|
|
949
|
+
restoreRenderCtx(rctx);
|
|
936
950
|
return renderComponent(type, props, writer, isSvg, _suspenseRetries + 1);
|
|
937
951
|
});
|
|
938
952
|
}
|
|
@@ -944,30 +958,25 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
944
958
|
savedIdTree = pushTreeContext(1, 0);
|
|
945
959
|
}
|
|
946
960
|
if (result instanceof Promise) {
|
|
947
|
-
const
|
|
948
|
-
const u = captureUnsuspend();
|
|
961
|
+
const rctx = captureRenderCtx();
|
|
949
962
|
return result.then((resolved) => {
|
|
950
|
-
|
|
951
|
-
restoreUnsuspend(u);
|
|
963
|
+
restoreRenderCtx(rctx);
|
|
952
964
|
let asyncSavedIdTree;
|
|
953
965
|
if (componentCalledUseId()) {
|
|
954
966
|
asyncSavedIdTree = pushTreeContext(1, 0);
|
|
955
967
|
}
|
|
956
968
|
const r2 = renderNode(resolved, writer, isSvg);
|
|
957
969
|
if (r2 && typeof r2.then === "function") {
|
|
958
|
-
const
|
|
959
|
-
const u2 = captureUnsuspend();
|
|
970
|
+
const rctx2 = captureRenderCtx();
|
|
960
971
|
return r2.then(
|
|
961
972
|
() => {
|
|
962
|
-
|
|
963
|
-
restoreUnsuspend(u2);
|
|
973
|
+
restoreRenderCtx(rctx2);
|
|
964
974
|
if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
|
|
965
975
|
popComponentScope(savedScope);
|
|
966
976
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
967
977
|
},
|
|
968
978
|
(e) => {
|
|
969
|
-
|
|
970
|
-
restoreUnsuspend(u2);
|
|
979
|
+
restoreRenderCtx(rctx2);
|
|
971
980
|
if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
|
|
972
981
|
popComponentScope(savedScope);
|
|
973
982
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
@@ -979,8 +988,7 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
979
988
|
popComponentScope(savedScope);
|
|
980
989
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
981
990
|
}, (e) => {
|
|
982
|
-
|
|
983
|
-
restoreUnsuspend(u);
|
|
991
|
+
restoreRenderCtx(rctx);
|
|
984
992
|
popComponentScope(savedScope);
|
|
985
993
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
986
994
|
throw e;
|
|
@@ -988,19 +996,16 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
988
996
|
}
|
|
989
997
|
const r = renderNode(result, writer, isSvg);
|
|
990
998
|
if (r && typeof r.then === "function") {
|
|
991
|
-
const
|
|
992
|
-
const u = captureUnsuspend();
|
|
999
|
+
const rctx = captureRenderCtx();
|
|
993
1000
|
return r.then(
|
|
994
1001
|
() => {
|
|
995
|
-
|
|
996
|
-
restoreUnsuspend(u);
|
|
1002
|
+
restoreRenderCtx(rctx);
|
|
997
1003
|
if (savedIdTree !== void 0) popTreeContext(savedIdTree);
|
|
998
1004
|
popComponentScope(savedScope);
|
|
999
1005
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
1000
1006
|
},
|
|
1001
1007
|
(e) => {
|
|
1002
|
-
|
|
1003
|
-
restoreUnsuspend(u);
|
|
1008
|
+
restoreRenderCtx(rctx);
|
|
1004
1009
|
if (savedIdTree !== void 0) popTreeContext(savedIdTree);
|
|
1005
1010
|
popComponentScope(savedScope);
|
|
1006
1011
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
@@ -1025,11 +1030,9 @@ function renderChildArrayFrom(children, startIndex, writer, isSvg) {
|
|
|
1025
1030
|
const savedTree = pushTreeContext(totalChildren, i);
|
|
1026
1031
|
const r = renderNode(child, writer, isSvg);
|
|
1027
1032
|
if (r && typeof r.then === "function") {
|
|
1028
|
-
const
|
|
1029
|
-
const u = captureUnsuspend();
|
|
1033
|
+
const rctx = captureRenderCtx();
|
|
1030
1034
|
return r.then(() => {
|
|
1031
|
-
|
|
1032
|
-
restoreUnsuspend(u);
|
|
1035
|
+
restoreRenderCtx(rctx);
|
|
1033
1036
|
popTreeContext(savedTree);
|
|
1034
1037
|
return renderChildArrayFrom(children, i + 1, writer, isSvg);
|
|
1035
1038
|
});
|
|
@@ -1053,11 +1056,9 @@ async function renderSuspense(props, writer, isSvg = false) {
|
|
|
1053
1056
|
try {
|
|
1054
1057
|
const r = renderNode(children, buffer, isSvg);
|
|
1055
1058
|
if (r && typeof r.then === "function") {
|
|
1056
|
-
const
|
|
1057
|
-
const u = captureUnsuspend();
|
|
1059
|
+
const rctx = captureRenderCtx();
|
|
1058
1060
|
await r;
|
|
1059
|
-
|
|
1060
|
-
restoreUnsuspend(u);
|
|
1061
|
+
restoreRenderCtx(rctx);
|
|
1061
1062
|
}
|
|
1062
1063
|
writer.write("<!--$-->");
|
|
1063
1064
|
buffer.flushTo(writer);
|
|
@@ -1071,11 +1072,9 @@ async function renderSuspense(props, writer, isSvg = false) {
|
|
|
1071
1072
|
if (fallback) {
|
|
1072
1073
|
const r = renderNode(fallback, writer, isSvg);
|
|
1073
1074
|
if (r && typeof r.then === "function") {
|
|
1074
|
-
const
|
|
1075
|
-
const u = captureUnsuspend();
|
|
1075
|
+
const rctx = captureRenderCtx();
|
|
1076
1076
|
await r;
|
|
1077
|
-
|
|
1078
|
-
restoreUnsuspend(u);
|
|
1077
|
+
restoreRenderCtx(rctx);
|
|
1079
1078
|
}
|
|
1080
1079
|
}
|
|
1081
1080
|
writer.write("<!--/$-->");
|
|
@@ -1100,9 +1099,9 @@ async function renderPreflight(element, options) {
|
|
|
1100
1099
|
NULL_WRITER.lastWasText = false;
|
|
1101
1100
|
const r = renderNode(element, NULL_WRITER);
|
|
1102
1101
|
if (r && typeof r.then === "function") {
|
|
1103
|
-
const
|
|
1102
|
+
const rctx = captureRenderCtx();
|
|
1104
1103
|
await r;
|
|
1105
|
-
|
|
1104
|
+
restoreRenderCtx(rctx);
|
|
1106
1105
|
}
|
|
1107
1106
|
} finally {
|
|
1108
1107
|
swapContextMap(prev);
|
|
@@ -1127,9 +1126,9 @@ async function renderToString(element, options) {
|
|
|
1127
1126
|
resetRenderState(idPrefix);
|
|
1128
1127
|
const r = renderNode(element, writer);
|
|
1129
1128
|
if (r && typeof r.then === "function") {
|
|
1130
|
-
const
|
|
1129
|
+
const rctx = captureRenderCtx();
|
|
1131
1130
|
await r;
|
|
1132
|
-
|
|
1131
|
+
restoreRenderCtx(rctx);
|
|
1133
1132
|
}
|
|
1134
1133
|
return output;
|
|
1135
1134
|
} finally {
|
|
@@ -1245,18 +1244,18 @@ var makePrecontentHtmlGetter = (htmlFilePromise) => {
|
|
|
1245
1244
|
let preHead = null;
|
|
1246
1245
|
let postHead = null;
|
|
1247
1246
|
let postContent = null;
|
|
1247
|
+
const primed = htmlFilePromise.then((html) => {
|
|
1248
|
+
const headEnd = html.indexOf(HEAD_MARKER);
|
|
1249
|
+
const contentStart = html.indexOf(BODY_MARKER);
|
|
1250
|
+
preHead = html.slice(0, headEnd);
|
|
1251
|
+
postHead = html.slice(headEnd + HEAD_MARKER.length, contentStart);
|
|
1252
|
+
postContent = html.slice(contentStart + BODY_MARKER.length);
|
|
1253
|
+
});
|
|
1248
1254
|
return (headHtml) => {
|
|
1249
1255
|
if (preHead !== null) {
|
|
1250
1256
|
return [preHead + headHtml + postHead, postContent];
|
|
1251
1257
|
}
|
|
1252
|
-
return
|
|
1253
|
-
const headEnd = html.indexOf(HEAD_MARKER);
|
|
1254
|
-
const contentStart = html.indexOf(BODY_MARKER);
|
|
1255
|
-
preHead = html.slice(0, headEnd);
|
|
1256
|
-
postHead = html.slice(headEnd + HEAD_MARKER.length, contentStart);
|
|
1257
|
-
postContent = html.slice(contentStart + BODY_MARKER.length);
|
|
1258
|
-
return [preHead + headHtml + postHead, postContent];
|
|
1259
|
-
});
|
|
1258
|
+
return primed.then(() => [preHead + headHtml + postHead, postContent]);
|
|
1260
1259
|
};
|
|
1261
1260
|
};
|
|
1262
1261
|
async function transformStream(data, stream) {
|
package/dist/cloudflare.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
getReactResponse,
|
|
7
7
|
makePrecontentHtmlGetter,
|
|
8
8
|
parseRequest
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-2J2L2H3H.js";
|
|
10
|
+
import "./chunk-TV37IMRB.js";
|
|
11
11
|
import "./chunk-OS3V4CPN.js";
|
|
12
12
|
|
|
13
13
|
// src/cloudflare.ts
|
package/dist/lambda.cjs
CHANGED
|
@@ -323,7 +323,16 @@ function componentCalledUseId() {
|
|
|
323
323
|
function snapshotContext() {
|
|
324
324
|
const st = s();
|
|
325
325
|
const ctx = st.currentTreeContext;
|
|
326
|
-
|
|
326
|
+
const depth = _treeDepth;
|
|
327
|
+
return {
|
|
328
|
+
tree: { id: ctx.id, overflow: ctx.overflow },
|
|
329
|
+
localId: st.localIdCounter,
|
|
330
|
+
treeDepth: depth,
|
|
331
|
+
// Snapshot the live stack so that popTreeContext reads correct saved values
|
|
332
|
+
// even if another concurrent render's resetRenderState stomped the arrays.
|
|
333
|
+
idStack: _treeIdStack.slice(0, depth),
|
|
334
|
+
ovStack: _treeOvStack.slice(0, depth)
|
|
335
|
+
};
|
|
327
336
|
}
|
|
328
337
|
function restoreContext(snap) {
|
|
329
338
|
const st = s();
|
|
@@ -332,6 +341,10 @@ function restoreContext(snap) {
|
|
|
332
341
|
ctx.overflow = snap.tree.overflow;
|
|
333
342
|
st.localIdCounter = snap.localId;
|
|
334
343
|
_treeDepth = snap.treeDepth;
|
|
344
|
+
for (let i = 0; i < snap.treeDepth; i++) {
|
|
345
|
+
_treeIdStack[i] = snap.idStack[i];
|
|
346
|
+
_treeOvStack[i] = snap.ovStack[i];
|
|
347
|
+
}
|
|
335
348
|
}
|
|
336
349
|
function getTreeId() {
|
|
337
350
|
const { id, overflow } = s().currentTreeContext;
|
|
@@ -445,6 +458,14 @@ function restoreDispatcher(prev) {
|
|
|
445
458
|
}
|
|
446
459
|
|
|
447
460
|
// src/slim-react/render.ts
|
|
461
|
+
function captureRenderCtx() {
|
|
462
|
+
return { m: captureMap(), u: captureUnsuspend(), t: snapshotContext() };
|
|
463
|
+
}
|
|
464
|
+
function restoreRenderCtx(ctx) {
|
|
465
|
+
swapContextMap(ctx.m);
|
|
466
|
+
restoreUnsuspend(ctx.u);
|
|
467
|
+
restoreContext(ctx.t);
|
|
468
|
+
}
|
|
448
469
|
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
449
470
|
"area",
|
|
450
471
|
"base",
|
|
@@ -888,11 +909,9 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
888
909
|
if (e && typeof e.then === "function") {
|
|
889
910
|
if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
|
|
890
911
|
patchPromiseStatus(e);
|
|
891
|
-
const
|
|
892
|
-
const u = captureUnsuspend();
|
|
912
|
+
const rctx = captureRenderCtx();
|
|
893
913
|
return e.then(() => {
|
|
894
|
-
|
|
895
|
-
restoreUnsuspend(u);
|
|
914
|
+
restoreRenderCtx(rctx);
|
|
896
915
|
return renderComponent(type, props, writer, isSvg, _suspenseRetries + 1);
|
|
897
916
|
});
|
|
898
917
|
}
|
|
@@ -929,17 +948,14 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
929
948
|
};
|
|
930
949
|
const r2 = renderChildren(props.children, writer, isSvg);
|
|
931
950
|
if (r2 && typeof r2.then === "function") {
|
|
932
|
-
const
|
|
933
|
-
const u = captureUnsuspend();
|
|
951
|
+
const rctx = captureRenderCtx();
|
|
934
952
|
return r2.then(
|
|
935
953
|
() => {
|
|
936
|
-
|
|
937
|
-
restoreUnsuspend(u);
|
|
954
|
+
restoreRenderCtx(rctx);
|
|
938
955
|
finish();
|
|
939
956
|
},
|
|
940
957
|
(e) => {
|
|
941
|
-
|
|
942
|
-
restoreUnsuspend(u);
|
|
958
|
+
restoreRenderCtx(rctx);
|
|
943
959
|
finish();
|
|
944
960
|
throw e;
|
|
945
961
|
}
|
|
@@ -968,11 +984,9 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
968
984
|
if (e && typeof e.then === "function") {
|
|
969
985
|
if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
|
|
970
986
|
patchPromiseStatus(e);
|
|
971
|
-
const
|
|
972
|
-
const u = captureUnsuspend();
|
|
987
|
+
const rctx = captureRenderCtx();
|
|
973
988
|
return e.then(() => {
|
|
974
|
-
|
|
975
|
-
restoreUnsuspend(u);
|
|
989
|
+
restoreRenderCtx(rctx);
|
|
976
990
|
return renderComponent(type, props, writer, isSvg, _suspenseRetries + 1);
|
|
977
991
|
});
|
|
978
992
|
}
|
|
@@ -984,30 +998,25 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
984
998
|
savedIdTree = pushTreeContext(1, 0);
|
|
985
999
|
}
|
|
986
1000
|
if (result instanceof Promise) {
|
|
987
|
-
const
|
|
988
|
-
const u = captureUnsuspend();
|
|
1001
|
+
const rctx = captureRenderCtx();
|
|
989
1002
|
return result.then((resolved) => {
|
|
990
|
-
|
|
991
|
-
restoreUnsuspend(u);
|
|
1003
|
+
restoreRenderCtx(rctx);
|
|
992
1004
|
let asyncSavedIdTree;
|
|
993
1005
|
if (componentCalledUseId()) {
|
|
994
1006
|
asyncSavedIdTree = pushTreeContext(1, 0);
|
|
995
1007
|
}
|
|
996
1008
|
const r2 = renderNode(resolved, writer, isSvg);
|
|
997
1009
|
if (r2 && typeof r2.then === "function") {
|
|
998
|
-
const
|
|
999
|
-
const u2 = captureUnsuspend();
|
|
1010
|
+
const rctx2 = captureRenderCtx();
|
|
1000
1011
|
return r2.then(
|
|
1001
1012
|
() => {
|
|
1002
|
-
|
|
1003
|
-
restoreUnsuspend(u2);
|
|
1013
|
+
restoreRenderCtx(rctx2);
|
|
1004
1014
|
if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
|
|
1005
1015
|
popComponentScope(savedScope);
|
|
1006
1016
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
1007
1017
|
},
|
|
1008
1018
|
(e) => {
|
|
1009
|
-
|
|
1010
|
-
restoreUnsuspend(u2);
|
|
1019
|
+
restoreRenderCtx(rctx2);
|
|
1011
1020
|
if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
|
|
1012
1021
|
popComponentScope(savedScope);
|
|
1013
1022
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
@@ -1019,8 +1028,7 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
1019
1028
|
popComponentScope(savedScope);
|
|
1020
1029
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
1021
1030
|
}, (e) => {
|
|
1022
|
-
|
|
1023
|
-
restoreUnsuspend(u);
|
|
1031
|
+
restoreRenderCtx(rctx);
|
|
1024
1032
|
popComponentScope(savedScope);
|
|
1025
1033
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
1026
1034
|
throw e;
|
|
@@ -1028,19 +1036,16 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
1028
1036
|
}
|
|
1029
1037
|
const r = renderNode(result, writer, isSvg);
|
|
1030
1038
|
if (r && typeof r.then === "function") {
|
|
1031
|
-
const
|
|
1032
|
-
const u = captureUnsuspend();
|
|
1039
|
+
const rctx = captureRenderCtx();
|
|
1033
1040
|
return r.then(
|
|
1034
1041
|
() => {
|
|
1035
|
-
|
|
1036
|
-
restoreUnsuspend(u);
|
|
1042
|
+
restoreRenderCtx(rctx);
|
|
1037
1043
|
if (savedIdTree !== void 0) popTreeContext(savedIdTree);
|
|
1038
1044
|
popComponentScope(savedScope);
|
|
1039
1045
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
1040
1046
|
},
|
|
1041
1047
|
(e) => {
|
|
1042
|
-
|
|
1043
|
-
restoreUnsuspend(u);
|
|
1048
|
+
restoreRenderCtx(rctx);
|
|
1044
1049
|
if (savedIdTree !== void 0) popTreeContext(savedIdTree);
|
|
1045
1050
|
popComponentScope(savedScope);
|
|
1046
1051
|
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
@@ -1065,11 +1070,9 @@ function renderChildArrayFrom(children, startIndex, writer, isSvg) {
|
|
|
1065
1070
|
const savedTree = pushTreeContext(totalChildren, i);
|
|
1066
1071
|
const r = renderNode(child, writer, isSvg);
|
|
1067
1072
|
if (r && typeof r.then === "function") {
|
|
1068
|
-
const
|
|
1069
|
-
const u = captureUnsuspend();
|
|
1073
|
+
const rctx = captureRenderCtx();
|
|
1070
1074
|
return r.then(() => {
|
|
1071
|
-
|
|
1072
|
-
restoreUnsuspend(u);
|
|
1075
|
+
restoreRenderCtx(rctx);
|
|
1073
1076
|
popTreeContext(savedTree);
|
|
1074
1077
|
return renderChildArrayFrom(children, i + 1, writer, isSvg);
|
|
1075
1078
|
});
|
|
@@ -1093,11 +1096,9 @@ async function renderSuspense(props, writer, isSvg = false) {
|
|
|
1093
1096
|
try {
|
|
1094
1097
|
const r = renderNode(children, buffer, isSvg);
|
|
1095
1098
|
if (r && typeof r.then === "function") {
|
|
1096
|
-
const
|
|
1097
|
-
const u = captureUnsuspend();
|
|
1099
|
+
const rctx = captureRenderCtx();
|
|
1098
1100
|
await r;
|
|
1099
|
-
|
|
1100
|
-
restoreUnsuspend(u);
|
|
1101
|
+
restoreRenderCtx(rctx);
|
|
1101
1102
|
}
|
|
1102
1103
|
writer.write("<!--$-->");
|
|
1103
1104
|
buffer.flushTo(writer);
|
|
@@ -1111,11 +1112,9 @@ async function renderSuspense(props, writer, isSvg = false) {
|
|
|
1111
1112
|
if (fallback) {
|
|
1112
1113
|
const r = renderNode(fallback, writer, isSvg);
|
|
1113
1114
|
if (r && typeof r.then === "function") {
|
|
1114
|
-
const
|
|
1115
|
-
const u = captureUnsuspend();
|
|
1115
|
+
const rctx = captureRenderCtx();
|
|
1116
1116
|
await r;
|
|
1117
|
-
|
|
1118
|
-
restoreUnsuspend(u);
|
|
1117
|
+
restoreRenderCtx(rctx);
|
|
1119
1118
|
}
|
|
1120
1119
|
}
|
|
1121
1120
|
writer.write("<!--/$-->");
|
|
@@ -1140,9 +1139,9 @@ async function renderPreflight(element, options) {
|
|
|
1140
1139
|
NULL_WRITER.lastWasText = false;
|
|
1141
1140
|
const r = renderNode(element, NULL_WRITER);
|
|
1142
1141
|
if (r && typeof r.then === "function") {
|
|
1143
|
-
const
|
|
1142
|
+
const rctx = captureRenderCtx();
|
|
1144
1143
|
await r;
|
|
1145
|
-
|
|
1144
|
+
restoreRenderCtx(rctx);
|
|
1146
1145
|
}
|
|
1147
1146
|
} finally {
|
|
1148
1147
|
swapContextMap(prev);
|
|
@@ -1167,9 +1166,9 @@ async function renderToString(element, options) {
|
|
|
1167
1166
|
resetRenderState(idPrefix);
|
|
1168
1167
|
const r = renderNode(element, writer);
|
|
1169
1168
|
if (r && typeof r.then === "function") {
|
|
1170
|
-
const
|
|
1169
|
+
const rctx = captureRenderCtx();
|
|
1171
1170
|
await r;
|
|
1172
|
-
|
|
1171
|
+
restoreRenderCtx(rctx);
|
|
1173
1172
|
}
|
|
1174
1173
|
return output;
|
|
1175
1174
|
} finally {
|
|
@@ -1285,18 +1284,18 @@ var makePrecontentHtmlGetter = (htmlFilePromise) => {
|
|
|
1285
1284
|
let preHead = null;
|
|
1286
1285
|
let postHead = null;
|
|
1287
1286
|
let postContent = null;
|
|
1287
|
+
const primed = htmlFilePromise.then((html) => {
|
|
1288
|
+
const headEnd = html.indexOf(HEAD_MARKER);
|
|
1289
|
+
const contentStart = html.indexOf(BODY_MARKER);
|
|
1290
|
+
preHead = html.slice(0, headEnd);
|
|
1291
|
+
postHead = html.slice(headEnd + HEAD_MARKER.length, contentStart);
|
|
1292
|
+
postContent = html.slice(contentStart + BODY_MARKER.length);
|
|
1293
|
+
});
|
|
1288
1294
|
return (headHtml) => {
|
|
1289
1295
|
if (preHead !== null) {
|
|
1290
1296
|
return [preHead + headHtml + postHead, postContent];
|
|
1291
1297
|
}
|
|
1292
|
-
return
|
|
1293
|
-
const headEnd = html.indexOf(HEAD_MARKER);
|
|
1294
|
-
const contentStart = html.indexOf(BODY_MARKER);
|
|
1295
|
-
preHead = html.slice(0, headEnd);
|
|
1296
|
-
postHead = html.slice(headEnd + HEAD_MARKER.length, contentStart);
|
|
1297
|
-
postContent = html.slice(contentStart + BODY_MARKER.length);
|
|
1298
|
-
return [preHead + headHtml + postHead, postContent];
|
|
1299
|
-
});
|
|
1298
|
+
return primed.then(() => [preHead + headHtml + postHead, postContent]);
|
|
1300
1299
|
};
|
|
1301
1300
|
};
|
|
1302
1301
|
async function transformStream(data, stream) {
|
|
@@ -1456,14 +1455,8 @@ function createLambdaHandler(options, bundled) {
|
|
|
1456
1455
|
const fetchHandler = options.fetch;
|
|
1457
1456
|
const handleProxy = createProxyHandler(options);
|
|
1458
1457
|
const getPrecontentHtml = bundled ? makePrecontentHtmlGetter(Promise.resolve(bundled.outHtml)) : makePrecontentHtmlGetter(import_promises2.default.readFile(import_node_path.default.join(cwd, StaticPath, "out.html"), "utf-8"));
|
|
1459
|
-
|
|
1460
|
-
const getSsrModule = () =>
|
|
1461
|
-
if (bundled) return Promise.resolve(bundled.ssrModule);
|
|
1462
|
-
if (!ssrModulePromise) {
|
|
1463
|
-
ssrModulePromise = import((0, import_node_url.pathToFileURL)(import_node_path.default.resolve(cwd, HadarsFolder, SSR_FILENAME)).href);
|
|
1464
|
-
}
|
|
1465
|
-
return ssrModulePromise;
|
|
1466
|
-
};
|
|
1458
|
+
const ssrModulePromise = bundled ? Promise.resolve(bundled.ssrModule) : import((0, import_node_url.pathToFileURL)(import_node_path.default.resolve(cwd, HadarsFolder, SSR_FILENAME)).href);
|
|
1459
|
+
const getSsrModule = () => ssrModulePromise;
|
|
1467
1460
|
const runHandler = async (req) => {
|
|
1468
1461
|
const request = parseRequest(req);
|
|
1469
1462
|
if (fetchHandler) {
|
package/dist/lambda.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
getReactResponse,
|
|
7
7
|
makePrecontentHtmlGetter,
|
|
8
8
|
parseRequest
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-2J2L2H3H.js";
|
|
10
|
+
import "./chunk-TV37IMRB.js";
|
|
11
11
|
import "./chunk-OS3V4CPN.js";
|
|
12
12
|
|
|
13
13
|
// src/lambda.ts
|
|
@@ -123,14 +123,8 @@ function createLambdaHandler(options, bundled) {
|
|
|
123
123
|
const fetchHandler = options.fetch;
|
|
124
124
|
const handleProxy = createProxyHandler(options);
|
|
125
125
|
const getPrecontentHtml = bundled ? makePrecontentHtmlGetter(Promise.resolve(bundled.outHtml)) : makePrecontentHtmlGetter(fs.readFile(pathMod.join(cwd, StaticPath, "out.html"), "utf-8"));
|
|
126
|
-
|
|
127
|
-
const getSsrModule = () =>
|
|
128
|
-
if (bundled) return Promise.resolve(bundled.ssrModule);
|
|
129
|
-
if (!ssrModulePromise) {
|
|
130
|
-
ssrModulePromise = import(pathToFileURL(pathMod.resolve(cwd, HadarsFolder, SSR_FILENAME)).href);
|
|
131
|
-
}
|
|
132
|
-
return ssrModulePromise;
|
|
133
|
-
};
|
|
126
|
+
const ssrModulePromise = bundled ? Promise.resolve(bundled.ssrModule) : import(pathToFileURL(pathMod.resolve(cwd, HadarsFolder, SSR_FILENAME)).href);
|
|
127
|
+
const getSsrModule = () => ssrModulePromise;
|
|
134
128
|
const runHandler = async (req) => {
|
|
135
129
|
const request = parseRequest(req);
|
|
136
130
|
if (fetchHandler) {
|