@doubao-apps/create 0.0.31 → 0.0.32

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 (35) hide show
  1. package/dist/36.js +4 -4
  2. package/dist/cli.js +33 -31
  3. package/dist/template-empty/AGENTS.md +12 -0
  4. package/dist/template-empty/package.json +2 -2
  5. package/dist/template-empty/references/reference/open-api/02-/345/256/232/344/275/215.md +224 -0
  6. package/dist/template-empty/references/reference/open-api/22-/350/256/276/345/244/207-/345/237/272/347/241/200/344/277/241/346/201/257.md +133 -0
  7. package/dist/template-empty/references/reference/open-api/README.md +12 -11
  8. package/dist/template-empty/references/reference/open-api.md +460 -0
  9. package/dist/template-starter/AGENTS.md +12 -0
  10. package/dist/template-starter/package.json +2 -2
  11. package/dist/template-starter/references/reference/open-api/02-/345/256/232/344/275/215.md +224 -0
  12. package/dist/template-starter/references/reference/open-api/22-/350/256/276/345/244/207-/345/237/272/347/241/200/344/277/241/346/201/257.md +133 -0
  13. package/dist/template-starter/references/reference/open-api/README.md +12 -11
  14. package/dist/template-starter/references/reference/open-api.md +460 -0
  15. package/package.json +1 -1
  16. /package/dist/template-empty/references/reference/open-api/{22- → 23-}/350/256/276/345/244/207-/347/224/265/346/261/240.md" +0 -0
  17. /package/dist/template-empty/references/reference/open-api/{23- → 24-}/350/256/276/345/244/207-/346/227/245/345/216/206.md" +0 -0
  18. /package/dist/template-empty/references/reference/open-api/{24- → 25-}/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md" +0 -0
  19. /package/dist/template-empty/references/reference/open-api/{25- → 26-}/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md" +0 -0
  20. /package/dist/template-empty/references/reference/open-api/{26- → 27-}/350/256/276/345/244/207-/345/212/240/345/257/206.md" +0 -0
  21. /package/dist/template-empty/references/reference/open-api/{27- → 28-}/350/256/276/345/244/207-/347/224/265/350/257/235.md" +0 -0
  22. /package/dist/template-empty/references/reference/open-api/{28- → 29-}/350/256/276/345/244/207-/346/211/253/347/240/201.md" +0 -0
  23. /package/dist/template-empty/references/reference/open-api/{29- → 30-}/350/256/276/345/244/207-/345/261/217/345/271/225.md" +0 -0
  24. /package/dist/template-empty/references/reference/open-api/{30- → 31-}/350/256/276/345/244/207-/351/234/207/345/212/250.md" +0 -0
  25. /package/dist/template-empty/references/reference/open-api/{31- → 32-}/346/226/207/344/273/266/347/263/273/347/273/237.md" +0 -0
  26. /package/dist/template-starter/references/reference/open-api/{22- → 23-}/350/256/276/345/244/207-/347/224/265/346/261/240.md" +0 -0
  27. /package/dist/template-starter/references/reference/open-api/{23- → 24-}/350/256/276/345/244/207-/346/227/245/345/216/206.md" +0 -0
  28. /package/dist/template-starter/references/reference/open-api/{24- → 25-}/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md" +0 -0
  29. /package/dist/template-starter/references/reference/open-api/{25- → 26-}/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md" +0 -0
  30. /package/dist/template-starter/references/reference/open-api/{26- → 27-}/350/256/276/345/244/207-/345/212/240/345/257/206.md" +0 -0
  31. /package/dist/template-starter/references/reference/open-api/{27- → 28-}/350/256/276/345/244/207-/347/224/265/350/257/235.md" +0 -0
  32. /package/dist/template-starter/references/reference/open-api/{28- → 29-}/350/256/276/345/244/207-/346/211/253/347/240/201.md" +0 -0
  33. /package/dist/template-starter/references/reference/open-api/{29- → 30-}/350/256/276/345/244/207-/345/261/217/345/271/225.md" +0 -0
  34. /package/dist/template-starter/references/reference/open-api/{30- → 31-}/350/256/276/345/244/207-/351/234/207/345/212/250.md" +0 -0
  35. /package/dist/template-starter/references/reference/open-api/{31- → 32-}/346/226/207/344/273/266/347/263/273/347/273/237.md" +0 -0
