@cfp-studio/analyzer-api 0.1.11 → 0.1.12

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 (3) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +56 -0
  3. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Zenc Labs Pty Ltd
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Zenc Labs Pty Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @cfp-studio/analyzer-api
2
+
3
+ 核心分析 API,用于组件/Story/TS 类型的静态分析、可预览 ID 生成与解析、分析器工厂等。为 CFP Studio 设计器和相关工具提供统一的类型分析与组件元数据抽象。
4
+
5
+ ## 特性
6
+
7
+ - 提供统一的 `Analyzer` 接口,支持 TS 组件/Story 批量分析、属性/类型收集、资源释放
8
+ - 支持可预览 ID 的生成与解析,便于组件/Story 的唯一定位
9
+ - 支持分析器工厂模式,可自定义 reader/logger
10
+ - 类型定义清晰,便于二次开发和类型推断
11
+ - 内置 Vitest 测试用例
12
+
13
+ ## 主要 API/模块
14
+
15
+ - `Analyzer`/`AnalyzerFactory`:分析器主接口与工厂
16
+ - `Component`/`Story`/`BasePreviewable`:可预览对象抽象
17
+ - `generatePreviewableId`/`decodePreviewableId`:可预览 ID 生成与解析
18
+ - `factoryWithDefaultOptions`:分析器工厂默认参数包装
19
+
20
+ ## 用法示例
21
+
22
+ ```ts
23
+ import { AnalyzerFactory } from '@cfp-studio/analyzer-api';
24
+
25
+ const factory: AnalyzerFactory = ...;
26
+ const analyzer = factory({ rootDir: '/project/root' });
27
+ const { components, stories } = await analyzer.crawlFiles(['src/App.tsx']);
28
+ await components[0].analyze();
29
+ analyzer.dispose();
30
+ ```
31
+
32
+ 可预览 ID:
33
+ ```ts
34
+ import { generatePreviewableId, decodePreviewableId } from '@cfp-studio/analyzer-api';
35
+ const id = generatePreviewableId({ filePath: '/src/App.tsx', name: 'App' });
36
+ const { filePath, name } = decodePreviewableId(id);
37
+ ```
38
+
39
+ ## 依赖
40
+ - `@cfp-studio/jsx-processor`:JSX 结构分析
41
+ - `@cfp-studio/serializable-values`:可序列化值类型
42
+ - `@cfp-studio/type-analyzer`:TS 类型分析
43
+ - `@cfp-studio/vfs`:虚拟文件系统
44
+ - `pino`:日志
45
+ - `unbuild`:打包
46
+ - `vitest`:测试
47
+
48
+ ## 构建
49
+
50
+ ```sh
51
+ pnpm build
52
+ ```
53
+
54
+ ## 许可证
55
+
56
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfp-studio/analyzer-api",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -20,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "@cfp-studio/jsx-processor": "^0.1.0",
22
22
  "@cfp-studio/serializable-values": "^9.0.7",
23
- "@cfp-studio/type-analyzer": "^10.1.7",
24
- "@cfp-studio/vfs": "^2.1.5",
23
+ "@cfp-studio/type-analyzer": "^10.1.8",
24
+ "@cfp-studio/vfs": "^2.1.6",
25
25
  "pino": "^9.10.0",
26
26
  "pino-pretty": "^13.1.1"
27
27
  },