锁定移动壳生命周期映射门禁

移动壳配置检查反查生命周期映射函数和四类 AppState 测试

共享决策日志记录生命周期映射门禁约束
This commit is contained in:
2026-06-20 09:38:33 +08:00
parent 888c4bc4d5
commit 68bb9718d6
2 changed files with 44 additions and 0 deletions
@@ -150,6 +150,10 @@ const loadFailureTestPath = new URL(
const loadFailureTestSource = fs.readFileSync(loadFailureTestPath, 'utf8');
const runtimePath = new URL('../src/shell/runtime.ts', import.meta.url);
const runtimeSource = fs.readFileSync(runtimePath, 'utf8');
const lifecyclePath = new URL('../src/shell/lifecycle.ts', import.meta.url);
const lifecycleSource = fs.readFileSync(lifecyclePath, 'utf8');
const lifecycleTestPath = new URL('../src/shell/lifecycle.test.ts', import.meta.url);
const lifecycleTestSource = fs.readFileSync(lifecycleTestPath, 'utf8');
const safeAreaTestPath = new URL('../src/shell/safeArea.test.ts', import.meta.url);
const safeAreaTestSource = fs.readFileSync(safeAreaTestPath, 'utf8');
const sharedContractPath = new URL(
@@ -1397,6 +1401,39 @@ for (const snippet of [
}
}
for (const snippet of [
'lifecyclePayloadFromAppState',
"state === 'active'",
"state === 'background'",
"? 'background'",
": 'inactive'",
'focused: state === \'active\'',
'nativeState: state',
]) {
if (!lifecycleSource.includes(snippet)) {
throw new Error(`mobile shell lifecycle mapper missing ${snippet}`);
}
}
for (const snippet of [
"describe('lifecycle'",
"test('把 React Native AppState 映射为统一 HostBridge 生命周期状态'",
"lifecyclePayloadFromAppState('active')",
"lifecyclePayloadFromAppState('background')",
"lifecyclePayloadFromAppState('inactive')",
"lifecyclePayloadFromAppState('unknown')",
"state: 'active'",
"state: 'background'",
"state: 'inactive'",
'focused: true',
'focused: false',
"nativeState: 'unknown'",
]) {
if (!lifecycleTestSource.includes(snippet)) {
throw new Error(`mobile shell lifecycle tests missing ${snippet}`);
}
}
for (const snippet of [
'type HostBridgeEventName',
'isHostBridgeEventName',