From 7e5ba60ac03f876ebfc03a7d8d2a526993a89301 Mon Sep 17 00:00:00 2001 From: kdletters Date: Sun, 21 Jun 2026 19:37:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=81=E5=AE=9A=E5=A3=B3=E6=9C=AA=E5=A3=B0?= =?UTF-8?q?=E6=98=8E=E8=83=BD=E5=8A=9B=E9=97=A8=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 反查移动壳未声明方法测试必须由共享方法清单派生 反查桌面壳未声明方法测试必须由 Rust 能力清单派生 --- scripts/check-native-shells.mjs | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/scripts/check-native-shells.mjs b/scripts/check-native-shells.mjs index 300b2bdcc..049678edd 100644 --- a/scripts/check-native-shells.mjs +++ b/scripts/check-native-shells.mjs @@ -2853,6 +2853,18 @@ function assertNativeShellCapabilityPlan() { 'apps/desktop-shell/src-tauri/src/shell/events.rs', 'utf8', ); + const mobileDispatchTestSource = fs.readFileSync( + 'apps/mobile-shell/src/host-bridge/dispatch.test.ts', + 'utf8', + ); + const mobileBridgeTestSource = fs.readFileSync( + 'apps/mobile-shell/src/host-bridge/bridge.test.ts', + 'utf8', + ); + const desktopDispatchSource = fs.readFileSync( + 'apps/desktop-shell/src-tauri/src/host_bridge/dispatch.rs', + 'utf8', + ); const wechatProtocol = requireCommonJsModule( 'miniprogram/host-bridge/protocol.js', ); @@ -2888,6 +2900,42 @@ function assertNativeShellCapabilityPlan() { sharedDesktopCapabilities, 'desktop shell runtime capability profile', ); + for (const [source, label, snippets] of [ + [ + mobileDispatchTestSource, + 'mobile dispatch undeclared method test', + [ + 'HOST_BRIDGE_METHODS.filter', + '!HOST_BRIDGE_EXPO_MOBILE_IOS_CAPABILITIES.includes(method)', + "expect(response.error.code).toBe('unsupported_method')", + ], + ], + [ + mobileBridgeTestSource, + 'mobile bridge undeclared method test', + [ + 'HOST_BRIDGE_METHODS.filter', + '!HOST_BRIDGE_EXPO_MOBILE_IOS_CAPABILITIES.includes(method)', + "expect(failedResponse.error.code).toBe('unsupported_method')", + ], + ], + ]) { + for (const snippet of snippets) { + if (!source.includes(snippet)) { + throw new Error(`${label} must derive unsupported methods from shared method list`); + } + } + } + for (const snippet of [ + 'HOST_BRIDGE_METHODS\n .iter()', + '.filter(|method| !desktop_capabilities.contains(method))', + 'let response = resolve_host_bridge_request(request(method));', + 'assert_eq!(error.code, "unsupported_method");', + ]) { + if (!desktopDispatchSource.includes(snippet)) { + throw new Error('desktop dispatch test must derive unsupported methods from Rust capability list'); + } + } assertSameList( extractDocumentMethodTable(planSource),