@colrealpro/react-luau-doctor 0.18.1 → 0.18.3

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.
@@ -1109,6 +1109,71 @@ function applyMasks(source, ranges) {
1109
1109
  }
1110
1110
  return output;
1111
1111
  }
1112
+ function genericFunctionParameterRanges(source, mask) {
1113
+ const ranges = [];
1114
+ const functionPattern = /\bfunction\b/g;
1115
+ for (const match of source.matchAll(functionPattern)) {
1116
+ const start = match.index;
1117
+ if (!isCode(mask, start, start + match[0].length))
1118
+ continue;
1119
+ let cursor = start + match[0].length;
1120
+ while (cursor < source.length) {
1121
+ const char = source[cursor];
1122
+ if (/\s/.test(char)) {
1123
+ cursor += 1;
1124
+ continue;
1125
+ }
1126
+ if (char === "(")
1127
+ break;
1128
+ if (char === "<") {
1129
+ let depth = 0;
1130
+ const rangeStart = cursor;
1131
+ while (cursor < source.length) {
1132
+ if (isCode(mask, cursor)) {
1133
+ if (source[cursor] === "<")
1134
+ depth += 1;
1135
+ else if (source[cursor] === ">") {
1136
+ depth -= 1;
1137
+ if (depth === 0) {
1138
+ cursor += 1;
1139
+ ranges.push({ start: rangeStart, end: cursor });
1140
+ break;
1141
+ }
1142
+ }
1143
+ }
1144
+ cursor += 1;
1145
+ }
1146
+ break;
1147
+ }
1148
+ if (/[A-Za-z0-9_.:]/.test(char)) {
1149
+ cursor += 1;
1150
+ continue;
1151
+ }
1152
+ break;
1153
+ }
1154
+ }
1155
+ return ranges;
1156
+ }
1157
+ function normalizeGenericTypePackUses(source, mask) {
1158
+ const declarationRanges = genericFunctionParameterRanges(source, mask);
1159
+ const replacements = [];
1160
+ const packPattern = /\b[A-Za-z_][A-Za-z0-9_]*\.\.\./g;
1161
+ for (const match of source.matchAll(packPattern)) {
1162
+ const start = match.index;
1163
+ const end = start + match[0].length;
1164
+ if (!isCode(mask, start, end))
1165
+ continue;
1166
+ if (declarationRanges.some((range) => start >= range.start && end <= range.end))
1167
+ continue;
1168
+ const name = match[0].slice(0, -3);
1169
+ replacements.push({ start, end, value: `...${name}` });
1170
+ }
1171
+ let output = source;
1172
+ for (const replacement of replacements.sort((a, b) => b.start - a.start)) {
1173
+ output = `${output.slice(0, replacement.start)}${replacement.value}${output.slice(replacement.end)}`;
1174
+ }
1175
+ return output;
1176
+ }
1112
1177
  function normalizeIntegerLiteralSuffixes(source, mask) {
1113
1178
  const suffixes = [];
1114
1179
  const integerPattern = /\b(?:0[xX][0-9A-Fa-f_]+|0[bB][01_]+|[0-9][0-9_]*)i\b/g;
@@ -1148,13 +1213,14 @@ function parserCompatibleSource(source) {
1148
1213
  const mask = codeMask(source);
1149
1214
  const keywordCompatible = replaceContextualKeywords(source, mask);
1150
1215
  const literalCompatible = normalizeIntegerLiteralSuffixes(keywordCompatible, mask);
1216
+ const packCompatible = normalizeGenericTypePackUses(literalCompatible, mask);
1151
1217
  const ranges = [
1152
1218
  ...maskTypeAliases(source, mask),
1153
1219
  ...maskTypeLevelBlocks(source, mask),
1154
1220
  ...attributeRanges(source, mask),
1155
1221
  ...explicitTypeArgumentRanges(source, mask)
1156
1222
  ];
1157
- const masked = applyMasks(literalCompatible, ranges);
1223
+ const masked = applyMasks(packCompatible, ranges);
1158
1224
  return masked.replace(/^(\s*)type(?=\s*(?:\+=|-=|\*=|\/=|%=|\^=|\.\.=|=(?!=)))/gm, "$1_typ");
1159
1225
  }
1160
1226
 
@@ -7389,5 +7455,5 @@ parentPort.on("message", async (request) => {
7389
7455
  }
7390
7456
  });
7391
7457
 
7392
- //# debugId=D3DA65AABFE680C664756E2164756E21
7458
+ //# debugId=CD648BE1625A701464756E2164756E21
7393
7459
  //# sourceMappingURL=scan-worker.js.map