@heybox/hb-sdk 0.9.6-alpha.1 → 0.9.6-alpha.11
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.
- package/CHANGELOG.md +86 -5
- package/README.md +37 -557
- package/dist/cli-chunks/{artifact-C5n7xjnz.cjs → artifact-BW6SD1G6.cjs} +3 -3
- package/dist/cli-chunks/{build-BgBt5SkX.cjs → build-B0Id0UTN.cjs} +8 -6
- package/dist/cli-chunks/{create-BL6uwtkQ.cjs → create-DVu93Ekp.cjs} +3 -1
- package/dist/cli-chunks/{dev-NgklQb6b.cjs → dev-CeSjpEZQ.cjs} +9613 -616
- package/dist/cli-chunks/{dev-context-Tf8MgSsu.cjs → dev-context-CVc_BsWR.cjs} +4 -6
- package/dist/cli-chunks/{doctor-CGlEf1yi.cjs → doctor-BF9mtkJr.cjs} +3 -1
- package/dist/cli-chunks/{games-Cc-DclmK.cjs → games-BKnDCklM.cjs} +3 -1
- package/dist/cli-chunks/{index-D9XLBbNV.cjs → index-Cgui_8Rk.cjs} +1 -1
- package/dist/cli-chunks/{index-CmxsiTTn.cjs → index-Rp3UMZIO.cjs} +1754 -120
- package/dist/cli-chunks/index.esm-BK0eVYaM.cjs +154 -0
- package/dist/cli-chunks/{login-ZMBDHBuA.cjs → login-DpeDN-mt.cjs} +3 -3
- package/dist/cli-chunks/{project-vite-eM87vX9L.cjs → project-vite-Cg3jYqAJ.cjs} +3 -18
- package/dist/cli-chunks/{remote-DVhxpWDg.cjs → remote-BQ-9rhTb.cjs} +12 -21
- package/dist/cli-chunks/{runtime-permission-env-q1FWWwbV.cjs → runtime-permission-env-BgipCJ0Z.cjs} +62 -13
- package/dist/cli-chunks/{skill-mRXM87hY.cjs → skill-D7pd4yPq.cjs} +3 -2
- package/dist/cli-chunks/{version-BqHRI4Lz.cjs → version-DbjRZkb6.cjs} +1 -1
- package/dist/cli.cjs +3 -1
- package/dist/dev.cjs +1358 -0
- package/dist/dev.mjs +1356 -0
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-DVlT56iQ.js +100 -0
- package/dist/devtools/browser-dev-host/assets/desktop-app-launch-BzRxl_MM.js +6 -0
- package/dist/devtools/browser-dev-host/assets/index-CHYEXFEg.css +1 -0
- package/dist/devtools/browser-dev-host/assets/index-DY5ZynQp.js +586 -0
- package/dist/devtools/browser-dev-host/index.html +3 -3
- package/dist/index.cjs.js +232 -114
- package/dist/index.esm.js +232 -114
- package/dist/miniapp-publish.cjs.js +2 -2
- package/dist/miniapp-publish.esm.js +2 -2
- package/dist/protocol.cjs.js +5 -0
- package/dist/protocol.esm.js +5 -0
- package/dist/vite.cjs.js +1060 -203
- package/dist/vite.esm.js +1061 -204
- package/docs/device-logs.md +39 -22
- package/package.json +22 -9
- package/skill/skill.json +4 -4
- package/types/dev/index.d.cts +386 -0
- package/types/dev/index.d.mts +386 -0
- package/types/dev/vendor/playwright-core/LICENSE +202 -0
- package/types/dev/vendor/playwright-core/NOTICE +5 -0
- package/types/dev/vendor/playwright-core/UPSTREAM.json +5 -0
- package/types/dev/vendor/playwright-core/types/protocol.d.ts +24776 -0
- package/types/dev/vendor/playwright-core/types/structs.d.ts +52 -0
- package/types/dev/vendor/playwright-core/types/types.d.ts +27167 -0
- package/types/index.d.ts +66 -5
- package/types/protocol.d.ts +3 -2
- package/types/vite/index.d.ts +5 -4
- package/dist/cli-chunks/index.esm-DnyLP_Zc.cjs +0 -5216
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-DtWOjzCe.js +0 -103
- package/dist/devtools/browser-dev-host/assets/desktop-app-launch-C2Vw0-AC.js +0 -6
- package/dist/devtools/browser-dev-host/assets/index-B-rjfibN.js +0 -567
- package/dist/devtools/browser-dev-host/assets/index-DSTlrpnQ.css +0 -1
- package/docs/runtime-host-migration.md +0 -128
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import { Page, FrameLocator } from './vendor/playwright-core/types/types.js';
|
|
3
|
+
|
|
4
|
+
/** 连接建立时的会话快照;服务重启或预览目标变化后需要重新连接。 */
|
|
5
|
+
interface PreviewSession {
|
|
6
|
+
/** 调试台所属 dev 会话 ID。 */
|
|
7
|
+
readonly id: string;
|
|
8
|
+
/** 已核验的项目真实绝对路径。 */
|
|
9
|
+
readonly projectRoot: string;
|
|
10
|
+
/** 当前调试台的实际端口。 */
|
|
11
|
+
readonly port: number;
|
|
12
|
+
/** 本次连接精确绑定的浏览器 target ID。 */
|
|
13
|
+
readonly cdpTargetId: string;
|
|
14
|
+
}
|
|
15
|
+
/** 当前项目预览的原生 Playwright 连接。 */
|
|
16
|
+
interface ConnectedPreview {
|
|
17
|
+
/** 原生调试台 Page,支持 Playwright 的定位、交互、等待和截图 API。 */
|
|
18
|
+
readonly page: Page;
|
|
19
|
+
/** 原生小程序 FrameLocator;Runtime 更换 iframe 后,下次定位会解析新 iframe。 */
|
|
20
|
+
readonly app: FrameLocator;
|
|
21
|
+
/** 连接建立时核验通过的会话身份,不在后台自动切换目标。 */
|
|
22
|
+
readonly session: PreviewSession;
|
|
23
|
+
/**
|
|
24
|
+
* 释放本连接的交互焦点模拟并断开控制连接,保留浏览器窗口和标签页。
|
|
25
|
+
*
|
|
26
|
+
* @returns 本次客户端连接已断开;重复调用共用同一次清理。
|
|
27
|
+
* @since 0.9.6
|
|
28
|
+
*/
|
|
29
|
+
disconnect(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare const DEV_DIAGNOSTICS_SCHEMA_VERSION: 3;
|
|
33
|
+
interface DevResourceCapabilities {
|
|
34
|
+
storage: boolean;
|
|
35
|
+
/** Browser Dev Host 的只读呈现快照;原生 Host 未实现时省略。 */
|
|
36
|
+
presentation?: boolean;
|
|
37
|
+
sandboxList: boolean;
|
|
38
|
+
sandboxRead: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface DevSandboxFile {
|
|
41
|
+
encoding: 'base64';
|
|
42
|
+
data: string;
|
|
43
|
+
byteLength: number;
|
|
44
|
+
truncated: boolean;
|
|
45
|
+
}
|
|
46
|
+
type DevInstanceState = 'starting' | 'ready' | 'failed' | 'closed';
|
|
47
|
+
interface DevDiagnosticError {
|
|
48
|
+
code: string;
|
|
49
|
+
message: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
stack?: string;
|
|
52
|
+
cause?: string;
|
|
53
|
+
phase?: string;
|
|
54
|
+
}
|
|
55
|
+
/** 来自实际 Host 的有限标识,仅用于展示,不代表可信硬件身份。 */
|
|
56
|
+
interface DevTargetMetadata {
|
|
57
|
+
displayName: string;
|
|
58
|
+
browser?: string;
|
|
59
|
+
os?: string;
|
|
60
|
+
deviceModel?: string;
|
|
61
|
+
osVersion?: string;
|
|
62
|
+
}
|
|
63
|
+
interface DevUploadSession {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
browser: string;
|
|
67
|
+
os: string;
|
|
68
|
+
deviceModel?: string;
|
|
69
|
+
connectedAt: number;
|
|
70
|
+
lastSeen: number;
|
|
71
|
+
online: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** 一个明确的预览页或原生 Host 连接;当前实例只由显式挂载决定。 */
|
|
74
|
+
interface DevTarget {
|
|
75
|
+
targetId: string;
|
|
76
|
+
adapterId: string;
|
|
77
|
+
ownerId: string;
|
|
78
|
+
kind: 'browser' | 'mobile';
|
|
79
|
+
capabilities: DevResourceCapabilities;
|
|
80
|
+
state: 'attached' | 'detached' | 'closed';
|
|
81
|
+
currentInstanceId: string | null;
|
|
82
|
+
cdpTargetId?: string;
|
|
83
|
+
metadata: DevTargetMetadata;
|
|
84
|
+
updatedAt: number;
|
|
85
|
+
stale: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface DevInstance {
|
|
88
|
+
instanceId: string;
|
|
89
|
+
targetId: string;
|
|
90
|
+
ownerId: string;
|
|
91
|
+
adapterId: string;
|
|
92
|
+
kind: 'browser' | 'mobile';
|
|
93
|
+
capabilities: DevResourceCapabilities;
|
|
94
|
+
state: DevInstanceState;
|
|
95
|
+
startedAt: number;
|
|
96
|
+
updatedAt: number;
|
|
97
|
+
endedAt?: number;
|
|
98
|
+
/** Runtime 报告的既有文档验证阶段;验证期间不能视为可操作。 */
|
|
99
|
+
documentVerifying?: boolean;
|
|
100
|
+
runtimeId?: string;
|
|
101
|
+
uploadSessionId?: string;
|
|
102
|
+
error?: DevDiagnosticError;
|
|
103
|
+
reason?: string;
|
|
104
|
+
startCursor: number;
|
|
105
|
+
lastCursor: number;
|
|
106
|
+
stale: boolean;
|
|
107
|
+
}
|
|
108
|
+
/** 一次宿主呈现,不代表对应 SDK 调用或外部系统动作成功。 */
|
|
109
|
+
interface DevHostInteraction {
|
|
110
|
+
interactionId: string;
|
|
111
|
+
kind: 'toast' | 'loading' | 'dialog' | 'effect';
|
|
112
|
+
method: string;
|
|
113
|
+
mode: 'simulated' | 'browser';
|
|
114
|
+
startedAt: number;
|
|
115
|
+
callId?: string;
|
|
116
|
+
message?: string;
|
|
117
|
+
title?: string;
|
|
118
|
+
status?: 'success' | 'error';
|
|
119
|
+
dismissible?: boolean;
|
|
120
|
+
actions?: string[];
|
|
121
|
+
}
|
|
122
|
+
interface DevPresentationSnapshot {
|
|
123
|
+
instanceId: string | null;
|
|
124
|
+
interactions: DevHostInteraction[];
|
|
125
|
+
}
|
|
126
|
+
type DevInteractionState = 'shown' | 'completed' | 'confirmed' | 'cancelled' | 'expired' | 'replaced' | 'hidden' | 'closed';
|
|
127
|
+
interface DevDiagnosticInput {
|
|
128
|
+
source: 'app' | 'sdk' | 'runtime' | 'host';
|
|
129
|
+
level: string;
|
|
130
|
+
message: string;
|
|
131
|
+
timestamp: number;
|
|
132
|
+
phase?: string;
|
|
133
|
+
method?: string;
|
|
134
|
+
callId?: string;
|
|
135
|
+
outcome?: string;
|
|
136
|
+
errorCode?: string;
|
|
137
|
+
durationMs?: number;
|
|
138
|
+
startedAt?: number;
|
|
139
|
+
interaction?: DevHostInteraction & {
|
|
140
|
+
state: DevInteractionState;
|
|
141
|
+
};
|
|
142
|
+
network?: {
|
|
143
|
+
method?: string;
|
|
144
|
+
origin?: string;
|
|
145
|
+
pathname?: string;
|
|
146
|
+
responseStatus?: number;
|
|
147
|
+
};
|
|
148
|
+
truncated?: boolean;
|
|
149
|
+
}
|
|
150
|
+
interface DevDiagnosticEvent extends DevDiagnosticInput {
|
|
151
|
+
targetId?: string;
|
|
152
|
+
ownerId?: string;
|
|
153
|
+
cursor: number;
|
|
154
|
+
receivedAt: number;
|
|
155
|
+
late: boolean;
|
|
156
|
+
instanceId?: string;
|
|
157
|
+
uploadSessionId?: string;
|
|
158
|
+
sequence?: number;
|
|
159
|
+
truncated: boolean;
|
|
160
|
+
}
|
|
161
|
+
interface DevResourceResult<T = unknown> {
|
|
162
|
+
instanceId: string;
|
|
163
|
+
requestId?: string;
|
|
164
|
+
resource: string;
|
|
165
|
+
timestamp: number;
|
|
166
|
+
stale: boolean;
|
|
167
|
+
value?: T;
|
|
168
|
+
/** 查询失败时保留已知实例状态;不代表本次取得实时资源。 */
|
|
169
|
+
lastKnownState?: DevInstanceState;
|
|
170
|
+
lastSeenAt?: number;
|
|
171
|
+
reason?: string;
|
|
172
|
+
code?: 'unsupported' | 'forbidden' | 'offline' | 'closed' | 'timeout' | 'busy' | 'invalid';
|
|
173
|
+
error?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare const PREVIEW_SELECTORS: {
|
|
177
|
+
readonly device: "[data-preview-target=\"device\"]";
|
|
178
|
+
readonly screen: "[data-preview-target=\"screen\"]";
|
|
179
|
+
readonly app: "#device iframe";
|
|
180
|
+
readonly workbench: "[data-testid=\"workbench-root\"]";
|
|
181
|
+
};
|
|
182
|
+
type PreviewScope = keyof typeof PREVIEW_SELECTORS;
|
|
183
|
+
type PreviewScale = 'css' | 'device';
|
|
184
|
+
type PreviewOrientation = 'portrait' | 'landscape';
|
|
185
|
+
interface PreviewObservation {
|
|
186
|
+
preset: string;
|
|
187
|
+
orientation: PreviewOrientation;
|
|
188
|
+
runtimeStatus: string;
|
|
189
|
+
viewport: {
|
|
190
|
+
width: number;
|
|
191
|
+
height: number;
|
|
192
|
+
};
|
|
193
|
+
instanceId: string | null;
|
|
194
|
+
browserPixelRatio: number;
|
|
195
|
+
presentation?: DevPresentationSnapshot;
|
|
196
|
+
}
|
|
197
|
+
interface PreviewBrowserActionRequest {
|
|
198
|
+
operationId: string;
|
|
199
|
+
/** 操作创建时固定的绝对期限,拦截主线程恢复后的迟到动作。 */
|
|
200
|
+
deadlineAt: number;
|
|
201
|
+
command: 'observe' | 'select' | 'reload';
|
|
202
|
+
preset?: string;
|
|
203
|
+
orientation?: PreviewOrientation;
|
|
204
|
+
timeoutMs?: number;
|
|
205
|
+
}
|
|
206
|
+
type PreviewBrowserActionResult = {
|
|
207
|
+
ok: true;
|
|
208
|
+
value: PreviewObservation;
|
|
209
|
+
} | {
|
|
210
|
+
ok: false;
|
|
211
|
+
error: {
|
|
212
|
+
code: string;
|
|
213
|
+
message: string;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
interface PreparePreviewCapture {
|
|
217
|
+
operationId: string;
|
|
218
|
+
deadlineAt: number;
|
|
219
|
+
scope: PreviewScope;
|
|
220
|
+
/** 当前 viewport 的冻结图,仅维持共享窗口显示。 */
|
|
221
|
+
previewImage: string;
|
|
222
|
+
}
|
|
223
|
+
interface PreparedPreviewCapture {
|
|
224
|
+
token: string;
|
|
225
|
+
clip: {
|
|
226
|
+
x: number;
|
|
227
|
+
y: number;
|
|
228
|
+
width: number;
|
|
229
|
+
height: number;
|
|
230
|
+
};
|
|
231
|
+
devicePixelRatio: number;
|
|
232
|
+
expiresAt: number;
|
|
233
|
+
}
|
|
234
|
+
interface PreviewBrowserActions {
|
|
235
|
+
readonly version: 1;
|
|
236
|
+
run(request: PreviewBrowserActionRequest): Promise<PreviewBrowserActionResult>;
|
|
237
|
+
cancel(operationId: string): void;
|
|
238
|
+
prepareCapture(input: PreparePreviewCapture): Promise<PreparedPreviewCapture>;
|
|
239
|
+
restoreCapture(token: string): boolean;
|
|
240
|
+
}
|
|
241
|
+
declare global {
|
|
242
|
+
interface Window {
|
|
243
|
+
/** 仅本机 Browser Dev Host 调试工具使用的受限动作入口。 */
|
|
244
|
+
__HB_SDK_PREVIEW__?: PreviewBrowserActions;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** 单次开发工具请求的取消和总等待期限。 */
|
|
249
|
+
interface DevRequestOptions {
|
|
250
|
+
signal?: AbortSignal;
|
|
251
|
+
/** 默认 5000 毫秒;Runtime 等待默认 30000 毫秒。 */
|
|
252
|
+
timeoutMs?: number;
|
|
253
|
+
}
|
|
254
|
+
/** 连接已运行的开发会话;不隐式启动服务或打开浏览器。 */
|
|
255
|
+
interface ConnectDevSessionOptions extends DevRequestOptions {
|
|
256
|
+
projectRoot?: string;
|
|
257
|
+
port?: number;
|
|
258
|
+
}
|
|
259
|
+
/** 统一开发会话状态,失败历史不依赖 iframe 存活。 */
|
|
260
|
+
interface DevSessionInspection {
|
|
261
|
+
schemaVersion: typeof DEV_DIAGNOSTICS_SCHEMA_VERSION;
|
|
262
|
+
sessionId: string;
|
|
263
|
+
projectRoot: string;
|
|
264
|
+
appUrl: string;
|
|
265
|
+
previewUrl: string;
|
|
266
|
+
browser: Record<string, unknown>;
|
|
267
|
+
playwright: Record<string, unknown>;
|
|
268
|
+
selectors: Record<string, string>;
|
|
269
|
+
targets: DevTarget[];
|
|
270
|
+
primaryTargetId: string | null;
|
|
271
|
+
primaryTarget: DevTarget | null;
|
|
272
|
+
currentInstance: DevInstance | null;
|
|
273
|
+
recentFailure: DevInstance | null;
|
|
274
|
+
/** 按启动尝试的登记顺序排列;状态更新不改变顺序。 */
|
|
275
|
+
instances: DevInstance[];
|
|
276
|
+
epoch: string;
|
|
277
|
+
nextCursor: number;
|
|
278
|
+
timestamp: number;
|
|
279
|
+
stale: boolean;
|
|
280
|
+
uploadSessions: DevUploadSession[];
|
|
281
|
+
}
|
|
282
|
+
/** targetId 选择稳定目标;日志跨实例查询,活资源解析当前实例。与 instanceId 不能同时提供。 */
|
|
283
|
+
interface DevTargetSelection {
|
|
284
|
+
targetId?: string;
|
|
285
|
+
instanceId?: string;
|
|
286
|
+
}
|
|
287
|
+
/** 服务端事实筛选;游标表示接收顺序,不是操作因果证明。 */
|
|
288
|
+
interface DevLogFilters extends DevRequestOptions, DevTargetSelection {
|
|
289
|
+
uploadSessionId?: string;
|
|
290
|
+
callId?: string;
|
|
291
|
+
/** 调用阶段(如 client / host),用于区分同一 callId 的不同事实。 */
|
|
292
|
+
phase?: string;
|
|
293
|
+
/** 仅查询 warn/error 事实,仍由服务端分页。 */
|
|
294
|
+
problems?: boolean;
|
|
295
|
+
source?: 'app' | 'sdk' | 'runtime' | 'host' | 'network';
|
|
296
|
+
level?: 'log' | 'debug' | 'info' | 'warn' | 'error';
|
|
297
|
+
query?: string;
|
|
298
|
+
after?: number;
|
|
299
|
+
limit?: number;
|
|
300
|
+
id?: number;
|
|
301
|
+
since?: number;
|
|
302
|
+
}
|
|
303
|
+
/** 日志增量页;gap 表示指定游标之前已有事实被淘汰。 */
|
|
304
|
+
interface DevLogPage {
|
|
305
|
+
schemaVersion: typeof DEV_DIAGNOSTICS_SCHEMA_VERSION;
|
|
306
|
+
sessionId: string;
|
|
307
|
+
epoch: string;
|
|
308
|
+
items: DevDiagnosticEvent[];
|
|
309
|
+
nextCursor: number;
|
|
310
|
+
hasMore: boolean;
|
|
311
|
+
gap: boolean;
|
|
312
|
+
uploadSessions: DevUploadSession[];
|
|
313
|
+
[key: string]: unknown;
|
|
314
|
+
}
|
|
315
|
+
/** 默认等待主浏览器实例;指定 instanceId 时观察该实例自身的生命周期,支持同时连接的真机。 */
|
|
316
|
+
interface WaitForRuntimeOptions extends DevRequestOptions, DevTargetSelection {
|
|
317
|
+
}
|
|
318
|
+
interface DevResourceOptions extends DevRequestOptions, DevTargetSelection {
|
|
319
|
+
}
|
|
320
|
+
/** 只读资源保留原实例、时间和新鲜度;不自动将敏感值写入日志。 */
|
|
321
|
+
interface DevResources {
|
|
322
|
+
/** 当前实例的宿主呈现;短暂反馈结束后从 logs() 查询历史。 */
|
|
323
|
+
presentation(options?: DevResourceOptions): Promise<DevResourceResult<DevPresentationSnapshot>>;
|
|
324
|
+
storage(options?: DevResourceOptions): Promise<DevResourceResult>;
|
|
325
|
+
sandbox(options?: DevResourceOptions & {
|
|
326
|
+
path?: string;
|
|
327
|
+
}): Promise<DevResourceResult>;
|
|
328
|
+
/** 只读二进制前缀;最多 16 KiB,base64 保留原始字节。 */
|
|
329
|
+
sandboxRead(options: DevResourceOptions & {
|
|
330
|
+
path: string;
|
|
331
|
+
maxBytes?: number;
|
|
332
|
+
}): Promise<DevResourceResult<DevSandboxFile>>;
|
|
333
|
+
/** 网络事件历史;默认主目标,包含 Client/Host 开始与终态,不是实时连接快照。 */
|
|
334
|
+
network(filters?: DevLogFilters): Promise<DevLogPage>;
|
|
335
|
+
/** warn/error 事件历史;默认主目标,可显式按目标或实例查询。 */
|
|
336
|
+
problems(filters?: DevLogFilters): Promise<DevLogPage>;
|
|
337
|
+
}
|
|
338
|
+
/** hb-sdk 特有预览动作;通用定位、点击、输入和滚动直接使用 Playwright。 */
|
|
339
|
+
interface DevPreviewActions {
|
|
340
|
+
connect(options?: DevRequestOptions & {
|
|
341
|
+
emulateFocus?: boolean;
|
|
342
|
+
}): Promise<ConnectedPreview>;
|
|
343
|
+
open(options?: DevRequestOptions): Promise<Record<string, unknown>>;
|
|
344
|
+
select(options: DevRequestOptions & {
|
|
345
|
+
preset?: string;
|
|
346
|
+
orientation?: PreviewOrientation;
|
|
347
|
+
}): Promise<Record<string, unknown>>;
|
|
348
|
+
reload(options?: DevRequestOptions): Promise<Record<string, unknown>>;
|
|
349
|
+
/** 返回 PNG base64 与像素元数据;不调整默认 CSS 截图行为。 */
|
|
350
|
+
capture(options?: DevRequestOptions & {
|
|
351
|
+
scope?: PreviewScope;
|
|
352
|
+
scale?: PreviewScale;
|
|
353
|
+
}): Promise<Record<string, unknown>>;
|
|
354
|
+
}
|
|
355
|
+
/** 已绑定项目与 dev 服务身份的轻量对象;连接成功不代表 Runtime 或业务页面就绪。 */
|
|
356
|
+
interface DevSession {
|
|
357
|
+
readonly id: string;
|
|
358
|
+
readonly projectRoot: string;
|
|
359
|
+
readonly port: number;
|
|
360
|
+
inspect(options?: DevRequestOptions): Promise<DevSessionInspection>;
|
|
361
|
+
logs(filters?: DevLogFilters): Promise<DevLogPage>;
|
|
362
|
+
waitForRuntime(options?: WaitForRuntimeOptions): Promise<DevInstance>;
|
|
363
|
+
readonly preview: DevPreviewActions;
|
|
364
|
+
readonly resources: DevResources;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* 连接当前项目的开发会话,复用与 CLI 相同的发现、身份核验和 HTTP 查询。
|
|
368
|
+
*
|
|
369
|
+
* @remarks 此步及 inspect/logs 不加载 Playwright 或改变焦点。只有 preview.connect 才按需准备控制库。
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* import { connectDevSession } from '@heybox/hb-sdk/dev';
|
|
373
|
+
* const dev = await connectDevSession();
|
|
374
|
+
* const preview = await dev.preview.connect();
|
|
375
|
+
* try {
|
|
376
|
+
* await dev.waitForRuntime({ timeoutMs: 30_000 });
|
|
377
|
+
* await preview.app.getByRole('button', { name: '环境信息' }).click();
|
|
378
|
+
* }
|
|
379
|
+
* finally { await preview.disconnect(); }
|
|
380
|
+
* ```
|
|
381
|
+
* @since 0.9.6
|
|
382
|
+
*/
|
|
383
|
+
declare function connectDevSession(options?: ConnectDevSessionOptions): Promise<DevSession>;
|
|
384
|
+
|
|
385
|
+
export { connectDevSession };
|
|
386
|
+
export type { ConnectDevSessionOptions, ConnectedPreview, DevDiagnosticError, DevDiagnosticEvent, DevHostInteraction, DevInstance, DevInteractionState, DevLogFilters, DevLogPage, DevPresentationSnapshot, DevPreviewActions, DevRequestOptions, DevResourceCapabilities, DevResourceOptions, DevResourceResult, DevResources, DevSandboxFile, DevSession, DevSessionInspection, DevTarget, DevTargetMetadata, DevTargetSelection, DevUploadSession, PreviewOrientation, PreviewScale, PreviewScope, PreviewSession, WaitForRuntimeOptions };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Portions Copyright (c) Microsoft Corporation.
|
|
190
|
+
Portions Copyright 2017 Google Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|