收口桌面壳JS依赖边界

移除根H5与桌面壳未使用的Tauri JS guest依赖

新增桌面壳检查,禁止根包和桌面壳包安装Tauri JS guest包

更新原生壳方案和共享决策记录,明确桌面系统能力只由Rust HostBridge分发
This commit is contained in:
2026-06-18 12:30:43 +08:00
parent ef5b7afd2c
commit 6a5869596c
6 changed files with 37 additions and 40 deletions
@@ -4,6 +4,8 @@ const configPath = new URL('../src-tauri/tauri.conf.json', import.meta.url);
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
const packagePath = new URL('../package.json', import.meta.url);
const packageConfig = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
const rootPackagePath = new URL('../../../package.json', import.meta.url);
const rootPackageConfig = JSON.parse(fs.readFileSync(rootPackagePath, 'utf8'));
const capabilityPath = new URL(
'../src-tauri/capabilities/main.json',
import.meta.url,
@@ -136,6 +138,29 @@ function assertNoBlockedNpmDependencies() {
}
}
function collectNpmDependencyNames(packageJson) {
const dependencySections = [
'dependencies',
'devDependencies',
'optionalDependencies',
'peerDependencies',
];
return dependencySections.flatMap((section) =>
Object.keys(packageJson[section] ?? {}),
);
}
function assertNoTauriGuestNpmDependencies(packageJson, packageLabel) {
for (const dependency of collectNpmDependencyNames(packageJson)) {
if (dependency === '@tauri-apps/api' || dependency.startsWith('@tauri-apps/plugin-')) {
throw new Error(
`${packageLabel} must not depend on ${dependency}; desktop H5 must use HostBridge through the injected Tauri global only`,
);
}
}
}
function assertNoBlockedCargoDependencies() {
for (const dependency of blockedDesktopCargoDependencies) {
const dependencyPattern = new RegExp(
@@ -220,6 +245,8 @@ assertNoDevScaffoldTerms(
productionSourceRoots.flatMap((root) => collectProductionSourceFiles(root)),
);
assertNoBlockedNpmDependencies();
assertNoTauriGuestNpmDependencies(packageConfig, 'desktop shell package');
assertNoTauriGuestNpmDependencies(rootPackageConfig, 'root H5 package');
assertNoBlockedCargoDependencies();
assertNoBlockedDesktopSdkSnippets();