@component-compass/parser-react 0.0.4 → 0.1.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.
package/dist/emit.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Emit references for a single React/TSX file into the graph.
3
+ *
4
+ * Replaces walk-jsx.ts. This is a structural AST walker — it pattern-matches
5
+ * shapes without doing resolution. Meaning emerges from the engine resolving
6
+ * the InferredType algebra in a post-Walk phase. See spec §8.
7
+ */
8
+ import type { Node as OxcNode, Program } from "@oxc-project/types";
9
+ import type { FileBuilder, InferredType } from "@component-compass/reference-graph";
10
+ export type EmitOptions = {
11
+ file: string;
12
+ source: string;
13
+ ast: Program;
14
+ fileBuilder: FileBuilder;
15
+ captureValues?: boolean;
16
+ };
17
+ export declare function emitReact(opts: EmitOptions): void;
18
+ export type PatternLeaf = {
19
+ symbol: string;
20
+ value: InferredType;
21
+ loc: {
22
+ line: number;
23
+ column: number;
24
+ };
25
+ };
26
+ /**
27
+ * Walk a function-parameter or destructure pattern AST node, yielding one
28
+ * PatternLeaf per leaf Identifier. The `source` InferredType describes the
29
+ * value being destructured (e.g. `ParameterOf(fnRef, i)` or the call-return
30
+ * type for `const { X } = useFoo()`). Leaves carry MemberOf chains over
31
+ * `source` keyed by destructure path. Mirrors Omlet's
32
+ * extract_symbols_from_pattern.
33
+ *
34
+ * `sourceText` is needed to compute `positionAt` for each leaf identifier.
35
+ */
36
+ export declare function extractBindingsFromPattern(pattern: OxcNode, source: InferredType, sourceText: string): PatternLeaf[];
37
+ /**
38
+ * True if the given node type is a JSX expression that produces a React
39
+ * element value. Used to detect module-scope `const X = <JSX/>` bindings
40
+ * whose JSX construction site needs prop-forward owner attribution.
41
+ */
42
+ export declare function isJsxTypeInit(nodeType: string): boolean;
43
+ /**
44
+ * Extract the root identifier from a JSX init expression.
45
+ * Returns the root binding name (`<Foo.Bar />` → `"Foo"`) or null for
46
+ * JSXFragment / namespaced names (no static root identifier).
47
+ */
48
+ export declare function rootSymbolOfJsxInit(init: OxcNode): string | null;