@heybox/hb-sdk 0.7.4-alpha.4 → 0.7.4-alpha.6

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 (43) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +19 -1
  3. package/dist/cli-chunks/{build-BqGFRLe-.cjs → build-DF74IHGR.cjs} +2 -2
  4. package/dist/cli-chunks/{context-DTr3hRTv.cjs → context-QemmshdY.cjs} +26 -1
  5. package/dist/cli-chunks/{create-OkiiiH4I.cjs → create-Ch9m8w8M.cjs} +1 -1
  6. package/dist/cli-chunks/dev-D2DwLxXW.cjs +15682 -0
  7. package/dist/cli-chunks/{doctor-BO0vkDny.cjs → doctor-B9xJ2j20.cjs} +1 -1
  8. package/dist/cli-chunks/{index-CZuvk1Rg.cjs → index-Cv36miWx.cjs} +83 -83
  9. package/dist/cli-chunks/{index-CyEqCbeu.cjs → index-DxQgKWRT.cjs} +31 -32
  10. package/dist/cli-chunks/index.esm-DZQrllrR.cjs +5212 -0
  11. package/dist/cli-chunks/{login-CuAGltGs.cjs → login-DEKhX1Vf.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-BUY9DgYo.cjs → project-vite-D_NNB_Ib.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-tPMcxgpi.cjs → remote-B_Bn4v81.cjs} +4 -4
  14. package/dist/cli-chunks/{session-BUjFX2U2.cjs → session-C2zY7XHn.cjs} +2 -1
  15. package/dist/cli.cjs +1 -1
  16. package/dist/devtools/browser-dev-host/index.html +128 -151
  17. package/dist/devtools/browser-dev-host/main.js +2591 -345
  18. package/dist/index.cjs.js +1187 -3
  19. package/dist/index.esm.js +1187 -3
  20. package/dist/protocol.cjs.js +3 -0
  21. package/dist/protocol.esm.js +3 -1
  22. package/dist/vite.cjs.js +1 -1
  23. package/dist/vite.esm.js +1 -1
  24. package/package.json +16 -8
  25. package/skill/SKILL.md +7 -6
  26. package/skill/references/api-protocol.md +6 -3
  27. package/skill/references/api-root.md +6 -2
  28. package/skill/references/cli.md +16 -20
  29. package/skill/references/examples.md +2 -2
  30. package/skill/references/recipes.md +37 -0
  31. package/skill/references/safety-boundaries.md +1 -1
  32. package/skill/references/smoke-evaluation.md +1 -1
  33. package/skill/scripts/sync-references.mjs +6 -6
  34. package/skill/skill.json +4 -4
  35. package/types/index.d.ts +1 -1
  36. package/types/modules/share/copy-link.d.ts +16 -0
  37. package/types/modules/share/extra.d.ts +3 -0
  38. package/types/modules/share/index.d.ts +8 -2
  39. package/types/modules/share/types.d.ts +11 -0
  40. package/types/protocol/capabilities.d.ts +1 -1
  41. package/types/protocol/dev-session.d.ts +13 -0
  42. package/types/protocol.d.ts +2 -2
  43. package/dist/cli-chunks/dev-j7W9R7ew.cjs +0 -2769
@@ -3,9 +3,9 @@
3
3
  var promises = require('node:readline/promises');
4
4
  var node_crypto = require('node:crypto');
5
5
  var node_http = require('node:http');
