@c4a/extract-ts 0.6.19 → 0.7.0

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 (4) hide show
  1. package/README.md +43 -5
  2. package/README.zh-CN.md +30 -6
  3. package/index.js +1812 -121
  4. package/package.json +2 -2
package/index.js CHANGED
@@ -11375,6 +11375,416 @@ var factSchema = exports_external.union([
11375
11375
  activeFactSchema,
11376
11376
  deprecatedFactSchema
11377
11377
  ]);
11378
+ // ../core/src/schemas/indexerEvidenceAdapterSchema.ts
11379
+ import { createHash } from "node:crypto";
11380
+
11381
+ // ../core/src/indexerOutputRedaction.ts
11382
+ var INDEXER_OUTPUT_REDACTION_MARKER = "[REDACTED:indexer-output]";
11383
+ var SECRET_TOKEN = /^(?:password|passwd|pwd|secret|token|credential|credentials|cookie)$/u;
11384
+ var SECRET_COMPOUND = /^(?:api-key|access-key|private-key|client-secret|access-token|refresh-token)$/u;
11385
+ var NON_SECRET_SUFFIX = new Set([
11386
+ "budget",
11387
+ "count",
11388
+ "digest",
11389
+ "fingerprint",
11390
+ "hash",
11391
+ "index",
11392
+ "kind",
11393
+ "length",
11394
+ "limit",
11395
+ "name",
11396
+ "ref",
11397
+ "reference",
11398
+ "references",
11399
+ "refs",
11400
+ "status",
11401
+ "type"
11402
+ ]);
11403
+ function keyTokens(key) {
11404
+ return key.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase().split("-").filter(Boolean);
11405
+ }
11406
+ function sensitiveKey(key, value) {
11407
+ const tokens = keyTokens(key);
11408
+ if (tokens.length === 0)
11409
+ return false;
11410
+ const normalized = tokens.join("-");
11411
+ if (normalized === "authorization" && value !== null && typeof value === "object") {
11412
+ return false;
11413
+ }
11414
+ if (NON_SECRET_SUFFIX.has(tokens.at(-1)))
11415
+ return false;
11416
+ return SECRET_COMPOUND.test(normalized) || tokens.some((token) => SECRET_TOKEN.test(token)) || normalized === "authorization";
11417
+ }
11418
+ function escapeRegExp(value) {
11419
+ return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
11420
+ }
11421
+ function normalizedBlockedScalars(policy) {
11422
+ const identities = new Set;
11423
+ const values = [];
11424
+ for (const value of policy.blocked_scalars ?? []) {
11425
+ if (typeof value === "number" && !Number.isFinite(value))
11426
+ continue;
11427
+ if (typeof value === "string" && value.length === 0)
11428
+ continue;
11429
+ const identity = `${typeof value}:${String(value)}`;
11430
+ if (identities.has(identity))
11431
+ continue;
11432
+ identities.add(identity);
11433
+ values.push(value);
11434
+ }
11435
+ return values.sort((left, right) => String(right).length - String(left).length);
11436
+ }
11437
+ function replaceWithCount(value, pattern, replacement, count) {
11438
+ return value.replace(pattern, (...args) => {
11439
+ count.replacements += 1;
11440
+ if (typeof replacement === "string")
11441
+ return replacement;
11442
+ return replacement(...args.slice(0, -2));
11443
+ });
11444
+ }
11445
+ function redactKnownText(value, count) {
11446
+ let output = value;
11447
+ output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
11448
+ output = replaceWithCount(output, /(\bauthorization\s*:\s*(?:bearer|basic)\s+)[^\s,;]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
11449
+ output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
11450
+ output = replaceWithCount(output, /([?&](?:access_token|refresh_token|api_key|password|secret)=)[^&#\s]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
11451
+ const key = "(?:[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret|token|credential|cookie)[A-Za-z0-9_.-]*|api[-_]?key|access[-_]?(?:key|token)|private[-_]?key|client[-_]?secret|authorization)";
11452
+ const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
11453
+ output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
11454
+ return output;
11455
+ }
11456
+ function redactBlockedText(value, blocked, count) {
11457
+ let output = value;
11458
+ for (const scalar of blocked) {
11459
+ const pattern = typeof scalar === "number" ? new RegExp(`(?<![0-9.])${escapeRegExp(String(scalar))}(?![0-9.])`, "gu") : new RegExp(escapeRegExp(scalar), "gu");
11460
+ output = replaceWithCount(output, pattern, INDEXER_OUTPUT_REDACTION_MARKER, count);
11461
+ }
11462
+ return output;
11463
+ }
11464
+ function redactText(value, blocked, count) {
11465
+ return redactBlockedText(redactKnownText(value, count), blocked, count);
11466
+ }
11467
+ function blockedScalar(value, blocked) {
11468
+ return blocked.some((candidate) => typeof candidate === typeof value && Object.is(candidate, value));
11469
+ }
11470
+ function redactStructured(value, blocked, count, seen) {
11471
+ if (blockedScalar(value, blocked)) {
11472
+ count.replacements += 1;
11473
+ return INDEXER_OUTPUT_REDACTION_MARKER;
11474
+ }
11475
+ if (typeof value === "string")
11476
+ return redactText(value, blocked, count);
11477
+ if (value === null || typeof value !== "object")
11478
+ return value;
11479
+ if (seen.has(value))
11480
+ throw new TypeError("Indexer output redaction requires an acyclic value");
11481
+ seen.add(value);
11482
+ if (value instanceof Date) {
11483
+ const redacted2 = redactText(value.toISOString(), blocked, count);
11484
+ seen.delete(value);
11485
+ return redacted2;
11486
+ }
11487
+ if (value instanceof Error) {
11488
+ const redacted2 = {
11489
+ name: redactText(value.name, blocked, count),
11490
+ message: redactText(value.message, blocked, count)
11491
+ };
11492
+ seen.delete(value);
11493
+ return redacted2;
11494
+ }
11495
+ if (Array.isArray(value)) {
11496
+ const redacted2 = value.map((item) => redactStructured(item, blocked, count, seen));
11497
+ seen.delete(value);
11498
+ return redacted2;
11499
+ }
11500
+ const redacted = {};
11501
+ for (const [key, item] of Object.entries(value)) {
11502
+ const safeKey = redactText(key, blocked, count);
11503
+ if (sensitiveKey(key, item)) {
11504
+ count.replacements += 1;
11505
+ redacted[safeKey] = INDEXER_OUTPUT_REDACTION_MARKER;
11506
+ } else {
11507
+ redacted[safeKey] = redactStructured(item, blocked, count, seen);
11508
+ }
11509
+ }
11510
+ seen.delete(value);
11511
+ return redacted;
11512
+ }
11513
+ function redactIndexerOutput(input) {
11514
+ const count = { replacements: 0 };
11515
+ const blocked = normalizedBlockedScalars(input.policy ?? {});
11516
+ const value = typeof input.value === "string" ? redactText(input.value, blocked, count) : redactStructured(input.value, blocked, count, new WeakSet);
11517
+ return {
11518
+ value,
11519
+ redacted: count.replacements > 0,
11520
+ replacement_count: count.replacements
11521
+ };
11522
+ }
11523
+ function assertIndexerOutputSafe(input) {
11524
+ const result = redactIndexerOutput(input);
11525
+ if (result.redacted) {
11526
+ throw new TypeError(`Indexer ${input.channel} was blocked by the common output redaction boundary`);
11527
+ }
11528
+ return input.value;
11529
+ }
11530
+
11531
+ // ../core/src/schemas/indexerEvidenceAdapterSchema.ts
11532
+ var digestSchema = exports_external.string().regex(/^sha256:[a-f0-9]{64}$/u);
11533
+ var idSchema = exports_external.string().regex(/^[a-z0-9][a-z0-9._/-]*$/u).superRefine((value, context) => {
11534
+ if (value.split("/").some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
11535
+ context.addIssue({
11536
+ code: exports_external.ZodIssueCode.custom,
11537
+ message: "must not contain empty, current-directory, or parent-directory segments"
11538
+ });
11539
+ }
11540
+ });
11541
+ var semverSchema = exports_external.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u);
11542
+ var canonicalRefSchema = exports_external.string().regex(/^[a-z][a-z0-9.-]*:[A-Za-z0-9][A-Za-z0-9._~:/#@+-]*$/u);
11543
+ var packageCoordinateSchema = exports_external.string().regex(/^(?:@[a-z0-9._-]+\/)?[a-z0-9][a-z0-9._-]*$/u);
11544
+ var portablePathSchema = exports_external.string().superRefine((value, context) => {
11545
+ const segments = value.split("/");
11546
+ if (value.length === 0 || value.includes("\x00") || value.includes("\\") || value.startsWith("/") || /^[A-Za-z]:\//u.test(value) || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
11547
+ context.addIssue({
11548
+ code: exports_external.ZodIssueCode.custom,
11549
+ message: "must be a portable relative path"
11550
+ });
11551
+ }
11552
+ });
11553
+ function addDuplicateIssues(values, context, field) {
11554
+ const seen = new Set;
11555
+ values.forEach((value, index) => {
11556
+ if (seen.has(value)) {
11557
+ context.addIssue({
11558
+ code: exports_external.ZodIssueCode.custom,
11559
+ message: `${field} must not contain duplicate value ${value}`,
11560
+ path: [index]
11561
+ });
11562
+ }
11563
+ seen.add(value);
11564
+ });
11565
+ }
11566
+ var adapterIdentitySchema = exports_external.object({
11567
+ id: idSchema,
11568
+ package: packageCoordinateSchema,
11569
+ export: exports_external.string().regex(/^[A-Za-z_$][A-Za-z0-9_$.-]*$/u),
11570
+ version: semverSchema,
11571
+ digest: digestSchema
11572
+ }).strict();
11573
+ var adapterLocatorSchema = exports_external.object({
11574
+ source_ref: canonicalRefSchema,
11575
+ module_ref: canonicalRefSchema.nullable(),
11576
+ normalized_path: portablePathSchema,
11577
+ qualified_item_path: exports_external.string().min(1).max(1024),
11578
+ signature_digest: digestSchema
11579
+ }).strict();
11580
+ var indexerEvidenceAdapterFactSchema = exports_external.object({
11581
+ fact_ref: canonicalRefSchema,
11582
+ kind: idSchema,
11583
+ locator: adapterLocatorSchema,
11584
+ payload_digest: digestSchema,
11585
+ denominator: exports_external.enum(["none", "eligible-file", "loc", "symbol", "protocol-item"])
11586
+ }).strict();
11587
+ var indexerEvidenceAdapterFileSchema = exports_external.object({
11588
+ file_ref: canonicalRefSchema,
11589
+ source_ref: canonicalRefSchema,
11590
+ module_ref: canonicalRefSchema.nullable(),
11591
+ normalized_path: portablePathSchema,
11592
+ role: exports_external.enum(["primary-owner", "enricher"]),
11593
+ coverage_tier: exports_external.enum(["ast-catalog", "lightweight-evidence"]),
11594
+ disposition: exports_external.enum(["analyzed", "unsupported", "excluded"]),
11595
+ facts: exports_external.array(indexerEvidenceAdapterFactSchema)
11596
+ }).strict().superRefine((value, context) => {
11597
+ addDuplicateIssues(value.facts.map((fact2) => fact2.fact_ref), context, "facts");
11598
+ if (value.disposition !== "analyzed" && value.facts.length > 0) {
11599
+ context.addIssue({
11600
+ code: exports_external.ZodIssueCode.custom,
11601
+ message: "unsupported or excluded files cannot publish facts",
11602
+ path: ["facts"]
11603
+ });
11604
+ }
11605
+ if ((value.role === "enricher" || value.coverage_tier === "lightweight-evidence") && value.facts.some((fact2) => fact2.denominator !== "none")) {
11606
+ context.addIssue({
11607
+ code: exports_external.ZodIssueCode.custom,
11608
+ message: "enricher and lightweight evidence facts cannot contribute denominators",
11609
+ path: ["facts"]
11610
+ });
11611
+ }
11612
+ });
11613
+ var toolchainStepSchema = exports_external.object({
11614
+ step: idSchema,
11615
+ package: packageCoordinateSchema,
11616
+ export: exports_external.string().regex(/^[A-Za-z_$][A-Za-z0-9_$.-]*$/u),
11617
+ version: semverSchema,
11618
+ digest: digestSchema,
11619
+ capabilities: exports_external.array(idSchema).min(1),
11620
+ input_digest: digestSchema,
11621
+ output_digest: digestSchema
11622
+ }).strict().superRefine((value, context) => {
11623
+ addDuplicateIssues(value.capabilities, context, "capabilities");
11624
+ });
11625
+ var adapterDiagnosticSchema = exports_external.object({
11626
+ code: idSchema,
11627
+ fact_ref: canonicalRefSchema.optional(),
11628
+ severity: exports_external.enum(["info", "warning", "error"]),
11629
+ detail_digest: digestSchema
11630
+ }).strict();
11631
+ var indexerEvidenceAdapterResultSchema = exports_external.object({
11632
+ protocol: exports_external.literal("context.indexer.evidence-adapter-result/v1"),
11633
+ adapter: adapterIdentitySchema,
11634
+ authorized_scope: exports_external.object({
11635
+ source_ref: canonicalRefSchema,
11636
+ module_refs: exports_external.array(canonicalRefSchema),
11637
+ scope_digest: digestSchema
11638
+ }).strict(),
11639
+ input_digest: digestSchema,
11640
+ precedence: exports_external.number().int().nonnegative(),
11641
+ files: exports_external.array(indexerEvidenceAdapterFileSchema).min(1),
11642
+ diagnostics: exports_external.array(adapterDiagnosticSchema),
11643
+ toolchain: exports_external.array(toolchainStepSchema).min(1),
11644
+ output_digest: digestSchema
11645
+ }).strict().superRefine((value, context) => {
11646
+ addDuplicateIssues(value.authorized_scope.module_refs, context, "authorized_scope.module_refs");
11647
+ addDuplicateIssues(value.files.map((file) => file.file_ref), context, "files");
11648
+ addDuplicateIssues(value.toolchain.map((step) => step.step), context, "toolchain");
11649
+ });
11650
+ var FACT_PAYLOADS = new WeakMap;
11651
+ function canonicalFactPayload(value, seen = new WeakSet, path = "$") {
11652
+ if (value === null || typeof value === "boolean" || typeof value === "string") {
11653
+ return value;
11654
+ }
11655
+ if (typeof value === "number") {
11656
+ if (!Number.isFinite(value)) {
11657
+ throw new TypeError("Indexer Evidence Adapter fact payload numbers must be finite");
11658
+ }
11659
+ return value;
11660
+ }
11661
+ if (typeof value !== "object") {
11662
+ throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must contain only JSON values`);
11663
+ }
11664
+ if (seen.has(value)) {
11665
+ throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must be acyclic`);
11666
+ }
11667
+ seen.add(value);
11668
+ if (Array.isArray(value)) {
11669
+ const output2 = value.map((item, index) => canonicalFactPayload(item, seen, `${path}[${index}]`));
11670
+ seen.delete(value);
11671
+ return output2;
11672
+ }
11673
+ if (Object.prototype.toString.call(value) !== "[object Object]") {
11674
+ throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must use plain JSON objects; received ${Object.prototype.toString.call(value)}`);
11675
+ }
11676
+ const output = {};
11677
+ for (const [key, item] of Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)) {
11678
+ output[key] = canonicalFactPayload(item, seen, `${path}.${key}`);
11679
+ }
11680
+ seen.delete(value);
11681
+ return output;
11682
+ }
11683
+ function canonicalize(value) {
11684
+ if (Array.isArray(value))
11685
+ return value.map(canonicalize);
11686
+ if (value !== null && typeof value === "object") {
11687
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => [key, canonicalize(item)]));
11688
+ }
11689
+ return value;
11690
+ }
11691
+ function indexerEvidenceAdapterProtocolDigest(value) {
11692
+ const canonical = JSON.stringify(canonicalize(value));
11693
+ return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
11694
+ }
11695
+ function indexerEvidenceAdapterFileRef(input) {
11696
+ return `adapter-file:${indexerEvidenceAdapterProtocolDigest(input)}`;
11697
+ }
11698
+ function indexerEvidenceAdapterFactRef(input) {
11699
+ return `adapter-fact:${indexerEvidenceAdapterProtocolDigest(input)}`;
11700
+ }
11701
+ function createIndexerEvidenceAdapterFact(input) {
11702
+ const payload = canonicalFactPayload(input.payload);
11703
+ const qualifiedItemPath = input.qualified_item_path.length <= 1024 ? input.qualified_item_path : `${input.qualified_item_path.slice(0, 950)}#${indexerEvidenceAdapterProtocolDigest(input.qualified_item_path)}`;
11704
+ const locator = {
11705
+ source_ref: input.source_ref,
11706
+ module_ref: input.module_ref,
11707
+ normalized_path: input.normalized_path,
11708
+ qualified_item_path: qualifiedItemPath,
11709
+ signature_digest: indexerEvidenceAdapterProtocolDigest(input.signature)
11710
+ };
11711
+ const fact2 = {
11712
+ fact_ref: indexerEvidenceAdapterFactRef({ ...locator, kind: input.kind }),
11713
+ kind: input.kind,
11714
+ locator,
11715
+ payload_digest: indexerEvidenceAdapterProtocolDigest(payload),
11716
+ denominator: input.denominator
11717
+ };
11718
+ FACT_PAYLOADS.set(fact2, payload);
11719
+ return fact2;
11720
+ }
11721
+ function indexerEvidenceAdapterFactPayloads(result) {
11722
+ const payloads = result.files.flatMap((file) => file.facts.map((fact2) => {
11723
+ const payload = FACT_PAYLOADS.get(fact2);
11724
+ if (payload === undefined) {
11725
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is no longer materialized in this process`);
11726
+ }
11727
+ if (indexerEvidenceAdapterProtocolDigest(payload) !== fact2.payload_digest) {
11728
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is stale`);
11729
+ }
11730
+ return { fact_ref: fact2.fact_ref, payload };
11731
+ })).sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref));
11732
+ return assertIndexerOutputSafe({ channel: "ipc-envelope", value: payloads });
11733
+ }
11734
+ function materializeIndexerEvidenceAdapterResult(result) {
11735
+ return {
11736
+ result,
11737
+ fact_payloads: indexerEvidenceAdapterFactPayloads(result)
11738
+ };
11739
+ }
11740
+ function indexerEvidenceAdapterOutputDigest(value) {
11741
+ return indexerEvidenceAdapterProtocolDigest(value);
11742
+ }
11743
+ function compareCanonicalText(left, right) {
11744
+ if (left < right)
11745
+ return -1;
11746
+ if (left > right)
11747
+ return 1;
11748
+ return 0;
11749
+ }
11750
+ function buildIndexerEvidenceAdapterResult(input) {
11751
+ const canonical = {
11752
+ ...input,
11753
+ authorized_scope: {
11754
+ ...input.authorized_scope,
11755
+ module_refs: [...input.authorized_scope.module_refs].sort(compareCanonicalText)
11756
+ },
11757
+ files: input.files.map((file) => ({
11758
+ ...file,
11759
+ facts: [...file.facts].sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref))
11760
+ })).sort((left, right) => compareCanonicalText(left.file_ref, right.file_ref)),
11761
+ diagnostics: [...input.diagnostics].sort((left, right) => compareCanonicalText(left.fact_ref ?? "", right.fact_ref ?? "") || compareCanonicalText(left.code, right.code) || compareCanonicalText(left.severity, right.severity) || compareCanonicalText(left.detail_digest, right.detail_digest)),
11762
+ toolchain: input.toolchain.map((step) => ({
11763
+ ...step,
11764
+ capabilities: [...step.capabilities].sort(compareCanonicalText)
11765
+ }))
11766
+ };
11767
+ const payloads = new Map;
11768
+ for (const file of canonical.files) {
11769
+ for (const fact2 of file.facts) {
11770
+ const payload = FACT_PAYLOADS.get(fact2);
11771
+ if (payload !== undefined)
11772
+ payloads.set(fact2.fact_ref, payload);
11773
+ }
11774
+ }
11775
+ const parsed = indexerEvidenceAdapterResultSchema.parse({
11776
+ ...canonical,
11777
+ output_digest: indexerEvidenceAdapterOutputDigest(canonical)
11778
+ });
11779
+ for (const file of parsed.files) {
11780
+ for (const fact2 of file.facts) {
11781
+ const payload = payloads.get(fact2.fact_ref);
11782
+ if (payload !== undefined)
11783
+ FACT_PAYLOADS.set(fact2, payload);
11784
+ }
11785
+ }
11786
+ return assertIndexerOutputSafe({ channel: "success-payload", value: parsed });
11787
+ }
11378
11788
  // ../core/src/errors/httpStatus.ts
