@cfp-studio/core 1.0.2 → 1.0.3

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 +75 -0
  3. package/package.json +4 -4
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,75 @@
1
+ # @cfp-studio/core
2
+
3
+ CFP Studio 的核心运行时与服务编排包,负责组件/Story 静态分析、预览服务、插件架构、Vite 集成、API 路由、依赖管理等。是整个 monorepo 的中枢和 glue 层。
4
+
5
+ ---
6
+
7
+ ## 架构与工作原理
8
+
9
+ ### 1. 预览服务与中间件
10
+ - 启动 Express/Vite 组合服务,自动托管前端产物与 API。
11
+ - 支持自定义中间件(如 inspector、静态资源、CORS、API 路由等)。
12
+ - 通过 `Previewer` 类统一管理服务生命周期、端口、热重载、缓存等。
13
+
14
+ ### 2. 插件化框架支持
15
+ - 通过 `FrameworkPluginFactory`/`FrameworkPlugin` 接口,支持多框架(React/Vue/Svelte/Solid/Preact 等)插件热插拔。
16
+ - 插件可自定义类型分析、依赖检测、Vite 配置、特殊文件处理等。
17
+ - 自动检测项目依赖,动态选择兼容插件。
18
+
19
+ ### 3. 组件/Story 静态分析
20
+ - 集成 `@cfp-studio/analyzer-api`,支持 TS/JSX 组件、Story、属性、类型、propTypes 等静态分析。
21
+ - 支持批量文件爬取、缓存、依赖追踪、增量分析。
22
+ - 统一可预览 ID 生成与解析,便于前后端通信。
23
+
24
+ ### 4. Vite 深度集成与虚拟文件
25
+ - 内置多种 Vite 插件(如虚拟文件、CSS modules、inspector、public asset import、local eval 等)。
26
+ - 支持虚拟文件系统(VFS),可动态生成/注入模块。
27
+ - 自动处理 alias、tsconfig 路径、全局样式、热重载等。
28
+
29
+ ### 5. API 路由与远程调用
30
+ - 内置 `ApiRouter`,支持类型安全的 RPC 路由与分发。
31
+ - 支持插件/服务注册自定义 RPC 端点。
32
+ - 统一错误处理与日志。
33
+
34
+ ### 6. 缓存与依赖管理
35
+ - 自动管理缓存目录,支持多版本隔离。
36
+ - 支持依赖包版本检测、动态加载、兼容性校验。
37
+
38
+ ---
39
+
40
+ ## 主要 API/模块
41
+ - `Previewer`:预览服务主类
42
+ - `FrameworkPluginFactory`/`FrameworkPlugin`:插件接口
43
+ - `crawlFiles`/`findFiles`:批量文件爬取与查找
44
+ - `ApiRouter`:RPC 路由
45
+ - `ViteManager`:Vite 服务与插件集成
46
+ - `getCacheDir`:缓存目录管理
47
+ - `extractPackageDependencies`:依赖检测
48
+ - `toVitePath`:路径工具
49
+
50
+ ## 用法示例
51
+
52
+ ```ts
53
+ import { Previewer, findCompatiblePlugin } from '@cfp-studio/core';
54
+ const plugin = await findCompatiblePlugin({ rootDir: '/project' });
55
+ const previewer = new Previewer({
56
+ rootDir: '/project',
57
+ frameworkPlugin: plugin,
58
+ // ...其他参数
59
+ });
60
+ await previewer.start();
61
+ ```
62
+
63
+ ## 依赖
64
+ - `@cfp-studio/analyzer-api`、`@cfp-studio/api`、`@cfp-studio/config`、`@cfp-studio/iframe`、`@cfp-studio/middleware`、`@cfp-studio/serializable-values`、`@cfp-studio/type-analyzer`、`@cfp-studio/vfs`
65
+ - `express`、`vite`、`pino`、`fs-extra`、`axios`、`zod` 等
66
+
67
+ ## 构建
68
+
69
+ ```sh
70
+ pnpm build
71
+ ```
72
+
73
+ ## 许可证
74
+
75
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfp-studio/core",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -9,14 +9,14 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@cfp-studio/analyzer-api": "^0.1.11",
12
+ "@cfp-studio/analyzer-api": "^0.1.12",
13
13
  "@cfp-studio/api": "^16.1.1",
14
14
  "@cfp-studio/config": "7.0.1",
15
15
  "@cfp-studio/iframe": "^18.0.1",
16
16
  "@cfp-studio/middleware": "2.1.100",
17
17
  "@cfp-studio/serializable-values": "^9.0.7",
18
- "@cfp-studio/type-analyzer": "^10.1.7",
19
- "@cfp-studio/vfs": "^2.1.5",
18
+ "@cfp-studio/type-analyzer": "^10.1.8",
19
+ "@cfp-studio/vfs": "^2.1.6",
20
20
  "@fwouts/vite-tsconfig-paths": "^4.2.1",
21
21
  "assert-never": "1.4.0",
22
22
  "axios": "1.12.2",