@cfp-studio/analyzer-api 0.1.9 → 0.1.10

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.
@@ -1,8 +1,9 @@
1
- import { AnalyzerOptions, Analyzer, AnalyzerFactory } from './index.mjs';
1
+ import { a as AnalyzerOptions, A as Analyzer, b as AnalyzerFactory } from './shared/analyzer-api.40adf6f7.mjs';
2
2
  import '@cfp-studio/serializable-values';
3
3
  import '@cfp-studio/type-analyzer';
4
4
  import '@cfp-studio/vfs';
5
5
  import 'pino';
6
+ import '@cfp-studio/jsx-processor';
6
7
 
7
8
  /**
8
9
  * 给 AnalyzerFactory 工厂函数进行默认选项填充
package/dist/factory.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { AnalyzerOptions, Analyzer, AnalyzerFactory } from './index.js';
1
+ import { a as AnalyzerOptions, A as Analyzer, b as AnalyzerFactory } from './shared/analyzer-api.40adf6f7.js';
2
2
  import '@cfp-studio/serializable-values';
3
3
  import '@cfp-studio/type-analyzer';
4
4
  import '@cfp-studio/vfs';
5
5
  import 'pino';
6
+ import '@cfp-studio/jsx-processor';
6
7
 
7
8
  /**
8
9
  * 给 AnalyzerFactory 工厂函数进行默认选项填充
package/dist/factory.mjs CHANGED
@@ -1,18 +1 @@
1
- import { createFileSystemReader } from '@cfp-studio/vfs';
2
- import pino from 'pino';
3
- import PinoPretty from 'pino-pretty';
4
-
5
- const { pino: createLogger } = pino;
6
- const prettyLogger = PinoPretty;
7
- function factoryWithDefaultOptions(factory) {
8
- return (options) => factory({
9
- // 展开传入的选项
10
- ...options,
11
- // 如果 options 中没有提供 reader,则使用 createFileSystemReader 创建一个
12
- reader: options.reader || createFileSystemReader(),
13
- // 如果 options 中没有提供 logger,则创建一个默认的 logger
14
- logger: options.logger || createLogger({ level: "debug" }, prettyLogger({ colorize: true }))
15
- });
16
- }
17
-
18
- export { factoryWithDefaultOptions };
1
+ import{createFileSystemReader as o}from"@cfp-studio/vfs";import t from"pino";import i from"pino-pretty";const{pino:a}=t,l=i;function m(r){return e=>r({...e,reader:e.reader||o(),logger:e.logger||a({level:"debug"},l({colorize:!0}))})}export{m as factoryWithDefaultOptions};
package/dist/index.d.mts CHANGED
@@ -1,20 +1,10 @@
1
- import { SerializableValue } from '@cfp-studio/serializable-values';
2
- import { TypeAnalyzer, ValueType, CollectedTypes } from '@cfp-studio/type-analyzer';
3
- import { Reader } from '@cfp-studio/vfs';
4
- import { Logger } from 'pino';
1
+ export { A as Analyzer, b as AnalyzerFactory, a as AnalyzerOptions, B as BasePreviewable, f as BasicComponent, C as Component, c as ComponentAnalysis, F as FileSourcePosition, S as Story, d as StoryAnalysis, e as StoryArgs } from './shared/analyzer-api.40adf6f7.mjs';
2
+ import '@cfp-studio/serializable-values';
3
+ import '@cfp-studio/type-analyzer';
4
+ import '@cfp-studio/vfs';
5
+ import 'pino';
6
+ import '@cfp-studio/jsx-processor';
5
7
 
6
- interface JSXNode {
7
- displayName?: string;
8
- tag: string;
9
- type: "element" | "fragment" | "text" | "expression";
10
- isComponent?: boolean;
11
- jsxAttr?: Record<string, unknown>;
12
- children: JSXNode[];
13
- location: {
14
- start: number;
15
- end: number;
16
- };
17
- }
18
8
  type PreviewableId = {
19
9
  filePath: string;
20
10
  name: string;
@@ -40,135 +30,4 @@ declare function generatePreviewableId(options: {
40
30
  */
