收口宿主用户交互超时
将宿主用户交互长操作超时提升到共享 HostBridge 契约 让 H5 HostBridge facade 复用共享用户交互超时 增加原生壳门禁拦截 H5 facade 手写交互超时 补充 HostBridge 测试、壳方案和共享决策记录
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
import { afterEach, describe, expect, test, vi } from 'vitest';
|
||||
|
||||
import type { HostBridgeCapability } from '../../../packages/shared/src/contracts/hostBridge';
|
||||
import { HOST_BRIDGE_RUNTIME_REFRESH_TIMEOUT_MS } from '../../../packages/shared/src/contracts/hostBridge';
|
||||
import {
|
||||
HOST_BRIDGE_RUNTIME_REFRESH_TIMEOUT_MS,
|
||||
HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
} from '../../../packages/shared/src/contracts/hostBridge';
|
||||
import {
|
||||
canUseHostShareGrid,
|
||||
canUseNativeHostCapability,
|
||||
@@ -1194,13 +1197,13 @@ describe('hostBridge', () => {
|
||||
base64Data: 'c2hhcmUtY2FyZA==',
|
||||
mimeType: 'image/png',
|
||||
},
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importImage',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
@@ -1212,19 +1215,19 @@ describe('hostBridge', () => {
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importText',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importDocument',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importAudio',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
@@ -1427,7 +1430,7 @@ describe('hostBridge', () => {
|
||||
fileName: '作品记录.txt',
|
||||
content: 'content',
|
||||
},
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -1514,7 +1517,7 @@ describe('hostBridge', () => {
|
||||
base64Data: 'c2hhcmUtY2FyZA==',
|
||||
mimeType: 'image/png',
|
||||
},
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -1595,7 +1598,7 @@ describe('hostBridge', () => {
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importImage',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -1641,7 +1644,7 @@ describe('hostBridge', () => {
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importText',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -1689,7 +1692,7 @@ describe('hostBridge', () => {
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importDocument',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -1735,7 +1738,7 @@ describe('hostBridge', () => {
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'file.importAudio',
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -1788,7 +1791,7 @@ describe('hostBridge', () => {
|
||||
base64Data: 'YXVkaW8=',
|
||||
mimeType: 'audio/wav',
|
||||
},
|
||||
timeoutMs: 30000,
|
||||
timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
HOST_BRIDGE_RUNTIME_REFRESH_TIMEOUT_MS,
|
||||
HOST_BRIDGE_RUNTIME_CONTEXT_QUERY_KEY,
|
||||
HOST_BRIDGE_TEXT_MIME_TYPES,
|
||||
HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS,
|
||||
HOST_BRIDGE_WECHAT_MINI_PROGRAM_SOURCE_QUERY,
|
||||
isHostBridgeCapability,
|
||||
normalizeHostBridgeBadgeCount,
|
||||
@@ -781,7 +782,7 @@ export async function exportHostTextFile(
|
||||
return await requestNativeAppHostBridge<FileExportTextResult>(
|
||||
'file.exportText',
|
||||
params,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
);
|
||||
} catch (error) {
|
||||
if (isUnsupportedHostBridgeError(error)) {
|
||||
@@ -802,7 +803,7 @@ export async function exportHostImageFile(
|
||||
return await requestNativeAppHostBridge<FileExportImageResult>(
|
||||
'file.exportImage',
|
||||
params,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
);
|
||||
} catch (error) {
|
||||
if (isUnsupportedHostBridgeError(error)) {
|
||||
@@ -823,7 +824,7 @@ export async function exportHostAudioFile(
|
||||
return await requestNativeAppHostBridge<FileExportAudioResult>(
|
||||
'file.exportAudio',
|
||||
params,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
);
|
||||
} catch (error) {
|
||||
if (isUnsupportedHostBridgeError(error)) {
|
||||
@@ -888,7 +889,7 @@ export async function importHostImageFile() {
|
||||
await requestNativeAppHostBridge<FileImportImageResult>(
|
||||
'file.importImage',
|
||||
undefined,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -909,7 +910,7 @@ export async function captureHostImageFile() {
|
||||
await requestNativeAppHostBridge<FileImportImageResult>(
|
||||
'file.captureImage',
|
||||
undefined,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -984,7 +985,7 @@ export async function importHostTextFile() {
|
||||
await requestNativeAppHostBridge<FileImportTextResult>(
|
||||
'file.importText',
|
||||
undefined,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -1033,7 +1034,7 @@ export async function importHostDocumentFile() {
|
||||
await requestNativeAppHostBridge<FileImportDocumentResult>(
|
||||
'file.importDocument',
|
||||
undefined,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -1084,7 +1085,7 @@ export async function importHostAudioFile() {
|
||||
await requestNativeAppHostBridge<FileImportAudioResult>(
|
||||
'file.importAudio',
|
||||
undefined,
|
||||
{ timeoutMs: 30000 },
|
||||
{ timeoutMs: HOST_BRIDGE_USER_INTERACTION_TIMEOUT_MS },
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user