lurqrun 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -10
- package/dist/auditHandler-JCOJSUYW.js +23 -0
- package/dist/bin/lurq.js +3090 -23306
- package/dist/browserAuth-B6G27USY.js +95 -0
- package/dist/cache-DKI34SVS.js +12 -0
- package/dist/check-2FDGUOV7.js +192 -0
- package/dist/checkUpgrade-F2WESBPM.js +103 -0
- package/dist/chunk-2VMOWSRY.js +300 -0
- package/dist/chunk-3GHJR7XR.js +2049 -0
- package/dist/chunk-3N3Q3DSW.js +214 -0
- package/dist/chunk-4ESO33J6.js +34 -0
- package/dist/chunk-4F7ZESPO.js +132 -0
- package/dist/chunk-4KCPOMG6.js +68 -0
- package/dist/chunk-4ZYCIMY4.js +155 -0
- package/dist/chunk-63MUJNZL.js +318 -0
- package/dist/chunk-6AAEVQ7I.js +6336 -0
- package/dist/chunk-6EQ3ARXA.js +304 -0
- package/dist/chunk-6L3U7DZ5.js +23 -0
- package/dist/chunk-AHBP533R.js +220 -0
- package/dist/chunk-B43LCXBM.js +223 -0
- package/dist/chunk-BCANRN5B.js +33 -0
- package/dist/chunk-BUALU27S.js +123 -0
- package/dist/chunk-BULZAX2U.js +1554 -0
- package/dist/chunk-BV32UNLL.js +154 -0
- package/dist/chunk-C6GLE626.js +160 -0
- package/dist/chunk-CIDWNUAP.js +145 -0
- package/dist/chunk-CUP36ND3.js +2126 -0
- package/dist/chunk-CW5HJ3LX.js +96 -0
- package/dist/chunk-DB2VF5UD.js +315 -0
- package/dist/chunk-DWAGCNEL.js +210 -0
- package/dist/chunk-EA3DP5HG.js +293 -0
- package/dist/chunk-ELGCAM7P.js +184 -0
- package/dist/chunk-FW6BD2NO.js +1915 -0
- package/dist/chunk-GE37NVLN.js +15 -0
- package/dist/chunk-GPTKSNR6.js +171 -0
- package/dist/chunk-GRJXQBQZ.js +793 -0
- package/dist/chunk-HWBBVLOT.js +92 -0
- package/dist/chunk-I2JUKN6Z.js +24 -0
- package/dist/chunk-I3M2KJXB.js +56 -0
- package/dist/chunk-IQ4SDKKY.js +733 -0
- package/dist/chunk-J5FZYN4A.js +116 -0
- package/dist/chunk-L6N4JFW2.js +263 -0
- package/dist/chunk-LBFGSSF2.js +126 -0
- package/dist/chunk-LEGPB7DO.js +81 -0
- package/dist/chunk-LO35HLQZ.js +219 -0
- package/dist/chunk-LRD4GBYE.js +73 -0
- package/dist/chunk-LUAKDHLZ.js +40 -0
- package/dist/chunk-LYMPYETA.js +965 -0
- package/dist/chunk-M6NYEXCW.js +38 -0
- package/dist/chunk-MHUEVBVO.js +35 -0
- package/dist/chunk-MYGSLK44.js +37 -0
- package/dist/chunk-NH5I4KHH.js +201 -0
- package/dist/chunk-OQS4GUSI.js +1391 -0
- package/dist/chunk-PSX3GIAN.js +176 -0
- package/dist/chunk-Q5VPF4WI.js +26 -0
- package/dist/chunk-QKGYDMWB.js +7409 -0
- package/dist/chunk-QSL6QN5X.js +115 -0
- package/dist/chunk-SHCEBP3J.js +107 -0
- package/dist/chunk-SJOVFF7B.js +201 -0
- package/dist/chunk-ST2X2GYN.js +373 -0
- package/dist/chunk-TNTXWSYA.js +19 -0
- package/dist/chunk-U5AT3TD4.js +2128 -0
- package/dist/chunk-UDVNA7EA.js +483 -0
- package/dist/chunk-VL2E5T2A.js +109 -0
- package/dist/chunk-VLRHFMGJ.js +58 -0
- package/dist/chunk-WHX2ZFCG.js +4048 -0
- package/dist/chunk-WQ23REYT.js +37 -0
- package/dist/chunk-XBIDMHSK.js +15425 -0
- package/dist/chunk-Y5GI7RL3.js +66 -0
- package/dist/client-IRKAMDYZ.js +15 -0
- package/dist/commands-FIL5ET6P.js +911 -0
- package/dist/compat-R3UTFQ5Q.js +201 -0
- package/dist/dashboardIssue-WYYMBFIB.js +192 -0
- package/dist/diff-GZA2774U.js +13 -0
- package/dist/dist-4XXIXHHZ.js +12945 -0
- package/dist/e2b-FVPHDULZ.js +172 -0
- package/dist/extract-NKGKLIVT.js +444 -0
- package/dist/fetch-QYTUJVG2.js +22 -0
- package/dist/firstTouch-QQTJH4QX.js +55 -0
- package/dist/handlers-GEJAVZDK.js +53 -0
- package/dist/http-ETPYMBGD.js +5360 -0
- package/dist/ingestQueue-VKN4KBIF.js +35 -0
- package/dist/install-EK3W2COX.js +20 -0
- package/dist/installSkill-VQJWJVCL.js +52 -0
- package/dist/inventory-5AWSLJYU.js +31 -0
- package/dist/local-XPZMRH5R.js +13 -0
- package/dist/mcp-3JHD5SUZ.js +472 -0
- package/dist/mcpHandlers-QFN4MCFL.js +22 -0
- package/dist/mcpScan-QZHWENIP.js +1871 -0
- package/dist/mcpScanWorkflow-JPYCBGC4.js +81 -0
- package/dist/mcpStack-BYJCZNIV.js +20 -0
- package/dist/packages-THVFMWFP.js +42 -0
- package/dist/plan-V4OEI3J4.js +463 -0
- package/dist/planView-JRXGCG2N.js +79 -0
- package/dist/policy-3P6BGRDN.js +115 -0
- package/dist/references-6N7VEPHT.js +14 -0
- package/dist/release-4U4ABNSJ.js +128 -0
- package/dist/remote-YGCXYI4V.js +32 -0
- package/dist/reportRuns-CKQQYLY4.js +64 -0
- package/dist/sandbox-MEZLAODF.js +39 -0
- package/dist/server-KFUD5X57.js +55 -0
- package/dist/surface-V62GE554.js +141 -0
- package/dist/surface-YL6O67W3.js +36 -0
- package/dist/surfaceHandlers-X2IZKA3E.js +20 -0
- package/dist/typecheck-X7U5ELMR.js +268 -0
- package/dist/types-M5JP2W3D.js +10 -0
- package/dist/uninstall-P7RGBX6G.js +174 -0
- package/dist/upgrade-NQ5IWFZB.js +596 -0
- package/dist/upgradePlan-A4LRKLEG.js +146 -0
- package/dist/userConfig-Z3GQE776.js +20 -0
- package/dist/watch-DGFMWUDL.js +214 -0
- package/package.json +26 -21
- package/templates/agent-rules.md +4 -4
- package/templates/skill-instructions.md +13 -14
- package/dist/bin/lurq.js.map +0 -1
- package/dist/index.d.ts +0 -805
- package/dist/index.js +0 -23570
- package/dist/index.js.map +0 -1
- package/drizzle/0000_confused_fabian_cortez.sql +0 -54
- package/drizzle/0001_aspiring_timeslip.sql +0 -15
- package/drizzle/0002_lyrical_lila_cheney.sql +0 -14
- package/drizzle/0003_violet_giant_girl.sql +0 -14
- package/drizzle/0004_slim_valeria_richards.sql +0 -15
- package/drizzle/0005_petite_luke_cage.sql +0 -12
- package/drizzle/0006_calm_nighthawk.sql +0 -3
- package/drizzle/0007_slimy_naoko.sql +0 -1
- package/drizzle/0008_peaceful_tigra.sql +0 -1
- package/drizzle/0009_smooth_harrier.sql +0 -10
- package/drizzle/0010_curved_amphibian.sql +0 -2
- package/drizzle/0011_compat_provenance_closures.sql +0 -11
- package/drizzle/0012_api_surfaces.sql +0 -9
- package/drizzle/0013_nice_thanos.sql +0 -1
- package/drizzle/0014_luxuriant_malcolm_colcord.sql +0 -10
- package/drizzle/0015_past_fat_cobra.sql +0 -11
- package/drizzle/0016_futuristic_junta.sql +0 -50
- package/drizzle/0017_absent_grandmaster.sql +0 -20
- package/drizzle/0018_rainy_proemial_gods.sql +0 -1
- package/drizzle/0019_dashing_korvac.sql +0 -11
- package/drizzle/0020_normal_vulture.sql +0 -3
- package/drizzle/0021_dazzling_blue_shield.sql +0 -17
- package/drizzle/0022_massive_ghost_rider.sql +0 -24
- package/drizzle/0023_next_shatterstar.sql +0 -1
- package/drizzle/0024_dusty_maelstrom.sql +0 -15
- package/drizzle/0025_gifted_harpoon.sql +0 -5
- package/drizzle/0026_awesome_mordo.sql +0 -1
- package/drizzle/0027_charming_ulik.sql +0 -2
- package/drizzle/0028_romantic_loners.sql +0 -2
- package/drizzle/0029_busy_korvac.sql +0 -16
- package/drizzle/0030_steady_mathemanic.sql +0 -6
- package/drizzle/0031_redundant_maginty.sql +0 -2
- package/drizzle/0032_stack_resolutions.sql +0 -14
- package/drizzle/0033_graceful_tyger_tiger.sql +0 -3
- package/drizzle/0034_uneven_thunderbird.sql +0 -1
- package/drizzle/0035_api_key_scopes.sql +0 -1
- package/drizzle/0036_policy_audit.sql +0 -21
- package/drizzle/0037_subscription_seats.sql +0 -1
- package/drizzle/0038_symbol_offsets.sql +0 -2
- package/drizzle/0039_mcp_runtime_scans.sql +0 -80
- package/drizzle/0040_subscription_overage_and_interval.sql +0 -4
- package/drizzle/0041_account_email.sql +0 -38
- package/drizzle/0042_alert_channels.sql +0 -21
- package/drizzle/meta/0000_snapshot.json +0 -370
- package/drizzle/meta/0001_snapshot.json +0 -482
- package/drizzle/meta/0002_snapshot.json +0 -575
- package/drizzle/meta/0003_snapshot.json +0 -667
- package/drizzle/meta/0004_snapshot.json +0 -769
- package/drizzle/meta/0005_snapshot.json +0 -864
- package/drizzle/meta/0006_snapshot.json +0 -882
- package/drizzle/meta/0007_snapshot.json +0 -876
- package/drizzle/meta/0008_snapshot.json +0 -882
- package/drizzle/meta/0009_snapshot.json +0 -948
- package/drizzle/meta/0010_snapshot.json +0 -969
- package/drizzle/meta/0011_snapshot.json +0 -1049
- package/drizzle/meta/0012_snapshot.json +0 -1115
- package/drizzle/meta/0013_snapshot.json +0 -1121
- package/drizzle/meta/0014_snapshot.json +0 -1190
- package/drizzle/meta/0015_snapshot.json +0 -1280
- package/drizzle/meta/0016_snapshot.json +0 -1683
- package/drizzle/meta/0017_snapshot.json +0 -1834
- package/drizzle/meta/0018_snapshot.json +0 -1834
- package/drizzle/meta/0019_snapshot.json +0 -1909
- package/drizzle/meta/0020_snapshot.json +0 -1921
- package/drizzle/meta/0021_snapshot.json +0 -2045
- package/drizzle/meta/0022_snapshot.json +0 -2246
- package/drizzle/meta/0023_snapshot.json +0 -2252
- package/drizzle/meta/0024_snapshot.json +0 -2375
- package/drizzle/meta/0025_snapshot.json +0 -2407
- package/drizzle/meta/0026_snapshot.json +0 -2413
- package/drizzle/meta/0027_snapshot.json +0 -2425
- package/drizzle/meta/0028_snapshot.json +0 -2438
- package/drizzle/meta/0029_snapshot.json +0 -2546
- package/drizzle/meta/0030_snapshot.json +0 -2586
- package/drizzle/meta/0031_snapshot.json +0 -2598
- package/drizzle/meta/0032_snapshot.json +0 -2699
- package/drizzle/meta/0033_snapshot.json +0 -2712
- package/drizzle/meta/0034_snapshot.json +0 -2719
- package/drizzle/meta/0035_snapshot.json +0 -2726
- package/drizzle/meta/0036_snapshot.json +0 -2876
- package/drizzle/meta/0037_snapshot.json +0 -2883
- package/drizzle/meta/0038_snapshot.json +0 -2895
- package/drizzle/meta/0039_snapshot.json +0 -3501
- package/drizzle/meta/0040_snapshot.json +0 -3527
- package/drizzle/meta/0041_snapshot.json +0 -3824
- package/drizzle/meta/0042_snapshot.json +0 -3960
- package/drizzle/meta/_journal.json +0 -307
- package/src/data/seed.json +0 -253
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
init_esm_shims
|
|
4
|
+
} from "./chunk-I3M2KJXB.js";
|
|
5
|
+
|
|
6
|
+
// src/surface/references.ts
|
|
7
|
+
init_esm_shims();
|
|
8
|
+
import { execFileSync } from "child_process";
|
|
9
|
+
import { readdirSync, readFileSync, statSync } from "fs";
|
|
10
|
+
import { extname, join, relative } from "path";
|
|
11
|
+
import ts from "typescript";
|
|
12
|
+
var SOURCE_EXT = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
13
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", "out", ".next", "coverage"]);
|
|
14
|
+
var SURFACE_CLAIM_KINDS = ["named", "destructured", "namespace"];
|
|
15
|
+
function isRootSpecifier(ref, pkg) {
|
|
16
|
+
return ref.specifier === pkg;
|
|
17
|
+
}
|
|
18
|
+
function packageOfSpecifier(spec) {
|
|
19
|
+
if (!spec || spec.startsWith(".") || spec.startsWith("/")) return null;
|
|
20
|
+
if (spec.startsWith("node:")) return null;
|
|
21
|
+
const parts = spec.split("/");
|
|
22
|
+
return spec.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
23
|
+
}
|
|
24
|
+
function listSourceFiles(dir, limit = 5e3) {
|
|
25
|
+
const tracked = gitSourceFiles(dir, limit);
|
|
26
|
+
if (tracked) return tracked;
|
|
27
|
+
const out = [];
|
|
28
|
+
let truncated = false;
|
|
29
|
+
const walk = (d) => {
|
|
30
|
+
if (truncated) return;
|
|
31
|
+
let entries;
|
|
32
|
+
try {
|
|
33
|
+
entries = readdirSync(d);
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
for (const e of entries) {
|
|
38
|
+
if (truncated) return;
|
|
39
|
+
if (SKIP_DIRS.has(e) || e.startsWith(".")) continue;
|
|
40
|
+
const full = join(d, e);
|
|
41
|
+
let st;
|
|
42
|
+
try {
|
|
43
|
+
st = statSync(full);
|
|
44
|
+
} catch {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (st.isDirectory()) walk(full);
|
|
48
|
+
else if (SOURCE_EXT.has(extname(e)) && !e.endsWith(".d.ts")) {
|
|
49
|
+
if (out.length >= limit) truncated = true;
|
|
50
|
+
else out.push(full);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
walk(dir);
|
|
55
|
+
return { files: out, truncated };
|
|
56
|
+
}
|
|
57
|
+
function gitSourceFiles(dir, limit) {
|
|
58
|
+
let stdout;
|
|
59
|
+
try {
|
|
60
|
+
stdout = execFileSync("git", ["ls-files", "--cached", "--others", "--exclude-standard"], {
|
|
61
|
+
cwd: dir,
|
|
62
|
+
encoding: "utf8",
|
|
63
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
64
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
65
|
+
});
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const out = [];
|
|
70
|
+
for (const rel of stdout.split("\n")) {
|
|
71
|
+
if (!rel) continue;
|
|
72
|
+
if (!SOURCE_EXT.has(extname(rel)) || rel.endsWith(".d.ts")) continue;
|
|
73
|
+
if (rel.split("/").includes("node_modules")) continue;
|
|
74
|
+
if (out.length >= limit) return { files: out, truncated: true };
|
|
75
|
+
out.push(join(dir, rel));
|
|
76
|
+
}
|
|
77
|
+
return { files: out, truncated: false };
|
|
78
|
+
}
|
|
79
|
+
function loadedModule(expr) {
|
|
80
|
+
let e = expr;
|
|
81
|
+
while (ts.isParenthesizedExpression(e)) e = e.expression;
|
|
82
|
+
const awaited = ts.isAwaitExpression(e);
|
|
83
|
+
if (awaited) e = e.expression;
|
|
84
|
+
if (!ts.isCallExpression(e) || e.arguments.length !== 1) return null;
|
|
85
|
+
const arg = e.arguments[0];
|
|
86
|
+
if (!ts.isStringLiteralLike(arg)) return null;
|
|
87
|
+
if (e.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
88
|
+
return awaited ? { spec: arg.text, loader: "import" } : null;
|
|
89
|
+
}
|
|
90
|
+
if (ts.isIdentifier(e.expression) && e.expression.text === "require") {
|
|
91
|
+
return { spec: arg.text, loader: "require" };
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function callSiteOf(sf, node) {
|
|
96
|
+
const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
|
|
97
|
+
const p = node.parent;
|
|
98
|
+
if (p && (ts.isCallExpression(p) || ts.isNewExpression(p)) && p.expression === node) {
|
|
99
|
+
const args = p.arguments ?? [];
|
|
100
|
+
return { line, args: args.some(ts.isSpreadElement) ? null : args.length };
|
|
101
|
+
}
|
|
102
|
+
return { line, args: null };
|
|
103
|
+
}
|
|
104
|
+
function isValueUse(id) {
|
|
105
|
+
const p = id.parent;
|
|
106
|
+
if (!p) return false;
|
|
107
|
+
if (ts.isImportSpecifier(p) || ts.isImportClause(p) || ts.isNamespaceImport(p)) return false;
|
|
108
|
+
if (ts.isImportEqualsDeclaration(p) || ts.isLabeledStatement(p) || ts.isBreakOrContinueStatement(p)) return false;
|
|
109
|
+
if (ts.isPropertyAccessExpression(p) && p.name === id) return false;
|
|
110
|
+
if (ts.isQualifiedName(p) && p.right === id) return false;
|
|
111
|
+
if (ts.isBindingElement(p) && (p.name === id || p.propertyName === id)) return false;
|
|
112
|
+
if (ts.isExportSpecifier(p) && p.name === id && p.propertyName) return false;
|
|
113
|
+
const declares = ts.isVariableDeclaration(p) || ts.isParameter(p) || ts.isFunctionDeclaration(p) || ts.isFunctionExpression(p) || ts.isClassDeclaration(p) || ts.isClassExpression(p) || ts.isPropertyAssignment(p) || ts.isPropertyDeclaration(p) || ts.isPropertySignature(p) || ts.isMethodDeclaration(p) || ts.isGetAccessor(p) || ts.isSetAccessor(p) || ts.isEnumMember(p) || ts.isJsxAttribute(p) || ts.isMethodSignature(p) || ts.isInterfaceDeclaration(p) || ts.isTypeAliasDeclaration(p) || ts.isModuleDeclaration(p) || ts.isEnumDeclaration(p) || ts.isTypeParameterDeclaration(p);
|
|
114
|
+
return !(declares && p.name === id);
|
|
115
|
+
}
|
|
116
|
+
function isTypePosition(node) {
|
|
117
|
+
if (ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && node.parent.token === ts.SyntaxKind.ExtendsKeyword && ts.isClassLike(node.parent.parent)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return ts.isTypeNode(node);
|
|
121
|
+
}
|
|
122
|
+
function bindsName(id) {
|
|
123
|
+
const p = id.parent;
|
|
124
|
+
if (!p) return false;
|
|
125
|
+
if (ts.isImportClause(p) || ts.isNamespaceImport(p) || ts.isImportEqualsDeclaration(p)) return true;
|
|
126
|
+
if (ts.isImportSpecifier(p) || ts.isBindingElement(p) || ts.isVariableDeclaration(p) || ts.isParameter(p) || ts.isFunctionDeclaration(p) || ts.isFunctionExpression(p) || ts.isClassDeclaration(p) || ts.isClassExpression(p)) {
|
|
127
|
+
return p.name === id;
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
function valueUses(sf, locals) {
|
|
132
|
+
const out = /* @__PURE__ */ new Map();
|
|
133
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
134
|
+
const visit = (node, inType) => {
|
|
135
|
+
if (ts.isIdentifier(node) && locals.has(node.text) && bindsName(node)) {
|
|
136
|
+
bindings.set(node.text, (bindings.get(node.text) ?? 0) + 1);
|
|
137
|
+
}
|
|
138
|
+
const nowInType = inType || isTypePosition(node);
|
|
139
|
+
if (!nowInType && ts.isIdentifier(node) && locals.has(node.text) && isValueUse(node)) {
|
|
140
|
+
const list = out.get(node.text);
|
|
141
|
+
if (list) list.push(callSiteOf(sf, node));
|
|
142
|
+
else out.set(node.text, [callSiteOf(sf, node)]);
|
|
143
|
+
}
|
|
144
|
+
ts.forEachChild(node, (c) => visit(c, nowInType));
|
|
145
|
+
};
|
|
146
|
+
visit(sf, false);
|
|
147
|
+
for (const [name, count] of bindings) {
|
|
148
|
+
const uses = out.get(name);
|
|
149
|
+
if (count > 1 && uses) out.set(name, uses.map((u) => ({ line: u.line, args: null })));
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
function collectValueIdentifiers(sf) {
|
|
154
|
+
const out = /* @__PURE__ */ new Set();
|
|
155
|
+
const visit = (node, inType) => {
|
|
156
|
+
const nowInType = inType || isTypePosition(node);
|
|
157
|
+
if (!nowInType && ts.isIdentifier(node) && node.parent && !ts.isImportSpecifier(node.parent) && !ts.isImportClause(node.parent) && !ts.isNamespaceImport(node.parent) && !ts.isPropertyAccessExpression(node.parent)) {
|
|
158
|
+
out.add(node.text);
|
|
159
|
+
}
|
|
160
|
+
if (!nowInType && ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {
|
|
161
|
+
out.add(node.expression.text);
|
|
162
|
+
}
|
|
163
|
+
ts.forEachChild(node, (c) => visit(c, nowInType));
|
|
164
|
+
};
|
|
165
|
+
visit(sf, false);
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
function scanReferences(rootDir, opts = {}) {
|
|
169
|
+
const byPackage = /* @__PURE__ */ new Map();
|
|
170
|
+
const record = (pkg, symbol, via, specifier, file, line, parent, call) => {
|
|
171
|
+
let syms = byPackage.get(pkg);
|
|
172
|
+
if (!syms) byPackage.set(pkg, syms = /* @__PURE__ */ new Map());
|
|
173
|
+
const list = syms.get(symbol);
|
|
174
|
+
const ref = {
|
|
175
|
+
symbol,
|
|
176
|
+
via,
|
|
177
|
+
specifier,
|
|
178
|
+
file,
|
|
179
|
+
line,
|
|
180
|
+
...parent ? { parent } : {},
|
|
181
|
+
...call ? { calls: [call] } : {}
|
|
182
|
+
};
|
|
183
|
+
if (!list) {
|
|
184
|
+
syms.set(symbol, [ref]);
|
|
185
|
+
return ref;
|
|
186
|
+
}
|
|
187
|
+
const same = list.find((r) => r.file === file && r.line === line && r.via === via);
|
|
188
|
+
if (!same) {
|
|
189
|
+
list.push(ref);
|
|
190
|
+
return ref;
|
|
191
|
+
}
|
|
192
|
+
if (call) (same.calls ??= []).push(call);
|
|
193
|
+
return same;
|
|
194
|
+
};
|
|
195
|
+
const listing = listSourceFiles(rootDir, opts.limit);
|
|
196
|
+
if (opts.stats) {
|
|
197
|
+
opts.stats.files = listing.files.length;
|
|
198
|
+
opts.stats.truncated = listing.truncated;
|
|
199
|
+
}
|
|
200
|
+
for (const file of listing.files) {
|
|
201
|
+
let text;
|
|
202
|
+
try {
|
|
203
|
+
text = readFileSync(file, "utf8");
|
|
204
|
+
} catch {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const rel = relative(rootDir, file);
|
|
208
|
+
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true);
|
|
209
|
+
const lineOf = (n) => sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1;
|
|
210
|
+
const nsBindings = /* @__PURE__ */ new Map();
|
|
211
|
+
const defaultBindings = /* @__PURE__ */ new Map();
|
|
212
|
+
const namedBindings = /* @__PURE__ */ new Map();
|
|
213
|
+
const valueUsed = collectValueIdentifiers(sf);
|
|
214
|
+
const followed = /* @__PURE__ */ new Map();
|
|
215
|
+
const follow = (local, ref) => {
|
|
216
|
+
const list = followed.get(local);
|
|
217
|
+
if (list) list.push(ref);
|
|
218
|
+
else followed.set(local, [ref]);
|
|
219
|
+
};
|
|
220
|
+
const visit = (node) => {
|
|
221
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
222
|
+
const pkg = packageOfSpecifier(node.moduleSpecifier.text);
|
|
223
|
+
if (pkg) {
|
|
224
|
+
const clause = node.importClause;
|
|
225
|
+
if (!clause) record(pkg, "default", "side-effect", node.moduleSpecifier.text, rel, lineOf(node));
|
|
226
|
+
if (clause?.name) {
|
|
227
|
+
record(pkg, "default", "default", node.moduleSpecifier.text, rel, lineOf(clause.name));
|
|
228
|
+
defaultBindings.set(clause.name.text, { pkg, spec: node.moduleSpecifier.text });
|
|
229
|
+
}
|
|
230
|
+
if (clause?.namedBindings) {
|
|
231
|
+
if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
232
|
+
nsBindings.set(clause.namedBindings.name.text, { pkg, spec: node.moduleSpecifier.text });
|
|
233
|
+
} else {
|
|
234
|
+
for (const el of clause.namedBindings.elements) {
|
|
235
|
+
const local = el.name.text;
|
|
236
|
+
const exported = el.propertyName?.text ?? local;
|
|
237
|
+
const typeOnly = clause.isTypeOnly || el.isTypeOnly || !valueUsed.has(local);
|
|
238
|
+
const ref = record(
|
|
239
|
+
pkg,
|
|
240
|
+
exported,
|
|
241
|
+
typeOnly ? "type-only" : "named",
|
|
242
|
+
node.moduleSpecifier.text,
|
|
243
|
+
rel,
|
|
244
|
+
lineOf(el)
|
|
245
|
+
);
|
|
246
|
+
if (!typeOnly) {
|
|
247
|
+
follow(local, ref);
|
|
248
|
+
namedBindings.set(local, {
|
|
249
|
+
pkg,
|
|
250
|
+
spec: node.moduleSpecifier.text,
|
|
251
|
+
exported
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier) && node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
260
|
+
const spec = node.moduleSpecifier.text;
|
|
261
|
+
const pkg = packageOfSpecifier(spec);
|
|
262
|
+
if (pkg) {
|
|
263
|
+
for (const el of node.exportClause.elements) {
|
|
264
|
+
const exported = el.propertyName?.text ?? el.name.text;
|
|
265
|
+
const line = lineOf(el);
|
|
266
|
+
if (node.isTypeOnly || el.isTypeOnly) record(pkg, exported, "type-only", spec, rel, line);
|
|
267
|
+
else record(pkg, exported, "named", spec, rel, line, void 0, { line, args: null });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (ts.isImportEqualsDeclaration(node) && !node.isTypeOnly && ts.isExternalModuleReference(node.moduleReference) && ts.isStringLiteral(node.moduleReference.expression)) {
|
|
272
|
+
const spec = node.moduleReference.expression.text;
|
|
273
|
+
const pkg = packageOfSpecifier(spec);
|
|
274
|
+
if (pkg) {
|
|
275
|
+
nsBindings.set(node.name.text, { pkg, spec, loader: "require" });
|
|
276
|
+
const ref = record(pkg, "default", "default", spec, rel, lineOf(node.name));
|
|
277
|
+
ref.loader = "require";
|
|
278
|
+
follow(node.name.text, ref);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (ts.isVariableDeclaration(node) && node.initializer && ts.isIdentifier(node.initializer) && ts.isObjectBindingPattern(node.name)) {
|
|
282
|
+
const ns = nsBindings.get(node.initializer.text);
|
|
283
|
+
if (ns) {
|
|
284
|
+
for (const el of node.name.elements) {
|
|
285
|
+
const name = el.propertyName ?? el.name;
|
|
286
|
+
if (!ts.isIdentifier(name)) continue;
|
|
287
|
+
const ref = record(ns.pkg, name.text, "namespace", ns.spec, rel, lineOf(el));
|
|
288
|
+
if (ns.loader) ref.loader = ns.loader;
|
|
289
|
+
if (ts.isIdentifier(el.name)) follow(el.name.text, ref);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const loaded = ts.isVariableDeclaration(node) && node.initializer ? loadedModule(node.initializer) : null;
|
|
294
|
+
if (ts.isVariableDeclaration(node) && loaded) {
|
|
295
|
+
const spec = loaded.spec;
|
|
296
|
+
const viaRequire = loaded.loader === "require";
|
|
297
|
+
const pkg = packageOfSpecifier(spec);
|
|
298
|
+
if (pkg) {
|
|
299
|
+
if (ts.isIdentifier(node.name)) {
|
|
300
|
+
nsBindings.set(node.name.text, { pkg, spec, ...viaRequire ? { loader: "require" } : {} });
|
|
301
|
+
const ref = record(pkg, "default", "default", spec, rel, lineOf(node.name));
|
|
302
|
+
if (viaRequire) ref.loader = "require";
|
|
303
|
+
follow(node.name.text, ref);
|
|
304
|
+
} else if (ts.isObjectBindingPattern(node.name)) {
|
|
305
|
+
for (const el of node.name.elements) {
|
|
306
|
+
const name = el.propertyName ?? el.name;
|
|
307
|
+
if (!ts.isIdentifier(name)) continue;
|
|
308
|
+
const ref = record(pkg, name.text, "destructured", spec, rel, lineOf(el));
|
|
309
|
+
if (viaRequire) ref.loader = "require";
|
|
310
|
+
if (ts.isIdentifier(el.name)) follow(el.name.text, ref);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (ts.isExpressionStatement(node)) {
|
|
316
|
+
const load = loadedModule(node.expression);
|
|
317
|
+
const pkg = load ? packageOfSpecifier(load.spec) : null;
|
|
318
|
+
if (load && pkg) {
|
|
319
|
+
const ref = record(pkg, "default", "side-effect", load.spec, rel, lineOf(node));
|
|
320
|
+
if (load.loader === "require") ref.loader = "require";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
324
|
+
const load = loadedModule(node.expression);
|
|
325
|
+
const pkg = load ? packageOfSpecifier(load.spec) : null;
|
|
326
|
+
if (load && pkg) {
|
|
327
|
+
const ref = record(pkg, node.name.text, "namespace", load.spec, rel, lineOf(node), void 0, callSiteOf(sf, node));
|
|
328
|
+
if (load.loader === "require") ref.loader = "require";
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {
|
|
332
|
+
const local = node.expression.text;
|
|
333
|
+
const ns = nsBindings.get(local);
|
|
334
|
+
const def = defaultBindings.get(local);
|
|
335
|
+
const named = namedBindings.get(local);
|
|
336
|
+
const call = callSiteOf(sf, node);
|
|
337
|
+
if (ns) {
|
|
338
|
+
const ref = record(ns.pkg, node.name.text, "namespace", ns.spec, rel, lineOf(node), void 0, call);
|
|
339
|
+
if (ns.loader) ref.loader = ns.loader;
|
|
340
|
+
} else if (def) {
|
|
341
|
+
record(def.pkg, node.name.text, "default-member", def.spec, rel, lineOf(node), void 0, call);
|
|
342
|
+
} else if (named) {
|
|
343
|
+
record(
|
|
344
|
+
named.pkg,
|
|
345
|
+
node.name.text,
|
|
346
|
+
"named-member",
|
|
347
|
+
named.spec,
|
|
348
|
+
rel,
|
|
349
|
+
lineOf(node),
|
|
350
|
+
named.exported,
|
|
351
|
+
call
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
ts.forEachChild(node, visit);
|
|
356
|
+
};
|
|
357
|
+
visit(sf);
|
|
358
|
+
if (followed.size) {
|
|
359
|
+
const uses = valueUses(sf, new Set(followed.keys()));
|
|
360
|
+
for (const [local, refs] of followed) {
|
|
361
|
+
for (const ref of refs) ref.calls = [...ref.calls ?? [], ...uses.get(local) ?? []];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return [...byPackage.entries()].map(([pkg, symbols]) => ({ package: pkg, symbols })).sort((a, b) => a.package.localeCompare(b.package));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export {
|
|
369
|
+
SURFACE_CLAIM_KINDS,
|
|
370
|
+
isRootSpecifier,
|
|
371
|
+
packageOfSpecifier,
|
|
372
|
+
scanReferences
|
|
373
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
init_esm_shims
|
|
4
|
+
} from "./chunk-I3M2KJXB.js";
|
|
5
|
+
|
|
6
|
+
// src/core/open.ts
|
|
7
|
+
init_esm_shims();
|
|
8
|
+
import { spawn } from "child_process";
|
|
9
|
+
function openInBrowser(target) {
|
|
10
|
+
const [cmd, args] = process.platform === "darwin" ? ["open", [target]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", target]] : ["xdg-open", [target]];
|
|
11
|
+
try {
|
|
12
|
+
spawn(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
openInBrowser
|
|
19
|
+
};
|