41
31
  declare function decodePreviewableId(id: string): PreviewableId;
42
32
 
43
- /**
44
- * 定义 Analyzer 类型,包含类型分析器、文件爬取方法和资源释放方法
45
- */
46
- type Analyzer = {
47
- /**
48
- * 类型分析器,去除了 dispose 方法
49
- */
50
- typeAnalyzer: Omit<TypeAnalyzer, "dispose">;
51
- /**
52
- * 爬取指定文件路径的文件,返回组件和故事的集合
53
- * @param filePaths - 要爬取的文件路径数组
54
- * @returns 包含组件和故事数组的 Promise
55
- */
56
- crawlFiles: (filePaths: string[]) => Promise<{
57
- components: Component[];
58
- stories: Story[];
59
- }>;
60
- /**
61
- * 释放 Analyzer 占用的资源
62
- */
63
- dispose: () => void;
64
- };
65
- type AnalyzerOptions = {
66
- rootDir: string;
67
- reader?: Reader;
68
- logger?: Logger;
69
- };
70
- /**
71
- * 定义 AnalyzerFactory 类型,是一个函数,用于创建 Analyzer 实例
72
- * @param options - 创建 Analyzer 所需的选项
73
- * @param options.rootDir - 根目录路径
74
- * @param options.reader - 可选的读取器
75
- * @param options.logger - 可选的日志记录器
76
- * @returns 新创建的 Analyzer 实例
77
- */
78
- type AnalyzerFactory = (options: AnalyzerOptions) => Analyzer;
79
- /**
80
- * 定义 BasePreviewable 接口,作为可预览对象的基础接口
81
- */
82
- interface BasePreviewable {
83
- /**
84
- * 可预览对象的唯一标识符
85
- */
86
- id: string;
87
- /**
88
- * 可预览对象在文件中的源位置
89
- */
90
- sourcePosition: FileSourcePosition;
91
- }
92
- /**
93
- * 定义 Component 接口,继承自 BasePreviewable 接口,代表一个组件
94
- */
95
- interface Component extends BasePreviewable {
96
- /**
97
- * 指示组件是否被导出
98
- */
99
- exported: boolean;
100
- /**
101
- * 分析组件,返回组件分析结果的 Promise
102
- * @returns 包含组件属性和类型信息的 ComponentAnalysis 对象的 Promise
103
- */
104
- analyze: (withTreeData?: boolean) => Promise<ComponentAnalysis>;
105
- }
106
- /**
107
- * 定义 ComponentAnalysis 接口,包含组件分析的结果
108
- */
109
- interface ComponentAnalysis {
110
- /**
111
- * 组件的属性类型
112
- */
113
- props: ValueType;
114
- /**
115
- * 收集到的组件类型信息
116
- */
117
- types: CollectedTypes;
118
- jsxTree?: JSXNode;
119
- }
120
- /**
121
- * 定义 Story 接口,继承自 BasePreviewable 接口,代表一个故事
122
- */
123
- interface Story extends BasePreviewable {
124
- /**
125
- * 分析故事,返回故事分析结果的 Promise
126
- * @returns 包含故事参数信息的 StoryAnalysis 对象的 Promise
127
- */
128
- analyze: () => Promise<StoryAnalysis>;
129
- /**
130
- * 与故事关联的基本组件,可能为 null
131
- */
132
- associatedComponent: BasicComponent | null;
133
- }
134
- /**
135
- * 定义 StoryAnalysis 接口,包含故事分析的结果
136
- */
137
- interface StoryAnalysis {
138
- /**
139
- * 故事的参数,可能为 null
140
- */
141
- args: StoryArgs | null;
142
- }
143
- /**
144
- * 定义 StoryArgs 类型,包含故事参数的源位置和值
145
- */
146
- type StoryArgs = {
147
- /**
148
- * 故事参数在文件中的源位置
149
- */
150
- sourcePosition: FileSourcePosition;
151
- /**
152
- * 故事参数的值
153
- */
154
- value: SerializableValue;
155
- };
156
- /**
157
- * 定义 FileSourcePosition 类型,包含文件中某个位置的起始和结束索引
158
- */
159
- type FileSourcePosition = {
160
- /**
161
- * 起始索引
162
- */
163
- start: number;
164
- /**
165
- * 结束索引
166
- */
167
- end: number;
168
- };
169
- /**
170
- * 定义 BasicComponent 类型,是 Component 类型的部分属性集合
171
- */
172
- type BasicComponent = Pick<Component, "id" | "analyze">;
173
-
174
- export { type Analyzer, type AnalyzerFactory, type AnalyzerOptions, type BasePreviewable, type BasicComponent, type Component, type ComponentAnalysis, type FileSourcePosition, type JSXNode, type PreviewableId, type Story, type StoryAnalysis, type StoryArgs, decodePreviewableId, generatePreviewableId };
33
+ export { type PreviewableId, decodePreviewableId, generatePreviewableId };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,10 @@
1
- import { SerializableValue } from '@cfp-studio/serializable-values';
2
- import { TypeAnalyzer, ValueType, CollectedTypes } from '@cfp-studio/type-analyzer';
3
- import { Reader } from '@cfp-studio/vfs';
4
- import { Logger } from 'pino';
1
+ export { A as Analyzer, b as AnalyzerFactory, a as AnalyzerOptions, B as BasePreviewable, f as BasicComponent, C as Component, c as ComponentAnalysis, F as FileSourcePosition, S as Story, d as StoryAnalysis, e as StoryArgs } from './shared/analyzer-api.40adf6f7.js';
2
+ import '@cfp-studio/serializable-values';
3
+ import '@cfp-studio/type-analyzer';
4
+ import '@cfp-studio/vfs';
5
+ import 'pino';
6
+ import '@cfp-studio/jsx-processor';
5
7
 
