diff --git a/apps/mobile-shell/scripts/check-config.mjs b/apps/mobile-shell/scripts/check-config.mjs index a4accea7d..a1bf7bc51 100644 --- a/apps/mobile-shell/scripts/check-config.mjs +++ b/apps/mobile-shell/scripts/check-config.mjs @@ -2104,19 +2104,38 @@ if ( ) { throw new Error('mobile shell image export must reject empty and oversized bytes'); } -const exportTextFileBody = extractFunctionBody(filesSource, 'exportTextFile'); -const exportTextMimeValidationIndex = exportTextFileBody.indexOf( - 'HOST_BRIDGE_TEXT_MIME_TYPE_SET.has(mimeType as HostBridgeTextMimeType)', -); -const exportTextSharingAvailabilityIndex = exportTextFileBody.indexOf( - 'await assertMobileFileSharingAvailable()', -); -if ( - exportTextMimeValidationIndex < 0 || - exportTextSharingAvailabilityIndex < 0 || - exportTextMimeValidationIndex > exportTextSharingAvailabilityIndex -) { - throw new Error('mobile shell text export must validate MIME before native sharing checks'); + +for (const [functionName, mimeCheckSnippet, label] of [ + [ + 'exportTextFile', + 'HOST_BRIDGE_TEXT_MIME_TYPE_SET.has(mimeType as HostBridgeTextMimeType)', + 'text', + ], + [ + 'exportImageFile', + 'HOST_BRIDGE_IMAGE_MIME_TYPE_SET.has(mimeType as HostBridgeImageMimeType)', + 'image', + ], + [ + 'exportAudioFile', + 'HOST_BRIDGE_AUDIO_MIME_TYPE_SET.has(mimeType as HostBridgeAudioMimeType)', + 'audio', + ], +]) { + const functionBody = extractFunctionBody(filesSource, functionName); + const mimeValidationIndex = functionBody.indexOf(mimeCheckSnippet); + const sharingAvailabilityIndex = functionBody.indexOf( + 'await assertMobileFileSharingAvailable()', + ); + if ( + mimeValidationIndex < 0 || + sharingAvailabilityIndex < 0 || + mimeValidationIndex > sharingAvailabilityIndex + ) { + throw new Error( + `mobile shell ${label} export must validate MIME before native sharing checks`, + ); + } } for (const [wrapperName, fileCall] of [