@c4a/extract-ts 0.5.33-alpha.2 → 0.5.33-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +46 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -13744,6 +13744,10 @@ var symbolParamSchema = exports_external.object({
13744
13744
  name: exports_external.string().min(1),
13745
13745
  type: exports_external.string().min(1).nullable()
13746
13746
  });
13747
+ var symbolRenameEvidenceSchema = exports_external.object({
13748
+ previous_identity_key: exports_external.string().min(1),
13749
+ reason: exports_external.string().min(1)
13750
+ });
13747
13751
  var symbolInfoSchema = exports_external.lazy(() => exports_external.object({
13748
13752
  name: exports_external.string().min(1),
13749
13753
  kind: symbolKindSchema2,
@@ -13751,6 +13755,14 @@ var symbolInfoSchema = exports_external.lazy(() => exports_external.object({
13751
13755
  file: exports_external.string().min(1),
13752
13756
  line: exports_external.number().int().positive(),
13753
13757
  endLine: exports_external.number().int().positive(),
13758
+ symbol_id: exports_external.string().min(1).optional(),
13759
+ identity_key: exports_external.string().min(1).optional(),
13760
+ display_name: exports_external.string().min(1).optional(),
13761
+ member_path: exports_external.array(exports_external.string().min(1)).optional(),
13762
+ root_symbol_id: exports_external.string().min(1).optional(),
13763
+ parent_symbol_id: exports_external.string().min(1).optional(),
13764
+ symbol_locator: exports_external.string().min(1).optional(),
13765
+ rename_evidence: exports_external.array(symbolRenameEvidenceSchema).optional(),
13754
13766
  members: exports_external.array(symbolInfoSchema).optional(),
13755
13767
  params: exports_external.array(symbolParamSchema).optional(),
13756
13768
  returnType: exports_external.string().min(1).nullable().optional(),
@@ -13931,6 +13943,37 @@ var MANIFEST_FILES = [
13931
13943
  "build.gradle"
13932
13944
  ];
13933
13945
  var MANIFEST_NAMES = new Set(MANIFEST_FILES.map((f) => f.toLowerCase()));
13946
+ // ../extract/src/codeSnapshot.ts
13947
+ var buildCodeSymbolLocator = (packageName, symbolId, symbol) => `${packageName}:${symbolId}:${symbol.kind}:${symbol.file}:${symbol.line}-${symbol.endLine}`;
13948
+ var buildCodeSymbolIdentityKey = (packageName, rootSymbolId, symbolId, kind, hasParent) => hasParent ? `${packageName}|root:${rootSymbolId}|owned:${symbolId}|${kind}` : `${packageName}|root:${symbolId}|${kind}`;
13949
+ function applyCodeSymbolIdentity(symbol, context) {
13950
+ const segment = symbol.name;
13951
+ const symbolId = symbol.symbol_id ?? (context.parentSymbolId ? `${context.parentSymbolId}.${segment}` : segment);
13952
+ const rootSymbolId = symbol.root_symbol_id ?? context.rootSymbolId ?? symbolId;
13953
+ const memberPath = symbol.member_path ?? [...context.parentPath ?? [], segment];
13954
+ const hasParent = context.parentSymbolId !== undefined || symbol.parent_symbol_id !== undefined;
13955
+ const parentSymbolId = symbol.parent_symbol_id ?? context.parentSymbolId;
13956
+ const members = symbol.members?.map((member) => applyCodeSymbolIdentity(member, {
13957
+ packageName: context.packageName,
13958
+ parentSymbolId: symbolId,
13959
+ rootSymbolId,
13960
+ parentPath: memberPath
13961
+ }));
13962
+ return {
13963
+ ...symbol,
13964
+ symbol_id: symbolId,
13965
+ identity_key: symbol.identity_key ?? buildCodeSymbolIdentityKey(context.packageName, rootSymbolId, symbolId, symbol.kind, hasParent),
13966
+ display_name: symbol.display_name ?? symbol.name,
13967
+ member_path: memberPath,
13968
+ root_symbol_id: rootSymbolId,
13969
+ ...parentSymbolId !== undefined ? { parent_symbol_id: parentSymbolId } : {},
13970
+ symbol_locator: symbol.symbol_locator ?? buildCodeSymbolLocator(context.packageName, symbolId, symbol),
13971
+ ...members && members.length > 0 ? { members } : {}
13972
+ };
13973
+ }
13974
+ function applySymbolIdentities(symbols, packageName) {
13975
+ return symbols.map((symbol) => applyCodeSymbolIdentity(symbol, { packageName }));
13976
+ }
13934
13977
  // ../extract/src/runner.ts
13935
13978
  var pluginSpecSchema = exports_external.object({
13936
13979
  package: exports_external.string().min(1),
@@ -14668,7 +14711,7 @@ var extractSymbols = async (entries, fs2, options) => {
14668
14711
  });
14669
14712
  }
14670
14713
  }
14671
- const symbols = [...exportedSymbols, ...internalSymbols];
14714
+ const rawSymbols = [...exportedSymbols, ...internalSymbols];
14672
14715
  const typeDeclarations = new Map;
14673
14716
  for (const analysis of analyses.values()) {
14674
14717
  for (const [name, decl] of analysis.declarations) {
@@ -14677,7 +14720,7 @@ var extractSymbols = async (entries, fs2, options) => {
14677
14720
  }
14678
14721
  }
14679
14722
  }
14680
- for (const sym of symbols) {
14723
+ for (const sym of rawSymbols) {
14681
14724
  if (sym.kind !== "component")
14682
14725
  continue;
14683
14726
  let propsTypeName;
@@ -14698,6 +14741,7 @@ var extractSymbols = async (entries, fs2, options) => {
14698
14741
  relations.push(createRelation("of_type" /* OfType */, sym.name, propsTypeName, false, sym.line));
14699
14742
  }
14700
14743
  }
14744
+ const symbols = applySymbolIdentities(rawSymbols, options.packageInfo.name);
14701
14745
  const files = [...filePaths].sort().map((filePath) => ({
14702
14746
  path: filePath,
14703
14747
  language: filePath.endsWith(".tsx") ? "tsx" : "typescript",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract-ts",
3
- "version": "0.5.33-alpha.2",
3
+ "version": "0.5.33-alpha.4",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "web-tree-sitter": "^0.20.8"