@colrealpro/react-luau-doctor 0.18.2 → 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.
package/dist/cli.js CHANGED
@@ -11,7 +11,7 @@ var package_default = {
11
11
  publishConfig: {
12
12
  access: "public"
13
13
  },
14
- version: "0.18.2",
14
+ version: "0.18.3",
15
15
  description: "Static analysis for React-Luau hooks, effects, rendering, and performance.",
16
16
  license: "MIT",
17
17
  type: "module",
@@ -2141,6 +2141,71 @@ function applyMasks(source, ranges) {
2141
2141
  }
2142
2142
  return output;
2143
2143
  }
2144
+ function genericFunctionParameterRanges(source, mask) {
2145
+ const ranges = [];
2146
+ const functionPattern = /\bfunction\b/g;
2147
+ for (const match of source.matchAll(functionPattern)) {
2148
+ const start = match.index;
2149
+ if (!isCode(mask, start, start + match[0].length))
2150
+ continue;
2151
+ let cursor = start + match[0].length;
2152
+ while (cursor < source.length) {
2153
+ const char = source[cursor];
2154
+ if (/\s/.test(char)) {
2155
+ cursor += 1;
2156
+ continue;
2157
+ }
2158
+ if (char === "(")
2159
+ break;
2160
+ if (char === "<") {
2161
+ let depth = 0;
2162
+ const rangeStart = cursor;
2163
+ while (cursor < source.length) {
2164
+ if (isCode(mask, cursor)) {
2165
+ if (source[cursor] === "<")
2166
+ depth += 1;
2167
+ else if (source[cursor] === ">") {
2168
+ depth -= 1;
2169
+ if (depth === 0) {
2170
+ cursor += 1;
2171
+ ranges.push({ start: rangeStart, end: cursor });
2172
+ break;
2173
+ }
2174
+ }
2175
+ }
2176
+ cursor += 1;
2177
+ }
2178
+ break;
2179
+ }
2180
+ if (/[A-Za-z0-9_.:]/.test(char)) {
2181
+ cursor += 1;
2182
+ continue;
2183
+ }
2184
+ break;
2185
+ }
2186
+ }
2187
+ return ranges;
2188
+ }
2189
+ function normalizeGenericTypePackUses(source, mask) {
2190
+ const declarationRanges = genericFunctionParameterRanges(source, mask);
2191
+ const replacements = [];
2192
+ const packPattern = /\b[A-Za-z_][A-Za-z0-9_]*\.\.\./g;
2193
+ for (const match of source.matchAll(packPattern)) {
2194
+ const start = match.index;
2195
+ const end = start + match[0].length;
2196
+ if (!isCode(mask, start, end))
2197
+ continue;
2198
+ if (declarationRanges.some((range) => start >= range.start && end <= range.end))
2199
+ continue;
2200
+ const name = match[0].slice(0, -3);
2201
+ replacements.push({ start, end, value: `...${name}` });
2202
+ }
2203
+ let output = source;
2204
+ for (const replacement of replacements.sort((a, b) => b.start - a.start)) {
2205
+ output = `${output.slice(0, replacement.start)}${replacement.value}${output.slice(replacement.end)}`;
2206
+ }
2207
+ return output;
2208
+ }
2144
2209
  function normalizeIntegerLiteralSuffixes(source, mask) {
2145
2210
  const suffixes = [];
2146
2211
  const integerPattern = /\b(?:0[xX][0-9A-Fa-f_]+|0[bB][01_]+|[0-9][0-9_]*)i\b/g;
@@ -2180,13 +2245,14 @@ function parserCompatibleSource(source) {
2180
2245
  const mask = codeMask(source);
2181
2246
  const keywordCompatible = replaceContextualKeywords(source, mask);
2182
2247
  const literalCompatible = normalizeIntegerLiteralSuffixes(keywordCompatible, mask);
2248
+ const packCompatible = normalizeGenericTypePackUses(literalCompatible, mask);
2183
2249
  const ranges = [
2184
2250
  ...maskTypeAliases(source, mask),
2185
2251
  ...maskTypeLevelBlocks(source, mask),
2186
2252
  ...attributeRanges(source, mask),
2187
2253
  ...explicitTypeArgumentRanges(source, mask)
2188
2254
  ];
2189
- const masked = applyMasks(literalCompatible, ranges);
2255
+ const masked = applyMasks(packCompatible, ranges);
2190
2256
  return masked.replace(/^(\s*)type(?=\s*(?:\+=|-=|\*=|\/=|%=|\^=|\.\.=|=(?!=)))/gm, "$1_typ");
2191
2257
  }
2192
2258
 
@@ -12752,5 +12818,5 @@ ${renderUpdateNotice(update.current, update.latest, colorized)}
12752
12818
  }
12753
12819
  main();
12754
12820
 
12755
- //# debugId=53584D6CB0EB00E064756E2164756E21
12821
+ //# debugId=32BB85E7FBDD457564756E2164756E21
12756
12822
  //# sourceMappingURL=cli.js.map