@heybox/hb-sdk 0.8.2-alpha.2 → 0.8.2-alpha.6

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 (54) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/README.md +10 -3
  3. package/dist/cli-chunks/{build-bVThH3Z5.cjs → build-TOcahJhW.cjs} +5 -5
  4. package/dist/cli-chunks/{context-DpKqGnjp.cjs → context-Bk0adtVQ.cjs} +326 -104
  5. package/dist/cli-chunks/{create-BWC2343y.cjs → create-BxIgQ4SF.cjs} +5 -1
  6. package/dist/cli-chunks/{dev-t14YpHHY.cjs → dev-CyhKTGGJ.cjs} +17 -9
  7. package/dist/cli-chunks/{doctor-BWkrE0Hj.cjs → doctor-ItlNn-K2.cjs} +25 -13
  8. package/dist/cli-chunks/{index-CDtcZVWv.cjs → index-CP14FXez.cjs} +16 -18
  9. package/dist/cli-chunks/{index-D3FMcOZq.cjs → index-CjWRMwuI.cjs} +2 -2
  10. package/dist/cli-chunks/{index.esm-BrJBaJWS.cjs → index.esm-deP-KEyE.cjs} +11 -10
  11. package/dist/cli-chunks/{login-DRMl7nFH.cjs → login-4B-2nqgd.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-CXgdzIYw.cjs → project-vite-HKW4tSBX.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-ibQybNiM.cjs → remote-BLdGzViG.cjs} +80 -60
  14. package/dist/cli-chunks/runtime-gate-B_fHNic6.cjs +58 -0
  15. package/dist/cli-chunks/{runtime-gate-BWb8QIcX.cjs → runtime-permission-env-CAhESVDA.cjs} +4533 -40
  16. package/dist/cli-chunks/{session-CIoBspg-.cjs → session-COr9TQ6O.cjs} +1 -1
  17. package/dist/cli-chunks/{skill-5labzuWk.cjs → skill-DiZSczbw.cjs} +2 -2
  18. package/dist/cli-chunks/{version-QiVEs76a.cjs → version-tRrcrp9F.cjs} +1 -1
  19. package/dist/cli.cjs +1 -1
  20. package/dist/devtools/browser-dev-host/assets/browser-dev-host-CF7IQARw.js +101 -0
  21. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-B4KsgItx.js → desktop-app-launch-CQmXIMyL.js} +1 -1
  22. package/dist/devtools/browser-dev-host/assets/{index-9Nb3XhtI.js → index-DdKYO0um.js} +3 -3
  23. package/dist/devtools/browser-dev-host/index.html +2 -2
  24. package/dist/index.cjs.js +1 -1
  25. package/dist/index.esm.js +1 -1
  26. package/dist/miniapp-publish.cjs.js +8782 -0
  27. package/dist/miniapp-publish.esm.js +8778 -1
  28. package/dist/templates/vanilla-vite-js/README.md.ejs +3 -0
  29. package/dist/templates/vanilla-vite-js/assets/heybox-placeholder.png +0 -0
  30. package/dist/templates/vanilla-vite-js/package.json.ejs +3 -0
  31. package/dist/vite.cjs.js +499 -346
  32. package/dist/vite.esm.js +500 -347
  33. package/package.json +8 -7
  34. package/skill/SKILL.md +22 -124
  35. package/skill/skill.json +5 -5
  36. package/types/miniapp-manifest/basic-info-browser.d.ts +9 -0
  37. package/types/miniapp-manifest/basic-info-image-header.d.ts +6 -0
  38. package/types/miniapp-manifest/basic-info-node.d.ts +17 -0
  39. package/types/miniapp-manifest/basic-info-placeholder.d.ts +1 -0
  40. package/types/miniapp-manifest/basic-info.d.ts +12 -0
  41. package/types/miniapp-manifest/schema.d.ts +7 -1
  42. package/types/miniapp-publish/index.d.ts +8 -0
  43. package/types/skill-metadata.d.ts +2 -2
  44. package/dist/cli-chunks/runtime-permission-env-DiTeD75Q.cjs +0 -4498
  45. package/dist/devtools/browser-dev-host/assets/browser-dev-host-DxzOkljJ.js +0 -101
  46. package/skill/references/api-protocol.md +0 -317
  47. package/skill/references/api-root.md +0 -1243
  48. package/skill/references/cli.md +0 -401
  49. package/skill/references/examples.md +0 -204
  50. package/skill/references/llms-index.md +0 -24
  51. package/skill/references/recipes.md +0 -854
  52. package/skill/references/safety-boundaries.md +0 -63
  53. package/skill/references/smoke-evaluation.md +0 -26
  54. /package/types/{vite → miniapp-manifest}/runtime-gate.d.ts +0 -0
