@superinterface/react 2.17.0 → 2.17.1

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
@@ -1353,87 +1353,114 @@ var components = {
1353
1353
  annotation: Annotation
1354
1354
  };
1355
1355
  // src/lib/remark/remarkAnnotation.ts
1356
- import { visit, SKIP } from "unist-util-visit";
1356
+ import { isNumber } from "radash";
1357
+ import flatMap from "unist-util-flatmap";
1357
1358
  var remarkAnnotation = function(param) {
1358
1359
  var content = param.content;
1359
1360
  return function() {
1360
1361
  return function(tree) {
1361
- visit(tree, "text", function(node, index, parent) {
1362
- if (content.text.annotations.length > 0) {
1363
- content.text.annotations.forEach(function(annotation) {
1364
- var _parent_children;
1365
- var _node_position_start, _node_position, _node_position_end, _node_position1;
1366
- if (!((_node_position = node.position) === null || _node_position === void 0 ? void 0 : (_node_position_start = _node_position.start) === null || _node_position_start === void 0 ? void 0 : _node_position_start.offset)) return;
1367
- if (!((_node_position1 = node.position) === null || _node_position1 === void 0 ? void 0 : (_node_position_end = _node_position1.end) === null || _node_position_end === void 0 ? void 0 : _node_position_end.offset)) return;
1368
- if (node.position.start.offset > annotation.start_index) {
1369
- return;
1370
- }
1371
- if (node.position.end.offset < annotation.end_index) {
1372
- return;
1373
- }
1374
- var beforeStart = node.position.start.offset;
1375
- var beforeEnd = annotation.start_index;
1376
- var annotationStart = annotation.start_index;
1377
- var annotationEnd = annotation.end_index;
1378
- var afterStart = annotation.end_index;
1379
- var afterEnd = node.position.end.offset;
1380
- var before = node.value.slice(0, annotation.start_index - node.position.start.offset);
1381
- var annotatedText = node.value.slice(annotation.start_index - node.position.start.offset, annotation.end_index - node.position.start.offset);
1382
- var after = node.value.slice(annotation.end_index - node.position.start.offset);
1383
- var newNodes = [];
1384
- if (before) {
1385
- newNodes.push({
1386
- type: "text",
1387
- value: before,
1388
- position: {
1389
- start: {
1390
- offset: beforeStart
1391
- },
1392
- end: {
1393
- offset: beforeEnd
1394
- }
1395
- }
1396
- });
1397
- }
1362
+ flatMap(tree, function(node) {
1363
+ if (node.type !== "text") {
1364
+ return [
1365
+ node
1366
+ ];
1367
+ }
1368
+ if (!content.text.annotations.length) {
1369
+ return [
1370
+ node
1371
+ ];
1372
+ }
1373
+ if (!node.position) {
1374
+ return [
1375
+ node
1376
+ ];
1377
+ }
1378
+ var nodeStart = node.position.start.offset;
1379
+ if (!isNumber(nodeStart)) {
1380
+ return [
1381
+ node
1382
+ ];
1383
+ }
1384
+ var nodeEnd = node.position.end.offset;
1385
+ if (!isNumber(nodeEnd)) {
1386
+ return [
1387
+ node
1388
+ ];
1389
+ }
1390
+ var newNodes = [];
1391
+ var sortedAnnotations = content.text.annotations.sort(function(a, b) {
1392
+ return a.start_index - b.start_index;
1393
+ });
1394
+ var lastProcessedIndex = nodeStart;
1395
+ sortedAnnotations.forEach(function(annotation) {
1396
+ var annotationStart = annotation.start_index;
1397
+ var annotationEnd = annotation.end_index;
1398
+ if (nodeEnd < annotationStart || nodeStart > annotationEnd) {
1399
+ return;
1400
+ }
1401
+ var startIndex = Math.max(nodeStart, annotationStart);
1402
+ var endIndex = Math.min(nodeEnd, annotationEnd);
1403
+ if (lastProcessedIndex < startIndex) {
1398
1404
  newNodes.push({
1399
- value: annotatedText,
1400
- data: {
1401
- hName: "annotation",
1402
- hProperties: {
1403
- annotation: annotation
1404
- }
1405
- },
1405
+ type: "text",
1406
+ value: node.value.slice(lastProcessedIndex - nodeStart, startIndex - nodeStart),
1406
1407
  position: {
1407
1408
  start: {
1408
- offset: annotationStart
1409
+ line: node.position.start.line,
1410
+ column: node.position.start.column,
1411
+ offset: lastProcessedIndex
1409
1412
  },
1410
1413
  end: {
1411
- offset: annotationEnd
1414
+ line: node.position.end.line,
1415
+ column: node.position.end.column,
1416
+ offset: startIndex
1412
1417
  }
1413
1418
  }
1414
1419
  });
1415
- if (after) {
1416
- newNodes.push({
1417
- type: "text",
1418
- value: after,
1419
- position: {
1420
- start: {
1421
- offset: afterStart
1422
- },
1423
- end: {
1424
- offset: afterEnd
1425
- }
1426
- }
1427
- });
1420
+ }
1421
+ newNodes.push({
1422
+ type: "annotation",
1423
+ value: node.value.slice(startIndex - nodeStart, endIndex - nodeStart),
1424
+ position: {
1425
+ start: {
1426
+ line: node.position.start.line,
1427
+ column: node.position.start.column,
1428
+ offset: startIndex
1429
+ },
1430
+ end: {
1431
+ line: node.position.end.line,
1432
+ column: node.position.end.column,
1433
+ offset: endIndex
1434
+ }
1435
+ },
1436
+ data: {
1437
+ hName: "annotation",
1438
+ hProperties: {
1439
+ annotation: annotation
1440
+ }
1441
+ }
1442
+ });
1443
+ lastProcessedIndex = endIndex;
1444
+ });
1445
+ if (lastProcessedIndex < nodeEnd) {
1446
+ newNodes.push({
1447
+ type: "text",
1448
+ value: node.value.slice(lastProcessedIndex - nodeStart, nodeEnd - nodeStart),
1449
+ position: {
1450
+ start: {
1451
+ line: node.position.start.line,
1452
+ column: node.position.start.column,
1453
+ offset: lastProcessedIndex
1454
+ },
1455
+ end: {
1456
+ line: node.position.end.line,
1457
+ column: node.position.end.column,
1458
+ offset: nodeEnd
1459
+ }
1428
1460
  }
1429
- (_parent_children = parent.children).splice.apply(_parent_children, [
1430
- index,
1431
- 1
1432
- ].concat(_to_consumable_array(newNodes)));
1433
1461
  });
1434
- return SKIP;
1435
1462
  }
1436
- return;
1463
+ return newNodes;
1437
1464
  });
1438
1465
  };
1439
1466
  };
@@ -1812,7 +1839,8 @@ var Messages = function(param) {
1812
1839
  /* @__PURE__ */ jsx46(NextPageSkeleton, {}),
1813
1840
  /* @__PURE__ */ jsx46(Flex14, {
1814
1841
  flexShrink: "0",
1815
- flexGrow: "1"
1842
+ flexGrow: "1",
1843
+ minHeight: "var(--space-5)"
1816
1844
  })
1817
1845
  ]
1818
1846
  });