@heybox/hb-sdk 0.8.1-alpha.3 → 0.8.1-alpha.7

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 (63) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +47 -3
  3. package/dist/cli-chunks/{build-B5Sbi8Sq.cjs → build-C8oN_Ms9.cjs} +7 -5
  4. package/dist/cli-chunks/{context-DuxaBL3Y.cjs → context-DZkqvg9S.cjs} +8 -3
  5. package/dist/cli-chunks/{create-CIfZrg3F.cjs → create-CToSHRfO.cjs} +1 -1
  6. package/dist/cli-chunks/{dev-CFubP5kW.cjs → dev-CTA0lsLD.cjs} +479 -140
  7. package/dist/cli-chunks/{doctor-IPKn3PBn.cjs → doctor-DRa_kjP1.cjs} +1 -1
  8. package/dist/cli-chunks/{index-KHhdZ8eZ.cjs → index-Bkl5YmtN.cjs} +2 -2
  9. package/dist/cli-chunks/{index-DCJN-V1y.cjs → index-zNpZDWhc.cjs} +87 -15
  10. package/dist/cli-chunks/{index.esm-8hgZlNF8.cjs → index.esm-CGoUW47e.cjs} +9 -8
  11. package/dist/cli-chunks/{login-CoB9jXxC.cjs → login-CCEPk2Ok.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-DMxdOWsU.cjs → project-vite-couFw5bL.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-D4ZcngLn.cjs → remote-DQ70o-Km.cjs} +33 -24
  14. package/dist/cli-chunks/{runtime-permission-env-XAZFauvZ.cjs → runtime-permission-env-BN43V7d0.cjs} +181 -16
  15. package/dist/cli-chunks/{session-BnoHxzFq.cjs → session-C1R_39si.cjs} +1 -1
  16. package/dist/cli-chunks/{skill-CDEJtATn.cjs → skill-CVXOE5jH.cjs} +83 -27
  17. package/dist/cli-chunks/{version-BGzCIQhE.cjs → version-DbDVL6vm.cjs} +1 -1
  18. package/dist/cli.cjs +1 -1
  19. package/dist/devtools/browser-dev-host/assets/browser-dev-host-CH6L1ZJI.js +101 -0
  20. package/dist/devtools/browser-dev-host/assets/desktop-app-launch-DnPRjCa3.js +6 -0
  21. package/dist/devtools/browser-dev-host/assets/index-D-aNERAr.css +1 -0
  22. package/dist/devtools/browser-dev-host/assets/index-DocojUxT.js +567 -0
  23. package/dist/devtools/browser-dev-host/index.html +3 -3
  24. package/dist/index.cjs.js +1893 -1571
  25. package/dist/index.esm.js +1893 -1572
  26. package/dist/miniapp-publish.cjs.js +61 -0
  27. package/dist/miniapp-publish.esm.js +59 -1
  28. package/dist/protocol.cjs.js +64 -13
  29. package/dist/protocol.esm.js +64 -13
  30. package/dist/vite.cjs.js +1316 -10
  31. package/dist/vite.esm.js +1317 -12
  32. package/package.json +7 -7
  33. package/skill/SKILL.md +8 -3
  34. package/skill/references/api-protocol.md +3 -3
  35. package/skill/references/api-root.md +224 -208
  36. package/skill/references/cli.md +7 -1
  37. package/skill/references/examples.md +4 -0
  38. package/skill/references/recipes.md +161 -0
  39. package/skill/references/safety-boundaries.md +8 -2
  40. package/skill/skill.json +5 -5
  41. package/types/core/client.d.ts +2 -0
  42. package/types/core/sdk.d.ts +3 -0
  43. package/types/core/singleton.d.ts +3 -0
  44. package/types/devtools/device-logs.d.ts +48 -0
  45. package/types/index.d.ts +3 -1
  46. package/types/miniapp-manifest/companion-directory.d.ts +2 -0
  47. package/types/miniapp-manifest/companion-executable.d.ts +4 -0
  48. package/types/miniapp-manifest/companion-types.d.ts +38 -0
  49. package/types/miniapp-manifest/companions.d.ts +17 -0
  50. package/types/miniapp-manifest/index.d.ts +2 -0
  51. package/types/miniapp-manifest/node.d.ts +7 -0
  52. package/types/miniapp-manifest/permissions.d.ts +1 -1
  53. package/types/miniapp-manifest/schema.d.ts +4 -1
  54. package/types/miniapp-publish/index.d.ts +17 -2
  55. package/types/modules/companion/index.d.ts +57 -0
  56. package/types/modules/network/index.d.ts +1 -4
  57. package/types/modules/network/observability.d.ts +0 -1
  58. package/types/protocol/dev-session.d.ts +6 -0
  59. package/types/vite/index.d.ts +10 -0
  60. package/dist/devtools/browser-dev-host/assets/browser-dev-host-DzEst9n7.js +0 -99
  61. package/dist/devtools/browser-dev-host/assets/index-B-NHlLsr.js +0 -567
  62. package/dist/devtools/browser-dev-host/assets/index-P-ra4m1y.css +0 -1
  63. package/dist/devtools/browser-dev-host/assets/workbench-state-BwV7bm4n.js +0 -5
