@heybox/hb-sdk 0.9.9-alpha.0 → 0.9.9-alpha.11
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 +44 -0
- package/README.md +2 -0
- package/dist/cli-chunks/{build-Vi5Zyplz.cjs → build-D_2l0CIV.cjs} +5 -5
- package/dist/cli-chunks/{create-Cfz1IcYf.cjs → create-0QH1Tn92.cjs} +2 -2
- package/dist/cli-chunks/{dev-C2dtgF42.cjs → dev-CS5VPiB1.cjs} +912 -703
- package/dist/cli-chunks/{doctor-D-zMCLIA.cjs → doctor-B33mYzm-.cjs} +1 -1
- package/dist/cli-chunks/{game-binding-guide-z3X6h8ck.cjs → game-binding-guide-DMDuw1Pj.cjs} +3 -3
- package/dist/cli-chunks/{game-bindings-DiVP8PdD.cjs → game-bindings-CQWdvXfM.cjs} +4 -4
- package/dist/cli-chunks/{games-THhcga6y.cjs → games-deIaD0qu.cjs} +1 -1
- package/dist/cli-chunks/{index-BuYCoach.cjs → index-C91c2NGN.cjs} +1 -1
- package/dist/cli-chunks/{index-H9U6-mLY.cjs → index-DpfxAeSH.cjs} +78 -25
- package/dist/cli-chunks/{index.esm-XiyiK7eH.cjs → index.esm-B2WXn2A4.cjs} +10 -10
- package/dist/cli-chunks/{index.esm-D8lqHXUQ.cjs → index.esm-CenYK5Bl.cjs} +72 -3
- package/dist/cli-chunks/{login-Bw_1UJ8i.cjs → login-D7XGHQFo.cjs} +1 -1
- package/dist/cli-chunks/{project-vite-CFfq-fV7.cjs → project-vite-B7sylnO7.cjs} +1 -1
- package/dist/cli-chunks/{remote-CU88U8t8.cjs → remote-Crnu4l7X.cjs} +952 -742
- package/dist/cli-chunks/{runtime-permission-env-BtxzR-dv.cjs → runtime-permission-env-Cj9STUWz.cjs} +25 -4
- package/dist/cli-chunks/{skill-7RZJxGDO.cjs → skill-BDswKf84.cjs} +2 -2
- package/dist/cli-chunks/{version-COTSItDf.cjs → version-Dl0HQVTu.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-Be8jnz2C.js +224 -0
- package/dist/devtools/browser-dev-host/assets/desktop-app-launch-z3rWAJJc.js +6 -0
- package/dist/devtools/browser-dev-host/assets/index-CvUCSIVI.js +574 -0
- package/dist/devtools/browser-dev-host/assets/index-DQgWBZbX.css +1 -0
- package/dist/devtools/browser-dev-host/index.html +3 -3
- package/dist/index.cjs.js +149 -4
- package/dist/index.esm.js +149 -5
- package/dist/miniapp-publish.cjs.js +64 -1
- package/dist/miniapp-publish.esm.js +63 -2
- package/dist/protocol.cjs.js +51 -5
- package/dist/protocol.esm.js +51 -5
- package/dist/vite.cjs.js +74 -9
- package/dist/vite.esm.js +74 -9
- package/package.json +5 -5
- package/skill/SKILL.md +7 -0
- package/skill/skill.json +5 -5
- package/types/index.d.ts +140 -4
- package/types/miniapp-publish/index.d.ts +14 -3
- package/types/vite/index.d.ts +2 -0
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-CHdD15qt.js +0 -221
- package/dist/devtools/browser-dev-host/assets/desktop-app-launch-az2quV7I.js +0 -13
- package/dist/devtools/browser-dev-host/assets/index-D0XGMYIr.css +0 -1
- package/dist/devtools/browser-dev-host/assets/index-o5r5oqtq.js +0 -567
package/dist/protocol.esm.js
CHANGED
|
@@ -29,6 +29,19 @@ const SDK_LOCATION_REPORT_METHOD = 'sdk.location.report';
|
|
|
29
29
|
const SDK_CSP_VIOLATION_METHOD = 'sdk.csp.violation';
|
|
30
30
|
const MINI_PROGRAM_OPERATION_PROGRESS_METHOD = 'operation.progress';
|
|
31
31
|
|
|
32
|
+
const POST_READ_METHODS = [
|
|
33
|
+
'post.get',
|
|
34
|
+
'post.comments.list',
|
|
35
|
+
'post.watch',
|
|
36
|
+
];
|
|
37
|
+
const POST_WRITE_METHODS = [
|
|
38
|
+
'post.setLiked',
|
|
39
|
+
'post.setFavorited',
|
|
40
|
+
'post.comments.openEditor',
|
|
41
|
+
'post.comments.delete',
|
|
42
|
+
'post.comments.setLiked',
|
|
43
|
+
];
|
|
44
|
+
|
|
32
45
|
/** 游戏资料内部 wire:业务方法由 SDK 映射为精确资源请求。 */
|
|
33
46
|
const USER_GAMES_GET_OVERVIEW_METHOD = 'user.games.getOverview';
|
|
34
47
|
const USER_DATA_QUERY_METHOD = 'user.data.query';
|
|
@@ -139,6 +152,20 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
|
|
|
139
152
|
* 仅表示无需 Manifest 权限声明,不表示绕过参数校验、Host 能力、可信手势或业务策略。
|
|
140
153
|
*/
|
|
141
154
|
const MINI_PROGRAM_PROTOCOL_CAPABILITIES = [
|
|
155
|
+
...POST_READ_METHODS.map((method) => ({
|
|
156
|
+
method,
|
|
157
|
+
module: 'post',
|
|
158
|
+
capability: method,
|
|
159
|
+
requirement: { kind: 'all', permissions: ['post'] },
|
|
160
|
+
risk: 'medium',
|
|
161
|
+
})),
|
|
162
|
+
...POST_WRITE_METHODS.map((method) => ({
|
|
163
|
+
method,
|
|
164
|
+
module: 'post',
|
|
165
|
+
capability: method,
|
|
166
|
+
requirement: { kind: 'all', permissions: ['post'] },
|
|
167
|
+
risk: 'high',
|
|
168
|
+
})),
|
|
142
169
|
...[GAME_SAVES_LIST_METHOD, GAME_SAVES_SYNC_METHOD, GAME_SAVES_GET_FILE_METHOD, GAME_SAVES_READ_PARSED_DATA_METHOD].map((method) => ({
|
|
143
170
|
method,
|
|
144
171
|
module: 'gameSaves',
|
|
@@ -231,7 +258,13 @@ const MINI_PROGRAM_PROTOCOL_CAPABILITIES = [
|
|
|
231
258
|
requirement: { kind: 'all', permissions: ['share'] },
|
|
232
259
|
risk: 'medium',
|
|
233
260
|
},
|
|
234
|
-
{
|
|
261
|
+
{
|
|
262
|
+
method: SHARE_SCREENSHOT_LONG_METHOD,
|
|
263
|
+
module: 'share',
|
|
264
|
+
capability: SHARE_SCREENSHOT_LONG_METHOD,
|
|
265
|
+
requirement: { kind: 'all', permissions: ['share'] },
|
|
266
|
+
risk: 'medium',
|
|
267
|
+
},
|
|
235
268
|
{
|
|
236
269
|
method: VIEWPORT_GET_WINDOW_INFO_METHOD,
|
|
237
270
|
module: 'viewport',
|
|
@@ -524,8 +557,8 @@ const MINI_PROGRAM_PROTOCOL_CAPABILITIES = [
|
|
|
524
557
|
* `code` 与字符串 `message`。该最低结构允许 `payload` 与合法 `error` 同时存在,终态语义由消费端决定。
|
|
525
558
|
* - 普通 `event`(v1/v2):`method` 非空、`error` 必须为 `undefined`,`id` 可省略或为非空字符串;事件名和
|
|
526
559
|
* `payload` 不在此处校验。
|
|
527
|
-
* - `operation.progress` 与 `cancel` 只接受 v2。progress 还要求非空 `id`
|
|
528
|
-
* prepare
|
|
560
|
+
* - `operation.progress` 与 `cancel` 只接受 v2。progress 还要求非空 `id` 和受支持的下载、companion
|
|
561
|
+
* prepare 或关联帖订阅就绪 payload;cancel 要求非空 `id`,且 `method`、`payload`、`error` 都必须为 `undefined`。
|
|
529
562
|
*
|
|
530
563
|
* 返回 `true` 只表示 wire envelope 可识别,不建立信任或授权边界。该函数不会校验
|
|
531
564
|
* `MessageEvent.source` / `origin`,只检查 nonce 非空而不会与当前 iframe 的预期 nonce 比较,也不会确认
|
|
@@ -1435,7 +1468,9 @@ function isMiniProgramCompanionPrepareProgress(value) {
|
|
|
1435
1468
|
hasOnlyKeys(value, ['phase', 'processed', 'total']));
|
|
1436
1469
|
}
|
|
1437
1470
|
function isMiniProgramOperationProgressPayload(value) {
|
|
1438
|
-
return isMiniProgramDownloadProgressPayload(value) ||
|
|
1471
|
+
return (isMiniProgramDownloadProgressPayload(value) ||
|
|
1472
|
+
isMiniProgramCompanionPrepareProgress(value) ||
|
|
1473
|
+
(isRecord$5(value) && hasOnlyKeys(value, ['watching']) && value.watching === true));
|
|
1439
1474
|
}
|
|
1440
1475
|
function isSDKHandshakePayload(value) {
|
|
1441
1476
|
return isRecord$5(value) && isNonEmptyString$1(value.href) && typeof value.userAgent === 'string' && isNonEmptyString$1(value.sdkVersion);
|
|
@@ -1671,6 +1706,7 @@ const MINI_PROGRAM_PERMISSION_KEYS = [
|
|
|
1671
1706
|
'appProtocol',
|
|
1672
1707
|
'workspaceCards',
|
|
1673
1708
|
'user_game_data',
|
|
1709
|
+
'post',
|
|
1674
1710
|
];
|
|
1675
1711
|
new Set(MINI_PROGRAM_PERMISSION_KEYS);
|
|
1676
1712
|
|
|
@@ -1753,6 +1789,7 @@ const MANAGED_RUNTIME_PERMISSION_KEYS = new Set(MINI_PROGRAM_PERMISSION_KEYS);
|
|
|
1753
1789
|
* - `appProtocol`
|
|
1754
1790
|
* - `workspaceCards`
|
|
1755
1791
|
* - `user_game_data`
|
|
1792
|
+
* - `post`
|
|
1756
1793
|
*
|
|
1757
1794
|
* 匹配大小写敏感且按原字符串执行。该 guard 不 trim,因此 `' network '` 返回 `false`;历史权限 key
|
|
1758
1795
|
* `network.request` 也返回 `false`,即使同名 capability method 仍是公开 method。消费完整 schema v1 权限快照时
|
|
@@ -1821,6 +1858,7 @@ function isManagedMiniProgramRuntimePermissionKey(key) {
|
|
|
1821
1858
|
* 必须是已发布的精确资源 key(见 `USER_GAME_DATA_RESOURCE_KEYS`),重复或未知项会让整份
|
|
1822
1859
|
* snapshot 失败;返回值只复制校验后的 `resources` 数组,不接受 `*`、前缀或未开放 key。
|
|
1823
1860
|
* 空数组是合法的「未声明任何资源」,它不会授予任何资源级访问。
|
|
1861
|
+
* `post` 必须显式包含 `read`、`write` 两个 boolean,分别控制读取和互动;解析后丢弃其他字段。
|
|
1824
1862
|
* 其余当前权限是无配置项权限,输入 config 可以缺失、为 `null` 或 `{}`,并统一输出 `{}`;
|
|
1825
1863
|
* 非空对象、数组或其他值会使整个 snapshot 无效。Runtime snapshot 必须显式包含
|
|
1826
1864
|
* network 的有效 boolean,即使 Manifest 目录把省略 `useOfficialDomain` 的开发者默认值定义为
|
|
@@ -1833,7 +1871,7 @@ function isManagedMiniProgramRuntimePermissionKey(key) {
|
|
|
1833
1871
|
* `valid: true` 只表示 snapshot 可安全消费,不代表 entry 已启用,更不代表某个 capability 已获
|
|
1834
1872
|
* 授权。Runtime consumer 应先查 {@link MINI_PROGRAM_PROTOCOL_CAPABILITIES} 中目标 method 的
|
|
1835
1873
|
* `requirement`:`kind: 'none'` 不读取权限;`kind: 'all'` 要求列出的每个 canonical entry 都存在
|
|
1836
|
-
* 且 `status === 'enabled'
|
|
1874
|
+
* 且 `status === 'enabled'`;`post` 还要求方法对应的 `config.read` 或 `config.write` 为 true。之后仍需通过 Host capability、可信手势、用户授权、参数和业务
|
|
1837
1875
|
* policy。当前 Runtime 对 `valid: false` 按空权限表 fail closed,受保护 method 会得到
|
|
1838
1876
|
* `PERMISSION_NOT_IN_SNAPSHOT`,而不是沿用输入中的部分 enabled entry。
|
|
1839
1877
|
*
|
|
@@ -1904,6 +1942,14 @@ function parseMiniProgramRuntimePermissions(snapshot) {
|
|
|
1904
1942
|
};
|
|
1905
1943
|
continue;
|
|
1906
1944
|
}
|
|
1945
|
+
if (key === 'post') {
|
|
1946
|
+
const config = rawEntry.config;
|
|
1947
|
+
if (!isRecord$3(config) || typeof config.read !== 'boolean' || typeof config.write !== 'boolean') {
|
|
1948
|
+
return { valid: false, permissions: {} };
|
|
1949
|
+
}
|
|
1950
|
+
permissions[key] = { key, status: rawEntry.status, config: { read: config.read, write: config.write } };
|
|
1951
|
+
continue;
|
|
1952
|
+
}
|
|
1907
1953
|
if (key === 'user_game_data') {
|
|
1908
1954
|
const config = rawEntry.config;
|
|
1909
1955
|
if (!isRecord$3(config))
|
package/dist/vite.cjs.js
CHANGED
|
@@ -57,6 +57,19 @@ const MINI_PROGRAM_MESSAGE_VERSION = 2;
|
|
|
57
57
|
*/
|
|
58
58
|
const MINI_PROGRAM_BRIDGE_NONCE_PARAM = 'hb_mini_bridge_nonce';
|
|
59
59
|
|
|
60
|
+
const POST_READ_METHODS = [
|
|
61
|
+
'post.get',
|
|
62
|
+
'post.comments.list',
|
|
63
|
+
'post.watch',
|
|
64
|
+
];
|
|
65
|
+
const POST_WRITE_METHODS = [
|
|
66
|
+
'post.setLiked',
|
|
67
|
+
'post.setFavorited',
|
|
68
|
+
'post.comments.openEditor',
|
|
69
|
+
'post.comments.delete',
|
|
70
|
+
'post.comments.setLiked',
|
|
71
|
+
];
|
|
72
|
+
|
|
60
73
|
/** 游戏资料内部 wire:业务方法由 SDK 映射为精确资源请求。 */
|
|
61
74
|
const USER_GAMES_GET_OVERVIEW_METHOD = 'user.games.getOverview';
|
|
62
75
|
const USER_DATA_QUERY_METHOD = 'user.data.query';
|
|
@@ -167,6 +180,20 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
|
|
|
167
180
|
* 仅表示无需 Manifest 权限声明,不表示绕过参数校验、Host 能力、可信手势或业务策略。
|
|
168
181
|
*/
|
|
169
182
|
[
|
|
183
|
+
...POST_READ_METHODS.map((method) => ({
|
|
184
|
+
method,
|
|
185
|
+
module: 'post',
|
|
186
|
+
capability: method,
|
|
187
|
+
requirement: { kind: 'all', permissions: ['post'] },
|
|
188
|
+
risk: 'medium',
|
|
189
|
+
})),
|
|
190
|
+
...POST_WRITE_METHODS.map((method) => ({
|
|
191
|
+
method,
|
|
192
|
+
module: 'post',
|
|
193
|
+
capability: method,
|
|
194
|
+
requirement: { kind: 'all', permissions: ['post'] },
|
|
195
|
+
risk: 'high',
|
|
196
|
+
})),
|
|
170
197
|
...[GAME_SAVES_LIST_METHOD, GAME_SAVES_SYNC_METHOD, GAME_SAVES_GET_FILE_METHOD, GAME_SAVES_READ_PARSED_DATA_METHOD].map((method) => ({
|
|
171
198
|
method,
|
|
172
199
|
module: 'gameSaves',
|
|
@@ -259,7 +286,13 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
|
|
|
259
286
|
requirement: { kind: 'all', permissions: ['share'] },
|
|
260
287
|
risk: 'medium',
|
|
261
288
|
},
|
|
262
|
-
{
|
|
289
|
+
{
|
|
290
|
+
method: SHARE_SCREENSHOT_LONG_METHOD,
|
|
291
|
+
module: 'share',
|
|
292
|
+
capability: SHARE_SCREENSHOT_LONG_METHOD,
|
|
293
|
+
requirement: { kind: 'all', permissions: ['share'] },
|
|
294
|
+
risk: 'medium',
|
|
295
|
+
},
|
|
263
296
|
{
|
|
264
297
|
method: VIEWPORT_GET_WINDOW_INFO_METHOD,
|
|
265
298
|
module: 'viewport',
|
|
@@ -728,6 +761,7 @@ const MINI_PROGRAM_PERMISSION_KEYS = [
|
|
|
728
761
|
'appProtocol',
|
|
729
762
|
'workspaceCards',
|
|
730
763
|
'user_game_data',
|
|
764
|
+
'post',
|
|
731
765
|
];
|
|
732
766
|
const MINI_PROGRAM_PERMISSION_CATALOG = [
|
|
733
767
|
{
|
|
@@ -936,6 +970,19 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
|
|
|
936
970
|
'平台取数不授予小程序 `network` 权限;已交付的数据副本无法撤回。',
|
|
937
971
|
],
|
|
938
972
|
},
|
|
973
|
+
{
|
|
974
|
+
key: 'post',
|
|
975
|
+
name: '关联帖子',
|
|
976
|
+
description: '读取关联帖子与评论,或以当前用户身份互动并打开社区原生编辑器。',
|
|
977
|
+
access: 'declaration',
|
|
978
|
+
risk: 'high',
|
|
979
|
+
config: {
|
|
980
|
+
read: { type: 'boolean', required: false, default: false, description: '读取帖子、评论和订阅变化。' },
|
|
981
|
+
write: { type: 'boolean', required: false, default: false, description: '点赞、收藏、删除评论及打开社区原生编辑器。' },
|
|
982
|
+
},
|
|
983
|
+
methods: [...POST_READ_METHODS, ...POST_WRITE_METHODS],
|
|
984
|
+
conditions: ['显式声明 read / write,省略时为 false;写操作须由用户明确触发,继续执行社区审核和权限校验。'],
|
|
985
|
+
},
|
|
939
986
|
];
|
|
940
987
|
new Set(MINI_PROGRAM_PERMISSION_KEYS);
|
|
941
988
|
|
|
@@ -11246,7 +11293,7 @@ async function ensureBasicInfoDirectory(rootPath, relative) {
|
|
|
11246
11293
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
11247
11294
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
11248
11295
|
? undefined
|
|
11249
|
-
: '0.9.9-alpha.
|
|
11296
|
+
: '0.9.9-alpha.11';
|
|
11250
11297
|
|
|
11251
11298
|
/**
|
|
11252
11299
|
* network.request 诊断日志的纯脱敏工具。
|
|
@@ -12497,6 +12544,16 @@ function parseMiniappPermissions(value, options) {
|
|
|
12497
12544
|
}
|
|
12498
12545
|
useOfficialDomain = declaration.useOfficialDomain === true;
|
|
12499
12546
|
}
|
|
12547
|
+
if (key === 'post') {
|
|
12548
|
+
for (const field of ['read', 'write']) {
|
|
12549
|
+
if (declaration[field] !== undefined && typeof declaration[field] !== 'boolean') {
|
|
12550
|
+
throw new Error(`${itemLabel}.${field} 必须是 boolean`);
|
|
12551
|
+
}
|
|
12552
|
+
}
|
|
12553
|
+
if (declaration.enabled)
|
|
12554
|
+
permissions.post = { enabled: true, read: declaration.read === true, write: declaration.write === true };
|
|
12555
|
+
continue;
|
|
12556
|
+
}
|
|
12500
12557
|
if (key === 'user_game_data') {
|
|
12501
12558
|
// 即使声明关闭也校验资源清单:enabled:false 不能隐藏非法字段。
|
|
12502
12559
|
const resources = parseUserGameDataResources(declaration.resources, itemLabel);
|
|
@@ -22535,7 +22592,8 @@ const diagnosticsOwner = (diagnosticsOwnerRegistry[diagnosticsOwnerKey] ??= new
|
|
|
22535
22592
|
* @since 0.3.1
|
|
22536
22593
|
*/
|
|
22537
22594
|
function miniappManifest() {
|
|
22538
|
-
const
|
|
22595
|
+
const mobilePreview = process.env.HB_SDK_MOBILE_PREVIEW === '1';
|
|
22596
|
+
const includeCompanions = !mobilePreview && process.env.HB_SDK_SKIP_COMPANIONS !== '1';
|
|
22539
22597
|
const diagnosticsSessionId = process.env.HB_SDK_DEV_DIAGNOSTICS_SESSION_ID;
|
|
22540
22598
|
const managedDiagnostics = diagnosticsSessionId ? getDevDiagnosticsSession(diagnosticsSessionId) : undefined;
|
|
22541
22599
|
if (diagnosticsSessionId && !managedDiagnostics)
|
|
@@ -22575,7 +22633,7 @@ function miniappManifest() {
|
|
|
22575
22633
|
}
|
|
22576
22634
|
return {
|
|
22577
22635
|
...(config.base === undefined ? { base: './' } : {}),
|
|
22578
|
-
...(buildTargets ? { build: { target: buildTargets } } : {}),
|
|
22636
|
+
...(buildTargets ? { build: { target: buildTargets, ...(mobilePreview ? { sourcemap: false, emptyOutDir: true } : {}) } } : {}),
|
|
22579
22637
|
define: {
|
|
22580
22638
|
[sdkVersionBuildConstant]: JSON.stringify(resolveSdkVersion()),
|
|
22581
22639
|
},
|
|
@@ -22941,6 +22999,9 @@ function miniappManifest() {
|
|
|
22941
22999
|
if (isLegacyMobileTemplatePlatforms(platforms))
|
|
22942
23000
|
this.warn(getLegacyMobileTemplatePlatformsNotice());
|
|
22943
23001
|
const parsedPermissions = readMiniappPermissionsFromPackageJson(root, sdkVersion);
|
|
23002
|
+
// 手机构建与其独立签发的开发快照使用相同权限,不携带桌面 Companion。
|
|
23003
|
+
if (mobilePreview && parsedPermissions.permissions)
|
|
23004
|
+
delete parsedPermissions.permissions.companion;
|
|
22944
23005
|
const windowDeclaration = readMiniappWindowFromPackageJson(root);
|
|
22945
23006
|
const companionConfig = readMiniappCompanionsFromPackageJson(root);
|
|
22946
23007
|
const companionDeclarations = includeCompanions ? companionConfig.declarations : undefined;
|
|
@@ -23183,8 +23244,7 @@ function resolveHmrWebSocketUrls(resolved, server) {
|
|
|
23183
23244
|
const urls = [...(server?.resolvedUrls?.local ?? []), ...(server?.resolvedUrls?.network ?? [])];
|
|
23184
23245
|
if (urls.length === 0) {
|
|
23185
23246
|
const configuredHost = resolved.server.host;
|
|
23186
|
-
const host = typeof configuredHost === 'string' && configuredHost !== '0.0.0.0' && configuredHost !== '::'
|
|
23187
|
-
? configuredHost : '127.0.0.1';
|
|
23247
|
+
const host = typeof configuredHost === 'string' && configuredHost !== '0.0.0.0' && configuredHost !== '::' ? configuredHost : '127.0.0.1';
|
|
23188
23248
|
const address = server?.httpServer?.address();
|
|
23189
23249
|
const port = address && typeof address !== 'string' ? address.port : resolved.server.port;
|
|
23190
23250
|
const url = createDeviceLogUploadUrl(resolved.server.https ? 'https' : 'http', host, port);
|
|
@@ -23202,9 +23262,14 @@ function resolveHmrWebSocketUrls(resolved, server) {
|
|
|
23202
23262
|
// 与 Vite client 一致:显式 clientPort/port 优先,否则从加载入口推导。
|
|
23203
23263
|
const port = options.clientPort || options.port || source.port;
|
|
23204
23264
|
const endpoint = new URL(`${protocol}://${normalizedHost}${port ? `:${port}` : ''}`);
|
|
23205
|
-
if (!['ws:', 'wss:'].includes(endpoint.protocol) ||
|
|
23206
|
-
|
|
23207
|
-
|
|
23265
|
+
if (!['ws:', 'wss:'].includes(endpoint.protocol) ||
|
|
23266
|
+
endpoint.hostname.includes('*') ||
|
|
23267
|
+
['0.0.0.0', '[::]'].includes(endpoint.hostname) ||
|
|
23268
|
+
endpoint.username ||
|
|
23269
|
+
endpoint.password ||
|
|
23270
|
+
endpoint.pathname !== '/' ||
|
|
23271
|
+
endpoint.search ||
|
|
23272
|
+
endpoint.hash)
|
|
23208
23273
|
return [];
|
|
23209
23274
|
return [endpoint.origin];
|
|
23210
23275
|
}
|
package/dist/vite.esm.js
CHANGED
|
@@ -54,6 +54,19 @@ const MINI_PROGRAM_MESSAGE_VERSION = 2;
|
|
|
54
54
|
*/
|
|
55
55
|
const MINI_PROGRAM_BRIDGE_NONCE_PARAM = 'hb_mini_bridge_nonce';
|
|
56
56
|
|
|
57
|
+
const POST_READ_METHODS = [
|
|
58
|
+
'post.get',
|
|
59
|
+
'post.comments.list',
|
|
60
|
+
'post.watch',
|
|
61
|
+
];
|
|
62
|
+
const POST_WRITE_METHODS = [
|
|
63
|
+
'post.setLiked',
|
|
64
|
+
'post.setFavorited',
|
|
65
|
+
'post.comments.openEditor',
|
|
66
|
+
'post.comments.delete',
|
|
67
|
+
'post.comments.setLiked',
|
|
68
|
+
];
|
|
69
|
+
|
|
57
70
|
/** 游戏资料内部 wire:业务方法由 SDK 映射为精确资源请求。 */
|
|
58
71
|
const USER_GAMES_GET_OVERVIEW_METHOD = 'user.games.getOverview';
|
|
59
72
|
const USER_DATA_QUERY_METHOD = 'user.data.query';
|
|
@@ -164,6 +177,20 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
|
|
|
164
177
|
* 仅表示无需 Manifest 权限声明,不表示绕过参数校验、Host 能力、可信手势或业务策略。
|
|
165
178
|
*/
|
|
166
179
|
[
|
|
180
|
+
...POST_READ_METHODS.map((method) => ({
|
|
181
|
+
method,
|
|
182
|
+
module: 'post',
|
|
183
|
+
capability: method,
|
|
184
|
+
requirement: { kind: 'all', permissions: ['post'] },
|
|
185
|
+
risk: 'medium',
|
|
186
|
+
})),
|
|
187
|
+
...POST_WRITE_METHODS.map((method) => ({
|
|
188
|
+
method,
|
|
189
|
+
module: 'post',
|
|
190
|
+
capability: method,
|
|
191
|
+
requirement: { kind: 'all', permissions: ['post'] },
|
|
192
|
+
risk: 'high',
|
|
193
|
+
})),
|
|
167
194
|
...[GAME_SAVES_LIST_METHOD, GAME_SAVES_SYNC_METHOD, GAME_SAVES_GET_FILE_METHOD, GAME_SAVES_READ_PARSED_DATA_METHOD].map((method) => ({
|
|
168
195
|
method,
|
|
169
196
|
module: 'gameSaves',
|
|
@@ -256,7 +283,13 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
|
|
|
256
283
|
requirement: { kind: 'all', permissions: ['share'] },
|
|
257
284
|
risk: 'medium',
|
|
258
285
|
},
|
|
259
|
-
{
|
|
286
|
+
{
|
|
287
|
+
method: SHARE_SCREENSHOT_LONG_METHOD,
|
|
288
|
+
module: 'share',
|
|
289
|
+
capability: SHARE_SCREENSHOT_LONG_METHOD,
|
|
290
|
+
requirement: { kind: 'all', permissions: ['share'] },
|
|
291
|
+
risk: 'medium',
|
|
292
|
+
},
|
|
260
293
|
{
|
|
261
294
|
method: VIEWPORT_GET_WINDOW_INFO_METHOD,
|
|
262
295
|
module: 'viewport',
|
|
@@ -725,6 +758,7 @@ const MINI_PROGRAM_PERMISSION_KEYS = [
|
|
|
725
758
|
'appProtocol',
|
|
726
759
|
'workspaceCards',
|
|
727
760
|
'user_game_data',
|
|
761
|
+
'post',
|
|
728
762
|
];
|
|
729
763
|
const MINI_PROGRAM_PERMISSION_CATALOG = [
|
|
730
764
|
{
|
|
@@ -933,6 +967,19 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
|
|
|
933
967
|
'平台取数不授予小程序 `network` 权限;已交付的数据副本无法撤回。',
|
|
934
968
|
],
|
|
935
969
|
},
|
|
970
|
+
{
|
|
971
|
+
key: 'post',
|
|
972
|
+
name: '关联帖子',
|
|
973
|
+
description: '读取关联帖子与评论,或以当前用户身份互动并打开社区原生编辑器。',
|
|
974
|
+
access: 'declaration',
|
|
975
|
+
risk: 'high',
|
|
976
|
+
config: {
|
|
977
|
+
read: { type: 'boolean', required: false, default: false, description: '读取帖子、评论和订阅变化。' },
|
|
978
|
+
write: { type: 'boolean', required: false, default: false, description: '点赞、收藏、删除评论及打开社区原生编辑器。' },
|
|
979
|
+
},
|
|
980
|
+
methods: [...POST_READ_METHODS, ...POST_WRITE_METHODS],
|
|
981
|
+
conditions: ['显式声明 read / write,省略时为 false;写操作须由用户明确触发,继续执行社区审核和权限校验。'],
|
|
982
|
+
},
|
|
936
983
|
];
|
|
937
984
|
new Set(MINI_PROGRAM_PERMISSION_KEYS);
|
|
938
985
|
|
|
@@ -11243,7 +11290,7 @@ async function ensureBasicInfoDirectory(rootPath, relative) {
|
|
|
11243
11290
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
11244
11291
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
11245
11292
|
? undefined
|
|
11246
|
-
: '0.9.9-alpha.
|
|
11293
|
+
: '0.9.9-alpha.11';
|
|
11247
11294
|
|
|
11248
11295
|
/**
|
|
11249
11296
|
* network.request 诊断日志的纯脱敏工具。
|
|
@@ -12494,6 +12541,16 @@ function parseMiniappPermissions(value, options) {
|
|
|
12494
12541
|
}
|
|
12495
12542
|
useOfficialDomain = declaration.useOfficialDomain === true;
|
|
12496
12543
|
}
|
|
12544
|
+
if (key === 'post') {
|
|
12545
|
+
for (const field of ['read', 'write']) {
|
|
12546
|
+
if (declaration[field] !== undefined && typeof declaration[field] !== 'boolean') {
|
|
12547
|
+
throw new Error(`${itemLabel}.${field} 必须是 boolean`);
|
|
12548
|
+
}
|
|
12549
|
+
}
|
|
12550
|
+
if (declaration.enabled)
|
|
12551
|
+
permissions.post = { enabled: true, read: declaration.read === true, write: declaration.write === true };
|
|
12552
|
+
continue;
|
|
12553
|
+
}
|
|
12497
12554
|
if (key === 'user_game_data') {
|
|
12498
12555
|
// 即使声明关闭也校验资源清单:enabled:false 不能隐藏非法字段。
|
|
12499
12556
|
const resources = parseUserGameDataResources(declaration.resources, itemLabel);
|
|
@@ -22532,7 +22589,8 @@ const diagnosticsOwner = (diagnosticsOwnerRegistry[diagnosticsOwnerKey] ??= new
|
|
|
22532
22589
|
* @since 0.3.1
|
|
22533
22590
|
*/
|
|
22534
22591
|
function miniappManifest() {
|
|
22535
|
-
const
|
|
22592
|
+
const mobilePreview = process.env.HB_SDK_MOBILE_PREVIEW === '1';
|
|
22593
|
+
const includeCompanions = !mobilePreview && process.env.HB_SDK_SKIP_COMPANIONS !== '1';
|
|
22536
22594
|
const diagnosticsSessionId = process.env.HB_SDK_DEV_DIAGNOSTICS_SESSION_ID;
|
|
22537
22595
|
const managedDiagnostics = diagnosticsSessionId ? getDevDiagnosticsSession(diagnosticsSessionId) : undefined;
|
|
22538
22596
|
if (diagnosticsSessionId && !managedDiagnostics)
|
|
@@ -22572,7 +22630,7 @@ function miniappManifest() {
|
|
|
22572
22630
|
}
|
|
22573
22631
|
return {
|
|
22574
22632
|
...(config.base === undefined ? { base: './' } : {}),
|
|
22575
|
-
...(buildTargets ? { build: { target: buildTargets } } : {}),
|
|
22633
|
+
...(buildTargets ? { build: { target: buildTargets, ...(mobilePreview ? { sourcemap: false, emptyOutDir: true } : {}) } } : {}),
|
|
22576
22634
|
define: {
|
|
22577
22635
|
[sdkVersionBuildConstant]: JSON.stringify(resolveSdkVersion()),
|
|
22578
22636
|
},
|
|
@@ -22938,6 +22996,9 @@ function miniappManifest() {
|
|
|
22938
22996
|
if (isLegacyMobileTemplatePlatforms(platforms))
|
|
22939
22997
|
this.warn(getLegacyMobileTemplatePlatformsNotice());
|
|
22940
22998
|
const parsedPermissions = readMiniappPermissionsFromPackageJson(root, sdkVersion);
|
|
22999
|
+
// 手机构建与其独立签发的开发快照使用相同权限,不携带桌面 Companion。
|
|
23000
|
+
if (mobilePreview && parsedPermissions.permissions)
|
|
23001
|
+
delete parsedPermissions.permissions.companion;
|
|
22941
23002
|
const windowDeclaration = readMiniappWindowFromPackageJson(root);
|
|
22942
23003
|
const companionConfig = readMiniappCompanionsFromPackageJson(root);
|
|
22943
23004
|
const companionDeclarations = includeCompanions ? companionConfig.declarations : undefined;
|
|
@@ -23180,8 +23241,7 @@ function resolveHmrWebSocketUrls(resolved, server) {
|
|
|
23180
23241
|
const urls = [...(server?.resolvedUrls?.local ?? []), ...(server?.resolvedUrls?.network ?? [])];
|
|
23181
23242
|
if (urls.length === 0) {
|
|
23182
23243
|
const configuredHost = resolved.server.host;
|
|
23183
|
-
const host = typeof configuredHost === 'string' && configuredHost !== '0.0.0.0' && configuredHost !== '::'
|
|
23184
|
-
? configuredHost : '127.0.0.1';
|
|
23244
|
+
const host = typeof configuredHost === 'string' && configuredHost !== '0.0.0.0' && configuredHost !== '::' ? configuredHost : '127.0.0.1';
|
|
23185
23245
|
const address = server?.httpServer?.address();
|
|
23186
23246
|
const port = address && typeof address !== 'string' ? address.port : resolved.server.port;
|
|
23187
23247
|
const url = createDeviceLogUploadUrl(resolved.server.https ? 'https' : 'http', host, port);
|
|
@@ -23199,9 +23259,14 @@ function resolveHmrWebSocketUrls(resolved, server) {
|
|
|
23199
23259
|
// 与 Vite client 一致:显式 clientPort/port 优先,否则从加载入口推导。
|
|
23200
23260
|
const port = options.clientPort || options.port || source.port;
|
|
23201
23261
|
const endpoint = new URL(`${protocol}://${normalizedHost}${port ? `:${port}` : ''}`);
|
|
23202
|
-
if (!['ws:', 'wss:'].includes(endpoint.protocol) ||
|
|
23203
|
-
|
|
23204
|
-
|
|
23262
|
+
if (!['ws:', 'wss:'].includes(endpoint.protocol) ||
|
|
23263
|
+
endpoint.hostname.includes('*') ||
|
|
23264
|
+
['0.0.0.0', '[::]'].includes(endpoint.hostname) ||
|
|
23265
|
+
endpoint.username ||
|
|
23266
|
+
endpoint.password ||
|
|
23267
|
+
endpoint.pathname !== '/' ||
|
|
23268
|
+
endpoint.search ||
|
|
23269
|
+
endpoint.hash)
|
|
23205
23270
|
return [];
|
|
23206
23271
|
return [endpoint.origin];
|
|
23207
23272
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heybox/hb-sdk",
|
|
3
|
-
"version": "0.9.9-alpha.
|
|
3
|
+
"version": "0.9.9-alpha.11",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"./src/index.ts",
|
|
6
6
|
"./src/core/singleton.ts",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"undici": "^7.28.0",
|
|
89
89
|
"ws": "^8.18.0",
|
|
90
90
|
"sharp": "^0.34.5",
|
|
91
|
-
"@heybox/hb-sdk-protocol": "0.9.9-alpha.
|
|
91
|
+
"@heybox/hb-sdk-protocol": "0.9.9-alpha.11"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"vite": ">=5"
|
|
@@ -140,10 +140,10 @@
|
|
|
140
140
|
"@ai-desktop/view-contract": "file:../hb-sdk-protocol/vendor/view-contract-2.2.2-6ac49bbf6410.tgz",
|
|
141
141
|
"rollup-plugin-dts": "6.4.0",
|
|
142
142
|
"playwright-core": "1.64.1",
|
|
143
|
-
"@heybox-domain/heybox-vue3-ui": "~0.1.0",
|
|
144
|
-
"@heybox/hb-sdk-runtime": "~0.9.9-alpha.0",
|
|
145
143
|
"@heybox-domain/heybox-theme": "~0.1.0",
|
|
146
|
-
"@heybox/hb-
|
|
144
|
+
"@heybox/hb-sdk-runtime": "~0.9.9-alpha.11",
|
|
145
|
+
"@heybox-domain/heybox-vue3-ui": "~0.1.0",
|
|
146
|
+
"@heybox/hb-api": "~1.28.31",
|
|
147
147
|
"@heybox/runtime": "~0.2.2",
|
|
148
148
|
"@heybox/runtime-policy": "~0.2.2",
|
|
149
149
|
"@heybox/runtime-transport-fetch": "~0.2.2"
|
package/skill/SKILL.md
CHANGED
|
@@ -70,6 +70,13 @@ After the mini-program purpose is clear, after completing its main functionality
|
|
|
70
70
|
- Search results are candidates, not proof that binding is valid. Never guess appids, assume every id is a Steam App ID, or choose the first result merely by ranking. Ask a short question when names, editions or platforms remain ambiguous. Tools without a specific game may remain unbound. Do not invent a separate project category or persist a reminder preference. Do not clear existing bindings without intended removal. Explain an unresolved binding decision without changing category to bypass warnings. A deferred or ambiguous decision must remain unresolved so the next publishing guide can ask again.
|
|
71
71
|
- Treat metadata warnings as actionable suggestions and fix confirmed omissions within the authorized scope. Missing optional metadata must not block development or publication, and a warning does not authorize remote publication. Leave invalid-value errors to the documented validation rules.
|
|
72
72
|
|
|
73
|
+
## Proactive PC Adaptation
|
|
74
|
+
|
|
75
|
+
- After the purpose is clear, assess whether desktop use benefits the project (for example game reference, build planning, or data tools). Proactively explain that Workshop mini-programs can also target PC, and offer to help adapt suitable projects. Avoid repeating promotion in unrelated answers.
|
|
76
|
+
- Read the PC adaptation guide selected from the fresh canonical index for the maintained client download entry, platform configuration, desktop preview, and real-client validation. Share that download entry when recommending PC use; never guess installer URLs or supported systems.
|
|
77
|
+
- Before build or audit submission, check desktop suitability even when the template already declares desktop platforms. Validate responsive windows, mouse/keyboard interaction, and the actual SDK capabilities used on each claimed platform. Browser preview and successful builds do not establish real-client support.
|
|
78
|
+
- Explain any target declaration needed for local client debugging, and keep release platforms limited to those adapted and verified. Do not silently add platforms or claim verification without evidence. Respect an explicit mobile-only decision, keep suggestions non-blocking, and report any unverified desktop declarations before submission.
|
|
79
|
+
|
|
73
80
|
## Troubleshooting and Proactive Feedback
|
|
74
81
|
|
|
75
82
|
- Investigate and fix application code, configuration, dependency-version, and permission errors using the official documentation first. A single error does not establish an SDK defect. Do not misclassify undeclared permissions, missing authorization, or platform limitations as SDK defects.
|
package/skill/skill.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hb-sdk",
|
|
3
|
-
"skillVersion": "0.9.9-alpha.
|
|
3
|
+
"skillVersion": "0.9.9-alpha.11+skill.ebdc6208c358",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.9.9-alpha.
|
|
7
|
-
"compatibility": "0.9.9-alpha.
|
|
6
|
+
"version": "0.9.9-alpha.11",
|
|
7
|
+
"compatibility": "0.9.9-alpha.11"
|
|
8
8
|
},
|
|
9
9
|
"distribution": {
|
|
10
10
|
"type": "npm",
|
|
11
11
|
"package": "@heybox/hb-sdk",
|
|
12
|
-
"version": "0.9.9-alpha.
|
|
12
|
+
"version": "0.9.9-alpha.11",
|
|
13
13
|
"path": "skill"
|
|
14
14
|
},
|
|
15
|
-
"integrity": "sha256-
|
|
15
|
+
"integrity": "sha256-ebdc6208c35883b0fccf9bb50a43e096c9b89644a4cd000e0d931bdaf3d13d64"
|
|
16
16
|
}
|