@@ -215,6 +215,18 @@ export default defineWidget({
215
215
  - **路由编码**:入口页跳转含 `/` 的 case name 时必须 `encodeURIComponent`;开发模式 `delegate-page` 的 query 需要 encode/decode。
216
216
  - **响应式主题**:Playground 外壳和示例辅助 UI 使用 `--pg-*` 变量;不要在 Playground 任务中顺手修组件库自身主题。
217
217
 
218
+ ### API e2e 测试范式
219
+
220
+ 当任务新增或正式暴露 `@doubao-apps/framework/api` / Open API / JSB API 时,必须同步补充 `e2e/api` 自动化测试:
221
+
222
+ - **测试目录**:Vitest case 放在 `e2e/api/__tests__/`,优先补到已有 domain 文件,如 `basic.test.ts`、`network.test.ts`、`storage.test.ts`、`device.test.ts`、`ui.test.ts`;没有合适分组时新建 `<domain>.test.ts`。
223
+ - **测试小程序**:`examples/e2e-api-runner` 只负责建立 WebSocket 链接、接收 API 调用指令、执行 `@doubao-apps/framework/api` 并回传结果;不要把具体 e2e case 写在小程序或 playground 内。
224
+ - **协议层**:WebSocket server、协议类型和 runner client 由 `@byted-doubao-apps/e2e-runner` 提供;不要在测试用例里重复实现通信协议。
225
+ - **调用方式**:在测试中使用 `const session = await getApiSession()`,再通过 `await session.callApi<TResult>('<apiName>', [params], { timeoutMs })` 调用并在 Vitest 侧断言。
226
+ - **稳定性原则**:只自动化稳定、低副作用、可断言的 API;强交互、权限弹窗、支付、路由退出、账号业务态或设备状态不稳定的 API 应 `it.skip` / `describe.skip` 并写明原因。
227
+ - **本地依赖**:网络类 API 优先使用 `session.httpFixtureServer`,避免依赖公网。
228
+ - **验证命令**:至少运行 `pnpm --filter @byted-doubao-apps/e2e-api typecheck`;有目标设备时再运行 `pnpm --filter @byted-doubao-apps/e2e-api test:api`。
229
+
218
230
  ### Lynx 组件
219
231
 
220
232
  Lynx 组件库完整参考文档请访问官方文档:
@@ -6,10 +6,10 @@
6
6
  "build": "doubao build"
7
7
  },
8
8
  "dependencies": {
9
- "@doubao-apps/framework": "^0.0.31"
9
+ "@doubao-apps/framework": "^0.0.32"
10
10
  },
11
11
  "devDependencies": {
12
- "@doubao-apps/kit": "^0.0.31",
12
+ "@doubao-apps/kit": "^0.0.32",
13
13
  "typescript": "5.5.3"
14
14
  },
15
15
  "version": "0.0.16"
@@ -9,6 +9,14 @@
9
9
  | API | 说明 |
10
10
  | --- | --- |
11
11
  | [getLocation](#getlocation) | 获取设备当前的地理位置信息。<br><br>可能涉及定位授权。 |
12
+ | [chooseLocation](#chooselocation) | 打开地图选择位置。 |
13
+ | [openLocation](#openlocation) | 使用地图查看位置。 |
14
+ | [startLocationUpdate](#startlocationupdate) | 开始接收位置更新。<br><br>需配对调用 stopLocationUpdate。 |
15
+ | [stopLocationUpdate](#stoplocationupdate) | 停止接收位置更新。 |
16
+ | [onLocationChange](#onlocationchange) | 注册地理位置变化回调。<br><br>返回 void,不是 Promise。 |
17
+ | [offLocationChange](#offlocationchange) | 取消注册地理位置变化回调。<br><br>返回 void,不是 Promise。 |
18
+ | [onLocationChangeError](#onlocationchangeerror) | 注册位置更新异常回调。<br><br>返回 void,不是 Promise。 |
19
+ | [offLocationChangeError](#offlocationchangeerror) | 取消注册位置更新异常回调。<br><br>返回 void,不是 Promise。 |
12
20
 
13
21
  ## API 详情
14
22
 
@@ -65,6 +73,130 @@ async function fetchLocation() {
65
73
  fetchLocation();
66
74
  ```
67
75
 
76
+ <a id="chooselocation"></a>
77
+ ### chooseLocation()
78
+
79
+ > **chooseLocation**(`params`?): `Promise`\<[`ChooseLocationResponse`](#chooselocationresponse)\>
80
+
81
+ 打开地图选择位置。
82
+
83
+ #### Parameters
84
+
85
+ • **params?**: [`ChooseLocationParams`](#chooselocationparams)
86
+
87
+ #### Returns
88
+
89
+ `Promise`\<[`ChooseLocationResponse`](#chooselocationresponse)\>
90
+
91
+ <a id="openlocation"></a>
92
+ ### openLocation()
93
+
94
+ > **openLocation**(`params`): `Promise`\<`object`\>
95
+
96
+ 使用地图查看位置。
97
+
98
+ #### Parameters
99
+
100
+ • **params**: [`OpenLocationParams`](#openlocationparams)
101
+
102
+ #### Returns
103
+
104
+ `Promise`\<`object`\>
105
+
106
+ <a id="startlocationupdate"></a>
107
+ ### startLocationUpdate()
108
+
109
+ > **startLocationUpdate**(`params`?): `Promise`\<`object`\>
110
+
111
+ 开始接收位置更新。
112
+
113
+ #### Parameters
114
+
115
+ • **params?**: [`StartLocationUpdateParams`](#startlocationupdateparams)
116
+
117
+ #### Returns
118
+
119
+ `Promise`\<`object`\>
120
+
121
+ #### Remarks
122
+
123
+ 需配对调用 stopLocationUpdate。
124
+
125
+ <a id="stoplocationupdate"></a>
126
+ ### stopLocationUpdate()
127
+
128
+ > **stopLocationUpdate**(`params`?): `Promise`\<`object`\>
129
+
130
+ 停止接收位置更新。
131
+
132
+ #### Parameters
133
+
134
+ • **params?**
135
+
136
+ #### Returns
137
+
138
+ `Promise`\<`object`\>
139
+
140
+ <a id="onlocationchange"></a>
141
+ ### onLocationChange()
142
+
143
+ > **onLocationChange**(`callback`): `void`
144
+
145
+ 注册地理位置变化回调。
146
+
147
+ #### Parameters
148
+
149
+ • **callback**: [`LocationChangeListener`](#locationchangelistener)
150
+
151
+ #### Returns
152
+
153
+ `void`
154
+
155
+ <a id="offlocationchange"></a>
156
+ ### offLocationChange()
157
+
158
+ > **offLocationChange**(`callback`?): `void`
159
+
160
+ 取消注册地理位置变化回调。
161
+
162
+ #### Parameters
163
+
164
+ • **callback?**: [`LocationChangeListener`](#locationchangelistener)
165
+
166
+ #### Returns
167
+
168
+ `void`
169
+
170
+ <a id="onlocationchangeerror"></a>
171
+ ### onLocationChangeError()
172
+
173
+ > **onLocationChangeError**(`callback`): `void`
174
+
175
+ 注册位置更新异常回调。
176
+
177
+ #### Parameters
178
+
179
+ • **callback**: [`LocationChangeErrorListener`](#locationchangeerrorlistener)
180
+
181
+ #### Returns
182
+
183
+ `void`
184
+
185
+ <a id="offlocationchangeerror"></a>
186
+ ### offLocationChangeError()
187
+
188
+ > **offLocationChangeError**(`callback`?): `void`
189
+
190
+ 取消注册位置更新异常回调。
191
+
192
+ #### Parameters
193
+
194
+ • **callback?**: [`LocationChangeErrorListener`](#locationchangeerrorlistener)
195
+
196
+ #### Returns
197
+
198
+ `void`
199
+
68
200
  ## 相关类型
69
201
 
70
202
  <a id="getlocationparams"></a>
@@ -133,3 +265,95 @@ fetchLocation();
133
265
  > **timestamp**: `string`
134
266
 
135
267
  时间戳
268
+
269
+ <a id="chooselocationparams"></a>
270
+ ### ChooseLocationParams
271
+
272
+ #### Properties
273
+
274
+ ##### latitude?
275
+
276
+ > `optional` **latitude**: `number`
277
+
278
+ 目标地纬度
279
+
280
+ ##### longitude?
281
+
282
+ > `optional` **longitude**: `number`
283
+
284
+ 目标地经度
285
+
286
+ <a id="chooselocationresponse"></a>
287
+ ### ChooseLocationResponse
288
+
289
+ #### Properties
290
+
291
+ ##### address?
292
+
293
+ > `optional` **address**: `string`
294
+
295
+ 地址详情
296
+
297
+ ##### latitude
298
+
299
+ > **latitude**: `number`
300
+
301
+ 纬度,GCJ-02 坐标系
302
+
303
+ ##### longitude
304
+
305
+ > **longitude**: `number`
306
+
307
+ 经度,GCJ-02 坐标系
308
+
309
+ ##### name?
310
+
311
+ > `optional` **name**: `string`
312
+
313
+ 位置名称
314
+
315
+ <a id="openlocationparams"></a>
316
+ ### OpenLocationParams
317
+
318
+ #### Properties
319
+
320
+ ##### address?
321
+
322
+ > `optional` **address**: `string`
323
+
324
+ 地址详情
325
+
326
+ ##### latitude
327
+
328
+ > **latitude**: `number`
329
+
330
+ 纬度
331
+
332
+ ##### longitude
333
+
334
+ > **longitude**: `number`
335
+
336
+ 经度
337
+
338
+ ##### name?
339
+
340
+ > `optional` **name**: `string`
341
+
342
+ 位置名称
343
+
344
+ ##### scale?
345
+
346
+ > `optional` **scale**: `number`
347
+
348
+ 缩放比例,范围 5 ~ 18
349
+
350
+ <a id="startlocationupdateparams"></a>
351
+ ### StartLocationUpdateParams
352
+
353
+ #### Properties
354
+
355
+ ##### type?
356
+
357
+ > `optional` **type**: `"wgs84"` \| `"gcj02"`
358
+
359
+ 坐标系类型,支持 wgs84 或 gcj02
@@ -0,0 +1,133 @@
1
+ # Open API: 设备 / 基础信息
2
+
3
+ 设备品牌、型号、系统、内存和性能等级。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [getDeviceInfo](#getdeviceinfo) | 获取设备基础信息。 |
12
+ | [getDeviceInfoSync](#getdeviceinfosync) | 同步获取设备基础信息。<br><br>同步 API。 |
13
+
14
+ ## API 详情
15
+
16
+ <a id="getdeviceinfo"></a>
17
+ ### getDeviceInfo()
18
+
19
+ > **getDeviceInfo**(`params`?): `Promise`\<[`GetDeviceInfoResult`](#getdeviceinforesult)\>
20
+
21
+ 获取设备基础信息。
22
+
23
+ #### Parameters
24
+
25
+ • **params?**
26
+
27
+ #### Returns
28
+
29
+ `Promise`\<[`GetDeviceInfoResult`](#getdeviceinforesult)\>
30
+
31
+ 返回设备品牌、型号、系统、内存和性能等级等字段,见 [GetDeviceInfoResult](#getdeviceinforesult)。
32
+
33
+ #### Example
34
+
35
+ ```typescript
36
+ import { getDeviceInfo } from '@doubao-apps/framework/api';
37
+
38
+ const result = await getDeviceInfo();
39
+
40
+ console.log(result.brand, result.model, result.system);
41
+ console.log(result.platform, result.benchmarkLevel);
42
+ ```
43
+
44
+ <a id="getdeviceinfosync"></a>
45
+ ### getDeviceInfoSync()
46
+
47
+ > **getDeviceInfoSync**(`params`?): [`GetDeviceInfoResult`](#getdeviceinforesult)
48
+
49
+ 同步获取设备基础信息。
50
+
51
+ #### Parameters
52
+
53
+ • **params?**
54
+
55
+ #### Returns
56
+
57
+ [`GetDeviceInfoResult`](#getdeviceinforesult)
58
+
59
+ 返回设备品牌、型号、系统、内存和性能等级等字段,见 [GetDeviceInfoResult](#getdeviceinforesult)。
60
+
61
+ #### Example
62
+
63
+ ```typescript
64
+ import { getDeviceInfoSync } from '@doubao-apps/framework/api';
65
+
66
+ const result = getDeviceInfoSync();
67
+
68
+ console.log(result.brand, result.model, result.system);
69
+ console.log(result.platform, result.benchmarkLevel);
70
+ ```
71
+
72
+ ## 相关类型
73
+
74
+ <a id="getdeviceinforesult"></a>
75
+ ### GetDeviceInfoResult
76
+
77
+ 设备基础信息。
78
+
79
+ #### Properties
80
+
81
+ ##### abi?
82
+
83
+ > `optional` **abi**: `string`
84
+
85
+ 宿主 App 二进制接口类型,仅 Android 支持。
86
+
87
+ ##### benchmarkLevel
88
+
89
+ > **benchmarkLevel**: `number`
90
+
91
+ 设备性能等级,值越高性能越好;-1 表示未知。
92
+
93
+ ##### brand
94
+
95
+ > **brand**: `string`
96
+
97
+ 设备品牌。
98
+
99
+ ##### cpuType?
100
+
101
+ > `optional` **cpuType**: `string`
102
+
103
+ 设备 CPU 型号,仅 Android 支持。
104
+
105
+ ##### deviceAbi?
106
+
107
+ > `optional` **deviceAbi**: `string`
108
+
109
+ 设备二进制接口类型,仅 Android 支持。
110
+
111
+ ##### memorySize
112
+
113
+ > **memorySize**: `string`
114
+
115
+ 设备内存大小,单位 MB。
116
+
117
+ ##### model
118
+
119
+ > **model**: `string`
120
+
121
+ 设备型号。
122
+
123
+ ##### platform
124
+
125
+ > **platform**: `string`
126
+
127
+ 客户端平台。
128
+
129
+ ##### system
130
+
131
+ > **system**: `string`
132
+
133
+ 操作系统及版本。
@@ -7,7 +7,7 @@
7
7
  | 分组 | 说明 | API 数量 | 详细文档 |
8
8
  | --- | --- | ---: | --- |
9
9
  | 基础 / 账号 / 系统 | 账号、授权、宿主基础信息、窗口信息和能力可用性。 | 9 | [查看](./01-基础-账号-系统.md) |
10
- | 定位 | 获取设备当前的地理位置信息。 | 1 | [查看](./02-定位.md) |
10
+ | 定位 | 获取设备当前的地理位置信息。 | 9 | [查看](./02-定位.md) |
11
11
  | 存储 | 本地缓存;带 Sync 后缀的是同步 API。 | 10 | [查看](./03-存储.md) |
12
12
  | 路由 | 应用内页面跳转、返回、退出和关闭。 | 6 | [查看](./04-路由.md) |
13
13
  | 界面 / 交互 | Toast、Loading、Modal、ActionSheet 和返回前提醒。 | 9 | [查看](./05-界面-交互.md) |
@@ -27,13 +27,14 @@
27
27
  | 设备 / 网络 | 网络类型和本机局域网 IP。 | 3 | [查看](./19-设备-网络.md) |
28
28
  | 设备 / 短信 | 拉起系统短信发送面板。 | 1 | [查看](./20-设备-短信.md) |
29
29
  | 设备 / 无障碍 | 检测无障碍能力开关状态。 | 1 | [查看](./21-设备-无障碍.md) |
30
- | 设备 / 电池 | 电池信息读取与变化监听。 | 2 | [查看](./22-设备-电池.md) |
31
- | 设备 / 日历 | 向系统日历添加事件和重复事件。 | 2 | [查看](./23-设备-日历.md) |
32
- | 设备 / 剪贴板 | 读取和设置系统剪贴板内容。 | 2 | [查看](./24-设备-剪贴板.md) |
33
- | 设备 / 联系人 | 选择和添加手机联系人。 | 2 | [查看](./25-设备-联系人.md) |
34
- | 设备 / 加密 | 安全随机数能力。 | 1 | [查看](./26-设备-加密.md) |
35
- | 设备 / 电话 | 拨打电话。 | 1 | [查看](./27-设备-电话.md) |
36
- | 设备 / 扫码 | 调起扫码并读取扫码结果。 | 1 | [查看](./28-设备-扫码.md) |
37
- | 设备 / 屏幕 | 屏幕亮度、常亮和截屏/录屏相关能力。 | 5 | [查看](./29-设备-屏幕.md) |
38
- | 设备 / 震动 | 触发短震动和长震动。 | 2 | [查看](./30-设备-震动.md) |
39
- | 文件系统 | 文件读写、目录管理和文件信息操作。 | 1 | [查看](./31-文件系统.md) |
30
+ | 设备 / 基础信息 | 设备品牌、型号、系统、内存和性能等级。 | 2 | [查看](./22-设备-基础信息.md) |
31
+ | 设备 / 电池 | 电池信息读取与变化监听。 | 2 | [查看](./23-设备-电池.md) |
32
+ | 设备 / 日历 | 向系统日历添加事件和重复事件。 | 2 | [查看](./24-设备-日历.md) |
33
+ | 设备 / 剪贴板 | 读取和设置系统剪贴板内容。 | 2 | [查看](./25-设备-剪贴板.md) |
34
+ | 设备 / 联系人 | 选择和添加手机联系人。 | 2 | [查看](./26-设备-联系人.md) |
35
+ | 设备 / 加密 | 安全随机数能力。 | 1 | [查看](./27-设备-加密.md) |
36
+ | 设备 / 电话 | 拨打电话。 | 1 | [查看](./28-设备-电话.md) |
37
+ | 设备 / 扫码 | 调起扫码并读取扫码结果。 | 1 | [查看](./29-设备-扫码.md) |
38
+ | 设备 / 屏幕 | 屏幕亮度、常亮和截屏/录屏相关能力。 | 5 | [查看](./30-设备-屏幕.md) |
39
+ | 设备 / 震动 | 触发短震动和长震动。 | 2 | [查看](./31-设备-震动.md) |
40
+ | 文件系统 | 文件读写、目录管理和文件信息操作。 | 1 | [查看](./32-文件系统.md) |