6
- var session = require('./session-BUjFX2U2.cjs');
6
+ var session = require('./session-C2zY7XHn.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
- var index = require('./index-CyEqCbeu.cjs');
8
+ var index = require('./index-DxQgKWRT.cjs');
9
9
  require('node:path');
10
10
  require('fs');
11
11
  require('constants');
@@ -5,7 +5,7 @@ var fs$1 = require('node:fs/promises');
5
5
  var node_module = require('node:module');
6
6
  var path = require('node:path');
7
7
  var node_url = require('node:url');
8
- var index = require('./index-CyEqCbeu.cjs');
8
+ var index = require('./index-DxQgKWRT.cjs');
9
9
 
10
10
  function findProjectRoot(startDir) {
11
11
  let current = path.resolve(startDir);
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var promises = require('node:readline/promises');
4
- var index = require('./index-CyEqCbeu.cjs');
5
- var session = require('./session-BUjFX2U2.cjs');
4
+ var index = require('./index-DxQgKWRT.cjs');
5
+ var session = require('./session-C2zY7XHn.cjs');
6
6
  var childProcess = require('node:child_process');
7
7
  var fs = require('node:fs');
8
8
  var fs$1 = require('node:fs/promises');
@@ -10,7 +10,7 @@ var path = require('node:path');
10
10
  var runtimePermissionEnv = require('./runtime-permission-env-D-8_jPG3.cjs');
11
11
  var runtimeGate = require('./runtime-gate-CtV7rWyX.cjs');
12
12
  var node_crypto = require('node:crypto');
13
- var context = require('./context-DTr3hRTv.cjs');
13
+ var context = require('./context-QemmshdY.cjs');
14
14
  require('node:module');
15
15
  require('path');
16
16
  require('os');
@@ -271,7 +271,7 @@ function createDefaultCosClient(uploadToken, COS) {
271
271
  };
272
272
  }
273
273
  async function loadCosConstructor() {
274
- const cosModule = await Promise.resolve().then(function () { return require('./index-CZuvk1Rg.cjs'); }).then(function (n) { return n.index; });
274
+ const cosModule = await Promise.resolve().then(function () { return require('./index-Cv36miWx.cjs'); }).then(function (n) { return n.index; });
275
275
  return cosModule.default;
276
276
  }
277
277
  function formatSize(bytes) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CyEqCbeu.cjs');
3
+ var index = require('./index-DxQgKWRT.cjs');
4
4
  var node_crypto = require('node:crypto');
5
5
  var path = require('node:path');
6
6
  var require$$0$2 = require('fs');
@@ -3327,6 +3327,7 @@ exports.createHeyboxAuthSession = createHeyboxAuthSession;
3327
3327
  exports.createHeyboxOpenPlatformRequestContext = createHeyboxOpenPlatformRequestContext;
3328
3328
  exports.getAuthCacheFilePath = getAuthCacheFilePath;
3329
3329
  exports.readHeyboxApiEnvelope = readHeyboxApiEnvelope;
3330
+ exports.readHeyboxAuthSession = readHeyboxAuthSession;
3330
3331
  exports.readRedactedHeyboxAuthStatus = readRedactedHeyboxAuthStatus;
3331
3332
  exports.requireHeyboxAuthSession = requireHeyboxAuthSession;
3332
3333
  exports.resolveHeyboxApiBaseUrl = resolveHeyboxApiBaseUrl;
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./cli-chunks/index-CyEqCbeu.cjs');
3
+ var index = require('./cli-chunks/index-DxQgKWRT.cjs');
4
4
  require('node:module');
5
5
  require('node:fs');
6
6
  require('node:fs/promises');
@@ -9,6 +9,10 @@
9
9
  box-sizing: border-box;
10
10
  }
11
11
 
12
+ [hidden] {
13
+ display: none !important;
14
+ }
15
+
12
16
  body {
13
17
  margin: 0;
14
18
  height: 100vh;
@@ -32,6 +36,14 @@
32
36
  min-height: 0;
33
37
  }
34
38
 
39
+ html[data-screenshot-chrome-hidden='true'] .layout {
40
+ grid-template-columns: minmax(0, 1fr);
41
+ }
42
+
43
+ html[data-screenshot-chrome-hidden='true'] .panel {
44
+ display: none;
45
+ }
46
+
35
47
  .panel {
36
48
  display: flex;
37
49
  flex-direction: column;
@@ -51,19 +63,6 @@
51
63
  line-height: 1.25;
52
64
  }
53
65
 
54
- .panel p {
55
- margin: 0;
56
- color: #64748b;
57
- line-height: 1.5;
58
- }
59
-
60
- .status {
61
- display: grid;
62
- grid-template-columns: repeat(2, minmax(0, 1fr));
63
- gap: 8px;
64
- }
65
-
66
- .status div,
67
66
  .block {
68
67
  min-width: 0;
69
68
  border: 1px solid #d7dee8;
@@ -72,14 +71,12 @@
72
71
  background: #f8fafc;
73
72
  }
74
73
 
75
- .status span,
76
74
  .block span {
77
75
  display: block;
78
76
  color: #64748b;
79
77
  font-size: 12px;
80
78
  }
81
79
 
82
- .status strong,
83
80
  .block strong {
84
81
  display: block;
85
82
  margin-top: 6px;
@@ -87,29 +84,7 @@
87
84
  word-break: break-word;
88
85
  }
89
86
 
