m8-mcp-server 1.0.6 → 1.0.8

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 (75) hide show
  1. package/dist/cli.d.ts +1 -1
  2. package/dist/cli.js +1 -13
  3. package/dist/docs/apis.d.ts +1 -1
  4. package/dist/docs/apis.js +9 -326
  5. package/dist/docs/components.d.ts +1 -1
  6. package/dist/docs/components.js +2 -186
  7. package/dist/docs/index.d.ts +1 -1
  8. package/dist/docs/index.js +18 -177
  9. package/dist/docs/loader.d.ts +1 -1
  10. package/dist/docs/loader.js +1 -165
  11. package/dist/docs/search.d.ts +1 -1
  12. package/dist/docs/search.js +2 -196
  13. package/dist/docs/standards.d.ts +1 -1
  14. package/dist/docs/standards.js +3 -134
  15. package/dist/docs/utils.d.ts +1 -1
  16. package/dist/docs/utils.js +3 -129
  17. package/dist/generator/card-component.d.ts +55 -0
  18. package/dist/generator/card-component.d.ts.map +1 -0
  19. package/dist/generator/card-component.js +262 -0
  20. package/dist/generator/header.d.ts +1 -1
  21. package/dist/generator/header.js +3 -83
  22. package/dist/generator/index.d.ts +1 -1
  23. package/dist/generator/index.js +283 -648
  24. package/dist/generator/vue-template.d.ts +1 -1
  25. package/dist/generator/vue-template.js +336 -1016
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +1 -73
  28. package/dist/recommend/index.d.ts +1 -1
  29. package/dist/recommend/index.js +2 -412
  30. package/dist/tools/generate-card-component.d.ts +16 -0
  31. package/dist/tools/generate-card-component.d.ts.map +1 -0
  32. package/dist/tools/generate-card-component.js +4 -0
  33. package/dist/tools/generate-code.d.ts +1 -1
  34. package/dist/tools/generate-code.js +39 -211
  35. package/dist/tools/get-api-info.d.ts +1 -1
  36. package/dist/tools/get-api-info.js +1 -65
  37. package/dist/tools/get-coding-standard.d.ts +1 -1
  38. package/dist/tools/get-coding-standard.js +1 -66
  39. package/dist/tools/get-component-info.d.ts +1 -1
  40. package/dist/tools/get-component-info.js +1 -60
  41. package/dist/tools/get-util-info.d.ts +1 -1
  42. package/dist/tools/get-util-info.js +1 -65
  43. package/dist/tools/index.d.ts +2 -1
  44. package/dist/tools/index.d.ts.map +1 -1
  45. package/dist/tools/index.js +3 -101
  46. package/dist/tools/recommend-solution.d.ts +1 -1
  47. package/dist/tools/recommend-solution.js +1 -67
  48. package/dist/tools/search-docs.d.ts +1 -1
  49. package/dist/tools/search-docs.js +1 -71
  50. package/dist/types/index.d.ts +74 -1
  51. package/dist/types/index.d.ts.map +1 -1
  52. package/dist/types/index.js +0 -8
  53. package/package.json +4 -2
  54. package/dist/cli.js.map +0 -1
  55. package/dist/docs/apis.js.map +0 -1
  56. package/dist/docs/components.js.map +0 -1
  57. package/dist/docs/index.js.map +0 -1
  58. package/dist/docs/loader.js.map +0 -1
  59. package/dist/docs/search.js.map +0 -1
  60. package/dist/docs/standards.js.map +0 -1
  61. package/dist/docs/utils.js.map +0 -1
  62. package/dist/generator/header.js.map +0 -1
  63. package/dist/generator/index.js.map +0 -1
  64. package/dist/generator/vue-template.js.map +0 -1
  65. package/dist/index.js.map +0 -1
  66. package/dist/recommend/index.js.map +0 -1
  67. package/dist/tools/generate-code.js.map +0 -1
  68. package/dist/tools/get-api-info.js.map +0 -1
  69. package/dist/tools/get-coding-standard.js.map +0 -1
  70. package/dist/tools/get-component-info.js.map +0 -1
  71. package/dist/tools/get-util-info.js.map +0 -1
  72. package/dist/tools/index.js.map +0 -1
  73. package/dist/tools/recommend-solution.js.map +0 -1
  74. package/dist/tools/search-docs.js.map +0 -1
  75. package/dist/types/index.js.map +0 -1
package/dist/cli.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * M8 MCP Server CLI 入口
4
4
  * @作者 li peng
5
- * @创建时间 2024-12-29
5
+ * @创建时间 2025-12-20
6
6
  * @描述 命令行入口,用于启动 MCP Server
7
7
  */
8
8
  export {};
package/dist/cli.js CHANGED
@@ -1,14 +1,2 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * M8 MCP Server CLI 入口
4
- * @作者 li peng
5
- * @创建时间 2024-12-29
6
- * @描述 命令行入口,用于启动 MCP Server
7
- */
8
- import { startServer } from './index.js';
9
- // 启动服务器
10
- startServer().catch(() => {
11
- // MCP 协议要求不能输出非 JSON 内容
12
- process.exit(1);
13
- });
14
- //# sourceMappingURL=cli.js.map
2
+ import{startServer as r}from"./index.js";r().catch(()=>{process.exit(1)});
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * EJS API 信息查询
3
3
  * @作者 li peng
