收紧移动文档选择器门禁

锁定文本、文档和音频导入的 DocumentPicker 单选缓存配置

要求移动壳文件导入继续使用受控类型清单

同步 HostBridge 文件选择边界记录
This commit is contained in:
2026-06-19 17:17:26 +08:00
parent 83be6c02d9
commit 204e629100
2 changed files with 35 additions and 0 deletions
@@ -264,6 +264,27 @@ function extractFunctionBody(source, functionName) {
throw new Error(`unable to read complete function body ${functionName}`);
}
function assertMobileDocumentPickerBoundary(
functionName,
expectedTypeExpression,
) {
const functionBody = extractFunctionBody(hostBridgeSource, functionName);
if (!functionBody.includes('DocumentPicker.getDocumentAsync({')) {
throw new Error(`mobile shell ${functionName} must use DocumentPicker`);
}
for (const requiredPickerOption of [
'copyToCacheDirectory: true',
'multiple: false',
`type: ${expectedTypeExpression}`,
]) {
if (!functionBody.includes(requiredPickerOption)) {
throw new Error(
`mobile shell ${functionName} picker options missing ${requiredPickerOption}`,
);
}
}
}
function assertNoBlockedMobileChannelDependencies(packageJson, packageLabel) {
const dependencySections = [
'dependencies',
@@ -1548,6 +1569,19 @@ for (const [functionName, pickerCall] of [
}
}
assertMobileDocumentPickerBoundary(
'importTextFile',
"['text/*', 'application/json']",
);
assertMobileDocumentPickerBoundary(
'importDocumentFile',
'MOBILE_DOCUMENT_PICKER_TYPES',
);
assertMobileDocumentPickerBoundary(
'importAudioFile',
'MOBILE_AUDIO_DOCUMENT_PICKER_TYPES',
);
if (
!hostBridgeSource.includes(
'const externalUrlPayload = normalizeHostBridgeExternalUrlPayload(',
File diff suppressed because one or more lines are too long