Skip to content

Commit 6f13f60

Browse files
authored
feat: export runtime transport helper (#395)
1 parent 966fcb2 commit 6f13f60

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/__tests__/metro-public.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
buildIosRuntimeHints,
2222
ensureMetroTunnel,
2323
prepareRemoteMetro,
24+
resolveRuntimeTransport,
2425
stopMetroTunnel,
2526
} from '../metro.ts';
2627

@@ -111,4 +112,15 @@ test('public metro helpers expose stable Node-facing wrappers', async () => {
111112
buildAndroidRuntimeHints('https://public.example.test').bundleUrl,
112113
'https://public.example.test/index.bundle?platform=android&dev=true&minify=false',
113114
);
115+
assert.deepEqual(
116+
resolveRuntimeTransport({
117+
platform: 'ios',
118+
bundleUrl: 'https://10.0.0.10:8082/index.bundle?platform=ios',
119+
}),
120+
{
121+
host: '10.0.0.10',
122+
port: 8082,
123+
scheme: 'https',
124+
},
125+
);
114126
});

src/metro.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import type { SessionRuntimeHints } from './contracts.ts';
22
import { buildMetroRuntimeHints, prepareMetroRuntime } from './client-metro.ts';
33
import { ensureMetroCompanion, stopMetroCompanion } from './client-metro-companion.ts';
4+
import { resolveRuntimeTransportHints } from './daemon/runtime-hints.ts';
45
export { buildBundleUrl, normalizeBaseUrl } from './utils/url.ts';
56

67
type EnvSource = NodeJS.ProcessEnv | Record<string, string | undefined>;
78

89
/** Re-export of {@link SessionRuntimeHints} under the Metro-specific alias used by public API consumers. */
910
export type MetroRuntimeHints = SessionRuntimeHints;
1011

12+
export function resolveRuntimeTransport(
13+
runtime: SessionRuntimeHints | undefined,
14+
): { host: string; port: number; scheme: 'http' | 'https' } | undefined {
15+
return resolveRuntimeTransportHints(runtime);
16+
}
17+
1118
export type MetroBridgeResult = {
1219
enabled: boolean;
1320
baseUrl: string;

0 commit comments

Comments
 (0)