扩展原生壳替身扫描范围
将微信小程序生产 JS 纳入原生壳替身词扫描 将 H5 HostBridge 直接调用链纳入生产替身词扫描 为桌面壳最小 capability 文档增加正向门禁 同步方案文档、协议文档、开发流程和决策记录
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
- 2026-06-18 宿主 runtime 回读:主 App 启动时会通过真实 `host.getRuntime` 回读 Expo / Tauri runtime 并缓存过滤后的能力清单,能力来源为 URL `hostCapabilities` 与宿主真实回包的并集;裁剪壳或旧入口 URL 缺少 `hostCapabilities` 时也能启用真实声明能力,但仍不会仅凭 `native_app` 或 transport 存在推断能力可用。
|
||||
- 2026-06-18 壳能力防漂移:`npm run mobile-shell:typecheck` 与 `npm run desktop-shell:typecheck` 会校验 Expo / Tauri 壳声明的 capability 均来自共享 HostBridge 白名单,并校验壳 runtime 回包、H5 URL `hostCapabilities` 和实现分支保持一致;微信小程序 `WECHAT_HOST_CAPABILITIES` 也由 `miniprogram/host-bridge/protocol.test.js` 反查同一共享白名单。新增能力必须先更新契约和真实壳实现,再通过这些检查。
|
||||
- 2026-06-18 原生壳统一验收门禁:根级 `npm run check:native-shells` 统一执行 H5 HostBridge 关键测试、Expo 壳 typecheck / test / config smoke / Metro export smoke、Tauri 壳 typecheck / cargo test、桌面 release `--no-bundle` 构建烟测,以及可分发壳与 H5 HostBridge 真实调用链的临时替身词扫描;根级 `npm run check` 会在 lint、主站测试、构建和内容检查后继续执行该门禁,避免 HostBridge、三端壳、Expo managed config、移动端 production bundle、桌面 release 入口和 H5 HostBridge 真实调用链禁替身验收散落成容易漏跑的单项命令。
|
||||
- 2026-06-19 原生壳临时替身扫描范围:`npm run check:native-shells` 的生产替身词扫描必须覆盖微信小程序壳生产 `.js`、Expo / Tauri 壳源码与配置、共享 HostBridge 契约、H5 native transport,以及已接入的 H5 直接调用链文件;新增 H5 调用点接入 HostBridge 时,必须同步把对应文件纳入扫描或在同等门禁中证明生产代码没有 mock / fake / placeholder / TODO / FIXME / 占位 / 伪造。
|
||||
- 2026-06-18 微信壳桥接层纳入统一验收:`npm run check:native-shells` 还会运行 `miniprogram/host-bridge/`、`miniprogram/shell/`、`pages/web-view` 样式和 `scripts/miniprogram-web-view-auth.test.ts` 的微信壳测试,覆盖 WebView 入口、登录触发、分享目标、支付结果、订阅消息结果和九宫切图行为;三端桥接层文件结构检查只证明目录边界,行为回归必须由同一门禁中的微信壳测试证明。
|
||||
- 2026-06-18 登录 / 支付能力禁伪声明:`auth.requestLogin` 和 `payment.request` 保留在共享 HostBridge 契约中供未来真实接入,但 Expo / Tauri 壳在真实 SDK、渠道流程和后端契约落地前不得声明这些 capability,也不得把它们写入入口 URL `hostCapabilities`;两端检查脚本会拒绝伪声明,请求实际到达壳层时必须返回明确 `unsupported_method` 并让 H5 fallback,两端壳测试直接覆盖这两个 method。
|
||||
- 2026-06-18 移动壳触觉反馈边界:`haptics.impact` 只接受 `light`、`medium`、`heavy` 三档 impact style,缺省为 `light`;未知值必须返回 `invalid_request`,不得静默降级成真实设备触觉反馈。桌面壳不声明该 capability,H5 继续按 HostBridge fallback 处理。
|
||||
|
||||
@@ -216,7 +216,7 @@ npm run build
|
||||
npm run check:native-shells
|
||||
```
|
||||
|
||||
该命令会覆盖 H5 HostBridge 关键测试、微信 / Expo / Tauri 三端桥接层文件结构门禁、Expo 壳 typecheck / test / config smoke / Metro export smoke、Tauri 壳 typecheck / cargo test、桌面壳 release `--no-bundle` 构建烟测,以及可分发壳与 H5 HostBridge 真实调用链的临时替身词扫描,确认 Expo managed config、移动端 iOS / Android production bundle、打包 H5 资产、Tauri release 入口和 H5 HostBridge 真实调用链没有漂移。
|
||||
该命令会覆盖 H5 HostBridge 关键测试、微信 / Expo / Tauri 三端桥接层文件结构门禁、Expo 壳 typecheck / test / config smoke / Metro export smoke、Tauri 壳 typecheck / cargo test、桌面壳 release `--no-bundle` 构建烟测,以及可分发壳与 H5 HostBridge 真实调用链的临时替身词扫描,确认 Expo managed config、移动端 iOS / Android production bundle、打包 H5 资产、Tauri release 入口和 H5 HostBridge 真实调用链没有漂移;扫描范围包含微信小程序壳生产 `.js`、共享 HostBridge 契约、H5 native transport 和已接入的 H5 直接调用链文件。
|
||||
该命令同时会运行微信小程序 `miniprogram/host-bridge/`、`miniprogram/shell/`、`pages/web-view` 样式和 `scripts/miniprogram-web-view-auth.test.ts` 的壳层测试,保证微信桥接层拆分后的支付、订阅消息、九宫切图、分享目标和 WebView 登录 / 分享入口行为与 Expo、Tauri 壳一起验收。
|
||||
|
||||
内容检查:
|
||||
|
||||
@@ -479,7 +479,7 @@ GameBridge 禁止:
|
||||
- AI sandbox 无法调用 HostBridge,也无法读取 H5 登录态。
|
||||
- Tauri release 包不允许任意远端页面调用桌面命令。
|
||||
- Expo WebView 外链离开主站后不保留完整 HostBridge。
|
||||
- 根级验收入口 `npm run check:native-shells` 必须同时覆盖 H5 HostBridge 关键路径、三端桥接层文件结构门禁、Expo 壳 typecheck / test / config smoke / Metro export smoke、Tauri 壳 typecheck / cargo test、桌面 release `--no-bundle` 构建烟测,以及可分发壳与 H5 HostBridge 真实调用链的临时替身词扫描。
|
||||
- 根级验收入口 `npm run check:native-shells` 必须同时覆盖 H5 HostBridge 关键路径、三端桥接层文件结构门禁、Expo 壳 typecheck / test / config smoke / Metro export smoke、Tauri 壳 typecheck / cargo test、桌面 release `--no-bundle` 构建烟测,以及可分发壳与 H5 HostBridge 真实调用链的临时替身词扫描。该扫描范围必须包含微信小程序壳生产 `.js`、共享 HostBridge 契约、H5 native transport 和已接入的 H5 直接调用链文件。
|
||||
|
||||
## 参考资料
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ AI H5 sandbox
|
||||
- 小程序支付仍跳转 `/pages/wechat-pay/index` 并保留支付结果 hash 回灌确认。
|
||||
- 小程序订阅授权仍跳转 `/pages/subscribe-message/index`,且返回不阻断生成主链路。
|
||||
- 普通浏览器分享、H5 支付和 Native 二维码支付不受影响。
|
||||
- 原生壳统一验收入口 `npm run check:native-shells` 通过,能力白名单、壳 runtime 回包、URL `hostCapabilities`、H5 fallback、三端桥接层结构、两端壳实现、Expo managed config、移动端 production bundle、桌面 release 构建入口,以及可分发壳与 H5 HostBridge 真实调用链的临时替身词扫描没有漂移。
|
||||
- 原生壳统一验收入口 `npm run check:native-shells` 通过,能力白名单、壳 runtime 回包、URL `hostCapabilities`、H5 fallback、三端桥接层结构、两端壳实现、Expo managed config、移动端 production bundle、桌面 release 构建入口,以及可分发壳与 H5 HostBridge 真实调用链的临时替身词扫描没有漂移;扫描范围包含微信小程序壳生产 `.js`、共享 HostBridge 契约、H5 native transport 和已接入的 H5 直接调用链文件。
|
||||
|
||||
## 后续
|
||||
|
||||
|
||||
@@ -20,6 +20,16 @@ const productionShellScanRoots = [
|
||||
'packages/shared/src/contracts/hostBridge.ts',
|
||||
'src/services/host-bridge',
|
||||
];
|
||||
const h5HostBridgeCallChainScanFiles = [
|
||||
'src/services/clipboard.ts',
|
||||
'src/services/appTitle.ts',
|
||||
'src/services/runtimeAudioFeedback.ts',
|
||||
'src/hooks/useHostLifecycleActive.ts',
|
||||
'src/hooks/useHostNetworkOnline.ts',
|
||||
'src/components/common/PublishShareModal.tsx',
|
||||
'src/components/common/publishShareCardImage.ts',
|
||||
'src/components/common/CreativeAudioInputPanel.tsx',
|
||||
];
|
||||
const expectedWechatHostBridgeFiles = [
|
||||
'dispatch.js',
|
||||
'payment.js',
|
||||
@@ -106,6 +116,7 @@ const capabilityListMarkers = {
|
||||
const sharedHostBridgeContractPath =
|
||||
'packages/shared/src/contracts/hostBridge.ts';
|
||||
const productionShellExtensions = new Set([
|
||||
'.js',
|
||||
'.json',
|
||||
'.mjs',
|
||||
'.rs',
|
||||
@@ -229,6 +240,10 @@ function collectProductionShellFiles(entryPath) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!fs.existsSync(entryPath)) {
|
||||
throw new Error(`production shell scan path does not exist: ${entryPath}`);
|
||||
}
|
||||
|
||||
const stats = fs.statSync(entryPath);
|
||||
if (stats.isDirectory()) {
|
||||
const name = path.basename(entryPath);
|
||||
@@ -245,7 +260,10 @@ function collectProductionShellFiles(entryPath) {
|
||||
}
|
||||
|
||||
function assertNoProductionShellDevScaffoldTerms() {
|
||||
const files = productionShellScanRoots.flatMap(collectProductionShellFiles);
|
||||
const files = [
|
||||
...productionShellScanRoots,
|
||||
...h5HostBridgeCallChainScanFiles,
|
||||
].flatMap(collectProductionShellFiles);
|
||||
|
||||
for (const file of files) {
|
||||
const source = fs.readFileSync(file, 'utf8');
|
||||
@@ -384,6 +402,11 @@ function assertNativeShellCapabilityPlan() {
|
||||
'native shell plan must not document core:default as a desktop capability permission',
|
||||
);
|
||||
}
|
||||
if (!planSource.includes('主窗口 capability 只授予 `allow-host-bridge-request`')) {
|
||||
throw new Error(
|
||||
'native shell plan must document the minimal desktop capability permission',
|
||||
);
|
||||
}
|
||||
assertNativeShellScaffoldScanWording(planSource, 'native shell plan');
|
||||
assertNativeShellScaffoldScanWording(
|
||||
hostBridgeProtocolDocSource,
|
||||
|
||||
Reference in New Issue
Block a user