4
- * @创建时间 2024-12-29
4
+ * @创建时间 2025-12-20
5
5
  * @描述 实现 EJS 原生 API 信息的查询功能
6
6
  */
7
7
  import type { ApiDoc, ApiMethod } from '../types/index.js';
package/dist/docs/apis.js CHANGED
@@ -1,326 +1,9 @@
1
- /**
2
- * EJS API 信息查询
3
- * @作者 li peng
4
- * @创建时间 2024-12-29
5
- * @描述 实现 EJS 原生 API 信息的查询功能
6
- */
7
- // 内置的 EJS API 文档数据
8
- const EJS_APIS = [
9
- {
10
- module: 'ui',
11
- description: 'UI 交互相关 API,包括弹窗、提示、选择器等',
12
- methods: [
13
- {
14
- name: 'toast',
15
- description: '显示轻提示',
16
- parameters: [
17
- { name: 'message', type: 'string', required: true, description: '提示内容' },
18
- { name: 'duration', type: 'number', required: false, description: '显示时长,单位毫秒' }
19
- ],
20
- returnValue: { type: 'void', description: '无返回值' },
21
- platformSupport: { ios: true, android: true, h5: true },
22
- examples: [{ title: '显示提示', code: "ejs.ui.toast({ message: '操作成功' });" }]
23
- },
24
- {
25
- name: 'alert',
26
- description: '显示警告弹窗',
27
- parameters: [
28
- { name: 'title', type: 'string', required: false, description: '标题' },
29
- { name: 'message', type: 'string', required: true, description: '内容' },
30
- { name: 'buttonText', type: 'string', required: false, description: '按钮文字' }
31
- ],
32
- returnValue: { type: 'Promise', description: '点击确定后 resolve' },
33
- platformSupport: { ios: true, android: true, h5: true },
34
- examples: [{ title: '显示警告', code: "ejs.ui.alert({ title: '提示', message: '这是一条警告信息' });" }]
35
- },
36
- {
37
- name: 'confirm',
38
- description: '显示确认弹窗',
39
- parameters: [
40
- { name: 'title', type: 'string', required: false, description: '标题' },
41
- { name: 'message', type: 'string', required: true, description: '内容' },
42
- { name: 'confirmText', type: 'string', required: false, description: '确认按钮文字' },
43
- { name: 'cancelText', type: 'string', required: false, description: '取消按钮文字' }
44
- ],
45
- returnValue: { type: 'Promise<boolean>', description: '点击确认返回 true,取消返回 false' },
46
- platformSupport: { ios: true, android: true, h5: true },
47
- examples: [{ title: '确认弹窗', code: "const result = await ejs.ui.confirm({ title: '确认', message: '确定要删除吗?' });" }]
48
- },
49
- {
50
- name: 'showWaiting',
51
- description: '显示加载中提示',
52
- parameters: [
53
- { name: 'message', type: 'string', required: false, description: '提示文字' }
54
- ],
55
- returnValue: { type: 'void', description: '无返回值' },
56
- platformSupport: { ios: true, android: true, h5: true },
57
- examples: [{ title: '显示加载', code: "ejs.ui.showWaiting({ message: '加载中...' });" }]
58
- },
59
- {
60
- name: 'closeWaiting',
61
- description: '关闭加载中提示',
62
- parameters: [],
63
- returnValue: { type: 'void', description: '无返回值' },
64
- platformSupport: { ios: true, android: true, h5: true },
65
- examples: [{ title: '关闭加载', code: 'ejs.ui.closeWaiting();' }]
66
- },
67
- {
68
- name: 'picker',
69
- description: '显示选择器',
70
- parameters: [
71
- { name: 'title', type: 'string', required: false, description: '标题' },
72
- { name: 'options', type: 'array', required: true, description: '选项数组' },
73
- { name: 'defaultIndex', type: 'number', required: false, description: '默认选中索引' }
74
- ],
75
- returnValue: { type: 'Promise<object>', description: '选中的选项' },
76
- platformSupport: { ios: true, android: true, h5: true },
77
- examples: [{ title: '单列选择', code: "const result = await ejs.ui.picker({ options: ['选项1', '选项2', '选项3'] });" }]
78
- },
79
- {
80
- name: 'pickDate',
81
- description: '显示日期选择器',
82
- parameters: [
83
- { name: 'title', type: 'string', required: false, description: '标题' },
84
- { name: 'defaultDate', type: 'string', required: false, description: '默认日期' },
85
- { name: 'minDate', type: 'string', required: false, description: '最小日期' },
86
- { name: 'maxDate', type: 'string', required: false, description: '最大日期' }
87
- ],
88
- returnValue: { type: 'Promise<string>', description: '选中的日期字符串' },
89
- platformSupport: { ios: true, android: true, h5: true },
90
- examples: [{ title: '日期选择', code: "const date = await ejs.ui.pickDate({ title: '选择日期' });" }]
91
- },
92
- {
93
- name: 'pickTime',
94
- description: '显示时间选择器',
95
- parameters: [
96
- { name: 'title', type: 'string', required: false, description: '标题' },
97
- { name: 'defaultTime', type: 'string', required: false, description: '默认时间' }
98
- ],
99
- returnValue: { type: 'Promise<string>', description: '选中的时间字符串' },
100
- platformSupport: { ios: true, android: true, h5: true },
101
- examples: [{ title: '时间选择', code: "const time = await ejs.ui.pickTime({ title: '选择时间' });" }]
102
- }
103
- ]
104
- },
105
- {
106
- module: 'page',
107
- description: '页面导航相关 API,包括页面跳转、关闭等',
108
- methods: [
109
- {
110
- name: 'open',
111
- description: '打开新页面',
112
- parameters: [
113
- { name: 'pageUrl', type: 'string', required: true, description: '页面路径' },
114
- { name: 'data', type: 'object', required: false, description: '传递给新页面的参数' },
115
- { name: 'success', type: 'function', required: false, description: '页面关闭后的回调' }
116
- ],
117
- returnValue: { type: 'void', description: '无返回值' },
118
- platformSupport: { ios: true, android: true, h5: true },
119
- examples: [{ title: '打开页面', code: "ejs.page.open({\n pageUrl: './detail',\n data: { id: '123' },\n success: (result) => {\n console.log('返回数据:', result.resultData);\n }\n});" }]
120
- },
121
- {
122
- name: 'close',
123
- description: '关闭当前页面',
124
- parameters: [
125
- { name: 'resultData', type: 'object', required: false, description: '返回给上一页的数据' }
126
- ],
127
- returnValue: { type: 'void', description: '无返回值' },
128
- platformSupport: { ios: true, android: true, h5: true },
129
- examples: [{ title: '关闭页面', code: "ejs.page.close({ resultData: { status: 'success' } });" }]
130
- },
131
- {
132
- name: 'setTitle',
133
- description: '设置页面标题',
134
- parameters: [
135
- { name: 'title', type: 'string', required: true, description: '页面标题' }
136
- ],
137
- returnValue: { type: 'void', description: '无返回值' },
138
- platformSupport: { ios: true, android: true, h5: true },
139
- examples: [{ title: '设置标题', code: "ejs.page.setTitle({ title: '新标题' });" }]
140
- }
141
- ]
142
- },
143
- {
144
- module: 'storage',
145
- description: '本地存储相关 API',
146
- methods: [
147
- {
148
- name: 'setItem',
149
- description: '存储数据',
150
- parameters: [
151
- { name: 'key', type: 'string', required: true, description: '键名' },
152
- { name: 'value', type: 'string', required: true, description: '值' }
153
- ],
154
- returnValue: { type: 'void', description: '无返回值' },
155
- platformSupport: { ios: true, android: true, h5: true },
156
- examples: [{ title: '存储数据', code: "ejs.storage.setItem({ key: 'token', value: 'xxx' });" }]
157
- },
158
- {
159
- name: 'getItem',
160
- description: '获取数据',
161
- parameters: [
162
- { name: 'key', type: 'string', required: true, description: '键名' }
163
- ],
164
- returnValue: { type: 'Promise<string>', description: '存储的值' },
165
- platformSupport: { ios: true, android: true, h5: true },
166
- examples: [{ title: '获取数据', code: "const token = await ejs.storage.getItem({ key: 'token' });" }]
167
- },
168
- {
169
- name: 'removeItem',
170
- description: '删除数据',
171
- parameters: [
172
- { name: 'key', type: 'string', required: true, description: '键名' }
173
- ],
174
- returnValue: { type: 'void', description: '无返回值' },
175
- platformSupport: { ios: true, android: true, h5: true },
176
- examples: [{ title: '删除数据', code: "ejs.storage.removeItem({ key: 'token' });" }]
177
- }
178
- ]
179
- },
180
- {
181
- module: 'device',
182
- description: '设备相关 API,包括获取设备信息、拍照等',
183
- methods: [
184
- {
185
- name: 'getInfo',
186
- description: '获取设备信息',
187
- parameters: [],
188
- returnValue: { type: 'Promise<object>', description: '设备信息对象' },
189
- platformSupport: { ios: true, android: true, h5: true },
190
- examples: [{ title: '获取设备信息', code: 'const info = await ejs.device.getInfo();' }]
191
- },
192
- {
193
- name: 'scan',
194
- description: '扫描二维码/条形码',
195
- parameters: [],
196
- returnValue: { type: 'Promise<string>', description: '扫描结果' },
197
- platformSupport: { ios: true, android: true, h5: false },
198
- examples: [{ title: '扫码', code: 'const result = await ejs.device.scan();' }]
199
- },
200
- {
201
- name: 'takePhoto',
202
- description: '拍照',
203
- parameters: [
204
- { name: 'quality', type: 'number', required: false, description: '图片质量 0-100' }
205
- ],
206
- returnValue: { type: 'Promise<object>', description: '图片信息' },
207
- platformSupport: { ios: true, android: true, h5: false },
208
- examples: [{ title: '拍照', code: 'const photo = await ejs.device.takePhoto({ quality: 80 });' }]
209
- }
210
- ]
211
- }
212
- ];
213
- /**
214
- * 获取 API 模块信息
215
- * @param moduleName 模块名称
216
- * @returns API 模块信息或 null
217
- */
218
- export function getApiInfo(moduleName) {
219
- const normalized = moduleName.toLowerCase().trim();
220
- return EJS_APIS.find(api => api.module.toLowerCase() === normalized) || null;
221
- }
222
- /**
223
- * 获取 API 方法信息
224
- * @param moduleName 模块名称
225
- * @param methodName 方法名称
226
- * @returns API 方法信息或 null
227
- */
228
- export function getApiMethodInfo(moduleName, methodName) {
229
- const api = getApiInfo(moduleName);
230
- if (!api)
231
- return null;
232
- const normalized = methodName.toLowerCase().trim();
233
- return api.methods.find(m => m.name.toLowerCase() === normalized) || null;
234
- }
235
- /**
236
- * 获取所有可用的 API 模块
237
- * @returns 模块名称数组
238
- */
239
- export function getAvailableModules() {
240
- return EJS_APIS.map(api => api.module);
241
- }
242
- /**
243
- * 格式化 API 信息为文本
244
- * @param api API 文档
245
- * @param methodName 可选的方法名称
246
- * @returns 格式化的文本
247
- */
248
- export function formatApiInfo(api, methodName) {
249
- const lines = [];
250
- if (methodName) {
251
- // 格式化单个方法
252
- const method = api.methods.find(m => m.name.toLowerCase() === methodName.toLowerCase());
253
- if (!method) {
254
- return `方法 ${methodName} 不存在于 ejs.${api.module} 模块中。\n可用方法: ${api.methods.map(m => m.name).join(', ')}`;
255
- }
256
- lines.push(`# ejs.${api.module}.${method.name}`);
257
- lines.push('');
258
- lines.push(method.description);
259
- lines.push('');
260
- // 参数
261
- if (method.parameters.length > 0) {
262
- lines.push('## 参数');
263
- lines.push('');
264
- lines.push('| 参数 | 类型 | 必填 | 说明 |');
265
- lines.push('| --- | --- | --- | --- |');
266
- for (const param of method.parameters) {
267
- lines.push(`| ${param.name} | ${param.type} | ${param.required ? '是' : '否'} | ${param.description} |`);
268
- }
269
- lines.push('');
270
- }
271
- // 返回值
272
- lines.push('## 返回值');
273
- lines.push('');
274
- lines.push(`- 类型: \`${method.returnValue.type}\``);
275
- lines.push(`- 说明: ${method.returnValue.description}`);
276
- lines.push('');
277
- // 平台支持
278
- lines.push('## 平台支持');
279
- lines.push('');
280
- lines.push(`- iOS: ${method.platformSupport.ios ? '✓' : '✗'}`);
281
- lines.push(`- Android: ${method.platformSupport.android ? '✓' : '✗'}`);
282
- lines.push(`- H5: ${method.platformSupport.h5 ? '✓' : '✗'}`);
283
- lines.push('');
284
- // 示例
285
- if (method.examples.length > 0) {
286
- lines.push('## 示例');
287
- lines.push('');
288
- for (const example of method.examples) {
289
- lines.push(`### ${example.title}`);
290
- lines.push('```javascript');
291
- lines.push(example.code);
292
- lines.push('```');
293
- lines.push('');
294
- }
295
- }
296
- }
297
- else {
298
- // 格式化整个模块
299
- lines.push(`# ejs.${api.module}`);
300
- lines.push('');
301
- lines.push(api.description);
302
- lines.push('');
303
- lines.push('## 方法列表');
304
- lines.push('');
305
- lines.push('| 方法 | 说明 |');
306
- lines.push('| --- | --- |');
307
- for (const method of api.methods) {
308
- lines.push(`| ${method.name} | ${method.description} |`);
309
- }
310
- lines.push('');
311
- lines.push('使用 `get_api_info` 工具并指定 `method` 参数可获取具体方法的详细信息。');
312
- }
313
- return lines.join('\n');
314
- }
315
- /**
316
- * 将 EJS API 加载到文档索引中
317
- * @returns API 文档映射
318
- */
319
- export function loadEjsApis() {
320
- const apis = new Map();
321
- for (const api of EJS_APIS) {
322
- apis.set(api.module, api);
323
- }
324
- return apis;
325
- }
326
- //# sourceMappingURL=apis.js.map
1
+ const o=[{module:"ui",description:"UI \u4EA4\u4E92\u76F8\u5173 API\uFF0C\u5305\u62EC\u5F39\u7A97\u3001\u63D0\u793A\u3001\u9009\u62E9\u5668\u7B49",methods:[{name:"toast",description:"\u663E\u793A\u8F7B\u63D0\u793A",parameters:[{name:"message",type:"string",required:!0,description:"\u63D0\u793A\u5185\u5BB9"},{name:"duration",type:"number",required:!1,description:"\u663E\u793A\u65F6\u957F\uFF0C\u5355\u4F4D\u6BEB\u79D2"}],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u663E\u793A\u63D0\u793A",code:"ejs.ui.toast({ message: '\u64CD\u4F5C\u6210\u529F' });"}]},{name:"alert",description:"\u663E\u793A\u8B66\u544A\u5F39\u7A97",parameters:[{name:"title",type:"string",required:!1,description:"\u6807\u9898"},{name:"message",type:"string",required:!0,description:"\u5185\u5BB9"},{name:"buttonText",type:"string",required:!1,description:"\u6309\u94AE\u6587\u5B57"}],returnValue:{type:"Promise",description:"\u70B9\u51FB\u786E\u5B9A\u540E resolve"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u663E\u793A\u8B66\u544A",code:"ejs.ui.alert({ title: '\u63D0\u793A', message: '\u8FD9\u662F\u4E00\u6761\u8B66\u544A\u4FE1\u606F' });"}]},{name:"confirm",description:"\u663E\u793A\u786E\u8BA4\u5F39\u7A97",parameters:[{name:"title",type:"string",required:!1,description:"\u6807\u9898"},{name:"message",type:"string",required:!0,description:"\u5185\u5BB9"},{name:"confirmText",type:"string",required:!1,description:"\u786E\u8BA4\u6309\u94AE\u6587\u5B57"},{name:"cancelText",type:"string",required:!1,description:"\u53D6\u6D88\u6309\u94AE\u6587\u5B57"}],returnValue:{type:"Promise<boolean>",description:"\u70B9\u51FB\u786E\u8BA4\u8FD4\u56DE true\uFF0C\u53D6\u6D88\u8FD4\u56DE false"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u786E\u8BA4\u5F39\u7A97",code:"const result = await ejs.ui.confirm({ title: '\u786E\u8BA4', message: '\u786E\u5B9A\u8981\u5220\u9664\u5417\uFF1F' });"}]},{name:"showWaiting",description:"\u663E\u793A\u52A0\u8F7D\u4E2D\u63D0\u793A",parameters:[{name:"message",type:"string",required:!1,description:"\u63D0\u793A\u6587\u5B57"}],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u663E\u793A\u52A0\u8F7D",code:"ejs.ui.showWaiting({ message: '\u52A0\u8F7D\u4E2D...' });"}]},{name:"closeWaiting",description:"\u5173\u95ED\u52A0\u8F7D\u4E2D\u63D0\u793A",parameters:[],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u5173\u95ED\u52A0\u8F7D",code:"ejs.ui.closeWaiting();"}]},{name:"picker",description:"\u663E\u793A\u9009\u62E9\u5668",parameters:[{name:"title",type:"string",required:!1,description:"\u6807\u9898"},{name:"options",type:"array",required:!0,description:"\u9009\u9879\u6570\u7EC4"},{name:"defaultIndex",type:"number",required:!1,description:"\u9ED8\u8BA4\u9009\u4E2D\u7D22\u5F15"}],returnValue:{type:"Promise<object>",description:"\u9009\u4E2D\u7684\u9009\u9879"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u5355\u5217\u9009\u62E9",code:"const result = await ejs.ui.picker({ options: ['\u9009\u98791', '\u9009\u98792', '\u9009\u98793'] });"}]},{name:"pickDate",description:"\u663E\u793A\u65E5\u671F\u9009\u62E9\u5668",parameters:[{name:"title",type:"string",required:!1,description:"\u6807\u9898"},{name:"defaultDate",type:"string",required:!1,description:"\u9ED8\u8BA4\u65E5\u671F"},{name:"minDate",type:"string",required:!1,description:"\u6700\u5C0F\u65E5\u671F"},{name:"maxDate",type:"string",required:!1,description:"\u6700\u5927\u65E5\u671F"}],returnValue:{type:"Promise<string>",description:"\u9009\u4E2D\u7684\u65E5\u671F\u5B57\u7B26\u4E32"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u65E5\u671F\u9009\u62E9",code:"const date = await ejs.ui.pickDate({ title: '\u9009\u62E9\u65E5\u671F' });"}]},{name:"pickTime",description:"\u663E\u793A\u65F6\u95F4\u9009\u62E9\u5668",parameters:[{name:"title",type:"string",required:!1,description:"\u6807\u9898"},{name:"defaultTime",type:"string",required:!1,description:"\u9ED8\u8BA4\u65F6\u95F4"}],returnValue:{type:"Promise<string>",description:"\u9009\u4E2D\u7684\u65F6\u95F4\u5B57\u7B26\u4E32"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u65F6\u95F4\u9009\u62E9",code:"const time = await ejs.ui.pickTime({ title: '\u9009\u62E9\u65F6\u95F4' });"}]}]},{module:"page",description:"\u9875\u9762\u5BFC\u822A\u76F8\u5173 API\uFF0C\u5305\u62EC\u9875\u9762\u8DF3\u8F6C\u3001\u5173\u95ED\u7B49",methods:[{name:"open",description:"\u6253\u5F00\u65B0\u9875\u9762",parameters:[{name:"pageUrl",type:"string",required:!0,description:"\u9875\u9762\u8DEF\u5F84"},{name:"data",type:"object",required:!1,description:"\u4F20\u9012\u7ED9\u65B0\u9875\u9762\u7684\u53C2\u6570"},{name:"success",type:"function",required:!1,description:"\u9875\u9762\u5173\u95ED\u540E\u7684\u56DE\u8C03"}],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u6253\u5F00\u9875\u9762",code:`ejs.page.open({
2
+ pageUrl: './detail',
3
+ data: { id: '123' },
4
+ success: (result) => {
5
+ console.log('\u8FD4\u56DE\u6570\u636E:', result.resultData);
6
+ }
7
+ });`}]},{name:"close",description:"\u5173\u95ED\u5F53\u524D\u9875\u9762",parameters:[{name:"resultData",type:"object",required:!1,description:"\u8FD4\u56DE\u7ED9\u4E0A\u4E00\u9875\u7684\u6570\u636E"}],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u5173\u95ED\u9875\u9762",code:"ejs.page.close({ resultData: { status: 'success' } });"}]},{name:"setTitle",description:"\u8BBE\u7F6E\u9875\u9762\u6807\u9898",parameters:[{name:"title",type:"string",required:!0,description:"\u9875\u9762\u6807\u9898"}],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u8BBE\u7F6E\u6807\u9898",code:"ejs.page.setTitle({ title: '\u65B0\u6807\u9898' });"}]}]},{module:"storage",description:"\u672C\u5730\u5B58\u50A8\u76F8\u5173 API",methods:[{name:"setItem",description:"\u5B58\u50A8\u6570\u636E",parameters:[{name:"key",type:"string",required:!0,description:"\u952E\u540D"},{name:"value",type:"string",required:!0,description:"\u503C"}],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u5B58\u50A8\u6570\u636E",code:"ejs.storage.setItem({ key: 'token', value: 'xxx' });"}]},{name:"getItem",description:"\u83B7\u53D6\u6570\u636E",parameters:[{name:"key",type:"string",required:!0,description:"\u952E\u540D"}],returnValue:{type:"Promise<string>",description:"\u5B58\u50A8\u7684\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u83B7\u53D6\u6570\u636E",code:"const token = await ejs.storage.getItem({ key: 'token' });"}]},{name:"removeItem",description:"\u5220\u9664\u6570\u636E",parameters:[{name:"key",type:"string",required:!0,description:"\u952E\u540D"}],returnValue:{type:"void",description:"\u65E0\u8FD4\u56DE\u503C"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u5220\u9664\u6570\u636E",code:"ejs.storage.removeItem({ key: 'token' });"}]}]},{module:"device",description:"\u8BBE\u5907\u76F8\u5173 API\uFF0C\u5305\u62EC\u83B7\u53D6\u8BBE\u5907\u4FE1\u606F\u3001\u62CD\u7167\u7B49",methods:[{name:"getInfo",description:"\u83B7\u53D6\u8BBE\u5907\u4FE1\u606F",parameters:[],returnValue:{type:"Promise<object>",description:"\u8BBE\u5907\u4FE1\u606F\u5BF9\u8C61"},platformSupport:{ios:!0,android:!0,h5:!0},examples:[{title:"\u83B7\u53D6\u8BBE\u5907\u4FE1\u606F",code:"const info = await ejs.device.getInfo();"}]},{name:"scan",description:"\u626B\u63CF\u4E8C\u7EF4\u7801/\u6761\u5F62\u7801",parameters:[],returnValue:{type:"Promise<string>",description:"\u626B\u63CF\u7ED3\u679C"},platformSupport:{ios:!0,android:!0,h5:!1},examples:[{title:"\u626B\u7801",code:"const result = await ejs.device.scan();"}]},{name:"takePhoto",description:"\u62CD\u7167",parameters:[{name:"quality",type:"number",required:!1,description:"\u56FE\u7247\u8D28\u91CF 0-100"}],returnValue:{type:"Promise<object>",description:"\u56FE\u7247\u4FE1\u606F"},platformSupport:{ios:!0,android:!0,h5:!1},examples:[{title:"\u62CD\u7167",code:"const photo = await ejs.device.takePhoto({ quality: 80 });"}]}]}];function p(r){const s=r.toLowerCase().trim();return o.find(e=>e.module.toLowerCase()===s)||null}function n(r,s){const e=p(r);if(!e)return null;const t=s.toLowerCase().trim();return e.methods.find(i=>i.name.toLowerCase()===t)||null}function a(){return o.map(r=>r.module)}function u(r,s){const e=[];if(s){const t=r.methods.find(i=>i.name.toLowerCase()===s.toLowerCase());if(!t)return`\u65B9\u6CD5 ${s} \u4E0D\u5B58\u5728\u4E8E ejs.${r.module} \u6A21\u5757\u4E2D\u3002
8
+ \u53EF\u7528\u65B9\u6CD5: ${r.methods.map(i=>i.name).join(", ")}`;if(e.push(`# ejs.${r.module}.${t.name}`),e.push(""),e.push(t.description),e.push(""),t.parameters.length>0){e.push("## \u53C2\u6570"),e.push(""),e.push("| \u53C2\u6570 | \u7C7B\u578B | \u5FC5\u586B | \u8BF4\u660E |"),e.push("| --- | --- | --- | --- |");for(const i of t.parameters)e.push(`| ${i.name} | ${i.type} | ${i.required?"\u662F":"\u5426"} | ${i.description} |`);e.push("")}if(e.push("## \u8FD4\u56DE\u503C"),e.push(""),e.push(`- \u7C7B\u578B: \`${t.returnValue.type}\``),e.push(`- \u8BF4\u660E: ${t.returnValue.description}`),e.push(""),e.push("## \u5E73\u53F0\u652F\u6301"),e.push(""),e.push(`- iOS: ${t.platformSupport.ios?"\u2713":"\u2717"}`),e.push(`- Android: ${t.platformSupport.android?"\u2713":"\u2717"}`),e.push(`- H5: ${t.platformSupport.h5?"\u2713":"\u2717"}`),e.push(""),t.examples.length>0){e.push("## \u793A\u4F8B"),e.push("");for(const i of t.examples)e.push(`### ${i.title}`),e.push("```javascript"),e.push(i.code),e.push("```"),e.push("")}}else{e.push(`# ejs.${r.module}`),e.push(""),e.push(r.description),e.push(""),e.push("## \u65B9\u6CD5\u5217\u8868"),e.push(""),e.push("| \u65B9\u6CD5 | \u8BF4\u660E |"),e.push("| --- | --- |");for(const t of r.methods)e.push(`| ${t.name} | ${t.description} |`);e.push(""),e.push("\u4F7F\u7528 `get_api_info` \u5DE5\u5177\u5E76\u6307\u5B9A `method` \u53C2\u6570\u53EF\u83B7\u53D6\u5177\u4F53\u65B9\u6CD5\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002")}return e.join(`
9
+ `)}function d(){const r=new Map;for(const s of o)r.set(s.module,s);return r}export{u as formatApiInfo,p as getApiInfo,n as getApiMethodInfo,a as getAvailableModules,d as loadEjsApis};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 组件信息查询
3
3
  * @作者 li peng
4
- * @创建时间 2024-12-29
4
+ * @创建时间 2025-12-20
5
5
  * @描述 实现 UI 组件信息的查询功能
6
6
  */
7
7
  import type { UIComponentDoc } from '../types/index.js';
@@ -1,186 +1,2 @@
1
- /**
2
- * 组件信息查询
3
- * @作者 li peng
4
- * @创建时间 2024-12-29
5
- * @描述 实现 UI 组件信息的查询功能
6
- */
7
- /**
8
- * 规范化组件名称
9
- * 支持带或不带 em- 前缀的查询
10
- * @param name 组件名称
11
- * @returns 规范化后的名称数组(用于查找)
12
- */
13
- export function normalizeComponentName(name) {
14
- const normalized = name.toLowerCase().trim();
15
- const names = [normalized];
16
- // 如果带有 em- 前缀,添加不带前缀的版本
17
- if (normalized.startsWith('em-')) {
18
- names.push(normalized.replace('em-', ''));
19
- }
20
- else {
21
- // 如果不带前缀,添加带前缀的版本
22
- names.push(`em-${normalized}`);
23
- }
24
- return names;
25
- }
26
- /**
27
- * 获取组件信息
28
- * @param components 组件映射
29
- * @param name 组件名称
30
- * @returns 组件信息或 null
31
- */
32
- export function getComponentInfo(components, name) {
33
- const names = normalizeComponentName(name);
34
- for (const n of names) {
35
- const doc = components.get(n);
36
- if (doc) {
37
- return doc;
38
- }
39
- }
40
- return null;
41
- }
42
- /**
43
- * 查找相似的组件名称
44
- * @param components 组件映射
45
- * @param name 查询的名称
46
- * @param limit 返回数量限制
47
- * @returns 相似组件名称数组
48
- */
49
- export function findSimilarComponents(components, name, limit = 5) {
50
- const query = name.toLowerCase().replace('em-', '');
51
- const seen = new Set();
52
- const similar = [];
53
- for (const [, doc] of components) {
54
- if (seen.has(doc.id))
55
- continue;
56
- seen.add(doc.id);
57
- const componentName = doc.id.toLowerCase();
58
- const score = calculateSimilarity(query, componentName);
59
- if (score > 0.3) {
60
- similar.push({ name: doc.name, score });
61
- }
62
- }
63
- // 按相似度排序
64
- similar.sort((a, b) => b.score - a.score);
65
- return similar.slice(0, limit).map(s => s.name);
66
- }
67
- /**
68
- * 计算两个字符串的相似度(简单实现)
69
- * @param a 字符串 a
70
- * @param b 字符串 b
71
- * @returns 相似度分数 (0-1)
72
- */
73
- function calculateSimilarity(a, b) {
74
- if (a === b)
75
- return 1;
76
- if (a.length === 0 || b.length === 0)
77
- return 0;
78
- // 检查是否包含
79
- if (a.includes(b) || b.includes(a)) {
80
- return 0.8;
81
- }
82
- // 计算共同字符数
83
- const setA = new Set(a.split(''));
84
- const setB = new Set(b.split(''));
85
- let common = 0;
86
- for (const char of setA) {
87
- if (setB.has(char))
88
- common++;
89
- }
90
- return common / Math.max(setA.size, setB.size);
91
- }
92
- /**
93
- * 格式化组件信息为文本
94
- * @param doc 组件文档
95
- * @returns 格式化的文本
96
- */
97
- export function formatComponentInfo(doc) {
98
- const lines = [];
99
- // 标题
100
- lines.push(`# ${doc.name} (${doc.title})`);
101
- lines.push('');
102
- lines.push(doc.description);
103
- lines.push('');
104
- // Props
105
- if (doc.props.length > 0) {
106
- lines.push('## Props');
107
- lines.push('');
108
- lines.push('| 参数 | 类型 | 默认值 | 必填 | 说明 |');
109
- lines.push('| --- | --- | --- | --- | --- |');
110
- for (const prop of doc.props) {
111
- lines.push(`| ${prop.name} | ${prop.type} | ${prop.default || '-'} | ${prop.required ? '是' : '否'} | ${prop.description} |`);
112
- }
113
- lines.push('');
114
- }
115
- // Events
116
- if (doc.events.length > 0) {
117
- lines.push('## Events');
118
- lines.push('');
119
- lines.push('| 事件名 | 参数 | 说明 |');
120
- lines.push('| --- | --- | --- |');
121
- for (const event of doc.events) {
122
- lines.push(`| ${event.name} | ${event.parameters} | ${event.description} |`);
123
- }
124
- lines.push('');
125
- }
126
- // Slots
127
- if (doc.slots && doc.slots.length > 0) {
128
- lines.push('## Slots');
129
- lines.push('');
130
- lines.push('| 名称 | 说明 |');
131
- lines.push('| --- | --- |');
132
- for (const slot of doc.slots) {
133
- lines.push(`| ${slot.name} | ${slot.description} |`);
134
- }
135
- lines.push('');
136
- }
137
- // 示例代码
138
- if (doc.examples) {
139
- if (doc.examples.vue2 && doc.examples.vue2.length > 0) {
140
- lines.push('## Vue2 (M8.3) 示例');
141
- lines.push('');
142
- for (const example of doc.examples.vue2) {
143
- lines.push(`### ${example.title}`);
144
- if (example.description) {
145
- lines.push(example.description);
146
- }
147
- lines.push('```vue');
148
- lines.push(example.code);
149
- lines.push('```');
150
- lines.push('');
151
- }
152
- }
153
- if (doc.examples.vue3 && doc.examples.vue3.length > 0) {
154
- lines.push('## Vue3 (M8.4) 示例');
155
- lines.push('');
156
- for (const example of doc.examples.vue3) {
157
- lines.push(`### ${example.title}`);
158
- if (example.description) {
159
- lines.push(example.description);
160
- }
161
- lines.push('```vue');
162
- lines.push(example.code);
163
- lines.push('```');
164
- lines.push('');
165
- }
166
- }
167
- }
168
- return lines.join('\n');
169
- }
170
- /**
171
- * 获取所有组件列表
172
- * @param components 组件映射
173
- * @returns 组件列表
174
- */
175
- export function getAllComponents(components) {
176
- const seen = new Set();
177
- const list = [];
178
- for (const [, doc] of components) {
179
- if (seen.has(doc.id))
180
- continue;
181
- seen.add(doc.id);
182
- list.push({ name: doc.name, title: doc.title });
183
- }
184
- return list.sort((a, b) => a.name.localeCompare(b.name));
185
- }
186
- //# sourceMappingURL=components.js.map
1
+ function m(s){const e=s.toLowerCase().trim(),n=[e];return e.startsWith("em-")?n.push(e.replace("em-","")):n.push(`em-${e}`),n}function h(s,e){const n=m(e);for(const t of n){const o=s.get(t);if(o)return o}return null}function l(s,e,n=5){const t=e.toLowerCase().replace("em-",""),o=new Set,i=[];for(const[,r]of s){if(o.has(r.id))continue;o.add(r.id);const p=r.id.toLowerCase(),u=a(t,p);u>.3&&i.push({name:r.name,score:u})}return i.sort((r,p)=>p.score-r.score),i.slice(0,n).map(r=>r.name)}function a(s,e){if(s===e)return 1;if(s.length===0||e.length===0)return 0;if(s.includes(e)||e.includes(s))return .8;const n=new Set(s.split("")),t=new Set(e.split(""));let o=0;for(const i of n)t.has(i)&&o++;return o/Math.max(n.size,t.size)}function c(s){const e=[];if(e.push(`# ${s.name} (${s.title})`),e.push(""),e.push(s.description),e.push(""),s.props.length>0){e.push("## Props"),e.push(""),e.push("| \u53C2\u6570 | \u7C7B\u578B | \u9ED8\u8BA4\u503C | \u5FC5\u586B | \u8BF4\u660E |"),e.push("| --- | --- | --- | --- | --- |");for(const n of s.props)e.push(`| ${n.name} | ${n.type} | ${n.default||"-"} | ${n.required?"\u662F":"\u5426"} | ${n.description} |`);e.push("")}if(s.events.length>0){e.push("## Events"),e.push(""),e.push("| \u4E8B\u4EF6\u540D | \u53C2\u6570 | \u8BF4\u660E |"),e.push("| --- | --- | --- |");for(const n of s.events)e.push(`| ${n.name} | ${n.parameters} | ${n.description} |`);e.push("")}if(s.slots&&s.slots.length>0){e.push("## Slots"),e.push(""),e.push("| \u540D\u79F0 | \u8BF4\u660E |"),e.push("| --- | --- |");for(const n of s.slots)e.push(`| ${n.name} | ${n.description} |`);e.push("")}if(s.examples){if(s.examples.vue2&&s.examples.vue2.length>0){e.push("## Vue2 (M8.3) \u793A\u4F8B"),e.push("");for(const n of s.examples.vue2)e.push(`### ${n.title}`),n.description&&e.push(n.description),e.push("```vue"),e.push(n.code),e.push("```"),e.push("")}if(s.examples.vue3&&s.examples.vue3.length>0){e.push("## Vue3 (M8.4) \u793A\u4F8B"),e.push("");for(const n of s.examples.vue3)e.push(`### ${n.title}`),n.description&&e.push(n.description),e.push("```vue"),e.push(n.code),e.push("```"),e.push("")}}return e.join(`
2
+ `)}function f(s){const e=new Set,n=[];for(const[,t]of s)e.has(t.id)||(e.add(t.id),n.push({name:t.name,title:t.title}));return n.sort((t,o)=>t.name.localeCompare(o.name))}export{l as findSimilarComponents,c as formatComponentInfo,f as getAllComponents,h as getComponentInfo,m as normalizeComponentName};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Document Manager 主入口
3
3
  * @作者 li peng
4
- * @创建时间 2024-12-29
4
+ * @创建时间 2025-12-20
5
5
  * @描述 文档管理器,提供文档加载、搜索和查询功能
6
6
  */
7
7
  import type { DocumentIndex, SearchOptions, SearchResult, UIComponentDoc, CodingStandardDoc, UtilDoc, ApiDoc, StandardType } from '../types/index.js';