@heybox/hb-sdk 0.9.0-alpha.2 → 0.9.0-alpha.3
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 +6 -0
- package/README.md +5 -0
- package/dist/cli-chunks/{build-CvxoPTJb.cjs → build-C4d4WXYT.cjs} +5 -5
- package/dist/cli-chunks/{context-ChyajSZV.cjs → context-mt_ERryB.cjs} +2 -2
- package/dist/cli-chunks/{create-vXFVQGD7.cjs → create-LfZ8OhT6.cjs} +1 -1
- package/dist/cli-chunks/{dev-QH1jaFr1.cjs → dev-lgUgVorS.cjs} +9 -9
- package/dist/cli-chunks/{doctor-CU25P_q2.cjs → doctor-BSJnY0Bu.cjs} +1 -1
- package/dist/cli-chunks/{index-QY5q1rWs.cjs → index-BtqxUixL.cjs} +15 -15
- package/dist/cli-chunks/{index-I2MJ0S1h.cjs → index-DVALw2rx.cjs} +2 -2
- package/dist/cli-chunks/{index.esm-81ZfQF1o.cjs → index.esm-Deim9BX8.cjs} +7 -7
- package/dist/cli-chunks/{login-DCNzO2CY.cjs → login-TIFXGbKv.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-BA81QqiJ.cjs → project-vite-DSBP8NLj.cjs} +1 -1
- package/dist/cli-chunks/{remote-CBuPWvcD.cjs → remote-DyGb3YBA.cjs} +83 -17
- package/dist/cli-chunks/{runtime-gate-C1gdlVUB.cjs → runtime-gate-CWUZK4aE.cjs} +1 -1
- package/dist/cli-chunks/{runtime-permission-env-w3sXIJU4.cjs → runtime-permission-env-DdWYFrFT.cjs} +39 -6
- package/dist/cli-chunks/{session-Dtkbu4vT.cjs → session-CWCq-oeW.cjs} +1 -1
- package/dist/cli-chunks/{skill-DKgQa7PY.cjs → skill-DQzR5fMS.cjs} +2 -2
- package/dist/cli-chunks/{version-NZ-E_XUT.cjs → version-4zRtvcVD.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/{browser-dev-host-CRdzRTKL.js → browser-dev-host-BEJTrPTS.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-Cx-1tLJI.js → desktop-app-launch-Dod9L2SF.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-DAO9aQMF.js → index-xtE6gn7j.js} +3 -3
- package/dist/devtools/browser-dev-host/index.html +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/miniapp-publish.cjs.js +38 -5
- package/dist/miniapp-publish.esm.js +38 -5
- package/dist/vite.cjs.js +1 -1
- package/dist/vite.esm.js +1 -1
- package/package.json +6 -6
- package/skill/skill.json +4 -4
- package/types/miniapp-publish/index.d.ts +13 -3
package/dist/cli-chunks/{runtime-permission-env-w3sXIJU4.cjs → runtime-permission-env-DdWYFrFT.cjs}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var version = require('./version-
|
|
5
|
+
var version = require('./version-4zRtvcVD.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
var node_async_hooks = require('node:async_hooks');
|
|
8
8
|
|
|
@@ -3608,6 +3608,7 @@ function validateGeneratedCompanions(value) {
|
|
|
3608
3608
|
return undefined;
|
|
3609
3609
|
if (!isRecord$2(value) || Object.keys(value).length === 0)
|
|
3610
3610
|
throw new Error('manifest.companions 必须是非空对象');
|
|
3611
|
+
let descriptorCount = 0;
|
|
3611
3612
|
for (const [alias, definition] of Object.entries(value)) {
|
|
3612
3613
|
if (!/^[a-z][a-z0-9-]{0,31}$/.test(alias) ||
|
|
3613
3614
|
!isRecord$2(definition) ||
|
|
@@ -3621,6 +3622,9 @@ function validateGeneratedCompanions(value) {
|
|
|
3621
3622
|
Object.keys(definition.targets).length === 0)
|
|
3622
3623
|
throw new Error(`manifest.companions.${alias} 不合法`);
|
|
3623
3624
|
for (const [target, artifact] of Object.entries(definition.targets)) {
|
|
3625
|
+
descriptorCount += 1;
|
|
3626
|
+
if (descriptorCount > 64)
|
|
3627
|
+
throw new Error('manifest.companions 最多允许 64 个 target 描述符');
|
|
3624
3628
|
if (isRecord$2(artifact) && artifact.elevation === 'required') {
|
|
3625
3629
|
throw new Error(`manifest.companions.${alias}.targets.${target}.elevation V1 仅支持 none,暂不支持管理员权限启动`);
|
|
3626
3630
|
}
|
|
@@ -12469,8 +12473,9 @@ function createMiniappArtifactFileHeader(file) {
|
|
|
12469
12473
|
* 校验服务端 session 文件映射,并计算仍需上传的文件。
|
|
12470
12474
|
*
|
|
12471
12475
|
* @param localFiles - 本地构建产物 receipt;除 `relativePath` 和 `size` 外,每项必须包含 64 位小写十六进制 `sha256`。
|
|
12472
|
-
* @param serverFiles -
|
|
12476
|
+
* @param serverFiles - 服务端签发的会话文件映射;与复用的 Companion 合起来必须覆盖本地产物。
|
|
12473
12477
|
* @param uploadedKeys - 服务端已确认上传成功的 key;每个值都必须属于当前会话,重复值会被去重。
|
|
12478
|
+
* @param reusedCompanionFiles - 已验证 Blob 引用;仅允许当前产物中的 Companion 文件。
|
|
12474
12479
|
* @returns
|
|
12475
12480
|
* 包含三个字段的对象:`files` 是按路径 UTF-8 字节序排列的全部 `{ file, key }` 映射,
|
|
12476
12481
|
* `missingFiles` 是其中尚未确认上传的映射,`uploadedKeys` 是去重后的已上传 key。
|
|
@@ -12486,15 +12491,38 @@ function createMiniappArtifactFileHeader(file) {
|
|
|
12486
12491
|
* sha256: 'a'.repeat(64),
|
|
12487
12492
|
* }],
|
|
12488
12493
|
* [],
|
|
12494
|
+
* [],
|
|
12489
12495
|
* );
|
|
12490
12496
|
*
|
|
12491
12497
|
* console.log(resolved.missingFiles.length); // 1
|
|
12492
12498
|
* ```
|
|
12493
12499
|
*/
|
|
12494
|
-
function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys) {
|
|
12500
|
+
function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys, reusedCompanionFiles) {
|
|
12495
12501
|
const preparedFiles = prepareMiniappArtifactFiles(localFiles);
|
|
12496
|
-
if (serverFiles.length !== preparedFiles.length) {
|
|
12497
|
-
throw new Error(`上传会话文件数量异常:期望 ${preparedFiles.length},实际 ${serverFiles.length}`);
|
|
12502
|
+
if (serverFiles.length + reusedCompanionFiles.length !== preparedFiles.length) {
|
|
12503
|
+
throw new Error(`上传会话文件数量异常:期望 ${preparedFiles.length},实际 ${serverFiles.length + reusedCompanionFiles.length}`);
|
|
12504
|
+
}
|
|
12505
|
+
const localByPath = new Map(preparedFiles.map((file) => [file.relativePath, file]));
|
|
12506
|
+
const reused = new Map();
|
|
12507
|
+
for (const reference of reusedCompanionFiles) {
|
|
12508
|
+
const relativePath = normalizeMiniappArtifactRelativePath(reference.relative_path);
|
|
12509
|
+
const local = localByPath.get(relativePath);
|
|
12510
|
+
if (!relativePath.startsWith('companions/') || !local) {
|
|
12511
|
+
throw new Error(`上传会话返回了不属于当前 Companion 产物的 Blob 引用:${relativePath}`);
|
|
12512
|
+
}
|
|
12513
|
+
if (reused.has(relativePath)) {
|
|
12514
|
+
throw new Error(`上传会话返回重复 Blob 引用:${relativePath}`);
|
|
12515
|
+
}
|
|
12516
|
+
if (!Number.isSafeInteger(reference.size) || reference.size < 0 || reference.size !== local.size) {
|
|
12517
|
+
throw new Error(`上传会话 Blob 文件大小与本地构建不一致:${relativePath}`);
|
|
12518
|
+
}
|
|
12519
|
+
if (!('sha256' in local) || !/^[a-f0-9]{64}$/.test(reference.sha256) || reference.sha256 !== local.sha256) {
|
|
12520
|
+
throw new Error(`上传会话 Blob 文件 SHA-256 与本地构建不一致:${relativePath}`);
|
|
12521
|
+
}
|
|
12522
|
+
if (typeof reference.blob_id !== 'string' || !reference.blob_id.trim()) {
|
|
12523
|
+
throw new Error(`上传会话 Blob 引用 ID 无效:${relativePath}`);
|
|
12524
|
+
}
|
|
12525
|
+
reused.set(relativePath, reference);
|
|
12498
12526
|
}
|
|
12499
12527
|
const mappings = new Map();
|
|
12500
12528
|
const serverSizes = new Map();
|
|
@@ -12505,6 +12533,9 @@ function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys)
|
|
|
12505
12533
|
if (mappings.has(relativePath)) {
|
|
12506
12534
|
throw new Error(`上传会话返回重复文件路径:${relativePath}`);
|
|
12507
12535
|
}
|
|
12536
|
+
if (reused.has(relativePath)) {
|
|
12537
|
+
throw new Error(`上传会话同时返回文件 key 和 Blob 引用:${relativePath}`);
|
|
12538
|
+
}
|
|
12508
12539
|
const key = String(serverFile.key || '');
|
|
12509
12540
|
if (!key) {
|
|
12510
12541
|
throw new Error(`上传会话未返回文件 key:${relativePath}`);
|
|
@@ -12525,7 +12556,8 @@ function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys)
|
|
|
12525
12556
|
serverHashes.set(relativePath, sha256);
|
|
12526
12557
|
knownKeys.add(key);
|
|
12527
12558
|
}
|
|
12528
|
-
const
|
|
12559
|
+
const sessionFiles = preparedFiles.filter((file) => !reused.has(file.relativePath));
|
|
12560
|
+
const files = sessionFiles.map((file) => {
|
|
12529
12561
|
const key = mappings.get(file.relativePath);
|
|
12530
12562
|
if (!key) {
|
|
12531
12563
|
throw new Error(`上传会话缺少文件映射:${file.relativePath}`);
|
|
@@ -12550,6 +12582,7 @@ function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys)
|
|
|
12550
12582
|
files,
|
|
12551
12583
|
missingFiles: files.filter((file) => !completed.has(file.key)),
|
|
12552
12584
|
uploadedKeys: [...completed],
|
|
12585
|
+
reusedCompanionFiles: [...reused.values()],
|
|
12553
12586
|
};
|
|
12554
12587
|
}
|
|
12555
12588
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = require('./version-
|
|
3
|
+
var version = require('./version-4zRtvcVD.cjs');
|
|
4
4
|
var fs = require('node:fs/promises');
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var childProcess = require('node:child_process');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-BtqxUixL.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('node:fs');
|
|
10
10
|
require('path');
|