@c4a/extract-ts 0.6.2 → 0.6.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.
package/README.md CHANGED
@@ -11,6 +11,34 @@ packages.
11
11
 
12
12
  **Depends on:** `@c4a/extract`, `web-tree-sitter`
13
13
 
14
+ ## React Router structural facts
15
+
16
+ Projects that use `extractCustom()` can reuse `extractReactRouterRoutes()` to
17
+ index JSX `<Route>` declarations and route-object arrays. It reports paths,
18
+ components, redirects, conditions, import sources, notes, and source locations
19
+ without classifying product meaning:
20
+
21
+ ```ts
22
+ import { extractReactRouterRoutes } from "@c4a/extract-ts";
23
+
24
+ const routes = extractReactRouterRoutes(source, "src/router.tsx", {
25
+ routeIdPrefix: "web",
26
+ mountPath: "/web",
27
+ });
28
+ ```
29
+
30
+ ## TypeScript module export facts
31
+
32
+ `extractTypeScriptModuleExports()` reads one TypeScript or TSX module and
33
+ returns deterministic named exports, wildcard export targets, and all
34
+ re-export targets. It does not resolve files or infer product meaning:
35
+
36
+ ```ts
37
+ import { extractTypeScriptModuleExports } from "@c4a/extract-ts";
38
+
39
+ const exports = extractTypeScriptModuleExports(source, "src/index.ts");
40
+ ```
41
+
14
42
  ## Current Extraction Coverage
15
43
 
16
44
  ### Entry Detection
@@ -0,0 +1,32 @@
1
+ # @c4a/extract-ts
2
+
3
+ Context 的 TypeScript/TSX 结构提取包。它实现 `@c4a/extract` 的插件协议,
4
+ 也是 SDK `extractTs({ source, collection: "codegraph" })` 阶段使用的默认
5
+ 提取器。
6
+
7
+ 除 TypeScript 符号、导出和 AST 关系外,包还提供可独立使用的 React Router
8
+ 结构提取:
9
+
10
+ ```ts
11
+ import { extractReactRouterRoutes } from "@c4a/extract-ts";
12
+
13
+ const routes = extractReactRouterRoutes(source, "src/router.tsx", {
14
+ routeIdPrefix: "web",
15
+ mountPath: "/web",
16
+ });
17
+ ```
18
+
19
+ 该函数读取 JSX `<Route>` 和 route object 数组,返回路径、组件、重定向、
20
+ 条件、导入来源、注释及源码位置,不判断业务含义。项目可以在
21
+ `extractCustom()` 中将这些结构事实映射为自己的候选。
22
+
23
+ 包还提供单文件导出面读取:
24
+
25
+ ```ts
26
+ import { extractTypeScriptModuleExports } from "@c4a/extract-ts";
27
+
28
+ const exports = extractTypeScriptModuleExports(source, "src/index.ts");
29
+ ```
30
+
31
+ 返回结果包含具名导出、通配导出目标和全部 re-export 目标。函数不解析文件、
32
+ 不追踪依赖,也不判断业务含义,适合由定制提取流程继续映射为领域事实。