@component-compass/cli 0.1.24 → 0.1.25

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.
Files changed (2) hide show
  1. package/dist/cli.js +908 -529
  2. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -43170,6 +43170,207 @@ var require_ignore = __commonJS({
43170
43170
  }
43171
43171
  });
43172
43172
 
43173
+ // src/upload.ts
43174
+ import { gzipSync } from "node:zlib";
43175
+ function statusUrl(host, receipt) {
43176
+ const base2 = new URL(host);
43177
+ const url = new URL(receipt.statusUrl, base2);
43178
+ if (url.origin !== base2.origin || url.username || url.password) {
43179
+ throw new Error("Upload status URL must have the same origin as the upload host");
43180
+ }
43181
+ return url.href;
43182
+ }
43183
+ async function getUploadStatus(opts) {
43184
+ const url = statusUrl(opts.host, opts.receipt);
43185
+ opts.signal?.throwIfAborted();
43186
+ const response = await fetch(url, {
43187
+ method: "GET",
43188
+ redirect: "error",
43189
+ headers: { Authorization: `Bearer ${opts.token}` },
43190
+ ...opts.signal ? { signal: opts.signal } : {}
43191
+ });
43192
+ const retryAfterSeconds = parseRetryAfter(response.headers.get("Retry-After"));
43193
+ if (!response.ok) {
43194
+ await response.body?.cancel();
43195
+ throw new UploadError(response.status, `Upload status failed (${response.status})`, retryAfterSeconds);
43196
+ }
43197
+ const status = await response.json();
43198
+ if (retryAfterSeconds !== void 0) status.retryAfterSeconds = retryAfterSeconds;
43199
+ return status;
43200
+ }
43201
+ function parseRetryAfter(retryAfter) {
43202
+ if (retryAfter === null) return void 0;
43203
+ const seconds = /^\d+(?:\.\d+)?$/.test(retryAfter.trim()) ? Number(retryAfter) : (Date.parse(retryAfter) - Date.now()) / 1e3;
43204
+ return Number.isFinite(seconds) ? Math.max(0, seconds) : void 0;
43205
+ }
43206
+ function transientReason(err2) {
43207
+ if (err2 instanceof UploadError) return TRANSIENT_STATUSES.has(err2.code) ? err2.message : void 0;
43208
+ const seen2 = /* @__PURE__ */ new Set();
43209
+ for (let current = err2; typeof current === "object" && current !== null && !seen2.has(current); current = current.cause) {
43210
+ seen2.add(current);
43211
+ const { code } = current;
43212
+ if (typeof code === "string" && TRANSIENT_CODES.has(code)) {
43213
+ return err2 instanceof Error ? `${err2.message} (${code})` : code;
43214
+ }
43215
+ }
43216
+ return void 0;
43217
+ }
43218
+ function backoffDelay(attempt) {
43219
+ return Math.min(3e4, 1e3 * 2 ** attempt);
43220
+ }
43221
+ async function pollUpload(opts) {
43222
+ const url = statusUrl(opts.host, opts.receipt);
43223
+ const controller = new AbortController();
43224
+ const signal = controller.signal;
43225
+ const abort = () => controller.abort(opts.signal?.reason);
43226
+ opts.signal?.addEventListener("abort", abort, { once: true });
43227
+ let lastFailure;
43228
+ const timer = setTimeout(() => controller.abort(new UploadPendingError(opts.receipt, url, lastFailure)), opts.timeoutMs);
43229
+ const cancelled = new Promise((_resolve, reject) => {
43230
+ signal.addEventListener("abort", () => reject(signal.reason), { once: true });
43231
+ });
43232
+ async function run() {
43233
+ opts.signal?.throwIfAborted();
43234
+ let token = await opts.getToken();
43235
+ for (let attempt = 0; ; attempt++) {
43236
+ signal.throwIfAborted();
43237
+ const inspect3 = () => getUploadStatus({ host: opts.host, receipt: opts.receipt, token, signal });
43238
+ let status;
43239
+ let hint;
43240
+ try {
43241
+ status = await inspect3().catch(async (err2) => {
43242
+ if (!(err2 instanceof UploadError) || err2.code !== 401) throw err2;
43243
+ signal.throwIfAborted();
43244
+ token = await opts.refreshToken();
43245
+ return await inspect3();
43246
+ });
43247
+ } catch (err2) {
43248
+ const reason = transientReason(err2);
43249
+ if (reason === void 0) throw err2;
43250
+ lastFailure = { reason, error: err2 };
43251
+ hint = err2 instanceof UploadError ? err2.retryAfterSeconds : void 0;
43252
+ }
43253
+ signal.throwIfAborted();
43254
+ if (status) {
43255
+ lastFailure = void 0;
43256
+ opts.onStatus?.(status);
43257
+ if (status.state === "failed") {
43258
+ throw new UploadPollingError(
43259
+ opts.receipt,
43260
+ url,
43261
+ "failed",
43262
+ new Error(`Upload ${opts.receipt.uploadId} failed: ${status.error?.code ?? "processing_failed"}: ${status.error?.message ?? "Processing failed"}`)
43263
+ );
43264
+ }
43265
+ if (status.readable && (status.state === "ready" || status.state === "duplicate")) {
43266
+ return { status: status.state === "ready" ? "inserted" : "exists", scanId: status.scanId, url: status.url };
43267
+ }
43268
+ hint = status.retryAfterSeconds;
43269
+ }
43270
+ const delay = hint !== void 0 ? hint * 1e3 : backoffDelay(attempt);
43271
+ await wait(Math.min(2147483647, Math.max(1e3, delay)), signal);
43272
+ }
43273
+ }
43274
+ try {
43275
+ return await Promise.race([run(), cancelled]);
43276
+ } catch (err2) {
43277
+ if (err2 instanceof UploadPendingError || err2 instanceof UploadPollingError) throw err2;
43278
+ throw new UploadPollingError(opts.receipt, url, "unknown", err2);
43279
+ } finally {
43280
+ clearTimeout(timer);
43281
+ opts.signal?.removeEventListener("abort", abort);
43282
+ controller.abort();
43283
+ }
43284
+ }
43285
+ function wait(delay, signal) {
43286
+ return new Promise((resolve14, reject) => {
43287
+ signal?.throwIfAborted();
43288
+ const abort = () => {
43289
+ clearTimeout(timer);
43290
+ reject(signal?.reason);
43291
+ };
43292
+ const timer = setTimeout(() => {
43293
+ signal?.removeEventListener("abort", abort);
43294
+ resolve14();
43295
+ }, delay);
43296
+ signal?.addEventListener("abort", abort, { once: true });
43297
+ });
43298
+ }
43299
+ async function submitArtifact(opts) {
43300
+ const url = `${opts.host.replace(/\/$/, "")}/api/scans`;
43301
+ const useGzip = opts.artifactJson.length > GZIP_THRESHOLD;
43302
+ const body = useGzip ? gzipSync(Buffer.from(opts.artifactJson, "utf8")) : opts.artifactJson;
43303
+ const headers = {
43304
+ "Content-Type": "application/json",
43305
+ Authorization: `Bearer ${opts.token}`
43306
+ };
43307
+ if (useGzip) headers["Content-Encoding"] = "gzip";
43308
+ for (let attempt = 1; ; attempt++) {
43309
+ try {
43310
+ return await postArtifact(url, headers, body);
43311
+ } catch (err2) {
43312
+ if (attempt >= SUBMIT_ATTEMPTS || transientReason(err2) === void 0) throw err2;
43313
+ const hint = err2 instanceof UploadError ? err2.retryAfterSeconds : void 0;
43314
+ const backoff = backoffDelay(attempt - 1);
43315
+ await wait(hint === void 0 ? backoff : Math.max(backoff, Math.min(hint * 1e3, 3e4)));
43316
+ }
43317
+ }
43318
+ }
43319
+ async function postArtifact(url, headers, body) {
43320
+ const res = await fetch(url, { method: "POST", headers, body, redirect: "error" });
43321
+ if (res.status === 202) {
43322
+ return await res.json();
43323
+ }
43324
+ const text2 = await res.text().catch(() => "");
43325
+ throw new UploadError(res.status, `Upload failed (${res.status}): ${text2 || res.statusText}`, parseRetryAfter(res.headers.get("Retry-After")));
43326
+ }
43327
+ var UploadPendingError, UploadPollingError, TRANSIENT_STATUSES, TRANSIENT_CODES, UploadError, GZIP_THRESHOLD, SUBMIT_ATTEMPTS;
43328
+ var init_upload = __esm({
43329
+ "src/upload.ts"() {
43330
+ "use strict";
43331
+ UploadPendingError = class extends Error {
43332
+ constructor(receipt, statusUrl2, lastFailure) {
43333
+ const failure = lastFailure ? ` The last status check failed: ${lastFailure.reason}.` : "";
43334
+ super(
43335
+ `Upload ${receipt.uploadId} is still pending. Check ${statusUrl2}; the server job continues.${failure}`,
43336
+ lastFailure ? { cause: lastFailure.error } : void 0
43337
+ );
43338
+ this.receipt = receipt;
43339
+ this.statusUrl = statusUrl2;
43340
+ }
43341
+ receipt;
43342
+ statusUrl;
43343
+ };
43344
+ UploadPollingError = class extends Error {
43345
+ constructor(receipt, statusUrl2, outcome, cause) {
43346
+ super(cause instanceof Error ? cause.message : String(cause), { cause });
43347
+ this.receipt = receipt;
43348
+ this.statusUrl = statusUrl2;
43349
+ this.outcome = outcome;
43350
+ }
43351
+ receipt;
43352
+ statusUrl;
43353
+ outcome;
43354
+ get code() {
43355
+ return this.cause instanceof UploadError ? this.cause.code : void 0;
43356
+ }
43357
+ };
43358
+ TRANSIENT_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
43359
+ TRANSIENT_CODES = /* @__PURE__ */ new Set(["ECONNRESET", "ECONNREFUSED", "EPIPE", "EAI_AGAIN", "UND_ERR_SOCKET"]);
43360
+ UploadError = class extends Error {
43361
+ constructor(code, message, retryAfterSeconds) {
43362
+ super(message);
43363
+ this.code = code;
43364
+ this.retryAfterSeconds = retryAfterSeconds;
43365
+ }
43366
+ code;
43367
+ retryAfterSeconds;
43368
+ };
43369
+ GZIP_THRESHOLD = 1024 * 1024;
43370
+ SUBMIT_ATTEMPTS = 3;
43371
+ }
43372
+ });
43373
+
43173
43374
  // src/auth/paths.ts
43174
43375
  import { homedir } from "node:os";
43175
43376
  import { join as join15 } from "node:path";
@@ -43407,44 +43608,6 @@ var init_session = __esm({
43407
43608
  }
43408
43609
  });
43409
43610
 
43410
- // src/upload.ts
43411
- import { gzipSync } from "node:zlib";
43412
- async function uploadArtifact(opts) {
43413
- const url = `${opts.host.replace(/\/$/, "")}/api/scans`;
43414
- const useGzip = opts.artifactJson.length > GZIP_THRESHOLD;
43415
- const body = useGzip ? gzipSync(Buffer.from(opts.artifactJson, "utf8")) : opts.artifactJson;
43416
- const headers = {
43417
- "Content-Type": "application/json",
43418
- Authorization: `Bearer ${opts.token}`
43419
- };
43420
- if (useGzip) headers["Content-Encoding"] = "gzip";
43421
- const res = await fetch(url, { method: "POST", headers, body });
43422
- if (res.status === 201 || res.status === 200) {
43423
- const json = await res.json();
43424
- return {
43425
- status: res.status === 201 ? "inserted" : "exists",
43426
- scanId: json.scanId,
43427
- url: json.url
43428
- };
43429
- }
43430
- const text2 = await res.text().catch(() => "");
43431
- throw new UploadError(res.status, `Upload failed (${res.status}): ${text2 || res.statusText}`);
43432
- }
43433
- var UploadError, GZIP_THRESHOLD;
43434
- var init_upload = __esm({
43435
- "src/upload.ts"() {
43436
- "use strict";
43437
- UploadError = class extends Error {
43438
- constructor(code, message) {
43439
- super(message);
43440
- this.code = code;
43441
- }
43442
- code;
43443
- };
43444
- GZIP_THRESHOLD = 1024 * 1024;
43445
- }
43446
- });
43447
-
43448
43611
  // src/auth/upload-auth.ts
43449
43612
  var upload_auth_exports = {};
