ReviewOS

also looking at this

stacks/stx

fix(native): type tab visibility and back gesture options

#2093
Merged chris wants to merge codex/native-navigation-options into main
3 files +53 -0
packages/stx/test/native/bridge-protocol.test.tsmodified+19-0
Changes to packages/stx/test/native/bridge-protocol.test.ts
@@ -1,5 +1,7 @@
11import { describe, expect, it } from 'bun:test'
22import { NativeCapabilityError, STXBridge } from '../../src/native/bridge/protocol'
3import { installCraftBridge } from '../../src/native/runtime/craft-bridge'
4import type { NativeNavigationOptions } from '../../src/native/runtime/craft'
35
46function host() {
57 const sent: Array<Record<string, any>> = []
@@ -15,6 +17,23 @@ function host() {
1517}
1618
1719describe('typed native capability bridge', () => {
20 it.each(['ios', 'android'])('preserves screen chrome options and explicit navigation on %s', (platform) => {
21 const native = host()
22 const protocol = new STXBridge()
23 protocol.initialize(native.bridge)
24 const craft = installCraftBridge(protocol, { ...native.bridge, platform }, {})
25 const options: NativeNavigationOptions = { hidden: true, tabBarHidden: true, swipeBack: false }
26 craft.navigation.setOptions(options)
27 craft.navigation.open('/feed')
28 craft.navigation.setOptions({ hidden: false, tabBarHidden: false, swipeBack: true })
29 expect(native.sent.map(({ type, payload }) => ({ type, payload }))).toEqual([
30 { type: 'NAVIGATION_SET_OPTIONS', payload: options },
31 { type: 'NAVIGATE_OPEN', payload: { path: '/feed' } },
32 { type: 'NAVIGATION_SET_OPTIONS', payload: { hidden: false, tabBarHidden: false, swipeBack: true } },
33 ])
34 protocol.dispose()
35 })
36
1837 it('sends protocol v1 and resolves a correlated response', async () => {
1938 const native = host()
2039 const bridge = new STXBridge()