logicstamp-context 0.2.4 → 0.2.6

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 (107) hide show
  1. package/LLM_CONTEXT.md +2 -2
  2. package/README.md +28 -19
  3. package/dist/cli/commands/compare.d.ts.map +1 -1
  4. package/dist/cli/commands/compare.js +120 -13
  5. package/dist/cli/commands/compare.js.map +1 -1
  6. package/dist/cli/commands/context/fileWriter.d.ts.map +1 -1
  7. package/dist/cli/commands/context/fileWriter.js +68 -6
  8. package/dist/cli/commands/context/fileWriter.js.map +1 -1
  9. package/dist/cli/commands/context/tokenEstimator.d.ts.map +1 -1
  10. package/dist/cli/commands/context/tokenEstimator.js +12 -4
  11. package/dist/cli/commands/context/tokenEstimator.js.map +1 -1
  12. package/dist/cli/commands/context.d.ts.map +1 -1
  13. package/dist/cli/commands/context.js +71 -2
  14. package/dist/cli/commands/context.js.map +1 -1
  15. package/dist/cli/commands/validate.d.ts.map +1 -1
  16. package/dist/cli/commands/validate.js +84 -8
  17. package/dist/cli/commands/validate.js.map +1 -1
  18. package/dist/cli/handlers/compareHandler.d.ts.map +1 -1
  19. package/dist/cli/handlers/compareHandler.js +123 -9
  20. package/dist/cli/handlers/compareHandler.js.map +1 -1
  21. package/dist/core/astParser/detectors.d.ts.map +1 -1
  22. package/dist/core/astParser/detectors.js +130 -57
  23. package/dist/core/astParser/detectors.js.map +1 -1
  24. package/dist/core/astParser/extractors/componentExtractor.d.ts.map +1 -1
  25. package/dist/core/astParser/extractors/componentExtractor.js +89 -20
  26. package/dist/core/astParser/extractors/componentExtractor.js.map +1 -1
  27. package/dist/core/astParser/extractors/eventExtractor.d.ts.map +1 -1
  28. package/dist/core/astParser/extractors/eventExtractor.js +83 -28
  29. package/dist/core/astParser/extractors/eventExtractor.js.map +1 -1
  30. package/dist/core/astParser/extractors/propExtractor.d.ts.map +1 -1
  31. package/dist/core/astParser/extractors/propExtractor.js +142 -51
  32. package/dist/core/astParser/extractors/propExtractor.js.map +1 -1
  33. package/dist/core/astParser/extractors/stateExtractor.d.ts.map +1 -1
  34. package/dist/core/astParser/extractors/stateExtractor.js +95 -44
  35. package/dist/core/astParser/extractors/stateExtractor.js.map +1 -1
  36. package/dist/core/astParser.d.ts +4 -1
  37. package/dist/core/astParser.d.ts.map +1 -1
  38. package/dist/core/astParser.js +183 -26
  39. package/dist/core/astParser.js.map +1 -1
  40. package/dist/core/contractBuilder.d.ts.map +1 -1
  41. package/dist/core/contractBuilder.js +11 -15
  42. package/dist/core/contractBuilder.js.map +1 -1
  43. package/dist/core/manifest.d.ts.map +1 -1
  44. package/dist/core/manifest.js +82 -4
  45. package/dist/core/manifest.js.map +1 -1
  46. package/dist/core/pack/loader.d.ts.map +1 -1
  47. package/dist/core/pack/loader.js +22 -2
  48. package/dist/core/pack/loader.js.map +1 -1
  49. package/dist/core/pack.d.ts.map +1 -1
  50. package/dist/core/pack.js +57 -1
  51. package/dist/core/pack.js.map +1 -1
  52. package/dist/core/styleExtractor/index.d.ts +1 -0
  53. package/dist/core/styleExtractor/index.d.ts.map +1 -1
  54. package/dist/core/styleExtractor/index.js +1 -0
  55. package/dist/core/styleExtractor/index.js.map +1 -1
  56. package/dist/core/styleExtractor/layout.d.ts +13 -2
  57. package/dist/core/styleExtractor/layout.d.ts.map +1 -1
  58. package/dist/core/styleExtractor/layout.js +135 -65
  59. package/dist/core/styleExtractor/layout.js.map +1 -1
  60. package/dist/core/styleExtractor/material.d.ts.map +1 -1
  61. package/dist/core/styleExtractor/material.js +291 -66
  62. package/dist/core/styleExtractor/material.js.map +1 -1
  63. package/dist/core/styleExtractor/motion.d.ts +2 -2
  64. package/dist/core/styleExtractor/motion.d.ts.map +1 -1
  65. package/dist/core/styleExtractor/motion.js +425 -56
  66. package/dist/core/styleExtractor/motion.js.map +1 -1
  67. package/dist/core/styleExtractor/radix.d.ts +29 -0
  68. package/dist/core/styleExtractor/radix.d.ts.map +1 -0
  69. package/dist/core/styleExtractor/radix.js +315 -0
  70. package/dist/core/styleExtractor/radix.js.map +1 -0
  71. package/dist/core/styleExtractor/scss.d.ts.map +1 -1
  72. package/dist/core/styleExtractor/scss.js +37 -23
  73. package/dist/core/styleExtractor/scss.js.map +1 -1
  74. package/dist/core/styleExtractor/shadcn.d.ts +20 -0
  75. package/dist/core/styleExtractor/shadcn.d.ts.map +1 -0
  76. package/dist/core/styleExtractor/shadcn.js +345 -0
  77. package/dist/core/styleExtractor/shadcn.js.map +1 -0
  78. package/dist/core/styleExtractor/styleExtractor.d.ts.map +1 -1
  79. package/dist/core/styleExtractor/styleExtractor.js +267 -89
  80. package/dist/core/styleExtractor/styleExtractor.js.map +1 -1
  81. package/dist/core/styleExtractor/styled.d.ts +1 -1
  82. package/dist/core/styleExtractor/styled.d.ts.map +1 -1
  83. package/dist/core/styleExtractor/styled.js +308 -23
  84. package/dist/core/styleExtractor/styled.js.map +1 -1
  85. package/dist/core/styleExtractor/tailwind.d.ts +21 -3
  86. package/dist/core/styleExtractor/tailwind.d.ts.map +1 -1
  87. package/dist/core/styleExtractor/tailwind.js +279 -46
  88. package/dist/core/styleExtractor/tailwind.js.map +1 -1
  89. package/dist/types/UIFContract.d.ts +34 -0
  90. package/dist/types/UIFContract.d.ts.map +1 -1
  91. package/dist/types/UIFContract.js.map +1 -1
  92. package/dist/utils/config.d.ts.map +1 -1
  93. package/dist/utils/config.js +41 -2
  94. package/dist/utils/config.js.map +1 -1
  95. package/dist/utils/debug.d.ts +12 -0
  96. package/dist/utils/debug.d.ts.map +1 -0
  97. package/dist/utils/debug.js +16 -0
  98. package/dist/utils/debug.js.map +1 -0
  99. package/dist/utils/fsx.d.ts +2 -1
  100. package/dist/utils/fsx.d.ts.map +1 -1
  101. package/dist/utils/fsx.js +99 -28
  102. package/dist/utils/fsx.js.map +1 -1
  103. package/dist/utils/gitignore.d.ts.map +1 -1
  104. package/dist/utils/gitignore.js +28 -1
  105. package/dist/utils/gitignore.js.map +1 -1
  106. package/package.json +1 -1
  107. package/schema/logicstamp.context.schema.json +26 -1
