foresthouse 1.0.1-dev.1 → 1.0.1-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as printReactUsageTree, c as printPackageDependencyTree, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, m as isSourceCodeFile, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree } from "./react-
|
|
2
|
+
import { a as printReactUsageTree, c as printPackageDependencyTree, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, m as isSourceCodeFile, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree } from "./react-DxWukhfX.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as printReactUsageTree, c as printPackageDependencyTree, d as getReactUsageRoots, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, l as getFilteredUsages, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree, u as getReactUsageEntries } from "./react-
|
|
1
|
+
import { a as printReactUsageTree, c as printPackageDependencyTree, d as getReactUsageRoots, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, l as getFilteredUsages, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree, u as getReactUsageEntries } from "./react-DxWukhfX.mjs";
|
|
2
2
|
export { analyzeDependencies, analyzePackageDependencies, analyzePackageDependencyDiff, analyzeReactUsage, diffGraphToSerializablePackageTree, getFilteredUsages, getReactUsageEntries, getReactUsageRoots, graphToSerializablePackageTree, graphToSerializableReactTree, graphToSerializableTree, printDependencyTree, printPackageDependencyDiffTree, printPackageDependencyTree, printReactUsageTree };
|
|
@@ -1499,6 +1499,7 @@ function unwrapExpression(expression) {
|
|
|
1499
1499
|
}
|
|
1500
1500
|
//#endregion
|
|
1501
1501
|
//#region src/analyzers/react/entries.ts
|
|
1502
|
+
const lineStartOffsetsCache = /* @__PURE__ */ new Map();
|
|
1502
1503
|
function collectEntryUsages(program, filePath, sourceText, includeBuiltins) {
|
|
1503
1504
|
const entries = /* @__PURE__ */ new Map();
|
|
1504
1505
|
program.body.forEach((statement) => {
|
|
@@ -1565,24 +1566,43 @@ function createReactUsageLocation(filePath, sourceText, offset) {
|
|
|
1565
1566
|
};
|
|
1566
1567
|
}
|
|
1567
1568
|
function offsetToLineAndColumn(sourceText, offset) {
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
line += 1;
|
|
1573
|
-
column = 1;
|
|
1574
|
-
continue;
|
|
1575
|
-
}
|
|
1576
|
-
column += 1;
|
|
1577
|
-
}
|
|
1569
|
+
const lineStartOffsets = getLineStartOffsets(sourceText);
|
|
1570
|
+
const boundedOffset = Math.max(0, Math.min(offset, sourceText.length));
|
|
1571
|
+
const lineIndex = findLineIndex(lineStartOffsets, boundedOffset);
|
|
1572
|
+
const lineStartOffset = lineStartOffsets[lineIndex] ?? 0;
|
|
1578
1573
|
return {
|
|
1579
|
-
line,
|
|
1580
|
-
column
|
|
1574
|
+
line: lineIndex + 1,
|
|
1575
|
+
column: boundedOffset - lineStartOffset + 1
|
|
1581
1576
|
};
|
|
1582
1577
|
}
|
|
1583
1578
|
function comparePendingReactUsageEntries(left, right) {
|
|
1584
1579
|
return left.location.filePath.localeCompare(right.location.filePath) || left.location.line - right.location.line || left.location.column - right.location.column || left.kind.localeCompare(right.kind) || left.referenceName.localeCompare(right.referenceName);
|
|
1585
1580
|
}
|
|
1581
|
+
function getLineStartOffsets(sourceText) {
|
|
1582
|
+
const cached = lineStartOffsetsCache.get(sourceText);
|
|
1583
|
+
if (cached !== void 0) return cached;
|
|
1584
|
+
const lineStartOffsets = [0];
|
|
1585
|
+
for (let index = 0; index < sourceText.length; index += 1) if (sourceText[index] === "\n") lineStartOffsets.push(index + 1);
|
|
1586
|
+
lineStartOffsetsCache.set(sourceText, lineStartOffsets);
|
|
1587
|
+
return lineStartOffsets;
|
|
1588
|
+
}
|
|
1589
|
+
function findLineIndex(lineStartOffsets, offset) {
|
|
1590
|
+
let lowerBound = 0;
|
|
1591
|
+
let upperBound = lineStartOffsets.length - 1;
|
|
1592
|
+
while (lowerBound <= upperBound) {
|
|
1593
|
+
const middleIndex = Math.floor((lowerBound + upperBound) / 2);
|
|
1594
|
+
const middleOffset = lineStartOffsets[middleIndex];
|
|
1595
|
+
const nextOffset = lineStartOffsets[middleIndex + 1];
|
|
1596
|
+
if (middleOffset === void 0) return 0;
|
|
1597
|
+
if (offset < middleOffset) {
|
|
1598
|
+
upperBound = middleIndex - 1;
|
|
1599
|
+
continue;
|
|
1600
|
+
}
|
|
1601
|
+
if (nextOffset === void 0 || offset < nextOffset) return middleIndex;
|
|
1602
|
+
lowerBound = middleIndex + 1;
|
|
1603
|
+
}
|
|
1604
|
+
return Math.max(0, lineStartOffsets.length - 1);
|
|
1605
|
+
}
|
|
1586
1606
|
//#endregion
|
|
1587
1607
|
//#region src/analyzers/react/symbols.ts
|
|
1588
1608
|
function collectTopLevelReactSymbols(statement, filePath, symbolsByName) {
|
|
@@ -2520,4 +2540,4 @@ function formatReactNodeFilePath(filePath, kind, cwd) {
|
|
|
2520
2540
|
//#endregion
|
|
2521
2541
|
export { printReactUsageTree as a, printPackageDependencyTree as c, getReactUsageRoots as d, analyzeReactUsage as f, analyzePackageDependencies as g, analyzePackageDependencyDiff as h, graphToSerializablePackageTree as i, getFilteredUsages as l, isSourceCodeFile as m, graphToSerializableTree as n, printDependencyTree as o, analyzeDependencies as p, diffGraphToSerializablePackageTree as r, printPackageDependencyDiffTree as s, graphToSerializableReactTree as t, getReactUsageEntries as u };
|
|
2522
2542
|
|
|
2523
|
-
//# sourceMappingURL=react-
|
|
2543
|
+
//# sourceMappingURL=react-DxWukhfX.mjs.map
|