@heybox/hb-sdk 0.8.1-alpha.13 → 0.8.1-alpha.14

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 (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +25 -0
  3. package/dist/cli-chunks/{build-CBPmqCVZ.cjs → build-D-VaxzAE.cjs} +11 -7
  4. package/dist/cli-chunks/{context-CvuPJq1G.cjs → context-BH7BZPoY.cjs} +2 -2
  5. package/dist/cli-chunks/{create-CyMWFYrc.cjs → create-Bmp9E1n8.cjs} +1 -1
  6. package/dist/cli-chunks/{dev-BcAPHk9L.cjs → dev-BntAFyWR.cjs} +28 -10
  7. package/dist/cli-chunks/{doctor-CIwaVrM1.cjs → doctor-t3YMD3qv.cjs} +1 -1
  8. package/dist/cli-chunks/{index-B0KCGR9H.cjs → index-CjP8Qye_.cjs} +2 -2
  9. package/dist/cli-chunks/{index-E0qh3FUb.cjs → index-VP8boR-7.cjs} +15 -15
  10. package/dist/cli-chunks/{index.esm-DTEOIvDp.cjs → index.esm-B_5UnniK.cjs} +7 -7
  11. package/dist/cli-chunks/{login-DGvHzH9j.cjs → login-p38-WSHx.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-CRnpRhSb.cjs → project-vite-BfJ5TGoA.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-C1_Hs11w.cjs → remote-CBH04z6v.cjs} +11 -6
  14. package/dist/cli-chunks/{runtime-permission-env-Bn1ONUDU.cjs → runtime-permission-env-CVYOOxPB.cjs} +91 -1
  15. package/dist/cli-chunks/{session-BvZgS7VI.cjs → session-BEpV8CZQ.cjs} +1 -1
  16. package/dist/cli-chunks/{skill-BVT6fBpQ.cjs → skill-DuVDTrA2.cjs} +2 -2
  17. package/dist/cli-chunks/{version-CJTEIaOQ.cjs → version-Df-F-uhW.cjs} +1 -1
  18. package/dist/cli.cjs +1 -1
  19. package/dist/devtools/browser-dev-host/assets/{browser-dev-host-DOzYp6JS.js → browser-dev-host-D_nC-Zex.js} +21 -21
  20. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-DZ_umnQp.js → desktop-app-launch-C1GHFN_L.js} +3 -3
  21. package/dist/devtools/browser-dev-host/assets/{index-DoPg_zh_.js → index-mfGqyKpq.js} +4 -4
  22. package/dist/devtools/browser-dev-host/index.html +2 -2
  23. package/dist/index.cjs.js +1 -1
  24. package/dist/index.esm.js +1 -1
  25. package/dist/vite.cjs.js +141 -17
  26. package/dist/vite.esm.js +141 -18
  27. package/package.json +4 -4
  28. package/skill/SKILL.md +2 -0
  29. package/skill/references/api-protocol.md +2 -2
  30. package/skill/references/api-root.md +1 -1
  31. package/skill/references/safety-boundaries.md +2 -0
  32. package/skill/skill.json +5 -5
  33. package/types/miniapp-manifest/node.d.ts +8 -1
  34. package/types/miniapp-manifest/schema.d.ts +37 -0
  35. package/types/vite/index.d.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.8.1-alpha.13",
3
+ "version": "0.8.1-alpha.14",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -62,7 +62,7 @@
62
62
  "skills": "1.5.23",
63
63
  "undici": "^7.28.0",
64
64
  "ws": "^8.18.0",
65
- "@heybox/hb-sdk-protocol": "0.8.1-alpha.13"
65
+ "@heybox/hb-sdk-protocol": "0.8.1-alpha.14"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "vite": ">=5"
@@ -115,10 +115,10 @@
115
115
  "vitest": "^3.2.4",
116
116
  "@heybox-domain/heybox-theme": "~0.1.0",
117
117
  "@heybox-domain/heybox-vue3-ui": "~0.1.0",
118
+ "@heybox/hb-sdk-runtime": "~0.8.1-alpha.14",
118
119
  "@heybox/hb-api": "~1.28.3",
119
- "@heybox/hb-sdk-runtime": "~0.8.1-alpha.13",
120
- "@heybox/runtime-policy": "~0.2.0",
121
120
  "@heybox/runtime": "~0.2.0",