@@ -1,73 +1,164 @@
1
1
  /**
2
2
  * Prop Extractor - Extracts component props from TypeScript interfaces/types
3
3
  */
4
+ import { debugError } from '../../../utils/debug.js';
4
5
  /**
5
6
  * Extract component props from TypeScript interfaces/types
6
7
  */
7
8
  export function extractProps(source) {
8
9
  const props = {};
9
- // Look for interfaces ending with Props
10
- source.getInterfaces().forEach((iface) => {
11
- if (/Props$/i.test(iface.getName())) {
12
- iface.getProperties().forEach((prop) => {
13
- const name = prop.getName();
14
- const isOptional = prop.hasQuestionToken();
15
- const type = prop.getType().getText();
16
- props[name] = normalizePropType(type, isOptional);
10
+ const filePath = source.getFilePath?.() ?? 'unknown';
11
+ try {
12
+ // Look for interfaces ending with Props
13
+ try {
14
+ source.getInterfaces().forEach((iface) => {
15
+ try {
16
+ if (/Props$/i.test(iface.getName())) {
17
+ iface.getProperties().forEach((prop) => {
18
+ try {
19
+ const name = prop.getName();
20
+ const isOptional = prop.hasQuestionToken();
21
+ const type = prop.getType().getText();
22
+ props[name] = normalizePropType(type, isOptional);
23
+ }
24
+ catch (error) {
25
+ debugError('propExtractor', 'extractProps', {
26
+ filePath,
27
+ error: error instanceof Error ? error.message : String(error),
28
+ context: 'props-interface-property',
29
+ });
30
+ // Continue with next property
31
+ }
32
+ });
33
+ }
34
+ }
35
+ catch (error) {
36
+ debugError('propExtractor', 'extractProps', {
37
+ filePath,
38
+ error: error instanceof Error ? error.message : String(error),
39
+ context: 'props-interface',
40
+ });
41
+ // Continue with next interface
42
+ }
17
43
  });
18
44
  }
19
- });
20
- // Look for type aliases ending with Props
21
- source.getTypeAliases().forEach((typeAlias) => {
22
- if (/Props$/i.test(typeAlias.getName())) {
23
- const type = typeAlias.getType();
24
- const properties = type.getProperties();
25
- properties.forEach((prop) => {
26
- const name = prop.getName();
27
- const propType = prop.getTypeAtLocation(typeAlias).getText();
28
- // Check if optional from declaration
29
- const declarations = prop.getDeclarations();
30
- const isOptional = declarations.some((decl) => decl.getText().includes('?:'));
31
- props[name] = normalizePropType(propType, isOptional);
45
+ catch (error) {
46
+ debugError('propExtractor', 'extractProps', {
47
+ filePath,
48
+ error: error instanceof Error ? error.message : String(error),
49
+ context: 'props-interfaces-batch',
32
50
  });
33
51
  }
34
- });
52
+ // Look for type aliases ending with Props
53
+ try {
54
+ source.getTypeAliases().forEach((typeAlias) => {
55
+ try {
56
+ if (/Props$/i.test(typeAlias.getName())) {
57
+ const type = typeAlias.getType();
58
+ const properties = type.getProperties();
59
+ properties.forEach((prop) => {
60
+ try {
61
+ const name = prop.getName();
62
+ const propType = prop.getTypeAtLocation(typeAlias).getText();
63
+ // Check if optional using fast methods
64
+ let isOptional = false;
65
+ // Method 1: If type includes undefined in union, it's optional
66
+ if (propType.includes('undefined')) {
67
+ isOptional = true;
68
+ }
69
+ else {
70
+ // Method 2: Check declarations for question token (faster than getText())
71
+ const declarations = prop.getDeclarations();
72
+ isOptional = declarations.some((decl) => {
73
+ // Use AST method to check for question token (faster than text parsing)
74
+ return decl.hasQuestionToken?.() === true;
75
+ });
76
+ }
77
+ props[name] = normalizePropType(propType, isOptional);
78
+ }
79
+ catch (error) {
80
+ debugError('propExtractor', 'extractProps', {
81
+ filePath,
82
+ error: error instanceof Error ? error.message : String(error),
83
+ context: 'props-typealias-property',
84
+ });
85
+ // Continue with next property
86
+ }
87
+ });
88
+ }
89
+ }
90
+ catch (error) {
91
+ debugError('propExtractor', 'extractProps', {
92
+ filePath,
93
+ error: error instanceof Error ? error.message : String(error),
94
+ context: 'props-typealias',
95
+ });
96
+ // Continue with next type alias
97
+ }
98
+ });
99
+ }
100
+ catch (error) {
101
+ debugError('propExtractor', 'extractProps', {
102
+ filePath,
103
+ error: error instanceof Error ? error.message : String(error),
104
+ context: 'props-typealiases-batch',
105
+ });
106
+ }
107
+ }
108
+ catch (error) {
109
+ debugError('propExtractor', 'extractProps', {
110
+ filePath,
111
+ error: error instanceof Error ? error.message : String(error),
112
+ });
113
+ return {};
114
+ }
35
115
  return props;
36
116
  }
37
117
  /**
38
118
  * Normalize a prop type into the rich PropType format
39
119
  */
40
120
  export function normalizePropType(typeText, isOptional) {
41
- // Remove 'undefined' from unions if present
42
- const cleanType = typeText.replace(/\s*\|\s*undefined/g, '').trim();
43
- // Detect literal unions: "a" | "b" | "c"
44
- const literalUnionMatch = cleanType.match(/^("[\w-]+"(\s*\|\s*"[\w-]+")+)$/);
45
- if (literalUnionMatch) {
46
- const literals = cleanType
47
- .split('|')
48
- .map(t => t.trim().replace(/^"|"$/g, ''));
49
- return {
50
- type: 'literal-union',
51
- literals,
52
- ...(isOptional && { optional: true })
53
- };
54
- }
55
- // Detect function types: () => void, (x: string) => void
56
- if (cleanType.includes('=>') || cleanType.startsWith('(') && cleanType.includes(')')) {
57
- return {
58
- type: 'function',
59
- signature: cleanType,
60
- ...(isOptional && { optional: true })
61
- };
121
+ try {
122
+ // Remove 'undefined' from unions if present
123
+ const cleanType = typeText.replace(/\s*\|\s*undefined/g, '').trim();
124
+ // Detect literal unions: "a" | "b" | "c"
125
+ const literalUnionMatch = cleanType.match(/^("[\w-]+"(\s*\|\s*"[\w-]+")+)$/);
126
+ if (literalUnionMatch) {
127
+ const literals = cleanType
128
+ .split('|')
129
+ .map(t => t.trim().replace(/^"|"$/g, ''));
130
+ return {
131
+ type: 'literal-union',
132
+ literals,
133
+ ...(isOptional && { optional: true })
134
+ };
135
+ }
136
+ // Detect function types: () => void, (x: string) => void
137
+ if (cleanType.includes('=>') || cleanType.startsWith('(') && cleanType.includes(')')) {
138
+ return {
139
+ type: 'function',
140
+ signature: cleanType,
141
+ ...(isOptional && { optional: true })
142
+ };
143
+ }
144
+ // Simple type with optionality
145
+ if (isOptional) {
146
+ // For all optional types, return object with optional flag to preserve the optional information
147
+ return {
148
+ type: cleanType,
149
+ optional: true
150
+ };
151
+ }
152
+ // Return simple string for common types (backward compat)
153
+ return cleanType;
62
154
  }
63
- // Simple type with optionality
64
- if (isOptional && !['string', 'number', 'boolean'].includes(cleanType)) {
65
- return {
66
- type: cleanType,
67
- optional: true
68
- };
155
+ catch (error) {
156
+ // Fallback to simple string type on error
157
+ debugError('propExtractor', 'normalizePropType', {
158
+ error: error instanceof Error ? error.message : String(error),
159
+ typeText,
160
+ });
161
+ return typeText;
69
162
  }
70
- // Return simple string for common types (backward compat)
71
- return cleanType;
72
163
  }
73
164
  //# sourceMappingURL=propExtractor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"propExtractor.js","sourceRoot":"","sources":["../../../../src/core/astParser/extractors/propExtractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,MAAM,KAAK,GAA6B,EAAE,CAAC;IAE3C,wCAAwC;IACxC,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YACpC,KAAK,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC;gBAEtC,KAAK,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,0CAA0C;IAC1C,MAAM,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC5C,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,SAAS,CAAC,OAA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+1 @@
1
- {"version":3,"file":"stateExtractor.d.ts","sourceRoot":"","sources":["../../../../src/core/astParser/extractors/stateExtractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,CAY7D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAyCvE"}
1
+ {"version":3,"file":"stateExtractor.d.ts","sourceRoot":"","sources":["../../../../src/core/astParser/extractors/stateExtractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAGlD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,CA8B7D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoEvE"}
@@ -2,18 +2,39 @@
2
2
  * State Extractor - Extracts component state and variable declarations from AST
3
3
  */
4
4
  import { SyntaxKind } from 'ts-morph';
5
+ import { debugError } from '../../../utils/debug.js';
5
6
  /**
6
7
  * Extract all variable declarations (const, let, var)
7
8
  */
8
9
  export function extractVariables(source) {
9
10
  const variables = new Set();
10
- source.getVariableDeclarations().forEach((varDecl) => {
11
- const name = varDecl.getName();
12
- // Skip destructured state setters (e.g., setCount from [count, setCount])
13
- if (!name.startsWith('set') || !varDecl.getParent()?.getText().includes('useState')) {
14
- variables.add(name);
15
- }
16
- });
11
+ const filePath = source.getFilePath?.() ?? 'unknown';
12
+ try {
13
+ source.getVariableDeclarations().forEach((varDecl) => {
14
+ try {
15
+ const name = varDecl.getName();
16
+ // Skip destructured state setters (e.g., setCount from [count, setCount])
17
+ if (!name.startsWith('set') || !varDecl.getParent()?.getText().includes('useState')) {
18
+ variables.add(name);
19
+ }
20
+ }
21
+ catch (error) {
22
+ debugError('stateExtractor', 'extractVariables', {
23
+ filePath,
24
+ error: error instanceof Error ? error.message : String(error),
25
+ context: 'variables-iteration',
26
+ });
27
+ // Continue with next variable
28
+ }
29
+ });
30
+ }
31
+ catch (error) {
32
+ debugError('stateExtractor', 'extractVariables', {
33
+ filePath,
34
+ error: error instanceof Error ? error.message : String(error),
35
+ });
36
+ return [];
37
+ }
17
38
  return Array.from(variables).sort();
18
39
  }
19
40
  /**
@@ -21,46 +42,76 @@ export function extractVariables(source) {
21
42
  */
22
43
  export function extractState(source) {
23
44
  const state = {};
24
- source.getDescendantsOfKind(SyntaxKind.VariableDeclaration).forEach((varDecl) => {
25
- const initializer = varDecl.getInitializer();
26
- if (!initializer)
27
- return;
28
- const initText = initializer.getText();
29
- if (initText.startsWith('useState(') || initText.startsWith('useState<')) {
30
- const bindingName = varDecl.getName();
31
- // Extract state variable name from array destructuring [value, setValue]
32
- const match = bindingName.match(/\[([a-zA-Z0-9_]+)\s*,/);
33
- if (match) {
34
- const stateVar = match[1];
35
- // Try to infer type from generic or initial value
36
- let type = 'unknown';
37
- const genericMatch = initText.match(/useState<([^>]+)>/);
38
- if (genericMatch) {
39
- type = genericMatch[1];
40
- }
41
- else {
42
- // Infer from initial value
43
- const valueMatch = initText.match(/useState\(([^)]+)\)/);
44
- if (valueMatch) {
45
- const value = valueMatch[1].trim();
46
- if (value === 'true' || value === 'false')
47
- type = 'boolean';
48
- else if (/^\d+$/.test(value))
49
- type = 'number';
50
- else if (/^["']/.test(value))
51
- type = 'string';
52
- else if (value === 'null')
53
- type = 'null';
54
- else if (value === '[]')
55
- type = 'array';
56
- else if (value === '{}')
57
- type = 'object';
45
+ const filePath = source.getFilePath?.() ?? 'unknown';
46
+ try {
47
+ source.getDescendantsOfKind(SyntaxKind.VariableDeclaration).forEach((varDecl) => {
48
+ try {
49
+ const initializer = varDecl.getInitializer();
50
+ if (!initializer)
51
+ return;
52
+ const initText = initializer.getText();
53
+ if (initText.startsWith('useState(') || initText.startsWith('useState<')) {
54
+ const bindingName = varDecl.getName();
55
+ // Extract state variable name from array destructuring [value, setValue]
56
+ const match = bindingName.match(/\[([a-zA-Z0-9_]+)\s*,/);
57
+ if (match) {
58
+ const stateVar = match[1];
59
+ // Try to infer type from generic or initial value
60
+ let type = 'unknown';
61
+ try {
62
+ const genericMatch = initText.match(/useState<([^>]+)>/);
63
+ if (genericMatch) {
64
+ type = genericMatch[1];
65
+ }
66
+ else {
67
+ // Infer from initial value
68
+ const valueMatch = initText.match(/useState\(([^)]+)\)/);
69
+ if (valueMatch) {
70
+ const value = valueMatch[1].trim();
71
+ if (value === 'true' || value === 'false')
72
+ type = 'boolean';
73
+ else if (/^\d+$/.test(value))
74
+ type = 'number';
75
+ else if (/^["']/.test(value))
76
+ type = 'string';
77
+ else if (value === 'null')
78
+ type = 'null';
79
+ else if (value === '[]')
80
+ type = 'array';
81
+ else if (value === '{}')
82
+ type = 'object';
83
+ }
84
+ }
85
+ }
86
+ catch (error) {
87
+ debugError('stateExtractor', 'extractState', {
88
+ filePath,
89
+ error: error instanceof Error ? error.message : String(error),
90
+ context: 'state-type-inference',
91
+ });
92
+ // Use 'unknown' as fallback
93
+ }
94
+ state[stateVar] = type;
58
95
  }
59
96
  }
60
- state[stateVar] = type;
61
97
  }
62
- }
63
- });
98
+ catch (error) {
99
+ debugError('stateExtractor', 'extractState', {
100
+ filePath,
101
+ error: error instanceof Error ? error.message : String(error),
102
+ context: 'state-iteration',
103
+ });
104
+ // Continue with next declaration
105
+ }
106
+ });
107
+ }
108
+ catch (error) {
109
+ debugError('stateExtractor', 'extractState', {
110
+ filePath,
111
+ error: error instanceof Error ? error.message : String(error),
112
+ });
113
+ return {};
114
+ }
64
115
  return state;
65
116
  }
66
117
  //# sourceMappingURL=stateExtractor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stateExtractor.js","sourceRoot":"","sources":["../../../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,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,gBAAgB,EAAE,cAAc,EAAE;YAC3C,QAAQ;YACR,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -22,7 +22,7 @@
22
22
  * semantic: uif:7152990a34f9eda63e745359 (informational)
23
23
  * file: uif:d25bdbc8e21386b1a5e907d7
24
24
  */
25
- import type { LogicSignature, ContractKind, PropType, EventType, NextJSMetadata } from '../types/UIFContract.js';
25
+ import type { LogicSignature, ContractKind, PropType, EventType, NextJSMetadata, ExportMetadata } from '../types/UIFContract.js';
26
26
  export interface AstExtract {
27
27
  kind: ContractKind;
28
28
  variables: string[];
@@ -35,9 +35,12 @@ export interface AstExtract {
35
35
  imports: string[];
36
36
  jsxRoutes: string[];
37
37
  nextjs?: NextJSMetadata;
38
+ exports?: ExportMetadata;
39
+ exportedFunctions?: string[];
38
40
  }
39
41
  /**
40
42
  * Extract all structural information from a TypeScript/React file
43
+ * Returns empty AST on parsing errors to prevent crashes
41
44
  */
42
45
  export declare function extractFromFile(filePath: string): Promise<AstExtract>;
43
46
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"astParser.d.ts","sourceRoot":"","sources":["../../src/core/astParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOjH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAA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