11379
11789
  var ERROR_CODE_HTTP_STATUS = {
11380
11790
  ["VALIDATION_FAILED" /* VALIDATION_FAILED */]: 400,
@@ -11490,7 +11900,15 @@ var DEFAULT_CONTENT_TYPES = [
11490
11900
  {
11491
11901
  id: "typescript",
11492
11902
  category: "code",
11493
- match: { extensions: [".ts", ".tsx"] },
11903
+ match: { extensions: [".ts", ".tsx", ".mts", ".cts"] },
11904
+ cas: { encoding: "utf8", hashInput: "content" },
11905
+ pipeline: { digest: ["ast", "summary"], extraction: ["entities", "relations"] },
11906
+ display: { icon: "\uD83D\uDCDC", renderer: "code" }
11907
+ },
11908
+ {
11909
+ id: "javascript",
11910
+ category: "code",
11911
+ match: { extensions: [".js", ".jsx", ".mjs", ".cjs"] },
11494
11912
  cas: { encoding: "utf8", hashInput: "content" },
11495
11913
  pipeline: { digest: ["ast", "summary"], extraction: ["entities", "relations"] },
11496
11914
  display: { icon: "\uD83D\uDCDC", renderer: "code" }
@@ -11598,6 +12016,50 @@ var INDEXABLE_EXTENSIONS = new Set([
11598
12016
  var UPLOAD_ALLOWED_EXTENSIONS = collectExtensions(() => true);
11599
12017
  var TEXT_EXTENSIONS = collectExtensions((definition) => definition.cas.encoding === "utf8");
11600
12018
  var UPLOAD_MAX_FILE_SIZE = 5 * 1024 * 1024;
12019
+ // src/ecmaScriptLanguage.ts
12020
+ var LANGUAGE_BY_EXTENSION = {
12021
+ ".ts": "typescript",
12022
+ ".tsx": "tsx",
12023
+ ".mts": "typescript",
12024
+ ".cts": "typescript",
12025
+ ".js": "javascript",
12026
+ ".jsx": "jsx",
12027
+ ".mjs": "javascript",
12028
+ ".cjs": "javascript"
12029
+ };
12030
+ var EXTRACT_TS_CAPABILITIES = [
12031
+ "commonjs-module",
12032
+ "esm-module",
12033
+ "javascript-ast",
12034
+ "jsx-ast",
12035
+ "parser.javascript",
12036
+ "parser.typescript",
12037
+ "static-call-relations",
12038
+ "tsx-ast",
12039
+ "typescript-ast"
12040
+ ];
12041
+ var EXTRACT_TS_COVERAGE_TIER = "ast-catalog";
12042
+ var ecmaScriptLanguage = (filePath) => {
12043
+ const lower = filePath.toLowerCase();
12044
+ const extension = Object.keys(LANGUAGE_BY_EXTENSION).find((candidate) => lower.endsWith(candidate));
12045
+ return extension ? LANGUAGE_BY_EXTENSION[extension] : "typescript";
12046
+ };
12047
+ var isJsxLikePath = (filePath) => {
12048
+ const language = ecmaScriptLanguage(filePath);
12049
+ return language === "tsx" || language === "jsx";
12050
+ };
12051
+ var isJavaScriptPath = (filePath) => {
12052
+ const language = ecmaScriptLanguage(filePath);
12053
+ return language === "javascript" || language === "jsx";
12054
+ };
12055
+ var packageLanguage = (filePaths) => {
12056
+ const hasJavaScript = filePaths.some(isJavaScriptPath);
12057
+ const hasTypeScript = filePaths.some((filePath) => !isJavaScriptPath(filePath));
12058
+ if (hasJavaScript && hasTypeScript)
12059
+ return "ecmascript";
12060
+ return hasJavaScript ? "javascript" : "typescript";
12061
+ };
12062
+
11601
12063
  // src/pathUtils.ts
11602
12064
  import { posix as posix2 } from "node:path";
11603
12065
 
@@ -11781,8 +12243,9 @@ function resolveTsConfigCandidates(specifier, resolver) {
11781
12243
  }
11782
12244
 
11783
12245
  // src/pathUtils.ts
11784
- var SOURCE_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
11785
- var BUILD_EXTENSIONS = [".js", ".jsx", ".mjs", ".cjs"];
12246
+ var TYPESCRIPT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
12247
+ var JAVASCRIPT_EXTENSIONS = [".js", ".jsx", ".mjs", ".cjs"];
12248
+ var SOURCE_EXTENSIONS = [...TYPESCRIPT_EXTENSIONS, ...JAVASCRIPT_EXTENSIONS];
11786
12249
  var DECLARATION_EXTENSIONS = [".d.ts", ".d.mts", ".d.cts"];
11787
12250
  var KNOWN_CODE_SUFFIXES = [
11788
12251
  ...DECLARATION_EXTENSIONS,
@@ -11794,7 +12257,7 @@ var KNOWN_CODE_SUFFIXES = [
11794
12257
  ".system.js",
11795
12258
  ".min.js",
11796
12259
  ...SOURCE_EXTENSIONS,
11797
- ...BUILD_EXTENSIONS
12260
+ ...JAVASCRIPT_EXTENSIONS
11798
12261
  ];
11799
12262
  var BUILD_OUTPUT_ROOTS = new Set(["dist", "lib", "build", "output", "out"]);
11800
12263
  var BUILD_FORMAT_DIRS = new Set([
@@ -11857,25 +12320,27 @@ var createCandidatePaths = (value, options = {}) => {
11857
12320
  return [];
11858
12321
  const withoutExtension = removeKnownExtension(normalized);
11859
12322
  const mappedSourcePaths = buildToSourcePaths(withoutExtension);
11860
- const directFirst = SOURCE_EXTENSIONS.some((extension) => normalized.endsWith(extension));
12323
+ const isBuildOutput = buildToSourcePaths(withoutExtension).length > 0;
12324
+ const directFirst = SOURCE_EXTENSIONS.some((extension) => normalized.endsWith(extension)) && !isBuildOutput;
12325
+ const preferredExtensions = options.preferJavaScript ? [...JAVASCRIPT_EXTENSIONS, ...TYPESCRIPT_EXTENSIONS] : [...TYPESCRIPT_EXTENSIONS, ...JAVASCRIPT_EXTENSIONS];
11861
12326
  const bases = directFirst ? unique([normalized, withoutExtension, ...mappedSourcePaths]) : unique([...mappedSourcePaths, normalized, withoutExtension]);
11862
12327
  const candidates = new Set;
11863
12328
  for (const base of bases) {
11864
12329
  if (SOURCE_EXTENSIONS.some((ext) => base.endsWith(ext))) {
11865
12330
  candidates.add(base);
11866
12331
  }
11867
- for (const extension of SOURCE_EXTENSIONS) {
12332
+ for (const extension of preferredExtensions) {
11868
12333
  candidates.add(`${base}${extension}`);
11869
12334
  candidates.add(posix2.join(base, `index${extension}`));
11870
12335
  }
11871
- if (BUILD_EXTENSIONS.some((extension) => normalized.endsWith(extension))) {
11872
- for (const extension of SOURCE_EXTENSIONS) {
12336
+ if (JAVASCRIPT_EXTENSIONS.some((extension) => normalized.endsWith(extension))) {
12337
+ for (const extension of preferredExtensions) {
11873
12338
  candidates.add(removeKnownExtension(normalized) + extension);
11874
12339
  }
11875
12340
  }
11876
12341
  }
11877
12342
  if (options.allowIndexFallback ?? true) {
11878
- for (const extension of SOURCE_EXTENSIONS) {
12343
+ for (const extension of preferredExtensions) {
11879
12344
  candidates.add(`src/index${extension}`);
11880
12345
  }
11881
12346
  }
@@ -11896,7 +12361,10 @@ var resolveImportSourcePath = async (fromFile, specifier, fs, resolver) => {
11896
12361
  if (resolver === undefined)
11897
12362
  return null;
11898
12363
  for (const target of resolveTsConfigCandidates(specifier, resolver)) {
11899
- for (const candidate of createCandidatePaths(target, { allowIndexFallback: false })) {
12364
+ for (const candidate of createCandidatePaths(target, {
12365
+ allowIndexFallback: false,
12366
+ preferJavaScript: isJavaScriptPath(fromFile)
12367
+ })) {
11900
12368
  if (await fs.exists(candidate))
11901
12369
  return normalizeRelativePath(candidate);
11902
12370
  }
@@ -11904,7 +12372,7 @@ var resolveImportSourcePath = async (fromFile, specifier, fs, resolver) => {
11904
12372
  return null;
11905
12373
  }
11906
12374
  const baseDir = posix2.dirname(fromFile);
11907
- for (const candidate of createCandidatePaths(specifier)) {
12375
+ for (const candidate of createCandidatePaths(specifier, { preferJavaScript: isJavaScriptPath(fromFile) })) {
11908
12376
  const fullPath = baseDir === "." ? candidate : posix2.join(baseDir, candidate);
11909
12377
  if (await fs.exists(fullPath)) {
11910
12378
  return normalizeRelativePath(fullPath);
@@ -12053,7 +12521,7 @@ var detectEntries = async (manifest, fs) => {
12053
12521
  package: {
12054
12522
  name: readString(pkg.name) ?? "unknown-package",
12055
12523
  kind: detectPackageKind(pkg),
12056
- language: "typescript",
12524
+ language: packageLanguage(entries.map((entry) => entry.path)),
12057
12525
  version: readString(pkg.version) ?? undefined
12058
12526
  },
12059
12527
  entries,
@@ -12120,6 +12588,23 @@ var fileInfoSchema = exports_external.object({
12120
12588
  language: exports_external.string().min(1),
12121
12589
  lines: exports_external.number().int().nonnegative()
12122
12590
  });
12591
+ var extractionDiagnosticSchema = exports_external.object({
12592
+ code: exports_external.string().min(1),
12593
+ severity: exports_external.enum(["info", "warning", "error"]),
12594
+ file: exports_external.string().min(1),
12595
+ line: exports_external.number().int().positive(),
12596
+ column: exports_external.number().int().positive()
12597
+ });
12598
+ var extractionCoverageSchema = exports_external.object({
12599
+ tier: exports_external.enum(["ast-catalog", "lightweight-evidence"]),
12600
+ capabilities: exports_external.array(exports_external.string().min(1)),
12601
+ files: exports_external.array(exports_external.object({
12602
+ path: exports_external.string().min(1),
12603
+ disposition: exports_external.enum(["analyzed", "unsupported", "excluded"]),
12604
+ diagnosticCodes: exports_external.array(exports_external.string().min(1))
12605
+ })),
12606
+ diagnostics: exports_external.array(extractionDiagnosticSchema)
12607
+ });
12123
12608
  var extractionMetaSchema = exports_external.object({
12124
12609
  extractedAt: exports_external.string().datetime(),
12125
12610
  pluginId: exports_external.string().min(1),
@@ -12146,6 +12631,7 @@ var extractionResultSchema = exports_external.object({
12146
12631
  files: exports_external.array(fileInfoSchema),
12147
12632
  symbols: exports_external.array(symbolInfoSchema),
12148
12633
  relations: exports_external.array(relationInfoSchema),
12634
+ coverage: extractionCoverageSchema.optional(),
12149
12635
  stats: extractionStatsSchema
12150
12636
  });
12151
12637
  var digestStatsSchema = exports_external.object({
@@ -12162,6 +12648,7 @@ var digestDataSchema = exports_external.object({
12162
12648
  files: exports_external.array(fileInfoSchema),
12163
12649
  symbols: exports_external.array(symbolInfoSchema),
12164
12650
  relations: exports_external.array(relationInfoSchema),
12651
+ coverage: extractionCoverageSchema.optional(),
12165
12652
  stats: digestStatsSchema
12166
12653
  });
12167
12654
  var symbolDiffSchema = exports_external.object({
@@ -12264,7 +12751,16 @@ class ExtractionPluginRegistry {
12264
12751
  import { execFile } from "node:child_process";
12265
12752
  import { promisify } from "node:util";
12266
12753
  var execFileAsync = promisify(execFile);
12267
- var SUPPORTED_EXTENSIONS = new Set([".ts", ".tsx"]);
12754
+ var SUPPORTED_EXTENSIONS = new Set([
12755
+ ".ts",
12756
+ ".tsx",
12757
+ ".mts",
12758
+ ".cts",
12759
+ ".js",
12760
+ ".jsx",
12761
+ ".mjs",
12762
+ ".cjs"
12763
+ ]);
12268
12764
  var MANIFEST_FILES = [
12269
12765
  "package.json",
12270
12766
  "pyproject.toml",
@@ -12316,10 +12812,613 @@ var codeExtractRunnerInputSchema = exports_external.object({
12316
12812
  worktreeContentHash: exports_external.string().min(1).optional()
12317
12813
  }).optional()
12318
12814
  });
12815
+ // ../extract/src/evidenceAdapter.ts
12816
+ function fact2(input) {
12817
+ return createIndexerEvidenceAdapterFact({
12818
+ source_ref: input.sourceRef,
12819
+ module_ref: input.moduleRef,
12820
+ normalized_path: input.normalizedPath,
12821
+ qualified_item_path: input.qualifiedItemPath,
12822
+ kind: input.kind,
12823
+ signature: input.signature,
12824
+ payload: input.payload,
12825
+ denominator: input.denominator
12826
+ });
12827
+ }
12828
+ function semanticExtractionPayload(extraction) {
12829
+ return {
12830
+ version: extraction.version,
12831
+ meta: {
12832
+ pluginId: extraction.meta.pluginId,
12833
+ commitHash: extraction.meta.commitHash,
12834
+ language: extraction.meta.language
12835
+ },
12836
+ package: extraction.package,
12837
+ files: extraction.files,
12838
+ symbols: extraction.symbols,
12839
+ relations: extraction.relations,
12840
+ coverage: extraction.coverage,
12841
+ stats: extraction.stats
12842
+ };
12843
+ }
12844
+ function relationSourceFile(relation, symbols) {
12845
+ const candidates = symbols.filter((symbol) => symbol.name === relation.from);
12846
+ if (candidates.length === 1)
12847
+ return candidates[0].file;
12848
+ if (relation.line !== undefined) {
12849
+ const containing = candidates.filter((symbol) => symbol.line <= relation.line && symbol.endLine >= relation.line);
12850
+ if (containing.length === 1)
12851
+ return containing[0].file;
12852
+ }
12853
+ return null;
12854
+ }
12855
+ function diagnosticPayload(diagnostic) {
12856
+ return {
12857
+ code: diagnostic.code,
12858
+ severity: diagnostic.severity,
12859
+ file: diagnostic.file,
12860
+ line: diagnostic.line,
12861
+ column: diagnostic.column
12862
+ };
12863
+ }
12864
+ function extractionResultToEvidenceAdapterResult(extraction, invocation) {
12865
+ const coverage = extraction.coverage;
12866
+ if (!coverage) {
12867
+ throw new TypeError("ExtractionResult coverage is required for Evidence Adapter Result conversion");
12868
+ }
12869
+ if (coverage.capabilities.length === 0) {
12870
+ throw new TypeError("ExtractionResult coverage must declare at least one parser capability");
12871
+ }
12872
+ const coverageByPath = new Map(coverage.files.map((file) => [file.path, file]));
12873
+ const fileInfoByPath = new Map(extraction.files.map((file) => [file.path, file]));
12874
+ for (const file of extraction.files) {
12875
+ if (!coverageByPath.has(file.path)) {
12876
+ throw new TypeError(`ExtractionResult file ${file.path} has no coverage disposition`);
12877
+ }
12878
+ }
12879
+ for (const symbol of extraction.symbols) {
12880
+ const disposition = coverageByPath.get(symbol.file)?.disposition;
12881
+ if (disposition !== "analyzed") {
12882
+ throw new TypeError(`ExtractionResult symbol ${symbol.name} belongs to a file without analyzed disposition`);
12883
+ }
12884
+ }
12885
+ const role = invocation.role ?? "primary-owner";
12886
+ const ownsDenominators = role === "primary-owner" && coverage.tier === "ast-catalog";
12887
+ const generatedDiagnostics = [];
12888
+ const relationsByFile = new Map;
12889
+ for (const relation of extraction.relations) {
12890
+ const file = relationSourceFile(relation, extraction.symbols);
12891
+ if (file === null || coverageByPath.get(file)?.disposition !== "analyzed") {
12892
+ generatedDiagnostics.push({
12893
+ code: "relation-locator-unresolved",
12894
+ severity: "warning",
12895
+ detail_digest: indexerEvidenceAdapterProtocolDigest(relation)
12896
+ });
12897
+ continue;
12898
+ }
12899
+ const current = relationsByFile.get(file) ?? [];
12900
+ current.push(relation);
12901
+ relationsByFile.set(file, current);
12902
+ }
12903
+ const files = coverage.files.map((coverageFile) => {
12904
+ const normalizedPath2 = coverageFile.path;
12905
+ const fileRef = indexerEvidenceAdapterFileRef({
12906
+ source_ref: invocation.authorized_scope.source_ref,
12907
+ module_ref: invocation.module_ref,
12908
+ normalized_path: normalizedPath2
12909
+ });
12910
+ const fileInfo = fileInfoByPath.get(normalizedPath2);
12911
+ if (coverageFile.disposition === "analyzed" && !fileInfo) {
12912
+ throw new TypeError(`Analyzed file ${normalizedPath2} has no ExtractionResult file metadata`);
12913
+ }
12914
+ const facts = [];
12915
+ if (coverageFile.disposition === "analyzed" && fileInfo) {
12916
+ facts.push(fact2({
12917
+ sourceRef: invocation.authorized_scope.source_ref,
12918
+ moduleRef: invocation.module_ref,
12919
+ normalizedPath: normalizedPath2,
12920
+ qualifiedItemPath: "file",
12921
+ kind: "source-file",
12922
+ signature: { path: normalizedPath2, language: fileInfo.language },
12923
+ payload: fileInfo,
12924
+ denominator: ownsDenominators ? "eligible-file" : "none"
12925
+ }));
12926
+ facts.push(fact2({
12927
+ sourceRef: invocation.authorized_scope.source_ref,
12928
+ moduleRef: invocation.module_ref,
12929
+ normalizedPath: normalizedPath2,
12930
+ qualifiedItemPath: "loc",
12931
+ kind: "source-loc",
12932
+ signature: { path: normalizedPath2 },
12933
+ payload: { lines: fileInfo.lines },
12934
+ denominator: ownsDenominators ? "loc" : "none"
12935
+ }));
12936
+ for (const symbol of extraction.symbols.filter((item) => item.file === normalizedPath2)) {
12937
+ facts.push(fact2({
12938
+ sourceRef: invocation.authorized_scope.source_ref,
12939
+ moduleRef: invocation.module_ref,
12940
+ normalizedPath: normalizedPath2,
12941
+ qualifiedItemPath: `symbol:${symbol.kind}:${symbol.name}@${symbol.line}`,
12942
+ kind: "code-symbol",
12943
+ signature: {
12944
+ name: symbol.name,
12945
+ kind: symbol.kind,
12946
+ signature: symbol.signature ?? null,
12947
+ params: symbol.params ?? null,
12948
+ returnType: symbol.returnType ?? null,
12949
+ typeAnnotation: symbol.typeAnnotation ?? null
12950
+ },
12951
+ payload: symbol,
12952
+ denominator: ownsDenominators ? "symbol" : "none"
12953
+ }));
12954
+ }
12955
+ for (const relation of relationsByFile.get(normalizedPath2) ?? []) {
12956
+ facts.push(fact2({
12957
+ sourceRef: invocation.authorized_scope.source_ref,
12958
+ moduleRef: invocation.module_ref,
12959
+ normalizedPath: normalizedPath2,
12960
+ qualifiedItemPath: `relation:${relation.type}:${relation.from}->${relation.to}@${relation.line ?? 0}`,
12961
+ kind: "code-relation",
12962
+ signature: relation,
12963
+ payload: relation,
12964
+ denominator: "none"
12965
+ }));
12966
+ }
12967
+ }
12968
+ return {
12969
+ file_ref: fileRef,
12970
+ source_ref: invocation.authorized_scope.source_ref,
12971
+ module_ref: invocation.module_ref,
12972
+ normalized_path: normalizedPath2,
12973
+ role,
12974
+ coverage_tier: coverage.tier,
12975
+ disposition: coverageFile.disposition,
12976
+ facts
12977
+ };
12978
+ });
12979
+ const diagnostics = [
12980
+ ...coverage.diagnostics.map((diagnostic) => {
12981
+ const coverageFile = coverageByPath.get(diagnostic.file);
12982
+ const fileRef = coverageFile ? indexerEvidenceAdapterFileRef({
12983
+ source_ref: invocation.authorized_scope.source_ref,
12984
+ module_ref: invocation.module_ref,
12985
+ normalized_path: diagnostic.file
12986
+ }) : undefined;
12987
+ return {
12988
+ code: diagnostic.code,
12989
+ severity: diagnostic.severity,
12990
+ detail_digest: indexerEvidenceAdapterProtocolDigest(diagnosticPayload(diagnostic)),
12991
+ ...fileRef ? { fact_ref: fileRef } : {}
12992
+ };
12993
+ }),
12994
+ ...generatedDiagnostics
12995
+ ];
12996
+ const parserOutputDigest = indexerEvidenceAdapterProtocolDigest(semanticExtractionPayload(extraction));
12997
+ return buildIndexerEvidenceAdapterResult({
12998
+ protocol: "context.indexer.evidence-adapter-result/v1",
12999
+ adapter: invocation.adapter,
13000
+ authorized_scope: invocation.authorized_scope,
13001
+ input_digest: invocation.input_digest,
13002
+ precedence: invocation.precedence,
13003
+ files,
13004
+ diagnostics,
13005
+ toolchain: [{
13006
+ step: "parse-source",
13007
+ package: invocation.adapter.package,
13008
+ export: invocation.adapter.export,
13009
+ version: invocation.adapter.version,
13010
+ digest: invocation.adapter.digest,
13011
+ capabilities: coverage.capabilities,
13012
+ input_digest: invocation.input_digest,
13013
+ output_digest: parserOutputDigest
13014
+ }]
13015
+ });
13016
+ }
13017
+ // ../../node_modules/.bun/eslint-visitor-keys@5.0.1/node_modules/eslint-visitor-keys/lib/visitor-keys.js
13018
+ var KEYS = {
13019
+ ArrayExpression: ["elements"],
13020
+ ArrayPattern: ["elements"],
13021
+ ArrowFunctionExpression: ["params", "body"],
13022
+ AssignmentExpression: ["left", "right"],
13023
+ AssignmentPattern: ["left", "right"],
13024
+ AwaitExpression: ["argument"],
13025
+ BinaryExpression: ["left", "right"],
13026
+ BlockStatement: ["body"],
13027
+ BreakStatement: ["label"],
13028
+ CallExpression: ["callee", "arguments"],
13029
+ CatchClause: ["param", "body"],
13030
+ ChainExpression: ["expression"],
13031
+ ClassBody: ["body"],
13032
+ ClassDeclaration: ["id", "superClass", "body"],
13033
+ ClassExpression: ["id", "superClass", "body"],
13034
+ ConditionalExpression: ["test", "consequent", "alternate"],
13035
+ ContinueStatement: ["label"],
13036
+ DebuggerStatement: [],
13037
+ DoWhileStatement: ["body", "test"],
13038
+ EmptyStatement: [],
13039
+ ExperimentalRestProperty: ["argument"],
13040
+ ExperimentalSpreadProperty: ["argument"],
13041
+ ExportAllDeclaration: ["exported", "source", "attributes"],
13042
+ ExportDefaultDeclaration: ["declaration"],
13043
+ ExportNamedDeclaration: [
13044
+ "declaration",
13045
+ "specifiers",
13046
+ "source",
13047
+ "attributes"
13048
+ ],
13049
+ ExportSpecifier: ["local", "exported"],
13050
+ ExpressionStatement: ["expression"],
13051
+ ForInStatement: ["left", "right", "body"],
13052
+ ForOfStatement: ["left", "right", "body"],
13053
+ ForStatement: ["init", "test", "update", "body"],
13054
+ FunctionDeclaration: ["id", "params", "body"],
13055
+ FunctionExpression: ["id", "params", "body"],
13056
+ Identifier: [],
13057
+ IfStatement: ["test", "consequent", "alternate"],
13058
+ ImportAttribute: ["key", "value"],
13059
+ ImportDeclaration: ["specifiers", "source", "attributes"],
13060
+ ImportDefaultSpecifier: ["local"],
13061
+ ImportExpression: ["source", "options"],
13062
+ ImportNamespaceSpecifier: ["local"],
13063
+ ImportSpecifier: ["imported", "local"],
13064
+ JSXAttribute: ["name", "value"],
13065
+ JSXClosingElement: ["name"],
13066
+ JSXClosingFragment: [],
13067
+ JSXElement: ["openingElement", "children", "closingElement"],
13068
+ JSXEmptyExpression: [],
13069
+ JSXExpressionContainer: ["expression"],
13070
+ JSXFragment: ["openingFragment", "children", "closingFragment"],
13071
+ JSXIdentifier: [],
13072
+ JSXMemberExpression: ["object", "property"],
13073
+ JSXNamespacedName: ["namespace", "name"],
13074
+ JSXOpeningElement: ["name", "attributes"],
13075
+ JSXOpeningFragment: [],
13076
+ JSXSpreadAttribute: ["argument"],
13077
+ JSXSpreadChild: ["expression"],
13078
+ JSXText: [],
13079
+ LabeledStatement: ["label", "body"],
13080
+ Literal: [],
13081
+ LogicalExpression: ["left", "right"],
13082
+ MemberExpression: ["object", "property"],
13083
+ MetaProperty: ["meta", "property"],
13084
+ MethodDefinition: ["key", "value"],
13085
+ NewExpression: ["callee", "arguments"],
13086
+ ObjectExpression: ["properties"],
13087
+ ObjectPattern: ["properties"],
13088
+ PrivateIdentifier: [],
13089
+ Program: ["body"],
13090
+ Property: ["key", "value"],
13091
+ PropertyDefinition: ["key", "value"],
13092
+ RestElement: ["argument"],
13093
+ ReturnStatement: ["argument"],
13094
+ SequenceExpression: ["expressions"],
13095
+ SpreadElement: ["argument"],
13096
+ StaticBlock: ["body"],
13097
+ Super: [],
13098
+ SwitchCase: ["test", "consequent"],
13099
+ SwitchStatement: ["discriminant", "cases"],
13100
+ TaggedTemplateExpression: ["tag", "quasi"],
13101
+ TemplateElement: [],
13102
+ TemplateLiteral: ["quasis", "expressions"],
13103
+ ThisExpression: [],
13104
+ ThrowStatement: ["argument"],
13105
+ TryStatement: ["block", "handler", "finalizer"],
13106
+ UnaryExpression: ["argument"],
13107
+ UpdateExpression: ["argument"],
13108
+ VariableDeclaration: ["declarations"],
13109
+ VariableDeclarator: ["id", "init"],
13110
+ WhileStatement: ["test", "body"],
13111
+ WithStatement: ["object", "body"],
13112
+ YieldExpression: ["argument"]
13113
+ };
13114
+ var NODE_TYPES = Object.keys(KEYS);
13115
+ for (const type of NODE_TYPES) {
13116
+ Object.freeze(KEYS[type]);
13117
+ }
13118
+ Object.freeze(KEYS);
13119
+ var visitor_keys_default = KEYS;
13120
+
13121
+ // ../../node_modules/.bun/eslint-visitor-keys@5.0.1/node_modules/eslint-visitor-keys/lib/index.js
13122
+ var KEY_BLACKLIST = new Set([
13123
+ "parent",
13124
+ "leadingComments",
13125
+ "trailingComments"
13126
+ ]);
13127
+ function unionWith(additionalKeys) {
13128
+ const retv = Object.assign({}, visitor_keys_default);
13129
+ for (const type of Object.keys(additionalKeys)) {
13130
+ if (Object.hasOwn(retv, type)) {
13131
+ const keys = new Set(additionalKeys[type]);
13132
+ for (const key of retv[type]) {
13133
+ keys.add(key);
13134
+ }
13135
+ retv[type] = Object.freeze(Array.from(keys));
13136
+ } else {
13137
+ retv[type] = Object.freeze(Array.from(additionalKeys[type]));
13138
+ }
13139
+ }
13140
+ return Object.freeze(retv);
13141
+ }
13142
+
13143
+ // ../../node_modules/.bun/toml-eslint-parser@1.0.3/node_modules/toml-eslint-parser/lib/index.mjs
13144
+ function last(arr) {
13145
+ return arr[arr.length - 1] ?? null;
13146
+ }
13147
+ var TOMLVerImpl = class {
13148
+ constructor(major, minor) {
13149
+ this.major = major;
13150
+ this.minor = minor;
13151
+ }
13152
+ lt(major, minor) {
13153
+ return this.major < major || this.major === major && this.minor < minor;
13154
+ }
13155
+ gte(major, minor) {
13156
+ return this.major > major || this.major === major && this.minor >= minor;
13157
+ }
13158
+ };
13159
+ var TOML_VERSION_1_0 = new TOMLVerImpl(1, 0);
13160
+ var TOML_VERSION_1_1 = new TOMLVerImpl(1, 1);
13161
+ var CodePoint = {
13162
+ EOF: -1,
13163
+ NULL: 0,
13164
+ SOH: 1,
13165
+ BACKSPACE: 8,
13166
+ TABULATION: 9,
13167
+ LINE_FEED: 10,
13168
+ FORM_FEED: 12,
13169
+ CARRIAGE_RETURN: 13,
13170
+ ESCAPE: 27,
13171
+ SO: 14,
13172
+ US: 31,
13173
+ SPACE: 32,
13174
+ QUOTATION_MARK: 34,
13175
+ HASH: 35,
13176
+ SINGLE_QUOTE: 39,
13177
+ PLUS_SIGN: 43,
13178
+ COMMA: 44,
13179
+ DASH: 45,
13180
+ DOT: 46,
13181
+ DIGIT_0: 48,
13182
+ DIGIT_1: 49,
13183
+ DIGIT_2: 50,
13184
+ DIGIT_3: 51,
13185
+ DIGIT_7: 55,
13186
+ DIGIT_9: 57,
13187
+ COLON: 58,
13188
+ EQUALS_SIGN: 61,
13189
+ LATIN_CAPITAL_A: 65,
13190
+ LATIN_CAPITAL_E: 69,
13191
+ LATIN_CAPITAL_F: 70,
13192
+ LATIN_CAPITAL_T: 84,
13193
+ LATIN_CAPITAL_U: 85,
13194
+ LATIN_CAPITAL_Z: 90,
13195
+ LEFT_BRACKET: 91,
13196
+ BACKSLASH: 92,
13197
+ RIGHT_BRACKET: 93,
13198
+ UNDERSCORE: 95,
13199
+ LATIN_SMALL_A: 97,
13200
+ LATIN_SMALL_B: 98,
13201
+ LATIN_SMALL_E: 101,
13202
+ LATIN_SMALL_F: 102,
13203
+ LATIN_SMALL_I: 105,
13204
+ LATIN_SMALL_L: 108,
13205
+ LATIN_SMALL_N: 110,
13206
+ LATIN_SMALL_O: 111,
13207
+ LATIN_SMALL_R: 114,
13208
+ LATIN_SMALL_S: 115,
13209
+ LATIN_SMALL_T: 116,
13210
+ LATIN_SMALL_U: 117,
13211
+ LATIN_SMALL_X: 120,
13212
+ LATIN_SMALL_Z: 122,
13213
+ LEFT_BRACE: 123,
13214
+ RIGHT_BRACE: 125,
13215
+ TILDE: 126,
13216
+ DELETE: 127,
13217
+ PAD: 128,
13218
+ SUPERSCRIPT_TWO: 178,
13219
+ SUPERSCRIPT_THREE: 179,
13220
+ SUPERSCRIPT_ONE: 185,
13221
+ VULGAR_FRACTION_ONE_QUARTER: 188,
13222
+ VULGAR_FRACTION_THREE_QUARTERS: 190,
13223
+ LATIN_CAPITAL_LETTER_A_WITH_GRAVE: 192,
13224
+ LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS: 214,
13225
+ LATIN_CAPITAL_LETTER_O_WITH_STROKE: 216,
13226
+ LATIN_SMALL_LETTER_O_WITH_DIAERESIS: 246,
13227
+ LATIN_SMALL_LETTER_O_WITH_STROKE: 248,
13228
+ GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL: 891,
13229
+ GREEK_CAPITAL_LETTER_YOT: 895,
13230
+ CP_1FFF: 8191,
13231
+ ZERO_WIDTH_NON_JOINER: 8204,
13232
+ ZERO_WIDTH_JOINER: 8205,
13233
+ UNDERTIE: 8255,
13234
+ CHARACTER_TIE: 8256,
13235
+ SUPERSCRIPT_ZERO: 8304,
13236
+ CP_218F: 8591,
13237
+ CIRCLED_DIGIT_ONE: 9312,
13238
+ NEGATIVE_CIRCLED_DIGIT_ZERO: 9471,
13239
+ GLAGOLITIC_CAPITAL_LETTER_AZU: 11264,
13240
+ CP_2FEF: 12271,
13241
+ IDEOGRAPHIC_COMMA: 12289,
13242
+ CP_D7FF: 55295,
13243
+ CP_E000: 57344,
13244
+ CJK_COMPATIBILITY_IDEOGRAPH_F900: 63744,
13245
+ ARABIC_LIGATURE_SALAAMUHU_ALAYNAA: 64975,
13246
+ ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM: 65008,
13247
+ REPLACEMENT_CHARACTER: 65533,
13248
+ LINEAR_B_SYLLABLE_B008_A: 65536,
13249
+ CP_EFFFF: 983039,
13250
+ CP_10FFFF: 1114111
13251
+ };
13252
+ var ESCAPES_1_0 = {
13253
+ [CodePoint.QUOTATION_MARK]: CodePoint.QUOTATION_MARK,
13254
+ [CodePoint.BACKSLASH]: CodePoint.BACKSLASH,
13255
+ [CodePoint.LATIN_SMALL_B]: CodePoint.BACKSPACE,
13256
+ [CodePoint.LATIN_SMALL_F]: CodePoint.FORM_FEED,
13257
+ [CodePoint.LATIN_SMALL_N]: CodePoint.LINE_FEED,
13258
+ [CodePoint.LATIN_SMALL_R]: CodePoint.CARRIAGE_RETURN,
13259
+ [CodePoint.LATIN_SMALL_T]: CodePoint.TABULATION
13260
+ };
13261
+ var ESCAPES_LATEST = {
13262
+ ...ESCAPES_1_0,
13263
+ [CodePoint.LATIN_SMALL_E]: CodePoint.ESCAPE
13264
+ };
13265
+ var VALUE_KIND_VALUE = Symbol("VALUE_KIND_VALUE");
13266
+ var VALUE_KIND_INTERMEDIATE = Symbol("VALUE_KIND_INTERMEDIATE");
13267
+ var tomlKeys = {
13268
+ Program: ["body"],
13269
+ TOMLTopLevelTable: ["body"],
13270
+ TOMLTable: ["key", "body"],
13271
+ TOMLKeyValue: ["key", "value"],
13272
+ TOMLKey: ["keys"],
13273
+ TOMLArray: ["elements"],
13274
+ TOMLInlineTable: ["body"],
13275
+ TOMLBare: [],
13276
+ TOMLQuoted: [],
13277
+ TOMLValue: []
13278
+ };
13279
+ var KEYS2 = unionWith(tomlKeys);
13280
+ var getStaticTOMLValue = generateConvertTOMLValue((node2) => node2.value);
13281
+ function generateConvertTOMLValue(convertValue) {
13282
+ function resolveValue(node2, baseTable) {
13283
+ return resolver[node2.type](node2, baseTable);
13284
+ }
13285
+ const resolver = {
13286
+ Program(node2, baseTable = {}) {
13287
+ return resolveValue(node2.body[0], baseTable);
13288
+ },
13289
+ TOMLTopLevelTable(node2, baseTable = {}) {
13290
+ for (const body of node2.body)
13291
+ resolveValue(body, baseTable);
13292
+ return baseTable;
13293
+ },
13294
+ TOMLKeyValue(node2, baseTable = {}) {
13295
+ const value = resolveValue(node2.value);
13296
+ set(baseTable, resolveValue(node2.key), value);
13297
+ return baseTable;
13298
+ },
13299
+ TOMLTable(node2, baseTable = {}) {
13300
+ const table = getTable(baseTable, resolveValue(node2.key), node2.kind === "array");
13301
+ for (const body of node2.body)
13302
+ resolveValue(body, table);
13303
+ return baseTable;
13304
+ },
13305
+ TOMLArray(node2) {
13306
+ return node2.elements.map((e) => resolveValue(e));
13307
+ },
13308
+ TOMLInlineTable(node2) {
13309
+ const table = {};
13310
+ for (const body of node2.body)
13311
+ resolveValue(body, table);
13312
+ return table;
13313
+ },
13314
+ TOMLKey(node2) {
13315
+ return node2.keys.map((key) => resolveValue(key));
13316
+ },
13317
+ TOMLBare(node2) {
13318
+ return node2.name;
13319
+ },
13320
+ TOMLQuoted(node2) {
13321
+ return node2.value;
13322
+ },
13323
+ TOMLValue(node2) {
13324
+ return convertValue(node2);
13325
+ }
13326
+ };
13327
+ return (node2) => resolveValue(node2);
13328
+ }
13329
+ function getTable(baseTable, keys, array) {
13330
+ let target = baseTable;
13331
+ for (let index = 0;index < keys.length - 1; index++) {
13332
+ const key = keys[index];
13333
+ target = getNextTargetFromKey(target, key);
13334
+ }
13335
+ const lastKey = last(keys);
13336
+ const lastTarget = target[lastKey];
13337
+ if (lastTarget == null) {
13338
+ const tableValue$1 = {};
13339
+ target[lastKey] = array ? [tableValue$1] : tableValue$1;
13340
+ return tableValue$1;
13341
+ }
13342
+ if (isValue(lastTarget)) {
13343
+ const tableValue$1 = {};
13344
+ target[lastKey] = array ? [tableValue$1] : tableValue$1;
13345
+ return tableValue$1;
13346
+ }
13347
+ if (!array) {
13348
+ if (Array.isArray(lastTarget)) {
13349
+ const tableValue$1 = {};
13350
+ target[lastKey] = tableValue$1;
13351
+ return tableValue$1;
13352
+ }
13353
+ return lastTarget;
13354
+ }
13355
+ if (Array.isArray(lastTarget)) {
13356
+ const tableValue$1 = {};
13357
+ lastTarget.push(tableValue$1);
13358
+ return tableValue$1;
13359
+ }
13360
+ const tableValue = {};
13361
+ target[lastKey] = [tableValue];
13362
+ return tableValue;
13363
+ function getNextTargetFromKey(currTarget, key) {
13364
+ const nextTarget = currTarget[key];
13365
+ if (nextTarget == null) {
13366
+ const val = {};
13367
+ currTarget[key] = val;
13368
+ return val;
13369
+ }
13370
+ if (isValue(nextTarget)) {
13371
+ const val = {};
13372
+ currTarget[key] = val;
13373
+ return val;
13374
+ }
13375
+ let resultTarget = nextTarget;
13376
+ while (Array.isArray(resultTarget)) {
13377
+ const lastIndex = resultTarget.length - 1;
13378
+ const nextElement = resultTarget[lastIndex];
13379
+ if (isValue(nextElement)) {
13380
+ const val = {};
13381
+ resultTarget[lastIndex] = val;
13382
+ return val;
13383
+ }
13384
+ resultTarget = nextElement;
13385
+ }
13386
+ return resultTarget;
13387
+ }
13388
+ }
13389
+ function set(baseTable, keys, value) {
13390
+ let target = baseTable;
13391
+ for (let index = 0;index < keys.length - 1; index++) {
13392
+ const key = keys[index];
13393
+ const nextTarget = target[key];
13394
+ if (nextTarget == null) {
13395
+ const val = {};
13396
+ target[key] = val;
13397
+ target = val;
13398
+ } else if (isValue(nextTarget) || Array.isArray(nextTarget)) {
13399
+ const val = {};
13400
+ target[key] = val;
13401
+ target = val;
13402
+ } else
13403
+ target = nextTarget;
13404
+ }
13405
+ target[last(keys)] = value;
13406
+ }
13407
+ function isValue(value) {
13408
+ return typeof value !== "object" || value instanceof Date;
13409
+ }
13410
+
13411
+ // ../extract/src/configEvidenceParser.ts
13412
+ var import_yaml2 = __toESM(require_dist(), 1);
12319
13413
  // ../extract/src/parser.ts
12320
- import Parser from "web-tree-sitter";
13414
+ import * as WebTreeSitter from "web-tree-sitter";
12321
13415
  import { existsSync } from "node:fs";
12322
13416
  import { fileURLToPath } from "node:url";
13417
+ var treeSitterRuntime = WebTreeSitter;
13418
+ var Parser = treeSitterRuntime.default ?? treeSitterRuntime.Parser;
13419
+ if (!Parser) {
13420
+ throw new TypeError("web-tree-sitter runtime does not expose Parser");
13421
+ }
12323
13422
  var parserInitPromise = null;
12324
13423
  var parsedBytesSinceReset = 0;
12325
13424
  var parserDead = false;
@@ -12329,9 +13428,13 @@ var createParserInstance = async () => {
12329
13428
  const localWasm = resolveWasmPath("./wasm/tree-sitter.wasm");
12330
13429
  const initOptions = existsSync(localWasm) ? { locateFile: (scriptName) => resolveWasmPath(`./wasm/${scriptName}`) } : undefined;
12331
13430
  await Parser.init(initOptions);
13431
+ const LanguageRuntime = treeSitterRuntime.default?.Language ?? treeSitterRuntime.Language;
13432
+ if (!LanguageRuntime) {
13433
+ throw new TypeError("web-tree-sitter runtime does not expose Language after initialization");
13434
+ }
12332
13435
  const parser = new Parser;
12333
- const tsLanguage = await Parser.Language.load(resolveWasmPath("./wasm/tree-sitter-typescript.wasm"));
12334
- const tsxLanguage = await Parser.Language.load(resolveWasmPath("./wasm/tree-sitter-tsx.wasm"));
13436
+ const tsLanguage = await LanguageRuntime.load(resolveWasmPath("./wasm/tree-sitter-typescript.wasm"));
13437
+ const tsxLanguage = await LanguageRuntime.load(resolveWasmPath("./wasm/tree-sitter-tsx.wasm"));
12335
13438
  return { parser, tsLanguage, tsxLanguage };
12336
13439
  };
12337
13440
  var initParser = async () => {
@@ -12382,6 +13485,363 @@ var parseFile = async (source, isTsx) => {
12382
13485
  return null;
12383
13486
  }
12384
13487
  };
13488
+ // src/commonJsModule.ts
13489
+ import ts2 from "typescript";
13490
+
13491
+ // src/typescriptAst.ts
13492
+ import ts from "typescript";
13493
+ var scriptKind = (filePath) => {
13494
+ const lower = filePath.toLowerCase();
13495
+ if (lower.endsWith(".tsx"))
13496
+ return ts.ScriptKind.TSX;
13497
+ if (lower.endsWith(".jsx"))
13498
+ return ts.ScriptKind.JSX;
13499
+ if (lower.endsWith(".js") || lower.endsWith(".mjs") || lower.endsWith(".cjs")) {
13500
+ return ts.ScriptKind.JS;
13501
+ }
13502
+ return ts.ScriptKind.TS;
13503
+ };
13504
+ var createEcmaScriptSourceFile = (source, filePath) => ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true, scriptKind(filePath));
13505
+ var syntaxDiagnostics = (sourceFile) => {
13506
+ const diagnostics = sourceFile.parseDiagnostics ?? [];
13507
+ return diagnostics.map((diagnostic) => {
13508
+ const start = diagnostic.start ?? 0;
13509
+ const position = sourceFile.getLineAndCharacterOfPosition(start);
13510
+ return {
13511
+ code: "ecmascript-syntax-error",
13512
+ severity: "error",
13513
+ file: sourceFile.fileName,
13514
+ line: position.line + 1,
13515
+ column: position.character + 1
13516
+ };
13517
+ });
13518
+ };
13519
+ var nodeLocation = (sourceFile, node2) => {
13520
+ const start = sourceFile.getLineAndCharacterOfPosition(node2.getStart(sourceFile));
13521
+ const end = sourceFile.getLineAndCharacterOfPosition(node2.getEnd());
13522
+ return {
13523
+ line: start.line + 1,
13524
+ column: start.character + 1,
13525
+ endLine: end.line + 1
13526
+ };
13527
+ };
13528
+ var staticStringValue = (node2) => {
13529
+ if (!node2)
13530
+ return null;
13531
+ if (ts.isStringLiteral(node2) || ts.isNoSubstitutionTemplateLiteral(node2))
13532
+ return node2.text;
13533
+ return null;
13534
+ };
13535
+
13536
+ // src/commonJsModule.ts
13537
+ var requireCall = (node2) => ts2.isCallExpression(node2) && ts2.isIdentifier(node2.expression) && node2.expression.text === "require" ? node2 : null;
13538
+ var requireReference = (node2) => {
13539
+ const direct = requireCall(node2);
13540
+ if (direct) {
13541
+ const source = staticStringValue(direct.arguments[0]);
13542
+ return source ? { source, importedName: "*" } : null;
13543
+ }
13544
+ if (ts2.isPropertyAccessExpression(node2)) {
13545
+ const call = requireCall(node2.expression);
13546
+ const source = call ? staticStringValue(call.arguments[0]) : null;
13547
+ return source ? { source, importedName: node2.name.text } : null;
13548
+ }
13549
+ if (ts2.isElementAccessExpression(node2)) {
13550
+ const call = requireCall(node2.expression);
13551
+ const source = call ? staticStringValue(call.arguments[0]) : null;
13552
+ const importedName = staticStringValue(node2.argumentExpression);
13553
+ return source && importedName ? { source, importedName } : null;
13554
+ }
13555
+ return null;
13556
+ };
13557
+ var isModuleExports = (node2) => {
13558
+ if (ts2.isPropertyAccessExpression(node2) && ts2.isIdentifier(node2.expression) && node2.expression.text === "module" && node2.name.text === "exports")
13559
+ return true;
13560
+ return ts2.isElementAccessExpression(node2) && ts2.isIdentifier(node2.expression) && node2.expression.text === "module" && staticStringValue(node2.argumentExpression) === "exports";
13561
+ };
13562
+ var isExportsObject = (node2) => ts2.isIdentifier(node2) && node2.text === "exports" || isModuleExports(node2);
13563
+ var isUnsupportedExportMutationCall = (node2) => {
13564
+ if (ts2.isPropertyAccessExpression(node2.expression) && ts2.isIdentifier(node2.expression.expression) && node2.expression.expression.text === "Object" && ["assign", "defineProperties", "defineProperty"].includes(node2.expression.name.text) && node2.arguments[0] && isExportsObject(node2.arguments[0])) {
13565
+ return !(node2.expression.name.text === "defineProperty" && staticStringValue(node2.arguments[1]) === "__esModule");
13566
+ }
13567
+ return ts2.isIdentifier(node2.expression) && ["__createBinding", "__export", "__exportStar"].includes(node2.expression.text) && node2.arguments.some(isExportsObject);
13568
+ };
13569
+ var commonJsExportTarget = (node2) => {
13570
+ if (ts2.isPropertyAccessExpression(node2)) {
13571
+ if (ts2.isIdentifier(node2.expression) && node2.expression.text === "exports") {
13572
+ return { kind: "named", exportedName: node2.name.text };
13573
+ }
13574
+ if (isModuleExports(node2.expression)) {
13575
+ return { kind: "named", exportedName: node2.name.text };
13576
+ }
13577
+ if (isModuleExports(node2))
13578
+ return { kind: "whole" };
13579
+ }
13580
+ if (ts2.isElementAccessExpression(node2)) {
13581
+ const property = staticStringValue(node2.argumentExpression);
13582
+ if (ts2.isIdentifier(node2.expression) && node2.expression.text === "exports" && property) {
13583
+ return { kind: "named", exportedName: property };
13584
+ }
13585
+ if (isModuleExports(node2.expression) && property) {
13586
+ return { kind: "named", exportedName: property };
13587
+ }
13588
+ if (isModuleExports(node2))
13589
+ return { kind: "whole" };
13590
+ }
13591
+ return null;
13592
+ };
13593
+ var localReference = (expression, bindings) => {
13594
+ if (ts2.isIdentifier(expression)) {
13595
+ const binding = bindings.get(expression.text);
13596
+ if (binding) {
13597
+ return {
13598
+ source: binding.source,
13599
+ importedName: binding.importedName
13600
+ };
13601
+ }
13602
+ return { localName: expression.text };
13603
+ }
13604
+ if (ts2.isPropertyAccessExpression(expression) && ts2.isIdentifier(expression.expression)) {
13605
+ const binding = bindings.get(expression.expression.text);
13606
+ if (binding)
13607
+ return { source: binding.source, importedName: expression.name.text };
13608
+ }
13609
+ const required = requireReference(expression);
13610
+ return required ? { source: required.source, importedName: required.importedName } : null;
13611
+ };
13612
+ var syntheticDeclaration = (name, expression, sourceFile) => {
13613
+ const location = nodeLocation(sourceFile, expression);
13614
+ if (ts2.isFunctionExpression(expression) || ts2.isArrowFunction(expression)) {
13615
+ return {
13616
+ name,
13617
+ kind: "function",
13618
+ line: location.line,
13619
+ endLine: location.endLine,
13620
+ params: expression.parameters.map((parameter) => parameter.name.getText(sourceFile))
13621
+ };
13622
+ }
13623
+ if (ts2.isClassExpression(expression)) {
13624
+ return { name, kind: "class", line: location.line, endLine: location.endLine, params: [] };
13625
+ }
13626
+ if (ts2.isObjectLiteralExpression(expression) || ts2.isArrayLiteralExpression(expression) || ts2.isLiteralExpression(expression)) {
13627
+ return { name, kind: "variable", line: location.line, endLine: location.endLine, params: [] };
13628
+ }
13629
+ return null;
13630
+ };
13631
+ var pushExport = (result, exportedName, expression, line, bindings, sourceFile) => {
13632
+ const reference = localReference(expression, bindings);
13633
+ if (reference) {
13634
+ result.exports.push({ exportedName, ...reference, line });
13635
+ return true;
13636
+ }
13637
+ const synthetic = syntheticDeclaration(exportedName, expression, sourceFile);
13638
+ if (synthetic) {
13639
+ result.syntheticDeclarations.push(synthetic);
13640
+ result.exports.push({ exportedName, localName: exportedName, line });
13641
+ return true;
13642
+ }
13643
+ return false;
13644
+ };
13645
+ var appendUnsupportedExportDiagnostic = (result, sourceFile, node2) => {
13646
+ const location = nodeLocation(sourceFile, node2);
13647
+ if (result.diagnostics.some((diagnostic) => diagnostic.code === "dynamic-commonjs-require" && diagnostic.line === location.line && diagnostic.column === location.column))
13648
+ return;
13649
+ result.diagnostics.push({
13650
+ code: "unsupported-commonjs-export-expression",
13651
+ severity: "error",
13652
+ file: sourceFile.fileName,
13653
+ line: location.line,
13654
+ column: location.column
13655
+ });
13656
+ };
13657
+ var collectBindings = (sourceFile) => {
13658
+ const bindings = [];
13659
+ for (const statement of sourceFile.statements) {
13660
+ if (!ts2.isVariableStatement(statement))
13661
+ continue;
13662
+ for (const declaration of statement.declarationList.declarations) {
13663
+ if (!declaration.initializer)
13664
+ continue;
13665
+ const line = nodeLocation(sourceFile, declaration).line;
13666
+ if (ts2.isIdentifier(declaration.name)) {
13667
+ const reference = requireReference(declaration.initializer);
13668
+ if (reference)
13669
+ bindings.push({ localName: declaration.name.text, ...reference, line });
13670
+ continue;
13671
+ }
13672
+ const direct = requireCall(declaration.initializer);
13673
+ const source = direct ? staticStringValue(direct.arguments[0]) : null;
13674
+ if (!source || !ts2.isObjectBindingPattern(declaration.name))
13675
+ continue;
13676
+ for (const element of declaration.name.elements) {
13677
+ if (!ts2.isIdentifier(element.name))
13678
+ continue;
13679
+ const importedName = element.propertyName?.getText(sourceFile) ?? element.name.text;
13680
+ bindings.push({ localName: element.name.text, source, importedName, line });
13681
+ }
13682
+ }
13683
+ }
13684
+ return bindings;
13685
+ };
13686
+ var collectDynamicDiagnostics = (sourceFile) => {
13687
+ const diagnostics = [];
13688
+ const visit = (node2) => {
13689
+ if (ts2.isCallExpression(node2) && ts2.isIdentifier(node2.expression) && node2.expression.text === "require") {
13690
+ if (staticStringValue(node2.arguments[0]) === null) {
13691
+ const location = nodeLocation(sourceFile, node2);
13692
+ diagnostics.push({
13693
+ code: "dynamic-commonjs-require",
13694
+ severity: "error",
13695
+ file: sourceFile.fileName,
13696
+ line: location.line,
13697
+ column: location.column
13698
+ });
13699
+ }
13700
+ }
13701
+ if (ts2.isCallExpression(node2) && isUnsupportedExportMutationCall(node2)) {
13702
+ const location = nodeLocation(sourceFile, node2);
13703
+ diagnostics.push({
13704
+ code: "unsupported-commonjs-export-form",
13705
+ severity: "error",
13706
+ file: sourceFile.fileName,
13707
+ line: location.line,
13708
+ column: location.column
13709
+ });
13710
+ }
13711
+ if (ts2.isBinaryExpression(node2) && node2.operatorToken.kind === ts2.SyntaxKind.EqualsToken) {
13712
+ if (ts2.isElementAccessExpression(node2.left)) {
13713
+ const isCommonJsTarget = ts2.isIdentifier(node2.left.expression) && node2.left.expression.text === "exports" || isModuleExports(node2.left.expression) || isModuleExports(node2.left);
13714
+ if (isCommonJsTarget && commonJsExportTarget(node2.left) === null) {
13715
+ const location = nodeLocation(sourceFile, node2.left);
13716
+ diagnostics.push({
13717
+ code: "dynamic-commonjs-export",
13718
+ severity: "error",
13719
+ file: sourceFile.fileName,
13720
+ line: location.line,
13721
+ column: location.column
13722
+ });
13723
+ }
13724
+ }
13725
+ }
13726
+ ts2.forEachChild(node2, visit);
13727
+ };
13728
+ visit(sourceFile);
13729
+ return diagnostics;
13730
+ };
13731
+ var analyzeCommonJsModule = (source, filePath) => {
13732
+ const sourceFile = createEcmaScriptSourceFile(source, filePath);
13733
+ const bindings = collectBindings(sourceFile);
13734
+ const bindingMap = new Map(bindings.map((binding) => [binding.localName, binding]));
13735
+ const result = {
13736
+ bindings,
13737
+ exports: [],
13738
+ wildcardSources: [],
13739
+ syntheticDeclarations: [],
13740
+ diagnostics: collectDynamicDiagnostics(sourceFile)
13741
+ };
13742
+ for (const statement of sourceFile.statements) {
13743
+ if (!ts2.isExpressionStatement(statement) || !ts2.isBinaryExpression(statement.expression))
13744
+ continue;
13745
+ const assignment = statement.expression;
13746
+ if (assignment.operatorToken.kind !== ts2.SyntaxKind.EqualsToken)
13747
+ continue;
13748
+ const target = commonJsExportTarget(assignment.left);
13749
+ if (!target)
13750
+ continue;
13751
+ const line = nodeLocation(sourceFile, assignment).line;
13752
+ if (target.kind === "named") {
13753
+ if (!pushExport(result, target.exportedName, assignment.right, line, bindingMap, sourceFile)) {
13754
+ appendUnsupportedExportDiagnostic(result, sourceFile, assignment.right);
13755
+ }
13756
+ continue;
13757
+ }
13758
+ const directRequire = requireReference(assignment.right);
13759
+ if (directRequire?.importedName === "*") {
13760
+ result.wildcardSources.push(directRequire.source);
13761
+ continue;
13762
+ }
13763
+ if (ts2.isObjectLiteralExpression(assignment.right)) {
13764
+ for (const property of assignment.right.properties) {
13765
+ if (ts2.isShorthandPropertyAssignment(property)) {
13766
+ pushExport(result, property.name.text, property.name, line, bindingMap, sourceFile);
13767
+ continue;
13768
+ }
13769
+ if (ts2.isPropertyAssignment(property)) {
13770
+ const name = property.name && (ts2.isIdentifier(property.name) || ts2.isStringLiteral(property.name)) ? property.name.text : null;
13771
+ if (name) {
13772
+ if (!pushExport(result, name, property.initializer, line, bindingMap, sourceFile)) {
13773
+ appendUnsupportedExportDiagnostic(result, sourceFile, property.initializer);
13774
+ }
13775
+ } else {
13776
+ appendUnsupportedExportDiagnostic(result, sourceFile, property);
13777
+ }
13778
+ continue;
13779
+ }
13780
+ if (ts2.isMethodDeclaration(property) && property.name && ts2.isIdentifier(property.name)) {
13781
+ const location = nodeLocation(sourceFile, property);
13782
+ result.syntheticDeclarations.push({
13783
+ name: property.name.text,
13784
+ kind: "function",
13785
+ line: location.line,
13786
+ endLine: location.endLine,
13787
+ params: property.parameters.map((parameter) => parameter.name.getText(sourceFile))
13788
+ });
13789
+ result.exports.push({
13790
+ exportedName: property.name.text,
13791
+ localName: property.name.text,
13792
+ line
13793
+ });
13794
+ continue;
13795
+ }
13796
+ appendUnsupportedExportDiagnostic(result, sourceFile, property);
13797
+ }
13798
+ continue;
13799
+ }
13800
+ if (ts2.isIdentifier(assignment.right)) {
13801
+ const binding = bindingMap.get(assignment.right.text);
13802
+ if (binding?.importedName === "*") {
13803
+ result.wildcardSources.push(binding.source);
13804
+ continue;
13805
+ }
13806
+ if (!pushExport(result, assignment.right.text, assignment.right, line, bindingMap, sourceFile)) {
13807
+ appendUnsupportedExportDiagnostic(result, sourceFile, assignment.right);
13808
+ }
13809
+ continue;
13810
+ }
13811
+ if (!pushExport(result, "default", assignment.right, line, bindingMap, sourceFile)) {
13812
+ appendUnsupportedExportDiagnostic(result, sourceFile, assignment.right);
13813
+ }
13814
+ }
13815
+ result.bindings.sort((left, right) => left.localName.localeCompare(right.localName));
13816
+ result.exports.sort((left, right) => left.exportedName.localeCompare(right.exportedName) || left.line - right.line);
13817
+ result.wildcardSources = [...new Set(result.wildcardSources)].sort();
13818
+ result.syntheticDeclarations.sort((left, right) => left.name.localeCompare(right.name));
13819
+ result.diagnostics.sort((left, right) => left.line - right.line || left.column - right.column);
13820
+ return result;
13821
+ };
13822
+
13823
+ // src/commonJsExportTrace.ts
13824
+ var traceCommonJsExports = async (input) => {
13825
+ const traced = [];
13826
+ for (const item of input.analysis.exports) {
13827
+ if (item.localName && input.localDeclarations.has(item.localName)) {
13828
+ traced.push({
13829
+ exportedName: item.exportedName,
13830
+ localName: item.localName,
13831
+ declarationFile: input.filePath
13832
+ });
13833
+ continue;
13834
+ }
13835
+ if (item.source && item.importedName) {
13836
+ traced.push(...await input.traceImported(item.source, item.importedName, item.exportedName));
13837
+ }
13838
+ }
13839
+ for (const source of input.analysis.wildcardSources) {
13840
+ traced.push(...await input.traceWildcard(source));
13841
+ }
13842
+ return traced;
13843
+ };
13844
+
12385
13845
  // src/exportTracer.ts
12386
13846
  var DECLARATION_TYPES = new Set([
12387
13847
  "function_declaration",
@@ -12499,12 +13959,24 @@ var traceFile = async (filePath, fs, state) => {
12499
13959
  state.inFlight.add(filePath);
12500
13960
  state.files.add(filePath);
12501
13961
  const source = await fs.readFile(filePath);
12502
- const tree = await parseFile(source, filePath.endsWith(".tsx"));
13962
+ const commonJs = analyzeCommonJsModule(source, filePath);
13963
+ if (commonJs.diagnostics.length > 0)
13964
+ return [];
13965
+ const tree = await parseFile(source, isJsxLikePath(filePath));
12503
13966
  if (!tree)
12504
13967
  return [];
12505
13968
  const root = tree.rootNode;
12506
13969
  const localDeclarations = collectLocalDeclarations(root);
12507
13970
  const importBindings = collectImportBindings(root);
13971
+ for (const declaration of commonJs.syntheticDeclarations) {
13972
+ localDeclarations.set(declaration.name, declaration.name);
13973
+ }
13974
+ for (const binding of commonJs.bindings) {
13975
+ importBindings.set(binding.localName, {
13976
+ source: binding.source,
13977
+ importedName: binding.importedName
13978
+ });
13979
+ }
12508
13980
  const exportsList = [];
12509
13981
  for (const node2 of root.namedChildren) {
12510
13982
  if (node2.type !== "export_statement")
@@ -12576,6 +14048,16 @@ var traceFile = async (filePath, fs, state) => {
12576
14048
  });
12577
14049
  }
12578
14050
  }
14051
+ exportsList.push(...await traceCommonJsExports({
14052
+ analysis: commonJs,
14053
+ filePath,
14054
+ localDeclarations,
14055
+ traceImported: (source2, importedName, exportedName) => traceImportedBinding(filePath, { source: source2, importedName }, exportedName, fs, state),
14056
+ traceWildcard: async (source2) => {
14057
+ const targetPath = await resolveImportSourcePath(filePath, source2, fs, state.resolver);
14058
+ return targetPath ? traceFile(targetPath, fs, state) : [];
14059
+ }
14060
+ }));
12579
14061
  state.inFlight.delete(filePath);
12580
14062
  return uniqueExports(exportsList);
12581
14063
  })();
@@ -12727,7 +14209,7 @@ var appendTypeRelations = (relations, relationType, from, typeText, importBindin
12727
14209
  }
12728
14210
  };
12729
14211
  var classifyVariable = (name, filePath) => {
12730
- if (filePath.endsWith(".tsx") && /^[A-Z]/.test(name)) {
14212
+ if ((filePath.endsWith(".tsx") || filePath.endsWith(".jsx")) && /^[A-Z]/.test(name)) {
12731
14213
  return "component" /* Component */;
12732
14214
  }
12733
14215
  return "variable" /* Variable */;
@@ -12887,6 +14369,146 @@ var findObjectTypeNodes = (node2) => {
12887
14369
  return [];
12888
14370
  };
12889
14371
 
14372
+ // src/staticCallRelations.ts
14373
+ import ts3 from "typescript";
14374
+ var callTarget = (expression, sourceFile) => {
14375
+ if (ts3.isIdentifier(expression))
14376
+ return expression.text === "require" ? null : expression.text;
14377
+ if (ts3.isPropertyAccessExpression(expression))
14378
+ return expression.getText(sourceFile).replace(/\s+/gu, "");
14379
+ if (ts3.isElementAccessExpression(expression)) {
14380
+ const property = staticStringValue(expression.argumentExpression);
14381
+ return property ? `${expression.expression.getText(sourceFile).replace(/\s+/gu, "")}.${property}` : null;
14382
+ }
14383
+ return null;
14384
+ };
14385
+ var rootIdentifier = (expression) => {
14386
+ let current = expression;
14387
+ while (ts3.isPropertyAccessExpression(current) || ts3.isElementAccessExpression(current)) {
14388
+ current = current.expression;
14389
+ }
14390
+ return ts3.isIdentifier(current) ? current.text : null;
14391
+ };
14392
+ var declarationName = (node2, sourceFile) => {
14393
+ if (ts3.isFunctionDeclaration(node2) && node2.name)
14394
+ return node2.name.text;
14395
+ if (ts3.isClassDeclaration(node2) && node2.name)
14396
+ return node2.name.text;
14397
+ if (ts3.isVariableDeclaration(node2) && ts3.isIdentifier(node2.name))
14398
+ return node2.name.text;
14399
+ if (ts3.isMethodDeclaration(node2) || ts3.isGetAccessorDeclaration(node2) || ts3.isSetAccessorDeclaration(node2)) {
14400
+ const parent = node2.parent;
14401
+ if (parent && ts3.isClassDeclaration(parent) && parent.name)
14402
+ return parent.name.text;
14403
+ return node2.name?.getText(sourceFile) ?? null;
14404
+ }
14405
+ return null;
14406
+ };
14407
+ var collectStaticCallRelations = (source, filePath, importBindings) => {
14408
+ const sourceFile = createEcmaScriptSourceFile(source, filePath);
14409
+ const relations = [];
14410
+ const visit = (node2, owner) => {
14411
+ const namedOwner = declarationName(node2, sourceFile) ?? owner;
14412
+ if (ts3.isCallExpression(node2) || ts3.isNewExpression(node2)) {
14413
+ const target = callTarget(node2.expression, sourceFile);
14414
+ if (target) {
14415
+ const root = rootIdentifier(node2.expression);
14416
+ const isExternal = root ? importBindings.get(root)?.isExternal ?? false : false;
14417
+ relations.push(createRelation("calls" /* Calls */, namedOwner, target, isExternal, nodeLocation(sourceFile, node2).line));
14418
+ }
14419
+ }
14420
+ ts3.forEachChild(node2, (child) => visit(child, namedOwner));
14421
+ };
14422
+ visit(sourceFile, filePath);
14423
+ const seen = new Set;
14424
+ return relations.sort((left, right) => (left.line ?? 0) - (right.line ?? 0) || left.from.localeCompare(right.from) || left.to.localeCompare(right.to)).filter((relation) => {
14425
+ const key = `${relation.from}\x00${relation.to}\x00${relation.line ?? 0}`;
14426
+ if (seen.has(key))
14427
+ return false;
14428
+ seen.add(key);
14429
+ return true;
14430
+ });
14431
+ };
14432
+
14433
+ // src/symbolExtractorImports.ts
14434
+ var esmImportParts = (node2, bindings, isExternal, statementTypeOnly) => {
14435
+ let hasValueImport = !statementTypeOnly;
14436
+ let hasTypeImport = statementTypeOnly;
14437
+ const clause = node2.namedChildren.find((child) => child.type === "import_clause");
14438
+ for (const part of clause?.namedChildren ?? []) {
14439
+ if (part.type === "identifier") {
14440
+ bindings.set(part.text, { isExternal, typeOnly: statementTypeOnly });
14441
+ continue;
14442
+ }
14443
+ if (part.type === "namespace_import") {
14444
+ const identifier = part.namedChildren.find((child) => child.type === "identifier");
14445
+ if (identifier)
14446
+ bindings.set(identifier.text, { isExternal, typeOnly: statementTypeOnly });
14447
+ continue;
14448
+ }
14449
+ if (part.type !== "named_imports")
14450
+ continue;
14451
+ for (const specifierNode of part.namedChildren.filter((child) => child.type === "import_specifier")) {
14452
+ const identifiers = specifierNode.namedChildren.filter((child) => child.type === "identifier" || child.type === "type_identifier").map((child) => child.text);
14453
+ const localName = identifiers[1] ?? identifiers[0];
14454
+ if (!localName)
14455
+ continue;
14456
+ const typeOnly = statementTypeOnly || specifierNode.text.trim().startsWith("type ");
14457
+ bindings.set(localName, { isExternal, typeOnly });
14458
+ hasValueImport ||= !typeOnly;
14459
+ hasTypeImport ||= typeOnly;
14460
+ }
14461
+ }
14462
+ return { hasValueImport, hasTypeImport };
14463
+ };
14464
+ var appendEsmImport = async (input) => {
14465
+ const specifierNode = input.node.namedChildren.find((child) => child.type === "string");
14466
+ if (!specifierNode)
14467
+ return;
14468
+ const specifier = specifierNode.text.replace(/^['"]/, "").replace(/['"]$/, "");
14469
+ const resolvedAlias = isRelativeModuleSpecifier(specifier) ? null : await resolveImportSourcePath(input.filePath, specifier, input.fs, input.resolver);
14470
+ const isExternal = !isRelativeModuleSpecifier(specifier) && resolvedAlias === null;
14471
+ const statementTypeOnly = input.node.text.startsWith("import type ");
14472
+ const parts = esmImportParts(input.node, input.bindings, isExternal, statementTypeOnly);
14473
+ if (parts.hasValueImport) {
14474
+ input.relations.push(createRelation("imports" /* Imports */, "", resolvedAlias ?? specifier, isExternal, getLine(input.node)));
14475
+ }
14476
+ if (parts.hasTypeImport) {
14477
+ input.relations.push(createRelation("imports_type" /* ImportsType */, "", resolvedAlias ?? specifier, isExternal, getLine(input.node)));
14478
+ }
14479
+ };
14480
+ var appendCommonJsImports = async (input) => {
14481
+ const recordedSources = new Set;
14482
+ for (const binding of input.commonJs.bindings) {
14483
+ const resolved = await resolveImportSourcePath(input.filePath, binding.source, input.fs, input.resolver);
14484
+ const isExternal = !isRelativeModuleSpecifier(binding.source) && resolved === null;
14485
+ input.bindings.set(binding.localName, { isExternal, typeOnly: false });
14486
+ if (recordedSources.has(binding.source))
14487
+ continue;
14488
+ recordedSources.add(binding.source);
14489
+ input.relations.push(createRelation("imports" /* Imports */, "", resolved ?? binding.source, isExternal, binding.line));
14490
+ }
14491
+ const remainingSources = [...new Set([
14492
+ ...input.commonJs.wildcardSources,
14493
+ ...input.commonJs.exports.flatMap((item) => item.source ? [item.source] : [])
14494
+ ])].sort();
14495
+ for (const source of remainingSources) {
14496
+ if (recordedSources.has(source))
14497
+ continue;
14498
+ const resolved = await resolveImportSourcePath(input.filePath, source, input.fs, input.resolver);
14499
+ const isExternal = !isRelativeModuleSpecifier(source) && resolved === null;
14500
+ input.relations.push(createRelation("imports" /* Imports */, "", resolved ?? source, isExternal, input.commonJs.exports.find((item) => item.source === source)?.line ?? 1));
14501
+ }
14502
+ };
14503
+ var collectImportBindings2 = async (root, filePath, fs, resolver, relations, commonJs) => {
14504
+ const bindings = new Map;
14505
+ for (const node2 of root.namedChildren.filter((child) => child.type === "import_statement")) {
14506
+ await appendEsmImport({ node: node2, filePath, fs, resolver, bindings, relations });
14507
+ }
14508
+ await appendCommonJsImports({ commonJs, filePath, fs, resolver, bindings, relations });
14509
+ return bindings;
14510
+ };
14511
+
12890
14512
  // src/symbolExtractorAnalyze.ts
12891
14513
  var analyzeDeclaration = (node2, filePath, declarations, importBindings, relations) => {
12892
14514
  if (node2.type === "lexical_declaration") {
@@ -12971,7 +14593,7 @@ var analyzeFunctionDeclaration = (node2, name, filePath, declarations, importBin
12971
14593
  declarations.set(name, {
12972
14594
  info: {
12973
14595
  name,
12974
- kind: "function" /* Function */,
14596
+ kind: isJsxLikePath(filePath) && /^[A-Z]/u.test(name) && containsJsx(node2) ? "component" /* Component */ : "function" /* Function */,
12975
14597
  visibility: "internal" /* Internal */,
12976
14598
  file: filePath,
12977
14599
  line: getLine(node2),
@@ -13078,68 +14700,61 @@ var analyzeEnumDeclaration = (node2, name, symbolDoc, filePath, declarations) =>
13078
14700
  }
13079
14701
  });
13080
14702
  };
13081
- var collectImportBindings2 = async (root, filePath, fs, resolver, relations) => {
13082
- const bindings = new Map;
13083
- for (const node2 of root.namedChildren.filter((child) => child.type === "import_statement")) {
13084
- const specifierNode = node2.namedChildren.find((child) => child.type === "string");
13085
- if (!specifierNode)
14703
+ var appendCommonJsSyntheticDeclarations = (commonJs, filePath, declarations) => {
14704
+ for (const declaration of commonJs.syntheticDeclarations) {
14705
+ if (declarations.has(declaration.name))
13086
14706
  continue;
13087
- const specifier = specifierNode.text.replace(/^['"]/, "").replace(/['"]$/, "");
13088
- const resolvedAlias = isRelativeModuleSpecifier(specifier) ? null : await resolveImportSourcePath(filePath, specifier, fs, resolver);
13089
- const isExternal = !isRelativeModuleSpecifier(specifier) && resolvedAlias === null;
13090
- const relationTarget = resolvedAlias ?? specifier;
13091
- const statementTypeOnly = node2.text.startsWith("import type ");
13092
- let hasValueImport = !statementTypeOnly;
13093
- let hasTypeImport = statementTypeOnly;
13094
- const clause = node2.namedChildren.find((child) => child.type === "import_clause");
13095
- for (const part of clause?.namedChildren ?? []) {
13096
- if (part.type === "identifier") {
13097
- bindings.set(part.text, { isExternal, typeOnly: statementTypeOnly });
13098
- continue;
13099
- }
13100
- if (part.type === "namespace_import") {
13101
- const identifier = part.namedChildren.find((child) => child.type === "identifier");
13102
- if (identifier) {
13103
- bindings.set(identifier.text, { isExternal, typeOnly: statementTypeOnly });
13104
- }
13105
- continue;
13106
- }
13107
- if (part.type !== "named_imports")
13108
- continue;
13109
- for (const specifierNode2 of part.namedChildren.filter((child) => child.type === "import_specifier")) {
13110
- const identifiers = specifierNode2.namedChildren.filter((child) => child.type === "identifier" || child.type === "type_identifier").map((child) => child.text);
13111
- const localName = identifiers[1] ?? identifiers[0];
13112
- if (!localName)
13113
- continue;
13114
- const typeOnly = statementTypeOnly || specifierNode2.text.trim().startsWith("type ");
13115
- bindings.set(localName, { isExternal, typeOnly });
13116
- hasValueImport ||= !typeOnly;
13117
- hasTypeImport ||= typeOnly;
14707
+ declarations.set(declaration.name, {
14708
+ info: {
14709
+ name: declaration.name,
14710
+ kind: declaration.kind === "function" ? isJsxLikePath(filePath) && /^[A-Z]/u.test(declaration.name) ? "component" /* Component */ : "function" /* Function */ : declaration.kind === "class" ? "class" /* Class */ : "variable" /* Variable */,
14711
+ visibility: "internal" /* Internal */,
14712
+ file: filePath,
14713
+ line: declaration.line,
14714
+ endLine: declaration.endLine,
14715
+ ...declaration.params.length > 0 ? { params: declaration.params.map((name) => ({ name, type: null })) } : {}
13118
14716
  }
13119
- }
13120
- if (hasValueImport) {
13121
- relations.push(createRelation("imports" /* Imports */, "", relationTarget, isExternal, getLine(node2)));
13122
- }
13123
- if (hasTypeImport) {
13124
- relations.push(createRelation("imports_type" /* ImportsType */, "", relationTarget, isExternal, getLine(node2)));
13125
- }
14717
+ });
13126
14718
  }
13127
- return bindings;
13128
14719
  };
13129
14720
  var analyzeFile = async (filePath, fs, resolver = { mappings: [] }) => {
13130
14721
  const source = await fs.readFile(filePath);
13131
- const tree = await parseFile(source, filePath.endsWith(".tsx"));
14722
+ const sourceFile = createEcmaScriptSourceFile(source, filePath);
14723
+ const commonJs = analyzeCommonJsModule(source, filePath);
14724
+ const tree = await parseFile(source, isJsxLikePath(filePath));
13132
14725
  if (!tree) {
14726
+ const diagnostics = syntaxDiagnostics(sourceFile);
14727
+ if (diagnostics.length === 0) {
14728
+ diagnostics.push({
14729
+ code: "ecmascript-parser-unsupported",
14730
+ severity: "error",
14731
+ file: filePath,
14732
+ line: 1,
14733
+ column: 1
14734
+ });
14735
+ }
14736
+ return {
14737
+ declarations: new Map,
14738
+ importBindings: new Map,
14739
+ relations: [],
14740
+ lines: countLines(source),
14741
+ disposition: "unsupported",
14742
+ diagnostics
14743
+ };
14744
+ }
14745
+ if (commonJs.diagnostics.length > 0) {
13133
14746
  return {
13134
14747
  declarations: new Map,
13135
14748
  importBindings: new Map,
13136
14749
  relations: [],
13137
- lines: countLines(source)
14750
+ lines: countLines(source),
14751
+ disposition: "unsupported",
14752
+ diagnostics: commonJs.diagnostics
13138
14753
  };
13139
14754
  }
13140
14755
  const root = tree.rootNode;
13141
14756
  const relations = [];
13142
- const importBindings = await collectImportBindings2(root, filePath, fs, resolver, relations);
14757
+ const importBindings = await collectImportBindings2(root, filePath, fs, resolver, relations, commonJs);
13143
14758
  const declarations = new Map;
13144
14759
  for (const relation of relations) {
13145
14760
  if (relation.from === "") {
@@ -13158,11 +14773,15 @@ var analyzeFile = async (filePath, fs, resolver = { mappings: [] }) => {
13158
14773
  analyzeDeclaration(declaration, filePath, declarations, importBindings, relations);
13159
14774
  }
13160
14775
  }
14776
+ appendCommonJsSyntheticDeclarations(commonJs, filePath, declarations);
14777
+ relations.push(...collectStaticCallRelations(source, filePath, importBindings));
13161
14778
  return {
13162
14779
  declarations,
13163
14780
  importBindings,
13164
14781
  relations,
13165
- lines: countLines(source)
14782
+ lines: countLines(source),
14783
+ disposition: "analyzed",
14784
+ diagnostics: []
13166
14785
  };
13167
14786
  };
13168
14787
 
@@ -13243,21 +14862,38 @@ var extractSymbols = async (entries, fs, options) => {
13243
14862
  }
13244
14863
  const files = [...filePaths].sort().map((filePath) => ({
13245
14864
  path: filePath,
13246
- language: filePath.endsWith(".tsx") ? "tsx" : "typescript",
14865
+ language: ecmaScriptLanguage(filePath),
13247
14866
  lines: analyses.get(filePath)?.lines ?? 0
13248
14867
  }));
14868
+ const coverageFiles = files.map((file) => {
14869
+ const analysis = analyses.get(file.path);
14870
+ return {
14871
+ path: file.path,
14872
+ disposition: analysis?.disposition ?? "unsupported",
14873
+ diagnosticCodes: analysis?.diagnostics.map((diagnostic) => diagnostic.code) ?? [
14874
+ "ecmascript-analysis-missing"
14875
+ ]
14876
+ };
14877
+ });
14878
+ const diagnostics = [...analyses.values()].flatMap((analysis) => analysis.diagnostics).sort((left, right) => left.file.localeCompare(right.file) || left.line - right.line || left.column - right.column);
13249
14879
  return {
13250
14880
  version: "2",
13251
14881
  meta: {
13252
14882
  extractedAt: new Date().toISOString(),
13253
14883
  pluginId: options.pluginId,
13254
14884
  commitHash: null,
13255
- language: "typescript"
14885
+ language: options.packageInfo.language
13256
14886
  },
13257
14887
  package: options.packageInfo,
13258
14888
  files,
13259
14889
  symbols,
13260
14890
  relations,
14891
+ coverage: {
14892
+ tier: EXTRACT_TS_COVERAGE_TIER,
14893
+ capabilities: [...EXTRACT_TS_CAPABILITIES],
14894
+ files: coverageFiles,
14895
+ diagnostics
14896
+ },
13261
14897
  stats: {
13262
14898
  files: files.length,
13263
14899
  lines: files.reduce((sum, file) => sum + file.lines, 0),
@@ -13271,8 +14907,10 @@ var extractSymbols = async (entries, fs, options) => {
13271
14907
  // src/plugin.ts
13272
14908
  class TypeScriptPlugin {
13273
14909
  id = "c4a-extract-ts";
13274
- languages = ["typescript", "tsx"];
14910
+ languages = ["typescript", "tsx", "javascript", "jsx"];
13275
14911
  packageManagers = ["npm"];
14912
+ capabilities = [...EXTRACT_TS_CAPABILITIES];
14913
+ coverageTier = EXTRACT_TS_COVERAGE_TIER;
13276
14914
  manifestTypes = ["package.json"];
13277
14915
  #lastDetection = null;
13278
14916
  canHandle(source) {
@@ -13297,20 +14935,20 @@ class TypeScriptPlugin {
13297
14935
  }
13298
14936
  }
13299
14937
  // src/reactRouter.ts
13300
- import * as ts from "typescript";
14938
+ import * as ts4 from "typescript";
13301
14939
  function compact(value) {
13302
14940
  return value.replace(/\s+/gu, " ").trim();
13303
14941
  }
13304
14942
  function scalarValue(node2) {
13305
14943
  if (!node2)
13306
14944
  return;
13307
- if (ts.isStringLiteralLike(node2) || ts.isNoSubstitutionTemplateLiteral(node2))
14945
+ if (ts4.isStringLiteralLike(node2) || ts4.isNoSubstitutionTemplateLiteral(node2))
13308
14946
  return node2.text;
13309
- if (ts.isNumericLiteral(node2))
14947
+ if (ts4.isNumericLiteral(node2))
13310
14948
  return Number(node2.text);
13311
- if (node2.kind === ts.SyntaxKind.TrueKeyword)
14949
+ if (node2.kind === ts4.SyntaxKind.TrueKeyword)
13312
14950
  return true;
13313
- if (node2.kind === ts.SyntaxKind.FalseKeyword)
14951
+ if (node2.kind === ts4.SyntaxKind.FalseKeyword)
13314
14952
  return false;
13315
14953
  return;
13316
14954
  }
@@ -13319,37 +14957,37 @@ function findDynamicImport(node2) {
13319
14957
  const visit = (child) => {
13320
14958
  if (result)
13321
14959
  return;
13322
- if (ts.isCallExpression(child) && child.expression.kind === ts.SyntaxKind.ImportKeyword && child.arguments[0] && ts.isStringLiteralLike(child.arguments[0])) {
14960
+ if (ts4.isCallExpression(child) && child.expression.kind === ts4.SyntaxKind.ImportKeyword && child.arguments[0] && ts4.isStringLiteralLike(child.arguments[0])) {
13323
14961
  result = child.arguments[0].text;
13324
14962
  return;
13325
14963
  }
13326
- ts.forEachChild(child, visit);
14964
+ ts4.forEachChild(child, visit);
13327
14965
  };
13328
14966
  visit(node2);
13329
14967
  return result;
13330
14968
  }
13331
14969
  function parseSource(source, filePath) {
13332
- const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true, filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
14970
+ const sourceFile = ts4.createSourceFile(filePath, source, ts4.ScriptTarget.Latest, true, filePath.endsWith(".tsx") ? ts4.ScriptKind.TSX : ts4.ScriptKind.TS);
13333
14971
  const imports = new Map;
13334
14972
  const constants2 = new Map;
13335
14973
  for (const statement of sourceFile.statements) {
13336
- if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {
14974
+ if (ts4.isImportDeclaration(statement) && ts4.isStringLiteral(statement.moduleSpecifier)) {
13337
14975
  const moduleSource = statement.moduleSpecifier.text;
13338
14976
  const clause = statement.importClause;
13339
14977
  if (clause?.name)
13340
14978
  imports.set(clause.name.text, moduleSource);
13341
14979
  const bindings = clause?.namedBindings;
13342
- if (bindings && ts.isNamedImports(bindings)) {
14980
+ if (bindings && ts4.isNamedImports(bindings)) {
13343
14981
  for (const element of bindings.elements)
13344
14982
  imports.set(element.name.text, moduleSource);
13345
14983
  }
13346
- if (bindings && ts.isNamespaceImport(bindings))
14984
+ if (bindings && ts4.isNamespaceImport(bindings))
13347
14985
  imports.set(bindings.name.text, moduleSource);
13348
14986
  }
13349
- if (!ts.isVariableStatement(statement))
14987
+ if (!ts4.isVariableStatement(statement))
13350
14988
  continue;
13351
14989
  for (const declaration of statement.declarationList.declarations) {
13352
- if (!ts.isIdentifier(declaration.name) || !declaration.initializer)
14990
+ if (!ts4.isIdentifier(declaration.name) || !declaration.initializer)
13353
14991
  continue;
13354
14992
  const scalar = scalarValue(declaration.initializer);
13355
14993
  if (scalar !== undefined)
@@ -13378,13 +15016,13 @@ function routeConditions(node2, sourceFile) {
13378
15016
  let current = node2;
13379
15017
  while (current?.parent) {
13380
15018
  const parent = current.parent;
13381
- if (ts.isConditionalExpression(parent)) {
15019
+ if (ts4.isConditionalExpression(parent)) {
13382
15020
  const condition = compact(parent.condition.getText(sourceFile));
13383
15021
  conditions.push(current === parent.whenTrue ? condition : `!(${condition})`);
13384
- } else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken && current === parent.right) {
15022
+ } else if (ts4.isBinaryExpression(parent) && parent.operatorToken.kind === ts4.SyntaxKind.AmpersandAmpersandToken && current === parent.right) {
13385
15023
  conditions.push(compact(parent.left.getText(sourceFile)));
13386
15024
  }
13387
- if (ts.isFunctionLike(parent))
15025
+ if (ts4.isFunctionLike(parent))
13388
15026
  break;
13389
15027
  current = parent;
13390
15028
  }
@@ -13393,36 +15031,36 @@ function routeConditions(node2, sourceFile) {
13393
15031
  function jsxAttributes(node2) {
13394
15032
  const result = new Map;
13395
15033
  for (const property of node2.attributes.properties)
13396
- if (ts.isJsxAttribute(property))
15034
+ if (ts4.isJsxAttribute(property))
13397
15035
  result.set(property.name.getText(), property);
13398
15036
  return result;
13399
15037
  }
13400
15038
  function jsxExpression(attribute) {
13401
15039
  const initializer = attribute?.initializer;
13402
- return initializer && ts.isJsxExpression(initializer) ? initializer.expression : undefined;
15040
+ return initializer && ts4.isJsxExpression(initializer) ? initializer.expression : undefined;
13403
15041
  }
13404
15042
  function jsxScalar(attribute, constants2) {
13405
15043
  if (!attribute)
13406
15044
  return;
13407
15045
  if (!attribute.initializer)
13408
15046
  return true;
13409
- if (ts.isStringLiteral(attribute.initializer))
15047
+ if (ts4.isStringLiteral(attribute.initializer))
13410
15048
  return attribute.initializer.text;
13411
15049
  const expression = jsxExpression(attribute);
13412
- return scalarValue(expression) ?? (expression && ts.isIdentifier(expression) ? constants2.get(expression.text) : undefined);
15050
+ return scalarValue(expression) ?? (expression && ts4.isIdentifier(expression) ? constants2.get(expression.text) : undefined);
13413
15051
  }
13414
15052
  function descendantTags(node2) {
13415
15053
  const tags = new Set;
13416
15054
  const visit = (child) => {
13417
- if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) {
13418
- const opening = ts.isJsxElement(child) ? child.openingElement : child;
15055
+ if (ts4.isJsxElement(child) || ts4.isJsxSelfClosingElement(child)) {
15056
+ const opening = ts4.isJsxElement(child) ? child.openingElement : child;
13419
15057
  const tag = opening.tagName.getText();
13420
15058
  if (child !== node2 && tag === "Route")
13421
15059
  return;
13422
15060
  if (!["Route", "Routes", "Suspense", "Fragment", "React.Fragment", "Navigate"].includes(tag))
13423
15061
  tags.add(tag);
13424
15062
  }
13425
- ts.forEachChild(child, visit);
15063
+ ts4.forEachChild(child, visit);
13426
15064
  };
13427
15065
  visit(node2);
13428
15066
  return [...tags];
@@ -13432,8 +15070,8 @@ function navigateTarget(node2, sourceFile) {
13432
15070
  const visit = (child) => {
13433
15071
  if (target)
13434
15072
  return;
13435
- if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) {
13436
- const opening = ts.isJsxElement(child) ? child.openingElement : child;
15073
+ if (ts4.isJsxElement(child) || ts4.isJsxSelfClosingElement(child)) {
15074
+ const opening = ts4.isJsxElement(child) ? child.openingElement : child;
13437
15075
  if (child !== node2 && opening.tagName.getText() === "Route")
13438
15076
  return;
13439
15077
  if (opening.tagName.getText() === "Navigate") {
@@ -13448,7 +15086,7 @@ function navigateTarget(node2, sourceFile) {
13448
15086
  }
13449
15087
  }
13450
15088
  }
13451
- ts.forEachChild(child, visit);
15089
+ ts4.forEachChild(child, visit);
13452
15090
  };
13453
15091
  visit(node2);
13454
15092
  return target;
@@ -13465,12 +15103,12 @@ function componentSource(component, imports) {
13465
15103
  }
13466
15104
  function objectProperty(object2, name) {
13467
15105
  for (const property of object2.properties) {
13468
- if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property))
15106
+ if (!ts4.isPropertyAssignment(property) && !ts4.isShorthandPropertyAssignment(property))
13469
15107
  continue;
13470
- const key = property.name && (ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name)) ? property.name.text : undefined;
15108
+ const key = property.name && (ts4.isIdentifier(property.name) || ts4.isStringLiteralLike(property.name)) ? property.name.text : undefined;
13471
15109
  if (key !== name)
13472
15110
  continue;
13473
- return ts.isPropertyAssignment(property) ? property.initializer : property.name;
15111
+ return ts4.isPropertyAssignment(property) ? property.initializer : property.name;
13474
15112
  }
13475
15113
  return;
13476
15114
  }
@@ -13512,7 +15150,7 @@ function extractReactRouterRoutes(source, filePath, options = {}) {
13512
15150
  };
13513
15151
  const visitRouteObjects = (array, parentPath) => {
13514
15152
  for (const element of array.elements) {
13515
- if (!ts.isObjectLiteralExpression(element))
15153
+ if (!ts4.isObjectLiteralExpression(element))
13516
15154
  continue;
13517
15155
  const index = scalarValue(objectProperty(element, "index")) === true;
13518
15156
  const pathValue = scalarValue(objectProperty(element, "path"));
@@ -13528,13 +15166,13 @@ function extractReactRouterRoutes(source, filePath, options = {}) {
13528
15166
  index,
13529
15167
  ...component ? { component } : {},
13530
15168
  ...typeof redirect === "string" ? { redirectTo: redirect } : {},
13531
- ...children && ts.isArrayLiteralExpression(children) ? { children } : {}
15169
+ ...children && ts4.isArrayLiteralExpression(children) ? { children } : {}
13532
15170
  });
13533
15171
  }
13534
15172
  };
13535
15173
  const visit = (node2, parentPath) => {
13536
- if (ts.isJsxElement(node2) || ts.isJsxSelfClosingElement(node2)) {
13537
- const opening = ts.isJsxElement(node2) ? node2.openingElement : node2;
15174
+ if (ts4.isJsxElement(node2) || ts4.isJsxSelfClosingElement(node2)) {
15175
+ const opening = ts4.isJsxElement(node2) ? node2.openingElement : node2;
13538
15176
  if (opening.tagName.getText() === "Route") {
13539
15177
  const attributes = jsxAttributes(opening);
13540
15178
  const index = jsxScalar(attributes.get("index"), parsed.constants) === true;
@@ -13547,61 +15185,61 @@ function extractReactRouterRoutes(source, filePath, options = {}) {
13547
15185
  const fullPath = joinRoutePath(parentPath, typeof pathValue === "string" ? pathValue : "", index);
13548
15186
  const redirectTo = navigateTarget(candidateNode, parsed.sourceFile);
13549
15187
  pushRoute({ node: node2, parentPath, path: typeof pathValue === "string" ? pathValue : "", index, ...component ? { component } : {}, candidates, ...redirectTo ? { redirectTo } : {} });
13550
- if (ts.isJsxElement(node2))
15188
+ if (ts4.isJsxElement(node2))
13551
15189
  for (const child of node2.children)
13552
15190
  visit(child, fullPath);
13553
15191
  return;
13554
15192
  }
13555
15193
  }
13556
- if (ts.isCallExpression(node2)) {
15194
+ if (ts4.isCallExpression(node2)) {
13557
15195
  const callee = node2.expression.getText(parsed.sourceFile);
13558
- if ((callee === "createBrowserRouter" || callee === "createHashRouter" || callee === "useRoutes") && node2.arguments[0] && ts.isArrayLiteralExpression(node2.arguments[0])) {
15196
+ if ((callee === "createBrowserRouter" || callee === "createHashRouter" || callee === "useRoutes") && node2.arguments[0] && ts4.isArrayLiteralExpression(node2.arguments[0])) {
13559
15197
  visitRouteObjects(node2.arguments[0], mountPath);
13560
15198
  }
13561
15199
  }
13562
- ts.forEachChild(node2, (child) => visit(child, parentPath));
15200
+ ts4.forEachChild(node2, (child) => visit(child, parentPath));
13563
15201
  };
13564
15202
  visit(parsed.sourceFile, mountPath);
13565
15203
  return routes.sort((left, right) => left.fullPath.localeCompare(right.fullPath) || left.location.startLine - right.location.startLine || left.location.startColumn - right.location.startColumn);
13566
15204
  }
13567
15205
  // src/moduleExports.ts
13568
- import * as ts2 from "typescript";
15206
+ import * as ts5 from "typescript";
13569
15207
  function exportedDeclarationName(statement) {
13570
- const exported = ts2.canHaveModifiers(statement) && ts2.getModifiers(statement)?.some((modifier) => modifier.kind === ts2.SyntaxKind.ExportKeyword);
15208
+ const exported = ts5.canHaveModifiers(statement) && ts5.getModifiers(statement)?.some((modifier) => modifier.kind === ts5.SyntaxKind.ExportKeyword);
13571
15209
  if (!exported)
13572
15210
  return;
13573
- if ((ts2.isFunctionDeclaration(statement) || ts2.isClassDeclaration(statement) || ts2.isInterfaceDeclaration(statement) || ts2.isTypeAliasDeclaration(statement) || ts2.isEnumDeclaration(statement)) && statement.name) {
15211
+ if ((ts5.isFunctionDeclaration(statement) || ts5.isClassDeclaration(statement) || ts5.isInterfaceDeclaration(statement) || ts5.isTypeAliasDeclaration(statement) || ts5.isEnumDeclaration(statement)) && statement.name) {
13574
15212
  return statement.name.text;
13575
15213
  }
13576
15214
  return;
13577
15215
  }
13578
15216
  function extractTypeScriptModuleExports(source, filePath = "module.ts") {
13579
- const sourceFile = ts2.createSourceFile(filePath, source, ts2.ScriptTarget.Latest, true, filePath.endsWith("x") ? ts2.ScriptKind.TSX : ts2.ScriptKind.TS);
15217
+ const sourceFile = createEcmaScriptSourceFile(source, filePath);
13580
15218
  const named = new Set;
13581
15219
  const wildcard = new Set;
13582
15220
  const targets = new Set;
13583
15221
  for (const statement of sourceFile.statements) {
13584
- if (ts2.isExportDeclaration(statement)) {
13585
- const target = statement.moduleSpecifier && ts2.isStringLiteral(statement.moduleSpecifier) ? statement.moduleSpecifier.text : undefined;
15222
+ if (ts5.isExportDeclaration(statement)) {
15223
+ const target = statement.moduleSpecifier && ts5.isStringLiteral(statement.moduleSpecifier) ? statement.moduleSpecifier.text : undefined;
13586
15224
  if (target)
13587
15225
  targets.add(target);
13588
15226
  if (!statement.exportClause) {
13589
15227
  if (target)
13590
15228
  wildcard.add(target);
13591
- } else if (ts2.isNamedExports(statement.exportClause)) {
15229
+ } else if (ts5.isNamedExports(statement.exportClause)) {
13592
15230
  for (const element of statement.exportClause.elements)
13593
15231
  named.add(element.name.text);
13594
- } else if (ts2.isNamespaceExport(statement.exportClause)) {
15232
+ } else if (ts5.isNamespaceExport(statement.exportClause)) {
13595
15233
  named.add(statement.exportClause.name.text);
13596
15234
  }
13597
15235
  continue;
13598
15236
  }
13599
- const declarationName = exportedDeclarationName(statement);
13600
- if (declarationName)
13601
- named.add(declarationName);
13602
- if (ts2.isVariableStatement(statement) && ts2.getModifiers(statement)?.some((modifier) => modifier.kind === ts2.SyntaxKind.ExportKeyword)) {
15237
+ const declarationName2 = exportedDeclarationName(statement);
15238
+ if (declarationName2)
15239
+ named.add(declarationName2);
15240
+ if (ts5.isVariableStatement(statement) && ts5.getModifiers(statement)?.some((modifier) => modifier.kind === ts5.SyntaxKind.ExportKeyword)) {
13603
15241
  for (const declaration of statement.declarationList.declarations) {
13604
- if (ts2.isIdentifier(declaration.name))
15242
+ if (ts5.isIdentifier(declaration.name))
13605
15243
  named.add(declaration.name.text);
13606
15244
  }
13607
15245
  }
@@ -13612,8 +15250,61 @@ function extractTypeScriptModuleExports(source, filePath = "module.ts") {
13612
15250
  targets: [...targets].sort()
13613
15251
  };
13614
15252
  }
15253
+ function extractEcmaScriptModuleExports(source, filePath = "module.ts") {
15254
+ const esm = extractTypeScriptModuleExports(source, filePath);
15255
+ const sourceFile = createEcmaScriptSourceFile(source, filePath);
15256
+ const commonJs = analyzeCommonJsModule(source, filePath);
15257
+ const diagnostics = [
15258
+ ...syntaxDiagnostics(sourceFile),
15259
+ ...commonJs.diagnostics
15260
+ ].map(({ code, line, column }) => ({ code, line, column }));
15261
+ if (diagnostics.length > 0) {
15262
+ return {
15263
+ named: [],
15264
+ wildcard: [],
15265
+ targets: [],
15266
+ coverageTier: EXTRACT_TS_COVERAGE_TIER,
15267
+ capabilities: [...EXTRACT_TS_CAPABILITIES],
15268
+ disposition: "unsupported",
15269
+ diagnostics
15270
+ };
15271
+ }
15272
+ return {
15273
+ named: [...new Set([
15274
+ ...esm.named,
15275
+ ...commonJs.exports.map((item) => item.exportedName)
15276
+ ])].sort(),
15277
+ wildcard: [...new Set([...esm.wildcard, ...commonJs.wildcardSources])].sort(),
15278
+ targets: [...new Set([
15279
+ ...esm.targets,
15280
+ ...commonJs.bindings.map((binding) => binding.source),
15281
+ ...commonJs.exports.flatMap((item) => item.source ? [item.source] : []),
15282
+ ...commonJs.wildcardSources
15283
+ ])].sort(),
15284
+ coverageTier: EXTRACT_TS_COVERAGE_TIER,
15285
+ capabilities: [...EXTRACT_TS_CAPABILITIES],
15286
+ disposition: "analyzed",
15287
+ diagnostics
15288
+ };
15289
+ }
15290
+ // src/evidenceAdapter.ts
15291
+ function typeScriptExtractionToEvidenceAdapterResult(extraction, invocation) {
15292
+ if (extraction.meta.pluginId !== "c4a-extract-ts") {
15293
+ throw new TypeError("TypeScript evidence adapter requires c4a-extract-ts output");
15294
+ }
15295
+ return extractionResultToEvidenceAdapterResult(extraction, invocation);
15296
+ }
15297
+ function typeScriptExtractionToEvidenceAdapterMaterialization(extraction, invocation) {
15298
+ return materializeIndexerEvidenceAdapterResult(typeScriptExtractionToEvidenceAdapterResult(extraction, invocation));
15299
+ }
13615
15300
  export {
15301
+ typeScriptExtractionToEvidenceAdapterResult,
15302
+ typeScriptExtractionToEvidenceAdapterMaterialization,
13616
15303
  extractTypeScriptModuleExports,
13617
15304
  extractReactRouterRoutes,
13618
- TypeScriptPlugin
15305
+ extractEcmaScriptModuleExports,
15306
+ ecmaScriptLanguage,
15307
+ TypeScriptPlugin,
15308
+ EXTRACT_TS_COVERAGE_TIER,
15309
+ EXTRACT_TS_CAPABILITIES
13619
15310
  };