@heybox/hb-sdk 0.6.6-alpha.2 → 0.6.6-alpha.3
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/README.md +42 -7
- package/dist/cli-chunks/build-De-QADpA.cjs +137 -0
- package/dist/cli-chunks/context-CvZs9ZBf.cjs +311 -0
- package/dist/cli-chunks/{create-CxjB3oSo.cjs → create-B5gGBaSV.cjs} +1 -1
- package/dist/cli-chunks/{dev-Km0or0yY.cjs → dev-BcCWCeac.cjs} +11 -42
- package/dist/cli-chunks/{doctor-baVOqNSh.cjs → doctor-BhBM4cWH.cjs} +1 -1
- package/dist/cli-chunks/{context-CM46YbPT.cjs → index-BQm5XmMC.cjs} +19 -308
- package/dist/cli-chunks/{index-DCsEAuca.cjs → index-DyUo67lf.cjs} +3 -3
- package/dist/cli-chunks/{index-ByDy5HXi.cjs → index-QAkYgxPI.cjs} +32 -16
- package/dist/cli-chunks/{login-fNe0eDs_.cjs → login-BNLH13Zd.cjs} +2 -2
- package/dist/cli-chunks/project-vite-VcJMyz1l.cjs +45 -0
- package/dist/cli-chunks/remote-BE53wntR.cjs +1504 -0
- package/dist/cli-chunks/{remote-BRIlRrCG.cjs → runtime-gate-B2MQf1vc.cjs} +7 -1501
- package/dist/cli-chunks/{session-CTcelATz.cjs → session-YJ8xNESM.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/mock-host/main.js +149 -3
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/templates/vue3-vite-ts/README.md.ejs +2 -2
- package/dist/templates/vue3-vite-ts/package.json.ejs +1 -1
- package/dist/vite.cjs.js +50 -3
- package/dist/vite.esm.js +50 -3
- package/package.json +1 -1
- package/skill/SKILL.md +19 -14
- package/skill/references/api-protocol.md +3 -2
- package/skill/references/api-root.md +49 -10
- package/skill/references/cli.md +33 -1
- package/skill/references/recipes.md +53 -0
- package/skill/references/safety-boundaries.md +1 -1
- package/skill/scripts/sync-references.mjs +23 -1
- package/skill/skill.json +4 -4
- package/types/index.d.ts +1 -1
- package/types/modules/share/types.d.ts +11 -0
- package/types/protocol.d.ts +1 -1
- package/types/vite/html-policy.d.ts +4 -1
- package/types/vite/index.d.ts +10 -1
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
## Package metadata
|
|
20
20
|
|
|
21
21
|
- Package: `@heybox/hb-sdk`
|
|
22
|
-
- Version at generation time: `0.6.6-alpha.
|
|
22
|
+
- Version at generation time: `0.6.6-alpha.3`
|
|
23
23
|
- Public root export: `@heybox/hb-sdk`
|
|
24
24
|
- Protocol export: `@heybox/hb-sdk/protocol`
|
|
25
25
|
- Vite plugin export: `@heybox/hb-sdk/vite`
|
|
@@ -99,6 +99,7 @@ export type {
|
|
|
99
99
|
MiniProgramScreenshotRect,
|
|
100
100
|
MiniProgramShareChannel,
|
|
101
101
|
MiniProgramShareModule,
|
|
102
|
+
MiniProgramSharePostOptions,
|
|
102
103
|
MiniProgramShowShareMenuOptions,
|
|
103
104
|
ScreenshotPayload,
|
|
104
105
|
ScreenshotResult,
|
|
@@ -229,7 +230,18 @@ interface MiniappManifestResolvedConfig {
|
|
|
229
230
|
build: {
|
|
230
231
|
outDir: string;
|
|
231
232
|
};
|
|
232
|
-
server:
|
|
233
|
+
server: {
|
|
234
|
+
host?: string | boolean;
|
|
235
|
+
port?: number;
|
|
236
|
+
hmr?:
|
|
237
|
+
| boolean
|
|
238
|
+
| {
|
|
239
|
+
clientPort?: number;
|
|
240
|
+
host?: string;
|
|
241
|
+
port?: number;
|
|
242
|
+
protocol?: 'ws' | 'wss';
|
|
243
|
+
};
|
|
244
|
+
};
|
|
233
245
|
}
|
|
234
246
|
|
|
235
247
|
const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
|
|
@@ -238,6 +250,8 @@ const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
|
|
|
238
250
|
export function miniappManifest(): MiniappManifestPlugin {
|
|
239
251
|
let root = process.cwd();
|
|
240
252
|
let outDir = 'dist';
|
|
253
|
+
let command: 'build' | 'serve' = 'build';
|
|
254
|
+
let hmrWebSocketUrl: string | undefined;
|
|
241
255
|
/** 构建链路中更早的失败原因;closeBundle 不得再用产物校验覆盖它。 */
|
|
242
256
|
let priorBuildError: Error | undefined;
|
|
243
257
|
|
|
@@ -255,6 +269,8 @@ export function miniappManifest(): MiniappManifestPlugin {
|
|
|
255
269
|
configResolved(resolved) {
|
|
256
270
|
root = resolved.root;
|
|
257
271
|
outDir = resolved.build.outDir;
|
|
272
|
+
command = resolved.command;
|
|
273
|
+
hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
|
|
258
274
|
},
|
|
259
275
|
buildEnd(error) {
|
|
260
276
|
if (error) {
|
|
@@ -262,7 +278,7 @@ export function miniappManifest(): MiniappManifestPlugin {
|
|
|
262
278
|
}
|
|
263
279
|
},
|
|
264
280
|
transformIndexHtml(html) {
|
|
265
|
-
return enforceMiniappHtmlPolicy(html);
|
|
281
|
+
return enforceMiniappHtmlPolicy(html, command === 'serve' ? { hmrWebSocketUrl } : undefined);
|
|
266
282
|
},
|
|
267
283
|
async closeBundle() {
|
|
268
284
|
// Rollup 在 buildStart/transform 失败后仍会调用 closeBundle。
|
|
@@ -325,11 +341,22 @@ function resolveSdkVersion() {
|
|
|
325
341
|
}
|
|
326
342
|
return packageJson.version;
|
|
327
343
|
}
|
|
344
|
+
|
|
345
|
+
function resolveHmrWebSocketUrl(resolved: MiniappManifestResolvedConfig) {
|
|
346
|
+
const hmr = resolved.server.hmr;
|
|
347
|
+
if (hmr === false) return undefined;
|
|
348
|
+
const options = typeof hmr === 'object' ? hmr : {};
|
|
349
|
+
const protocol = options.protocol ?? 'ws';
|
|
350
|
+
const configuredHost = options.host ?? resolved.server.host;
|
|
351
|
+
const host = typeof configuredHost === 'string' && configuredHost !== '0.0.0.0' ? configuredHost : '127.0.0.1';
|
|
352
|
+
const port = options.clientPort ?? options.port ?? resolved.server.port;
|
|
353
|
+
return `${protocol}://${host}${port ? `:${port}` : ''}`;
|
|
354
|
+
}
|
|
328
355
|
```
|
|
329
356
|
|
|
330
357
|
## Manifest
|
|
331
358
|
|
|
332
|
-
`@heybox/hb-sdk/vite` 提供构建时插件 `miniappManifest()
|
|
359
|
+
`@heybox/hb-sdk/vite` 提供构建时插件 `miniappManifest()`。项目通过 `hb-sdk build` 完成生产构建后,会在固定的 `dist/` 中写入 `manifest.json`:
|
|
333
360
|
|
|
334
361
|
```json
|
|
335
362
|
{
|
|
@@ -338,7 +365,7 @@ function resolveSdkVersion() {
|
|
|
338
365
|
}
|
|
339
366
|
```
|
|
340
367
|
|
|
341
|
-
`version` 来自小程序项目自身的 `package.json.version`,`sdkVersion` 来自当前安装 SDK 的构建版本且不能由业务覆盖。`hb-sdk create`
|
|
368
|
+
`version` 来自小程序项目自身的 `package.json.version`,`sdkVersion` 来自当前安装 SDK 的构建版本且不能由业务覆盖。`hb-sdk build` 要求项目显式注册这个插件;`hb-sdk create` 生成的模板默认已注册,现有 Vite 项目可以在 `vite.config.ts` 中手动接入:
|
|
342
369
|
|
|
343
370
|
```ts
|
|
344
371
|
import { miniappManifest } from '@heybox/hb-sdk/vite';
|
|
@@ -354,15 +381,15 @@ export default defineConfig({
|
|
|
354
381
|
|
|
355
382
|
工坊小程序构建产物只能在兼容的小黑盒 Runtime 中启动。普通浏览器直接打开时不会执行标准业务脚本,并会提示在小黑盒 APP 内打开。项目应使用标准 Vite module 入口。
|
|
356
383
|
|
|
357
|
-
插件只接受单页应用:输出目录只能存在入口 `index.html`。build
|
|
384
|
+
插件只接受单页应用:输出目录只能存在入口 `index.html`。build 会用结构化 HTML parser 校验入口,并把平台 CSP 插入 `<head>` 首位;已有 CSP 会原样保留,两份策略按浏览器交集生效。正式策略禁止 `fetch`、XHR、WebSocket、EventSource、Beacon、Worker、iframe、表单和对象加载等浏览器原生出口;业务网络请求应使用 `network.request()`。dev 使用相同策略,只额外放行当前 Vite 的精确 HMR WebSocket 地址。
|
|
358
385
|
|
|
359
|
-
meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML
|
|
386
|
+
meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev`、`hb-sdk build` 和手动 Vite build 都不请求远端最低 SDK 版本;构建仍会把当前 `sdkVersion` 写入 Manifest,`hb-sdk remote deploy` 仍校验 Manifest 结构并经过服务端 precheck / submit-audit 策略。
|
|
360
387
|
|
|
361
388
|
失败与警告语义:
|
|
362
389
|
|
|
363
|
-
- 读取 `package.json` 失败或 JSON
|
|
364
|
-
- `package.json.version`
|
|
365
|
-
- `package.json.version` 仍是模板默认值 `0.0.0
|
|
390
|
+
- 读取 `package.json` 失败或 JSON 解析失败:build 直接失败,并输出具体原因。
|
|
391
|
+
- `package.json.version` 不是非空字符串:build 直接失败。
|
|
392
|
+
- `package.json.version` 仍是模板默认值 `0.0.0`:build 直接失败,必须改成实际 SemVer。
|
|
366
393
|
- 版本号不是严格 SemVer、包含 build metadata 或缺少 `sdkVersion`:build/deploy 直接失败。
|
|
367
394
|
|
|
368
395
|
`manifest.json` 不部署到 CDN,只交给发布流水线读取后上送后台;Host 通过后台 API 间接读取版本信息。第一阶段只支持 Vite 项目,非 Vite 打包器未来通过其他子入口扩展。
|
|
@@ -519,6 +546,10 @@ await share.showShareMenu({
|
|
|
519
546
|
title: '我的小程序页面',
|
|
520
547
|
desc: '来自黑盒小程序的分享',
|
|
521
548
|
imageUrl: 'https://imgheybox.max-c.com/demo.png',
|
|
549
|
+
post: {
|
|
550
|
+
topicIds: [235709],
|
|
551
|
+
topics: ['无畏契约战绩'],
|
|
552
|
+
},
|
|
522
553
|
});
|
|
523
554
|
```
|
|
524
555
|
|
|
@@ -526,15 +557,23 @@ await share.showShareMenu({
|
|
|
526
557
|
`/tools/common_share?user_miniprogram_id=...` 分享落地页。只有确实要分享外部
|
|
527
558
|
HTTP(S) 页面时才显式传 `url`。
|
|
528
559
|
|
|
560
|
+
`post` 用于给“转发到社区”预置可编辑的分区与话题。`topicIds` 接受正整数或非空字符串并按首次出现顺序去重;`topics` 只传话题内容,不要包含首尾 `#`。`showShareMenu()` 只支持一个默认分区,并且不能与 `channel` 同时使用;本地 Mock、App Dev Shell 和开发 Runtime 会直接拒绝这类错误,生产 Runtime 会过滤非法项、只取第一个分区并继续普通分享。`post: null` 等同于不配置。
|
|
561
|
+
|
|
529
562
|
截图分享:
|
|
530
563
|
|
|
531
564
|
```ts
|
|
532
565
|
await share.screenshot({
|
|
533
566
|
delay: 100,
|
|
534
567
|
saveToAlbum: true,
|
|
568
|
+
post: {
|
|
569
|
+
topicIds: [235709, 66739],
|
|
570
|
+
topics: ['无畏契约战绩'],
|
|
571
|
+
},
|
|
535
572
|
});
|
|
536
573
|
```
|
|
537
574
|
|
|
575
|
+
截图分享支持多个预置分区;分区与话题仍由用户在客户端发帖页中确认和修改,SDK 不会直接发布内容。
|
|
576
|
+
|
|
538
577
|
### 基础 UI
|
|
539
578
|
|
|
540
579
|
```ts
|
package/skill/references/cli.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
- packages/hb-sdk/src/cli/index.ts
|
|
9
9
|
- packages/hb-sdk/src/cli/commands/create.ts
|
|
10
10
|
- packages/hb-sdk/src/cli/commands/dev.ts
|
|
11
|
+
- packages/hb-sdk/src/cli/commands/build.ts
|
|
11
12
|
- packages/hb-sdk/src/cli/commands/login.ts
|
|
12
13
|
- apps/docs/hb-sdk/guide/cli.md
|
|
13
14
|
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
- [Command surface](#command-surface)
|
|
18
19
|
- [Create a mini-program template](#create-a-mini-program-template)
|
|
19
20
|
- [Local debugging](#local-debugging)
|
|
21
|
+
- [Production build](#production-build)
|
|
20
22
|
- [Deploy and publish](#deploy-and-publish)
|
|
21
23
|
- [Developer account scope](#developer-account-scope)
|
|
22
24
|
- [Remote management commands](#remote-management-commands)
|
|
@@ -34,6 +36,7 @@ Use the bundled `hb-sdk` CLI to create a workshop mini-program, open the local d
|
|
|
34
36
|
```text
|
|
35
37
|
hb-sdk create <project-name>
|
|
36
38
|
hb-sdk dev [--port <port>] [--mock-port <port>] [--no-open]
|
|
39
|
+
hb-sdk build [--env <name>] [--verbose]
|
|
37
40
|
hb-sdk login
|
|
38
41
|
hb-sdk login status
|
|
39
42
|
hb-sdk login clear
|
|
@@ -139,6 +142,35 @@ Dev Context 中调整的 `network.request` 权限不会修改线上配置,但
|
|
|
139
142
|
|
|
140
143
|
Use `hb-sdk dev` to open the local debugging page. The "在 Mac 版 APP 中启动" button opens the page in the Mac App; the "Mobile App" QR code opens it in the phone App after a LAN interface is selected. These entries remain available without CLI login or project binding, but managed capabilities are denied by default. The phone and computer must be on the same LAN. If an embedded browser cannot open the App, use the system browser.
|
|
141
144
|
|
|
145
|
+
## Production build
|
|
146
|
+
|
|
147
|
+
## 生产构建
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
hb-sdk build [--env <name>] [--verbose]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`hb-sdk build` 直接使用项目安装的 Vite,先清理再生成固定的 `dist/`,并校验小程序入口、Manifest 和可上传产物。它不执行类型检查,不要求 CLI 登录或绑定小程序,也不访问远端服务。项目必须在 `vite.config.ts` 中显式注册 `miniappManifest()`。
|
|
154
|
+
|
|
155
|
+
推荐由项目的 `scripts.build` 保留类型检查:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"scripts": {
|
|
160
|
+
"build": "vue-tsc --noEmit && hb-sdk build"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
构建命令只支持 `--env` 和 `--verbose`。已有项目继续使用 `vite build` 仍然兼容,不会自动迁移。
|
|
166
|
+
|
|
167
|
+
Agent rules:
|
|
168
|
+
|
|
169
|
+
- Use `hb-sdk build [--env <name>] [--verbose]` as the recommended production build entry.
|
|
170
|
+
- Require explicit `miniappManifest()` configuration and keep typechecking in the project's `scripts.build`.
|
|
171
|
+
- Do not claim `hb-sdk build` needs login, binding, or network access, and do not invent unsupported build flags.
|
|
172
|
+
- Existing `vite build` projects remain compatible and must not be auto-migrated.
|
|
173
|
+
|
|
142
174
|
## Deploy and publish
|
|
143
175
|
|
|
144
176
|
## 部署发布
|
|
@@ -158,7 +190,7 @@ hb-sdk remote bind mp_xxxxxxxx
|
|
|
158
190
|
hb-sdk remote deploy --release-note "修复登录状态展示"
|
|
159
191
|
```
|
|
160
192
|
|
|
161
|
-
|
|
193
|
+
这条命令会完成检查、执行项目的 `scripts.build`、上传和提交审核,因此项目定义的类型检查仍会执行。默认在审核通过后等待手动发布;普通低风险版本可以追加 `--auto-publish`。完整命令见 `hb-sdk remote --help`,提交要求见[小程序工坊上架规则](https://docs.xiaoheihe.cn/hb_sdk/guide/mini-program-publishing-rules)。
|
|
162
194
|
|
|
163
195
|
Before publishing, `hb-sdk remote deploy` verifies that the bound mini-program belongs to the current developer account. If it does not, the command stops and asks the user to switch accounts.
|
|
164
196
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- apps/docs/hb-sdk/guide/lifecycle.md
|
|
10
10
|
- apps/docs/hb-sdk/guide/error-handling.md
|
|
11
11
|
- apps/docs/hb-sdk/recipes/login-gate.md
|
|
12
|
+
- apps/docs/hb-sdk/recipes/community-share.md
|
|
12
13
|
- apps/docs/hb-sdk/recipes/custom-instance.md
|
|
13
14
|
|
|
14
15
|
## Contents
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
- [Lifecycle events](#lifecycle-events)
|
|
19
20
|
- [Error handling](#error-handling)
|
|
20
21
|
- [Login gate recipe](#login-gate-recipe)
|
|
22
|
+
- [Community share recipe](#community-share-recipe)
|
|
21
23
|
- [Custom instance recipe](#custom-instance-recipe)
|
|
22
24
|
## Quick start
|
|
23
25
|
|
|
@@ -355,6 +357,57 @@ async function handleSubmit() {
|
|
|
355
357
|
- 用户主动点击登录、提交、收藏等动作时,再调用 `login`。
|
|
356
358
|
- 登录态变化后,父容器应派发 `authChange`,页面可据此刷新用户相关 UI。
|
|
357
359
|
|
|
360
|
+
## Community share recipe
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
# 社区分享预置
|
|
364
|
+
|
|
365
|
+
`share.showShareMenu()` 和 `share.screenshot()` 可以给客户端的“转发到社区”流程预置分区与话题。预置内容进入发帖页后仍可由用户修改,SDK 不会直接发布内容。
|
|
366
|
+
|
|
367
|
+
## 普通分享
|
|
368
|
+
|
|
369
|
+
普通分享只支持一个默认分区,并且配置 `post` 时不要同时指定站外 `channel`。
|
|
370
|
+
|
|
371
|
+
```ts
|
|
372
|
+
import { ready, share } from '@heybox/hb-sdk'
|
|
373
|
+
|
|
374
|
+
await ready()
|
|
375
|
+
|
|
376
|
+
await share.showShareMenu({
|
|
377
|
+
title: '本局战绩',
|
|
378
|
+
desc: '查看我的完整战绩',
|
|
379
|
+
post: {
|
|
380
|
+
topicIds: [235709],
|
|
381
|
+
topics: ['无畏契约战绩'],
|
|
382
|
+
},
|
|
383
|
+
})
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## 截图分享
|
|
387
|
+
|
|
388
|
+
截图分享可以预置多个分区,客户端发帖页负责最终选择与确认。
|
|
389
|
+
|
|
390
|
+
```ts
|
|
391
|
+
await share.screenshot({
|
|
392
|
+
delay: 100,
|
|
393
|
+
saveToAlbum: true,
|
|
394
|
+
post: {
|
|
395
|
+
topicIds: [235709, 66739],
|
|
396
|
+
topics: ['无畏契约战绩'],
|
|
397
|
+
},
|
|
398
|
+
})
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## 参数边界
|
|
402
|
+
|
|
403
|
+
- `topicIds` 接受正整数或非空字符串,按首次出现顺序去重。
|
|
404
|
+
- `topics` 只传话题内容,不要添加首尾 `#`;字符串会先 trim 再去重。
|
|
405
|
+
- `post: null` 等同于不配置社区发帖预置,`post: {}` 是无效配置。
|
|
406
|
+
- 本地 Mock、App Dev Shell 和开发 Runtime 会对无效配置返回 `INVALID_PARAMS`。
|
|
407
|
+
- 生产 Runtime 会过滤无效项;普通分享只使用第一个有效分区,配置冲突时保留站外 `channel`,不会阻断原分享流程。
|
|
408
|
+
|
|
409
|
+
调用方不能通过该 API 传客户端协议、回调、自定义按钮或发布指令。
|
|
410
|
+
|
|
358
411
|
## Custom instance recipe
|
|
359
412
|
|
|
360
413
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
- Do not instruct mini-program code to read, extract, forward, store, or depend on token, cookie, phone number, or private credentials.
|
|
25
25
|
- Negative safety statements that explain the SDK does not expose token/cookie/private credentials are correct and should be preserved.
|
|
26
|
-
- Do not use raw share protocol fields, JS callbacks, activity reporting, post publishing, custom buttons, or upload-only flows.
|
|
26
|
+
- Do not use raw share protocol fields, JS callbacks, activity reporting, direct post publishing, custom buttons, or upload-only flows. Public `share.*({ post })` options only preset an editable client post flow.
|
|
27
27
|
- Do not use storage delete, clear, info listing, V2, or global Heybox client storage access.
|
|
28
28
|
- Do not pass host-only protocol fields through `network.request`.
|
|
29
29
|
- Do not build raw `postMessage` bridge flows in iframe business code.
|
|
@@ -207,6 +207,7 @@ const authGuide = frontmatterless(read('apps/docs/hb-sdk/guide/auth.md'));
|
|
|
207
207
|
const lifecycleGuide = frontmatterless(read('apps/docs/hb-sdk/guide/lifecycle.md'));
|
|
208
208
|
const errorGuide = frontmatterless(read('apps/docs/hb-sdk/guide/error-handling.md'));
|
|
209
209
|
const loginGate = frontmatterless(read('apps/docs/hb-sdk/recipes/login-gate.md'));
|
|
210
|
+
const communityShare = frontmatterless(read('apps/docs/hb-sdk/recipes/community-share.md'));
|
|
210
211
|
const customInstance = frontmatterless(read('apps/docs/hb-sdk/recipes/custom-instance.md'));
|
|
211
212
|
const referenceHome = frontmatterless(read('apps/docs/hb-sdk/reference/index.md'));
|
|
212
213
|
const quickStartSection = extractSection(readme, '## 快速开始');
|
|
@@ -220,6 +221,7 @@ const manifestSection = extractSection(readme, '## Manifest');
|
|
|
220
221
|
const cliSummarySection = extractSection(readme, '## CLI');
|
|
221
222
|
const cliCreateSection = extractSection(cliGuide, '## 创建工坊小程序');
|
|
222
223
|
const cliDevSection = extractSection(cliGuide, '## 推荐调试流程');
|
|
224
|
+
const cliBuildSection = extractSection(cliGuide, '## 生产构建');
|
|
223
225
|
const cliDeploySection = extractSection(cliGuide, '## 部署发布');
|
|
224
226
|
const cliRemoteSection = extractSection(cliGuide, '## 远端管理命令');
|
|
225
227
|
const cliLoginSection = extractSection(cliGuide, '## CLI 登录态');
|
|
@@ -227,6 +229,7 @@ const cliDoctorSection = extractSection(cliGuide, '## Agent Skill doctor');
|
|
|
227
229
|
const cliUpdateSection = extractSection(cliGuide, '## 版本提醒');
|
|
228
230
|
const cliCommandSurface = `hb-sdk create <project-name>
|
|
229
231
|
hb-sdk dev [--port <port>] [--mock-port <port>] [--no-open]
|
|
232
|
+
hb-sdk build [--env <name>] [--verbose]
|
|
230
233
|
hb-sdk login
|
|
231
234
|
hb-sdk login status
|
|
232
235
|
hb-sdk login clear
|
|
@@ -344,6 +347,7 @@ files.set('cli.md', `${header('CLI reference', [
|
|
|
344
347
|
'packages/hb-sdk/src/cli/index.ts',
|
|
345
348
|
'packages/hb-sdk/src/cli/commands/create.ts',
|
|
346
349
|
'packages/hb-sdk/src/cli/commands/dev.ts',
|
|
350
|
+
'packages/hb-sdk/src/cli/commands/build.ts',
|
|
347
351
|
'packages/hb-sdk/src/cli/commands/login.ts',
|
|
348
352
|
'apps/docs/hb-sdk/guide/cli.md',
|
|
349
353
|
])}${contents([
|
|
@@ -351,6 +355,7 @@ files.set('cli.md', `${header('CLI reference', [
|
|
|
351
355
|
['Command surface', 'command-surface'],
|
|
352
356
|
['Create a mini-program template', 'create-a-mini-program-template'],
|
|
353
357
|
['Local debugging', 'local-debugging'],
|
|
358
|
+
['Production build', 'production-build'],
|
|
354
359
|
['Deploy and publish', 'deploy-and-publish'],
|
|
355
360
|
['Developer account scope', 'developer-account-scope'],
|
|
356
361
|
['Remote management commands', 'remote-management-commands'],
|
|
@@ -386,6 +391,17 @@ ${cliDevSection}
|
|
|
386
391
|
|
|
387
392
|
Use \`hb-sdk dev\` to open the local debugging page. The "在 Mac 版 APP 中启动" button opens the page in the Mac App; the "Mobile App" QR code opens it in the phone App after a LAN interface is selected. These entries remain available without CLI login or project binding, but managed capabilities are denied by default. The phone and computer must be on the same LAN. If an embedded browser cannot open the App, use the system browser.
|
|
388
393
|
|
|
394
|
+
## Production build
|
|
395
|
+
|
|
396
|
+
${cliBuildSection}
|
|
397
|
+
|
|
398
|
+
Agent rules:
|
|
399
|
+
|
|
400
|
+
- Use \`hb-sdk build [--env <name>] [--verbose]\` as the recommended production build entry.
|
|
401
|
+
- Require explicit \`miniappManifest()\` configuration and keep typechecking in the project's \`scripts.build\`.
|
|
402
|
+
- Do not claim \`hb-sdk build\` needs login, binding, or network access, and do not invent unsupported build flags.
|
|
403
|
+
- Existing \`vite build\` projects remain compatible and must not be auto-migrated.
|
|
404
|
+
|
|
389
405
|
## Deploy and publish
|
|
390
406
|
|
|
391
407
|
${rewriteBundledCliLinks(cliDeploySection)}
|
|
@@ -462,6 +478,7 @@ files.set('recipes.md', `${header('Recipes', [
|
|
|
462
478
|
'apps/docs/hb-sdk/guide/lifecycle.md',
|
|
463
479
|
'apps/docs/hb-sdk/guide/error-handling.md',
|
|
464
480
|
'apps/docs/hb-sdk/recipes/login-gate.md',
|
|
481
|
+
'apps/docs/hb-sdk/recipes/community-share.md',
|
|
465
482
|
'apps/docs/hb-sdk/recipes/custom-instance.md',
|
|
466
483
|
])}${contents([
|
|
467
484
|
['Quick start', 'quick-start'],
|
|
@@ -469,6 +486,7 @@ files.set('recipes.md', `${header('Recipes', [
|
|
|
469
486
|
['Lifecycle events', 'lifecycle-events'],
|
|
470
487
|
['Error handling', 'error-handling'],
|
|
471
488
|
['Login gate recipe', 'login-gate-recipe'],
|
|
489
|
+
['Community share recipe', 'community-share-recipe'],
|
|
472
490
|
['Custom instance recipe', 'custom-instance-recipe'],
|
|
473
491
|
])}## Quick start
|
|
474
492
|
|
|
@@ -490,6 +508,10 @@ ${rewriteBundledRecipeLinks(errorGuide)}
|
|
|
490
508
|
|
|
491
509
|
${rewriteBundledRecipeLinks(loginGate)}
|
|
492
510
|
|
|
511
|
+
## Community share recipe
|
|
512
|
+
|
|
513
|
+
${rewriteBundledRecipeLinks(communityShare)}
|
|
514
|
+
|
|
493
515
|
## Custom instance recipe
|
|
494
516
|
|
|
495
517
|
${rewriteBundledRecipeLinks(customInstance)}
|
|
@@ -506,7 +528,7 @@ ${capabilityBoundaries}
|
|
|
506
528
|
|
|
507
529
|
- Do not instruct mini-program code to read, extract, forward, store, or depend on token, cookie, phone number, or private credentials.
|
|
508
530
|
- Negative safety statements that explain the SDK does not expose token/cookie/private credentials are correct and should be preserved.
|
|
509
|
-
- Do not use raw share protocol fields, JS callbacks, activity reporting, post publishing, custom buttons, or upload-only flows.
|
|
531
|
+
- Do not use raw share protocol fields, JS callbacks, activity reporting, direct post publishing, custom buttons, or upload-only flows. Public \`share.*({ post })\` options only preset an editable client post flow.
|
|
510
532
|
- Do not use storage delete, clear, info listing, V2, or global Heybox client storage access.
|
|
511
533
|
- Do not pass host-only protocol fields through \`network.request\`.
|
|
512
534
|
- Do not build raw \`postMessage\` bridge flows in iframe business code.
|
package/skill/skill.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hb-sdk",
|
|
3
|
-
"skillVersion": "0.6.6-alpha.
|
|
3
|
+
"skillVersion": "0.6.6-alpha.3+skill.7940a3d57a8b",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.6.6-alpha.
|
|
7
|
-
"compatibility": "0.6.6-alpha.
|
|
6
|
+
"version": "0.6.6-alpha.3",
|
|
7
|
+
"compatibility": "0.6.6-alpha.3"
|
|
8
8
|
},
|
|
9
9
|
"source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
|
|
10
|
-
"integrity": "sha256-
|
|
10
|
+
"integrity": "sha256-7940a3d57a8b57fb3045378c068cc875bea2def32d926fcef19e0accad67901b"
|
|
11
11
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type { MiniProgramEventHandler, MiniProgramEventName, MiniProgramEventPay
|
|
|
4
4
|
export type { LoginPayload, LoginResult, MiniProgramAuthModule } from './modules/auth';
|
|
5
5
|
export type { DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, LeaderboardEntry, LeaderboardOrder, MiniProgramCloudLeaderboardModule, MiniProgramCloudModule, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult, } from './modules/cloud';
|
|
6
6
|
export type { BasePlatformAccountInfo, CurrentUserAvatarConfig, CurrentUserAvatarDecoration, CurrentUserBbsInfo, CurrentUserDetail, CurrentUserLevelInfo, CurrentUserMedal, CurrentUserProfile, EpicPlatformAccountInfo, GetCurrentUserDetailPayload, GetCurrentUserDetailResult, GetCurrentUserProfilePayload, GetCurrentUserProfileResult, GetPlatformAccountInfoPayload, GetPlatformAccountInfoResult, GetPlatformAccountOverviewPayload, GetPlatformAccountOverviewResult, GetSteamGameListOptions, GetSteamGameListPayload, GetSteamGameListResult, GetUserInfoPayload, GetUserInfoResult, MiniProgramUserInfo, MiniProgramUserInfoResult, MiniProgramUserModule, MobilePlatformAccountInfo, PcHardwareAccountInfo, PlatformAccountInfoMap, PlatformAccountOverview, PlatformAccountResult, PlatformAccountType, PlatformStatItem, PsnPlatformAccountInfo, SteamGameListData, SteamGameListItem, SteamGameListSort, SteamGamePrice, SteamPlatformAccountInfo, SwitchPlatformAccountInfo, UserScopedResult, XboxPlatformAccountInfo, } from './modules/user';
|
|
7
|
-
export type { MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramShareModule, MiniProgramShowShareMenuOptions, ScreenshotPayload, ScreenshotResult, ShowShareMenuPayload, ShowShareMenuResult, } from './modules/share';
|
|
7
|
+
export type { MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramShareModule, MiniProgramSharePostOptions, MiniProgramShowShareMenuOptions, ScreenshotPayload, ScreenshotResult, ShowShareMenuPayload, ShowShareMenuResult, } from './modules/share';
|
|
8
8
|
export type { GetWindowInfoPayload, GetWindowInfoResult, MiniProgramNavigationBarForegroundStyle, MiniProgramSafeArea, MiniProgramSetNavigationBarStyleOptions, MiniProgramViewportModule, MiniProgramWindowInfoResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, } from './modules/viewport';
|
|
9
9
|
export type { GetStoragePayload, GetStorageResult, MiniProgramStorageModule, SetStoragePayload, } from './modules/storage';
|
|
10
10
|
export type { MiniProgramNetworkHeaders, MiniProgramNetworkModule, MiniProgramNetworkParams, MiniProgramNetworkRequestConfig, MiniProgramNetworkRequestMethod, MiniProgramNetworkResponse, MiniProgramNetworkValidateStatus, NetworkRequestPayload, NetworkResponsePayload, } from './modules/network';
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
* 不同宿主环境可支持的渠道集合可能不同;未传 `channel` 时由客户端自行展示默认分享面板。
|
|
6
6
|
*/
|
|
7
7
|
export type MiniProgramShareChannel = 'wechatSession' | 'wechatTimeline' | 'qqFriend' | 'qzone' | 'weibo';
|
|
8
|
+
/** 社区发帖预置配置。 */
|
|
9
|
+
export interface MiniProgramSharePostOptions {
|
|
10
|
+
/** 默认发布分区 ID;普通分享只使用第一项,截图分享支持多项。 */
|
|
11
|
+
topicIds?: (string | number)[];
|
|
12
|
+
/** 预置话题内容,不包含首尾 `#`。 */
|
|
13
|
+
topics?: string[];
|
|
14
|
+
}
|
|
8
15
|
/**
|
|
9
16
|
* 展示基础分享面板的配置。
|
|
10
17
|
*
|
|
@@ -22,6 +29,8 @@ export interface MiniProgramShowShareMenuOptions {
|
|
|
22
29
|
imageUrl?: string;
|
|
23
30
|
/** 指定分享渠道;不传则由客户端展示默认分享面板。 */
|
|
24
31
|
channel?: MiniProgramShareChannel;
|
|
32
|
+
/** 转发到社区时使用的分区与话题预置;`null` 等同于不配置。 */
|
|
33
|
+
post?: MiniProgramSharePostOptions | null;
|
|
25
34
|
}
|
|
26
35
|
/**
|
|
27
36
|
* 截图区域。
|
|
@@ -52,4 +61,6 @@ export interface MiniProgramScreenshotOptions {
|
|
|
52
61
|
delay?: number;
|
|
53
62
|
/** 是否展示保存到相册能力。 */
|
|
54
63
|
saveToAlbum?: boolean;
|
|
64
|
+
/** 转发到社区时使用的分区与话题预置;`null` 等同于不配置。 */
|
|
65
|
+
post?: MiniProgramSharePostOptions | null;
|
|
55
66
|
}
|
package/types/protocol.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderb
|
|
|
10
10
|
export type { GetCurrentUserDetailPayload, GetCurrentUserDetailResult, GetCurrentUserProfilePayload, GetCurrentUserProfileResult, GetPlatformAccountInfoPayload, GetPlatformAccountInfoResult, GetPlatformAccountOverviewPayload, GetPlatformAccountOverviewResult, GetSteamGameListOptions, GetSteamGameListPayload, GetSteamGameListResult, GetUserInfoPayload, GetUserInfoResult, MiniProgramUserInfo, MiniProgramUserInfoResult, SteamGameListData, SteamGameListItem, SteamGameListSort, SteamGamePrice, } from './modules/user';
|
|
11
11
|
export type { ScreenshotPayload, ScreenshotResult } from './modules/share/screenshot';
|
|
12
12
|
export type { ShowShareMenuPayload, ShowShareMenuResult } from './modules/share/show-share-menu';
|
|
13
|
-
export type { MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramShowShareMenuOptions, } from './modules/share';
|
|
13
|
+
export type { MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramSharePostOptions, MiniProgramShowShareMenuOptions, } from './modules/share';
|
|
14
14
|
export type { GetStoragePayload, GetStorageResult, SetStoragePayload } from './modules/storage';
|
|
15
15
|
export type { GetWindowInfoPayload, GetWindowInfoResult, MiniProgramNavigationBarForegroundStyle, MiniProgramSafeArea, MiniProgramSetNavigationBarStyleOptions, MiniProgramWindowInfoResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, } from './modules/viewport';
|
|
16
16
|
export type { MiniProgramNetworkHeaders, MiniProgramNetworkParams, MiniProgramNetworkRequestConfig, MiniProgramNetworkRequestMethod, MiniProgramNetworkResponse, MiniProgramNetworkValidateStatus, NetworkRequestPayload, NetworkResponsePayload, } from './modules/network';
|
package/types/vite/index.d.ts
CHANGED
|
@@ -20,7 +20,16 @@ interface MiniappManifestResolvedConfig {
|
|
|
20
20
|
build: {
|
|
21
21
|
outDir: string;
|
|
22
22
|
};
|
|
23
|
-
server:
|
|
23
|
+
server: {
|
|
24
|
+
host?: string | boolean;
|
|
25
|
+
port?: number;
|
|
26
|
+
hmr?: boolean | {
|
|
27
|
+
clientPort?: number;
|
|
28
|
+
host?: string;
|
|
29
|
+
port?: number;
|
|
30
|
+
protocol?: 'ws' | 'wss';
|
|
31
|
+
};
|
|
32
|
+
};
|
|
24
33
|
}
|
|
25
34
|
export declare function miniappManifest(): MiniappManifestPlugin;
|
|
26
35
|
export {};
|