121
+ "@heybox/runtime-policy": "~0.2.0",
122
122
  "@heybox/runtime-transport-fetch": "~0.2.0"
123
123
  },
124
124
  "publishConfig": {
package/skill/SKILL.md CHANGED
@@ -56,6 +56,7 @@ Apply these instructions when writing, reviewing, or debugging code that consume
56
56
  15. Use `companion.prepare()` and `companion.launch()` only from separate trusted user actions. Launch does not prepare implicitly. Treat stdio as raw `Uint8Array` with at-least-once output delivery, and implement business framing and sequence de-duplication explicitly.
57
57
  16. Use `environment.getInfo()` for the immutable runtime, Host App, canonical Mini-program, operating-system, and SDK version snapshot. It waits for the handshake automatically. Use `environment.getInfoSync()` only after `getHandshakeState().status === 'ready'` or inside a ready-state subscription; before that it throws `ENVIRONMENT_NOT_READY`.
58
58
  17. Treat missing environment strings as `null` and unknown enum values as `unknown`. Only `sdk.version` is SemVer; do not compare the other opaque version strings or use any environment field for authentication, authorization, or risk control.
59
+ 18. Declare window defaults only through `package.json#heybox.window` (`defaultWidth` / `defaultHeight` / `minWidth` / `minHeight` / `resizable`). `resizable` constrains user dragging only; `minWidth` / `minHeight` are the dragging lower bounds. Position is not open to developers.
59
60
 
60
61
  ## Step 5: Use CLI workflows
61
62
 
@@ -95,6 +96,7 @@ For workshop mini-program business code:
95
96
  9. Do not invent string paths, File System Access API handles, Blob downloads, uploads, Range/resume, external deletion, move, append, or persistent external grants. Public file operations use only SDK-created handles; deletion is limited to SDK sandbox handles.
96
97
  10. Do not pass executable paths, dynamic args, cwd, environment variables, shell commands, URLs, hashes, PID, or native handles through `companion`; reviewed Manifest declarations are the only launch source.
97
98
  11. Do not treat `environment.*` as a device-fingerprint or trusted backend signal. It intentionally excludes account data, device identifiers, model, UA, CPU, and memory; use `viewport.getWindowInfo()` for screen geometry.
99
+ 12. Do not declare or set window position through the SDK. `package.json#heybox.window` rejects `x` / `y` and `width` / `height`. Position comes from user dragging and is remembered locally by the Host.
98
100
 
99
101
  For CLI and local development:
100
102
 
@@ -302,9 +302,9 @@ Reference 由 `@heybox/hb-sdk` 的公开导出与源码注释自动生成,不
302
302
  | Root API | 2 | 4 | 75 | 73 | 3 |
303
303
  | Protocol API | 0 | 13 | 58 | 90 | 47 |
304
304
  | Miniapp Publish API | 0 | 5 | 2 | 0 | 0 |
305
- | Vite API | 0 | 1 | 5 | 1 | 2 |
305
+ | Vite API | 0 | 1 | 5 | 1 | 3 |
306
306
 
307
- <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=4; fingerprint=a80eea1bb8b0d64255afcb4a664911f025aeae33f3f766c9b126f55668400178 -->
307
+ <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=4; fingerprint=7356ab1376630f8bed1028cf9fca72895fc3a1603b8742280c265c53fdeff423 -->
308
308
 
309
309
  ## SDK API
310
310
 
@@ -27,7 +27,7 @@
27
27
  ## Package metadata
28
28
 
29
29
  - Package: `@heybox/hb-sdk`
30
- - Version at generation time: `0.8.1-alpha.13`
30
+ - Version at generation time: `0.8.1-alpha.14`
31
31
  - Public root export: `@heybox/hb-sdk`
32
32
  - Protocol export: `@heybox/hb-sdk/protocol`
33
33
  - Vite plugin export: `@heybox/hb-sdk/vite`
@@ -42,6 +42,8 @@
42
42
  - Companion stdio 是原始 `Uint8Array` 且输出为 at-least-once 投递;业务自行定义 framing、去重、重放与恢复。
43
43
  - Browser Dev Host 的 Companion Fake 只用于状态和 UI 开发,不能作为桌面程序可执行、签名、权限或进程监管的真机证据。
44
44
  - 本地真 PC Companion 需要 `package.json#heybox.companions`、本地产物、已绑定项目和 COA `companion` 批准;未配置本地产物时使用 Browser Fake。配置或产物更新后校验并切换不可变快照;已有进程保留原产物,新产物须重新准备与启动。
45
+ - `package.json#heybox.window` 只声明开窗初值与可缩放性;`resizable` 只约束用户拖拽。
46
+ - 窗口位置不开放:开发者不能声明、也不能设置位置;位置由用户拖拽并由宿主按小程序身份本地记忆。
45
47
 
46
48
  私有 Page Channel 适配没有修改 `@heybox/hb-sdk` 公开 API 或 iframe wire;本次 files/download
47
49
  Runtime 能力随 `0.8.0-alpha.11` release family 发布,部署 detail 前必须保证
package/skill/skill.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.8.1-alpha.13+skill.3784ce3da843",
3
+ "skillVersion": "0.8.1-alpha.14+skill.63b05480eba4",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.8.1-alpha.13",
7
- "compatibility": "0.8.1-alpha.13"
6
+ "version": "0.8.1-alpha.14",
7
+ "compatibility": "0.8.1-alpha.14"
8
8
  },
