@heybox/hb-sdk 0.2.0-alpha.1 → 0.3.1

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.
@@ -6,69 +6,36 @@
6
6
 
7
7
  - packages/hb-sdk/package.json
8
8
  - packages/hb-sdk/src/index.ts
9
+ - packages/hb-sdk/src/vite/index.ts
9
10
  - packages/hb-sdk/README.md
10
11
 
11
12
  ## Contents
12
13
 
13
14
  - [Package metadata](#package-metadata)
14
15
  - [Public root entrypoint](#public-root-entrypoint)
16
+ - [Vite plugin export](#vite-plugin-export)
15
17
  - [App-facing concepts](#app-facing-concepts)
16
18
  - [Public modules](#public-modules)
17
19
  ## Package metadata
18
20
 
19
21
  - Package: `@heybox/hb-sdk`
20
- - Version at generation time: `0.2.0-alpha.1`
22
+ - Version at generation time: `0.3.1`
21
23
  - Public root export: `@heybox/hb-sdk`
22
24
  - Protocol export: `@heybox/hb-sdk/protocol`
25
+ - Vite plugin export: `@heybox/hb-sdk/vite`
23
26
 
24
27
  ## Public root entrypoint
25
28
 
26
29
  ```ts
27
30
  export { createMiniProgramSDK, MiniProgramSDK } from './core/sdk';
28
31
  export { HbMiniProgramSDKError, HbMiniProgramNetworkError } from './core/errors';
29
- export type { MiniProgramRequester, MiniProgramSDKOptions } from './core/client';
32
+ export type { MiniProgramSDKOptions } from './core/client';
30
33
  export { ready, on, off, auth, user, share, viewport, storage, network } from './core/singleton';
31
- export {
32
- MINI_PROGRAM_BRIDGE_NONCE_PARAM,
33
- MINI_PROGRAM_MESSAGE_NAMESPACE,
34
- MINI_PROGRAM_MESSAGE_VERSION,
35
- SDK_HANDSHAKE_METHOD,
36
- } from './protocol/constants';
37
- export { isMiniProgramBridgeMessage } from './protocol/guards';
38
34
  export type {
39
- MiniProgramBridgeError,
40
- MiniProgramBridgeMessage,
41
- MiniProgramBridgeMessageType,
42
35
  MiniProgramEventHandler,
43
36
  MiniProgramEventName,
44
37
  MiniProgramEventPayloadMap,
45
38
  } from './protocol/types';
46
- export {
47
- AUTH_LOGIN_METHOD,
48
- NETWORK_REQUEST_METHOD,
49
- SHARE_SCREENSHOT_METHOD,
50
- SHARE_SHOW_SHARE_MENU_METHOD,
51
- STORAGE_GET_STORAGE_METHOD,
52
- STORAGE_SET_STORAGE_METHOD,
53
- USER_GET_INFO_METHOD,
54
- VIEWPORT_GET_WINDOW_INFO_METHOD,
55
- } from './protocol/capabilities';
56
- export type {
57
- MiniProgramAuthMethod,
58
- MiniProgramBridgeMethod,
59
- MiniProgramCapabilityDefinition,
60
- MiniProgramCapabilityModule,
61
- MiniProgramCapabilityPayload,
62
- MiniProgramCapabilityPayloadMap,
63
- MiniProgramCapabilityResult,
64
- MiniProgramCapabilityResultMap,
65
- MiniProgramCapabilityRisk,
66
- MiniProgramNetworkMethod,
67
- MiniProgramShareMethod,
68
- MiniProgramStorageMethod,
69
- MiniProgramUserMethod,
70
- MiniProgramViewportMethod,
71
- } from './protocol/capabilities';
72
39
  export type { LoginPayload, LoginResult, MiniProgramAuthModule } from './modules/auth';
73
40
  export type {
74
41
  GetUserInfoPayload,
@@ -130,6 +97,94 @@ const hbSDK = {
130
97
  export default hbSDK;
131
98
  ```
132
99
 
100
+ ## Vite plugin export
101
+
102
+ Use `@heybox/hb-sdk/vite` only in `vite.config.ts`. Do not import it from iframe mini-program business code.
103
+
104
+ ```ts
105
+ import { mkdirSync, writeFileSync } from 'node:fs';
106
+ import path from 'node:path';
107
+ import {
108
+ getMiniappManifestBuildWarning,
109
+ renderMiniappManifest,
110
+ } from '../miniapp-manifest/schema';
111
+ import { readMiniappVersionFromPackageJson } from '../miniapp-manifest/node';
112
+
113
+ type MiniappManifestPlugin = {
114
+ name: string;
115
+ apply: 'build';
116
+ configResolved: (resolved: MiniappManifestResolvedConfig) => void;
117
+ writeBundle: (this: MiniappManifestPluginContext) => void;
118
+ };
119
+
120
+ interface MiniappManifestPluginContext {
121
+ warn: (message: string) => void;
122
+ }
123
+
124
+ interface MiniappManifestResolvedConfig {
125
+ root: string;
126
+ build: {
127
+ outDir: string;
128
+ };
129
+ }
130
+
131
+ export function miniappManifest(): MiniappManifestPlugin {
132
+ let root = process.cwd();
133
+ let outDir = 'dist';
134
+
135
+ return {
136
+ name: 'heybox-miniapp-manifest',
137
+ apply: 'build',
138
+ configResolved(resolved) {
139
+ root = resolved.root;
140
+ outDir = resolved.build.outDir;
141
+ },
142
+ writeBundle() {
143
+ const version = readMiniappVersionFromPackageJson(root);
144
+ const warning = getMiniappManifestBuildWarning(version);
145
+
146
+ if (warning) {
147
+ this.warn(warning);
148
+ }
149
+
150
+ const manifestPath = path.resolve(root, outDir, 'manifest.json');
151
+ mkdirSync(path.dirname(manifestPath), { recursive: true });
152
+ writeFileSync(manifestPath, renderMiniappManifest({ version }));
153
+ },
154
+ };
155
+ }
156
+ ```
157
+
158
+ ## Manifest
159
+
160
+ `@heybox/hb-sdk/vite` 提供构建时插件 `miniappManifest()`。Vite 项目完成 `vite build` 后,会在输出目录写入 `manifest.json`:
161
+
162
+ ```json
163
+ {
164
+ "version": "1.2.3"
165
+ }
166
+ ```
167
+
168
+ `version` 来自小程序项目自身的 `package.json.version`。`hb-sdk create` 生成的模板默认已注册插件;现有 Vite 项目可以在 `vite.config.ts` 中手动接入:
169
+
170
+ ```ts
171
+ import { miniappManifest } from '@heybox/hb-sdk/vite';
172
+ import { defineConfig } from 'vite';
173
+
174
+ export default defineConfig({
175
+ plugins: [miniappManifest()],
176
+ });
177
+ ```
178
+
179
+ 失败与警告语义:
180
+
181
+ - 读取 `package.json` 失败或 JSON 解析失败:`vite build` 直接失败,并输出具体原因。
182
+ - `package.json.version` 不是非空字符串:`vite build` 直接失败。
183
+ - `package.json.version` 仍是模板默认值 `0.0.0`:`vite build` 输出 warning 并写入 manifest;`hb-sdk deploy` 会拒绝发布,必须改成实际 `x.y.z` 版本。
184
+ - 版本号不满足极简 semver 形态 `x.y.z`:只输出 Rollup/Vite warning,仍会写入 manifest。
185
+
186
+ `manifest.json` 不部署到 CDN,只交给发布流水线读取后上送后台;Host 通过后台 API 间接读取版本信息。第一阶段只支持 Vite 项目,非 Vite 打包器未来通过其他子入口扩展。
187
+
133
188
  ## App-facing concepts
134
189
 
135
190
  ## 快速开始
@@ -37,6 +37,7 @@ The CLI, templates, and mock host are owned by `@heybox/hb-sdk`. Do not create a
37
37
  ```ts
38
38
  import { Command, CommanderError, InvalidArgumentError } from 'commander';
39
39
  import { runCreateCommand as defaultRunCreateCommand } from './commands/create';
40
+ import { runDeployCommand as defaultRunDeployCommand } from './commands/deploy';
40
41
  import { runDevCommand as defaultRunDevCommand } from './commands/dev';
41
42
  import { runDoctorCommand as defaultRunDoctorCommand } from './commands/doctor';
42
43
  import {
@@ -54,6 +55,7 @@ export interface CliCommandHandlers {
54
55
  printLoginStatus: typeof defaultPrintLoginStatus;
55
56
  printUpdateReminder: typeof defaultPrintUpdateReminder;
56
57
  runCreateCommand: typeof defaultRunCreateCommand;
58
+ runDeployCommand: typeof defaultRunDeployCommand;
57
59
  runDevCommand: typeof defaultRunDevCommand;
58
60
  runDoctorCommand: typeof defaultRunDoctorCommand;
59
61
  }
@@ -90,6 +92,7 @@ export function createCliProgram(overrides: Partial<CliCommandHandlers> = {}) {
90
92
  printLoginStatus: defaultPrintLoginStatus,
91
93
  printUpdateReminder: defaultPrintUpdateReminder,
92
94
  runCreateCommand: defaultRunCreateCommand,
95
+ runDeployCommand: defaultRunDeployCommand,
93
96
  runDevCommand: defaultRunDevCommand,
94
97
  runDoctorCommand: defaultRunDoctorCommand,
95
98
  ...overrides,
@@ -126,6 +129,16 @@ export function createCliProgram(overrides: Partial<CliCommandHandlers> = {}) {
126
129
  }, handlers.printUpdateReminder),
127
130
  );
128
131
 
132
+ program
133
+ .command('deploy')
134
+ .description('构建并发布当前小程序到 Heybox 后台')
135
+ .option('--skip-build', '跳过 build,直接读 dist 目录上传并发布')
136
+ .action(
137
+ withUpdateReminder(async (options) => {
138
+ await handlers.runDeployCommand({ skipBuild: Boolean(options.skipBuild) });
139
+ }, handlers.printUpdateReminder),
140
+ );
141
+
129
142
  program
130
143
  .command('doctor')
131
144
  .description('诊断 hb-sdk 本地环境和 Agent Skill 版本')
@@ -298,7 +311,7 @@ Agent rules:
298
311
 
299
312
  ## 版本提醒
300
313
 
301
- `hb-sdk` CLI 会在命令成功执行后检查 npm registry 上 `@heybox/hb-sdk` 的 `latest` 版本。检查结果会缓存 24 小时;检查失败会静默跳过;`CI=true` 时会跳过检查,避免污染 CI 日志。本地可通过 `HB_SDK_NO_UPDATE_CHECK=1` 禁用检查。
314
+ `hb-sdk create`、`hb-sdk dev`、`hb-sdk login`、`hb-sdk login status`、`hb-sdk login clear` 会在命令成功执行后检查 npm registry 上 `@heybox/hb-sdk` 的 `latest` 版本。检查结果会缓存 24 小时;检查失败会静默跳过;`CI=true` 时会跳过检查,避免污染 CI 日志。`hb-sdk doctor` 不会附带版本提醒,避免把 skill 诊断输出和升级提示混在一起。本地可通过 `HB_SDK_NO_UPDATE_CHECK=1` 禁用检查。
302
315
 
303
316
  ## Repository validation commands
304
317
 
@@ -308,10 +321,13 @@ Agent rules:
308
321
  pnpm --filter @heybox/hb-sdk run test:unit
309
322
  pnpm --filter @heybox/hb-sdk run build:package
310
323
  pnpm --filter @heybox/hb-sdk run check:boundary
324
+ pnpm --filter @heybox/hb-sdk run check:docs-sync
311
325
  ```
312
326
 
313
327
  `check:boundary` 用于保护 SDK、CLI、mock host 与 runtime 之间的依赖边界。调整 CLI、mock 或协议导出时应一起运行。
314
328
 
329
+ `check:docs-sync` 用于校验 `README`、文档站 llms 镜像、skill references 与公开 `agent-skills` payload 没有漏同步。维护清单见 `packages/hb-sdk/DOC_SYNC_CHECKLIST.md`。
330
+
315
331
  ## Generated template README
316
332
 
317
333
  ````md
@@ -327,12 +343,14 @@ npm run dev
327
343
  npm run typecheck
328
344
  npm run test:unit
329
345
  npm run build
346
+ npm run deploy
330
347
  ```
331
348
 
332
349
  ## 开发模式
333
350
 
334
351
  - `npm run dev`:启动本地 Vite 服务和 `hb-sdk` 内置 mock runtime host,适合本地调试 SDK 能力;调试页内可点击按钮在 Mac 版 APP 中启动同一页面。
335
352
  - `npm run build`:先执行 TypeScript 检查,再构建生产产物。
353
+ - `npm run deploy`:构建并发布当前小程序。发布前需要先把 `package.json` 中的 `heybox.miniProgramId` 改成后台分配的真实小程序 id,并执行过 `npx hb-sdk login`。
336
354
 
337
355
  ## 更多能力
338
356
 
@@ -96,6 +96,17 @@ hb-sdk login status
96
96
  hb-sdk login clear
97
97
  ```
98
98
 
99
+ ### Vite manifest plugin
100
+
101
+ ```ts
102
+ import { miniappManifest } from '@heybox/hb-sdk/vite';
103
+ import { defineConfig } from 'vite';
104
+
105
+ export default defineConfig({
106
+ plugins: [miniappManifest()],
107
+ });
108
+ ```
109
+
99
110
  ## Negative examples
100
111
 
101
112
  - Do not import from internal hb-sdk implementation paths.
@@ -105,3 +116,4 @@ hb-sdk login clear
105
116
  - Do not pass raw internal share/network protocol fields from mini-program code.
106
117
  - Do not treat `hb-sdk login` as iframe SDK authentication state.
107
118
  - Do not create a second mock runtime package when `hb-sdk dev` is the supported local mock workflow.
119
+ - Do not import `@heybox/hb-sdk/vite` from iframe business code or fetch a deployed `manifest.json` directly.
@@ -16,6 +16,7 @@
16
16
  - `network.request()` 的 `validateStatus` 只在 SDK 本地执行,不会被序列化给父容器。
17
17
  - `on()` 返回取消监听函数;组件卸载或页面销毁时应主动取消监听。
18
18
  - 使用 `createMiniProgramSDK()` 创建独立实例后,不再需要时应调用 `destroy()`。
19
+ - 构建产物可以包含 `dist/manifest.json`,业务代码不应自行 fetch 已部署的 manifest;这个文件由发布流水线读取并上送后台。
19
20
 
20
21
  ## Agent rules
21
22
 
@@ -25,4 +26,5 @@
25
26
  - Do not use storage delete, clear, info listing, V2, or global Heybox client storage access.
26
27
  - Do not pass host-only protocol fields through `network.request`.
27
28
  - Do not build raw `postMessage` bridge flows in iframe business code.
29
+ - Do not fetch deployed `dist/manifest.json` from business code; it is a build artifact for the release pipeline, not a CDN runtime asset.
28
30
  - Do not import from internal hb-sdk implementation paths; only use documented package entrypoints.
@@ -2,7 +2,10 @@ import { createHash } from 'node:crypto';
2
2
 
3
3
  export const HB_SDK_SKILL_NAME = 'hb-sdk';
4
4
  export const HB_SDK_PACKAGE_NAME = '@heybox/hb-sdk';
5
- export const HB_SDK_SKILL_SOURCE = 'https://open.xiaoheihe.cn/agent-skills/hb-sdk';
5
+ export const HB_SDK_AGENT_SKILLS_BASE_URL = 'https://open.xiaoheihe.cn/agent-skills';
6
+ export const HB_SDK_SKILL_SOURCE = `${HB_SDK_AGENT_SKILLS_BASE_URL}/${HB_SDK_SKILL_NAME}`;
7
+ export const HB_SDK_SKILL_INDEX_URL = `${HB_SDK_AGENT_SKILLS_BASE_URL}/.well-known/agent-skills/index.json`;
8
+ export const HB_SDK_SKILL_INSTALL_COMMAND = `npx skills add ${HB_SDK_SKILL_SOURCE}`;
6
9
 
7
10
  export function createSkillContentHash(fileEntries) {
8
11
  const hash = createHash('sha256');
@@ -173,6 +173,7 @@ function createCurrentSkillManifest(generatedReferences) {
173
173
  const packageJson = JSON.parse(read('packages/hb-sdk/package.json'));
174
174
  const rootEntry = read('packages/hb-sdk/src/index.ts');
175
175
  const protocolEntry = read('packages/hb-sdk/src/protocol.ts');
176
+ const viteEntry = read('packages/hb-sdk/src/vite/index.ts');
176
177
  const cliEntry = read('packages/hb-sdk/src/cli/index.ts');
177
178
  const cliTemplateReadme = read('packages/hb-sdk/src/cli/templates/vue3-vite-ts/README.md.ejs');
178
179
  const readme = read('packages/hb-sdk/README.md');
@@ -193,6 +194,7 @@ const lifecycleEvents = extractSection(readme, '## 生命周期事件');
193
194
  const standardErrors = extractSection(readme, '## 错误处理');
194
195
  const sdkRuntimeRelation = extractSection(readme, '## SDK 与 Runtime');
195
196
  const capabilityBoundaries = extractSection(readme, '## 能力边界');
197
+ const manifestSection = extractSection(readme, '## Manifest');
196
198
  const cliSummarySection = extractSection(readme, '## CLI');
197
199
  const repositoryDevelopment = extractSection(readme, '## 本仓库开发');
198
200
  const cliCreateSection = extractSection(cliGuide, '## 创建外部小程序模板');
@@ -209,10 +211,12 @@ const files = new Map();
209
211
  files.set('api-root.md', `${header('Root API reference', [
210
212
  'packages/hb-sdk/package.json',
211
213
  'packages/hb-sdk/src/index.ts',
214
+ 'packages/hb-sdk/src/vite/index.ts',
212
215
  'packages/hb-sdk/README.md',
213
216
  ])}${contents([
214
217
  ['Package metadata', 'package-metadata'],
215
218
  ['Public root entrypoint', 'public-root-entrypoint'],
219
+ ['Vite plugin export', 'vite-plugin-export'],
216
220
  ['App-facing concepts', 'app-facing-concepts'],
217
221
  ['Public modules', 'public-modules'],
218
222
  ])}## Package metadata
@@ -221,11 +225,20 @@ files.set('api-root.md', `${header('Root API reference', [
221
225
  - Version at generation time: \`${packageJson.version}\`
222
226
  - Public root export: \`@heybox/hb-sdk\`
223
227
  - Protocol export: \`@heybox/hb-sdk/protocol\`
228
+ - Vite plugin export: \`@heybox/hb-sdk/vite\`
224
229
 
225
230
  ## Public root entrypoint
226
231
 
227
232
  ${fenced('ts', rootEntry)}
228
233
 
234
+ ## Vite plugin export
235
+
236
+ Use \`@heybox/hb-sdk/vite\` only in \`vite.config.ts\`. Do not import it from iframe mini-program business code.
237
+
238
+ ${fenced('ts', viteEntry)}
239
+
240
+ ${manifestSection}
241
+
229
242
  ## App-facing concepts
230
243
 
231
244
  ${quickStartSection}
@@ -404,6 +417,7 @@ ${capabilityBoundaries}
404
417
  - Do not use storage delete, clear, info listing, V2, or global Heybox client storage access.
405
418
  - Do not pass host-only protocol fields through \`network.request\`.
406
419
  - Do not build raw \`postMessage\` bridge flows in iframe business code.
420
+ - Do not fetch deployed \`dist/manifest.json\` from business code; it is a build artifact for the release pipeline, not a CDN runtime asset.
407
421
  - Do not import from internal hb-sdk implementation paths; only use documented package entrypoints.
408
422
  `);
409
423
 
@@ -498,6 +512,15 @@ ${fenced('bash', `hb-sdk login
498
512
  hb-sdk login status
499
513
  hb-sdk login clear`)}
500
514
 
515
+ ### Vite manifest plugin
516
+
517
+ ${fenced('ts', `import { miniappManifest } from '@heybox/hb-sdk/vite';
518
+ import { defineConfig } from 'vite';
519
+
520
+ export default defineConfig({
521
+ plugins: [miniappManifest()],
522
+ });`)}
523
+
501
524
  ## Negative examples
502
525
 
503
526
  - Do not import from internal hb-sdk implementation paths.
@@ -507,6 +530,7 @@ hb-sdk login clear`)}
507
530
  - Do not pass raw internal share/network protocol fields from mini-program code.
508
531
  - Do not treat \`hb-sdk login\` as iframe SDK authentication state.
509
532
  - Do not create a second mock runtime package when \`hb-sdk dev\` is the supported local mock workflow.
533
+ - Do not import \`@heybox/hb-sdk/vite\` from iframe business code or fetch a deployed \`manifest.json\` directly.
510
534
  `);
511
535
 
512
536
  const skillManifest = normalizeSkillManifest(createCurrentSkillManifest(files));
@@ -184,8 +184,10 @@ for (const file of textFiles) {
184
184
  fail(`Removed API guidance found in ${relative}: use auth.login() instead of user.login().`);
185
185
  }
186
186
 
187
- if (new RegExp(`${HB_SDK_PACKAGE_NAME.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\/(?!protocol\\b)[A-Za-z0-9_./-]+`).test(content)) {
188
- fail(`Deep/internal hb-sdk import guidance found in ${relative}. Only @heybox/hb-sdk and @heybox/hb-sdk/protocol are allowed.`);
187
+ if (new RegExp(`${HB_SDK_PACKAGE_NAME.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\/(?!(?:protocol|vite|miniapp-publish)\\b)[A-Za-z0-9_./-]+`).test(content)) {
188
+ fail(
189
+ `Deep/internal hb-sdk import guidance found in ${relative}. Only @heybox/hb-sdk, @heybox/hb-sdk/protocol, @heybox/hb-sdk/vite, and @heybox/hb-sdk/miniapp-publish are allowed.`,
190
+ );
189
191
  }
190
192
 
191
193
  const lines = content.split('\n');
package/skill/skill.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.2.0-alpha.1+skill.66c7559e5e13",
3
+ "skillVersion": "0.3.1+skill.3af1f225a627",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.2.0-alpha.1",
7
- "compatibility": "0.2.0-alpha.1"
6
+ "version": "0.3.1",
7
+ "compatibility": "0.3.1"
8
8
  },
9
9
  "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-66c7559e5e13eaaefc9718b0f643dffd5853c864913e57e5a65ab0c663553797"
10
+ "integrity": "sha256-3af1f225a627e3a1f6f4e01a98cc4e38bc571cb911a0e27cf0919784c6b9014f"
11
11
  }
@@ -1,3 +1,4 @@
1
+ import type { MiniProgramBridgeMethod, MiniProgramCapabilityPayload, MiniProgramCapabilityResult } from '../protocol/capabilities';
1
2
  import type { MiniProgramEventHandler, MiniProgramEventName } from '../protocol/types';
2
3
  /**
3
4
  * 创建 SDK bridge client 的配置项。
@@ -17,22 +18,11 @@ export interface MiniProgramSDKOptions {
17
18
  /** 精准 postMessage 目标 origin;未传时尝试推断,失败则回退为 `*`。 */
18
19
  targetOrigin?: string;
19
20
  }
20
- /**
21
- * 模块 API 发起请求所需的最小能力。
22
- *
23
- * @remarks
24
- * 各公开模块只依赖该最小接口发起 bridge 请求,以保持模块层与底层实现解耦。
25
- */
21
+ type MiniProgramRequesterArgs<Method extends MiniProgramBridgeMethod> = MiniProgramCapabilityPayload<Method> extends void ? [payload?: MiniProgramCapabilityPayload<Method>] : [payload: MiniProgramCapabilityPayload<Method>];
22
+ /** 模块 API 发起请求所需的最小能力。 */
26
23
  export interface MiniProgramRequester {
27
- /**
28
- * 向父容器调用指定开放能力。
29
- *
30
- * @typeParam T 标准化后的返回值类型。
31
- * @param method bridge method 名称。
32
- * @param payload 可序列化请求载荷。
33
- * @returns 由父容器返回的标准化结果。
34
- */
35
- request<T>(method: string, payload?: unknown): Promise<T>;
24
+ /** 向父容器调用指定开放能力。 */
25
+ request<Method extends MiniProgramBridgeMethod>(method: Method, ...args: MiniProgramRequesterArgs<Method>): Promise<MiniProgramCapabilityResult<Method>>;
36
26
  }
37
27
  /** 底层 bridge client,负责握手、请求响应、事件分发与超时清理。 */
38
28
  export declare class MiniProgramBridgeClient implements MiniProgramRequester {
@@ -60,7 +50,7 @@ export declare class MiniProgramBridgeClient implements MiniProgramRequester {
60
50
  /** 移除小程序事件监听。 */
61
51
  off<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): void;
62
52
  /** 调用父容器开放能力。 */
63
- request<T>(method: string, payload?: unknown): Promise<T>;
53
+ request<Method extends MiniProgramBridgeMethod>(method: Method, ...args: MiniProgramRequesterArgs<Method>): Promise<MiniProgramCapabilityResult<Method>>;
64
54
  /** 销毁 SDK 实例,并拒绝尚未完成的请求。 */
65
55
  destroy(): void;
66
56
  private ensureStarted;
@@ -74,3 +64,4 @@ export declare class MiniProgramBridgeClient implements MiniProgramRequester {
74
64
  private clearReadyTimers;
75
65
  private rejectAllPending;
76
66
  }
67
+ export {};
package/types/index.d.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  export { createMiniProgramSDK, MiniProgramSDK } from './core/sdk';
2
2
  export { HbMiniProgramSDKError, HbMiniProgramNetworkError } from './core/errors';
3
- export type { MiniProgramRequester, MiniProgramSDKOptions } from './core/client';
3
+ export type { MiniProgramSDKOptions } from './core/client';
4
4
  export { ready, on, off, auth, user, share, viewport, storage, network } from './core/singleton';
5
- export { MINI_PROGRAM_BRIDGE_NONCE_PARAM, MINI_PROGRAM_MESSAGE_NAMESPACE, MINI_PROGRAM_MESSAGE_VERSION, SDK_HANDSHAKE_METHOD, } from './protocol/constants';
6
- export { isMiniProgramBridgeMessage } from './protocol/guards';
7
- export type { MiniProgramBridgeError, MiniProgramBridgeMessage, MiniProgramBridgeMessageType, MiniProgramEventHandler, MiniProgramEventName, MiniProgramEventPayloadMap, } from './protocol/types';
8
- export { AUTH_LOGIN_METHOD, NETWORK_REQUEST_METHOD, SHARE_SCREENSHOT_METHOD, SHARE_SHOW_SHARE_MENU_METHOD, STORAGE_GET_STORAGE_METHOD, STORAGE_SET_STORAGE_METHOD, USER_GET_INFO_METHOD, VIEWPORT_GET_WINDOW_INFO_METHOD, } from './protocol/capabilities';
9
- export type { MiniProgramAuthMethod, MiniProgramBridgeMethod, MiniProgramCapabilityDefinition, MiniProgramCapabilityModule, MiniProgramCapabilityPayload, MiniProgramCapabilityPayloadMap, MiniProgramCapabilityResult, MiniProgramCapabilityResultMap, MiniProgramCapabilityRisk, MiniProgramNetworkMethod, MiniProgramShareMethod, MiniProgramStorageMethod, MiniProgramUserMethod, MiniProgramViewportMethod, } from './protocol/capabilities';
5
+ export type { MiniProgramEventHandler, MiniProgramEventName, MiniProgramEventPayloadMap, } from './protocol/types';
10
6
  export type { LoginPayload, LoginResult, MiniProgramAuthModule } from './modules/auth';
11
7
  export type { GetUserInfoPayload, GetUserInfoResult, MiniProgramUserInfo, MiniProgramUserInfoResult, MiniProgramUserModule, } from './modules/user';
12
8
  export type { MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramShareModule, MiniProgramShowShareMenuOptions, ScreenshotPayload, ScreenshotResult, ShowShareMenuPayload, ShowShareMenuResult, } from './modules/share';
@@ -0,0 +1,2 @@
1
+ export * from './schema';
2
+ export * from './node';
@@ -0,0 +1 @@
1
+ export declare function readMiniappVersionFromPackageJson(root: string): string;
@@ -0,0 +1,14 @@
1
+ export declare const MINIAPP_TEMPLATE_VERSION = "0.0.0";
2
+ export interface MiniappManifest {
3
+ [key: string]: unknown;
4
+ version: string;
5
+ }
6
+ export interface ParseMiniappManifestResult {
7
+ manifest: MiniappManifest;
8
+ hadBom: boolean;
9
+ }
10
+ export declare function isValidMiniappManifestVersion(version: string): boolean;
11
+ export declare function getMiniappManifestBuildWarning(version: string): string | undefined;
12
+ export declare function renderMiniappManifest(manifest: MiniappManifest): string;
13
+ export declare function parseMiniappManifestJson(raw: string, sourceLabel?: string): ParseMiniappManifestResult;
14
+ export declare function validateMiniappManifestForDeploy(manifest: MiniappManifest): string;
@@ -0,0 +1,23 @@
1
+ export declare const MINIAPP_UPLOAD_SCOPE = "activity";
2
+ export declare const ACTIVITY_UPLOAD_KEY_MAX_LENGTH = 64;
3
+ export declare const PUBLISH_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_miniprogram/publish";
4
+ export { isValidMiniappManifestVersion as isValidVersion } from '../miniapp-manifest/schema';
5
+ export declare function normalizeRelativePath(relativePath: string): string;
6
+ export declare function relativePathContainsNodeModulesSegment(relativePath: string): boolean;
7
+ export declare function getMiniProgramUploadAlias(miniProgramId: string): string;
8
+ export interface MiniappUploadKeyInput {
9
+ miniProgramId: string;
10
+ version: string;
11
+ relativePath: string;
12
+ }
13
+ export declare function getMiniappUploadKey(input: MiniappUploadKeyInput): string;
14
+ export interface UploadPathItem {
15
+ relativePath: string;
16
+ }
17
+ export interface ValidateUploadPathsOptions {
18
+ miniProgramId: string;
19
+ version: string;
20
+ maxLength?: number;
21
+ }
22
+ export declare function validateUploadPaths(items: UploadPathItem[], options: ValidateUploadPathsOptions): string | undefined;
23
+ export declare function shouldUploadDistFile(relativePath: string): boolean;
@@ -0,0 +1,6 @@
1
+ export declare const HB_SDK_PACKAGE_NAME = "@heybox/hb-sdk";
2
+ export declare const HB_SDK_SKILL_NAME = "hb-sdk";
3
+ export declare const HB_SDK_AGENT_SKILLS_BASE_URL = "https://open.xiaoheihe.cn/agent-skills";
4
+ export declare const HB_SDK_SKILL_SOURCE = "https://open.xiaoheihe.cn/agent-skills/hb-sdk";
5
+ export declare const HB_SDK_SKILL_INDEX_URL = "https://open.xiaoheihe.cn/agent-skills/.well-known/agent-skills/index.json";
6
+ export declare const HB_SDK_SKILL_INSTALL_COMMAND = "npx skills add https://open.xiaoheihe.cn/agent-skills/hb-sdk";
@@ -0,0 +1,17 @@
1
+ type MiniappManifestPlugin = {
2
+ name: string;
3
+ apply: 'build';
4
+ configResolved: (resolved: MiniappManifestResolvedConfig) => void;
5
+ writeBundle: (this: MiniappManifestPluginContext) => void;
6
+ };
7
+ interface MiniappManifestPluginContext {
8
+ warn: (message: string) => void;
9
+ }
10
+ interface MiniappManifestResolvedConfig {
11
+ root: string;
12
+ build: {
13
+ outDir: string;
14
+ };
15
+ }
16
+ export declare function miniappManifest(): MiniappManifestPlugin;
17
+ export {};