90
- .actions {
91
- display: flex;
92
- flex-wrap: wrap;
93
- gap: 8px;
94
- }
95
-
96
- .actions button {
97
- min-height: 36px;
98
- border: 1px solid #cad5e2;
99
- border-radius: 6px;
100
- padding: 0 12px;
101
- color: #1f2933;
102
- background: #fff;
103
- cursor: pointer;
104
- }
105
-
106
- .actions button.primary {
107
- border-color: #2563eb;
108
- color: #fff;
109
- background: #2563eb;
110
- }
111
-
112
- .mac-app-status {
87
+ .status {
113
88
  display: grid;
114
89
  gap: 8px;
115
90
  margin-top: 10px;
@@ -118,49 +93,47 @@
118
93
  line-height: 1.5;
119
94
  }
120
95
 
121
- .mac-app-status[hidden] {
122
- display: none;
123
- }
124
-
125
- .debug-page-url {
96
+ .account,
97
+ .mini-program {
126
98
  display: grid;
127
- grid-template-columns: minmax(0, 1fr) 32px;
99
+ grid-template-columns: 40px minmax(0, 1fr);
128
100
  align-items: center;
129
- gap: 8px;
101
+ gap: 10px;
102
+ margin-top: 10px;
130
103
  }
131
104
 
132
- .debug-page-url code {
133
- min-width: 0;
134
- overflow-wrap: anywhere;
135
- word-break: break-word;
105
+ .account:has(img[hidden]),
106
+ .mini-program:has(img[hidden]) {
107
+ grid-template-columns: minmax(0, 1fr);
108
+ }
109
+
110
+ .account__avatar,
111
+ .mini-program__icon {
112
+ width: 40px;
113
+ height: 40px;
136
114
  border: 1px solid #d7dee8;
137
- border-radius: 6px;
138
- padding: 7px 8px;
139
- color: #1f2933;
115
+ border-radius: 50%;
116
+ object-fit: cover;
140
117
  background: #fff;
141
118
  }
142
119
 
143
- .copy-icon-button {
144
- display: inline-grid;
145
- place-items: center;
146
- width: 32px;
147
- height: 32px;
148
- border: 1px solid #cad5e2;
149
- border-radius: 6px;
150
- padding: 0;
151
- color: #475569;
152
- background: #fff;
153
- cursor: pointer;
120
+ .mini-program__icon {
121
+ border-radius: 8px;
154
122
  }
155
123
 
156
- .copy-icon-button:hover {
157
- border-color: #2563eb;
158
- color: #2563eb;
124
+ .account__meta,
125
+ .mini-program__meta {
126
+ min-width: 0;
159
127
  }
160
128
 
161
- .copy-icon-button svg {
162
- width: 16px;
163
- height: 16px;
129
+ .account__meta strong,
130
+ .mini-program__meta strong {
131
+ margin-top: 0;
132
+ }
133
+
134
+ .account__meta span,
135
+ .mini-program__meta span {
136
+ margin-top: 2px;
164
137
  }
165
138
 
166
139
  .copy-status {
@@ -191,23 +164,6 @@
191
164
  background: #fff;
192
165
  }
193
166
 
194
- .release-diagnostics {
195
- display: grid;
196
- gap: 6px;
197
- margin: 10px 0 0;
198
- padding: 0;
199
- list-style: none;
200
- }
201
-
202
- .release-diagnostics li {
203
- border-left: 3px solid #d97706;
204
- padding: 7px 8px;
205
- color: #92400e;
206
- background: #fffbeb;
207
- font-size: 12px;
208
- line-height: 1.5;
209
- }
210
-
211
167
  .mobile-qr {
212
168
  display: grid;
213
169
  justify-items: center;
@@ -328,6 +284,73 @@
328
284
  color: #991b1b;
329
285
  }
330
286
 
287
+ .placeholder {
288
+ display: grid;
289
+ place-items: center;
290
+ height: 100%;
291
+ padding: 24px;
292
+ color: #64748b;
293
+ text-align: center;
294
+ }
295
+
296
+ .hb-sdk-auth-dialog {
297
+ position: fixed;
298
+ inset: 0;
299
+ z-index: 40;
300
+ display: grid;
301
+ place-items: center;
302
+ padding: 24px;
303
+ background: rgba(15, 23, 42, 0.45);
304
+ }
305
+
306
+ .hb-sdk-auth-dialog__panel {
307
+ width: min(360px, 100%);
308
+ border-radius: 12px;
309
+ padding: 20px;
310
+ background: #fff;
311
+ box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
312
+ }
313
+
314
+ .hb-sdk-auth-dialog__panel h2 {
315
+ margin: 0 0 8px;
316
+ font-size: 18px;
317
+ }
318
+
319
+ .hb-sdk-auth-dialog__app,
320
+ .hb-sdk-auth-dialog__profile {
321
+ margin: 0 0 12px;
322
+ color: #475569;
323
+ line-height: 1.5;
324
+ }
325
+
326
+ .hb-sdk-auth-dialog__scopes {
327
+ margin: 0 0 16px;
328
+ padding-left: 18px;
329
+ color: #1f2933;
330
+ line-height: 1.6;
331
+ }
332
+
333
+ .hb-sdk-auth-dialog__actions {
334
+ display: flex;
335
+ justify-content: flex-end;
336
+ gap: 8px;
337
+ }
338
+
339
+ .hb-sdk-auth-dialog__actions button {
340
+ min-height: 36px;
341
+ border: 1px solid #cad5e2;
342
+ border-radius: 6px;
343
+ padding: 0 12px;
344
+ background: #fff;
345
+ cursor: pointer;
346
+ }
347
+
348
+ .hb-sdk-auth-dialog__actions .primary {
349
+ border-color: #2563eb;
350
+ color: #fff;
351
+ background: #2563eb;
352
+ }
353
+
331
354
  @media (max-width: 860px) {
332
355
  body {
333
356
  height: auto;
@@ -357,71 +380,30 @@
357
380
  <body>
358
381
  <div class="layout">
359
382
  <aside class="panel">
360
- <div>
361
- <h1>HB SDK Browser Dev Host</h1>
362
- <p>本地浏览器宿主通过 iframe 加载小程序,使用真实 @heybox/hb-sdk bridge。</p>
363
- </div>
364
-
365
- <section class="status">
366
- <div>
367
- <span>Bridge</span>
368
- <strong id="bridge-status">waiting</strong>
369
- </div>
370
- <div>
371
- <span>User</span>
372
- <strong id="user-status">未登录</strong>
373
- </div>
374
- </section>
383
+ <h1>HB SDK Browser Dev Host</h1>
375
384
 
376
385
  <section class="block">
377
- <span>Mini URL</span>
378
- <strong id="mini-url"></strong>
379
- </section>
380
-
381
- <section class="block">
382
- <span>Dev Context</span>
383
- <strong id="dev-context-status"></strong>
384
- <label class="field" style="margin-top: 10px">
385
- <span>network.request</span>
386
- <select id="network-permission-select">
387
- <option value="disabled">拒绝</option>
388
- <option value="enabled">允许</option>
389
- </select>
390
- </label>
391
- <div class="actions" style="margin-top: 10px">
392
- <button id="reset-permissions-button" type="button">恢复初始权限</button>
386
+ <span>开发者</span>
387
+ <div class="account">
388
+ <img class="account__avatar" id="developer-avatar" alt="" hidden />
389
+ <div class="account__meta">
390
+ <strong id="developer-name"></strong>
391
+ <span id="developer-hint"></span>
392
+ </div>
393
393
  </div>
394
- <div class="mac-app-status" id="permission-persistence-status"></div>
395
- <ul class="release-diagnostics" id="release-diagnostics"></ul>
396
- </section>
397
-
398
- <section class="csp-violations" id="csp-violations" hidden>
399
- <strong>网络或资源请求已被 CSP 阻止</strong>
400
394
  </section>
401
395
 
402
396
  <section class="block">
403
- <span>Mac App</span>
404
- <div class="actions" style="margin-top: 10px">
405
- <button class="primary" id="mac-app-button" type="button">在 Mac 版 APP 中启动</button>
406
- </div>
407
- <div class="mac-app-status" id="mac-app-status" hidden>
408
- <div>如果没有唤起 Mac 版 APP,请在系统浏览器中打开当前调试页面后重试。若 APP 已打开但加载失败,请升级到支持本地小程序调试的 Mac App 版本。</div>
409
- <div class="debug-page-url">
410
- <code id="debug-page-url"></code>
411
- <button
412
- class="copy-icon-button"
413
- id="copy-debug-page-url-button"
414
- type="button"
415
- aria-label="复制调试页面地址"
416
- title="复制调试页面地址"
417
- >
418
- <svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2">
419
- <rect x="9" y="9" width="13" height="13" rx="2" />
420
- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
421
- </svg>
422
- </button>
397
+ <span>小程序</span>
398
+ <div class="mini-program" id="mini-program-summary" hidden>
399
+ <img class="mini-program__icon" id="mini-program-icon" alt="" hidden />
400
+ <div class="mini-program__meta">
401
+ <strong id="mini-program-name"></strong>
402
+ <span id="mini-program-id"></span>
423
403
  </div>
424
- <div class="copy-status" id="debug-page-copy-status"></div>
404
+ </div>
405
+ <div class="status" id="mini-program-empty" hidden>
406
+ 当前项目未绑定小程序,请运行 hb-sdk remote create 或 hb-sdk remote bind &lt;mini-program-id&gt;。
425
407
  </div>
426
408
  </section>
427
409
 
@@ -437,13 +419,8 @@
437
419
  </div>
438
420
  </section>
439
421
 
440
- <section class="block">
441
- <div class="actions" style="margin-top: 10px">
442
- <button class="primary" id="login-button" type="button">登录</button>
443
- <button id="logout-button" type="button">登出</button>
444
- <button id="show-button" type="button">show</button>
445
- <button id="hide-button" type="button">hide</button>
446
- </div>
422
+ <section class="csp-violations" id="csp-violations" hidden>
423
+ <strong>网络或资源请求已被 CSP 阻止</strong>
447
424
  </section>
448
425
 
449
426
  <section class="block">