@bgub/fig-server 2.2.0 → 2.2.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/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/payload.js +3 -3
- package/dist/payload.js.map +1 -1
- package/dist-development/index.js +40 -3
- package/dist-development/index.js.map +1 -1
- package/dist-development/payload.js +3 -3
- package/dist-development/payload.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as escapeText, n as escapeScriptJson, t as escapeAttribute } from "./escaping-2fHOwhEM.js";
|
|
2
2
|
import { a as componentStack, c as noLane, d as serverErrorPayload, f as streamFlowBlocked, i as cloneContextValues, l as nonceAttribute, m as withContextValue, n as suppressesImagePreloads, o as createStaticDispatcher, p as streamHighWaterMark, r as STREAMED_METADATA_ATTRIBUTE, s as deferred, t as imagePreloadFromHostProps, u as noop } from "./image-preloads-DwTY3DIk.js";
|
|
3
3
|
import { Fragment, createElement, isValidElement } from "@bgub/fig";
|
|
4
|
-
import { ACTIVITY_TEMPLATE_ATTRIBUTE, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, HYDRATION_SKIP_ATTRIBUTE, REPLAYABLE_EVENT_TYPES, STREAMED_DATA_PROPERTY, SUSPENSE_BROWSER_MARKER, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, TEXT_SEPARATOR_DATA, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, assetResourceFromHostProps, assetResourceHostProps, assetResourceKey, attachDataStore, collectChildren, createRendererDataStore, decodePayloadDataEntries, encodePayloadDataEntries, invalidChildError, isActivity, isAssets, isClientReference, isContext, isErrorBoundary, isFigAssetResource, isPortal, isSuspense, isThenable, isViewTransition, normalizeDataResourceKey, readThenable, setCurrentDataStore, setCurrentDispatcher } from "@bgub/fig/internal";
|
|
4
|
+
import { ACTIVITY_TEMPLATE_ATTRIBUTE, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, HYDRATION_SKIP_ATTRIBUTE, REPLAYABLE_EVENT_TYPES, STREAMED_DATA_PROPERTY, SUSPENSE_BROWSER_MARKER, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, TEXT_SEPARATOR_DATA, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, assetResourceFromHostProps, assetResourceHostProps, assetResourceKey, attachDataStore, attachThenableRetry, collectChildren, createRendererDataStore, decodePayloadDataEntries, encodePayloadDataEntries, invalidChildError, isActivity, isAssets, isClientReference, isContext, isErrorBoundary, isFigAssetResource, isPortal, isSuspense, isThenable, isViewTransition, normalizeDataResourceKey, readThenable, setCurrentDataStore, setCurrentDispatcher } from "@bgub/fig/internal";
|
|
5
5
|
//#region src/html.ts
|
|
6
6
|
const voidElements = /* @__PURE__ */ new Set([
|
|
7
7
|
"area",
|
|
@@ -591,6 +591,7 @@ function prefixedId(request, kind, id) {
|
|
|
591
591
|
//#endregion
|
|
592
592
|
//#region src/renderer-flush.ts
|
|
593
593
|
const documentHeadMarker = Symbol("fig.document-head");
|
|
594
|
+
const shellDataMarkersSlot = Symbol("fig.shell-data-markers-slot");
|
|
594
595
|
const leadingNewlineStartMarker = Symbol("fig.leading-newline-start");
|
|
595
596
|
const leadingNewlineEndMarker = Symbol("fig.leading-newline-end");
|
|
596
597
|
const RUNTIME_REF = "__figSSR";
|
|
@@ -604,8 +605,11 @@ function flushCompletedQueues(request) {
|
|
|
604
605
|
try {
|
|
605
606
|
sealHead(request);
|
|
606
607
|
if (request.rootSegment.status !== "flushed") {
|
|
608
|
+
request.shellDataRows = claimShellDependencies(request);
|
|
609
|
+
if (request.documentHasHead === null) writeShellDataMarkers(request);
|
|
607
610
|
flushSegment(request, request.rootSegment);
|
|
608
611
|
request.pendingDataKeys?.clear();
|
|
612
|
+
writeDataRows(request, request.shellDataRows.splice(0));
|
|
609
613
|
flushWriteBuffer(request);
|
|
610
614
|
}
|
|
611
615
|
if (!drainBoundaryQueue(request, request.clientRenderedBoundaries, flushClientRenderedBoundary) && !drainBoundaryQueue(request, request.completedBoundaries, flushCompletedBoundary)) drainBoundaryQueue(request, request.partialBoundaries, flushPartialBoundary);
|
|
@@ -736,6 +740,31 @@ function writeBoundaryRevealScript(request, boundary) {
|
|
|
736
740
|
writeScript(request, withAssetGate(blockingIds, boundary.activityId === null ? `${RUNTIME_REF}.c(${boundaryRef},${contentRef}${metadataArgument})` : `${RUNTIME_REF}.ac(${jsString(boundary.activityId)},${boundaryRef},${contentRef}${metadataArgument})`));
|
|
737
741
|
writeLateDataOperations(request, boundary);
|
|
738
742
|
}
|
|
743
|
+
function claimShellDependencies(request) {
|
|
744
|
+
if (request.pendingDataKeys === null) return [];
|
|
745
|
+
const reads = /* @__PURE__ */ new Set();
|
|
746
|
+
collectShellReads(request.rootSegment, reads);
|
|
747
|
+
const rows = encodeDataRows(unqueuedData(request, request.dataStore.snapshotDependencies(reads)));
|
|
748
|
+
for (const row of rows) request.writtenDataKeys.add(normalizeDataResourceKey(row.key));
|
|
749
|
+
return rows;
|
|
750
|
+
}
|
|
751
|
+
function collectShellReads(segment, reads) {
|
|
752
|
+
if (segment.boundary?.status === "completed") {
|
|
753
|
+
for (const completed of segment.boundary.completedSegments) collectShellReads(completed, reads);
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
for (const key of segment.dataKeys ?? []) reads.add(key);
|
|
757
|
+
for (const child of segment.children) collectShellReads(child, reads);
|
|
758
|
+
}
|
|
759
|
+
function writeShellDataMarkers(request) {
|
|
760
|
+
const rows = request.shellDataRows;
|
|
761
|
+
if (rows.length === 0) return;
|
|
762
|
+
writeRuntime(request);
|
|
763
|
+
writeDataRows(request, rows.map((row) => ({
|
|
764
|
+
key: row.key,
|
|
765
|
+
pending: true
|
|
766
|
+
})));
|
|
767
|
+
}
|
|
739
768
|
function takeData(request) {
|
|
740
769
|
return [...[...new Set(request.queuedDataRows.values())].flatMap((batch) => decodePayloadDataEntries(takeQueuedDataBatch(request, batch))), ...claimData(request, request.dataStore.snapshot())];
|
|
741
770
|
}
|
|
@@ -905,6 +934,10 @@ function writeChunk(request, chunk, segment) {
|
|
|
905
934
|
request.write(request.leadingNewlineStack.at(-1) === false && chunk.value.startsWith("\n") ? `\n${chunk.value}` : chunk.value);
|
|
906
935
|
return;
|
|
907
936
|
}
|
|
937
|
+
if (chunk === shellDataMarkersSlot) {
|
|
938
|
+
writeShellDataMarkers(request);
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
908
941
|
if (chunk !== documentHeadMarker) {
|
|
909
942
|
request.write(chunk);
|
|
910
943
|
return;
|
|
@@ -958,6 +991,7 @@ function createServerRenderRequest(node, options, mode) {
|
|
|
958
991
|
streamDataFilter: typeof options.streamData === "object" ? options.streamData.filter ?? null : null,
|
|
959
992
|
writtenDataKeys: /* @__PURE__ */ new Set(),
|
|
960
993
|
queuedDataRows: /* @__PURE__ */ new Map(),
|
|
994
|
+
shellDataRows: [],
|
|
961
995
|
dispose: disposeRequest,
|
|
962
996
|
abortReason: null,
|
|
963
997
|
identifierPrefix,
|
|
@@ -1506,7 +1540,10 @@ function renderHostElement(type, props, frame) {
|
|
|
1506
1540
|
consumePendingLeadingNewline(frame);
|
|
1507
1541
|
const viewTransition = frame.viewTransition;
|
|
1508
1542
|
writeElementStart(type, viewTransition === null ? props : viewTransitionHostProps(props, viewTransition), frame.segment, frame.selectProps);
|
|
1509
|
-
if (isDocumentHead)
|
|
1543
|
+
if (isDocumentHead) {
|
|
1544
|
+
frame.segment.write(earlyEventCaptureMarkup(frame.request));
|
|
1545
|
+
frame.segment.write(shellDataMarkersSlot);
|
|
1546
|
+
}
|
|
1510
1547
|
if (isVoid) return;
|
|
1511
1548
|
const previousPendingLeadingNewline = frame.pendingLeadingNewline;
|
|
1512
1549
|
const tracksLeadingNewline = type === "pre" || type === "textarea";
|
|
@@ -1577,7 +1614,7 @@ function spawnSuspendedTask(frame, node, thenable, childIndexBase) {
|
|
|
1577
1614
|
frame.segment.children.push(segment);
|
|
1578
1615
|
const task = createTask(node, forkFrame(frame, segment), childIndexBase);
|
|
1579
1616
|
const ping = () => pingTask(task);
|
|
1580
|
-
thenable
|
|
1617
|
+
attachThenableRetry(thenable, ping);
|
|
1581
1618
|
}
|
|
1582
1619
|
function pingTask(task) {
|
|
1583
1620
|
const { request } = task.frame;
|