@@ -1,17 +1,20 @@
1
1
  'use strict';
2
2
 
3
+ var runtimePermissionEnv = require('./runtime-permission-env-CAhESVDA.cjs');
4
+ var context = require('./context-Bk0adtVQ.cjs');
3
5
  var promises = require('node:readline/promises');
4
- var index = require('./index-CDtcZVWv.cjs');
5
- var session = require('./session-CIoBspg-.cjs');
6
+ var index = require('./index-CP14FXez.cjs');
7
+ var session = require('./session-COr9TQ6O.cjs');
6
8
  var childProcess = require('node:child_process');
7
9
  var fs = require('node:fs');
8
10
  var fs$1 = require('node:fs/promises');
9
11
  var path = require('node:path');
10
- var runtimePermissionEnv = require('./runtime-permission-env-DiTeD75Q.cjs');
11
12
  var node_crypto = require('node:crypto');
12
13
  require('node:zlib');
13
- var runtimeGate = require('./runtime-gate-BWb8QIcX.cjs');
14
- var context = require('./context-DpKqGnjp.cjs');
14
+ var runtimeGate = require('./runtime-gate-B_fHNic6.cjs');
15
+ require('./version-tRrcrp9F.cjs');
16
+ require('node:async_hooks');
17
+ require('sharp');
15
18
  require('node:module');
16
19
  require('path');
17
20
  require('os');
@@ -24,8 +27,9 @@ require('buffer');
24
27
  require('util');
25
28
  require('fs');
26
29
  require('constants');
27
- require('./version-QiVEs76a.cjs');
28
- require('node:async_hooks');
30
+
31
+ // 脚手架开发占位图;构建可用,提审前必须替换。
32
+ const BASIC_INFO_PLACEHOLDER_SHA256 = 'd14e54b30f5e6d1bcbf51267bc82b06a0af7c333f2945bcc16b4e1adc3b123dd';
29
33
 
