@heybox/hb-sdk 0.2.0-alpha.1 → 0.2.0-alpha.2
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 +68 -1
- package/dist/cli.cjs +71174 -3895
- package/dist/miniapp-publish.cjs.js +77 -0
- package/dist/miniapp-publish.esm.js +66 -0
- package/dist/templates/vue3-vite-ts/vite.config.ts +2 -1
- package/dist/vite.cjs.js +62 -0
- package/dist/vite.esm.js +60 -0
- package/package.json +28 -1
- package/skill/SKILL.md +28 -17
- package/skill/references/api-root.md +129 -1
- package/skill/references/cli.md +17 -1
- package/skill/references/examples.md +12 -0
- package/skill/references/safety-boundaries.md +2 -0
- package/skill/scripts/sync-references.mjs +24 -0
- package/skill/scripts/validate-skill.mjs +4 -2
- package/skill/skill.json +4 -4
- package/types/miniapp-publish/index.d.ts +23 -0
- package/types/vite/index.d.ts +17 -0
|
@@ -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.
|
|
@@ -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(
|
|
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.
|
|
3
|
+
"skillVersion": "0.2.0-alpha.2+skill.57e0cec11058",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.2.0-alpha.
|
|
7
|
-
"compatibility": "0.2.0-alpha.
|
|
6
|
+
"version": "0.2.0-alpha.2",
|
|
7
|
+
"compatibility": "0.2.0-alpha.2"
|
|
8
8
|
},
|
|
9
9
|
"source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
|
|
10
|
-
"integrity": "sha256-
|
|
10
|
+
"integrity": "sha256-57e0cec1105894712e82600045659d9f08fedc9e0e4c3159445168eaec6675e7"
|
|
11
11
|
}
|
|
@@ -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 declare function isValidVersion(version: string): boolean;
|
|
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,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 {};
|