收紧移动运行时能力上报
统一移动壳 host.getRuntime 的平台归一化来源 要求运行时 capabilities 复用同一个平台值 同步移动壳运行时能力边界记录
This commit is contained in:
@@ -1643,6 +1643,27 @@ if (!dispatchSource.includes('hostVersion: MOBILE_SHELL_HOST_VERSION')) {
|
||||
throw new Error('mobile shell runtime response must use the shared mobile shell host version');
|
||||
}
|
||||
|
||||
for (const runtimeSnippet of [
|
||||
'function getMobileRuntimePlatform()',
|
||||
"return Platform.OS === 'ios' ? 'ios' : 'android'",
|
||||
'function getRuntime()',
|
||||
'const platform = getMobileRuntimePlatform();',
|
||||
'platform,',
|
||||
'capabilities: resolveMobileHostCapabilities(platform)',
|
||||
"case 'host.getRuntime':",
|
||||
'return ok(request, getRuntime());',
|
||||
]) {
|
||||
if (!dispatchSource.includes(runtimeSnippet)) {
|
||||
throw new Error(`mobile shell runtime response missing ${runtimeSnippet}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (dispatchSource.includes('capabilities: resolveMobileHostCapabilities(),')) {
|
||||
throw new Error(
|
||||
'mobile shell runtime capabilities must use the same normalized platform reported in host.getRuntime',
|
||||
);
|
||||
}
|
||||
|
||||
for (const snippet of [
|
||||
"import appConfig from '../../app.json'",
|
||||
'resolveMobileShellHostVersion(',
|
||||
|
||||
@@ -219,6 +219,21 @@ function getColorScheme() {
|
||||
};
|
||||
}
|
||||
|
||||
function getMobileRuntimePlatform() {
|
||||
return Platform.OS === 'ios' ? 'ios' : 'android';
|
||||
}
|
||||
|
||||
function getRuntime() {
|
||||
const platform = getMobileRuntimePlatform();
|
||||
return {
|
||||
shell: 'expo_mobile',
|
||||
platform,
|
||||
hostVersion: MOBILE_SHELL_HOST_VERSION,
|
||||
bridgeVersion: HOST_BRIDGE_VERSION,
|
||||
capabilities: resolveMobileHostCapabilities(platform),
|
||||
};
|
||||
}
|
||||
|
||||
function openNativePage(payload: unknown) {
|
||||
if (!navigation) {
|
||||
throw unsupported('navigation.openNativePage');
|
||||
@@ -257,13 +272,7 @@ export async function dispatchMobileHostBridgeRequest(
|
||||
) {
|
||||
switch (request.method) {
|
||||
case 'host.getRuntime':
|
||||
return ok(request, {
|
||||
shell: 'expo_mobile',
|
||||
platform: Platform.OS === 'ios' ? 'ios' : 'android',
|
||||
hostVersion: MOBILE_SHELL_HOST_VERSION,
|
||||
bridgeVersion: HOST_BRIDGE_VERSION,
|
||||
capabilities: resolveMobileHostCapabilities(),
|
||||
});
|
||||
return ok(request, getRuntime());
|
||||
case 'appearance.getColorScheme':
|
||||
return ok(request, getColorScheme());
|
||||
case 'app.openExternalUrl':
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user