@bgub/fig-server 0.1.0-alpha.5 → 0.1.0-alpha.6

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 CHANGED
@@ -1049,7 +1049,7 @@ function retryTask(request, task) {
1049
1049
  task.segment.status = "rendering";
1050
1050
  const frame = createRenderFrame(request, task.segment, forkScope(task));
1051
1051
  try {
1052
- renderChildSequence(collectChildren(task.node), frame, task.childIndexBase);
1052
+ renderChildren(task.node, frame, task.childIndexBase);
1053
1053
  completeSegmentText(task.segment);
1054
1054
  task.segment.status = "completed";
1055
1055
  detachTask(request, task);
@@ -1130,36 +1130,37 @@ function renderNode(node, frame) {
1130
1130
  }
1131
1131
  throw invalidChildError(node);
1132
1132
  }
1133
- function renderChildren(node, frame) {
1134
- renderChildSequence(collectChildren(node), frame);
1135
- }
1136
- function renderChildSequence(children, frame, indexBase = 0) {
1137
- for (let index = 0; index < children.length; index += 1) {
1138
- const child = children[index];
1139
- try {
1140
- withIdSegment(frame, indexBase + index, () => renderNode(child, frame));
1141
- } catch (error) {
1142
- if (isThenable(error)) {
1143
- spawnSuspendedTask(frame, child, error, indexBase + index);
1144
- continue;
1145
- }
1146
- throw error;
1147
- }
1133
+ function renderChildren(node, frame, indexBase = 0) {
1134
+ if (Array.isArray(node)) {
1135
+ renderChildSequence(collectChildren(node), frame, indexBase);
1136
+ return;
1148
1137
  }
1138
+ if (node === null || node === void 0 || typeof node === "boolean" || node === "") return;
1139
+ renderChildAtIndex(node, frame, indexBase);
1149
1140
  }
1150
- function completeSegmentText(segment) {
1151
- if (segment.textEmbedded && segment.lastPushedText) segment.write(TEXT_SEPARATOR);
1141
+ function renderChildSequence(children, frame, indexBase = 0) {
1142
+ for (let index = 0; index < children.length; index += 1) renderChildAtIndex(children[index], frame, indexBase + index);
1152
1143
  }
1153
- function withIdSegment(frame, index, callback) {
1144
+ function renderChildAtIndex(child, frame, index) {
1154
1145
  const previousIdPath = frame.idPath;
1155
1146
  const segment = index.toString(32);
1156
1147
  frame.idPath = previousIdPath === "" ? segment : `${previousIdPath}-${segment}`;
1157
1148
  try {
1158
- return callback();
1149
+ renderNode(child, frame);
1150
+ } catch (error) {
1151
+ frame.idPath = previousIdPath;
1152
+ if (isThenable(error)) {
1153
+ spawnSuspendedTask(frame, child, error, index);
1154
+ return;
1155
+ }
1156
+ throw error;
1159
1157
  } finally {
1160
1158
  frame.idPath = previousIdPath;
1161
1159
  }
1162
1160
  }
1161
+ function completeSegmentText(segment) {
1162
+ if (segment.textEmbedded && segment.lastPushedText) segment.write(TEXT_SEPARATOR);
1163
+ }
1163
1164
  function renderElement(element, frame) {
1164
1165
  if (frame.treeParent === null) {
1165
1166
  renderElementKind(element, frame);
@@ -1249,7 +1250,7 @@ function renderFunctionComponent(type, props, frame) {
1249
1250
  const previousDataStore = setCurrentDataStore(frame.request.dataStore);
1250
1251
  const previousStack = frame.stack;
1251
1252
  const previousLocalIdCounter = frame.localIdCounter;
1252
- frame.stack = {
1253
+ if (frame.request.onError !== void 0) frame.stack = {
1253
1254
  name: type.name || "Anonymous",
1254
1255
  parent: previousStack
1255
1256
  };
@@ -1468,7 +1469,16 @@ function childHostNamespace(type, namespace) {
1468
1469
  return namespace === "svg" && type.toLowerCase() === "foreignobject" ? "html" : namespace;
1469
1470
  }
1470
1471
  function renderHostAsset(type, props, frame) {
1471
- const resource = assetResourceFromHostProps(type, props);
1472
+ if (type.length < 4 || type.length > 6) return false;
1473
+ const normalizedType = type.toLowerCase();
1474
+ switch (normalizedType) {
1475
+ case "link":
1476
+ case "meta":
1477
+ case "script":
1478
+ case "title": break;
1479
+ default: return false;
1480
+ }
1481
+ const resource = assetResourceFromHostProps(normalizedType, props);
1472
1482
  if (resource === null) return false;
1473
1483
  renderAssetValue(resource, frame);
1474
1484
  return true;