@@ -0,0 +1,57 @@
1
+ import { type CompanionCapability, type CompanionExit, type CompanionInfo, type CompanionNotificationCategory, type CompanionPreparationStatus, type CompanionPrepareProgress, type CompanionTarget } from '@heybox/hb-sdk-protocol';
2
+ import type { MiniProgramOperationRequester } from '../../core/client';
3
+ import type { MiniProgramEventHandler, MiniProgramEventName } from '../../protocol/types';
4
+ import type { FileHandle } from '../files';
5
+ interface CompanionRequester extends MiniProgramOperationRequester {
6
+ on<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): () => void;
7
+ }
8
+ export interface CompanionPrepareOptions {
9
+ signal?: AbortSignal;
10
+ onProgress?: (progress: CompanionPrepareProgress) => void;
11
+ }
12
+ export type CompanionOutputHandler = (data: Uint8Array) => void;
13
+ export type CompanionExitHandler = (exit: CompanionExit) => void;
14
+ export type CompanionOwnershipLostHandler = () => void;
15
+ export type CompanionState = 'running' | 'exited';
16
+ export type CompanionStateChangeHandler = (state: CompanionState) => void;
17
+ export interface CompanionNotification {
18
+ category: CompanionNotificationCategory;
19
+ }
20
+ export interface CompanionStdio {
21
+ write(data: Uint8Array): Promise<void>;
22
+ closeStdin(): Promise<void>;
23
+ onStdout(handler: CompanionOutputHandler): () => void;
24
+ onStderr(handler: CompanionOutputHandler): () => void;
25
+ }
26
+ export interface CompanionAttachments {
27
+ open(id: string): Promise<FileHandle>;
28
+ }
29
+ export interface CompanionNotifications {
30
+ show(input: CompanionNotification): Promise<void>;
31
+ }
32
+ export interface CompanionSession {
33
+ readonly id: string;
34
+ readonly alias: string;
35
+ readonly target: CompanionTarget;
36
+ readonly capabilities: readonly CompanionCapability[];
37
+ readonly state: CompanionState;
38
+ readonly stdio?: CompanionStdio;
39
+ readonly attachments?: CompanionAttachments;
40
+ readonly notifications?: CompanionNotifications;
41
+ terminate(): Promise<void>;
42
+ waitForExit(): Promise<CompanionExit>;
43
+ onStateChange(handler: CompanionStateChangeHandler): () => void;
44
+ onExit(handler: CompanionExitHandler): () => void;
45
+ onOwnershipLost(handler: CompanionOwnershipLostHandler): () => void;
46
+ }
47
+ export interface MiniProgramCompanionModule {
48
+ getInfo(alias: string): Promise<CompanionInfo>;
49
+ getPreparationStatus(alias: string): Promise<CompanionPreparationStatus>;
50
+ prepare(alias: string, options?: CompanionPrepareOptions): Promise<CompanionInfo>;
51
+ cancelPreparation(alias: string): Promise<void>;
52
+ launch(alias: string): Promise<CompanionSession>;
53
+ getActiveSession(alias: string): Promise<CompanionSession | undefined>;
54
+ }
55
+ /** 创建当前 SDK session 的 companion 模块。 */
56
+ export declare function createCompanionModule(requester: CompanionRequester): MiniProgramCompanionModule;
57
+ export type { CompanionCapability, CompanionExit, CompanionInfo, CompanionNotificationCategory, CompanionPreparationStatus, CompanionPrepareProgress, CompanionTarget, };
@@ -38,8 +38,6 @@ export interface MiniProgramNetworkRequestConfig {
38
38
  headers?: MiniProgramNetworkHeaders;
39
39
  /** 超时时间,单位毫秒。 */
40
40
  timeout?: number;
41
- /** 是否携带凭据意图;具体策略由宿主运行时决定。 */
42
- withCredentials?: boolean;
43
41
  /** SDK 侧状态校验;不会跨 bridge 传输函数值。 */
44
42
  validateStatus?: MiniProgramNetworkValidateStatus;
45
43
  }