9
9
  "distribution": {
10
10
  "type": "npm",
11
11
  "package": "@heybox/hb-sdk",
12
- "version": "0.8.1-alpha.13",
12
+ "version": "0.8.1-alpha.14",
13
13
  "path": "skill"
14
14
  },
15
- "integrity": "sha256-3784ce3da8431dd675160a5c2a66e19d08f5210d3765a2cddcadee6e3dfa2a38"
15
+ "integrity": "sha256-63b05480eba4af0e9aeb126196230250ec8349fa1d84e84ebac8005fabe3a602"
16
16
  }
@@ -1,6 +1,6 @@
1
1
  import { type ParsedMiniappPermissions } from './permissions';
2
2
  import type { MiniappCompanionAuthoringDeclarations } from './companion-types';
3
- import type { MiniappPlatform } from './schema';
3
+ import type { MiniappPlatform, MiniappWindowDeclaration } from './schema';
4
4
  export declare function readMiniappVersionFromPackageJson(root: string): string;
5
5
  /** Companion source 始终相对声明所在 package.json,而非 Vite 的 HTML root。 */
6
6
  export declare function readMiniappCompanionsFromPackageJson(root: string): {
@@ -9,5 +9,12 @@ export declare function readMiniappCompanionsFromPackageJson(root: string): {
9
9
  packageJsonPath: string;
10
10
  };
11
11
  export declare function readMiniappPlatformsFromPackageJson(root: string): readonly MiniappPlatform[];
12
+ /**
13
+ * 读取并校验 `package.json#heybox.window`。
14
+ *
15
+ * @returns 合法声明;未声明时返回 `undefined`,调用方不得向 manifest 写入空对象或 `null`。
16
+ * @throws 当声明违反 {@link validateMiniappWindow} 的规则时抛出,报错前缀为 `package.json#heybox.window`。
17
+ */
18
+ export declare function readMiniappWindowFromPackageJson(root: string): MiniappWindowDeclaration | undefined;
12
19
  export declare function readMiniappPermissionsFromPackageJson(root: string, sdkVersion: string): ParsedMiniappPermissions;
13
20
  export declare function resolveMiniappSdkVersion(): string;
@@ -3,6 +3,27 @@ import type { MiniappCompanionManifestDeclarations } from './companion-types';
3
3
  export declare const MINIAPP_TEMPLATE_VERSION = "0.0.0";
4
4
  export declare const MINIAPP_PLATFORM_VALUES: readonly ["android", "ios", "ohos", "windows", "macos", "linux"];
5
5
  export type MiniappPlatform = (typeof MINIAPP_PLATFORM_VALUES)[number];
6
+ /** 窗口尺寸字段的脏值兜底上限;真正的上限是宿主侧显示器 workArea。 */
7
+ export declare const MINIAPP_WINDOW_SIZE_MAX = 16384;
8
+ /**
9
+ * `package.json#heybox.window` 的开发者声明字段。
10
+ *
11
+ * @remarks
12
+ * 只描述**开窗初值**与可缩放性,不是窗口当前尺寸;运行期尺寸请用 `viewport.getWindowInfo()`。
13
+ * 位置(`x` / `y`)不开放声明,由用户拖拽产生并由宿主记忆。
14
+ */
15
+ export interface MiniappWindowDeclaration {
16
+ /** 默认窗口内容宽度(逻辑像素),正整数,不超过 16384。 */
17
+ defaultWidth?: number;
18
+ /** 默认窗口内容高度(逻辑像素),正整数,不超过 16384。 */
19
+ defaultHeight?: number;
20
+ /** 尺寸下限宽度;必须与 defaultWidth 同时声明,且不大于 defaultWidth。 */
21
+ minWidth?: number;
22
+ /** 尺寸下限高度;必须与 defaultHeight 同时声明,且不大于 defaultHeight。 */
23
+ minHeight?: number;
24
+ /** 是否允许用户手动拖拽改变尺寸。 */
25
+ resizable?: boolean;
26
+ }
6
27
  /**
7
28
  * 桌面平台子集:从唯一平台词表 `MINIAPP_PLATFORM_VALUES` 派生,`satisfies` 阻止它漂移出词表。
8
29
  * 小程序声明其中任一平台,即视为该项目承诺适配 PC / 桌面端;调试台据此取舍桌面调试入口。
@@ -19,6 +40,7 @@ export interface MiniappManifest {
19
40
  platforms: readonly MiniappPlatform[];
20
41
  permissions?: MiniappPermissionDeclarations;
21
42
  companions?: MiniappCompanionManifestDeclarations;
43
+ window?: MiniappWindowDeclaration;
22
44
  }
23
45
  export interface ParseMiniappManifestResult {
24
46
  manifest: MiniappManifest;
@@ -30,6 +52,7 @@ export declare function validateMiniappManifestVersion(version: unknown, sourceL
30
52
  export declare function renderMiniappManifest(manifest: MiniappManifest): string;
31
53
  export declare function parseMiniappManifestJson(raw: string, sourceLabel?: string): ParseMiniappManifestResult;
32
54
  export declare function validateMiniappManifestForDeploy(manifest: MiniappManifest): {
55
+ window?: MiniappWindowDeclaration | undefined;
33
56
  companions?: MiniappCompanionManifestDeclarations | undefined;
34
57
  permissions?: Partial<Record<"userInfo" | "steamLibrary" | "share" | "storage" | "filesystem" | "clipboard" | "leaderboard" | "companion", import("./permissions").SimpleMiniappPermissionDeclaration> & {
35
58
  network: import("./permissions").NetworkMiniappPermissionDeclaration;
@@ -40,4 +63,18 @@ export declare function validateMiniappManifestForDeploy(manifest: MiniappManife
40
63
  };
41
64
  export declare function validateMiniappPlatforms(platforms: unknown, sourceLabel?: string): readonly MiniappPlatform[];
42
65
  export declare function areMiniappPlatformsEqual(left: readonly MiniappPlatform[], right: readonly MiniappPlatform[]): boolean;
66
+ /**
67
+ * 校验并归一化 `package.json#heybox.window` / `manifest.window` 声明。
68
+ *
69
+ * @remarks
70
+ * 与 `heybox.permissions` 同样的严格风格:未知字段报错,不做静默忽略。
71
+ * `width` / `height` 显式给出改名提示;`x` / `y` 按未知字段显式报错(`INV-NO-DEV-POSITION`)。
72
+ * 未声明时返回 `undefined`,由调用方决定不写入产物。
73
+ * @param value - 待校验的原始声明(不可信输入)。
74
+ * @param sourceLabel - 报错前缀,默认指向开发者声明路径。
75
+ * @throws 当声明不是非空对象、含未知字段、数值/布尔类型不合法或 min/default 不配对时抛出。
76
+ */
77
+ export declare function validateMiniappWindow(value: unknown, sourceLabel?: string): MiniappWindowDeclaration | undefined;
78
+ /** 比较两份窗口声明是否逐字段一致;未声明视同 `undefined`。 */
79
+ export declare function areMiniappWindowsEqual(left: MiniappWindowDeclaration | undefined, right: MiniappWindowDeclaration | undefined): boolean;
43
80
  export declare function validateSdkVersion(version: unknown, sourceLabel?: string): string;
@@ -50,4 +50,5 @@ export interface MiniappManifestResolvedConfig {
50
50
  export { MINIAPP_PLATFORM_VALUES };
51
51
  export type { MiniappPlatform };
52
52
  export declare const HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN_ENV = "HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN";
53
+ export declare const HB_SDK_MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV = "HB_SDK_MINI_PROGRAM_MANIFEST_ACCESS_TOKEN";
53
54
  export declare function miniappManifest(): MiniappManifestPlugin;