@@ -5,7 +5,7 @@ import { getRouteFromDeepLink } from '../links/utils/urlHelpers';
55/**
66 * Arguments passed by Expo Router to `redirectSystemPath`.
77 */
8- export type NativeIntentArgs = {
8+ export type DetourNativeIntentArgs = {
99 /**
1010 * Incoming system path/URL that should be evaluated.
1111 */
@@ -19,21 +19,14 @@ export type NativeIntentArgs = {
1919/**
2020 * Function signature compatible with Expo Router native intent handlers.
2121 */
22- export type NativeIntentHandler = (
23- args : NativeIntentArgs
22+ export type DetourNativeIntentHandler = (
23+ args : DetourNativeIntentArgs
2424) => string | Promise < string > ;
2525
26- /**
27- * Match context with a parsed URL object.
28- */
29- export type NativeIntentMatchContext = NativeIntentArgs & {
30- url : URL ;
31- } ;
32-
3326/**
3427 * Value passed to `mapToRoute` after URL resolution.
3528 */
36- export type NativeIntentResolvedValue = {
29+ export type DetourNativeIntentResolvedValue = {
3730 /**
3831 * Original incoming system path passed by Expo Router.
3932 */
@@ -51,7 +44,10 @@ export type NativeIntentResolvedValue = {
5144/**
5245 * Resolve configuration for `createDetourNativeIntentHandler`.
5346 */
54- export type NativeIntentResolveConfig = Pick < Config , 'apiKey' | 'appID' > & {
47+ export type DetourNativeIntentResolveConfig = Pick <
48+ Config ,
49+ 'apiKey' | 'appID'
50+ > & {
5551 /**
5652 * Timeout for short-link resolution call.
5753 * Defaults to `1200` ms.
@@ -60,7 +56,7 @@ export type NativeIntentResolveConfig = Pick<Config, 'apiKey' | 'appID'> & {
6056 /**
6157 * Optional callback invoked when short-link resolution fails or times out.
6258 */
63- onResolveError ?: ( error : unknown , context : NativeIntentArgs ) => void ;
59+ onResolveError ?: ( error : unknown , context : DetourNativeIntentArgs ) => void ;
6460} ;
6561
6662/**
@@ -93,19 +89,14 @@ export type DetourNativeIntentOptions = {
9389 * Without this field, the handler works in intercept mode and simply returns
9490 * `fallbackPath` on host match.
9591 */
96- config ?: NativeIntentResolveConfig ;
92+ config ?: DetourNativeIntentResolveConfig ;
9793 /**
9894 * Optional mapping callback used in resolve mode.
9995 * If omitted, SDK uses the default mapping strategy.
10096 */
101- mapToRoute ?: ( value : NativeIntentResolvedValue ) => string ;
97+ mapToRoute ?: ( value : DetourNativeIntentResolvedValue ) => string ;
10298} ;
10399
104- /**
105- * Backward-compatible alias for options type.
106- */
107- export type NativeIntentOptions = DetourNativeIntentOptions ;
108-
109100const DEFAULT_HOSTS : Array < string | RegExp > = [ / \. g o d e t o u r \. l i n k $ / i] ;
110101const DEFAULT_TIMEOUT_MS = 1200 ;
111102
@@ -186,7 +177,9 @@ const normalizeRoute = (value: string, fallbackPath: string) => {
186177 * Custom scheme mapping:
187178 * - convert to Expo Router path (`myapp://app/details?id=1` -> `/app/details?id=1`)
188179 */
189- const defaultMapToRoute = ( { resolvedUrl } : NativeIntentResolvedValue ) => {
180+ const defaultMapToRoute = ( {
181+ resolvedUrl,
182+ } : DetourNativeIntentResolvedValue ) => {
190183 if ( ! isWebProtocol ( resolvedUrl ) ) {
191184 return getRouteFromDeepLink ( resolvedUrl ) ;
192185 }
@@ -249,7 +242,7 @@ const withTimeout = async <T>(promise: Promise<T>, timeoutMs: number) => {
249242 * @returns A `redirectSystemPath` handler function compatible with Expo Router.
250243 * @example
251244 * ```tsx title="app/+native-intent.tsx"
252- * import { createDetourNativeIntentHandler } from '@swmansion/react-native-detour';
245+ * import { createDetourNativeIntentHandler } from '@swmansion/react-native-detour/expo-router ';
253246 *
254247 * export const redirectSystemPath = createDetourNativeIntentHandler({
255248 * fallbackPath: '',
@@ -258,7 +251,7 @@ const withTimeout = async <T>(promise: Promise<T>, timeoutMs: number) => {
258251 *
259252 * @example
260253 * ```tsx title="app/+native-intent.tsx"
261- * import { createDetourNativeIntentHandler } from '@swmansion/react-native-detour';
254+ * import { createDetourNativeIntentHandler } from '@swmansion/react-native-detour/expo-router ';
262255 *
263256 * export const redirectSystemPath = createDetourNativeIntentHandler({
264257 * fallbackPath: '',
@@ -268,12 +261,12 @@ const withTimeout = async <T>(promise: Promise<T>, timeoutMs: number) => {
268261 *
269262 * @example
270263 * ```tsx title="app/+native-intent.tsx"
271- * import { createDetourNativeIntentHandler } from '@swmansion/react-native-detour';
264+ * import { createDetourNativeIntentHandler } from '@swmansion/react-native-detour/expo-router ';
272265 *
273266 * export const redirectSystemPath = createDetourNativeIntentHandler({
274267 * fallbackPath: '',
275268 * config: {
276- * API_KEY : process.env.EXPO_PUBLIC_DETOUR_API_KEY!,
269+ * apiKey : process.env.EXPO_PUBLIC_DETOUR_API_KEY!,
277270 * appID: process.env.EXPO_PUBLIC_DETOUR_APP_ID!,
278271 * timeoutMs: 1200,
279272 * },
@@ -285,12 +278,12 @@ const withTimeout = async <T>(promise: Promise<T>, timeoutMs: number) => {
285278 */
286279export const createDetourNativeIntentHandler = (
287280 options : DetourNativeIntentOptions = { }
288- ) : NativeIntentHandler => {
281+ ) : DetourNativeIntentHandler => {
289282 const fallbackPath = options . fallbackPath ?? '' ;
290283 const hosts = options . hosts ?. length ? options . hosts : DEFAULT_HOSTS ;
291284 const mapToRoute = options . mapToRoute ?? defaultMapToRoute ;
292285
293- return async ( { path, initial } : NativeIntentArgs ) => {
286+ return async ( { path, initial } : DetourNativeIntentArgs ) => {
294287 const url = parseIntentUrl ( path ) ;
295288 if ( ! url ?. hostname ) {
296289 return path ;
0 commit comments