hadars 0.3.0 → 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/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
- return { tree: { id: ctx.id, overflow: ctx.overflow }, localId: st.localIdCounter, treeDepth: _treeDepth };
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 m = captureMap();
892
- const u = captureUnsuspend();
912
+ const rctx = captureRenderCtx();
893
913
  return e.then(() => {
894
- swapContextMap(m);
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 m = captureMap();
933
- const u = captureUnsuspend();
951
+ const rctx = captureRenderCtx();
934
952
  return r2.then(
935
953
  () => {
936
- swapContextMap(m);
937
- restoreUnsuspend(u);
954
+ restoreRenderCtx(rctx);
938
955
  finish();
939
956
  },
940
957
  (e) => {
941
- swapContextMap(m);
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 m = captureMap();
972
- const u = captureUnsuspend();
987
+ const rctx = captureRenderCtx();
973
988
  return e.then(() => {
974
- swapContextMap(m);
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 m = captureMap();
988
- const u = captureUnsuspend();
1001
+ const rctx = captureRenderCtx();
989
1002
  return result.then((resolved) => {
990
- swapContextMap(m);
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 m2 = captureMap();
999
- const u2 = captureUnsuspend();
1010
+ const rctx2 = captureRenderCtx();
1000
1011
  return r2.then(
1001
1012
  () => {
1002
- swapContextMap(m2);
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
- swapContextMap(m2);
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
- swapContextMap(m);
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 m = captureMap();
1032
- const u = captureUnsuspend();
1039
+ const rctx = captureRenderCtx();
1033
1040
  return r.then(
1034
1041
  () => {
1035
- swapContextMap(m);
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
- swapContextMap(m);
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 m = captureMap();
1069
- const u = captureUnsuspend();
1073
+ const rctx = captureRenderCtx();
1070
1074
  return r.then(() => {
1071
- swapContextMap(m);
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 m = captureMap();
1097
- const u = captureUnsuspend();
1099
+ const rctx = captureRenderCtx();
1098
1100
  await r;
1099
- swapContextMap(m);
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 m = captureMap();
1115
- const u = captureUnsuspend();
1115
+ const rctx = captureRenderCtx();
1116
1116
  await r;
1117
- swapContextMap(m);
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 m = captureMap();
1142
+ const rctx = captureRenderCtx();
1144
1143
  await r;
1145
- swapContextMap(m);
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 m = captureMap();
1169
+ const rctx = captureRenderCtx();
1171
1170
  await r;
1172
- swapContextMap(m);
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 htmlFilePromise.then((html) => {
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) {
@@ -1319,8 +1318,18 @@ async function transformStream(data, stream) {
1319
1318
  }
1320
1319
  return out;
1321
1320
  }
1322
- var gzipCompress = (d) => transformStream(d, new globalThis.CompressionStream("gzip"));
1323
- var gzipDecompress = (d) => transformStream(d, new globalThis.DecompressionStream("gzip"));
1321
+ async function zlibGzip(d) {
1322
+ const zlib = await import("zlib");
1323
+ const { promisify } = await import("util");
1324
+ return promisify(zlib.gzip)(d);
1325
+ }
1326
+ async function zlibGunzip(d) {
1327
+ const zlib = await import("zlib");
1328
+ const { promisify } = await import("util");
1329
+ return promisify(zlib.gunzip)(d);
1330
+ }
1331
+ var gzipCompress = (d) => globalThis.CompressionStream ? transformStream(d, new globalThis.CompressionStream("gzip")) : zlibGzip(d);
1332
+ var gzipDecompress = (d) => globalThis.DecompressionStream ? transformStream(d, new globalThis.DecompressionStream("gzip")) : zlibGunzip(d);
1324
1333
  async function buildCacheEntry(res, ttl) {
1325
1334
  const buf = await res.arrayBuffer();
1326
1335
  const body = await gzipCompress(new Uint8Array(buf));
@@ -1446,14 +1455,8 @@ function createLambdaHandler(options, bundled) {
1446
1455
  const fetchHandler = options.fetch;
1447
1456
  const handleProxy = createProxyHandler(options);
1448
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"));
1449
- let ssrModulePromise = null;
1450
- const getSsrModule = () => {
1451
- if (bundled) return Promise.resolve(bundled.ssrModule);
1452
- if (!ssrModulePromise) {
1453
- ssrModulePromise = import((0, import_node_url.pathToFileURL)(import_node_path.default.resolve(cwd, HadarsFolder, SSR_FILENAME)).href);
1454
- }
1455
- return ssrModulePromise;
1456
- };
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;
1457
1460
  const runHandler = async (req) => {
1458
1461
  const request = parseRequest(req);
1459
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-H72BZXOA.js";
10
- import "./chunk-LY5MTHFV.js";
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
- let ssrModulePromise = null;
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) {
@@ -218,7 +218,16 @@ function componentCalledUseId() {
218
218
  function snapshotContext() {
219
219
  const st = s();
220
220
  const ctx = st.currentTreeContext;
221
- return { tree: { id: ctx.id, overflow: ctx.overflow }, localId: st.localIdCounter, treeDepth: _treeDepth };
221
+ const depth = _treeDepth;
222
+ return {
223
+ tree: { id: ctx.id, overflow: ctx.overflow },
224
+ localId: st.localIdCounter,
225
+ treeDepth: depth,
226
+ // Snapshot the live stack so that popTreeContext reads correct saved values
227
+ // even if another concurrent render's resetRenderState stomped the arrays.
228
+ idStack: _treeIdStack.slice(0, depth),
229
+ ovStack: _treeOvStack.slice(0, depth)
230
+ };
222
231
  }
223
232
  function restoreContext(snap) {
224
233
  const st = s();
@@ -227,6 +236,10 @@ function restoreContext(snap) {
227
236
  ctx.overflow = snap.tree.overflow;
228
237
  st.localIdCounter = snap.localId;
229
238
  _treeDepth = snap.treeDepth;
239
+ for (let i = 0; i < snap.treeDepth; i++) {
240
+ _treeIdStack[i] = snap.idStack[i];
241
+ _treeOvStack[i] = snap.ovStack[i];
242
+ }
230
243
  }
231
244
  function getTreeId() {
232
245
  const { id, overflow } = s().currentTreeContext;
@@ -372,6 +385,14 @@ function restoreDispatcher(prev) {
372
385
  }
373
386
 
374
387
  // src/slim-react/render.ts
388
+ function captureRenderCtx() {
389
+ return { m: captureMap(), u: captureUnsuspend(), t: snapshotContext() };
390
+ }
391
+ function restoreRenderCtx(ctx) {
392
+ swapContextMap(ctx.m);
393
+ restoreUnsuspend(ctx.u);
394
+ restoreContext(ctx.t);
395
+ }
375
396
  var VOID_ELEMENTS = /* @__PURE__ */ new Set([
376
397
  "area",
377
398
  "base",
@@ -815,11 +836,9 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
815
836
  if (e && typeof e.then === "function") {
816
837
  if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
817
838
  patchPromiseStatus(e);
818
- const m = captureMap();
819
- const u = captureUnsuspend();
839
+ const rctx = captureRenderCtx();
820
840
  return e.then(() => {
821
- swapContextMap(m);
822
- restoreUnsuspend(u);
841
+ restoreRenderCtx(rctx);
823
842
  return renderComponent(type, props, writer, isSvg, _suspenseRetries + 1);
824
843
  });
825
844
  }
@@ -856,17 +875,14 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
856
875
  };
857
876
  const r2 = renderChildren(props.children, writer, isSvg);
858
877
  if (r2 && typeof r2.then === "function") {
859
- const m = captureMap();
860
- const u = captureUnsuspend();
878
+ const rctx = captureRenderCtx();
861
879
  return r2.then(
862
880
  () => {
863
- swapContextMap(m);
864
- restoreUnsuspend(u);
881
+ restoreRenderCtx(rctx);
865
882
  finish();
866
883
  },
867
884
  (e) => {
868
- swapContextMap(m);
869
- restoreUnsuspend(u);
885
+ restoreRenderCtx(rctx);
870
886
  finish();
871
887
  throw e;
872
888
  }
@@ -895,11 +911,9 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
895
911
  if (e && typeof e.then === "function") {
896
912
  if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
897
913
  patchPromiseStatus(e);
898
- const m = captureMap();
899
- const u = captureUnsuspend();
914
+ const rctx = captureRenderCtx();
900
915
  return e.then(() => {
901
- swapContextMap(m);
902
- restoreUnsuspend(u);
916
+ restoreRenderCtx(rctx);
903
917
  return renderComponent(type, props, writer, isSvg, _suspenseRetries + 1);
904
918
  });
905
919
  }
@@ -911,30 +925,25 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
911
925
  savedIdTree = pushTreeContext(1, 0);
912
926
  }
913
927
  if (result instanceof Promise) {
914
- const m = captureMap();
915
- const u = captureUnsuspend();
928
+ const rctx = captureRenderCtx();
916
929
  return result.then((resolved) => {
917
- swapContextMap(m);
918
- restoreUnsuspend(u);
930
+ restoreRenderCtx(rctx);
919
931
  let asyncSavedIdTree;
920
932
  if (componentCalledUseId()) {
921
933
  asyncSavedIdTree = pushTreeContext(1, 0);
922
934
  }
923
935
  const r2 = renderNode(resolved, writer, isSvg);
924
936
  if (r2 && typeof r2.then === "function") {
925
- const m2 = captureMap();
926
- const u2 = captureUnsuspend();
937
+ const rctx2 = captureRenderCtx();
927
938
  return r2.then(
928
939
  () => {
929
- swapContextMap(m2);
930
- restoreUnsuspend(u2);
940
+ restoreRenderCtx(rctx2);
931
941
  if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
932
942
  popComponentScope(savedScope);
933
943
  if (isProvider) popContextValue(ctx, prevCtxValue);
934
944
  },
935
945
  (e) => {
936
- swapContextMap(m2);
937
- restoreUnsuspend(u2);
946
+ restoreRenderCtx(rctx2);
938
947
  if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
939
948
  popComponentScope(savedScope);
940
949
  if (isProvider) popContextValue(ctx, prevCtxValue);
@@ -946,8 +955,7 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
946
955
  popComponentScope(savedScope);
947
956
  if (isProvider) popContextValue(ctx, prevCtxValue);
948
957
  }, (e) => {
949
- swapContextMap(m);
950
- restoreUnsuspend(u);
958
+ restoreRenderCtx(rctx);
951
959
  popComponentScope(savedScope);
952
960
  if (isProvider) popContextValue(ctx, prevCtxValue);
953
961
  throw e;
@@ -955,19 +963,16 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
955
963
  }
956
964
  const r = renderNode(result, writer, isSvg);
957
965
  if (r && typeof r.then === "function") {
958
- const m = captureMap();
959
- const u = captureUnsuspend();
966
+ const rctx = captureRenderCtx();
960
967
  return r.then(
961
968
  () => {
962
- swapContextMap(m);
963
- restoreUnsuspend(u);
969
+ restoreRenderCtx(rctx);
964
970
  if (savedIdTree !== void 0) popTreeContext(savedIdTree);
965
971
  popComponentScope(savedScope);
966
972
  if (isProvider) popContextValue(ctx, prevCtxValue);
967
973
  },
968
974
  (e) => {
969
- swapContextMap(m);
970
- restoreUnsuspend(u);
975
+ restoreRenderCtx(rctx);
971
976
  if (savedIdTree !== void 0) popTreeContext(savedIdTree);
972
977
  popComponentScope(savedScope);
973
978
  if (isProvider) popContextValue(ctx, prevCtxValue);
@@ -992,11 +997,9 @@ function renderChildArrayFrom(children, startIndex, writer, isSvg) {
992
997
  const savedTree = pushTreeContext(totalChildren, i);
993
998
  const r = renderNode(child, writer, isSvg);
994
999
  if (r && typeof r.then === "function") {
995
- const m = captureMap();
996
- const u = captureUnsuspend();
1000
+ const rctx = captureRenderCtx();
997
1001
  return r.then(() => {
998
- swapContextMap(m);
999
- restoreUnsuspend(u);
1002
+ restoreRenderCtx(rctx);
1000
1003
  popTreeContext(savedTree);
1001
1004
  return renderChildArrayFrom(children, i + 1, writer, isSvg);
1002
1005
  });
@@ -1020,11 +1023,9 @@ async function renderSuspense(props, writer, isSvg = false) {
1020
1023
  try {
1021
1024
  const r = renderNode(children, buffer, isSvg);
1022
1025
  if (r && typeof r.then === "function") {
1023
- const m = captureMap();
1024
- const u = captureUnsuspend();
1026
+ const rctx = captureRenderCtx();
1025
1027
  await r;
1026
- swapContextMap(m);
1027
- restoreUnsuspend(u);
1028
+ restoreRenderCtx(rctx);
1028
1029
  }
1029
1030
  writer.write("<!--$-->");
1030
1031
  buffer.flushTo(writer);
@@ -1038,11 +1039,9 @@ async function renderSuspense(props, writer, isSvg = false) {
1038
1039
  if (fallback) {
1039
1040
  const r = renderNode(fallback, writer, isSvg);
1040
1041
  if (r && typeof r.then === "function") {
1041
- const m = captureMap();
1042
- const u = captureUnsuspend();
1042
+ const rctx = captureRenderCtx();
1043
1043
  await r;
1044
- swapContextMap(m);
1045
- restoreUnsuspend(u);
1044
+ restoreRenderCtx(rctx);
1046
1045
  }
1047
1046
  }
1048
1047
  writer.write("<!--/$-->");
@@ -1079,9 +1078,9 @@ function renderToStream(element, options) {
1079
1078
  try {
1080
1079
  const r = renderNode(element, writer);
1081
1080
  if (r && typeof r.then === "function") {
1082
- const m = captureMap();
1081
+ const rctx = captureRenderCtx();
1083
1082
  await r;
1084
- swapContextMap(m);
1083
+ restoreRenderCtx(rctx);
1085
1084
  }
1086
1085
  writer.flush();
1087
1086
  controller.close();
@@ -1108,9 +1107,9 @@ async function renderPreflight(element, options) {
1108
1107
  NULL_WRITER.lastWasText = false;
1109
1108
  const r = renderNode(element, NULL_WRITER);
1110
1109
  if (r && typeof r.then === "function") {
1111
- const m = captureMap();
1110
+ const rctx = captureRenderCtx();
1112
1111
  await r;
1113
- swapContextMap(m);
1112
+ restoreRenderCtx(rctx);
1114
1113
  }
1115
1114
  } finally {
1116
1115
  swapContextMap(prev);
@@ -1135,9 +1134,9 @@ async function renderToString(element, options) {
1135
1134
  resetRenderState(idPrefix);
1136
1135
  const r = renderNode(element, writer);
1137
1136
  if (r && typeof r.then === "function") {
1138
- const m = captureMap();
1137
+ const rctx = captureRenderCtx();
1139
1138
  await r;
1140
- swapContextMap(m);
1139
+ restoreRenderCtx(rctx);
1141
1140
  }
1142
1141
  return output;
1143
1142
  } finally {
@@ -34,7 +34,7 @@ import {
34
34
  useSyncExternalStore,
35
35
  useTransition,
36
36
  version
37
- } from "../chunk-LY5MTHFV.js";
37
+ } from "../chunk-TV37IMRB.js";
38
38
  import {
39
39
  FRAGMENT_TYPE,
40
40
  Fragment,