@@ -54,7 +52,6 @@ export interface DownloadBaseOptions {
54
52
  params?: MiniProgramNetworkParams;
55
53
  headers?: MiniProgramNetworkHeaders;
56
54
  timeout?: number;
57
- withCredentials?: boolean;
58
55
  maxBytes?: number;
59
56
  signal?: AbortSignal;
60
57
  onProgress?: (progress: DownloadProgress) => void;
@@ -82,7 +79,6 @@ export interface NetworkRequestPayload {
82
79
  data?: unknown;
83
80
  headers?: MiniProgramNetworkHeaders;
84
81
  timeout?: number;
85
- withCredentials?: boolean;
86
82
  }
87
83
  /**
88
84
  * bridge / runtime 返回的标准化 HTTP 响应。
@@ -114,6 +110,7 @@ export interface MiniProgramNetworkModule {
114
110
  * @returns 标准化网络响应;HTTP 2xx 默认返回 resolve。
115
111
  * @throws 当请求已完成但 HTTP 状态不满足 `validateStatus` 时抛出 `HbMiniProgramNetworkError`。
116
112
  * @throws 当 bridge、运行时或宿主能力调用失败时抛出 `HbMiniProgramSDKError`。
113
+ * @deprecated Since 0.8.1-alpha.7. 暂无替代接口;现有调用仍可使用,请移除 withCredentials 配置。Native Cookie 由 Host 按目标域名决定。
117
114
  * @since 0.2.0-alpha.0
118
115
  * @hbPlatform android
119
116
  * @hbPlatform ios
@@ -12,7 +12,6 @@ export interface NetworkRequestFailureLog {
12
12
  headers?: MiniProgramNetworkHeaders;
13
13
  dataPreview?: unknown;
14
14
  timeout?: number;
15
- withCredentials?: boolean;
16
15
  }
17
16
  /**
18
17
  * 记录 `network.request` 失败,保证异常路径在开发者控制台可观测。
@@ -33,6 +33,12 @@ export interface MiniProgramDevLaunchSnapshot {
33
33
  sdk_version?: string;
34
34
  mini_program_id?: string;
35
35
  local_dev_launch_token?: string;
36
+ /** CLI 进程身份,重启后变化;不作为授权凭据。 */
37
+ dev_session_id?: string;
38
+ /** 启动票过期时间,Unix 毫秒。 */
39
+ expires_at?: number;
40
+ companion_manifest_sha256?: string;
41
+ companion_artifact_access_token?: string;
36
42
  dev_context_url?: string;
37
43
  runtime_permissions?: MiniProgramRuntimePermissionsSnapshot;
38
44
  }
@@ -1,3 +1,4 @@
1
+ import type { IncomingMessage, Server, ServerResponse } from 'node:http';
1
2
  import { MINIAPP_PLATFORM_VALUES, type MiniappPlatform } from '../miniapp-manifest/schema';
2
3
  export interface MiniappManifestPlugin {
3
4
  name: string;
@@ -5,11 +6,19 @@ export interface MiniappManifestPlugin {
5
6
  command: 'build' | 'serve';
6
7
  }) => MiniappManifestUserConfig | void;
7
8
  configResolved: (resolved: MiniappManifestResolvedConfig) => void;
9
+ configureServer: (server: MiniappManifestDevServer) => void;
8
10
  /** Rollup 在构建失败后仍会跑 closeBundle;用 buildEnd 记录真实错误,避免二次校验掩盖原因。 */
9
11
  buildEnd: (error?: Error) => void;
10
12
  transformIndexHtml: (html: string) => string;
11
13
  closeBundle: (this: MiniappManifestPluginContext) => Promise<void>;
12
14
  }
15
+ export interface MiniappManifestDevServer {
16
+ httpServer?: Server | null;
17
+ restart?: (forceOptimize?: boolean) => Promise<void>;
18
+ middlewares: {
19
+ use: (handler: (request: IncomingMessage, response: ServerResponse, next: () => void) => void) => void;
20
+ };
21
+ }
13
22
  export interface MiniappManifestUserConfig {
14
23
  base?: string;
15
24
  define?: Record<string, string>;
@@ -40,4 +49,5 @@ export interface MiniappManifestResolvedConfig {
40
49
  }
41
50
  export { MINIAPP_PLATFORM_VALUES };
42
51
  export type { MiniappPlatform };
52
+ export declare const HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN_ENV = "HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN";
43
53
  export declare function miniappManifest(): MiniappManifestPlugin;