收口H5桥接载荷边界
让H5 HostBridge facade 复用共享MIME清单 增加原生壳门禁拦截H5本地复制MIME边界 补充共享决策记录中的载荷边界约定
This commit is contained in:
@@ -965,6 +965,52 @@ function assertH5HostBridgeEventSubscriptionGates() {
|
||||
}
|
||||
}
|
||||
|
||||
function assertH5HostBridgePayloadBoundaries() {
|
||||
const h5HostBridgeSource = fs.readFileSync(
|
||||
'src/services/host-bridge/hostBridge.ts',
|
||||
'utf8',
|
||||
);
|
||||
|
||||
for (const sharedBoundary of [
|
||||
'HOST_BRIDGE_TEXT_MIME_TYPES',
|
||||
'HOST_BRIDGE_DOCUMENT_MIME_TYPES',
|
||||
'HOST_BRIDGE_IMAGE_MIME_TYPES',
|
||||
'HOST_BRIDGE_AUDIO_MIME_TYPES',
|
||||
]) {
|
||||
if (!h5HostBridgeSource.includes(`${sharedBoundary},`)) {
|
||||
throw new Error(
|
||||
`H5 HostBridge facade must import shared payload boundary ${sharedBoundary}`,
|
||||
);
|
||||
}
|
||||
if (new RegExp(`const ${sharedBoundary}\\s*=\\s*new Set`).test(h5HostBridgeSource)) {
|
||||
throw new Error(
|
||||
`H5 HostBridge facade must not redeclare shared payload boundary ${sharedBoundary}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const mimeLiteral of [
|
||||
"'text/plain'",
|
||||
"'text/markdown'",
|
||||
"'text/csv'",
|
||||
"'application/json'",
|
||||
"'image/png'",
|
||||
"'image/jpeg'",
|
||||
"'image/webp'",
|
||||
"'audio/mpeg'",
|
||||
"'audio/mp4'",
|
||||
"'audio/wav'",
|
||||
"'audio/ogg'",
|
||||
"'audio/webm'",
|
||||
]) {
|
||||
if (h5HostBridgeSource.includes(mimeLiteral)) {
|
||||
throw new Error(
|
||||
`H5 HostBridge facade must read MIME boundaries from shared contract instead of ${mimeLiteral}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function extractDocumentCapabilityList(source, marker) {
|
||||
const markerIndex = source.indexOf(marker);
|
||||
if (markerIndex === -1) {
|
||||
@@ -1613,6 +1659,9 @@ assertWechatMiniProgramCapabilityFlows();
|
||||
console.log('[check:native-shells] h5-host-bridge-event-subscription-gates');
|
||||
assertH5HostBridgeEventSubscriptionGates();
|
||||
|
||||
console.log('[check:native-shells] h5-host-bridge-payload-boundaries');
|
||||
assertH5HostBridgePayloadBoundaries();
|
||||
|
||||
console.log('[check:native-shells] production-shell-dev-scaffold-scan');
|
||||
assertNoProductionShellDevScaffoldTerms();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user