react-doctor 0.9.1-dev.b1b62db → 0.9.2-dev.01ca0b3
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/README.md +2 -2
- package/dist/cli.js +1135 -224
- package/dist/index.d.ts +8 -2
- package/dist/index.js +819 -126
- package/dist/lsp.js +825 -126
- package/dist/{run-scan-app-DZ5jGWFf.js → run-scan-app-C9MJnVwv.js} +281 -210
- package/package.json +9 -7
package/dist/lsp.js
CHANGED
|
@@ -10,12 +10,14 @@ import * as Crypto from "node:crypto";
|
|
|
10
10
|
import crypto, { createHash } from "node:crypto";
|
|
11
11
|
import * as NodeChildProcess from "node:child_process";
|
|
12
12
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
13
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
13
14
|
import ts from "typescript";
|
|
14
|
-
import { parseJSON5 } from "confbox";
|
|
15
15
|
import * as NodeUrl from "node:url";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { parseJSON5 } from "confbox";
|
|
17
18
|
import { createJiti } from "jiti";
|
|
18
19
|
import { ANALYZED_MANIFEST_FILENAMES, DEFAULT_EXTENSIONS } from "deslop-js/analyzed-inputs";
|
|
20
|
+
import { convertToTSX } from "@astrojs/compiler/sync";
|
|
19
21
|
import { gzipSync } from "node:zlib";
|
|
20
22
|
import { CodeActionKind, CodeActionTriggerKind, DidChangeWatchedFilesNotification, DocumentDiagnosticReportKind, FileChangeType, TextDocumentSyncKind, TextDocuments, createConnection } from "vscode-languageserver/node.js";
|
|
21
23
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
@@ -10279,7 +10281,7 @@ const Number$4 = globalThis.Number;
|
|
|
10279
10281
|
* @category constructors
|
|
10280
10282
|
* @since 2.0.0
|
|
10281
10283
|
*/
|
|
10282
|
-
const parse = (s) => {
|
|
10284
|
+
const parse$1 = (s) => {
|
|
10283
10285
|
if (s === "NaN") return some(NaN);
|
|
10284
10286
|
if (s === "Infinity") return some(Infinity);
|
|
10285
10287
|
if (s === "-Infinity") return some(-Infinity);
|
|
@@ -14333,12 +14335,12 @@ TaggedError("EncodingError");
|
|
|
14333
14335
|
//#endregion
|
|
14334
14336
|
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.70/node_modules/effect/dist/internal/schema/annotations.js
|
|
14335
14337
|
/** @internal */
|
|
14336
|
-
function resolve(ast) {
|
|
14338
|
+
function resolve$1(ast) {
|
|
14337
14339
|
return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations;
|
|
14338
14340
|
}
|
|
14339
14341
|
/** @internal */
|
|
14340
14342
|
function resolveAt(key) {
|
|
14341
|
-
return (ast) => resolve(ast)?.[key];
|
|
14343
|
+
return (ast) => resolve$1(ast)?.[key];
|
|
14342
14344
|
}
|
|
14343
14345
|
/** @internal */
|
|
14344
14346
|
const resolveIdentifier = /* @__PURE__ */ resolveAt("identifier");
|
|
@@ -18090,7 +18092,7 @@ function asSync(parser) {
|
|
|
18090
18092
|
}
|
|
18091
18093
|
const recur$1 = /* @__PURE__ */ memoize((ast) => {
|
|
18092
18094
|
let parser;
|
|
18093
|
-
const astOptions = resolve(ast)?.["parseOptions"];
|
|
18095
|
+
const astOptions = resolve$1(ast)?.["parseOptions"];
|
|
18094
18096
|
if (!ast.context && !ast.encoding && !ast.checks) return (ou, options) => {
|
|
18095
18097
|
parser ??= ast.getParser(recur$1);
|
|
18096
18098
|
if (astOptions) options = {
|
|
@@ -57695,7 +57697,7 @@ var UrlParamsError = class extends TaggedError("UrlParamsError") {};
|
|
|
57695
57697
|
* @category converting
|
|
57696
57698
|
* @since 4.0.0
|
|
57697
57699
|
*/
|
|
57698
|
-
const makeUrl = (url, params, hash) => {
|
|
57700
|
+
const makeUrl$1 = (url, params, hash) => {
|
|
57699
57701
|
try {
|
|
57700
57702
|
const urlInstance = new URL(url, baseUrl());
|
|
57701
57703
|
for (let i = 0; i < params.params.length; i++) {
|
|
@@ -58329,7 +58331,7 @@ const Proto$2 = {
|
|
|
58329
58331
|
const make$10 = (f) => makeWith$1((effect) => flatMap$2(effect, (request) => withFiber((fiber) => {
|
|
58330
58332
|
const scopedController = scopedRequests.get(request);
|
|
58331
58333
|
const controller = scopedController ?? new AbortController();
|
|
58332
|
-
const urlResult = makeUrl(request.url, request.urlParams, getOrUndefined(request.hash));
|
|
58334
|
+
const urlResult = makeUrl$1(request.url, request.urlParams, getOrUndefined(request.hash));
|
|
58333
58335
|
if (isFailure(urlResult)) return fail$4(new HttpClientError({ reason: new InvalidUrlError({
|
|
58334
58336
|
request,
|
|
58335
58337
|
cause: urlResult.failure
|
|
@@ -58768,7 +58770,7 @@ const layer$7 = (loggers, options) => effect(CurrentLoggers, withFiber$1(fnUntra
|
|
|
58768
58770
|
* @since 4.0.0
|
|
58769
58771
|
*/
|
|
58770
58772
|
const policy = /* @__PURE__ */ forever$1.pipe(passthrough$2, /* @__PURE__ */ addDelay((error) => {
|
|
58771
|
-
if (isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429) return succeed$2(seconds(fromUndefinedOr(error.reason.response.headers["retry-after"]).pipe(flatMap$5(parse), getOrElse$1(() => 5))));
|
|
58773
|
+
if (isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429) return succeed$2(seconds(fromUndefinedOr(error.reason.response.headers["retry-after"]).pipe(flatMap$5(parse$1), getOrElse$1(() => 5))));
|
|
58772
58774
|
return succeed$2(seconds(1));
|
|
58773
58775
|
}));
|
|
58774
58776
|
/**
|
|
@@ -61410,6 +61412,428 @@ const layer = /* @__PURE__ */ succeed$3(Path$1)({
|
|
|
61410
61412
|
toFileUrl
|
|
61411
61413
|
});
|
|
61412
61414
|
//#endregion
|
|
61415
|
+
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
61416
|
+
var comma = ",".charCodeAt(0);
|
|
61417
|
+
";".charCodeAt(0);
|
|
61418
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
61419
|
+
var intToChar = new Uint8Array(64);
|
|
61420
|
+
var charToInt = new Uint8Array(128);
|
|
61421
|
+
for (let i = 0; i < chars.length; i++) {
|
|
61422
|
+
const c = chars.charCodeAt(i);
|
|
61423
|
+
intToChar[i] = c;
|
|
61424
|
+
charToInt[c] = i;
|
|
61425
|
+
}
|
|
61426
|
+
function decodeInteger(reader, relative) {
|
|
61427
|
+
let value = 0;
|
|
61428
|
+
let shift = 0;
|
|
61429
|
+
let integer = 0;
|
|
61430
|
+
do {
|
|
61431
|
+
integer = charToInt[reader.next()];
|
|
61432
|
+
value |= (integer & 31) << shift;
|
|
61433
|
+
shift += 5;
|
|
61434
|
+
} while (integer & 32);
|
|
61435
|
+
const shouldNegate = value & 1;
|
|
61436
|
+
value >>>= 1;
|
|
61437
|
+
if (shouldNegate) value = -2147483648 | -value;
|
|
61438
|
+
return relative + value;
|
|
61439
|
+
}
|
|
61440
|
+
function hasMoreVlq(reader, max) {
|
|
61441
|
+
if (reader.pos >= max) return false;
|
|
61442
|
+
return reader.peek() !== comma;
|
|
61443
|
+
}
|
|
61444
|
+
var StringReader = class {
|
|
61445
|
+
constructor(buffer) {
|
|
61446
|
+
this.pos = 0;
|
|
61447
|
+
this.buffer = buffer;
|
|
61448
|
+
}
|
|
61449
|
+
next() {
|
|
61450
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
61451
|
+
}
|
|
61452
|
+
peek() {
|
|
61453
|
+
return this.buffer.charCodeAt(this.pos);
|
|
61454
|
+
}
|
|
61455
|
+
indexOf(char) {
|
|
61456
|
+
const { buffer, pos } = this;
|
|
61457
|
+
const idx = buffer.indexOf(char, pos);
|
|
61458
|
+
return idx === -1 ? buffer.length : idx;
|
|
61459
|
+
}
|
|
61460
|
+
};
|
|
61461
|
+
function decode(mappings) {
|
|
61462
|
+
const { length } = mappings;
|
|
61463
|
+
const reader = new StringReader(mappings);
|
|
61464
|
+
const decoded = [];
|
|
61465
|
+
let genColumn = 0;
|
|
61466
|
+
let sourcesIndex = 0;
|
|
61467
|
+
let sourceLine = 0;
|
|
61468
|
+
let sourceColumn = 0;
|
|
61469
|
+
let namesIndex = 0;
|
|
61470
|
+
do {
|
|
61471
|
+
const semi = reader.indexOf(";");
|
|
61472
|
+
const line = [];
|
|
61473
|
+
let sorted = true;
|
|
61474
|
+
let lastCol = 0;
|
|
61475
|
+
genColumn = 0;
|
|
61476
|
+
while (reader.pos < semi) {
|
|
61477
|
+
let seg;
|
|
61478
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
61479
|
+
if (genColumn < lastCol) sorted = false;
|
|
61480
|
+
lastCol = genColumn;
|
|
61481
|
+
if (hasMoreVlq(reader, semi)) {
|
|
61482
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
61483
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
61484
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
61485
|
+
if (hasMoreVlq(reader, semi)) {
|
|
61486
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
61487
|
+
seg = [
|
|
61488
|
+
genColumn,
|
|
61489
|
+
sourcesIndex,
|
|
61490
|
+
sourceLine,
|
|
61491
|
+
sourceColumn,
|
|
61492
|
+
namesIndex
|
|
61493
|
+
];
|
|
61494
|
+
} else seg = [
|
|
61495
|
+
genColumn,
|
|
61496
|
+
sourcesIndex,
|
|
61497
|
+
sourceLine,
|
|
61498
|
+
sourceColumn
|
|
61499
|
+
];
|
|
61500
|
+
} else seg = [genColumn];
|
|
61501
|
+
line.push(seg);
|
|
61502
|
+
reader.pos++;
|
|
61503
|
+
}
|
|
61504
|
+
if (!sorted) sort(line);
|
|
61505
|
+
decoded.push(line);
|
|
61506
|
+
reader.pos = semi + 1;
|
|
61507
|
+
} while (reader.pos <= length);
|
|
61508
|
+
return decoded;
|
|
61509
|
+
}
|
|
61510
|
+
function sort(line) {
|
|
61511
|
+
line.sort(sortComparator$1);
|
|
61512
|
+
}
|
|
61513
|
+
function sortComparator$1(a, b) {
|
|
61514
|
+
return a[0] - b[0];
|
|
61515
|
+
}
|
|
61516
|
+
//#endregion
|
|
61517
|
+
//#region ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
|
|
61518
|
+
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
61519
|
+
/**
|
|
61520
|
+
* Matches the parts of a URL:
|
|
61521
|
+
* 1. Scheme, including ":", guaranteed.
|
|
61522
|
+
* 2. User/password, including "@", optional.
|
|
61523
|
+
* 3. Host, guaranteed.
|
|
61524
|
+
* 4. Port, including ":", optional.
|
|
61525
|
+
* 5. Path, including "/", optional.
|
|
61526
|
+
* 6. Query, including "?", optional.
|
|
61527
|
+
* 7. Hash, including "#", optional.
|
|
61528
|
+
*/
|
|
61529
|
+
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
61530
|
+
/**
|
|
61531
|
+
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
|
|
61532
|
+
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
|
|
61533
|
+
*
|
|
61534
|
+
* 1. Host, optional.
|
|
61535
|
+
* 2. Path, which may include "/", guaranteed.
|
|
61536
|
+
* 3. Query, including "?", optional.
|
|
61537
|
+
* 4. Hash, including "#", optional.
|
|
61538
|
+
*/
|
|
61539
|
+
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
61540
|
+
function isAbsoluteUrl(input) {
|
|
61541
|
+
return schemeRegex.test(input);
|
|
61542
|
+
}
|
|
61543
|
+
function isSchemeRelativeUrl(input) {
|
|
61544
|
+
return input.startsWith("//");
|
|
61545
|
+
}
|
|
61546
|
+
function isAbsolutePath(input) {
|
|
61547
|
+
return input.startsWith("/");
|
|
61548
|
+
}
|
|
61549
|
+
function isFileUrl(input) {
|
|
61550
|
+
return input.startsWith("file:");
|
|
61551
|
+
}
|
|
61552
|
+
function isRelative(input) {
|
|
61553
|
+
return /^[.?#]/.test(input);
|
|
61554
|
+
}
|
|
61555
|
+
function parseAbsoluteUrl(input) {
|
|
61556
|
+
const match = urlRegex.exec(input);
|
|
61557
|
+
return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
|
|
61558
|
+
}
|
|
61559
|
+
function parseFileUrl(input) {
|
|
61560
|
+
const match = fileRegex.exec(input);
|
|
61561
|
+
const path = match[2];
|
|
61562
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
|
|
61563
|
+
}
|
|
61564
|
+
function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
61565
|
+
return {
|
|
61566
|
+
scheme,
|
|
61567
|
+
user,
|
|
61568
|
+
host,
|
|
61569
|
+
port,
|
|
61570
|
+
path,
|
|
61571
|
+
query,
|
|
61572
|
+
hash,
|
|
61573
|
+
type: 7
|
|
61574
|
+
};
|
|
61575
|
+
}
|
|
61576
|
+
function parseUrl(input) {
|
|
61577
|
+
if (isSchemeRelativeUrl(input)) {
|
|
61578
|
+
const url = parseAbsoluteUrl("http:" + input);
|
|
61579
|
+
url.scheme = "";
|
|
61580
|
+
url.type = 6;
|
|
61581
|
+
return url;
|
|
61582
|
+
}
|
|
61583
|
+
if (isAbsolutePath(input)) {
|
|
61584
|
+
const url = parseAbsoluteUrl("http://foo.com" + input);
|
|
61585
|
+
url.scheme = "";
|
|
61586
|
+
url.host = "";
|
|
61587
|
+
url.type = 5;
|
|
61588
|
+
return url;
|
|
61589
|
+
}
|
|
61590
|
+
if (isFileUrl(input)) return parseFileUrl(input);
|
|
61591
|
+
if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
|
|
61592
|
+
const url = parseAbsoluteUrl("http://foo.com/" + input);
|
|
61593
|
+
url.scheme = "";
|
|
61594
|
+
url.host = "";
|
|
61595
|
+
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
61596
|
+
return url;
|
|
61597
|
+
}
|
|
61598
|
+
function stripPathFilename(path) {
|
|
61599
|
+
if (path.endsWith("/..")) return path;
|
|
61600
|
+
const index = path.lastIndexOf("/");
|
|
61601
|
+
return path.slice(0, index + 1);
|
|
61602
|
+
}
|
|
61603
|
+
function mergePaths(url, base) {
|
|
61604
|
+
normalizePath(base, base.type);
|
|
61605
|
+
if (url.path === "/") url.path = base.path;
|
|
61606
|
+
else url.path = stripPathFilename(base.path) + url.path;
|
|
61607
|
+
}
|
|
61608
|
+
/**
|
|
61609
|
+
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
|
|
61610
|
+
* "foo/.". We need to normalize to a standard representation.
|
|
61611
|
+
*/
|
|
61612
|
+
function normalizePath(url, type) {
|
|
61613
|
+
const rel = type <= 4;
|
|
61614
|
+
const pieces = url.path.split("/");
|
|
61615
|
+
let pointer = 1;
|
|
61616
|
+
let positive = 0;
|
|
61617
|
+
let addTrailingSlash = false;
|
|
61618
|
+
for (let i = 1; i < pieces.length; i++) {
|
|
61619
|
+
const piece = pieces[i];
|
|
61620
|
+
if (!piece) {
|
|
61621
|
+
addTrailingSlash = true;
|
|
61622
|
+
continue;
|
|
61623
|
+
}
|
|
61624
|
+
addTrailingSlash = false;
|
|
61625
|
+
if (piece === ".") continue;
|
|
61626
|
+
if (piece === "..") {
|
|
61627
|
+
if (positive) {
|
|
61628
|
+
addTrailingSlash = true;
|
|
61629
|
+
positive--;
|
|
61630
|
+
pointer--;
|
|
61631
|
+
} else if (rel) pieces[pointer++] = piece;
|
|
61632
|
+
continue;
|
|
61633
|
+
}
|
|
61634
|
+
pieces[pointer++] = piece;
|
|
61635
|
+
positive++;
|
|
61636
|
+
}
|
|
61637
|
+
let path = "";
|
|
61638
|
+
for (let i = 1; i < pointer; i++) path += "/" + pieces[i];
|
|
61639
|
+
if (!path || addTrailingSlash && !path.endsWith("/..")) path += "/";
|
|
61640
|
+
url.path = path;
|
|
61641
|
+
}
|
|
61642
|
+
/**
|
|
61643
|
+
* Attempts to resolve `input` URL/path relative to `base`.
|
|
61644
|
+
*/
|
|
61645
|
+
function resolve(input, base) {
|
|
61646
|
+
if (!input && !base) return "";
|
|
61647
|
+
const url = parseUrl(input);
|
|
61648
|
+
let inputType = url.type;
|
|
61649
|
+
if (base && inputType !== 7) {
|
|
61650
|
+
const baseUrl = parseUrl(base);
|
|
61651
|
+
const baseType = baseUrl.type;
|
|
61652
|
+
switch (inputType) {
|
|
61653
|
+
case 1: url.hash = baseUrl.hash;
|
|
61654
|
+
case 2: url.query = baseUrl.query;
|
|
61655
|
+
case 3:
|
|
61656
|
+
case 4: mergePaths(url, baseUrl);
|
|
61657
|
+
case 5:
|
|
61658
|
+
url.user = baseUrl.user;
|
|
61659
|
+
url.host = baseUrl.host;
|
|
61660
|
+
url.port = baseUrl.port;
|
|
61661
|
+
case 6: url.scheme = baseUrl.scheme;
|
|
61662
|
+
}
|
|
61663
|
+
if (baseType > inputType) inputType = baseType;
|
|
61664
|
+
}
|
|
61665
|
+
normalizePath(url, inputType);
|
|
61666
|
+
const queryHash = url.query + url.hash;
|
|
61667
|
+
switch (inputType) {
|
|
61668
|
+
case 2:
|
|
61669
|
+
case 3: return queryHash;
|
|
61670
|
+
case 4: {
|
|
61671
|
+
const path = url.path.slice(1);
|
|
61672
|
+
if (!path) return queryHash || ".";
|
|
61673
|
+
if (isRelative(base || input) && !isRelative(path)) return "./" + path + queryHash;
|
|
61674
|
+
return path + queryHash;
|
|
61675
|
+
}
|
|
61676
|
+
case 5: return url.path + queryHash;
|
|
61677
|
+
default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
|
|
61678
|
+
}
|
|
61679
|
+
}
|
|
61680
|
+
//#endregion
|
|
61681
|
+
//#region ../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
|
|
61682
|
+
function stripFilename(path) {
|
|
61683
|
+
if (!path) return "";
|
|
61684
|
+
const index = path.lastIndexOf("/");
|
|
61685
|
+
return path.slice(0, index + 1);
|
|
61686
|
+
}
|
|
61687
|
+
function resolver(mapUrl, sourceRoot) {
|
|
61688
|
+
const from = stripFilename(mapUrl);
|
|
61689
|
+
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
61690
|
+
return (source) => resolve(prefix + (source || ""), from);
|
|
61691
|
+
}
|
|
61692
|
+
var COLUMN = 0;
|
|
61693
|
+
var SOURCES_INDEX = 1;
|
|
61694
|
+
var SOURCE_LINE = 2;
|
|
61695
|
+
var SOURCE_COLUMN = 3;
|
|
61696
|
+
var NAMES_INDEX = 4;
|
|
61697
|
+
function maybeSort(mappings, owned) {
|
|
61698
|
+
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
61699
|
+
if (unsortedIndex === mappings.length) return mappings;
|
|
61700
|
+
if (!owned) mappings = mappings.slice();
|
|
61701
|
+
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) mappings[i] = sortSegments(mappings[i], owned);
|
|
61702
|
+
return mappings;
|
|
61703
|
+
}
|
|
61704
|
+
function nextUnsortedSegmentLine(mappings, start) {
|
|
61705
|
+
for (let i = start; i < mappings.length; i++) if (!isSorted(mappings[i])) return i;
|
|
61706
|
+
return mappings.length;
|
|
61707
|
+
}
|
|
61708
|
+
function isSorted(line) {
|
|
61709
|
+
for (let j = 1; j < line.length; j++) if (line[j][COLUMN] < line[j - 1][COLUMN]) return false;
|
|
61710
|
+
return true;
|
|
61711
|
+
}
|
|
61712
|
+
function sortSegments(line, owned) {
|
|
61713
|
+
if (!owned) line = line.slice();
|
|
61714
|
+
return line.sort(sortComparator);
|
|
61715
|
+
}
|
|
61716
|
+
function sortComparator(a, b) {
|
|
61717
|
+
return a[COLUMN] - b[COLUMN];
|
|
61718
|
+
}
|
|
61719
|
+
var found = false;
|
|
61720
|
+
function binarySearch(haystack, needle, low, high) {
|
|
61721
|
+
while (low <= high) {
|
|
61722
|
+
const mid = low + (high - low >> 1);
|
|
61723
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
61724
|
+
if (cmp === 0) {
|
|
61725
|
+
found = true;
|
|
61726
|
+
return mid;
|
|
61727
|
+
}
|
|
61728
|
+
if (cmp < 0) low = mid + 1;
|
|
61729
|
+
else high = mid - 1;
|
|
61730
|
+
}
|
|
61731
|
+
found = false;
|
|
61732
|
+
return low - 1;
|
|
61733
|
+
}
|
|
61734
|
+
function upperBound(haystack, needle, index) {
|
|
61735
|
+
for (let i = index + 1; i < haystack.length; index = i++) if (haystack[i][COLUMN] !== needle) break;
|
|
61736
|
+
return index;
|
|
61737
|
+
}
|
|
61738
|
+
function lowerBound(haystack, needle, index) {
|
|
61739
|
+
for (let i = index - 1; i >= 0; index = i--) if (haystack[i][COLUMN] !== needle) break;
|
|
61740
|
+
return index;
|
|
61741
|
+
}
|
|
61742
|
+
function memoizedState() {
|
|
61743
|
+
return {
|
|
61744
|
+
lastKey: -1,
|
|
61745
|
+
lastNeedle: -1,
|
|
61746
|
+
lastIndex: -1
|
|
61747
|
+
};
|
|
61748
|
+
}
|
|
61749
|
+
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
61750
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
61751
|
+
let low = 0;
|
|
61752
|
+
let high = haystack.length - 1;
|
|
61753
|
+
if (key === lastKey) {
|
|
61754
|
+
if (needle === lastNeedle) {
|
|
61755
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
61756
|
+
return lastIndex;
|
|
61757
|
+
}
|
|
61758
|
+
if (needle >= lastNeedle) low = lastIndex === -1 ? 0 : lastIndex;
|
|
61759
|
+
else high = lastIndex;
|
|
61760
|
+
}
|
|
61761
|
+
state.lastKey = key;
|
|
61762
|
+
state.lastNeedle = needle;
|
|
61763
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
61764
|
+
}
|
|
61765
|
+
function parse(map) {
|
|
61766
|
+
return typeof map === "string" ? JSON.parse(map) : map;
|
|
61767
|
+
}
|
|
61768
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
61769
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
61770
|
+
var TraceMap = class {
|
|
61771
|
+
constructor(map, mapUrl) {
|
|
61772
|
+
const isString = typeof map === "string";
|
|
61773
|
+
if (!isString && map._decodedMemo) return map;
|
|
61774
|
+
const parsed = parse(map);
|
|
61775
|
+
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
61776
|
+
this.version = version;
|
|
61777
|
+
this.file = file;
|
|
61778
|
+
this.names = names || [];
|
|
61779
|
+
this.sourceRoot = sourceRoot;
|
|
61780
|
+
this.sources = sources;
|
|
61781
|
+
this.sourcesContent = sourcesContent;
|
|
61782
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
61783
|
+
const resolve = resolver(mapUrl, sourceRoot);
|
|
61784
|
+
this.resolvedSources = sources.map(resolve);
|
|
61785
|
+
const { mappings } = parsed;
|
|
61786
|
+
if (typeof mappings === "string") {
|
|
61787
|
+
this._encoded = mappings;
|
|
61788
|
+
this._decoded = void 0;
|
|
61789
|
+
} else if (Array.isArray(mappings)) {
|
|
61790
|
+
this._encoded = void 0;
|
|
61791
|
+
this._decoded = maybeSort(mappings, isString);
|
|
61792
|
+
} else if (parsed.sections) throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
61793
|
+
else throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
61794
|
+
this._decodedMemo = memoizedState();
|
|
61795
|
+
this._bySources = void 0;
|
|
61796
|
+
this._bySourceMemos = void 0;
|
|
61797
|
+
}
|
|
61798
|
+
};
|
|
61799
|
+
function cast(map) {
|
|
61800
|
+
return map;
|
|
61801
|
+
}
|
|
61802
|
+
function decodedMappings(map) {
|
|
61803
|
+
var _a;
|
|
61804
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
61805
|
+
}
|
|
61806
|
+
function originalPositionFor(map, needle) {
|
|
61807
|
+
let { line, column, bias } = needle;
|
|
61808
|
+
line--;
|
|
61809
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
61810
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
61811
|
+
const decoded = decodedMappings(map);
|
|
61812
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
61813
|
+
const segments = decoded[line];
|
|
61814
|
+
const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || 1);
|
|
61815
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
61816
|
+
const segment = segments[index];
|
|
61817
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
61818
|
+
const { names, resolvedSources } = map;
|
|
61819
|
+
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
|
61820
|
+
}
|
|
61821
|
+
function OMapping(source, line, column, name) {
|
|
61822
|
+
return {
|
|
61823
|
+
source,
|
|
61824
|
+
line,
|
|
61825
|
+
column,
|
|
61826
|
+
name
|
|
61827
|
+
};
|
|
61828
|
+
}
|
|
61829
|
+
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
61830
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
61831
|
+
if (found) index = (bias === -1 ? upperBound : lowerBound)(segments, column, index);
|
|
61832
|
+
else if (bias === -1) index++;
|
|
61833
|
+
if (index === -1 || index === segments.length) return -1;
|
|
61834
|
+
return index;
|
|
61835
|
+
}
|
|
61836
|
+
//#endregion
|
|
61413
61837
|
//#region ../core/dist/index.js
|
|
61414
61838
|
var __create = Object.create;
|
|
61415
61839
|
var __defProp = Object.defineProperty;
|
|
@@ -61479,7 +61903,7 @@ var AmbiguousProjectError = class extends Error {
|
|
|
61479
61903
|
};
|
|
61480
61904
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
61481
61905
|
const HTML_FILE_PATTERN = /\.html$/i;
|
|
61482
|
-
const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
|
|
61906
|
+
const SOURCE_FILE_PATTERN = /\.(?:astro|tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
|
|
61483
61907
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
61484
61908
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
61485
61909
|
const MINIFIED_SNIFF_BYTES = 65536;
|
|
@@ -61845,7 +62269,7 @@ const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
|
61845
62269
|
const FILE_LINT_CACHE_FILENAME = "file-lint-cache.json";
|
|
61846
62270
|
const FILE_LINT_CACHE_MAX_FILE_COUNT = 5e4;
|
|
61847
62271
|
const SIDECAR_LINT_CACHE_FILENAME = "sidecar-lint-cache.json";
|
|
61848
|
-
const CORE_PACKAGE_VERSION = "0.9.
|
|
62272
|
+
const CORE_PACKAGE_VERSION = "0.9.2";
|
|
61849
62273
|
const DEAD_CODE_CACHE_FILENAME = "dead-code-cache.json";
|
|
61850
62274
|
const DEAD_CODE_SUMMARY_CACHE_FILENAME = "dead-code-summaries.json";
|
|
61851
62275
|
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
@@ -62095,8 +62519,13 @@ const findMonorepoRoot = (startDirectory) => {
|
|
|
62095
62519
|
* byte-equivalent copy.
|
|
62096
62520
|
*/
|
|
62097
62521
|
const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
|
|
62522
|
+
const unwrapTypescriptExpression = (expression) => {
|
|
62523
|
+
let currentExpression = expression;
|
|
62524
|
+
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
62525
|
+
return currentExpression;
|
|
62526
|
+
};
|
|
62098
62527
|
const TSCONFIG_FILENAME = "tsconfig.json";
|
|
62099
|
-
const
|
|
62528
|
+
const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
|
|
62100
62529
|
const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
|
|
62101
62530
|
const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
62102
62531
|
const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
|
|
@@ -62113,7 +62542,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
|
62113
62542
|
return null;
|
|
62114
62543
|
};
|
|
62115
62544
|
const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
62116
|
-
if (
|
|
62545
|
+
if (isLocalModuleSpecifier(extendsValue)) {
|
|
62546
|
+
const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
|
|
62547
|
+
if (isFile(resolvedPath)) return resolvedPath;
|
|
62548
|
+
const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
|
|
62549
|
+
return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
|
|
62550
|
+
}
|
|
62117
62551
|
return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
|
|
62118
62552
|
};
|
|
62119
62553
|
const normalizeCompilerOptions = (compilerOptions) => {
|
|
@@ -62220,6 +62654,7 @@ const FRAMEWORK_PACKAGES = {
|
|
|
62220
62654
|
"@tanstack/react-start": "tanstack-start",
|
|
62221
62655
|
"@remix-run/react": "remix",
|
|
62222
62656
|
gatsby: "gatsby",
|
|
62657
|
+
astro: "astro",
|
|
62223
62658
|
vite: "vite",
|
|
62224
62659
|
"react-scripts": "cra",
|
|
62225
62660
|
expo: "expo",
|
|
@@ -62307,6 +62742,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
|
|
|
62307
62742
|
".cts",
|
|
62308
62743
|
".json"
|
|
62309
62744
|
];
|
|
62745
|
+
const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
|
|
62746
|
+
conditionNames: [
|
|
62747
|
+
"import",
|
|
62748
|
+
"require",
|
|
62749
|
+
"node",
|
|
62750
|
+
"default"
|
|
62751
|
+
],
|
|
62752
|
+
extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
|
|
62753
|
+
});
|
|
62310
62754
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
62311
62755
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
62312
62756
|
const allDependencies = {
|
|
@@ -62330,6 +62774,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
|
|
|
62330
62774
|
return false;
|
|
62331
62775
|
};
|
|
62332
62776
|
const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
|
|
62777
|
+
if (!isLocalModuleSpecifier(moduleSpecifier)) {
|
|
62778
|
+
try {
|
|
62779
|
+
const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
|
|
62780
|
+
if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
|
|
62781
|
+
} catch {}
|
|
62782
|
+
try {
|
|
62783
|
+
const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
|
|
62784
|
+
return isFile(resolvedPath) ? resolvedPath : null;
|
|
62785
|
+
} catch {
|
|
62786
|
+
return null;
|
|
62787
|
+
}
|
|
62788
|
+
}
|
|
62333
62789
|
const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
|
|
62334
62790
|
const extension = Path.extname(unresolvedPath);
|
|
62335
62791
|
return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
|
|
@@ -62355,7 +62811,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
|
|
|
62355
62811
|
const namedBindings = importClause?.namedBindings;
|
|
62356
62812
|
return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
|
|
62357
62813
|
}
|
|
62358
|
-
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) =>
|
|
62814
|
+
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
|
|
62359
62815
|
return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
|
|
62360
62816
|
});
|
|
62361
62817
|
const getImportBinding = (sourceFile, bindingName) => {
|
|
@@ -62420,10 +62876,16 @@ const getTopLevelBinding = (sourceFile, bindingName) => {
|
|
|
62420
62876
|
}
|
|
62421
62877
|
return null;
|
|
62422
62878
|
};
|
|
62423
|
-
const getFunctionLocalBindings = (functionNode, argumentsList) => {
|
|
62879
|
+
const getFunctionLocalBindings = (functionNode, argumentsList, argumentAnalysis, functionAnalysis) => {
|
|
62424
62880
|
const localBindings = /* @__PURE__ */ new Map();
|
|
62425
62881
|
functionNode.parameters.forEach((parameter, parameterIndex) => {
|
|
62426
|
-
if (ts.isIdentifier(parameter.name))
|
|
62882
|
+
if (ts.isIdentifier(parameter.name)) {
|
|
62883
|
+
const argument = argumentsList[parameterIndex];
|
|
62884
|
+
localBindings.set(parameter.name.text, {
|
|
62885
|
+
expression: argument ?? parameter.initializer ?? null,
|
|
62886
|
+
analysis: argument ? argumentAnalysis : functionAnalysis
|
|
62887
|
+
});
|
|
62888
|
+
}
|
|
62427
62889
|
});
|
|
62428
62890
|
return localBindings;
|
|
62429
62891
|
};
|
|
@@ -62456,6 +62918,48 @@ const getScopedConfigBinding = (identifier) => {
|
|
|
62456
62918
|
};
|
|
62457
62919
|
};
|
|
62458
62920
|
const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
|
|
62921
|
+
const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
|
|
62922
|
+
const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
|
|
62923
|
+
const isNodeCreateRequireCall = (node, analysis) => {
|
|
62924
|
+
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
|
|
62925
|
+
if (!ts.isCallExpression(node)) return false;
|
|
62926
|
+
const target = node.expression;
|
|
62927
|
+
if (ts.isIdentifier(target)) {
|
|
62928
|
+
if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
|
|
62929
|
+
const importBinding = getImportBinding(analysis.sourceFile, target.text);
|
|
62930
|
+
return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
|
|
62931
|
+
}
|
|
62932
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
|
|
62933
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
|
|
62934
|
+
const createRequireReceiver = target.expression;
|
|
62935
|
+
if (ts.isCallExpression(createRequireReceiver)) {
|
|
62936
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
|
|
62937
|
+
if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
|
|
62938
|
+
const requireIdentifier = createRequireReceiver.expression;
|
|
62939
|
+
return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
|
|
62940
|
+
}
|
|
62941
|
+
if (!ts.isIdentifier(createRequireReceiver)) return false;
|
|
62942
|
+
if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
|
|
62943
|
+
const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
|
|
62944
|
+
return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
|
|
62945
|
+
};
|
|
62946
|
+
const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
|
|
62947
|
+
const [moduleSpecifierNode] = callExpression.arguments;
|
|
62948
|
+
if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
|
|
62949
|
+
const target = callExpression.expression;
|
|
62950
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62951
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
|
|
62952
|
+
if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
|
|
62953
|
+
if (!ts.isIdentifier(target.expression)) return null;
|
|
62954
|
+
const resolverIdentifier = target.expression;
|
|
62955
|
+
if (analysis.localBindings.has(resolverIdentifier.text)) return null;
|
|
62956
|
+
const scopedBinding = getScopedConfigBinding(resolverIdentifier);
|
|
62957
|
+
const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
|
|
62958
|
+
const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
|
|
62959
|
+
if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
|
|
62960
|
+
if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
|
|
62961
|
+
return moduleSpecifierNode.text;
|
|
62962
|
+
};
|
|
62459
62963
|
const getAssignedPropertyInitializer = (identifier, propertyName) => {
|
|
62460
62964
|
let bindingScope = null;
|
|
62461
62965
|
let currentNode = identifier;
|
|
@@ -62498,9 +63002,11 @@ const getAssignedPropertyInitializer = (identifier, propertyName) => {
|
|
|
62498
63002
|
initializer: assignedInitializer
|
|
62499
63003
|
};
|
|
62500
63004
|
};
|
|
62501
|
-
const getStaticConfigValueState = (expression, analysis) => {
|
|
62502
|
-
|
|
62503
|
-
|
|
63005
|
+
const getStaticConfigValueState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
|
|
63006
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
63007
|
+
if (visitedExpressions.has(unwrappedExpression)) return null;
|
|
63008
|
+
const nextVisitedExpressions = new Set(visitedExpressions);
|
|
63009
|
+
nextVisitedExpressions.add(unwrappedExpression);
|
|
62504
63010
|
if (unwrappedExpression.kind === ts.SyntaxKind.NullKeyword || ts.isIdentifier(unwrappedExpression) && unwrappedExpression.text === "undefined") return {
|
|
62505
63011
|
isNullish: true,
|
|
62506
63012
|
isTruthy: false
|
|
@@ -62515,32 +63021,32 @@ const getStaticConfigValueState = (expression, analysis) => {
|
|
|
62515
63021
|
};
|
|
62516
63022
|
if (ts.isIdentifier(unwrappedExpression)) {
|
|
62517
63023
|
if (analysis.localBindings.has(unwrappedExpression.text)) {
|
|
62518
|
-
const
|
|
62519
|
-
return
|
|
63024
|
+
const localReference = analysis.localBindings.get(unwrappedExpression.text);
|
|
63025
|
+
return localReference?.expression ? getStaticConfigValueState(localReference.expression, localReference.analysis, nextVisitedExpressions) : null;
|
|
62520
63026
|
}
|
|
62521
63027
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
|
|
62522
|
-
return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis) : null;
|
|
63028
|
+
return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis, nextVisitedExpressions) : null;
|
|
62523
63029
|
}
|
|
62524
63030
|
if (ts.isConditionalExpression(unwrappedExpression)) {
|
|
62525
|
-
const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis);
|
|
62526
|
-
if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis);
|
|
62527
|
-
const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis);
|
|
62528
|
-
const whenFalseState = getStaticConfigValueState(unwrappedExpression.whenFalse, analysis);
|
|
63031
|
+
const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis, nextVisitedExpressions);
|
|
63032
|
+
if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
|
|
63033
|
+
const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis, nextVisitedExpressions);
|
|
63034
|
+
const whenFalseState = getStaticConfigValueState(unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
|
|
62529
63035
|
return whenTrueState !== null && whenFalseState !== null && whenTrueState.isNullish === whenFalseState.isNullish && whenTrueState.isTruthy === whenFalseState.isTruthy ? whenTrueState : null;
|
|
62530
63036
|
}
|
|
62531
63037
|
if (ts.isBinaryExpression(unwrappedExpression)) {
|
|
62532
|
-
const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis);
|
|
63038
|
+
const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis, nextVisitedExpressions);
|
|
62533
63039
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
|
|
62534
63040
|
if (leftState === null) return null;
|
|
62535
|
-
return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
|
|
63041
|
+
return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
|
|
62536
63042
|
}
|
|
62537
63043
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
|
|
62538
63044
|
if (leftState === null) return null;
|
|
62539
|
-
return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis);
|
|
63045
|
+
return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions);
|
|
62540
63046
|
}
|
|
62541
63047
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken) {
|
|
62542
63048
|
if (leftState === null) return null;
|
|
62543
|
-
return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
|
|
63049
|
+
return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
|
|
62544
63050
|
}
|
|
62545
63051
|
}
|
|
62546
63052
|
return null;
|
|
@@ -62549,25 +63055,27 @@ const isStaticallyDisabledConfigExpression = (expression, analysis) => getStatic
|
|
|
62549
63055
|
const isStaticallyTruthyConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isTruthy === true;
|
|
62550
63056
|
const isStaticallyNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === true;
|
|
62551
63057
|
const isStaticallyNonNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === false;
|
|
62552
|
-
const getReactCompilerFlagState = (expression, analysis) => {
|
|
62553
|
-
|
|
62554
|
-
|
|
63058
|
+
const getReactCompilerFlagState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
|
|
63059
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
63060
|
+
if (visitedExpressions.has(unwrappedExpression)) return null;
|
|
63061
|
+
const nextVisitedExpressions = new Set(visitedExpressions);
|
|
63062
|
+
nextVisitedExpressions.add(unwrappedExpression);
|
|
62555
63063
|
if (ts.isIdentifier(unwrappedExpression)) {
|
|
62556
63064
|
const assignedBinding = getAssignedPropertyInitializer(unwrappedExpression, "reactCompiler");
|
|
62557
63065
|
if (assignedBinding.wasFound && assignedBinding.initializer) return { isEnabled: !isStaticallyDisabledConfigExpression(assignedBinding.initializer, analysis) };
|
|
62558
63066
|
if (analysis.localBindings.has(unwrappedExpression.text)) {
|
|
62559
|
-
const
|
|
62560
|
-
return
|
|
63067
|
+
const localReference = analysis.localBindings.get(unwrappedExpression.text);
|
|
63068
|
+
return localReference?.expression ? getReactCompilerFlagState(localReference.expression, localReference.analysis, nextVisitedExpressions) : null;
|
|
62561
63069
|
}
|
|
62562
63070
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
|
|
62563
|
-
return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis) : null;
|
|
63071
|
+
return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis, nextVisitedExpressions) : null;
|
|
62564
63072
|
}
|
|
62565
63073
|
if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
|
|
62566
63074
|
for (const property of [...unwrappedExpression.properties].reverse()) {
|
|
62567
63075
|
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
|
|
62568
63076
|
if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
|
|
62569
63077
|
if (ts.isSpreadAssignment(property)) {
|
|
62570
|
-
const spreadState = getReactCompilerFlagState(property.expression, analysis);
|
|
63078
|
+
const spreadState = getReactCompilerFlagState(property.expression, analysis, nextVisitedExpressions);
|
|
62571
63079
|
if (spreadState) return spreadState;
|
|
62572
63080
|
}
|
|
62573
63081
|
}
|
|
@@ -62580,8 +63088,8 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
|
|
|
62580
63088
|
visitedExpressions.add(resolvedExpression);
|
|
62581
63089
|
if (ts.isIdentifier(resolvedExpression)) {
|
|
62582
63090
|
if (analysis.localBindings.has(resolvedExpression.text)) {
|
|
62583
|
-
const
|
|
62584
|
-
return
|
|
63091
|
+
const localReference = analysis.localBindings.get(resolvedExpression.text);
|
|
63092
|
+
return localReference?.expression ? getSelectedObjectProperty(localReference.expression, propertyName, localReference.analysis, visitedExpressions) : null;
|
|
62585
63093
|
}
|
|
62586
63094
|
const scopedBinding = getScopedConfigBinding(resolvedExpression);
|
|
62587
63095
|
if (scopedBinding.wasFound) return scopedBinding.initializer ? getSelectedObjectProperty(scopedBinding.initializer, propertyName, analysis, visitedExpressions) : null;
|
|
@@ -62590,9 +63098,18 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
|
|
|
62590
63098
|
}
|
|
62591
63099
|
if (!ts.isObjectLiteralExpression(resolvedExpression)) return null;
|
|
62592
63100
|
for (const property of [...resolvedExpression.properties].reverse()) {
|
|
62593
|
-
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === propertyName) return
|
|
62594
|
-
|
|
62595
|
-
|
|
63101
|
+
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === propertyName) return {
|
|
63102
|
+
node: property.initializer,
|
|
63103
|
+
analysis
|
|
63104
|
+
};
|
|
63105
|
+
if (ts.isMethodDeclaration(property) && getStaticPropertyName$2(property.name) === propertyName) return {
|
|
63106
|
+
node: property,
|
|
63107
|
+
analysis
|
|
63108
|
+
};
|
|
63109
|
+
if (ts.isShorthandPropertyAssignment(property) && property.name.text === propertyName) return {
|
|
63110
|
+
node: property.name,
|
|
63111
|
+
analysis
|
|
63112
|
+
};
|
|
62596
63113
|
if (ts.isSpreadAssignment(property)) {
|
|
62597
63114
|
const spreadProperty = getSelectedObjectProperty(property.expression, propertyName, analysis, visitedExpressions);
|
|
62598
63115
|
if (spreadProperty) return spreadProperty;
|
|
@@ -62605,8 +63122,8 @@ const configExpressionMayDefineProperty = (expression, propertyName, analysis) =
|
|
|
62605
63122
|
while (ts.isParenthesizedExpression(resolvedExpression) || ts.isAsExpression(resolvedExpression) || ts.isTypeAssertionExpression(resolvedExpression) || ts.isSatisfiesExpression(resolvedExpression) || ts.isNonNullExpression(resolvedExpression)) resolvedExpression = resolvedExpression.expression;
|
|
62606
63123
|
if (ts.isIdentifier(resolvedExpression)) {
|
|
62607
63124
|
if (analysis.localBindings.has(resolvedExpression.text)) {
|
|
62608
|
-
const
|
|
62609
|
-
return
|
|
63125
|
+
const localReference = analysis.localBindings.get(resolvedExpression.text);
|
|
63126
|
+
return localReference?.expression ? configExpressionMayDefineProperty(localReference.expression, propertyName, localReference.analysis) : true;
|
|
62610
63127
|
}
|
|
62611
63128
|
const scopedBinding = getScopedConfigBinding(resolvedExpression);
|
|
62612
63129
|
if (scopedBinding.wasFound) return scopedBinding.initializer ? configExpressionMayDefineProperty(scopedBinding.initializer, propertyName, analysis) : true;
|
|
@@ -62690,15 +63207,15 @@ const getReExportedConfigModules = (sourceFile, exportName) => {
|
|
|
62690
63207
|
}
|
|
62691
63208
|
return bindings;
|
|
62692
63209
|
};
|
|
62693
|
-
const analyzeConfigModuleExport = (filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = []) => {
|
|
63210
|
+
const analyzeConfigModuleExport = (filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = [], argumentAnalysis) => {
|
|
62694
63211
|
if (!isFile(filePath) || importDepth > 4) return false;
|
|
62695
63212
|
const moduleVisitKey = `${filePath}:${exportName}:${allowCompilerTransform}`;
|
|
62696
63213
|
if (visitedModules.has(moduleVisitKey)) return false;
|
|
62697
63214
|
const nextVisitedModules = new Set(visitedModules);
|
|
62698
63215
|
nextVisitedModules.add(moduleVisitKey);
|
|
62699
|
-
return analyzeConfigSourceFileExport(parseConfigSourceFile(filePath, NFS.readFileSync(filePath, "utf-8")), filePath, exportName, allowCompilerTransform, importDepth, nextVisitedModules, argumentsList);
|
|
63216
|
+
return analyzeConfigSourceFileExport(parseConfigSourceFile(filePath, NFS.readFileSync(filePath, "utf-8")), filePath, exportName, allowCompilerTransform, importDepth, nextVisitedModules, argumentsList, argumentAnalysis);
|
|
62700
63217
|
};
|
|
62701
|
-
const analyzeConfigSourceFileExport = (sourceFile, filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = []) => {
|
|
63218
|
+
const analyzeConfigSourceFileExport = (sourceFile, filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = [], argumentAnalysis) => {
|
|
62702
63219
|
const analysis = {
|
|
62703
63220
|
filePath,
|
|
62704
63221
|
sourceFile,
|
|
@@ -62708,14 +63225,27 @@ const analyzeConfigSourceFileExport = (sourceFile, filePath, exportName, allowCo
|
|
|
62708
63225
|
localBindings: /* @__PURE__ */ new Map(),
|
|
62709
63226
|
activeFunctions: /* @__PURE__ */ new Set()
|
|
62710
63227
|
};
|
|
63228
|
+
const resolvedArgumentAnalysis = argumentAnalysis ?? analysis;
|
|
62711
63229
|
const exportedConfigNodes = getExportedConfigNodes(sourceFile, exportName);
|
|
62712
|
-
return exportedConfigNodes.some((node) =>
|
|
63230
|
+
return exportedConfigNodes.some((node) => {
|
|
63231
|
+
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) return analyzeConfigFunction(node, analysis, allowCompilerTransform, argumentsList, resolvedArgumentAnalysis);
|
|
63232
|
+
if (argumentsList.length > 0 && ts.isIdentifier(node)) {
|
|
63233
|
+
const topLevelBinding = getTopLevelBinding(sourceFile, node.text);
|
|
63234
|
+
if (topLevelBinding && ts.isFunctionLike(topLevelBinding)) return analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, argumentsList, resolvedArgumentAnalysis);
|
|
63235
|
+
const importBinding = getImportBinding(sourceFile, node.text);
|
|
63236
|
+
if (importBinding) {
|
|
63237
|
+
const importedFilePath = resolveImportedConfigFile(filePath, importBinding.moduleSpecifier);
|
|
63238
|
+
return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList, resolvedArgumentAnalysis));
|
|
63239
|
+
}
|
|
63240
|
+
}
|
|
63241
|
+
return analyzeConfigNode(node, analysis, allowCompilerTransform);
|
|
63242
|
+
}) || getReExportedConfigModules(sourceFile, exportName).some((binding) => {
|
|
62713
63243
|
if (exportedConfigNodes.length > 0 && binding.isNamespace) return false;
|
|
62714
63244
|
const importedFilePath = resolveImportedConfigFile(filePath, binding.moduleSpecifier);
|
|
62715
|
-
return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, binding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList));
|
|
63245
|
+
return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, binding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList, resolvedArgumentAnalysis));
|
|
62716
63246
|
});
|
|
62717
63247
|
};
|
|
62718
|
-
const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, argumentsList = []) => {
|
|
63248
|
+
const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, argumentsList = [], argumentAnalysis = analysis) => {
|
|
62719
63249
|
if (!functionNode.body) return false;
|
|
62720
63250
|
if (analysis.activeFunctions.has(functionNode.pos)) return false;
|
|
62721
63251
|
const activeFunctions = new Set(analysis.activeFunctions);
|
|
@@ -62723,7 +63253,7 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
|
|
|
62723
63253
|
const functionAnalysis = {
|
|
62724
63254
|
...analysis,
|
|
62725
63255
|
visitedNodes: /* @__PURE__ */ new Set(),
|
|
62726
|
-
localBindings: getFunctionLocalBindings(functionNode, argumentsList),
|
|
63256
|
+
localBindings: getFunctionLocalBindings(functionNode, argumentsList, argumentAnalysis, analysis),
|
|
62727
63257
|
activeFunctions
|
|
62728
63258
|
};
|
|
62729
63259
|
if (!ts.isBlock(functionNode.body)) return analyzeConfigNode(functionNode.body, functionAnalysis, allowCompilerTransform);
|
|
@@ -62739,6 +63269,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
|
|
|
62739
63269
|
visitReturns(functionNode.body);
|
|
62740
63270
|
return hasCompiler;
|
|
62741
63271
|
};
|
|
63272
|
+
const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
|
|
63273
|
+
const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
|
|
63274
|
+
if (!importedFilePath) return null;
|
|
63275
|
+
return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList, analysis);
|
|
63276
|
+
};
|
|
62742
63277
|
const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
|
|
62743
63278
|
const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
|
|
62744
63279
|
if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
|
|
@@ -62751,42 +63286,74 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
|
|
|
62751
63286
|
if (assignedPlugins.wasFound) overriddenPropertyNames.add("plugins");
|
|
62752
63287
|
if (assignedPresets.wasFound) overriddenPropertyNames.add("presets");
|
|
62753
63288
|
if (analysis.localBindings.has(identifier.text)) {
|
|
62754
|
-
const
|
|
62755
|
-
return Boolean(
|
|
63289
|
+
const localReference = analysis.localBindings.get(identifier.text);
|
|
63290
|
+
return Boolean(localReference?.expression && analyzeConfigNode(localReference.expression, localReference.analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62756
63291
|
}
|
|
62757
63292
|
const scopedBinding = getScopedConfigBinding(identifier);
|
|
62758
63293
|
if (scopedBinding.wasFound) return Boolean(scopedBinding.initializer && analyzeConfigNode(scopedBinding.initializer, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62759
63294
|
const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
|
|
62760
63295
|
if (importBinding) {
|
|
62761
63296
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
62762
|
-
|
|
62763
|
-
|
|
62764
|
-
|
|
63297
|
+
return Boolean(analyzeImportedConfig({
|
|
63298
|
+
analysis,
|
|
63299
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63300
|
+
exportName: importBinding.exportName,
|
|
63301
|
+
allowCompilerTransform
|
|
63302
|
+
}));
|
|
62765
63303
|
}
|
|
62766
63304
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
|
|
62767
63305
|
return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62768
63306
|
};
|
|
62769
63307
|
const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
|
|
62770
63308
|
const target = callExpression.expression;
|
|
63309
|
+
const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
|
|
63310
|
+
if (callableRequiredModuleSpecifier !== null) {
|
|
63311
|
+
if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
63312
|
+
if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
|
|
63313
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63314
|
+
analysis,
|
|
63315
|
+
moduleSpecifier: callableRequiredModuleSpecifier,
|
|
63316
|
+
exportName: "default",
|
|
63317
|
+
allowCompilerTransform,
|
|
63318
|
+
argumentsList: callExpression.arguments
|
|
63319
|
+
});
|
|
63320
|
+
if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63321
|
+
return null;
|
|
63322
|
+
}
|
|
62771
63323
|
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62772
63324
|
const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
|
|
62773
63325
|
if (propertyName === null) return null;
|
|
62774
63326
|
const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
|
|
62775
63327
|
if (requiredModuleSpecifier !== null) {
|
|
62776
|
-
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62777
|
-
if (
|
|
62778
|
-
const
|
|
62779
|
-
|
|
63328
|
+
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (analysis.localBindings.has(target.expression.expression.text) || getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
63329
|
+
if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
|
|
63330
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63331
|
+
analysis,
|
|
63332
|
+
moduleSpecifier: requiredModuleSpecifier,
|
|
63333
|
+
exportName: propertyName,
|
|
63334
|
+
allowCompilerTransform,
|
|
63335
|
+
argumentsList: callExpression.arguments
|
|
63336
|
+
});
|
|
63337
|
+
if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63338
|
+
return null;
|
|
62780
63339
|
}
|
|
62781
63340
|
if (!ts.isIdentifier(target.expression)) return null;
|
|
62782
|
-
const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
|
|
62783
|
-
if (importBinding?.isNamespace
|
|
62784
|
-
|
|
62785
|
-
|
|
63341
|
+
const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
|
|
63342
|
+
if (importBinding?.isNamespace) {
|
|
63343
|
+
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
|
|
63344
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63345
|
+
analysis,
|
|
63346
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63347
|
+
exportName: propertyName,
|
|
63348
|
+
allowCompilerTransform,
|
|
63349
|
+
argumentsList: callExpression.arguments
|
|
63350
|
+
});
|
|
63351
|
+
if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63352
|
+
return null;
|
|
62786
63353
|
}
|
|
62787
63354
|
const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
|
|
62788
63355
|
if (selectedProperty === null) return null;
|
|
62789
|
-
return ts.isFunctionLike(selectedProperty) ? analyzeConfigFunction(selectedProperty, analysis, allowCompilerTransform, callExpression.arguments) : analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
63356
|
+
return ts.isFunctionLike(selectedProperty.node) ? analyzeConfigFunction(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform, callExpression.arguments, analysis) : analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform);
|
|
62790
63357
|
};
|
|
62791
63358
|
const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTransformCollection = false, excludedPropertyNames) => {
|
|
62792
63359
|
const excludedPropertiesVisitKey = excludedPropertyNames ? [...excludedPropertyNames].sort().join(",") : "";
|
|
@@ -62805,9 +63372,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62805
63372
|
if (propertyName === "reactCompiler") continue;
|
|
62806
63373
|
if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === propertyName)) continue;
|
|
62807
63374
|
const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
|
|
62808
|
-
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)
|
|
62809
|
-
|
|
62810
|
-
|
|
63375
|
+
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
|
|
63376
|
+
if (analyzeImportedConfig({
|
|
63377
|
+
analysis,
|
|
63378
|
+
moduleSpecifier: property.initializer.text,
|
|
63379
|
+
exportName: "default",
|
|
63380
|
+
allowCompilerTransform: false
|
|
63381
|
+
})) return true;
|
|
62811
63382
|
}
|
|
62812
63383
|
if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
|
|
62813
63384
|
} else if (ts.isShorthandPropertyAssignment(property)) {
|
|
@@ -62831,6 +63402,8 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62831
63402
|
});
|
|
62832
63403
|
}
|
|
62833
63404
|
if (ts.isCallExpression(node)) {
|
|
63405
|
+
const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
|
|
63406
|
+
if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
|
|
62834
63407
|
const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
|
|
62835
63408
|
if (callTargetResult !== null) return callTargetResult;
|
|
62836
63409
|
const directModuleSpecifier = getRequireModuleSpecifier$1(node);
|
|
@@ -62838,16 +63411,27 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62838
63411
|
if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
62839
63412
|
if (directModuleSpecifier && !isRequireShadowed) {
|
|
62840
63413
|
if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
|
|
62841
|
-
if (
|
|
62842
|
-
|
|
62843
|
-
|
|
62844
|
-
|
|
63414
|
+
if (analyzeImportedConfig({
|
|
63415
|
+
analysis,
|
|
63416
|
+
moduleSpecifier: directModuleSpecifier,
|
|
63417
|
+
exportName: "default",
|
|
63418
|
+
allowCompilerTransform
|
|
63419
|
+
})) return true;
|
|
62845
63420
|
}
|
|
62846
63421
|
if (ts.isIdentifier(node.expression)) {
|
|
62847
|
-
|
|
62848
|
-
|
|
62849
|
-
|
|
62850
|
-
|
|
63422
|
+
if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
|
|
63423
|
+
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
63424
|
+
if (importBinding) {
|
|
63425
|
+
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
63426
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63427
|
+
analysis,
|
|
63428
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63429
|
+
exportName: importBinding.exportName,
|
|
63430
|
+
allowCompilerTransform,
|
|
63431
|
+
argumentsList: node.arguments
|
|
63432
|
+
});
|
|
63433
|
+
if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63434
|
+
}
|
|
62851
63435
|
}
|
|
62852
63436
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
|
|
62853
63437
|
if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
|
|
@@ -62857,45 +63441,55 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62857
63441
|
if (ts.isPropertyAccessExpression(node)) {
|
|
62858
63442
|
const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
|
|
62859
63443
|
if (requiredModuleSpecifier) {
|
|
62860
|
-
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62861
|
-
if (
|
|
62862
|
-
|
|
62863
|
-
|
|
62864
|
-
|
|
63444
|
+
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (analysis.localBindings.has(node.expression.expression.text) || getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
63445
|
+
if (analyzeImportedConfig({
|
|
63446
|
+
analysis,
|
|
63447
|
+
moduleSpecifier: requiredModuleSpecifier,
|
|
63448
|
+
exportName: node.name.text,
|
|
63449
|
+
allowCompilerTransform
|
|
63450
|
+
})) return true;
|
|
62865
63451
|
return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
|
|
62866
63452
|
}
|
|
62867
63453
|
if (ts.isIdentifier(node.expression)) {
|
|
62868
|
-
if (analysis.localBindings.has(node.expression.text)) {
|
|
62869
|
-
const
|
|
62870
|
-
return Boolean(
|
|
63454
|
+
if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
|
|
63455
|
+
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
63456
|
+
return Boolean(selectedProperty && analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform));
|
|
62871
63457
|
}
|
|
62872
63458
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62873
63459
|
if (importBinding?.isNamespace) {
|
|
62874
63460
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
|
|
62875
|
-
if (
|
|
62876
|
-
|
|
62877
|
-
|
|
62878
|
-
|
|
63461
|
+
if (analyzeImportedConfig({
|
|
63462
|
+
analysis,
|
|
63463
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63464
|
+
exportName: node.name.text,
|
|
63465
|
+
allowCompilerTransform
|
|
63466
|
+
})) return true;
|
|
62879
63467
|
return false;
|
|
62880
63468
|
}
|
|
62881
63469
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
62882
|
-
if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
63470
|
+
if (selectedProperty) return analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform);
|
|
62883
63471
|
return false;
|
|
62884
63472
|
}
|
|
62885
63473
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
62886
63474
|
}
|
|
62887
63475
|
if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
|
|
62888
63476
|
if (ts.isIdentifier(node.expression)) {
|
|
63477
|
+
if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
|
|
63478
|
+
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
63479
|
+
return Boolean(selectedProperty && analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform));
|
|
63480
|
+
}
|
|
62889
63481
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62890
63482
|
if (importBinding?.isNamespace) {
|
|
62891
63483
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
|
|
62892
|
-
|
|
62893
|
-
|
|
62894
|
-
|
|
62895
|
-
|
|
63484
|
+
return Boolean(analyzeImportedConfig({
|
|
63485
|
+
analysis,
|
|
63486
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63487
|
+
exportName: node.argumentExpression.text,
|
|
63488
|
+
allowCompilerTransform
|
|
63489
|
+
}));
|
|
62896
63490
|
}
|
|
62897
63491
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
62898
|
-
if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
63492
|
+
if (selectedProperty) return analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform);
|
|
62899
63493
|
return false;
|
|
62900
63494
|
}
|
|
62901
63495
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
@@ -62930,14 +63524,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62930
63524
|
};
|
|
62931
63525
|
const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
62932
63526
|
const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
|
|
62933
|
-
const hasCompilerInPackageJsonConfig = (
|
|
62934
|
-
|
|
63527
|
+
const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
|
|
63528
|
+
if (!isPlainObject(packageJson.babel)) return false;
|
|
63529
|
+
const packageJsonPath = Path.join(directory, "package.json");
|
|
63530
|
+
return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
63531
|
+
};
|
|
63532
|
+
const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
|
|
62935
63533
|
const hasCompilerConfigurationInAncestors = (directory) => {
|
|
62936
63534
|
if (isProjectBoundary(directory)) return false;
|
|
62937
63535
|
let ancestorDirectory = Path.dirname(directory);
|
|
62938
63536
|
while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
|
|
62939
63537
|
const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
|
|
62940
|
-
|
|
63538
|
+
const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
|
|
63539
|
+
if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
|
|
62941
63540
|
if (isProjectBoundary(ancestorDirectory)) return false;
|
|
62942
63541
|
ancestorDirectory = Path.dirname(ancestorDirectory);
|
|
62943
63542
|
}
|
|
@@ -65263,6 +65862,7 @@ const classifyPackageRole = (filename) => {
|
|
|
65263
65862
|
* Resolves the absolute path to read for a diagnostic's `filePath`,
|
|
65264
65863
|
* accounting for the various shapes oxlint emits:
|
|
65265
65864
|
*
|
|
65865
|
+
* - `file://` URL — decode to an absolute filesystem path.
|
|
65266
65866
|
* - Absolute POSIX (`/abs/path/file.tsx`) — pass through.
|
|
65267
65867
|
* - Absolute Windows (`C:/...` or `C:\...`) — pass through.
|
|
65268
65868
|
* - `./relative` or bare relative — join against `rootDirectory`.
|
|
@@ -65272,6 +65872,7 @@ const classifyPackageRole = (filename) => {
|
|
|
65272
65872
|
* use one canonical resolution path.
|
|
65273
65873
|
*/
|
|
65274
65874
|
const resolveCandidateReadPath = (rootDirectory, filePath) => {
|
|
65875
|
+
if (filePath.startsWith("file://")) return fileURLToPath(filePath);
|
|
65275
65876
|
const normalizedFile = filePath.replace(/\\/g, "/");
|
|
65276
65877
|
if (normalizedFile.startsWith("/") || /^[a-zA-Z]:\//.test(normalizedFile) || /^[a-zA-Z]:\\/.test(filePath)) return filePath;
|
|
65277
65878
|
return `${rootDirectory.replace(/\\/g, "/").replace(/\/$/, "")}/${normalizedFile.replace(/^\.\//, "")}`;
|
|
@@ -67121,11 +67722,6 @@ const getTypescriptScriptKind = (fileName) => {
|
|
|
67121
67722
|
if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
|
|
67122
67723
|
return ts.ScriptKind.JS;
|
|
67123
67724
|
};
|
|
67124
|
-
const unwrapTypescriptExpression = (expression) => {
|
|
67125
|
-
let currentExpression = expression;
|
|
67126
|
-
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
67127
|
-
return currentExpression;
|
|
67128
|
-
};
|
|
67129
67725
|
const BABEL_CONFIG_FILE_NAMES$1 = [
|
|
67130
67726
|
"babel.config.js",
|
|
67131
67727
|
"babel.config.cjs",
|
|
@@ -69471,7 +70067,10 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
69471
70067
|
if (argvLengthChars > spawnArgsLengthCap) return yield* foldSpawnFailure(`spawn ENAMETOOLONG (${argvLengthChars} argv chars exceed ${spawnArgsLengthCap})`);
|
|
69472
70068
|
const handle = yield* spawner.spawn(make$1(input.command, [...input.args], {
|
|
69473
70069
|
cwd: input.directory,
|
|
69474
|
-
env: input.
|
|
70070
|
+
env: input.command === "git" ? {
|
|
70071
|
+
...input.env,
|
|
70072
|
+
GIT_DIR: void 0
|
|
70073
|
+
} : input.env,
|
|
69475
70074
|
extendEnv: true
|
|
69476
70075
|
}));
|
|
69477
70076
|
const maxStdoutBytes = input.maxStdoutBytes;
|
|
@@ -69744,7 +70343,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
69744
70343
|
"--diff-filter=ACMR",
|
|
69745
70344
|
"--relative"
|
|
69746
70345
|
]).pipe(map$3((result) => {
|
|
69747
|
-
if (result.status !== 0) return
|
|
70346
|
+
if (result.status !== 0) return null;
|
|
69748
70347
|
return splitNullSeparated(result.stdout);
|
|
69749
70348
|
})),
|
|
69750
70349
|
showStagedContent: (directory, relativePath, options) => runCommand({
|
|
@@ -70832,6 +71431,50 @@ const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
|
|
|
70832
71431
|
while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
|
|
70833
71432
|
return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
|
|
70834
71433
|
};
|
|
71434
|
+
const utf8OffsetFromSourcePosition = (sourceBuffer, lineNumber, zeroBasedColumn) => {
|
|
71435
|
+
if (lineNumber < 1 || zeroBasedColumn < 0) return null;
|
|
71436
|
+
const sourceLines = sourceBuffer.toString("utf8").split("\n");
|
|
71437
|
+
const sourceLine = sourceLines[lineNumber - 1];
|
|
71438
|
+
if (sourceLine === void 0 || zeroBasedColumn > sourceLine.length) return null;
|
|
71439
|
+
const precedingLines = sourceLines.slice(0, lineNumber - 1).join("\n");
|
|
71440
|
+
return (lineNumber === 1 ? 0 : Buffer.byteLength(precedingLines) + Buffer.byteLength("\n")) + Buffer.byteLength(sourceLine.slice(0, zeroBasedColumn));
|
|
71441
|
+
};
|
|
71442
|
+
const mapPreparedSourceSpan = (span, preparedSourceMap) => {
|
|
71443
|
+
const generatedLine = lineOfUtf8Offset(preparedSourceMap.generatedBuffer, span.offset);
|
|
71444
|
+
const generatedColumn = columnOfUtf8Offset(preparedSourceMap.generatedBuffer, span.offset) - 1;
|
|
71445
|
+
const originalStart = originalPositionFor(preparedSourceMap.traceMap, {
|
|
71446
|
+
line: generatedLine,
|
|
71447
|
+
column: generatedColumn
|
|
71448
|
+
});
|
|
71449
|
+
if (originalStart.source === null || originalStart.line === null || originalStart.column === null) return null;
|
|
71450
|
+
const originalOffset = utf8OffsetFromSourcePosition(preparedSourceMap.sourceBuffer, originalStart.line, originalStart.column);
|
|
71451
|
+
if (originalOffset === null) return null;
|
|
71452
|
+
const generatedSpan = preparedSourceMap.generatedBuffer.subarray(span.offset, span.offset + span.length);
|
|
71453
|
+
return {
|
|
71454
|
+
offset: originalOffset,
|
|
71455
|
+
length: preparedSourceMap.sourceBuffer.subarray(originalOffset, originalOffset + generatedSpan.length).equals(generatedSpan) ? generatedSpan.length : 0,
|
|
71456
|
+
line: originalStart.line,
|
|
71457
|
+
column: originalStart.column + 1
|
|
71458
|
+
};
|
|
71459
|
+
};
|
|
71460
|
+
const mapPreparedSourceLabels = (labels, preparedSourceMap) => {
|
|
71461
|
+
const primaryLabel = labels[0];
|
|
71462
|
+
if (primaryLabel === void 0) return null;
|
|
71463
|
+
const primarySpan = mapPreparedSourceSpan(primaryLabel.span, preparedSourceMap);
|
|
71464
|
+
if (primarySpan === null) return null;
|
|
71465
|
+
const mappedLabels = [{
|
|
71466
|
+
...primaryLabel,
|
|
71467
|
+
span: primarySpan
|
|
71468
|
+
}];
|
|
71469
|
+
for (const relatedLabel of labels.slice(1)) {
|
|
71470
|
+
const relatedSpan = mapPreparedSourceSpan(relatedLabel.span, preparedSourceMap);
|
|
71471
|
+
if (relatedSpan !== null) mappedLabels.push({
|
|
71472
|
+
...relatedLabel,
|
|
71473
|
+
span: relatedSpan
|
|
71474
|
+
});
|
|
71475
|
+
}
|
|
71476
|
+
return mappedLabels;
|
|
71477
|
+
};
|
|
70835
71478
|
const REDACTED_PLACEHOLDER = "<redacted>";
|
|
70836
71479
|
const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
|
|
70837
71480
|
const KNOWN_SECRET_RULES = [
|
|
@@ -71576,7 +72219,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
|
|
|
71576
72219
|
* to the first `{`. Raises `OxlintOutputUnparseable` when the
|
|
71577
72220
|
* stdout isn't valid JSON or doesn't carry a `diagnostics` array.
|
|
71578
72221
|
*/
|
|
71579
|
-
const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath) => {
|
|
72222
|
+
const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath) => {
|
|
71580
72223
|
if (!stdout) return [];
|
|
71581
72224
|
const jsonStart = stdout.indexOf("{");
|
|
71582
72225
|
const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
|
|
@@ -71594,6 +72237,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath)
|
|
|
71594
72237
|
const sourceLinesCache = /* @__PURE__ */ new Map();
|
|
71595
72238
|
const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
|
|
71596
72239
|
const resolveMappedSourceFilename = (filename) => sourcePathByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
|
|
72240
|
+
const resolvePreparedSourceMap = (filename) => sourceMapByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
|
|
71597
72241
|
const resolveSourceFilename = (filename) => resolveMappedSourceFilename(filename) ?? filename;
|
|
71598
72242
|
const readSourceBuffer = (filename) => {
|
|
71599
72243
|
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
@@ -71625,7 +72269,19 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath)
|
|
|
71625
72269
|
minifiedFileCache.set(absolutePath, minified);
|
|
71626
72270
|
return minified;
|
|
71627
72271
|
};
|
|
71628
|
-
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.
|
|
72272
|
+
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.flatMap((diagnostic) => {
|
|
72273
|
+
const preparedSourceMap = resolvePreparedSourceMap(diagnostic.filename);
|
|
72274
|
+
if (preparedSourceMap === void 0) return [diagnostic];
|
|
72275
|
+
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
72276
|
+
if (plugin !== "react-doctor" || !reactDoctorPlugin.rules[rule]?.tags?.includes("design")) return [];
|
|
72277
|
+
const labels = mapPreparedSourceLabels(diagnostic.labels, preparedSourceMap);
|
|
72278
|
+
const sourceFilename = resolveMappedSourceFilename(diagnostic.filename);
|
|
72279
|
+
return labels === null || sourceFilename === void 0 ? [] : [{
|
|
72280
|
+
...diagnostic,
|
|
72281
|
+
filename: sourceFilename,
|
|
72282
|
+
labels
|
|
72283
|
+
}];
|
|
72284
|
+
}).filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(resolveSourceFilename(diagnostic.filename)) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
|
|
71629
72285
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
71630
72286
|
const primaryLabel = diagnostic.labels[0];
|
|
71631
72287
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
@@ -71843,7 +72499,7 @@ const isParallelismRelatedSpawnError = (error) => {
|
|
|
71843
72499
|
* loop with a slimmer config in that case.
|
|
71844
72500
|
*/
|
|
71845
72501
|
const spawnLintBatches = async (input) => {
|
|
71846
|
-
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
72502
|
+
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, sourceMapByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
71847
72503
|
const resolveSourcePath = (filePath) => {
|
|
71848
72504
|
const absoluteFilePath = Path.isAbsolute(filePath) ? filePath : Path.resolve(rootDirectory, filePath);
|
|
71849
72505
|
return sourcePathByLintPath?.get(Path.normalize(absoluteFilePath)) ?? filePath;
|
|
@@ -71867,7 +72523,7 @@ const spawnLintBatches = async (input) => {
|
|
|
71867
72523
|
}
|
|
71868
72524
|
const batchArgs = [...baseArgs, ...batch];
|
|
71869
72525
|
try {
|
|
71870
|
-
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath);
|
|
72526
|
+
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath);
|
|
71871
72527
|
} catch (error) {
|
|
71872
72528
|
if (!isSplittableReactDoctorError(error)) throw error;
|
|
71873
72529
|
if (isPastDeadline()) {
|
|
@@ -72306,20 +72962,47 @@ const prepareHtmlScriptSource = (sourceBuffer) => {
|
|
|
72306
72962
|
lintBuffer: maskedBuffer ?? sourceBuffer
|
|
72307
72963
|
};
|
|
72308
72964
|
};
|
|
72309
|
-
const
|
|
72965
|
+
const ASTRO_FILE_PATTERN = /\.astro$/;
|
|
72966
|
+
const prepareLintSources = (rootDirectory, temporaryDirectory, candidateFiles) => {
|
|
72310
72967
|
const lintFiles = [];
|
|
72311
72968
|
const sourcePathByLintPath = /* @__PURE__ */ new Map();
|
|
72969
|
+
const sourceMapByLintPath = /* @__PURE__ */ new Map();
|
|
72312
72970
|
const sizeByLintPath = /* @__PURE__ */ new Map();
|
|
72313
72971
|
const htmlSourcesDirectory = Path.join(temporaryDirectory, "html-sources");
|
|
72972
|
+
const astroSourcesDirectory = Path.join(temporaryDirectory, "astro-sources");
|
|
72314
72973
|
let htmlFileIndex = 0;
|
|
72974
|
+
let astroFileIndex = 0;
|
|
72315
72975
|
let hasThreeModuleImport = false;
|
|
72316
72976
|
for (const candidateFile of candidateFiles) {
|
|
72317
|
-
if (!HTML_FILE_PATTERN.test(candidateFile)) {
|
|
72977
|
+
if (!HTML_FILE_PATTERN.test(candidateFile) && !ASTRO_FILE_PATTERN.test(candidateFile)) {
|
|
72318
72978
|
lintFiles.push(candidateFile);
|
|
72319
72979
|
continue;
|
|
72320
72980
|
}
|
|
72321
72981
|
const absoluteSourcePath = Path.isAbsolute(candidateFile) ? candidateFile : Path.resolve(rootDirectory, candidateFile);
|
|
72322
72982
|
const sourceBuffer = NFS.readFileSync(absoluteSourcePath);
|
|
72983
|
+
if (ASTRO_FILE_PATTERN.test(candidateFile)) {
|
|
72984
|
+
const compilerSourcePath = absoluteSourcePath.replaceAll("\\", "/");
|
|
72985
|
+
const convertedSource = convertToTSX(sourceBuffer.toString("utf8"), {
|
|
72986
|
+
filename: compilerSourcePath,
|
|
72987
|
+
sourcemap: "external",
|
|
72988
|
+
includeScripts: true
|
|
72989
|
+
});
|
|
72990
|
+
if (astroFileIndex === 0) NFS.mkdirSync(astroSourcesDirectory, { recursive: true });
|
|
72991
|
+
const lintPath = Path.join(astroSourcesDirectory, `${astroFileIndex}.tsx`);
|
|
72992
|
+
const generatedBuffer = Buffer.from(convertedSource.code);
|
|
72993
|
+
NFS.writeFileSync(lintPath, generatedBuffer);
|
|
72994
|
+
lintFiles.push(candidateFile);
|
|
72995
|
+
lintFiles.push(lintPath);
|
|
72996
|
+
sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
|
|
72997
|
+
sourceMapByLintPath.set(Path.resolve(lintPath), {
|
|
72998
|
+
traceMap: new TraceMap(JSON.stringify(convertedSource.map)),
|
|
72999
|
+
generatedBuffer,
|
|
73000
|
+
sourceBuffer
|
|
73001
|
+
});
|
|
73002
|
+
sizeByLintPath.set(lintPath, sourceBuffer.length);
|
|
73003
|
+
astroFileIndex++;
|
|
73004
|
+
continue;
|
|
73005
|
+
}
|
|
72323
73006
|
const { executableScriptBodies, lintBuffer } = prepareHtmlScriptSource(sourceBuffer);
|
|
72324
73007
|
if (htmlFileIndex === 0) NFS.mkdirSync(htmlSourcesDirectory, { recursive: true });
|
|
72325
73008
|
const lintPath = Path.join(htmlSourcesDirectory, `${htmlFileIndex}.astro`);
|
|
@@ -72333,6 +73016,7 @@ const prepareHtmlLintSources = (rootDirectory, temporaryDirectory, candidateFile
|
|
|
72333
73016
|
return {
|
|
72334
73017
|
lintFiles,
|
|
72335
73018
|
sourcePathByLintPath,
|
|
73019
|
+
sourceMapByLintPath,
|
|
72336
73020
|
sizeByLintPath,
|
|
72337
73021
|
hasThreeModuleImport
|
|
72338
73022
|
};
|
|
@@ -72551,10 +73235,10 @@ const runOxlint = async (options) => {
|
|
|
72551
73235
|
rootDirectory,
|
|
72552
73236
|
candidateFiles
|
|
72553
73237
|
});
|
|
72554
|
-
const
|
|
72555
|
-
const lintFiles =
|
|
72556
|
-
const
|
|
72557
|
-
const lintProject = !project.hasThree &&
|
|
73238
|
+
const preparedLintSources = prepareLintSources(rootDirectory, configDirectory, candidateFiles);
|
|
73239
|
+
const lintFiles = preparedLintSources.lintFiles;
|
|
73240
|
+
const hasPreparedFiles = preparedLintSources.sourcePathByLintPath.size > 0;
|
|
73241
|
+
const lintProject = !project.hasThree && preparedLintSources.hasThreeModuleImport ? {
|
|
72558
73242
|
...project,
|
|
72559
73243
|
hasThree: true
|
|
72560
73244
|
} : project;
|
|
@@ -72576,7 +73260,7 @@ const runOxlint = async (options) => {
|
|
|
72576
73260
|
sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
|
|
72577
73261
|
});
|
|
72578
73262
|
const sizeByFile = sizedScanFiles !== null && lintBatchOrdering === "cost" ? new Map(sizedScanFiles.map((entry) => [entry.path, entry.sizeBytes])) : null;
|
|
72579
|
-
if (sizeByFile !== null) for (const [lintPath, sizeBytes] of
|
|
73263
|
+
if (sizeByFile !== null) for (const [lintPath, sizeBytes] of preparedLintSources.sizeByLintPath) sizeByFile.set(lintPath, sizeBytes);
|
|
72580
73264
|
const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
|
|
72581
73265
|
baseArgs: passBaseArgs,
|
|
72582
73266
|
files: passFiles,
|
|
@@ -72606,7 +73290,8 @@ const runOxlint = async (options) => {
|
|
|
72606
73290
|
rootDirectory,
|
|
72607
73291
|
nodeBinaryPath,
|
|
72608
73292
|
project: lintProject,
|
|
72609
|
-
sourcePathByLintPath:
|
|
73293
|
+
sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
|
|
73294
|
+
sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
|
|
72610
73295
|
onPartialFailure: reportPartialFailure,
|
|
72611
73296
|
onAnalyzedFiles: (filePaths) => {
|
|
72612
73297
|
analyzedFiles = filePaths;
|
|
@@ -72641,7 +73326,7 @@ const runOxlint = async (options) => {
|
|
|
72641
73326
|
};
|
|
72642
73327
|
}
|
|
72643
73328
|
};
|
|
72644
|
-
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !
|
|
73329
|
+
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !hasPreparedFiles) {
|
|
72645
73330
|
const rulesetHash = computeRulesetHash({
|
|
72646
73331
|
config: buildConfig({
|
|
72647
73332
|
extendsPaths: [],
|
|
@@ -72807,7 +73492,8 @@ const runOxlint = async (options) => {
|
|
|
72807
73492
|
rootDirectory,
|
|
72808
73493
|
nodeBinaryPath,
|
|
72809
73494
|
project: lintProject,
|
|
72810
|
-
sourcePathByLintPath:
|
|
73495
|
+
sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
|
|
73496
|
+
sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
|
|
72811
73497
|
onPartialFailure,
|
|
72812
73498
|
onAnalyzedFiles: (filePaths) => {
|
|
72813
73499
|
analyzedFiles = filePaths;
|
|
@@ -74156,10 +74842,14 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
74156
74842
|
materializedFiles.push(relativePath);
|
|
74157
74843
|
}
|
|
74158
74844
|
yield* sync(() => {
|
|
74159
|
-
for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
74160
|
-
const sourcePath = path.join(input.directory, configFilename);
|
|
74161
|
-
const targetPath = path.
|
|
74162
|
-
if (
|
|
74845
|
+
for (const subdirectory of ["", ...input.configSubdirectories ?? []]) for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
74846
|
+
const sourcePath = path.join(input.directory, subdirectory, configFilename);
|
|
74847
|
+
const targetPath = path.resolve(resolvedTempDirectory, subdirectory, configFilename);
|
|
74848
|
+
if (!isPathInsideDirectory(targetPath, resolvedTempDirectory)) continue;
|
|
74849
|
+
if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
|
|
74850
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
74851
|
+
fs.cpSync(sourcePath, targetPath);
|
|
74852
|
+
}
|
|
74163
74853
|
}
|
|
74164
74854
|
});
|
|
74165
74855
|
return {
|
|
@@ -74180,15 +74870,17 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
74180
74870
|
static layerNode = effect(StagedFiles, gen(function* () {
|
|
74181
74871
|
const git = yield* Git;
|
|
74182
74872
|
return StagedFiles.of({
|
|
74183
|
-
discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(map$3((entries) => entries.filter(isLintableSourceFile)), withSpan("StagedFiles.discoverSourceFiles")),
|
|
74184
|
-
materialize: ({ directory, stagedFiles, tempDirectory }) => materializeSourceTree({
|
|
74873
|
+
discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(map$3((entries) => entries === null ? null : entries.filter(isLintableSourceFile)), withSpan("StagedFiles.discoverSourceFiles")),
|
|
74874
|
+
materialize: ({ directory, stagedFiles, tempDirectory, configSubdirectories }) => materializeSourceTree({
|
|
74185
74875
|
directory,
|
|
74186
74876
|
files: stagedFiles,
|
|
74187
74877
|
tempDirectory,
|
|
74878
|
+
configSubdirectories,
|
|
74188
74879
|
readContent: (relativePath) => git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES })
|
|
74189
74880
|
}).pipe(map$3((tree) => ({
|
|
74190
74881
|
tempDirectory: tree.tempDirectory,
|
|
74191
74882
|
stagedFiles: tree.materializedFiles,
|
|
74883
|
+
unmaterializedFiles: tree.unmaterializedFiles,
|
|
74192
74884
|
cleanup: tree.cleanup
|
|
74193
74885
|
})), withSpan("StagedFiles.materialize"))
|
|
74194
74886
|
});
|
|
@@ -74203,6 +74895,7 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
74203
74895
|
materialize: ({ tempDirectory }) => succeed$2({
|
|
74204
74896
|
tempDirectory,
|
|
74205
74897
|
stagedFiles: snapshot.materializedFiles ?? snapshot.sourceFiles ?? [],
|
|
74898
|
+
unmaterializedFiles: [],
|
|
74206
74899
|
cleanup: () => {}
|
|
74207
74900
|
})
|
|
74208
74901
|
}));
|
|
@@ -74341,7 +75034,7 @@ const computeConfigFingerprint = (projectDirectory, version) => {
|
|
|
74341
75034
|
/** Display name used in client-facing messages and progress titles. */
|
|
74342
75035
|
const SERVER_DISPLAY_NAME = "React Doctor";
|
|
74343
75036
|
/** Server version reported in `serverInfo`; injected at build, `dev` from source. */
|
|
74344
|
-
const SERVER_VERSION = "0.9.
|
|
75037
|
+
const SERVER_VERSION = "0.9.2";
|
|
74345
75038
|
/** `Diagnostic.source` shown next to every published diagnostic. */
|
|
74346
75039
|
const DIAGNOSTIC_SOURCE = "react-doctor";
|
|
74347
75040
|
/**
|
|
@@ -76035,11 +76728,13 @@ const METRIC = {
|
|
|
76035
76728
|
cliError: "cli.error",
|
|
76036
76729
|
cliEnvironmentError: "cli.env_error",
|
|
76037
76730
|
stagedSnapshotDivergence: "staged.snapshot_divergence",
|
|
76731
|
+
stagedPerProject: "staged.per_project",
|
|
76038
76732
|
projectDetected: "project.detected",
|
|
76039
76733
|
projectPathSelected: "project.path_selected",
|
|
76040
76734
|
projectConfigSelected: "project.config_selected",
|
|
76041
76735
|
scanCompleted: "scan.completed",
|
|
76042
76736
|
scanDuration: "scan.duration",
|
|
76737
|
+
scanFeedbackDelay: "scan.feedback_delay",
|
|
76043
76738
|
scanPhaseDuration: "scan.phase_duration",
|
|
76044
76739
|
scanFiles: "scan.files",
|
|
76045
76740
|
scanScore: "scan.score",
|
|
@@ -76071,6 +76766,10 @@ const METRIC = {
|
|
|
76071
76766
|
lspScanCompleted: "lsp.scan.completed",
|
|
76072
76767
|
lspScanDuration: "lsp.scan.duration",
|
|
76073
76768
|
lspScanDiagnostics: "lsp.scan.diagnostics",
|
|
76769
|
+
tuiActionMenuOpened: "tui.action_menu_opened",
|
|
76770
|
+
tuiCompactReportShown: "tui.compact_report_shown",
|
|
76771
|
+
tuiFindingNavigated: "tui.finding_navigated",
|
|
76772
|
+
tuiStackedReportCapped: "tui.stacked_report_capped",
|
|
76074
76773
|
aiTrainingWarningShown: "ai.training.warning_shown",
|
|
76075
76774
|
jsonOutUsed: "json.out_used"
|
|
76076
76775
|
};
|
|
@@ -76372,5 +77071,5 @@ const startLanguageServer = () => {
|
|
|
76372
77071
|
};
|
|
76373
77072
|
//#endregion
|
|
76374
77073
|
export { startLanguageServer };
|
|
76375
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
76376
|
-
//# debugId=
|
|
77074
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7cb1cf13-9787-536b-856a-49d43fec26a4")}catch(e){}}();
|
|
77075
|
+
//# debugId=7cb1cf13-9787-536b-856a-49d43fec26a4
|