@heybox/hb-sdk 0.9.1-alpha.3 → 0.9.1-alpha.5
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/CHANGELOG.md +27 -2
- package/README.md +11 -0
- package/dist/card-controller.cjs.js +194 -0
- package/dist/card-controller.esm.js +159 -0
- package/dist/cli-chunks/{build-CXfLIArV.cjs → build-D91J_GAa.cjs} +13 -7
- package/dist/cli-chunks/{context-28ngGR4F.cjs → context-Xdd45FFd.cjs} +4 -4
- package/dist/cli-chunks/{create-5YcojPd6.cjs → create-BzpdRC5r.cjs} +1 -1
- package/dist/cli-chunks/{dev-BeFMlbOR.cjs → dev-C7acO3Kt.cjs} +56 -10
- package/dist/cli-chunks/{doctor-CqadEn3n.cjs → doctor-BgHRDQmG.cjs} +1 -1
- package/dist/cli-chunks/{index-GE8dMvDl.cjs → index-CjhQXbxy.cjs} +4 -7
- package/dist/cli-chunks/{index-Dexro5MZ.cjs → index-TQwjvNjL.cjs} +33 -17
- package/dist/cli-chunks/{index.esm-BjCGi12Z.cjs → index.esm-dgqkvowo.cjs} +7 -7
- package/dist/cli-chunks/{login-D4RB9Ben.cjs → login-B14iGXHh.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-7ns71VB6.cjs → project-vite-CN6mMjzX.cjs} +1 -1
- package/dist/cli-chunks/{remote-DMxbElj_.cjs → remote-C9RUiZxK.cjs} +25 -17
- package/dist/cli-chunks/runtime-gate-CfAkz0p-.cjs +201950 -0
- package/dist/cli-chunks/{runtime-permission-env-CHeBjX3l.cjs → runtime-permission-env-L7OfyRcl.cjs} +7295 -812
- package/dist/cli-chunks/{session-B3q86WA5.cjs → session-DZrr6RYK.cjs} +2 -1
- package/dist/cli-chunks/{skill-CnjlGsLj.cjs → skill-BHTVho1a.cjs} +2 -2
- package/dist/cli-chunks/{version-BnnLp_km.cjs → version-C_NaCZ8O.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-KPFU0Lsa.js +102 -0
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-e2ZHzPgD.js → desktop-app-launch-BNF9Yk4P.js} +3 -3
- package/dist/devtools/browser-dev-host/assets/{index-ClSYpidU.css → index-BRxbUJVN.css} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-D9bz_RbJ.js → index-DRRtB9Nm.js} +4 -4
- package/dist/devtools/browser-dev-host/index.html +3 -3
- package/dist/index.cjs.js +6252 -279
- package/dist/index.esm.js +6252 -280
- package/dist/miniapp-publish.cjs.js +6612 -157
- package/dist/miniapp-publish.esm.js +6612 -158
- package/dist/protocol.cjs.js +5815 -0
- package/dist/protocol.esm.js +5815 -1
- package/dist/vite.cjs.js +7475 -206
- package/dist/vite.esm.js +7474 -207
- package/dist/workspace-card-build-sandbox-worker.mjs +72 -0
- package/package.json +25 -11
- package/skill/skill.json +4 -4
- package/types/card-controller.d.ts +3682 -0
- package/types/index.d.ts +7532 -35
- package/types/miniapp-publish/index.d.ts +542 -64
- package/types/protocol.d.ts +2083 -9
- package/types/vite/index.d.ts +25 -12
- package/dist/cli-chunks/runtime-gate-C__ySQYU.cjs +0 -65
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-DBjCd6Dd.js +0 -102
- package/types/core/client.d.ts +0 -108
- package/types/core/csp-violation.d.ts +0 -5
- package/types/core/errors.d.ts +0 -78
- package/types/core/event-bus.d.ts +0 -11
- package/types/core/handshake-state.d.ts +0 -54
- package/types/core/history-observer.d.ts +0 -4
- package/types/core/mini-dev-console.d.ts +0 -36
- package/types/core/network-sanitize.d.ts +0 -31
- package/types/core/sdk.d.ts +0 -104
- package/types/core/singleton.d.ts +0 -372
- package/types/core/utils.d.ts +0 -10
- package/types/core/version.d.ts +0 -2
- package/types/devtools/device-logs.d.ts +0 -48
- package/types/miniapp-manifest/basic-info-browser.d.ts +0 -37
- package/types/miniapp-manifest/basic-info-image-header.d.ts +0 -6
- package/types/miniapp-manifest/basic-info-node.d.ts +0 -17
- package/types/miniapp-manifest/basic-info-placeholder.d.ts +0 -1
- package/types/miniapp-manifest/basic-info.d.ts +0 -33
- package/types/miniapp-manifest/bindings.d.ts +0 -70
- package/types/miniapp-manifest/category.d.ts +0 -11
- package/types/miniapp-manifest/companion-directory.d.ts +0 -2
- package/types/miniapp-manifest/companion-executable.d.ts +0 -4
- package/types/miniapp-manifest/companion-types.d.ts +0 -63
- package/types/miniapp-manifest/companions.d.ts +0 -17
- package/types/miniapp-manifest/index.d.ts +0 -7
- package/types/miniapp-manifest/node.d.ts +0 -22
- package/types/miniapp-manifest/permissions.d.ts +0 -48
- package/types/miniapp-manifest/runtime-gate.d.ts +0 -12
- package/types/miniapp-manifest/schema.d.ts +0 -302
- package/types/modules/auth/index.d.ts +0 -204
- package/types/modules/cloud/index.d.ts +0 -669
- package/types/modules/companion/index.d.ts +0 -1619
- package/types/modules/device/index.d.ts +0 -193
- package/types/modules/environment/index.d.ts +0 -238
- package/types/modules/files/index.d.ts +0 -5
- package/types/modules/files/registry.d.ts +0 -35
- package/types/modules/files/types.d.ts +0 -1548
- package/types/modules/navigation/app-pages/index.d.ts +0 -4
- package/types/modules/navigation/app-pages/types.d.ts +0 -135
- package/types/modules/navigation/index.d.ts +0 -312
- package/types/modules/network/index.d.ts +0 -457
- package/types/modules/network/observability.d.ts +0 -38
- package/types/modules/network/request-shape.d.ts +0 -44
- package/types/modules/share/copy-link.d.ts +0 -46
- package/types/modules/share/extra.d.ts +0 -5
- package/types/modules/share/index.d.ts +0 -294
- package/types/modules/share/screenshot.d.ts +0 -34
- package/types/modules/share/show-share-menu.d.ts +0 -29
- package/types/modules/share/types.d.ts +0 -201
- package/types/modules/storage/index.d.ts +0 -214
- package/types/modules/ui/index.d.ts +0 -315
- package/types/modules/user/get-info.d.ts +0 -44
- package/types/modules/user/index.d.ts +0 -245
- package/types/modules/user/revoke-authorization.d.ts +0 -31
- package/types/modules/user/steam-game-list.d.ts +0 -153
- package/types/modules/user/types.d.ts +0 -2
- package/types/modules/viewport/index.d.ts +0 -319
- package/types/protocol/capabilities.d.ts +0 -2
- package/types/protocol/constants.d.ts +0 -1
- package/types/protocol/dev-session.d.ts +0 -74
- package/types/protocol/guards.d.ts +0 -1
- package/types/protocol/runtime-permissions.d.ts +0 -2
- package/types/protocol/types.d.ts +0 -22
- package/types/skill-metadata.d.ts +0 -18
- package/types/vite/html-policy.d.ts +0 -6
- package/types/vite/runtime-permission-env.d.ts +0 -9
package/types/vite/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Server, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `package.json#heybox.platforms` 接受的平台值,顺序同时是 Manifest 的规范化输出顺序。
|
|
5
|
+
*
|
|
6
|
+
* @remarks 项目仍应只声明实际完成适配并经过验收的平台;模板默认值不是自动兼容承诺。
|
|
7
|
+
*/
|
|
8
|
+
declare const MINIAPP_PLATFORM_VALUES: readonly ["android", "ios", "ohos", "windows", "macos", "linux"];
|
|
9
|
+
/** `package.json#heybox.platforms` 中单个平台标识。 */
|
|
10
|
+
type MiniappPlatform = (typeof MINIAPP_PLATFORM_VALUES)[number];
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* {@link miniappManifest} 返回的 Vite 插件契约。
|
|
5
14
|
*
|
|
@@ -8,7 +17,7 @@ import { MINIAPP_PLATFORM_VALUES, type MiniappPlatform } from '../miniapp-manife
|
|
|
8
17
|
* 也不应手动调用这些 Vite hook。该接口不包含小程序声明;目标平台、权限、窗口、游戏绑定和 Companion
|
|
9
18
|
* 等配置统一来自距离 Vite `root` 最近的 `package.json#heybox`。
|
|
10
19
|
*/
|
|
11
|
-
|
|
20
|
+
interface MiniappManifestPlugin {
|
|
12
21
|
/** 固定为 `heybox-miniapp-manifest`,同一份 Vite 配置必须且只能注册一个实例。 */
|
|
13
22
|
name: string;
|
|
14
23
|
/** 校验资源基准路径,并向 Vite 注入 SDK 版本和开发期日志开关。 */
|
|
@@ -32,7 +41,7 @@ export interface MiniappManifestPlugin {
|
|
|
32
41
|
* @remarks
|
|
33
42
|
* 这是插件返回值暴露的 hook 类型,不是 `miniappManifest()` 的配置项。业务项目应让 Vite 创建并传入服务实例。
|
|
34
43
|
*/
|
|
35
|
-
|
|
44
|
+
interface MiniappManifestDevServer {
|
|
36
45
|
/** Vite 底层 HTTP 服务;middleware mode 或尚未监听时可能为空。 */
|
|
37
46
|
httpServer?: Server | null;
|
|
38
47
|
/** Vite 配置重载入口;插件会在重载期间保留当前本地调试快照。 */
|
|
@@ -49,7 +58,7 @@ export interface MiniappManifestDevServer {
|
|
|
49
58
|
* 该接口描述 Vite hook 数据,不是插件 options;`miniappManifest()` 必须无参调用。小程序声明请写入
|
|
50
59
|
* `package.json#heybox`,不要写入 Vite 配置。
|
|
51
60
|
*/
|
|
52
|
-
|
|
61
|
+
interface MiniappManifestUserConfig {
|
|
53
62
|
/**
|
|
54
63
|
* Vite 资源基准路径。省略时插件返回 `./`;显式配置只接受空字符串或 `./`,以便版本目录内相对加载资源。
|
|
55
64
|
*/
|
|
@@ -58,7 +67,7 @@ export interface MiniappManifestUserConfig {
|
|
|
58
67
|
define?: Record<string, string>;
|
|
59
68
|
}
|
|
60
69
|
/** {@link MiniappManifestPlugin.closeBundle} 使用的最小 Rollup 插件上下文。 */
|
|
61
|
-
|
|
70
|
+
interface MiniappManifestPluginContext {
|
|
62
71
|
/** 输出缺少迁移期声明等非阻断构建警告。 */
|
|
63
72
|
warn: (message: string) => void;
|
|
64
73
|
}
|
|
@@ -69,7 +78,7 @@ export interface MiniappManifestPluginContext {
|
|
|
69
78
|
* 这是 Vite 传给插件的 hook 数据,不是应用作者需要创建的 options。插件从中确定项目根目录、输出目录、
|
|
70
79
|
* serve/build 分支和 HMR WebSocket 白名单。
|
|
71
80
|
*/
|
|
72
|
-
|
|
81
|
+
interface MiniappManifestResolvedConfig {
|
|
73
82
|
/** Vite 项目根目录;小程序配置从该目录向上找到的最近 `package.json` 读取。 */
|
|
74
83
|
root: string;
|
|
75
84
|
/** `serve` 只准备本地调试,`build` 还会校验产物并生成 `manifest.json`。 */
|
|
@@ -95,22 +104,23 @@ export interface MiniappManifestResolvedConfig {
|
|
|
95
104
|
name?: string;
|
|
96
105
|
}[];
|
|
97
106
|
}
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
|
|
108
|
+
declare const HB_SDK_WORKSPACE_CARD_DEV_ARTIFACT_PREFIX = "/__hb_sdk__/";
|
|
109
|
+
declare const HB_SDK_WORKSPACE_CARD_GENERATION_HEADER = "x-hb-sdk-workspace-cards-generation";
|
|
100
110
|
/**
|
|
101
111
|
* `hb-sdk dev` 为本地 Companion 产物访问注入的进程环境变量名。
|
|
102
112
|
*
|
|
103
113
|
* @remarks
|
|
104
114
|
* 该变量由 CLI 管理,不是项目配置项。应用代码不应读取、设置、记录或转发它的值。
|
|
105
115
|
*/
|
|
106
|
-
|
|
116
|
+
declare const HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN_ENV = "HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN";
|
|
107
117
|
/**
|
|
108
118
|
* `hb-sdk dev` 为本地小程序 Manifest 访问注入的进程环境变量名。
|
|
109
119
|
*
|
|
110
120
|
* @remarks
|
|
111
121
|
* 该变量由 CLI 管理,不是项目配置项。应用代码不应读取、设置、记录或转发它的值。
|
|
112
122
|
*/
|
|
113
|
-
|
|
123
|
+
declare const HB_SDK_MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV = "HB_SDK_MINI_PROGRAM_MANIFEST_ACCESS_TOKEN";
|
|
114
124
|
/**
|
|
115
125
|
* 创建工坊小程序使用的 Vite 插件。
|
|
116
126
|
*
|
|
@@ -216,4 +226,7 @@ export declare const HB_SDK_MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV = "HB_SDK_MIN
|
|
|
216
226
|
* @see [窗口尺寸与可缩放性](/guide/window-size) `heybox.window` 字段与 Host 消费语义。
|
|
217
227
|
* @see [受管桌面程序](/guide/companion) Companion 声明、归档和本地联调边界。
|
|
218
228
|
*/
|
|
219
|
-
|
|
229
|
+
declare function miniappManifest(): MiniappManifestPlugin;
|
|
230
|
+
|
|
231
|
+
export { HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN_ENV, HB_SDK_MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV, HB_SDK_WORKSPACE_CARD_DEV_ARTIFACT_PREFIX, HB_SDK_WORKSPACE_CARD_GENERATION_HEADER, MINIAPP_PLATFORM_VALUES, miniappManifest };
|
|
232
|
+
export type { MiniappManifestDevServer, MiniappManifestPlugin, MiniappManifestPluginContext, MiniappManifestResolvedConfig, MiniappManifestUserConfig, MiniappPlatform };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var runtimePermissionEnv = require('./runtime-permission-env-CHeBjX3l.cjs');
|
|
4
|
-
|
|
5
|
-
// Shorthands
|
|
6
|
-
/**
|
|
7
|
-
* Parses an HTML string.
|
|
8
|
-
*
|
|
9
|
-
* @param html Input HTML string.
|
|
10
|
-
* @param options Parsing options.
|
|
11
|
-
* @returns Document
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
*
|
|
15
|
-
* ```js
|
|
16
|
-
* const parse5 = require('parse5');
|
|
17
|
-
*
|
|
18
|
-
* const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
|
|
19
|
-
*
|
|
20
|
-
* console.log(document.childNodes[1].tagName); //> 'html'
|
|
21
|
-
*```
|
|
22
|
-
*/
|
|
23
|
-
function parse(html, options) {
|
|
24
|
-
return runtimePermissionEnv.Parser.parse(html, options);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const RUNTIME_GATE_MARKER = 'data-heybox-runtime-gate';
|
|
28
|
-
const RUNTIME_GATE_STYLE_MARKER = 'data-heybox-runtime-gate-style';
|
|
29
|
-
const RUNTIME_GATE_BOOTSTRAP_MARKER = 'data-heybox-runtime-gate-bootstrap';
|
|
30
|
-
/**
|
|
31
|
-
* 检查 HTML 是否包含 Runtime Gate 的三个结构标记。
|
|
32
|
-
*
|
|
33
|
-
* @param html - 待检查的完整 HTML 文本,使用 HTML parser 解析。
|
|
34
|
-
* @returns Gate、隐藏样式及 bootstrap 标记均出现时返回 `true`,否则返回 `false`。
|
|
35
|
-
* @remarks 只识别标记,不验证脚本内容、标记所在节点或宿主握手;不能据此判断页面安全或实际可运行。
|
|
36
|
-
*/
|
|
37
|
-
function hasMiniappRuntimeGate(html) {
|
|
38
|
-
const document = parse(html);
|
|
39
|
-
let hasGate = false;
|
|
40
|
-
let hasGateStyle = false;
|
|
41
|
-
let hasGateBootstrap = false;
|
|
42
|
-
walk(document, (element) => {
|
|
43
|
-
hasGate ||= hasAttr(element, RUNTIME_GATE_MARKER);
|
|
44
|
-
hasGateStyle ||= hasAttr(element, RUNTIME_GATE_STYLE_MARKER);
|
|
45
|
-
hasGateBootstrap ||= hasAttr(element, RUNTIME_GATE_BOOTSTRAP_MARKER);
|
|
46
|
-
});
|
|
47
|
-
return hasGate && hasGateStyle && hasGateBootstrap;
|
|
48
|
-
}
|
|
49
|
-
function readAttr(element, name) {
|
|
50
|
-
return element.attrs.find((attr) => attr.name.toLowerCase() === name)?.value;
|
|
51
|
-
}
|
|
52
|
-
function hasAttr(element, name) {
|
|
53
|
-
return readAttr(element, name) !== undefined;
|
|
54
|
-
}
|
|
55
|
-
function walk(node, visit) {
|
|
56
|
-
if ('tagName' in node)
|
|
57
|
-
visit(node);
|
|
58
|
-
if ('childNodes' in node)
|
|
59
|
-
for (const child of node.childNodes)
|
|
60
|
-
walk(child, visit);
|
|
61
|
-
if ('content' in node && node.content)
|
|
62
|
-
walk(node.content, visit);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
exports.hasMiniappRuntimeGate = hasMiniappRuntimeGate;
|