30
34
  async function getCDNUploadInfo(options, runtime = {}) {
31
35
  const body = new URLSearchParams();
@@ -66,29 +70,24 @@ const CREATE_USER_MINIPROGRAM_UPLOAD_SESSION_API_PATH = '/mall/developer/user_mi
66
70
  const RECORD_USER_MINIPROGRAM_UPLOAD_RESULT_API_PATH = '/mall/developer/user_miniprogram/version/upload_session/record';
67
71
  async function precheckUserMiniprogramVersion(options, runtime = {}) {
68
72
  return postUserMiniprogramVersionForm(runtimePermissionEnv.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, options, {
69
- // 展示资料由服务端沿用 last approved 或注入默认名/默认图;CLI 不传 name/icon/cover。
73
+ // 构建前轻预检不携带独立资料;权威准入读取构建 Manifest。
70
74
  ...(options.version ? { version: options.version } : {}),
71
- ...(options.source_version ? { source_version: options.source_version } : {}),
72
75
  ...(options.manifest ? { manifest: JSON.stringify(options.manifest) } : {}),
73
76
  release_note: options.releaseNote,
74
77
  auto_publish: String(options.autoPublish),
75
78
  }, runtime);
76
79
  }
77
80
  async function submitUserMiniprogramAudit(options, runtime = {}) {
78
- return postUserMiniprogramVersionForm(runtimePermissionEnv.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, options, {
79
- // 展示资料由服务端沿用 last approved 或注入默认名/默认图;CLI 不传 name/icon/cover。
80
- ...(options.manifest ? { manifest: JSON.stringify(options.manifest) } : {}),
81
- ...(options.source_version ? { source_version: options.source_version } : {}),
82
- ...(options.sessionId ? { session_id: options.sessionId } : {}),
83
- release_note: options.releaseNote,
84
- auto_publish: String(options.autoPublish),
85
- }, runtime);
81
+ return postUserMiniprogramVersionForm(runtimePermissionEnv.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, options, { session_id: options.sessionId, preflight_token: options.preflightToken }, runtime);
86
82
  }
87
83
  async function createUserMiniprogramUploadSession(options, runtime = {}) {
88
84
  return postUserMiniprogramVersionForm(CREATE_USER_MINIPROGRAM_UPLOAD_SESSION_API_PATH, options, {
89
85
  version: options.version,
90
86
  artifact_signature: options.artifactSignature,
91
87
  files: JSON.stringify(options.files),
88
+ manifest: JSON.stringify(options.manifest),
89
+ release_note: options.releaseNote,
90
+ auto_publish: String(options.autoPublish),
92
91
  }, runtime);
93
92
  }
94
93
  async function recordUserMiniprogramUploadResult(options, runtime = {}) {
@@ -275,7 +274,7 @@ function createDefaultCosClient(uploadToken, COS) {
275
274
  };
276
275
  }
277
276
  async function loadCosConstructor() {
278
- const cosModule = await Promise.resolve().then(function () { return require('./index-D3FMcOZq.cjs'); }).then(function (n) { return n.index; });
277
+ const cosModule = await Promise.resolve().then(function () { return require('./index-CjWRMwuI.cjs'); }).then(function (n) { return n.index; });
279
278
  return cosModule.default;
280
279
  }
281
280
  function formatSize(bytes) {
@@ -515,32 +514,29 @@ async function runDeployCommand(options, runtime = {}) {
515
514
  if (typeof miniProgramId !== 'string' || !miniProgramId.trim()) {
516
515
  throw new Error('未在 package.json 中找到 heybox.miniProgramId,请先配置 mini program id');
517
516
  }
518
- const fromVersion = options.fromVersion?.trim();
519
- const declaredPlatforms = fromVersion ? undefined : runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
520
- const declaredWindow = fromVersion ? undefined : runtimePermissionEnv.readMiniappWindowFromPackageJson(projectRoot);
521
- const declaredBindAppIds = fromVersion ? undefined : runtimePermissionEnv.readMiniappBindAppIdsFromPackageJson(projectRoot);
517
+ const declaredPlatforms = runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
518
+ const declaredWindow = runtimePermissionEnv.readMiniappWindowFromPackageJson(projectRoot);
519
+ const declaredBindAppIds = runtimePermissionEnv.readMiniappBindAppIdsFromPackageJson(projectRoot);
522
520
  const releaseNote = await resolveDeployReleaseNote(options, runtime);
523
521
  const session$1 = await logger.task('正在校验 Heybox 登录态', () => (runtime.requireAuthSession ?? session.requireHeyboxAuthSession)({ loginBaseUrl }), { successText: 'Heybox 登录态有效' });
524
522
  logger.debug(`Heybox API: ${apiBaseUrl}`);
525
- const uploadVersion = fromVersion ? '' : validateVersionForDeploy(packageJson.version, 'package.json.version');
523
+ const uploadVersion = validateVersionForDeploy(packageJson.version, 'package.json.version');
526
524
  const deploy = async () => {
527
525
  let precheckVersion;
528
- const historyArtifact = fromVersion ? { source_version: fromVersion } : {};
529
- if (fromVersion) {
530
- const precheck = await runVersionPrecheck({
531
- session: session$1,
532
- miniProgramId,
533
- ...historyArtifact,
534
- releaseNote,
535
- autoPublish,
536
- }, runtime, apiBaseUrl, projectRoot, logger);
537
- const sourceSdkVersion = typeof precheck.sdk_version === 'string' ? precheck.sdk_version.trim() : '';
538
- if (!sourceSdkVersion) {
539
- throw new Error('历史产物缺少 sdkVersion,无法复用,请重新构建并上传新版本');
526
+ {
527
+ const configuredProfile = runtimePermissionEnv.parseMiniappBasicInfo(packageJson.heybox ?? {}, '0.8.1');
528
+ if (!configuredProfile) {
529
+ const bound = await (runtime.getBoundMiniProgram ?? context.getBoundMiniProgram)({
530
+ allowUnsafeApiBaseUrl: options.allowUnsafeApiBaseUrl,
531
+ apiBaseUrl,
532
+ cwd: projectRoot,
533
+ env,
534
+ fetchImpl: runtime.fetchImpl,
535
+ loginBaseUrl,
536
+ session: session$1,
537
+ });
538
+ await context.migrateBasicInfo(projectRoot, bound.detail, miniProgramId, runtime.fetchImpl);
540
539
  }
541
- precheckVersion = precheck.version || precheck.version_normalized || fromVersion;
542
- }
543
- else {
544
540
  const localPermissions = runtimePermissionEnv.readMiniappPermissionsFromPackageJson(projectRoot, runtimePermissionEnv.resolveMiniappSdkVersion());
545
541
  if (typeof packageJson.scripts?.build !== 'string') {
546
542
  throw new Error('package.json scripts.build 未定义,请添加 build 脚本');
@@ -589,7 +585,8 @@ async function runDeployCommand(options, runtime = {}) {
589
585
  let version = precheckVersion;
590
586
  let manifest;
591
587
  let uploadSessionId = '';
592
- if (!fromVersion) {
588
+ let preflightToken = '';
589
+ {
593
590
  const distDir = path.join(projectRoot, 'dist');
594
591
  const parsedManifest = await readDeployManifest(projectRoot, logger);
595
592
  ({ manifest, version } = parsedManifest);
@@ -634,28 +631,54 @@ async function runDeployCommand(options, runtime = {}) {
634
631
  // deploy 期间 dist 视为稳定构建输出;为避免持有大量文件描述符,签名和上传不会共享打开的文件句柄。
635
632
  const artifactReceipt = await logger.task('正在计算构建产物签名', () => (runtime.computeMiniappArtifactReceipt ?? computeMiniappArtifactReceipt)(uploadFiles), { successText: '构建产物签名计算完成' });
636
633
  runtimePermissionEnv.validateMiniappCompanionFileReceipts(manifest?.companions, artifactReceipt.files);
634
+ const profile = runtimePermissionEnv.parseMiniappBasicInfo(manifest, String(manifest.sdkVersion));
635
+ if (profile) {
636
+ const localProfile = runtimePermissionEnv.parseMiniappBasicInfo((await readPackageJson(projectRoot)).heybox ?? {});
637
+ if (localProfile.name !== profile.name || localProfile.coverImages.length !== profile.coverImages.length)
638
+ throw new Error('构建资料与 package.json 声明不一致,请重新构建');
639
+ const sources = [localProfile.icon, ...localProfile.coverImages];
640
+ const refs = [{ path: profile.icon, kind: 'icon' }, ...profile.coverImages.map((path) => ({ path, kind: 'cover' }))];
641
+ for (const [index, ref] of refs.entries()) {
642
+ const image = await context.readBasicInfoSource(distDir, ref.path, ref.kind);
643
+ const source = await context.readBasicInfoSource(projectRoot, sources[index], ref.kind);
644
+ if (source.sha256 !== image.sha256)
645
+ throw new Error('构建图片与项目声明不一致,请重新构建');
646
+ if (image.sha256 === BASIC_INFO_PLACEHOLDER_SHA256)
647
+ throw new Error('请替换脚手架占位图片后再提交审核');
648
+ const receipt = artifactReceipt.files.find((file) => file.relativePath === ref.path);
649
+ if (!receipt || receipt.sha256 !== image.sha256 || receipt.size !== image.bytes.length)
650
+ throw new Error('资料图片与产物 receipt 不一致');
651
+ }
652
+ }
637
653
  const createdUploadSession = await logger.task('正在创建或恢复上传会话', async () => {
638
654
  const result = await (runtime.createUserMiniprogramUploadSession ?? createUserMiniprogramUploadSession)({
639
655
  session: session$1,
640
656
  miniProgramId,
641
657
  version,
658
+ manifest,
659
+ releaseNote,
660
+ autoPublish,
642
661
  artifactSignature: artifactReceipt.artifactSignature,
643
662
  files: artifactReceipt.files.map((file) => ({ path: file.relativePath, size: file.size, sha256: file.sha256 })),
644
663
  }, { baseUrl: apiBaseUrl, fetchImpl: runtime.fetchImpl });
645
664
  if (typeof result.session_id !== 'string' || !result.session_id.trim()) {
646
665
  throw new Error('创建上传会话失败:服务端未返回 session_id');
647
666
  }
667
+ if (!result.preflight_token)
668
+ throw new Error('服务端未返回 preflight_token,请先升级服务端');
648
669
  if (result.file_receipt_version !== 1) {
649
670
  throw new Error('创建上传会话失败:服务端不支持文件完整性 receipt v1,请升级服务端后重试');
650
671
  }
651
672
  const resolved = runtimePermissionEnv.resolveMiniappUploadSessionFiles(artifactReceipt.files, Array.isArray(result.files) ? result.files : [], Array.isArray(result.uploaded_keys) ? result.uploaded_keys : []);
652
673
  return {
674
+ preflightToken: result.preflight_token,
653
675
  sessionId: result.session_id.trim(),
654
676
  files: resolved.files,
655
677
  missingFiles: resolved.missingFiles,
656
678
  };
657
679
  }, { successText: '上传会话已就绪' });
658
680
  uploadSessionId = createdUploadSession.sessionId;
681
+ preflightToken = createdUploadSession.preflightToken;
659
682
  const uploadedCount = createdUploadSession.files.length - createdUploadSession.missingFiles.length;
660
683
  if (uploadedCount > 0) {
661
684
  logger.debug(`复用已上传文件: ${uploadedCount}/${createdUploadSession.files.length}`);
@@ -683,15 +706,14 @@ async function runDeployCommand(options, runtime = {}) {
683
706
  }
684
707
  }
685
708
  try {
686
- const submitOptions = fromVersion
687
- ? { session: session$1, miniProgramId, ...historyArtifact, releaseNote, autoPublish }
688
- : { session: session$1, miniProgramId, manifest, sessionId: uploadSessionId, releaseNote, autoPublish };
709
+ const submitOptions = { session: session$1, miniProgramId, sessionId: uploadSessionId, preflightToken };
689
710
  submitAuditResult = await logger.task('正在提交审核', () => (runtime.submitUserMiniprogramAudit ?? submitUserMiniprogramAudit)(submitOptions, {
690
711
  baseUrl: apiBaseUrl,
691
712
  fetchImpl: runtime.fetchImpl,
692
713
  }), { successText: '审核提交完成' });
693
714
  }
694
715
  catch (error) {
716
+ logger.warn('提交未完成;已上传文件会保留,再次部署相同产物时只补传缺失文件。');
695
717
  throw translateHeyboxDeployError(error, { projectRoot, stage: 'submitAudit', version });
696
718
  }
697
719
  printDeploySuccess({
@@ -710,10 +732,6 @@ async function runDeployCommand(options, runtime = {}) {
710
732
  version,
711
733
  };
712
734
  };
713
- if (fromVersion) {
714
- logger.info('平台声明:未分类(复用历史产物)');
715
- return deploy();
716
- }
717
735
  return (runtime.withDeployLock ?? withDeployLock)({ apiBaseUrl, miniProgramId, version: uploadVersion }, deploy);
718
736
  }
719
737
  function printDeploySuccess(options) {
@@ -826,14 +844,14 @@ async function maybePromptReleaseNote(runtime) {
826
844
  }
827
845
  async function runVersionPrecheck(options, runtime, apiBaseUrl, projectRoot, logger) {
828
846
  try {
829
- const label = options.version ?? options.source_version ?? '';
847
+ const label = options.version ?? '';
830
848
  return await logger.task(`正在预检版本 ${label}`, () => (runtime.precheckUserMiniprogramVersion ?? precheckUserMiniprogramVersion)(options, {
831
849
  baseUrl: apiBaseUrl,
832
850
  fetchImpl: runtime.fetchImpl,
833
851
  }), { successText: `版本 ${label} 预检通过` });
834
852
  }
835
853
  catch (error) {
836
- throw translateHeyboxDeployError(error, { projectRoot, stage: 'precheck', version: options.version ?? options.source_version ?? '' });
854
+ throw translateHeyboxDeployError(error, { projectRoot, stage: 'precheck', version: options.version ?? '' });
837
855
  }
838
856
  }
839
857
  function detectPackageManager(projectRoot) {
@@ -1077,7 +1095,6 @@ async function runRemoteDeployCommand(options, runtime) {
1077
1095
  apiBaseUrl: options.apiBaseUrl,
1078
1096
  autoPublish: options.autoPublish,
1079
1097
  env: options.env,
1080
- fromVersion: options.fromVersion,
1081
1098
  loginBaseUrl: options.loginBaseUrl,
1082
1099
  releaseNote: options.releaseNote,
1083
1100
  buildOutputMode: options.json ? 'stderr' : 'inherit',
@@ -1256,6 +1273,7 @@ async function remoteCreate(options, context$1, runtime) {
1256
1273
  throw new Error(`当前 CLI 用户没有创建工坊小程序权限:${String(access.status ?? 'unknown')}`);
1257
1274
  }
1258
1275
  await confirmCreateWithCurrentEntity(options, context$1, runtime);
1276
+ runtimePermissionEnv.parseMiniappBasicInfo(context$1.packageJson.packageJson.heybox ?? {});
1259
1277
  const result = await context$1.api.createMiniProgram();
1260
1278
  const miniProgramId = requireMiniProgramId(result);
1261
1279
  await context.writeBoundMiniProgramId(context$1.packageJson.projectRoot, miniProgramId, { force: options.forceBind });
@@ -1272,23 +1290,22 @@ async function remoteBind(options, context$1, runtime) {
1272
1290
  }
1273
1291
  const detail = await context$1.api.getMiniProgramDetail(miniProgramId);
1274
1292
  const verifiedId = requireMiniProgramId(detail);
1293
+ if (verifiedId !== miniProgramId)
1294
+ throw new Error('远端返回的小程序 ID 与绑定目标不一致');
1275
1295
  await assertMiniProgramEntityMatchesCurrent(context$1, detail);
1276
- const changed = context$1.binding !== verifiedId;
1277
- if (changed) {
1278
- await context.writeBoundMiniProgramId(context$1.packageJson.projectRoot, verifiedId, { force: options.force });
1279
- }
1296
+ const { changed } = await context.migrateBasicInfo(context$1.packageJson.projectRoot, detail, verifiedId, runtime.fetchImpl, options.force);
1280
1297
  const output = { changed, miniProgramId: verifiedId, remote: toCamelCaseDeep(detail) };
1281
1298
  if (!options.json) {
1282
1299
  context$1.logger.success(changed ? `绑定成功:${verifiedId}` : `已绑定:${verifiedId}`);
1283
1300
  }
1284
1301
  return finishRemoteCommand(options, runtime, output);
1285
1302
  }
1286
- async function remoteInfo(options, context, runtime) {
1287
- const miniProgramId = requireBinding(context);
1288
- const detail = await context.api.getMiniProgramDetail(miniProgramId);
1289
- const localPermissions = runtimePermissionEnv.readMiniappPermissionsFromPackageJson(context.packageJson.projectRoot, runtimePermissionEnv.resolveMiniappSdkVersion());
1303
+ async function remoteInfo(options, context$1, runtime) {
1304
+ const miniProgramId = requireBinding(context$1);
1305
+ const detail = await context$1.api.getMiniProgramDetail(miniProgramId);
1306
+ const localPermissions = runtimePermissionEnv.readMiniappPermissionsFromPackageJson(context$1.packageJson.projectRoot, runtimePermissionEnv.resolveMiniappSdkVersion());
1290
1307
  const permissionViews = runtimePermissionEnv.composeMiniappRuntimePermissions(localPermissions, detail.runtime_permissions).views;
1291
- const localBindAppIds = runtimePermissionEnv.readMiniappBindAppIdsFromPackageJson(context.packageJson.projectRoot);
1308
+ const localBindAppIds = runtimePermissionEnv.readMiniappBindAppIdsFromPackageJson(context$1.packageJson.projectRoot);
1292
1309
  const currentBindApps = normalizeRemoteBoundApps(detail.bind_apps);
1293
1310
  const currentByID = new Map(currentBindApps.map((item) => [item.appid, item]));
1294
1311
  const local = localBindAppIds.map((appid) => currentByID.get(appid) ?? { appid });
@@ -1297,9 +1314,12 @@ async function remoteInfo(options, context, runtime) {
1297
1314
  const localIDs = new Set(localBindAppIds);
1298
1315
  const removed = currentBindApps.filter((item) => !localIDs.has(item.appid));
1299
1316
  const bindings = { local, current: currentBindApps, added, removed };
1300
- const output = { changed: false, miniProgramId, detail: toCamelCaseDeep(detail), permissions: permissionViews, bindings };
1317
+ const basicInfo = await context.compareBasicInfo(context$1.packageJson.projectRoot, detail, runtime.fetchImpl);
1318
+ const output = { changed: false, miniProgramId, detail: toCamelCaseDeep(detail), permissions: permissionViews, bindings, basicInfo };
1319
+ if (!options.json)
1320
+ context$1.logger.info(`版本资料:${basicInfo.status}`);
1301
1321
  if (!options.json) {
1302
- printMiniProgramDetail(context.logger, detail, permissionViews, bindings);
1322
+ printMiniProgramDetail(context$1.logger, detail, permissionViews, bindings);
1303
1323
  }
1304
1324
  return finishRemoteCommand(options, runtime, output);
1305
1325
  }
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var runtimePermissionEnv = require('./runtime-permission-env-CAhESVDA.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
+ function hasMiniappRuntimeGate(html) {
31
+ const document = parse(html);
32
+ let hasGate = false;
33
+ let hasGateStyle = false;
34
+ let hasGateBootstrap = false;
35
+ walk(document, (element) => {
36
+ hasGate ||= hasAttr(element, RUNTIME_GATE_MARKER);
37
+ hasGateStyle ||= hasAttr(element, RUNTIME_GATE_STYLE_MARKER);
38
+ hasGateBootstrap ||= hasAttr(element, RUNTIME_GATE_BOOTSTRAP_MARKER);
39
+ });
40
+ return hasGate && hasGateStyle && hasGateBootstrap;
41
+ }
42
+ function readAttr(element, name) {
43
+ return element.attrs.find((attr) => attr.name.toLowerCase() === name)?.value;
44
+ }
45
+ function hasAttr(element, name) {
46
+ return readAttr(element, name) !== undefined;
47
+ }
48
+ function walk(node, visit) {
49
+ if ('tagName' in node)
50
+ visit(node);
51
+ if ('childNodes' in node)
52
+ for (const child of node.childNodes)
53
+ walk(child, visit);
54
+ if ('content' in node && node.content)
55
+ walk(node.content, visit);
56
+ }
57
+
58
+ exports.hasMiniappRuntimeGate = hasMiniappRuntimeGate;