partial-tsx 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/partial.ts +2 -18
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "partial-tsx",
3
3
  "description": "Utilities for completing prefix-growing TSX.",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
package/src/partial.ts CHANGED
@@ -1391,22 +1391,6 @@ const isJsxShellPreview = (code: string, scan: StreamingScan) => {
1391
1391
  return allFramesAllowed(componentArrow);
1392
1392
  };
1393
1393
 
1394
- const findAsiBoundary = (code: string, start: number, regexLiteralStarts: ReadonlySet<number>) => {
1395
- if (code.indexOf("\n", start) === -1) return start;
1396
- let boundary = start;
1397
- const regexStarts = [...regexLiteralStarts];
1398
- let regexIndex = 0;
1399
- let lastRegexStart: number | undefined;
1400
- const segment = code.slice(start);
1401
- for (const match of segment.matchAll(/\n/g)) {
1402
- const index = match.index ?? 0;
1403
- const absoluteIndex = start + index;
1404
- while (regexIndex < regexStarts.length && regexStarts[regexIndex] < absoluteIndex) lastRegexStart = regexStarts[regexIndex++];
1405
- if (isAsiBoundary(segment.slice(0, index), segment.slice(index + 1), isTrailingClosedRegexLiteral(code, absoluteIndex, lastRegexStart))) boundary = absoluteIndex + 1;
1406
- }
1407
- return boundary;
1408
- };
1409
-
1410
1394
  const hasIncompleteControlTail = (tail: string) => {
1411
1395
  const trimmed = tail.trim();
1412
1396
  if (/^(?:if|for|while|switch|catch|with)\b[\s\S]*\)\s*$/.test(trimmed)) return true;
@@ -1488,8 +1472,8 @@ const hasSafeExpressionTail = (tail: string) => {
1488
1472
  };
1489
1473
 
1490
1474
  const findTrailingUnsafeStatementStart = (code: string, scan: StreamingScan) => {
1491
- const scopeStart = scan.scopes.at(-1)?.statementStart ?? 0;
1492
- const start = findAsiBoundary(code, scopeStart, scan.regexLiteralStarts);
1475
+ // The scanner already tracks ASI outside JSX, literals and nested expressions. Rescanning raw newlines can cut inside an attribute.
1476
+ const start = scan.scopes.at(-1)?.statementStart ?? 0;
1493
1477
  const tail = code.slice(start, Math.max(start, scan.lastSignificantEnd));
1494
1478
  if (isTrailingClosedRegexLiteral(code, code.length, findLastRegexLiteralStart(scan.regexLiteralStarts, code.length))) return code.length;
1495
1479
  if (/^\s*while\s*\([\s\S]*\)\s*$/.test(tail) && isCompleteDoWhileStatement(code, scan)) return code.length;