6
- interface JSXNode {
7
- displayName?: string;
8
- tag: string;
9
- type: "element" | "fragment" | "text" | "expression";
10
- isComponent?: boolean;
11
- jsxAttr?: Record<string, unknown>;
12
- children: JSXNode[];
13
- location: {
14
- start: number;
15
- end: number;
16
- };
17
- }
18
8
  type PreviewableId = {
19
9
  filePath: string;
20
10
  name: string;
@@ -40,135 +30,4 @@ declare function generatePreviewableId(options: {
40
30
  */
41
31
  declare function decodePreviewableId(id: string): PreviewableId;
42
32
 
43
- /**
44
- * 定义 Analyzer 类型,包含类型分析器、文件爬取方法和资源释放方法
45
- */
46
- type Analyzer = {
47
- /**
48
- * 类型分析器,去除了 dispose 方法
49
- */
50
- typeAnalyzer: Omit<TypeAnalyzer, "dispose">;
51
- /**
52
- * 爬取指定文件路径的文件,返回组件和故事的集合
53
- * @param filePaths - 要爬取的文件路径数组
54
- * @returns 包含组件和故事数组的 Promise
55
- */
56
- crawlFiles: (filePaths: string[]) => Promise<{
57
- components: Component[];
58
- stories: Story[];
59
- }>;
60
- /**
61
- * 释放 Analyzer 占用的资源
62
- */
63
- dispose: () => void;
64
- };
65
- type AnalyzerOptions = {
66
- rootDir: string;
67
- reader?: Reader;
68
- logger?: Logger;
69
- };
70
- /**
71
- * 定义 AnalyzerFactory 类型,是一个函数,用于创建 Analyzer 实例
72
- * @param options - 创建 Analyzer 所需的选项
73
- * @param options.rootDir - 根目录路径
74
- * @param options.reader - 可选的读取器
75
- * @param options.logger - 可选的日志记录器
76
- * @returns 新创建的 Analyzer 实例
77
- */
78
- type AnalyzerFactory = (options: AnalyzerOptions) => Analyzer;
79
- /**
80
- * 定义 BasePreviewable 接口,作为可预览对象的基础接口
81
- */
82
- interface BasePreviewable {
83
- /**
84
- * 可预览对象的唯一标识符
85
- */
86
- id: string;
87
- /**
88
- * 可预览对象在文件中的源位置
89
- */
90
- sourcePosition: FileSourcePosition;
91
- }
92
- /**
93
- * 定义 Component 接口,继承自 BasePreviewable 接口,代表一个组件
94
- */
95
- interface Component extends BasePreviewable {
96
- /**
97
- * 指示组件是否被导出
98
- */
99
- exported: boolean;
100
- /**
101
- * 分析组件,返回组件分析结果的 Promise
102
- * @returns 包含组件属性和类型信息的 ComponentAnalysis 对象的 Promise
103
- */
104
- analyze: (withTreeData?: boolean) => Promise<ComponentAnalysis>;
105
- }
106
- /**
107
- * 定义 ComponentAnalysis 接口,包含组件分析的结果
108
- */
109
- interface ComponentAnalysis {
110
- /**
111
- * 组件的属性类型
112
- */
113
- props: ValueType;
114
- /**
115
- * 收集到的组件类型信息
116
- */
117
- types: CollectedTypes;
118
- jsxTree?: JSXNode;
119
- }
120
- /**
121
- * 定义 Story 接口,继承自 BasePreviewable 接口,代表一个故事
122
- */
123
- interface Story extends BasePreviewable {
124
- /**
125
- * 分析故事,返回故事分析结果的 Promise
126
- * @returns 包含故事参数信息的 StoryAnalysis 对象的 Promise
127
- */
128
- analyze: () => Promise<StoryAnalysis>;
129
- /**
130
- * 与故事关联的基本组件,可能为 null
131
- */
132
- associatedComponent: BasicComponent | null;
133
- }
134
- /**
135
- * 定义 StoryAnalysis 接口,包含故事分析的结果
136
- */
137
- interface StoryAnalysis {
138
- /**
139
- * 故事的参数,可能为 null
140
- */
141
- args: StoryArgs | null;
142
- }
143
- /**
144
- * 定义 StoryArgs 类型,包含故事参数的源位置和值
145
- */
146
- type StoryArgs = {
147
- /**
148
- * 故事参数在文件中的源位置
149
- */
150
- sourcePosition: FileSourcePosition;
151
- /**
152
- * 故事参数的值
153
- */
154
- value: SerializableValue;
155
- };
156
- /**
157
- * 定义 FileSourcePosition 类型,包含文件中某个位置的起始和结束索引
158
- */
159
- type FileSourcePosition = {
160
- /**
161
- * 起始索引
162
- */
163
- start: number;
164
- /**
165
- * 结束索引
166
- */
167
- end: number;
168
- };
169
- /**
170
- * 定义 BasicComponent 类型,是 Component 类型的部分属性集合
171
- */
172
- type BasicComponent = Pick<Component, "id" | "analyze">;
173
-
174
- export { type Analyzer, type AnalyzerFactory, type AnalyzerOptions, type BasePreviewable, type BasicComponent, type Component, type ComponentAnalysis, type FileSourcePosition, type JSXNode, type PreviewableId, type Story, type StoryAnalysis, type StoryArgs, decodePreviewableId, generatePreviewableId };
33
+ export { type PreviewableId, decodePreviewableId, generatePreviewableId };
package/dist/index.mjs CHANGED
@@ -1,16 +1 @@
1
- function generatePreviewableId(options) {
2
- return `${options.filePath.replace(/\\/g, "/")}:${options.name}`;
3
- }
4
- function decodePreviewableId(id) {
5
- const colonPosition = id.lastIndexOf(":");
6
- if (colonPosition === -1) {
7
- throw new Error(`\u65E0\u6548\u7684 ID: "${id}"`);
8
- }
9
- const [filePath, name] = id.split(":");
10
- return {
11
- filePath,
12
- name
13
- };
14
- }
15
-
16
- export { decodePreviewableId, generatePreviewableId };
1
+ function t(e){return`${e.filePath.replace(/\\/g,"/")}:${e.name}`}function a(e){if(e.lastIndexOf(":")===-1)throw new Error(`\u65E0\u6548\u7684 ID: "${e}"`);const[n,r]=e.split(":");return{filePath:n,name:r}}export{a as decodePreviewableId,t as generatePreviewableId};
@@ -0,0 +1,141 @@
1
+ import { SerializableValue } from '@cfp-studio/serializable-values';
2
+ import { TypeAnalyzer, ValueType, CollectedTypes } from '@cfp-studio/type-analyzer';
3
+ import { Reader } from '@cfp-studio/vfs';
4
+ import { Logger } from 'pino';
5
+ import { JSXNode } from '@cfp-studio/jsx-processor';
6
+
7
+ /**
8
+ * 定义 FileSourcePosition 类型,包含文件路径和位置信息
9
+ */
10
+ /**
11
+ * 定义 Analyzer 类型,包含类型分析器、文件爬取方法和资源释放方法
12
+ */
13
+ type Analyzer = {
14
+ /**
15
+ * 类型分析器,去除了 dispose 方法
16
+ */
17
+ typeAnalyzer: Omit<TypeAnalyzer, "dispose">;
18
+ /**
19
+ * 爬取指定文件路径的文件,返回组件和故事的集合
20
+ * @param filePaths - 要爬取的文件路径数组
21
+ * @returns 包含组件和故事数组的 Promise
22
+ */
23
+ crawlFiles: (filePaths: string[]) => Promise<{
24
+ components: Component[];
25
+ stories: Story[];
26
+ }>;
27
+ /**
28
+ * 释放 Analyzer 占用的资源
29
+ */
30
+ dispose: () => void;
31
+ };
32
+ type AnalyzerOptions = {
33
+ rootDir: string;
34
+ reader?: Reader;
35
+ logger?: Logger;
36
+ };
37
+ /**
38
+ * 定义 AnalyzerFactory 类型,是一个函数,用于创建 Analyzer 实例
39
+ * @param options - 创建 Analyzer 所需的选项
40
+ * @param options.rootDir - 根目录路径
41
+ * @param options.reader - 可选的读取器
42
+ * @param options.logger - 可选的日志记录器
43
+ * @returns 新创建的 Analyzer 实例
44
+ */
45
+ type AnalyzerFactory = (options: AnalyzerOptions) => Analyzer;
46
+ /**
47
+ * 定义 BasePreviewable 接口,作为可预览对象的基础接口
48
+ */
49
+ interface BasePreviewable {
50
+ /**
51
+ * 可预览对象的唯一标识符
52
+ */
53
+ id: string;
54
+ /**
55
+ * 可预览对象在文件中的源位置
56
+ */
57
+ sourcePosition: FileSourcePosition;
58
+ }
59
+ /**
60
+ * 定义 Component 接口,继承自 BasePreviewable 接口,代表一个组件
61
+ */
62
+ interface Component extends BasePreviewable {
63
+ /**
64
+ * 指示组件是否被导出
65
+ */
66
+ exported: boolean;
67
+ /**
68
+ * 分析组件,返回组件分析结果的 Promise
69
+ * @returns 包含组件属性和类型信息的 ComponentAnalysis 对象的 Promise
70
+ */
71
+ analyze: (withTreeData?: boolean) => Promise<ComponentAnalysis>;
72
+ }
73
+ /**
74
+ * 定义 ComponentAnalysis 接口,包含组件分析的结果
75
+ */
76
+ interface ComponentAnalysis {
77
+ /**
78
+ * 组件的属性类型
79
+ */
80
+ props: ValueType;
81
+ /**
82
+ * 收集到的组件类型信息
83
+ */
84
+ types: CollectedTypes;
85
+ jsxTree?: JSXNode;
86
+ }
87
+ /**
88
+ * 定义 Story 接口,继承自 BasePreviewable 接口,代表一个故事
89
+ */
90
+ interface Story extends BasePreviewable {
91
+ /**
92
+ * 分析故事,返回故事分析结果的 Promise
93
+ * @returns 包含故事参数信息的 StoryAnalysis 对象的 Promise
94
+ */
95
+ analyze: () => Promise<StoryAnalysis>;
96
+ /**
97
+ * 与故事关联的基本组件,可能为 null
98
+ */
99
+ associatedComponent: BasicComponent | null;
100
+ }
101
+ /**
102
+ * 定义 StoryAnalysis 接口,包含故事分析的结果
103
+ */
104
+ interface StoryAnalysis {
105
+ /**
106
+ * 故事的参数,可能为 null
107
+ */
108
+ args: StoryArgs | null;
109
+ }
110
+ /**
111
+ * 定义 StoryArgs 类型,包含故事参数的源位置和值
112
+ */
113
+ type StoryArgs = {
114
+ /**
115
+ * 故事参数在文件中的源位置
116
+ */
117
+ sourcePosition: FileSourcePosition;
118
+ /**
119
+ * 故事参数的值
120
+ */
121
+ value: SerializableValue;
122
+ };
123
+ /**
124
+ * 定义 FileSourcePosition 类型,包含文件中某个位置的起始和结束索引
125
+ */
126
+ type FileSourcePosition = {
127
+ /**
128
+ * 起始索引
129
+ */
130
+ start: number;
131
+ /**
132
+ * 结束索引
133
+ */
134
+ end: number;
135
+ };
136
+ /**
137
+ * 定义 BasicComponent 类型,是 Component 类型的部分属性集合
138
+ */
139
+ type BasicComponent = Pick<Component, "id" | "analyze">;
140
+
141
+ export type { Analyzer as A, BasePreviewable as B, Component as C, FileSourcePosition as F, Story as S, AnalyzerOptions as a, AnalyzerFactory as b, ComponentAnalysis as c, StoryAnalysis as d, StoryArgs as e, BasicComponent as f };
@@ -0,0 +1,141 @@
1
+ import { SerializableValue } from '@cfp-studio/serializable-values';
2
+ import { TypeAnalyzer, ValueType, CollectedTypes } from '@cfp-studio/type-analyzer';
3
+ import { Reader } from '@cfp-studio/vfs';
4
+ import { Logger } from 'pino';
5
+ import { JSXNode } from '@cfp-studio/jsx-processor';
6
+
7
+ /**
8
+ * 定义 FileSourcePosition 类型,包含文件路径和位置信息
9
+ */
10
+ /**
11
+ * 定义 Analyzer 类型,包含类型分析器、文件爬取方法和资源释放方法
12
+ */
13
+ type Analyzer = {
14
+ /**
15
+ * 类型分析器,去除了 dispose 方法
16
+ */
17
+ typeAnalyzer: Omit<TypeAnalyzer, "dispose">;
18
+ /**
19
+ * 爬取指定文件路径的文件,返回组件和故事的集合
20
+ * @param filePaths - 要爬取的文件路径数组
21
+ * @returns 包含组件和故事数组的 Promise
22
+ */
23
+ crawlFiles: (filePaths: string[]) => Promise<{
24
+ components: Component[];
25
+ stories: Story[];
26
+ }>;
27
+ /**
28
+ * 释放 Analyzer 占用的资源
29
+ */
30
+ dispose: () => void;
31
+ };
32
+ type AnalyzerOptions = {
33
+ rootDir: string;
34
+ reader?: Reader;
35
+ logger?: Logger;
36
+ };
37
+ /**
38
+ * 定义 AnalyzerFactory 类型,是一个函数,用于创建 Analyzer 实例
39
+ * @param options - 创建 Analyzer 所需的选项
40
+ * @param options.rootDir - 根目录路径
41
+ * @param options.reader - 可选的读取器
42
+ * @param options.logger - 可选的日志记录器
43
+ * @returns 新创建的 Analyzer 实例
44
+ */
45
+ type AnalyzerFactory = (options: AnalyzerOptions) => Analyzer;
46
+ /**
47
+ * 定义 BasePreviewable 接口,作为可预览对象的基础接口
48
+ */
49
+ interface BasePreviewable {
50
+ /**
51
+ * 可预览对象的唯一标识符
52
+ */
53
+ id: string;
54
+ /**
55
+ * 可预览对象在文件中的源位置
56
+ */
57
+ sourcePosition: FileSourcePosition;
58
+ }
59
+ /**
60
+ * 定义 Component 接口,继承自 BasePreviewable 接口,代表一个组件
61
+ */
62
+ interface Component extends BasePreviewable {
63
+ /**
64
+ * 指示组件是否被导出
65
+ */
66
+ exported: boolean;
67
+ /**
68
+ * 分析组件,返回组件分析结果的 Promise
69
+ * @returns 包含组件属性和类型信息的 ComponentAnalysis 对象的 Promise
70
+ */
71
+ analyze: (withTreeData?: boolean) => Promise<ComponentAnalysis>;
72
+ }
73
+ /**
74
+ * 定义 ComponentAnalysis 接口,包含组件分析的结果
75
+ */
76
+ interface ComponentAnalysis {
77
+ /**
78
+ * 组件的属性类型
79
+ */
80
+ props: ValueType;
81
+ /**
82
+ * 收集到的组件类型信息
83
+ */
84
+ types: CollectedTypes;
85
+ jsxTree?: JSXNode;
86
+ }
87
+ /**
88
+ * 定义 Story 接口,继承自 BasePreviewable 接口,代表一个故事
89
+ */
90
+ interface Story extends BasePreviewable {
91
+ /**
92
+ * 分析故事,返回故事分析结果的 Promise
93
+ * @returns 包含故事参数信息的 StoryAnalysis 对象的 Promise
94
+ */
95
+ analyze: () => Promise<StoryAnalysis>;
96
+ /**
97
+ * 与故事关联的基本组件,可能为 null
98
+ */
99
+ associatedComponent: BasicComponent | null;
100
+ }
101
+ /**
102
+ * 定义 StoryAnalysis 接口,包含故事分析的结果
103
+ */
104
+ interface StoryAnalysis {
105
+ /**
106
+ * 故事的参数,可能为 null
107
+ */
108
+ args: StoryArgs | null;
109
+ }
110
+ /**
111
+ * 定义 StoryArgs 类型,包含故事参数的源位置和值
112
+ */
113
+ type StoryArgs = {
114
+ /**
115
+ * 故事参数在文件中的源位置
116
+ */
117
+ sourcePosition: FileSourcePosition;
118
+ /**
119
+ * 故事参数的值
120
+ */
121
+ value: SerializableValue;
122
+ };
123
+ /**
124
+ * 定义 FileSourcePosition 类型,包含文件中某个位置的起始和结束索引
125
+ */
126
+ type FileSourcePosition = {
127
+ /**
128
+ * 起始索引
129
+ */
130
+ start: number;
131
+ /**
132
+ * 结束索引
133
+ */
134
+ end: number;
135
+ };
136
+ /**
137
+ * 定义 BasicComponent 类型,是 Component 类型的部分属性集合
138
+ */
139
+ type BasicComponent = Pick<Component, "id" | "analyze">;
140
+
141
+ export type { Analyzer as A, BasePreviewable as B, Component as C, FileSourcePosition as F, Story as S, AnalyzerOptions as a, AnalyzerFactory as b, ComponentAnalysis as c, StoryAnalysis as d, StoryArgs as e, BasicComponent as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfp-studio/analyzer-api",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -18,11 +18,12 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@cfp-studio/serializable-values": "^9.0.6",
22
- "@cfp-studio/type-analyzer": "^10.1.5",
23
- "@cfp-studio/vfs": "^2.1.4",
24
- "pino": "^9.5.0",
25
- "pino-pretty": "^11.2.1"
21
+ "@cfp-studio/serializable-values": "^9.0.7",
22
+ "@cfp-studio/type-analyzer": "^10.1.7",
23
+ "@cfp-studio/vfs": "^2.1.5",
24
+ "pino": "^9.10.0",
25
+ "pino-pretty": "^13.1.1",
26
+ "@cfp-studio/jsx-processor": "1.0.0"
26
27
  },
27
28
  "devDependencies": {
28
29
  "typescript": "5.7.3",
@@ -30,7 +31,9 @@
30
31
  "vitest": "2.1.9"
31
32
  },
32
33
  "scripts": {
34
+ "prepublish": "pnpm release",
33
35
  "build": "tsc && unbuild",
36
+ "release": "tsc && unbuild --minify",
34
37
  "test": "vitest"
35
38
  }
36
39
  }