收口桌面运行时桥接边界
将 Tauri host.getRuntime 回包组装收口到 runtime 模块 让桌面 dispatch 只委托运行时请求 同步桌面壳结构门禁、架构文档和共享记忆
This commit is contained in:
@@ -118,6 +118,14 @@ const desktopHostBridgeNotificationsSource = fs.readFileSync(
|
||||
desktopHostBridgeNotificationsPath,
|
||||
'utf8',
|
||||
);
|
||||
const desktopHostBridgeRuntimePath = new URL(
|
||||
'../src-tauri/src/host_bridge/runtime.rs',
|
||||
import.meta.url,
|
||||
);
|
||||
const desktopHostBridgeRuntimeSource = fs.readFileSync(
|
||||
desktopHostBridgeRuntimePath,
|
||||
'utf8',
|
||||
);
|
||||
const desktopHostBridgeSharePath = new URL(
|
||||
'../src-tauri/src/host_bridge/share.rs',
|
||||
import.meta.url,
|
||||
@@ -252,6 +260,7 @@ const expectedDesktopHostBridgeRustFiles = [
|
||||
'network.rs',
|
||||
'notifications.rs',
|
||||
'protocol.rs',
|
||||
'runtime.rs',
|
||||
'share.rs',
|
||||
'title.rs',
|
||||
];
|
||||
@@ -1708,21 +1717,33 @@ if (!rustHostSource.includes('host_version: env!("CARGO_PKG_VERSION")')) {
|
||||
}
|
||||
|
||||
for (const runtimeSnippet of [
|
||||
'fn desktop_runtime() -> HostBridgeRuntime',
|
||||
'pub(crate) fn desktop_runtime() -> HostBridgeRuntime',
|
||||
'shell: "tauri_desktop"',
|
||||
'platform: desktop_platform()',
|
||||
'host_version: env!("CARGO_PKG_VERSION")',
|
||||
'bridge_version: HOST_BRIDGE_VERSION',
|
||||
'capabilities: capabilities()',
|
||||
'"host.getRuntime" => ok(request.id, json!(desktop_runtime()))',
|
||||
]) {
|
||||
if (!desktopHostBridgeDispatchSource.includes(runtimeSnippet)) {
|
||||
if (!desktopHostBridgeRuntimeSource.includes(runtimeSnippet)) {
|
||||
throw new Error(`desktop shell runtime response missing ${runtimeSnippet}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!desktopHostBridgeDispatchSource.includes(
|
||||
'"host.getRuntime" => ok(request.id, json!(desktop_runtime()))',
|
||||
) ||
|
||||
desktopHostBridgeDispatchSource.includes('HostBridgeRuntime') ||
|
||||
desktopHostBridgeDispatchSource.includes('HOST_BRIDGE_VERSION') ||
|
||||
desktopHostBridgeDispatchSource.includes('capabilities()') ||
|
||||
desktopHostBridgeDispatchSource.includes('desktop_platform()') ||
|
||||
desktopHostBridgeDispatchSource.includes('env!("CARGO_PKG_VERSION")')
|
||||
) {
|
||||
throw new Error('desktop shell dispatch must delegate host.getRuntime to runtime.rs');
|
||||
}
|
||||
|
||||
if (desktopHostBridgeDispatchSource.includes('json!(HostBridgeRuntime {')) {
|
||||
throw new Error('desktop shell host.getRuntime must be built by desktop_runtime()');
|
||||
throw new Error('desktop shell host.getRuntime must be built by runtime.rs');
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -1986,6 +2007,7 @@ const expectedRustHostBridgeFiles = [
|
||||
'network.rs',
|
||||
'notifications.rs',
|
||||
'protocol.rs',
|
||||
'runtime.rs',
|
||||
'share.rs',
|
||||
'title.rs',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user