43450
43613
  __export(upload_auth_exports, {
@@ -43458,28 +43621,33 @@ async function createAuthedUploader(opts) {
43458
43621
  ...opts.configHost !== void 0 ? { configHost: opts.configHost } : {},
43459
43622
  store
43460
43623
  });
43461
- const ciToken = process.env["COMPONENT_COMPASS_TOKEN"];
43462
- if (ciToken) {
43463
- return {
43464
- base: base2,
43465
- async upload(artifactJson) {
43466
- return await uploadArtifact({ host: base2, token: ciToken, artifactJson });
43467
- }
43468
- };
43624
+ const { COMPONENT_COMPASS_TOKEN: ciToken } = process.env;
43625
+ const session = filePath !== void 0 ? { filePath } : {};
43626
+ let token = ciToken || (await getAccessToken(base2, session)).accessToken;
43627
+ async function refreshToken() {
43628
+ if (ciToken) {
43629
+ throw new UploadError(401, "COMPONENT_COMPASS_TOKEN was rejected (401); interactive login and token refresh are disabled. Supply a valid token.");
43630
+ }
43631
+ token = (await getAccessToken(base2, { ...session, force: true })).accessToken;
43632
+ return token;
43469
43633
  }
43470
- let token = (await getAccessToken(base2, filePath !== void 0 ? { filePath } : {})).accessToken;
43471
43634
  return {
43472
43635
  base: base2,
43473
43636
  async upload(artifactJson) {
43474
- try {
43475
- return await uploadArtifact({ host: base2, token, artifactJson });
43476
- } catch (err2) {
43477
- if (err2 instanceof UploadError && err2.code === 401) {
43478
- token = (await getAccessToken(base2, { force: true, ...filePath !== void 0 ? { filePath } : {} })).accessToken;
43479
- return await uploadArtifact({ host: base2, token, artifactJson });
43480
- }
43481
- throw err2;
43482
- }
43637
+ const submit = () => submitArtifact({ host: base2, token, artifactJson });
43638
+ const receipt = await submit().catch(async (err2) => {
43639
+ if (!(err2 instanceof UploadError) || err2.code !== 401) throw err2;
43640
+ await refreshToken();
43641
+ return await submit();
43642
+ });
43643
+ return await pollUpload({
43644
+ host: base2,
43645
+ receipt,
43646
+ getToken: async () => token,
43647
+ refreshToken,
43648
+ timeoutMs: 3e5,
43649
+ ...opts.onStatus ? { onStatus: opts.onStatus } : {}
43650
+ });
43483
43651
  }
43484
43652
  };
43485
43653
  }
@@ -94573,6 +94741,236 @@ function walk2(graph, file, imported, seen2) {
94573
94741
  return null;
94574
94742
  }
94575
94743
 
94744
+ // ../reference-graph/dist/engine/helper-callers.js
94745
+ function findLocalDeclaration(fileGraph, ref) {
94746
+ let scope = ref.scope;
94747
+ while (true) {
94748
+ const decl = fileGraph.declarations.get(`${scope}::${ref.symbol}`);
94749
+ if (decl)
94750
+ return decl;
94751
+ if (scope === MODULE_SCOPE)
94752
+ return null;
94753
+ const parent = fileGraph.scopes.get(scope)?.parent;
94754
+ if (parent === null || parent === void 0)
94755
+ return null;
94756
+ scope = parent;
94757
+ }
94758
+ }
94759
+ function classifyDeclaration(decl, registry, fileGraph) {
94760
+ if (decl.value.kind !== "Function" && decl.value.kind !== "ReturnTypeOf")
94761
+ return "unknown";
94762
+ if (fileGraph.dialect === "vue" && isSfcDeclaration(fileGraph, decl))
94763
+ return "component";
94764
+ return registry.hasLocal(fileGraph.filePath, decl.symbol) ? "component" : "helper";
94765
+ }
94766
+ var isSfcDeclaration = (fileGraph, decl) => fileGraph.exports.some((e) => e.kind === "default" && "local" in e && e.local === decl.symbol);
94767
+ function buildHelperCallers(graph, registry) {
94768
+ const index = /* @__PURE__ */ new Map();
94769
+ const callerKeysByHelper = /* @__PURE__ */ new Map();
94770
+ const classificationCache = /* @__PURE__ */ new Map();
94771
+ const refResolutionCache = /* @__PURE__ */ new Map();
94772
+ function resolveRefCached(ref, callerFile, callerGraph) {
94773
+ const key = `${callerFile}::${ref.symbol}`;
94774
+ if (refResolutionCache.has(key)) {
94775
+ return refResolutionCache.get(key) ?? null;
94776
+ }
94777
+ const result2 = resolveRefToDecl(ref, callerFile, callerGraph, graph);
94778
+ refResolutionCache.set(key, result2);
94779
+ return result2;
94780
+ }
94781
+ const pendingValueRefs = [];
94782
+ for (const [file, fileGraph] of graph.files) {
94783
+ for (const decl of fileGraph.declarations.values()) {
94784
+ if (decl.scope !== MODULE_SCOPE)
94785
+ continue;
94786
+ const refs = [];
94787
+ if (decl.value.kind === "Function") {
94788
+ for (const r2 of decl.value.returns)
94789
+ collectRefsInType(r2, refs);
94790
+ } else if (decl.value.kind === "ReturnTypeOf") {
94791
+ collectCalleeRefs(decl.value, refs);
94792
+ }
94793
+ for (const bc of fileGraph.bodyCalls) {
94794
+ if (bc.ownerSymbol === decl.symbol)
94795
+ refs.push(bc.callee);
94796
+ }
94797
+ const callerKey = { file, symbol: decl.symbol };
94798
+ for (const ref of refs) {
94799
+ const target = resolveRefCached(ref, file, fileGraph);
94800
+ if (!target)
94801
+ continue;
94802
+ pendingValueRefs.push({ target, caller: callerKey });
94803
+ }
94804
+ }
94805
+ }
94806
+ const pendingJsxCalls = [];
94807
+ for (const [file, fileGraph] of graph.files) {
94808
+ for (let i2 = 0; i2 < fileGraph.jsxUsages.length; i2++) {
94809
+ const usage = fileGraph.jsxUsages[i2];
94810
+ if (!usage)
94811
+ continue;
94812
+ const target = resolveRefCached(usage.ref, file, fileGraph);
94813
+ if (!target)
94814
+ continue;
94815
+ const ownership = fileGraph.ownership[i2];
94816
+ if (!ownership?.ownerSymbolRef)
94817
+ continue;
94818
+ const callerTarget = resolveRefCached(ownership.ownerSymbolRef, file, fileGraph);
94819
+ if (!callerTarget)
94820
+ continue;
94821
+ if (callerTarget.decl.scope !== MODULE_SCOPE)
94822
+ continue;
94823
+ pendingJsxCalls.push({
94824
+ target,
94825
+ caller: { file: callerTarget.file, symbol: callerTarget.decl.symbol }
94826
+ });
94827
+ }
94828
+ }
94829
+ function classifyKey(file, decl) {
94830
+ const key = `${file}::${decl.symbol}`;
94831
+ const hit = classificationCache.get(key);
94832
+ if (hit !== void 0)
94833
+ return hit;
94834
+ const fileGraph = graph.files.get(file);
94835
+ const result2 = fileGraph ? classifyDeclaration(decl, registry, fileGraph) : "unknown";
94836
+ classificationCache.set(key, result2);
94837
+ return result2;
94838
+ }
94839
+ for (const [file, fileGraph] of graph.files) {
94840
+ for (const decl of fileGraph.declarations.values()) {
94841
+ if (decl.scope !== MODULE_SCOPE)
94842
+ continue;
94843
+ if (decl.value.kind !== "Function" && decl.value.kind !== "ReturnTypeOf")
94844
+ continue;
94845
+ classifyKey(file, decl);
94846
+ }
94847
+ }
94848
+ function recordCallerEdge(target, callerKey) {
94849
+ const keyStr = `${target.file}::${target.decl.symbol}`;
94850
+ const callerKeyStr = `${callerKey.file}::${callerKey.symbol}`;
94851
+ let seen2 = callerKeysByHelper.get(keyStr);
94852
+ if (!seen2) {
94853
+ seen2 = /* @__PURE__ */ new Set();
94854
+ callerKeysByHelper.set(keyStr, seen2);
94855
+ }
94856
+ if (seen2.has(callerKeyStr))
94857
+ return;
94858
+ seen2.add(callerKeyStr);
94859
+ let callers = index.get(keyStr);
94860
+ if (!callers) {
94861
+ callers = /* @__PURE__ */ new Set();
94862
+ index.set(keyStr, callers);
94863
+ }
94864
+ callers.add(callerKey);
94865
+ }
94866
+ for (const { target, caller } of pendingValueRefs) {
94867
+ if (classifyKey(target.file, target.decl) !== "helper")
94868
+ continue;
94869
+ recordCallerEdge(target, caller);
94870
+ }
94871
+ for (const { target, caller } of pendingJsxCalls) {
94872
+ if (classifyKey(target.file, target.decl) !== "helper")
94873
+ continue;
94874
+ recordCallerEdge(target, caller);
94875
+ }
94876
+ return {
94877
+ get(key) {
94878
+ return index.get(`${key.file}::${key.symbol}`);
94879
+ },
94880
+ classification(file, symbol2) {
94881
+ return classificationCache.get(`${file}::${symbol2}`) ?? "unknown";
94882
+ }
94883
+ };
94884
+ }
94885
+ function collectCalleeRefs(t3, out2) {
94886
+ switch (t3.kind) {
94887
+ case "ReturnTypeOf":
94888
+ collectCalleeRefs(t3.callee, out2);
94889
+ return;
94890
+ case "MemberOf":
94891
+ collectCalleeRefs(t3.obj, out2);
94892
+ return;
94893
+ case "TypeOf":
94894
+ out2.push(t3.ref);
94895
+ return;
94896
+ default:
94897
+ return;
94898
+ }
94899
+ }
94900
+ function collectRefsInType(t3, out2) {
94901
+ switch (t3.kind) {
94902
+ case "TypeOf":
94903
+ out2.push(t3.ref);
94904
+ return;
94905
+ case "Union":
94906
+ for (const u3 of t3.types)
94907
+ collectRefsInType(u3, out2);
94908
+ return;
94909
+ case "ReturnTypeOf":
94910
+ collectRefsInType(t3.callee, out2);
94911
+ for (const a3 of t3.args)
94912
+ collectRefsInType(a3, out2);
94913
+ return;
94914
+ case "Function":
94915
+ for (const r2 of t3.returns)
94916
+ collectRefsInType(r2, out2);
94917
+ return;
94918
+ case "Object":
94919
+ for (const v of Object.values(t3.props))
94920
+ collectRefsInType(v, out2);
94921
+ return;
94922
+ case "Array":
94923
+ for (const e of t3.elements)
94924
+ collectRefsInType(e, out2);
94925
+ return;
94926
+ case "MemberOf":
94927
+ collectRefsInType(t3.obj, out2);
94928
+ return;
94929
+ case "ParameterOf":
94930
+ return;
94931
+ default:
94932
+ return;
94933
+ }
94934
+ }
94935
+ function resolveRefToDecl(ref, callerFile, callerGraph, graph) {
94936
+ const localKey = `${MODULE_SCOPE}::${ref.symbol}`;
94937
+ const localDecl = callerGraph.declarations.get(localKey);
94938
+ if (localDecl)
94939
+ return { file: callerFile, decl: localDecl };
94940
+ const imp = callerGraph.importsByLocal.get(ref.symbol);
94941
+ if (!imp)
94942
+ return null;
94943
+ const resolvedAbs = graph.moduleResolver(callerFile, imp.specifier);
94944
+ if (!resolvedAbs)
94945
+ return null;
94946
+ const targetFile = graph.resolveToGraphKey ? graph.resolveToGraphKey(resolvedAbs) ?? resolvedAbs : resolvedAbs;
94947
+ const targetGraph = graph.files.get(targetFile);
94948
+ if (!targetGraph)
94949
+ return null;
94950
+ const chained = followReExportChain(graph, targetFile, imp.imported);
94951
+ if (chained) {
94952
+ const chainedGraph = graph.files.get(chained.file);
94953
+ if (chainedGraph) {
94954
+ const decl = chainedGraph.declarations.get(`${MODULE_SCOPE}::${chained.localExport}`);
94955
+ if (decl)
94956
+ return { file: chained.file, decl };
94957
+ }
94958
+ }
94959
+ for (const exp of targetGraph.exports) {
94960
+ if (exp.kind === "named" && "local" in exp && exp.exportedAs === imp.imported) {
94961
+ const decl = targetGraph.declarations.get(`${MODULE_SCOPE}::${exp.local}`);
94962
+ if (decl)
94963
+ return { file: targetFile, decl };
94964
+ }
94965
+ if (exp.kind === "default" && "local" in exp && imp.imported === "default") {
94966
+ const decl = targetGraph.declarations.get(`${MODULE_SCOPE}::${exp.local}`);
94967
+ if (decl)
94968
+ return { file: targetFile, decl };
94969
+ }
94970
+ }
94971
+ return null;
94972
+ }
94973
+
94576
94974
  // ../reference-graph/dist/engine/member-identity.js
94577
94975
  function effectiveExportName(imported, memberChain) {
94578
94976
  const first = memberChain[0];
@@ -94584,6 +94982,15 @@ function residualMemberChain(imported, memberChain) {
94584
94982
  function compoundExportName(root2, residual) {
94585
94983
  return residual.length === 0 ? root2 : `${root2}.${residual.join(".")}`;
94586
94984
  }
94985
+ function memberOfObjectPath(holder, path5) {
94986
+ let cur = holder;
94987
+ for (const segment of path5) {
94988
+ if (cur?.kind !== "Object")
94989
+ return void 0;
94990
+ cur = cur.props[segment];
94991
+ }
94992
+ return cur;
94993
+ }
94587
94994
  function unparsedMemberDefinition(graph, resolvedAbs, imported) {
94588
94995
  if (graph.workspaceMembership?.(resolvedAbs) !== true)
94589
94996
  return null;
@@ -94663,7 +95070,9 @@ function evalInner(t3, ctx) {
94663
95070
  }
94664
95071
  }
94665
95072
  function evalCall(t3, ctx) {
94666
- if (t3.args.some(containsDynamicImport))
95073
+ if (nonComponentProduct(ctx.graph, ctx.fileGraph, t3.callee, ctx.guard) !== null)
95074
+ return "other";
95075
+ if (t3.args.some((a3) => containsDynamicImport(a3)))
94667
95076
  return "component";
94668
95077
  const fns = resolveToFunctions(ctx.graph, ctx.fileGraph, t3.callee, ctx.argMap, ctx.guard);
94669
95078
  const resolvable = [];
@@ -94672,7 +95081,8 @@ function evalCall(t3, ctx) {
94672
95081
  resolvable.push(f);
94673
95082
  }
94674
95083
  if (resolvable.length === 0) {
94675
- const carries = t3.args.some((a3) => evalInner(a3, ctx) === "component" || isImportBackedLeaf(a3, ctx.graph, ctx.fileGraph, ctx.guard));
95084
+ const isProductCall = (a3) => a3.kind === "ReturnTypeOf" && nonComponentProduct(ctx.graph, ctx.fileGraph, a3.callee, ctx.guard) !== null;
95085
+ const carries = t3.args.some((a3) => evalInner(a3, ctx) === "component" || isImportBackedLeaf(a3, ctx.graph, ctx.fileGraph, ctx.guard) && !isProductCall(a3));
94676
95086
  if (!carries)
94677
95087
  return "unresolved";
94678
95088
  if (t3.callee.kind === "MemberOf" && !isImportBackedLeaf(t3.callee, ctx.graph, ctx.fileGraph, ctx.guard))
@@ -94709,43 +95119,75 @@ function isImportBackedLeaf(t3, graph, fileGraph, guard) {
94709
95119
  return false;
94710
95120
  return resolveReference(graph, fileGraph, cur.ref, guard).kind === "Unknown";
94711
95121
  }
95122
+ function nonComponentProduct(graph, fileGraph, callee, guard) {
95123
+ const ref = callee.kind === "TypeOf" ? callee.ref : callee.kind === "MemberOf" && callee.obj.kind === "TypeOf" ? { ...callee.obj.ref, memberChain: [callee.member] } : null;
95124
+ if (ref === null)
95125
+ return null;
95126
+ const imp = fileGraphForRef(graph, ref, fileGraph).importsByLocal.get(ref.symbol);
95127
+ const entry = imp === void 0 ? null : libraryExportFor(imp, ref);
95128
+ if (entry === null || entry.kind !== "non-component-product")
95129
+ return null;
95130
+ return isImportBackedLeaf(callee, graph, fileGraph, guard) ? entry.semantics : null;
95131
+ }
94712
95132
  function firstDynamicImport(t3) {
95133
+ return searchDynamicImport(t3, null);
95134
+ }
95135
+ function searchDynamicImport(t3, peek) {
94713
95136
  switch (t3.kind) {
94714
95137
  case "DynamicImport":
94715
95138
  return t3;
94716
95139
  case "Function":
94717
95140
  for (const r2 of t3.returns) {
94718
- const hit = firstDynamicImport(r2);
95141
+ const hit = searchDynamicImport(r2, peek);
94719
95142
  if (hit)
94720
95143
  return hit;
94721
95144
  }
94722
95145
  return null;
94723
95146
  case "ReturnTypeOf": {
94724
- const inCallee = firstDynamicImport(t3.callee);
95147
+ const inCallee = searchDynamicImport(t3.callee, peek);
94725
95148
  if (inCallee)
94726
95149
  return inCallee;
94727
95150
  for (const a3 of t3.args) {
94728
- const hit = firstDynamicImport(a3);
95151
+ const hit = searchDynamicImport(a3, peek);
94729
95152
  if (hit)
94730
95153
  return hit;
94731
95154
  }
94732
95155
  return null;
94733
95156
  }
94734
95157
  case "MemberOf":
94735
- return firstDynamicImport(t3.obj);
95158
+ return searchDynamicImport(t3.obj, peek);
94736
95159
  case "Union":
94737
95160
  for (const u3 of t3.types) {
94738
- const hit = firstDynamicImport(u3);
95161
+ const hit = searchDynamicImport(u3, peek);
95162
+ if (hit)
95163
+ return hit;
95164
+ }
95165
+ return null;
95166
+ case "Object":
95167
+ for (const v of Object.values(t3.props)) {
95168
+ const hit = searchDynamicImport(v, peek);
94739
95169
  if (hit)
94740
95170
  return hit;
94741
95171
  }
94742
95172
  return null;
95173
+ case "Array":
95174
+ for (const e of t3.elements) {
95175
+ const hit = searchDynamicImport(e, peek);
95176
+ if (hit)
95177
+ return hit;
95178
+ }
95179
+ return null;
95180
+ case "TypeOf": {
95181
+ const bound = peek?.(t3) ?? null;
95182
+ return bound === null ? null : searchDynamicImport(bound, null);
95183
+ }
94743
95184
  default:
94744
95185
  return null;
94745
95186
  }
94746
95187
  }
94747
- function containsDynamicImport(t3) {
94748
- return firstDynamicImport(t3) !== null;
95188
+ function containsDynamicImport(t3, at) {
95189
+ const peek = at === void 0 ? null : (ref) => findLocalDeclaration(fileGraphForRef(at.graph, ref.ref, at.fileGraph), ref.ref)?.value ?? null;
95190
+ return searchDynamicImport(t3, peek) !== null;
94749
95191
  }
94750
95192
 
94751
95193
  // ../reference-graph/dist/engine/host-element.js
@@ -94783,12 +95225,26 @@ var RENDER_VERDICT = {
94783
95225
  opaque: () => "silent",
94784
95226
  "late-bound": () => "late-bound",
94785
95227
  data: () => "unresolved",
94786
- indeterminate: () => "unresolved"
95228
+ indeterminate: () => "unresolved",
95229
+ callable: () => "credit"
94787
95230
  };
94788
95231
  var VERDICT_ORDER = ["credit", "silent", "late-bound", "unresolved"];
94789
95232
  function creditedTerminals(e) {
94790
95233
  return e.filter((t3) => matchDenotation(t3, RENDER_VERDICT) === "credit");
94791
95234
  }
95235
+ var IS_CALLABLE = {
95236
+ element: () => false,
95237
+ foreign: () => false,
95238
+ "host-string": () => false,
95239
+ opaque: () => false,
95240
+ "late-bound": () => false,
95241
+ data: () => false,
95242
+ indeterminate: () => false,
95243
+ callable: () => true
95244
+ };
95245
+ function isCallable(t3) {
95246
+ return matchDenotation(t3, IS_CALLABLE);
95247
+ }
94792
95248
  function renderOutcome(e) {
94793
95249
  const verdicts = e.map((t3) => matchDenotation(t3, RENDER_VERDICT));
94794
95250
  const winner = VERDICT_ORDER.find((v) => verdicts.includes(v)) ?? "unresolved";
@@ -94809,6 +95265,40 @@ function renderOutcome(e) {
94809
95265
  function isDataMethodRenderCall(type, graph, fileGraph, guard) {
94810
95266
  return type.callee.kind === "MemberOf" && !isImportBackedLeaf(type.callee, graph, fileGraph, guard);
94811
95267
  }
95268
+ function isLoader(value, graph, fileGraph, guard) {
95269
+ if (value.kind === "Function")
95270
+ return containsDynamicImport(value, { graph, fileGraph });
95271
+ if (value.kind !== "TypeOf" && value.kind !== "MemberOf")
95272
+ return false;
95273
+ if (guard.pushNode(value) === "cycle")
95274
+ return false;
95275
+ try {
95276
+ if (value.kind === "TypeOf")
95277
+ return isLoader(resolveReference(graph, fileGraph, value.ref, guard), graph, fileGraph, guard);
95278
+ const holder = objectLiteralOf(value.obj, graph, fileGraph, guard);
95279
+ if (holder === null)
95280
+ return false;
95281
+ if (value.member !== DYNAMIC_MEMBER_KEY) {
95282
+ const held = holder.props[value.member];
95283
+ return held !== void 0 && isLoader(held, graph, fileGraph, guard);
95284
+ }
95285
+ const all = Object.values(holder.props);
95286
+ return all.length > 0 && all.every((v) => isLoader(v, graph, fileGraph, guard));
95287
+ } finally {
95288
+ guard.popNode(value);
95289
+ }
95290
+ }
95291
+ function objectLiteralOf(value, graph, fileGraph, guard) {
95292
+ if (value.kind === "Object")
95293
+ return value;
95294
+ if (value.kind !== "TypeOf" || guard.pushNode(value) === "cycle")
95295
+ return null;
95296
+ try {
95297
+ return objectLiteralOf(resolveReference(graph, fileGraph, value.ref, guard), graph, fileGraph, guard);
95298
+ } finally {
95299
+ guard.popNode(value);
95300
+ }
95301
+ }
94812
95302
  var INDETERMINATE = { kind: "indeterminate" };
94813
95303
  function withSemantics(t3, semantics) {
94814
95304
  return { denotation: t3.denotation, viaTrail: t3.viaTrail, identity: t3.identity, semantics };
@@ -94826,7 +95316,8 @@ var CAME_TO_NOTHING = {
94826
95316
  opaque: () => true,
94827
95317
  "late-bound": () => true,
94828
95318
  data: () => false,
94829
- indeterminate: () => true
95319
+ indeterminate: () => true,
95320
+ callable: () => false
94830
95321
  };
94831
95322
  function cameToNothing(t3) {
94832
95323
  return matchDenotation(t3, CAME_TO_NOTHING);
@@ -94838,7 +95329,8 @@ var IS_LATE_BOUND = {
94838
95329
  opaque: () => false,
94839
95330
  "late-bound": () => true,
94840
95331
  data: () => false,
94841
- indeterminate: () => false
95332
+ indeterminate: () => false,
95333
+ callable: () => false
94842
95334
  };
94843
95335
  function relabel(denotation) {
94844
95336
  return (t3) => cameToNothing(t3) ? { denotation, viaTrail: t3.viaTrail, identity: t3.identity } : t3;
@@ -94856,7 +95348,8 @@ var AS_RETURNED_VALUE = {
94856
95348
  opaque: () => INDETERMINATE,
94857
95349
  "late-bound": () => INDETERMINATE,
94858
95350
  data: (d2) => d2,
94859
- indeterminate: (d2) => d2
95351
+ indeterminate: (d2) => d2,
95352
+ callable: (d2) => d2
94860
95353
  };
94861
95354
  function returnedValue(t3) {
94862
95355
  const denotation = matchDenotation(t3, AS_RETURNED_VALUE);
@@ -94959,25 +95452,27 @@ function isPassThroughWrapper(algResult, inner) {
94959
95452
  const algKeys = algResult.filter((t3) => !cameToNothing(t3));
94960
95453
  return algKeys.length > 0 && algKeys.every((t3) => t3.identity !== null && innerKeys.has(identityKey(t3.identity)));
94961
95454
  }
94962
- function walkWithFolding(graph, fileGraph, type, argMap, guard = createCycleGuard(), identityFallback) {
94963
- return atLeastOne(walkInner(graph, fileGraph, type, argMap, guard, identityFallback).map(published));
95455
+ function walkWithFolding(graph, fileGraph, type, argMap, guard = createCycleGuard(), identityFallback, position = "value") {
95456
+ return atLeastOne(walkInner(graph, fileGraph, type, argMap, guard, identityFallback, position).map(published));
94964
95457
  }
94965
- function walkInner(graph, fileGraph, type, argMap, guard, identityFallback) {
95458
+ function walkInner(graph, fileGraph, type, argMap, guard, identityFallback, position) {
94966
95459
  const fallback = identityFallback ?? type;
94967
95460
  switch (type.kind) {
94968
95461
  case "ReturnTypeOf":
94969
- return walkReturnTypeOf(graph, fileGraph, type, argMap, guard);
95462
+ return walkReturnTypeOf(graph, fileGraph, type, argMap, guard, position);
94970
95463
  case "MemberOf":
94971
95464
  if (type.member === DYNAMIC_MEMBER_KEY) {
94972
- return walkDynamicMember(graph, fileGraph, type, argMap, guard);
95465
+ return walkDynamicMember(graph, fileGraph, type, argMap, guard, position);
94973
95466
  }
94974
- return walkStaticMember(graph, fileGraph, type, argMap, guard, fallback);
95467
+ return walkStaticMember(graph, fileGraph, type, argMap, guard, fallback, position);
94975
95468
  case "Function":
94976
- return type.returns.flatMap((r2) => walkInner(graph, fileGraph, r2, argMap, guard, type)).map(returnedValue);
95469
+ if (position === "tag")
95470
+ return [{ denotation: { kind: "callable" }, identity: null, viaTrail: [] }];
95471
+ return type.returns.flatMap((r2) => walkInner(graph, fileGraph, r2, argMap, guard, type, "value")).map(returnedValue);
94977
95472
  case "TypeOf":
94978
- return walkTypeOf(graph, fileGraph, type, argMap, guard, fallback);
95473
+ return walkTypeOf(graph, fileGraph, type, argMap, guard, fallback, position);
94979
95474
  case "Union":
94980
- return type.types.flatMap((branch) => walkInner(graph, fileGraph, branch, argMap, guard, fallback));
95475
+ return type.types.flatMap((branch) => walkInner(graph, fileGraph, branch, argMap, guard, fallback, position));
94981
95476
  case "ParameterOf":
94982
95477
  return walkParameter(graph, fileGraph, type, argMap, guard, fallback);
94983
95478
  case "DynamicImport":
@@ -95019,7 +95514,7 @@ function dynamicImportIdentity(graph, fileGraph, di) {
95019
95514
  resolvedFile
95020
95515
  };
95021
95516
  }
95022
- function walkTypeOf(graph, fileGraph, type, argMap, guard, fallback) {
95517
+ function walkTypeOf(graph, fileGraph, type, argMap, guard, fallback, position) {
95023
95518
  if (guard.pushNode(type) === "cycle") {
95024
95519
  return [indeterminateTerminal()];
95025
95520
  }
@@ -95030,17 +95525,27 @@ function walkTypeOf(graph, fileGraph, type, argMap, guard, fallback) {
95030
95525
  return foldLeaf(graph, fileGraph, type, argMap, guard, fallback);
95031
95526
  }
95032
95527
  const innerGraph = resolved.kind === "Function" ? fileGraphForFunction(graph, fileGraph, resolved) : fileGraph;
95033
- const inner = walkInner(graph, innerGraph, resolved, argMap, guard, fallback);
95528
+ const inner = walkInner(graph, innerGraph, resolved, argMap, guard, fallback, position);
95034
95529
  if (inner.every((t3) => t3.identity !== null))
95035
95530
  return inner;
95036
- const self2 = resolved.kind !== "ParameterOf" && evalKind(resolved, graph, innerGraph, argMap) === "component" ? deriveIdentity(type, fileGraph, graph) : null;
95531
+ const derived = position === "tag" && inner.some((t3) => t3.identity === null && isCallable(t3)) || resolved.kind !== "ParameterOf" && evalKind(resolved, graph, innerGraph, argMap) === "component" ? deriveIdentity(type, fileGraph, graph) : null;
95532
+ const self2 = position === "tag" ? withOwnDeclaration(derived, graph, fileGraph, type.ref) : derived;
95037
95533
  const stamp = self2 ?? deriveIdentity(fallback, fileGraph, graph);
95038
95534
  return inner.map((t3) => t3.identity === null ? { denotation: t3.denotation, viaTrail: t3.viaTrail, identity: stamp, semantics: t3.semantics } : t3);
95039
95535
  } finally {
95040
95536
  guard.popNode(type);
95041
95537
  }
95042
95538
  }
95043
- function walkStaticMember(graph, fileGraph, type, argMap, guard, fallback) {
95539
+ function withOwnDeclaration(identity, graph, fileGraph, ref) {
95540
+ if (identity === null || identity.kind !== "local" || ref.memberChain.length > 0)
95541
+ return identity;
95542
+ const lookup2 = fileGraphForRef(graph, ref, fileGraph);
95543
+ if (identity.filePath !== lookup2.filePath || lookup2.importsByLocal.has(ref.symbol))
95544
+ return identity;
95545
+ const declaration2 = findLocalDeclaration(lookup2, ref);
95546
+ return declaration2 === null ? identity : { ...identity, declaration: declaration2 };
95547
+ }
95548
+ function walkStaticMember(graph, fileGraph, type, argMap, guard, fallback, position) {
95044
95549
  if (guard.pushNode(type) === "cycle") {
95045
95550
  return [indeterminateTerminal()];
95046
95551
  }
@@ -95051,7 +95556,7 @@ function walkStaticMember(graph, fileGraph, type, argMap, guard, fallback) {
95051
95556
  const leaf = foldLeaf(graph, fileGraph, type, argMap, guard, fallback);
95052
95557
  if (!(leaf.length > 0 && leaf.every(cameToNothing)))
95053
95558
  return leaf;
95054
- const object = walkInner(graph, fileGraph, type.obj, argMap, guard);
95559
+ const object = walkInner(graph, fileGraph, type.obj, argMap, guard, void 0, "value");
95055
95560
  const semantics = markedProduct(object);
95056
95561
  if (semantics !== null)
95057
95562
  return leaf.map((t3) => withSemantics(t3, semantics));
@@ -95062,36 +95567,24 @@ function walkStaticMember(graph, fileGraph, type, argMap, guard, fallback) {
95062
95567
  const value = obj.props[type.member];
95063
95568
  if (value === void 0)
95064
95569
  continue;
95065
- out2.push(...walkInner(graph, fileGraph, value, argMap, guard, fallback));
95570
+ out2.push(...walkInner(graph, fileGraph, value, argMap, guard, fallback, position));
95066
95571
  }
95067
95572
  return out2.length > 0 ? out2 : [indeterminateTerminal()];
95068
95573
  } finally {
95069
95574
  guard.popNode(type);
95070
95575
  }
95071
95576
  }
95072
- function walkReturnTypeOf(graph, fileGraph, type, argMap, guard) {
95073
- const returns = foldCall(graph, fileGraph, type, argMap, guard).map(returnedValue);
95074
- if (creditedTerminals(returns).length === 0) {
95075
- const semantics = nonComponentProduct(graph, fileGraph, type.callee, guard);
95076
- if (semantics !== null)
95077
- return returns.map((t3) => withSemantics(t3, semantics));
95078
- }
95577
+ function walkReturnTypeOf(graph, fileGraph, type, argMap, guard, position) {
95578
+ const semantics = nonComponentProduct(graph, fileGraph, type.callee, guard);
95579
+ if (semantics !== null)
95580
+ return [withSemantics(indeterminateTerminal(), semantics)];
95581
+ const returns = foldCall(graph, fileGraph, type, argMap, guard, position).map(returnedValue);
95079
95582
  if (!(returns.length > 0 && returns.every(cameToNothing)))
95080
95583
  return returns;
95081
95584
  const unseenHook = HOOK_NAME.test(deriveHocCallee(type.callee)) && isImportBackedLeaf(type.callee, graph, fileGraph, guard);
95082
95585
  return unseenHook ? returns.map(asLateBound("hook-result")) : returns;
95083
95586
  }
95084
- function nonComponentProduct(graph, fileGraph, callee, guard) {
95085
- const ref = callee.kind === "TypeOf" ? callee.ref : callee.kind === "MemberOf" && callee.obj.kind === "TypeOf" ? { ...callee.obj.ref, memberChain: [callee.member] } : null;
95086
- if (ref === null)
95087
- return null;
95088
- const imp = fileGraphForRef(graph, ref, fileGraph).importsByLocal.get(ref.symbol);
95089
- const entry = imp === void 0 ? null : libraryExportFor(imp, ref);
95090
- if (entry === null || entry.kind !== "non-component-product")
95091
- return null;
95092
- return isImportBackedLeaf(callee, graph, fileGraph, guard) ? entry.semantics : null;
95093
- }
95094
- function foldCall(graph, fileGraph, type, argMap, guard) {
95587
+ function foldCall(graph, fileGraph, type, argMap, guard, position) {
95095
95588
  const lazyShape = findLazyImportArg(type.args, fileGraph);
95096
95589
  if (lazyShape) {
95097
95590
  const syntheticDI = {
@@ -95107,7 +95600,7 @@ function foldCall(graph, fileGraph, type, argMap, guard) {
95107
95600
  let inner2;
95108
95601
  try {
95109
95602
  const target = resolveDynamicImportTarget(graph, fileGraph, syntheticDI, guard);
95110
- inner2 = target ? walkInner(graph, target.targetFileGraph, target.value, argMap, guard) : walkInner(graph, fileGraph, syntheticDI, argMap, guard);
95603
+ inner2 = target ? walkInner(graph, target.targetFileGraph, target.value, argMap, guard, void 0, position) : walkInner(graph, fileGraph, syntheticDI, argMap, guard, void 0, position);
95111
95604
  } finally {
95112
95605
  guard.pop(syntheticDI.originFile, guardKey);
95113
95606
  }
@@ -95130,14 +95623,14 @@ function foldCall(graph, fileGraph, type, argMap, guard) {
95130
95623
  }
95131
95624
  return [{ denotation: { kind: "foreign" }, viaTrail: [via], identity }];
95132
95625
  }
95133
- const dispatcherResult = walkDispatcherReturns(graph, fileGraph, type, argMap, guard);
95626
+ const dispatcherResult = walkDispatcherReturns(graph, fileGraph, type, argMap, guard, position);
95134
95627
  if (dispatcherResult)
95135
95628
  return dispatcherResult;
95136
95629
  const passThroughIndex = passThroughParameterIndex(graph, fileGraph, type, argMap, guard);
95137
95630
  if (passThroughIndex !== null) {
95138
95631
  const wrapped = type.args[passThroughIndex];
95139
95632
  if (wrapped !== void 0) {
95140
- const inner2 = walkInner(graph, fileGraph, wrapped, argMap, guard);
95633
+ const inner2 = walkInner(graph, fileGraph, wrapped, argMap, guard, void 0, position);
95141
95634
  return foldToWrappedArg(inner2, buildHocVia(type, wrapped, fileGraph));
95142
95635
  }
95143
95636
  }
@@ -95146,7 +95639,7 @@ function foldCall(graph, fileGraph, type, argMap, guard) {
95146
95639
  if (algHasNonUnknown) {
95147
95640
  const lastArg2 = type.args.at(-1);
95148
95641
  if (lastArg2 !== void 0) {
95149
- const inner2 = walkInner(graph, fileGraph, lastArg2, argMap, guard);
95642
+ const inner2 = walkInner(graph, fileGraph, lastArg2, argMap, guard, void 0, position);
95150
95643
  if (isPassThroughWrapper(algResult, inner2)) {
95151
95644
  const via = buildHocVia(type, lastArg2, fileGraph);
95152
95645
  return inner2.filter((t3) => !cameToNothing(t3)).map((t3) => ({ denotation: t3.denotation, viaTrail: [via, ...t3.viaTrail], identity: t3.identity }));
@@ -95158,8 +95651,10 @@ function foldCall(graph, fileGraph, type, argMap, guard) {
95158
95651
  if (lastArg === void 0) {
95159
95652
  return [indeterminateTerminal()];
95160
95653
  }
95161
- const inner = walkInner(graph, fileGraph, lastArg, argMap, guard);
95162
- if (isDataMethodRenderCall(type, graph, fileGraph, guard)) {
95654
+ const dataMethod = isDataMethodRenderCall(type, graph, fileGraph, guard);
95655
+ const called = dataMethod || isLoader(lastArg, graph, fileGraph, guard);
95656
+ const inner = walkInner(graph, fileGraph, lastArg, argMap, guard, void 0, called ? "value" : position);
95657
+ if (dataMethod) {
95163
95658
  const nonUnknown = inner.filter((t3) => !cameToNothing(t3));
95164
95659
  if (nonUnknown.length > 0) {
95165
95660
  return nonUnknown.map((t3) => ({ denotation: t3.denotation, viaTrail: t3.viaTrail, identity: null }));
@@ -95190,7 +95685,7 @@ function passThroughParameterIndex(graph, fileGraph, type, argMap, guard) {
95190
95685
  }
95191
95686
  return index;
95192
95687
  }
95193
- function walkDispatcherReturns(graph, fileGraph, type, argMap, guard) {
95688
+ function walkDispatcherReturns(graph, fileGraph, type, argMap, guard, position) {
95194
95689
  const calleeFns = resolveToFunctions(graph, fileGraph, type.callee, argMap, guard);
95195
95690
  const hasDispatcher = calleeFns.some(({ fn }) => fn.kind === "Function" && fn.returns.some(isDynamicMemberReturn));
95196
95691
  if (!hasDispatcher)
@@ -95204,7 +95699,7 @@ function walkDispatcherReturns(graph, fileGraph, type, argMap, guard) {
95204
95699
  argMap.bind(bindingRef, type.args);
95205
95700
  try {
95206
95701
  for (const ret of fn.returns) {
95207
- folded.push(...walkInner(graph, fnFileGraph, ret, argMap, guard));
95702
+ folded.push(...walkInner(graph, fnFileGraph, ret, argMap, guard, void 0, position));
95208
95703
  }
95209
95704
  } finally {
95210
95705
  if (bindingRef)
@@ -95267,7 +95762,7 @@ function findFirstDynamicImport(t3, fileGraph, depthBudget) {
95267
95762
  }
95268
95763
  return null;
95269
95764
  }
95270
- function walkDynamicMember(graph, fileGraph, type, argMap, guard) {
95765
+ function walkDynamicMember(graph, fileGraph, type, argMap, guard, position) {
95271
95766
  if (guard.pushNode(type) === "cycle") {
95272
95767
  return [indeterminateTerminal()];
95273
95768
  }
@@ -95285,7 +95780,7 @@ function walkDynamicMember(graph, fileGraph, type, argMap, guard) {
95285
95780
  column: mapBinding?.loc.column ?? 0
95286
95781
  };
95287
95782
  for (const propValue of Object.values(obj.props)) {
95288
- const inner = walkInner(graph, fileGraph, propValue, argMap, guard);
95783
+ const inner = walkInner(graph, fileGraph, propValue, argMap, guard, void 0, position);
95289
95784
  const via = { kind: "dynamic-map", mapName, mapLoc };
95290
95785
  for (const t3 of inner) {
95291
95786
  if (cameToNothing(t3))
@@ -95708,236 +96203,6 @@ function resolveToFunctionsInner(graph, fileGraph, type, argMap, guard) {
95708
96203
  // ../reference-graph/dist/engine/index.js
95709
96204
  import { asTagName, computeOccurrenceId, serialiseComponentId, projectPropUsages, parseCompoundExport as parseCompoundExport2 } from "@component-compass/plugin-core";
95710
96205
 
95711
- // ../reference-graph/dist/engine/helper-callers.js
95712
- function findLocalDeclaration(fileGraph, ref) {
95713
- let scope = ref.scope;
95714
- while (true) {
95715
- const decl = fileGraph.declarations.get(`${scope}::${ref.symbol}`);
95716
- if (decl)
95717
- return decl;
95718
- if (scope === MODULE_SCOPE)
95719
- return null;
95720
- const parent = fileGraph.scopes.get(scope)?.parent;
95721
- if (parent === null || parent === void 0)
95722
- return null;
95723
- scope = parent;
95724
- }
95725
- }
95726
- function classifyDeclaration(decl, registry, fileGraph) {
95727
- if (decl.value.kind !== "Function" && decl.value.kind !== "ReturnTypeOf")
95728
- return "unknown";
95729
- if (fileGraph.dialect === "vue" && isSfcDeclaration(fileGraph, decl))
95730
- return "component";
95731
- return registry.hasLocal(fileGraph.filePath, decl.symbol) ? "component" : "helper";
95732
- }
95733
- var isSfcDeclaration = (fileGraph, decl) => fileGraph.exports.some((e) => e.kind === "default" && "local" in e && e.local === decl.symbol);
95734
- function buildHelperCallers(graph, registry) {
95735
- const index = /* @__PURE__ */ new Map();
95736
- const callerKeysByHelper = /* @__PURE__ */ new Map();
95737
- const classificationCache = /* @__PURE__ */ new Map();
95738
- const refResolutionCache = /* @__PURE__ */ new Map();
95739
- function resolveRefCached(ref, callerFile, callerGraph) {
95740
- const key = `${callerFile}::${ref.symbol}`;
95741
- if (refResolutionCache.has(key)) {
95742
- return refResolutionCache.get(key) ?? null;
95743
- }
95744
- const result2 = resolveRefToDecl(ref, callerFile, callerGraph, graph);
95745
- refResolutionCache.set(key, result2);
95746
- return result2;
95747
- }
95748
- const pendingValueRefs = [];
95749
- for (const [file, fileGraph] of graph.files) {
95750
- for (const decl of fileGraph.declarations.values()) {
95751
- if (decl.scope !== MODULE_SCOPE)
95752
- continue;
95753
- const refs = [];
95754
- if (decl.value.kind === "Function") {
95755
- for (const r2 of decl.value.returns)
95756
- collectRefsInType(r2, refs);
95757
- } else if (decl.value.kind === "ReturnTypeOf") {
95758
- collectCalleeRefs(decl.value, refs);
95759
- }
95760
- for (const bc of fileGraph.bodyCalls) {
95761
- if (bc.ownerSymbol === decl.symbol)
95762
- refs.push(bc.callee);
95763
- }
95764
- const callerKey = { file, symbol: decl.symbol };
95765
- for (const ref of refs) {
95766
- const target = resolveRefCached(ref, file, fileGraph);
95767
- if (!target)
95768
- continue;
95769
- pendingValueRefs.push({ target, caller: callerKey });
95770
- }
95771
- }
95772
- }
95773
- const pendingJsxCalls = [];
95774
- for (const [file, fileGraph] of graph.files) {
95775
- for (let i2 = 0; i2 < fileGraph.jsxUsages.length; i2++) {
95776
- const usage = fileGraph.jsxUsages[i2];
95777
- if (!usage)
95778
- continue;
95779
- const target = resolveRefCached(usage.ref, file, fileGraph);
95780
- if (!target)
95781
- continue;
95782
- const ownership = fileGraph.ownership[i2];
95783
- if (!ownership?.ownerSymbolRef)
95784
- continue;
95785
- const callerTarget = resolveRefCached(ownership.ownerSymbolRef, file, fileGraph);
95786
- if (!callerTarget)
95787
- continue;
95788
- if (callerTarget.decl.scope !== MODULE_SCOPE)
95789
- continue;
95790
- pendingJsxCalls.push({
95791
- target,
95792
- caller: { file: callerTarget.file, symbol: callerTarget.decl.symbol }
95793
- });
95794
- }
95795
- }
95796
- function classifyKey(file, decl) {
95797
- const key = `${file}::${decl.symbol}`;
95798
- const hit = classificationCache.get(key);
95799
- if (hit !== void 0)
95800
- return hit;
95801
- const fileGraph = graph.files.get(file);
95802
- const result2 = fileGraph ? classifyDeclaration(decl, registry, fileGraph) : "unknown";
95803
- classificationCache.set(key, result2);
95804
- return result2;
95805
- }
95806
- for (const [file, fileGraph] of graph.files) {
95807
- for (const decl of fileGraph.declarations.values()) {
95808
- if (decl.scope !== MODULE_SCOPE)
95809
- continue;
95810
- if (decl.value.kind !== "Function" && decl.value.kind !== "ReturnTypeOf")
95811
- continue;
95812
- classifyKey(file, decl);
95813
- }
95814
- }
95815
- function recordCallerEdge(target, callerKey) {
95816
- const keyStr = `${target.file}::${target.decl.symbol}`;
95817
- const callerKeyStr = `${callerKey.file}::${callerKey.symbol}`;
95818
- let seen2 = callerKeysByHelper.get(keyStr);
95819
- if (!seen2) {
95820
- seen2 = /* @__PURE__ */ new Set();
95821
- callerKeysByHelper.set(keyStr, seen2);
95822
- }
95823
- if (seen2.has(callerKeyStr))
95824
- return;
95825
- seen2.add(callerKeyStr);
95826
- let callers = index.get(keyStr);
95827
- if (!callers) {
95828
- callers = /* @__PURE__ */ new Set();
95829
- index.set(keyStr, callers);
95830
- }
95831
- callers.add(callerKey);
95832
- }
95833
- for (const { target, caller } of pendingValueRefs) {
95834
- if (classifyKey(target.file, target.decl) !== "helper")
95835
- continue;
95836
- recordCallerEdge(target, caller);
95837
- }
95838
- for (const { target, caller } of pendingJsxCalls) {
95839
- if (classifyKey(target.file, target.decl) !== "helper")
95840
- continue;
95841
- recordCallerEdge(target, caller);
95842
- }
95843
- return {
95844
- get(key) {
95845
- return index.get(`${key.file}::${key.symbol}`);
95846
- },
95847
- classification(file, symbol2) {
95848
- return classificationCache.get(`${file}::${symbol2}`) ?? "unknown";
95849
- }
95850
- };
95851
- }
95852
- function collectCalleeRefs(t3, out2) {
95853
- switch (t3.kind) {
95854
- case "ReturnTypeOf":
95855
- collectCalleeRefs(t3.callee, out2);
95856
- return;
95857
- case "MemberOf":
95858
- collectCalleeRefs(t3.obj, out2);
95859
- return;
95860
- case "TypeOf":
95861
- out2.push(t3.ref);
95862
- return;
95863
- default:
95864
- return;
95865
- }
95866
- }
95867
- function collectRefsInType(t3, out2) {
95868
- switch (t3.kind) {
95869
- case "TypeOf":
95870
- out2.push(t3.ref);
95871
- return;
95872
- case "Union":
95873
- for (const u3 of t3.types)
95874
- collectRefsInType(u3, out2);
95875
- return;
95876
- case "ReturnTypeOf":
95877
- collectRefsInType(t3.callee, out2);
95878
- for (const a3 of t3.args)
95879
- collectRefsInType(a3, out2);
95880
- return;
95881
- case "Function":
95882
- for (const r2 of t3.returns)
95883
- collectRefsInType(r2, out2);
95884
- return;
95885
- case "Object":
95886
- for (const v of Object.values(t3.props))
95887
- collectRefsInType(v, out2);
95888
- return;
95889
- case "Array":
95890
- for (const e of t3.elements)
95891
- collectRefsInType(e, out2);
95892
- return;
95893
- case "MemberOf":
95894
- collectRefsInType(t3.obj, out2);
95895
- return;
95896
- case "ParameterOf":
95897
- return;
95898
- default:
95899
- return;
95900
- }
95901
- }
95902
- function resolveRefToDecl(ref, callerFile, callerGraph, graph) {
95903
- const localKey = `${MODULE_SCOPE}::${ref.symbol}`;
95904
- const localDecl = callerGraph.declarations.get(localKey);
95905
- if (localDecl)
95906
- return { file: callerFile, decl: localDecl };
95907
- const imp = callerGraph.importsByLocal.get(ref.symbol);
95908
- if (!imp)
95909
- return null;
95910
- const resolvedAbs = graph.moduleResolver(callerFile, imp.specifier);
95911
- if (!resolvedAbs)
95912
- return null;
95913
- const targetFile = graph.resolveToGraphKey ? graph.resolveToGraphKey(resolvedAbs) ?? resolvedAbs : resolvedAbs;
95914
- const targetGraph = graph.files.get(targetFile);
95915
- if (!targetGraph)
95916
- return null;
95917
- const chained = followReExportChain(graph, targetFile, imp.imported);
95918
- if (chained) {
95919
- const chainedGraph = graph.files.get(chained.file);
95920
- if (chainedGraph) {
95921
- const decl = chainedGraph.declarations.get(`${MODULE_SCOPE}::${chained.localExport}`);
95922
- if (decl)
95923
- return { file: chained.file, decl };
95924
- }
95925
- }
95926
- for (const exp of targetGraph.exports) {
95927
- if (exp.kind === "named" && "local" in exp && exp.exportedAs === imp.imported) {
95928
- const decl = targetGraph.declarations.get(`${MODULE_SCOPE}::${exp.local}`);
95929
- if (decl)
95930
- return { file: targetFile, decl };
95931
- }
95932
- if (exp.kind === "default" && "local" in exp && imp.imported === "default") {
95933
- const decl = targetGraph.declarations.get(`${MODULE_SCOPE}::${exp.local}`);
95934
- if (decl)
95935
- return { file: targetFile, decl };
95936
- }
95937
- }
95938
- return null;
95939
- }
95940
-
95941
96206
  // ../reference-graph/dist/engine/owner-resolution.js
95942
96207
  function resolveOwnerChain(ownerRef, graph, helperIndex, guard) {
95943
96208
  if (!ownerRef)
@@ -95996,12 +96261,28 @@ function narrowTo(registry, entries) {
95996
96261
  }
95997
96262
  return {
95998
96263
  hasLocal: (filePath, exportName) => survivingNames.has(entryKey(filePath, exportName)),
95999
- isComponentShaped: (filePath, exportName) => registry.isComponentShaped(filePath, exportName),
96264
+ isComponent: (filePath, name, declaration2) => registry.isComponent(filePath, name, declaration2),
96000
96265
  declarationOf: (filePath, exportName) => registry.declarationOf(filePath, exportName),
96266
+ isRenderedAsTag: (entry) => registry.isRenderedAsTag(entry),
96267
+ isTagged: (filePath, name, declaration2) => registry.isTagged(filePath, name, declaration2),
96001
96268
  localEntries: () => entries
96002
96269
  };
96003
96270
  }
96004
- function buildComponentRegistry(graph) {
96271
+ var CAN_HOLD_A_FUNCTION = {
96272
+ TypeOf: true,
96273
+ Function: true,
96274
+ ReturnTypeOf: true,
96275
+ ParameterOf: false,
96276
+ MemberOf: true,
96277
+ Union: true,
96278
+ Object: false,
96279
+ Array: false,
96280
+ JSX: false,
96281
+ Str: false,
96282
+ Unknown: false,
96283
+ DynamicImport: true
96284
+ };
96285
+ function buildComponentRegistry(graph, tagged = []) {
96005
96286
  const consumed = /* @__PURE__ */ new Set();
96006
96287
  for (const [file, fg] of graph.files) {
96007
96288
  for (const exp of fg.exports) {
@@ -96023,16 +96304,35 @@ function buildComponentRegistry(graph) {
96023
96304
  consumed.add(entryKey(target.file, target.symbol));
96024
96305
  }
96025
96306
  }
96307
+ const taggedDeclaration = (filePath, name, declaration2) => {
96308
+ const fg = graph.files.get(filePath);
96309
+ if (fg === void 0)
96310
+ return void 0;
96311
+ if (declaration2 !== void 0)
96312
+ return declaration2;
96313
+ const named = findDeclaration(fg, name);
96314
+ return named !== void 0 && CAN_HOLD_A_FUNCTION[named.value.kind] ? named : void 0;
96315
+ };
96316
+ const renderedAsTag = /* @__PURE__ */ new Set();
96317
+ for (const { filePath, exportName, declaration: declaration2 } of tagged) {
96318
+ const marked = taggedDeclaration(filePath, exportName, declaration2);
96319
+ if (marked !== void 0)
96320
+ renderedAsTag.add(marked);
96321
+ }
96322
+ const isTagged = (filePath, name, declaration2) => {
96323
+ const marked = taggedDeclaration(filePath, name, declaration2);
96324
+ return marked !== void 0 && renderedAsTag.has(marked);
96325
+ };
96026
96326
  const byKey = /* @__PURE__ */ new Map();
96027
96327
  const entryIndex = /* @__PURE__ */ new Map();
96028
96328
  const entries = [];
96329
+ const taggedEntries = /* @__PURE__ */ new Set();
96029
96330
  for (const [file, fg] of graph.files) {
96030
96331
  if (fg.dialect === "vue")
96031
96332
  continue;
96032
96333
  for (const decl of fg.declarations.values()) {
96033
- if (!consumed.has(entryKey(file, decl.symbol)))
96034
- continue;
96035
- if (!isAdmittedShape(decl.value, graph, fg))
96334
+ const symbolKey = entryKey(file, decl.symbol);
96335
+ if (!renderedAsTag.has(decl) && !(consumed.has(symbolKey) && isAdmittedShape(decl.value, graph, fg)))
96036
96336
  continue;
96037
96337
  const exportName = decl.exportedAs ?? decl.symbol;
96038
96338
  const entry = {
@@ -96043,6 +96343,8 @@ function buildComponentRegistry(graph) {
96043
96343
  loc: decl.loc,
96044
96344
  isDefault: decl.symbol === "default" || fg.exports.some((e) => e.kind === "default" && "local" in e && e.local === decl.symbol)
96045
96345
  };
96346
+ if (renderedAsTag.has(decl))
96347
+ taggedEntries.add(declarationKey(entry));
96046
96348
  const key = entryKey(file, exportName);
96047
96349
  if (!byKey.has(key)) {
96048
96350
  entryIndex.set(key, entries.length);
@@ -96056,20 +96358,28 @@ function buildComponentRegistry(graph) {
96056
96358
  byKey.set(key, entry);
96057
96359
  }
96058
96360
  }
96059
- const shapeCache = /* @__PURE__ */ new Map();
96060
- const isComponentShaped2 = (filePath, exportName) => {
96061
- const cacheKey = entryKey(filePath, exportName);
96062
- const cached = shapeCache.get(cacheKey);
96361
+ const judge = (fg, name, declaration2) => {
96362
+ const { root: root2, path: path5 } = parseCompoundExport(name);
96363
+ const decl = declaration2 ?? findDeclaration(fg, root2);
96364
+ if (decl === void 0)
96365
+ return false;
96366
+ if (path5.length > 0)
96367
+ return isAdmittedMember(decl.value, path5, graph, fg);
96368
+ return isAdmittedShape(decl.value, graph, fg) || renderedAsTag.has(decl);
96369
+ };
96370
+ const judgedByName = /* @__PURE__ */ new Map();
96371
+ const isComponent2 = (filePath, name, declaration2) => {
96372
+ const fg = graph.files.get(filePath);
96373
+ if (fg === void 0 || fg.dialect === "vue")
96374
+ return false;
96375
+ if (declaration2 !== void 0)
96376
+ return judge(fg, name, declaration2);
96377
+ const cacheKey = entryKey(filePath, name);
96378
+ const cached = judgedByName.get(cacheKey);
96063
96379
  if (cached !== void 0)
96064
96380
  return cached;
96065
- const fg = graph.files.get(filePath);
96066
- let result2 = false;
96067
- if (fg && fg.dialect !== "vue") {
96068
- const { root: root2, path: path5 } = parseCompoundExport(exportName);
96069
- const decl = findDeclaration(fg, root2);
96070
- result2 = decl !== void 0 && (path5.length === 0 ? isAdmittedShape(decl.value, graph, fg) : isAdmittedMember(decl.value, path5, graph, fg));
96071
- }
96072
- shapeCache.set(cacheKey, result2);
96381
+ const result2 = judge(fg, name, void 0);
96382
+ judgedByName.set(cacheKey, result2);
96073
96383
  return result2;
96074
96384
  };
96075
96385
  const declarationOf = (filePath, exportName) => {
@@ -96086,11 +96396,16 @@ function buildComponentRegistry(graph) {
96086
96396
  };
96087
96397
  return {
96088
96398
  hasLocal: (filePath, exportName) => byKey.has(entryKey(filePath, exportName)),
96089
- isComponentShaped: isComponentShaped2,
96399
+ isComponent: isComponent2,
96090
96400
  declarationOf,
96401
+ isRenderedAsTag: (entry) => taggedEntries.has(declarationKey(entry)),
96402
+ isTagged,
96091
96403
  localEntries: () => entries
96092
96404
  };
96093
96405
  }
96406
+ function declarationKey(entry) {
96407
+ return `${entryKey(entry.filePath, entry.symbol)}@${entry.loc.line}:${entry.loc.column}`;
96408
+ }
96094
96409
  function excludeFoldedHolders(registry, folded) {
96095
96410
  if (folded.size === 0)
96096
96411
  return registry;
@@ -96098,7 +96413,7 @@ function excludeFoldedHolders(registry, folded) {
96098
96413
  const survivors = [];
96099
96414
  for (const entry of registry.localEntries()) {
96100
96415
  const holder = folded.get(entryKey(entry.filePath, entry.symbol));
96101
- if (holder === void 0) {
96416
+ if (holder === void 0 || registry.isRenderedAsTag(entry)) {
96102
96417
  survivors.push(entry);
96103
96418
  continue;
96104
96419
  }
@@ -96124,16 +96439,8 @@ function isAdmittedShape(value, graph, fg) {
96124
96439
  return Object.values(value.props).some((prop) => evalKind(prop, graph, fg) === "component");
96125
96440
  }
96126
96441
  function isAdmittedMember(holder, path5, graph, fg) {
96127
- let cur = holder;
96128
- for (const segment of path5) {
96129
- if (cur.kind !== "Object")
96130
- return false;
96131
- const next = cur.props[segment];
96132
- if (next === void 0)
96133
- return false;
96134
- cur = next;
96135
- }
96136
- return isAdmittedShape(cur, graph, fg);
96442
+ const member = memberOfObjectPath(holder, path5);
96443
+ return member !== void 0 && isAdmittedShape(member, graph, fg);
96137
96444
  }
96138
96445
  function findDeclaration(fg, name) {
96139
96446
  const atModuleScope = fg.declarations.get(`${MODULE_SCOPE}::${name}`);
@@ -96164,7 +96471,11 @@ function isHostElementRoot(ref) {
96164
96471
  function resolve5(graph, opts) {
96165
96472
  const occurrences = [];
96166
96473
  const argMap = createArgumentMap();
96167
- const registry = buildComponentRegistry(graph);
96474
+ const tagEvaluations = /* @__PURE__ */ new Map();
96475
+ for (const [filePath, fileGraph] of graph.files) {
96476
+ tagEvaluations.set(filePath, fileGraph.jsxUsages.map((usage) => evaluateJsxUsage(graph, filePath, fileGraph, usage, argMap)));
96477
+ }
96478
+ const registry = buildComponentRegistry(graph, taggedDeclarations(graph, tagEvaluations));
96168
96479
  const helperIndex = buildHelperCallers(graph, excludeHostElementNames(registry, graph));
96169
96480
  const CODE_EXT = /\.(?:[cm]?[jt]sx?|vue)$/i;
96170
96481
  const HAS_EXT = /\.[^./\\]+$/;
@@ -96172,12 +96483,9 @@ function resolve5(graph, opts) {
96172
96483
  if (id2.kind !== "react-component" || id2.source.type !== "local")
96173
96484
  return true;
96174
96485
  const { filePath } = id2.source;
96175
- const declaring = graph.files.get(filePath);
96176
- if (declaring === void 0)
96177
- return !HAS_EXT.test(filePath) || CODE_EXT.test(filePath);
96178
- if (declaring.dialect === "vue")
96486
+ if (graph.files.has(filePath))
96179
96487
  return true;
96180
- return registry.isComponentShaped(filePath, id2.export);
96488
+ return !HAS_EXT.test(filePath) || CODE_EXT.test(filePath);
96181
96489
  };
96182
96490
  const composition = [];
96183
96491
  const compactSlice = (lengthBefore) => {
@@ -96207,119 +96515,21 @@ function resolve5(graph, opts) {
96207
96515
  }
96208
96516
  return occurrences.length - lengthBefore;
96209
96517
  };
96210
- const pushJsxUsageOccurrences = (filePath, fileGraph, usage, ownership) => {
96211
- const ownerRef = ownership?.ownerSymbolRef ?? null;
96212
- const viaOverride = ownership?.viaOverride;
96213
- const matchedImport = fileGraph.importsByLocal.get(usage.ref.symbol);
96214
- if (!matchedImport) {
96215
- const decl = findLocalDeclaration(fileGraph, usage.ref);
96216
- if (!decl)
96217
- return { kind: "unbound" };
96218
- return {
96219
- kind: "evaluated",
96220
- ...pushLocalOccurrence(occurrences, filePath, usage, decl, graph, fileGraph, argMap, ownerRef, helperIndex, opts, viaOverride)
96221
- };
96222
- }
96223
- const packageName = packageNameFromSpecifier(matchedImport.specifier);
96224
- const effectiveImported = effectiveExportName(matchedImport.imported, usage.ref.memberChain);
96225
- const residual = residualMemberChain(matchedImport.imported, usage.ref.memberChain);
96226
- const holderDefinition = (file, exportName) => {
96227
- if (residual.length === 0)
96228
- return void 0;
96229
- const loc = graph.files.get(file)?.declarations.get(`${MODULE_SCOPE}::${exportName}`)?.loc;
96230
- return loc === void 0 ? void 0 : { line: loc.line, column: loc.column };
96231
- };
96232
- if (!packageName) {
96233
- const resolvedAbsTarget2 = graph.moduleResolver(filePath, matchedImport.specifier);
96234
- if (!resolvedAbsTarget2)
96235
- return { kind: "import-failed", specifier: matchedImport.specifier };
96236
- const resolvedTarget = graph.resolveToGraphKey ? graph.resolveToGraphKey(resolvedAbsTarget2) ?? resolvedAbsTarget2 : resolvedAbsTarget2;
96237
- const refType = resolveReference(graph, fileGraph, usage.ref);
96238
- const evaluation = walkWithFolding(graph, fileGraph, refType, argMap);
96239
- const jsxTerminals = creditedTerminals(evaluation);
96240
- if (jsxTerminals.length === 0)
96241
- return { kind: "evaluated", evaluation, value: refType };
96242
- const chained = followReExportChain(graph, resolvedTarget, effectiveImported);
96243
- const canonicalFile = chained?.file ?? resolvedTarget;
96244
- let exportName = chained?.localExport ?? effectiveImported;
96245
- if (!chained) {
96246
- const targetGraph = graph.files.get(resolvedTarget);
96247
- if (targetGraph && effectiveImported === "default") {
96248
- const defaultExp = targetGraph.exports.find((e) => e.kind === "default");
96249
- if (defaultExp && "local" in defaultExp) {
96250
- exportName = defaultExp.local;
96251
- }
96252
- } else if (targetGraph) {
96253
- const namedExp = targetGraph.exports.find((e) => e.kind === "named" && "exportedAs" in e && e.exportedAs === effectiveImported && "local" in e);
96254
- if (namedExp && "local" in namedExp) {
96255
- exportName = namedExp.local;
96256
- }
96257
- }
96258
- }
96259
- const outerVia = viaOverride ?? {
96260
- kind: "direct-import",
96261
- specifier: matchedImport.specifier,
96262
- import: matchedImport.imported
96263
- };
96264
- const fallbackComponentId = {
96265
- kind: componentKindFor(fileGraph.dialect),
96266
- export: compoundExportName(exportName, residual),
96267
- source: { type: "local", filePath: canonicalFile }
96268
- };
96269
- const site = usageSite(filePath, usage);
96270
- const owners = usageOwners(graph, helperIndex, ownerRef, viaOverride, fileGraph.filePath);
96271
- const definition = holderDefinition(canonicalFile, exportName);
96272
- for (const ft of jsxTerminals) {
96273
- const rawComponentId = componentIdFromIdentity(ft.identity, fallbackComponentId, fileGraph.dialect, {
96274
- filePath,
96275
- resolveExternalLeaf: opts?.resolveExternalLeaf
96276
- });
96277
- emitOccurrence(occurrences, site, rawComponentId, owners, viaOverride !== void 0 ? [viaOverride] : [outerVia, ...ft.viaTrail], ft.identity === null ? definition : void 0);
96278
- }
96279
- return { kind: "evaluated", evaluation, value: refType };
96280
- }
96281
- const resolvedAbsTarget = graph.moduleResolver(filePath, matchedImport.specifier);
96282
- const resolvedNormTarget = resolvedAbsTarget !== null && graph.resolveToGraphKey ? graph.resolveToGraphKey(resolvedAbsTarget) ?? resolvedAbsTarget : resolvedAbsTarget;
96283
- const targetInGraph = resolvedNormTarget !== null && graph.files.has(resolvedNormTarget);
96284
- if (targetInGraph) {
96285
- const refType = resolveReference(graph, fileGraph, usage.ref);
96286
- const evaluation = walkWithFolding(graph, fileGraph, refType, argMap);
96287
- const jsxTerminals = creditedTerminals(evaluation);
96288
- if (jsxTerminals.length === 0)
96289
- return { kind: "evaluated", evaluation, value: refType };
96290
- const siblingFallback = workspaceSiblingFallback(graph, resolvedNormTarget, matchedImport, effectiveImported, fileGraph.dialect);
96291
- const localFallback = siblingFallback !== void 0 && siblingFallback.kind !== "custom-element" ? { ...siblingFallback, export: compoundExportName(siblingFallback.export, residual) } : siblingFallback;
96292
- const definition = siblingFallback !== void 0 && siblingFallback.kind !== "custom-element" && siblingFallback.source.type === "local" ? holderDefinition(siblingFallback.source.filePath, siblingFallback.export) : void 0;
96293
- for (const ft of jsxTerminals) {
96294
- pushOccurrence(occurrences, filePath, usage, matchedImport, compoundExportName(effectiveImported, residual), packageName, graph, fileGraph, ft, ownerRef, helperIndex, opts, localFallback, viaOverride, ft.identity === null ? definition : void 0);
96295
- }
96296
- return { kind: "evaluated", evaluation, value: refType };
96297
- }
96298
- const member = resolvedAbsTarget !== null ? unparsedMemberDefinition(graph, resolvedAbsTarget, effectiveImported) : null;
96299
- const sentinelFt = { denotation: { kind: "foreign" }, viaTrail: [], identity: null };
96300
- if (member !== null) {
96301
- const localFallback = {
96302
- kind: componentKindFor(fileGraph.dialect),
96303
- export: compoundExportName(member.exportName, residual),
96304
- source: { type: "local", filePath: member.absFile }
96305
- };
96306
- pushOccurrence(occurrences, filePath, usage, matchedImport, compoundExportName(effectiveImported, residual), packageName, graph, fileGraph, sentinelFt, ownerRef, helperIndex, opts, localFallback, viaOverride);
96307
- } else {
96308
- pushOccurrence(occurrences, filePath, usage, matchedImport, compoundExportName(effectiveImported, residual), packageName, graph, fileGraph, sentinelFt, ownerRef, helperIndex, opts, void 0, viaOverride);
96309
- }
96310
- return { kind: "evaluated", evaluation: [sentinelFt], value: null };
96311
- };
96312
96518
  for (const [filePath, fileGraph] of graph.files) {
96519
+ const evaluations = tagEvaluations.get(filePath) ?? [];
96313
96520
  for (let usageIdx = 0; usageIdx < fileGraph.jsxUsages.length; usageIdx++) {
96314
96521
  const usage = fileGraph.jsxUsages[usageIdx];
96315
- if (!usage)
96522
+ const evaluated = evaluations[usageIdx];
96523
+ if (!usage || !evaluated)
96316
96524
  continue;
96317
96525
  const ownership = fileGraph.ownership[usageIdx];
96318
96526
  const lengthBefore = occurrences.length;
96319
- const outcome = pushJsxUsageOccurrences(filePath, fileGraph, usage, ownership);
96527
+ if (evaluated.kind === "evaluated") {
96528
+ emitTagCredits(occurrences, graph, filePath, fileGraph, usage, ownership, evaluated.credits, helperIndex, registry, opts);
96529
+ }
96320
96530
  const admitted = stampComposition(lengthBefore, "jsx", usageIdx, ownership?.depth ?? 0, ownership?.parentUsageIdx);
96321
96531
  if (admitted === 0)
96322
- reportDroppedRender(opts, filePath, fileGraph.dialect, usage, outcome);
96532
+ reportDroppedRender(opts, filePath, fileGraph.dialect, usage, evaluated);
96323
96533
  }
96324
96534
  for (let i2 = 0; i2 < fileGraph.tagUsages.length; i2++) {
96325
96535
  const usage = fileGraph.tagUsages[i2];
@@ -96384,7 +96594,7 @@ function resolve5(graph, opts) {
96384
96594
  if (foldedAway !== null)
96385
96595
  folded.set(entryKey(filePath, decl.symbol), foldedAway);
96386
96596
  const lengthBefore = occurrences.length;
96387
- pushArgumentSiteOccurrences(occurrences, filePath, decl, decl.value, holderJsx, graph, fileGraph, argMap, opts);
96597
+ pushArgumentSiteOccurrences(occurrences, filePath, decl, decl.value, holderJsx, graph, fileGraph, argMap, registry, opts);
96388
96598
  compactSlice(lengthBefore);
96389
96599
  }
96390
96600
  }
@@ -96408,7 +96618,7 @@ function resolve5(graph, opts) {
96408
96618
  };
96409
96619
  const owners = () => chainOwners(graph, helperIndex, ownerRef);
96410
96620
  const lengthBefore = occurrences.length;
96411
- pushCallArgumentOccurrences(occurrences, filePath, call, owners, graph, fileGraph, argMap, opts);
96621
+ pushCallArgumentOccurrences(occurrences, filePath, call, owners, graph, fileGraph, argMap, registry, opts);
96412
96622
  compactSlice(lengthBefore);
96413
96623
  }
96414
96624
  }
@@ -96572,29 +96782,191 @@ function usageOwners(graph, helperIndex, ownerRef, viaOverride, fallbackFile) {
96572
96782
  }
96573
96783
  return chainOwners(graph, helperIndex, ownerRef);
96574
96784
  }
96575
- function pushOccurrence(occurrences, filePath, usage, matchedImport, effectiveImported, packageName, graph, fileGraph, ft, ownerRef, helperIndex, opts, fallbackOverride, viaOverride, definition) {
96576
- const fallback = fallbackOverride ?? {
96577
- kind: componentKindFor(fileGraph.dialect),
96578
- export: effectiveImported,
96579
- source: externalSource(packageName, matchedImport.specifier)
96785
+ function namesObjectMember(holder, path5) {
96786
+ return path5.length === 0 || memberOfObjectPath(holder, path5) !== void 0;
96787
+ }
96788
+ function evaluateJsxUsage(graph, filePath, fileGraph, usage, argMap) {
96789
+ if (fileGraph.dialect === "react" && isHostElementRoot(usage.ref))
96790
+ return { kind: "host-element" };
96791
+ const matchedImport = fileGraph.importsByLocal.get(usage.ref.symbol);
96792
+ if (!matchedImport) {
96793
+ const decl = findLocalDeclaration(fileGraph, usage.ref);
96794
+ if (!decl)
96795
+ return { kind: "unbound" };
96796
+ const value = usage.ref.memberChain.length > 0 ? resolveReference(graph, fileGraph, usage.ref) : decl.value;
96797
+ const evaluation = walkWithFolding(graph, fileGraph, value, argMap, createCycleGuard(), void 0, "tag");
96798
+ const fallback2 = {
96799
+ kind: componentKindFor(fileGraph.dialect),
96800
+ export: compoundExportName(usage.ref.symbol, usage.ref.memberChain),
96801
+ source: { type: "local", filePath }
96802
+ };
96803
+ const definition = { line: decl.loc.line, column: decl.loc.column };
96804
+ const outerVia2 = { kind: "local-component" };
96805
+ const rendered = usage.ref.memberChain.length === 0 ? { declaration: decl } : {};
96806
+ const named = namesObjectMember(decl.value, usage.ref.memberChain);
96807
+ const credits = creditedTerminals(evaluation).filter((t3) => t3.identity !== null || named).map((terminal) => ({
96808
+ terminal,
96809
+ fallback: fallback2,
96810
+ outerVia: outerVia2,
96811
+ ...terminal.identity === null ? { definition, ...rendered } : {}
96812
+ }));
96813
+ return { kind: "evaluated", evaluation, value, credits };
96814
+ }
96815
+ const packageName = packageNameFromSpecifier(matchedImport.specifier);
96816
+ const effectiveImported = effectiveExportName(matchedImport.imported, usage.ref.memberChain);
96817
+ const residual = residualMemberChain(matchedImport.imported, usage.ref.memberChain);
96818
+ const holderDecl = (file, exportName) => {
96819
+ const holderFile = graph.files.get(file);
96820
+ return holderFile === void 0 ? void 0 : findDeclaration(holderFile, exportName);
96580
96821
  };
96581
- const rawComponentId = componentIdFromIdentity(ft.identity, fallback, fileGraph.dialect, {
96582
- filePath,
96583
- fallbackSpecifier: matchedImport.specifier,
96584
- resolveExternalLeaf: opts?.resolveExternalLeaf
96585
- });
96586
- const outerVia = viaOverride ?? {
96822
+ const holderDefinition = (file, exportName) => {
96823
+ if (residual.length === 0)
96824
+ return void 0;
96825
+ const loc = holderDecl(file, exportName)?.loc;
96826
+ return loc === void 0 ? void 0 : { line: loc.line, column: loc.column };
96827
+ };
96828
+ const namesHolderMember = (file, exportName) => namesObjectMember(holderDecl(file, exportName)?.value, residual);
96829
+ const outerVia = {
96587
96830
  kind: "direct-import",
96588
96831
  specifier: matchedImport.specifier,
96589
96832
  import: matchedImport.imported
96590
96833
  };
96591
- emitOccurrence(occurrences, usageSite(filePath, usage), rawComponentId, usageOwners(graph, helperIndex, ownerRef, viaOverride, filePath), viaOverride !== void 0 ? [viaOverride] : [outerVia, ...ft.viaTrail], definition);
96834
+ if (!packageName) {
96835
+ const resolvedAbsTarget2 = graph.moduleResolver(filePath, matchedImport.specifier);
96836
+ if (!resolvedAbsTarget2)
96837
+ return { kind: "import-failed", specifier: matchedImport.specifier };
96838
+ const resolvedTarget = graph.resolveToGraphKey ? graph.resolveToGraphKey(resolvedAbsTarget2) ?? resolvedAbsTarget2 : resolvedAbsTarget2;
96839
+ const refType = resolveReference(graph, fileGraph, usage.ref);
96840
+ const evaluation = walkWithFolding(graph, fileGraph, refType, argMap, createCycleGuard(), void 0, "tag");
96841
+ const jsxTerminals = creditedTerminals(evaluation);
96842
+ if (jsxTerminals.length === 0)
96843
+ return { kind: "evaluated", evaluation, value: refType, credits: [] };
96844
+ const chained = followReExportChain(graph, resolvedTarget, effectiveImported);
96845
+ const canonicalFile = chained?.file ?? resolvedTarget;
96846
+ let exportName = chained?.localExport ?? effectiveImported;
96847
+ if (!chained) {
96848
+ const targetGraph = graph.files.get(resolvedTarget);
96849
+ if (targetGraph && effectiveImported === "default") {
96850
+ const defaultExp = targetGraph.exports.find((e) => e.kind === "default");
96851
+ if (defaultExp && "local" in defaultExp) {
96852
+ exportName = defaultExp.local;
96853
+ }
96854
+ } else if (targetGraph) {
96855
+ const namedExp = targetGraph.exports.find((e) => e.kind === "named" && "exportedAs" in e && e.exportedAs === effectiveImported && "local" in e);
96856
+ if (namedExp && "local" in namedExp) {
96857
+ exportName = namedExp.local;
96858
+ }
96859
+ }
96860
+ }
96861
+ const fallback2 = {
96862
+ kind: componentKindFor(fileGraph.dialect),
96863
+ export: compoundExportName(exportName, residual),
96864
+ source: { type: "local", filePath: canonicalFile }
96865
+ };
96866
+ const definition = holderDefinition(canonicalFile, exportName);
96867
+ const named = namesHolderMember(canonicalFile, exportName);
96868
+ const credits = jsxTerminals.filter((t3) => t3.identity !== null || named).map((terminal) => ({
96869
+ terminal,
96870
+ fallback: fallback2,
96871
+ outerVia,
96872
+ ...terminal.identity === null && definition !== void 0 ? { definition } : {}
96873
+ }));
96874
+ return { kind: "evaluated", evaluation, value: refType, credits };
96875
+ }
96876
+ const externalFallback = {
96877
+ kind: componentKindFor(fileGraph.dialect),
96878
+ export: compoundExportName(effectiveImported, residual),
96879
+ source: externalSource(packageName, matchedImport.specifier)
96880
+ };
96881
+ const resolvedAbsTarget = graph.moduleResolver(filePath, matchedImport.specifier);
96882
+ const resolvedNormTarget = resolvedAbsTarget !== null && graph.resolveToGraphKey ? graph.resolveToGraphKey(resolvedAbsTarget) ?? resolvedAbsTarget : resolvedAbsTarget;
96883
+ const targetInGraph = resolvedNormTarget !== null && graph.files.has(resolvedNormTarget);
96884
+ if (targetInGraph) {
96885
+ const refType = resolveReference(graph, fileGraph, usage.ref);
96886
+ const evaluation = walkWithFolding(graph, fileGraph, refType, argMap, createCycleGuard(), void 0, "tag");
96887
+ const jsxTerminals = creditedTerminals(evaluation);
96888
+ if (jsxTerminals.length === 0)
96889
+ return { kind: "evaluated", evaluation, value: refType, credits: [] };
96890
+ const siblingFallback = workspaceSiblingFallback(graph, resolvedNormTarget, matchedImport, effectiveImported, fileGraph.dialect);
96891
+ const localFallback = siblingFallback !== void 0 && siblingFallback.kind !== "custom-element" ? { ...siblingFallback, export: compoundExportName(siblingFallback.export, residual) } : siblingFallback;
96892
+ const localHolder = siblingFallback !== void 0 && siblingFallback.kind !== "custom-element" && siblingFallback.source.type === "local" ? { filePath: siblingFallback.source.filePath, exportName: siblingFallback.export } : void 0;
96893
+ const definition = localHolder === void 0 ? void 0 : holderDefinition(localHolder.filePath, localHolder.exportName);
96894
+ const named = localHolder === void 0 || namesHolderMember(localHolder.filePath, localHolder.exportName);
96895
+ const fallback2 = localFallback ?? externalFallback;
96896
+ const credits = jsxTerminals.filter((t3) => t3.identity !== null || named).map((terminal) => ({
96897
+ terminal,
96898
+ fallback: fallback2,
96899
+ fallbackSpecifier: matchedImport.specifier,
96900
+ outerVia,
96901
+ ...terminal.identity === null && definition !== void 0 ? { definition } : {}
96902
+ }));
96903
+ return { kind: "evaluated", evaluation, value: refType, credits };
96904
+ }
96905
+ const member = resolvedAbsTarget !== null ? unparsedMemberDefinition(graph, resolvedAbsTarget, effectiveImported) : null;
96906
+ const sentinel = { denotation: { kind: "foreign" }, viaTrail: [], identity: null };
96907
+ const fallback = member !== null ? {
96908
+ kind: componentKindFor(fileGraph.dialect),
96909
+ export: compoundExportName(member.exportName, residual),
96910
+ source: { type: "local", filePath: member.absFile }
96911
+ } : externalFallback;
96912
+ return {
96913
+ kind: "evaluated",
96914
+ evaluation: [sentinel],
96915
+ value: null,
96916
+ credits: [{ terminal: sentinel, fallback, fallbackSpecifier: matchedImport.specifier, outerVia }]
96917
+ };
96918
+ }
96919
+ function carriedDeclaration(credit) {
96920
+ const { identity } = credit.terminal;
96921
+ if (identity === null)
96922
+ return credit.declaration;
96923
+ return identity.kind === "local" ? identity.declaration : void 0;
96924
+ }
96925
+ function taggedDeclarations(graph, tagEvaluations) {
96926
+ const tagged = [];
96927
+ for (const [filePath, evaluations] of tagEvaluations) {
96928
+ const dialect = dialectForFile(graph, filePath);
96929
+ for (const evaluated of evaluations) {
96930
+ if (evaluated.kind !== "evaluated")
96931
+ continue;
96932
+ for (const credit of evaluated.credits) {
96933
+ if (!isCallable(credit.terminal))
96934
+ continue;
96935
+ const { identity } = credit.terminal;
96936
+ const id2 = buildComponentId(identity, credit.fallback, dialect);
96937
+ if (id2.kind === "react-component" && id2.source.type === "local") {
96938
+ const declaration2 = carriedDeclaration(credit);
96939
+ tagged.push({ filePath: id2.source.filePath, exportName: id2.export, ...declaration2 !== void 0 ? { declaration: declaration2 } : {} });
96940
+ }
96941
+ }
96942
+ }
96943
+ }
96944
+ return tagged;
96945
+ }
96946
+ function emitTagCredits(occurrences, graph, filePath, fileGraph, usage, ownership, credits, helperIndex, registry, opts) {
96947
+ if (credits.length === 0)
96948
+ return;
96949
+ const viaOverride = ownership?.viaOverride;
96950
+ const site = usageSite(filePath, usage);
96951
+ const owners = usageOwners(graph, helperIndex, ownership?.ownerSymbolRef ?? null, viaOverride, filePath);
96952
+ for (const credit of credits) {
96953
+ const rawComponentId = componentIdFromIdentity(credit.terminal.identity, credit.fallback, fileGraph.dialect, {
96954
+ filePath,
96955
+ ...credit.fallbackSpecifier !== void 0 ? { fallbackSpecifier: credit.fallbackSpecifier } : {},
96956
+ resolveExternalLeaf: opts?.resolveExternalLeaf
96957
+ });
96958
+ const declaration2 = carriedDeclaration(credit);
96959
+ const stands = isCallable(credit.terminal) ? registryTagged(registry, graph, rawComponentId, declaration2) : registryHolds(registry, graph, rawComponentId, declaration2);
96960
+ if (!stands)
96961
+ continue;
96962
+ emitOccurrence(occurrences, site, rawComponentId, owners, viaOverride !== void 0 ? [viaOverride] : [credit.outerVia, ...credit.terminal.viaTrail], credit.definition);
96963
+ }
96592
96964
  }
96593
96965
  function reportDroppedRender(opts, filePath, dialect, usage, outcome) {
96594
96966
  const collector = opts?.collector;
96595
96967
  if (collector === void 0)
96596
96968
  return;
96597
- if (isHostElementRoot(usage.ref))
96969
+ if (outcome.kind === "host-element")
96598
96970
  return;
96599
96971
  const at = { filePath, line: usage.loc.line, column: usage.loc.column };
96600
96972
  const positional = { ...at, symbol: usage.ref.symbol, memberChain: [...usage.ref.memberChain] };
@@ -96628,30 +97000,6 @@ function reportDroppedRender(opts, filePath, dialect, usage, outcome) {
96628
97000
  }
96629
97001
  collector.emit({ code: decided.code, severity: "info", ...positional });
96630
97002
  }
96631
- function pushLocalOccurrence(occurrences, filePath, usage, decl, graph, fileGraph, argMap, ownerRef, helperIndex, opts, viaOverride) {
96632
- const value = usage.ref.memberChain.length > 0 ? resolveReference(graph, fileGraph, usage.ref) : decl.value;
96633
- const evaluation = walkWithFolding(graph, fileGraph, value, argMap);
96634
- const jsxTerminals = creditedTerminals(evaluation);
96635
- if (jsxTerminals.length === 0)
96636
- return { evaluation, value };
96637
- const outerVia = viaOverride ?? { kind: "local-component" };
96638
- const site = usageSite(filePath, usage);
96639
- const owners = usageOwners(graph, helperIndex, ownerRef, viaOverride, fileGraph.filePath);
96640
- const fallback = {
96641
- kind: componentKindFor(fileGraph.dialect),
96642
- export: compoundExportName(usage.ref.symbol, usage.ref.memberChain),
96643
- source: { type: "local", filePath }
96644
- };
96645
- const definition = { line: decl.loc.line, column: decl.loc.column };
96646
- for (const ft of jsxTerminals) {
96647
- const rawComponentId = componentIdFromIdentity(ft.identity, fallback, fileGraph.dialect, {
96648
- filePath,
96649
- resolveExternalLeaf: opts?.resolveExternalLeaf
96650
- });
96651
- emitOccurrence(occurrences, site, rawComponentId, owners, viaOverride !== void 0 ? [viaOverride] : [outerVia, ...ft.viaTrail], ft.identity === null ? definition : void 0);
96652
- }
96653
- return { evaluation, value };
96654
- }
96655
97003
  function foldedHolder(holderJsx, filePath) {
96656
97004
  if (holderJsx.length === 0 || holderJsx.some((t3) => t3.identity === null))
96657
97005
  return null;
@@ -96659,7 +97007,7 @@ function foldedHolder(holderJsx, filePath) {
96659
97007
  const sameFileSingle = first !== void 0 && first !== null && first.kind === "local" && first.filePath === filePath && holderJsx.every((t3) => t3.identity !== null && t3.identity.kind === "local" && t3.identity.filePath === filePath && t3.identity.export === first.export);
96660
97008
  return { target: sameFileSingle ? { filePath, export: first.export } : null };
96661
97009
  }
96662
- function pushArgumentSiteOccurrences(occurrences, filePath, holder, call, holderJsx, graph, fileGraph, argMap, opts, depth = 0) {
97010
+ function pushArgumentSiteOccurrences(occurrences, filePath, holder, call, holderJsx, graph, fileGraph, argMap, registry, opts, depth = 0) {
96663
97011
  const shape = callFoldShape(holderJsx);
96664
97012
  if (shape === "wrapper") {
96665
97013
  if (depth >= MAX_ARGUMENT_CALL_DEPTH || !call.args.some((a3) => a3.kind === "ReturnTypeOf"))
@@ -96668,7 +97016,7 @@ function pushArgumentSiteOccurrences(occurrences, filePath, holder, call, holder
96668
97016
  if (folded?.arg.kind !== "ReturnTypeOf")
96669
97017
  return;
96670
97018
  const innerJsx = creditedTerminals(walkWithFolding(graph, fileGraph, folded.arg, argMap));
96671
- pushArgumentSiteOccurrences(occurrences, filePath, holder, folded.arg, innerJsx, graph, fileGraph, argMap, opts, depth + 1);
97019
+ pushArgumentSiteOccurrences(occurrences, filePath, holder, folded.arg, innerJsx, graph, fileGraph, argMap, registry, opts, depth + 1);
96672
97020
  return;
96673
97021
  }
96674
97022
  if (shape !== "product")
@@ -96681,7 +97029,7 @@ function pushArgumentSiteOccurrences(occurrences, filePath, holder, call, holder
96681
97029
  originFile: filePath
96682
97030
  };
96683
97031
  const rawOwnerComponentId = hasOnlyHostElementNames(holder.symbol, fileGraph) ? void 0 : ownerIdFromRef(graph, holderRef, filePath);
96684
- pushCallArgumentOccurrences(occurrences, filePath, call, () => [{ rawOwnerComponentId, viaPrefix: [] }], graph, fileGraph, argMap, opts, depth);
97032
+ pushCallArgumentOccurrences(occurrences, filePath, call, () => [{ rawOwnerComponentId, viaPrefix: [] }], graph, fileGraph, argMap, registry, opts, depth);
96685
97033
  }
96686
97034
  var MAX_ARGUMENT_CALL_DEPTH = 2;
96687
97035
  function callFoldShape(jsx) {
@@ -96692,7 +97040,23 @@ function callFoldShape(jsx) {
96692
97040
  return "product";
96693
97041
  return credited === jsx.length ? "wrapper" : null;
96694
97042
  }
96695
- function pushCallArgumentOccurrences(occurrences, filePath, call, owners, graph, fileGraph, argMap, opts, depth = 0) {
97043
+ function registryHolds(registry, graph, id2, declaration2) {
97044
+ if (id2.kind === "custom-element" || id2.source.type !== "local")
97045
+ return true;
97046
+ if (graph.files.get(id2.source.filePath)?.dialect !== "react")
97047
+ return true;
97048
+ return registry.isComponent(id2.source.filePath, id2.export, declaration2);
97049
+ }
97050
+ function registryTagged(registry, graph, id2, declaration2) {
97051
+ if (id2.kind !== "react-component" || id2.source.type !== "local")
97052
+ return true;
97053
+ if (graph.files.get(id2.source.filePath)?.dialect !== "react")
97054
+ return true;
97055
+ if (parseCompoundExport2(id2.export).isCompound)
97056
+ return true;
97057
+ return registry.isTagged(id2.source.filePath, id2.export, declaration2);
97058
+ }
97059
+ function pushCallArgumentOccurrences(occurrences, filePath, call, owners, graph, fileGraph, argMap, registry, opts, depth = 0) {
96696
97060
  let resolvedOwners;
96697
97061
  const seedIdentifier = (site, index, arg, hops) => {
96698
97062
  if (isHostElementName(arg.ref.symbol))
@@ -96707,6 +97071,8 @@ function pushCallArgumentOccurrences(occurrences, filePath, call, owners, graph,
96707
97071
  filePath,
96708
97072
  resolveExternalLeaf: opts?.resolveExternalLeaf
96709
97073
  });
97074
+ if (!registryHolds(registry, graph, rawComponentId))
97075
+ continue;
96710
97076
  resolvedOwners ??= owners();
96711
97077
  emitOccurrence(occurrences, { filePath, line: arg.ref.loc.line, column: arg.ref.loc.column, props: {}, events: [] }, rawComponentId, resolvedOwners, [outerVia, ...hops, ...ft.viaTrail], argDecl !== null ? { line: argDecl.loc.line, column: argDecl.loc.column } : void 0);
96712
97078
  }
@@ -101807,6 +102173,7 @@ var Logger = class {
101807
102173
  };
101808
102174
 
101809
102175
  // src/commands/scan.ts
102176
+ init_upload();
101810
102177
  import { errorMessage as errorMessage2 } from "@component-compass/ast-utils";
101811
102178
 
101812
102179
  // src/seeds.ts
@@ -103112,19 +103479,31 @@ async function runScan(opts) {
103112
103479
  const { createAuthedUploader: createAuthedUploader2 } = await Promise.resolve().then(() => (init_upload_auth(), upload_auth_exports));
103113
103480
  const uploader = await createAuthedUploader2({
103114
103481
  ...opts.hostOverride !== void 0 ? { flagHost: opts.hostOverride } : {},
103115
- ...cfg.host !== void 0 ? { configHost: cfg.host } : {}
103482
+ ...cfg.host !== void 0 ? { configHost: cfg.host } : {},
103483
+ onStatus: (status) => {
103484
+ if (status.state === "queued" || status.state === "processing" || !status.readable && status.state === "duplicate") {
103485
+ log2.info(`Upload ${status.state}${status.stage ? ` (${status.stage})` : ""}; waiting for publication.`);
103486
+ }
103487
+ }
103116
103488
  });
103117
103489
  const result2 = await uploader.upload(JSON.stringify(scanOutput));
103118
103490
  upload = result2.status === "inserted" ? "ok" : "exists";
103491
+ const scanUrl = new URL(result2.url, uploader.base).href;
103119
103492
  log2.info(
103120
- result2.status === "inserted" ? `Uploaded scan ${result2.scanId} \u2192 ${uploader.base}${result2.url}` : `Scan ${result2.scanId} already exists at ${uploader.base}${result2.url}; no changes.`
103493
+ result2.status === "inserted" ? `Uploaded scan ${result2.scanId} \u2192 ${scanUrl}` : `Scan ${result2.scanId} already exists at ${scanUrl}; no changes.`
103121
103494
  );
103122
103495
  } catch (err2) {
103123
103496
  upload = "failed";
103124
103497
  const { formatAuthError: formatAuthError2 } = await Promise.resolve().then(() => (init_session(), session_exports));
103125
- const authMsg = formatAuthError2(err2);
103498
+ const authMsg = formatAuthError2(err2 instanceof UploadPollingError ? err2.cause : err2);
103126
103499
  const msg = authMsg ?? (err2 instanceof Error ? err2.message : String(err2));
103127
- log2.error(`Upload failed: ${msg}`);
103500
+ if (err2 instanceof UploadPollingError) {
103501
+ const outcome = err2.outcome === "unknown" ? "outcome unknown" : "failed";
103502
+ const continuation = err2.outcome === "unknown" ? " The server job may still be processing or may have completed." : "";
103503
+ log2.error(`Upload ${outcome}: ${msg}. Check upload ${err2.receipt.uploadId} at ${err2.statusUrl}.${continuation}`);
103504
+ } else {
103505
+ log2.error(`Upload ${err2 instanceof UploadPendingError ? "pending" : "failed"}: ${msg}`);
103506
+ }
103128
103507
  }
103129
103508
  }
103130
103509
  return { output: scanOutput, upload };