expo-router 4.0.0-preview.9 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/error.png +0 -0
- package/assets/file.png +0 -0
- package/assets/forward.png +0 -0
- package/assets/logotype.png +0 -0
- package/assets/pkg.png +0 -0
- package/assets/sitemap.png +0 -0
- package/build/ExpoRoot.js +2 -2
- package/build/ExpoRoot.js.map +1 -1
- package/build/doctor/index.d.ts +16 -0
- package/build/doctor/index.d.ts.map +1 -0
- package/build/doctor/index.js +66 -0
- package/build/doctor/index.js.map +1 -0
- package/build/exports.d.ts +1 -1
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +24 -2
- package/build/exports.js.map +1 -1
- package/build/fast-refresh.d.ts.map +1 -1
- package/build/fast-refresh.js.map +1 -1
- package/build/getRoutesCore.d.ts +1 -0
- package/build/getRoutesCore.d.ts.map +1 -1
- package/build/getRoutesCore.js +3 -1
- package/build/getRoutesCore.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +1 -2
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +4 -0
- package/build/global-state/routing.js.map +1 -1
- package/build/head/url.d.ts +1 -0
- package/build/head/url.d.ts.map +1 -1
- package/build/head/url.js +21 -4
- package/build/head/url.js.map +1 -1
- package/build/hooks.d.ts +90 -38
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +46 -39
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.d.ts +58 -15
- package/build/imperative-api.d.ts.map +1 -1
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/Drawer.d.ts +2 -142
- package/build/layouts/Drawer.d.ts.map +1 -1
- package/build/layouts/Drawer.js +8 -5
- package/build/layouts/Drawer.js.map +1 -1
- package/build/layouts/DrawerClient.d.ts +144 -0
- package/build/layouts/DrawerClient.d.ts.map +1 -0
- package/build/layouts/DrawerClient.js +10 -0
- package/build/layouts/DrawerClient.js.map +1 -0
- package/build/layouts/Stack.d.ts +2 -126
- package/build/layouts/Stack.d.ts.map +1 -1
- package/build/layouts/Stack.js +8 -6
- package/build/layouts/Stack.js.map +1 -1
- package/build/layouts/StackClient.d.ts +128 -0
- package/build/layouts/StackClient.d.ts.map +1 -0
- package/build/layouts/StackClient.js +10 -0
- package/build/layouts/StackClient.js.map +1 -0
- package/build/layouts/Tabs.d.ts +2 -134
- package/build/layouts/Tabs.d.ts.map +1 -1
- package/build/layouts/Tabs.js +5 -37
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +136 -0
- package/build/layouts/TabsClient.d.ts.map +1 -0
- package/build/layouts/TabsClient.js +44 -0
- package/build/layouts/TabsClient.js.map +1 -0
- package/build/layouts/withLayoutContext.d.ts +4 -1
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +4 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +48 -4
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +47 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/href.d.ts +1 -1
- package/build/link/href.d.ts.map +1 -1
- package/build/link/href.js.map +1 -1
- package/build/link/useLinkHooks.d.ts +122 -29
- package/build/link/useLinkHooks.d.ts.map +1 -1
- package/build/link/useLinkHooks.js.map +1 -1
- package/build/onboard/Tutorial.d.ts.map +1 -1
- package/build/onboard/Tutorial.js +140 -86
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +1 -2
- package/build/renderRootComponent.js.map +1 -1
- package/build/rsc/exports.d.ts +3 -1
- package/build/rsc/exports.d.ts.map +1 -1
- package/build/rsc/exports.js +3 -1
- package/build/rsc/exports.js.map +1 -1
- package/build/rsc/middleware.d.ts +1 -1
- package/build/rsc/middleware.d.ts.map +1 -1
- package/build/rsc/middleware.js +2 -1
- package/build/rsc/middleware.js.map +1 -1
- package/build/rsc/router/client.d.ts +2 -2
- package/build/rsc/router/client.d.ts.map +1 -1
- package/build/rsc/router/client.js.map +1 -1
- package/build/rsc/router/host.d.ts.map +1 -1
- package/build/rsc/router/host.js +20 -15
- package/build/rsc/router/host.js.map +1 -1
- package/build/rsc/rsc-renderer.d.ts +1 -1
- package/build/rsc/rsc-renderer.d.ts.map +1 -1
- package/build/rsc/rsc-renderer.js +1 -1
- package/build/rsc/rsc-renderer.js.map +1 -1
- package/build/rsc/server.d.ts +3 -0
- package/build/rsc/server.d.ts.map +1 -1
- package/build/rsc/server.js +19 -1
- package/build/rsc/server.js.map +1 -1
- package/build/testing-library/context-stubs.d.ts.map +1 -1
- package/build/testing-library/context-stubs.js +3 -1
- package/build/testing-library/context-stubs.js.map +1 -1
- package/build/testing-library/mocks.js +14 -13
- package/build/testing-library/mocks.js.map +1 -1
- package/build/typed-routes/generate.d.ts +5 -1
- package/build/typed-routes/generate.d.ts.map +1 -1
- package/build/typed-routes/generate.js +129 -64
- package/build/typed-routes/generate.js.map +1 -1
- package/build/typed-routes/index.d.ts +5 -0
- package/build/typed-routes/index.d.ts.map +1 -1
- package/build/typed-routes/index.js +8 -3
- package/build/typed-routes/index.js.map +1 -1
- package/build/typed-routes/testSetup.d.ts +1 -1
- package/build/typed-routes/testSetup.d.ts.map +1 -1
- package/build/typed-routes/testSetup.js +29 -17
- package/build/typed-routes/testSetup.js.map +1 -1
- package/build/typed-routes/types.d.ts +43 -145
- package/build/typed-routes/types.d.ts.map +1 -1
- package/build/typed-routes/types.js.map +1 -1
- package/build/types.d.ts +33 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/ui/TabContext.d.ts +158 -1
- package/build/ui/TabContext.d.ts.map +1 -1
- package/build/ui/TabContext.js +25 -1
- package/build/ui/TabContext.js.map +1 -1
- package/build/ui/TabList.d.ts +17 -1
- package/build/ui/TabList.d.ts.map +1 -1
- package/build/ui/TabList.js +16 -0
- package/build/ui/TabList.js.map +1 -1
- package/build/ui/TabSlot.d.ts +55 -5
- package/build/ui/TabSlot.d.ts.map +1 -1
- package/build/ui/TabSlot.js +38 -14
- package/build/ui/TabSlot.js.map +1 -1
- package/build/ui/TabTrigger.d.ts +65 -70
- package/build/ui/TabTrigger.d.ts.map +1 -1
- package/build/ui/TabTrigger.js +25 -1
- package/build/ui/TabTrigger.js.map +1 -1
- package/build/ui/Tabs.d.ts +89 -132
- package/build/ui/Tabs.d.ts.map +1 -1
- package/build/ui/Tabs.js +53 -8
- package/build/ui/Tabs.js.map +1 -1
- package/build/ui/common.d.ts +3 -3
- package/build/ui/common.d.ts.map +1 -1
- package/build/ui/common.js.map +1 -1
- package/build/useFocusEffect.d.ts +15 -6
- package/build/useFocusEffect.d.ts.map +1 -1
- package/build/useFocusEffect.js +15 -6
- package/build/useFocusEffect.js.map +1 -1
- package/build/useNavigation.d.ts +11 -5
- package/build/useNavigation.d.ts.map +1 -1
- package/build/useNavigation.js +11 -5
- package/build/useNavigation.js.map +1 -1
- package/build/utils/splash.d.ts +6 -0
- package/build/utils/splash.d.ts.map +1 -0
- package/build/utils/splash.js +51 -0
- package/build/utils/splash.js.map +1 -0
- package/build/utils/url.js +2 -2
- package/build/utils/url.js.map +1 -1
- package/build/views/Navigator.d.ts +6 -5
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Navigator.js +6 -5
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Sitemap.d.ts.map +1 -1
- package/build/views/Sitemap.js +93 -46
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/Splash.d.ts +1 -1
- package/build/views/Splash.d.ts.map +1 -1
- package/build/views/Splash.js +3 -13
- package/build/views/Splash.js.map +1 -1
- package/build/views/Try.d.ts +1 -1
- package/build/views/Try.d.ts.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/doctor.js +1 -0
- package/entry-classic.js +0 -6
- package/package.json +23 -24
- package/plugin/build/index.d.ts +2 -0
- package/plugin/options.json +74 -73
- package/plugin/src/index.ts +64 -0
- package/rsc/entry.js +0 -6
- package/rsc/headers.d.ts +3 -0
- package/rsc/headers.js +5 -0
- package/build/rsc/runtime.d.ts +0 -9
- package/build/rsc/runtime.d.ts.map +0 -1
- package/build/rsc/runtime.js +0 -36
- package/build/rsc/runtime.js.map +0 -1
- package/virtual-client-boundaries.js +0 -1
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.regenerateDeclarations = exports.getWatchHandler = void 0;
|
|
6
|
+
exports.regenerateDeclarations = exports.getWatchHandler = exports.version = void 0;
|
|
7
7
|
const _ctx_shared_1 = require("expo-router/_ctx-shared");
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -11,6 +11,11 @@ const generate_1 = require("./generate");
|
|
|
11
11
|
const matchers_1 = require("../matchers");
|
|
12
12
|
const require_context_ponyfill_1 = __importDefault(require("../testing-library/require-context-ponyfill"));
|
|
13
13
|
const defaultCtx = (0, require_context_ponyfill_1.default)(process.env.EXPO_ROUTER_APP_ROOT, true, _ctx_shared_1.EXPO_ROUTER_CTX_IGNORE);
|
|
14
|
+
/**
|
|
15
|
+
* This file is imported via `@expo/cli`. While users should be using the same SDK version of `expo-router` as `@expo/cli`,
|
|
16
|
+
* this export allows us to ensure that the version of the `expo-router` package is compatible with the version of `@expo/cli`.
|
|
17
|
+
*/
|
|
18
|
+
exports.version = 52;
|
|
14
19
|
/**
|
|
15
20
|
* Generate a Metro watch handler that regenerates the typed routes declaration file
|
|
16
21
|
*/
|
|
@@ -64,10 +69,10 @@ exports.getWatchHandler = getWatchHandler;
|
|
|
64
69
|
*
|
|
65
70
|
* If you process the types after the ADD, then they will crash as you will have conflicting routes
|
|
66
71
|
*/
|
|
67
|
-
exports.regenerateDeclarations = debounce((outputDir, ctx = defaultCtx) => {
|
|
72
|
+
exports.regenerateDeclarations = debounce((outputDir, options = {}, ctx = defaultCtx) => {
|
|
68
73
|
// Don't crash the process, just log the error. The user will most likely fix it and continue
|
|
69
74
|
try {
|
|
70
|
-
const file = (0, generate_1.getTypedRoutesDeclarationFile)(ctx);
|
|
75
|
+
const file = (0, generate_1.getTypedRoutesDeclarationFile)(ctx, options);
|
|
71
76
|
if (!file)
|
|
72
77
|
return;
|
|
73
78
|
node_fs_1.default.writeFileSync(node_path_1.default.resolve(outputDir, './router.d.ts'), file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/typed-routes/index.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAiE;AACjE,sDAAyB;AACzB,0DAA6B;AAE7B,yCAA2D;AAC3D,0CAA2C;AAC3C,2GAEqD;AAErD,MAAM,UAAU,GAAG,IAAA,kCAAc,EAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,oCAAsB,CAAC,CAAC;AAIlG;;GAEG;AACH,SAAgB,eAAe,CAC7B,SAAiB,EACjB,EAAE,GAAG,GAAG,UAAU,EAAE,YAAY,GAAG,8BAAsB,EAAE,GAAG,EAAE,CAAC,sBAAsB;;IAEvF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE1E,OAAO,KAAK,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAsC;QACnF,qDAAqD;QACrD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB;YAAE,OAAO;QAE9C,IAAI,gBAAgB,GAAG,KAAK,CAAC;QAC7B,IAAI,YAAY,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import { EXPO_ROUTER_CTX_IGNORE } from 'expo-router/_ctx-shared';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { getTypedRoutesDeclarationFile } from './generate';\nimport { isTypedRoute } from '../matchers';\nimport requireContext, {\n RequireContextPonyFill,\n} from '../testing-library/require-context-ponyfill';\n\nconst defaultCtx = requireContext(process.env.EXPO_ROUTER_APP_ROOT, true, EXPO_ROUTER_CTX_IGNORE);\n\nexport type { RequireContextPonyFill } from '../testing-library/require-context-ponyfill';\n\n/**\n * This file is imported via `@expo/cli`. While users should be using the same SDK version of `expo-router` as `@expo/cli`,\n * this export allows us to ensure that the version of the `expo-router` package is compatible with the version of `@expo/cli`.\n */\nexport const version = 52;\n\n/**\n * Generate a Metro watch handler that regenerates the typed routes declaration file\n */\nexport function getWatchHandler(\n outputDir: string,\n { ctx = defaultCtx, regenerateFn = regenerateDeclarations } = {} // Exposed for testing\n) {\n const routeFiles = new Set(ctx.keys().filter((key) => isTypedRoute(key)));\n\n return async function callback({ filePath, type }: { filePath: string; type: string }) {\n // Sanity check that we are in an Expo Router project\n if (!process.env.EXPO_ROUTER_APP_ROOT) return;\n\n let shouldRegenerate = false;\n let relativePath = path.relative(process.env.EXPO_ROUTER_APP_ROOT, filePath);\n const isInsideAppRoot = !relativePath.startsWith('../');\n const basename = path.basename(relativePath);\n\n if (!isInsideAppRoot) return;\n\n // require.context paths always start with './' when relative to the root\n relativePath = `./${relativePath}`;\n\n if (type === 'delete') {\n ctx.__delete(relativePath);\n if (routeFiles.has(relativePath)) {\n routeFiles.delete(relativePath);\n shouldRegenerate = true;\n }\n } else if (type === 'add') {\n ctx.__add(relativePath);\n if (isTypedRoute(basename)) {\n routeFiles.add(relativePath);\n shouldRegenerate = true;\n }\n } else {\n shouldRegenerate = routeFiles.has(relativePath);\n }\n\n if (shouldRegenerate) {\n regenerateFn(outputDir, ctx);\n }\n };\n}\n\n/**\n * Regenerate the declaration file.\n *\n * This function needs to be debounced due to Metro's handling of renaming folders.\n * For example, if you have the file /(tabs)/route.tsx and you rename the folder to /(tabs,test)/route.tsx\n *\n * Metro will fire 2 filesystem events:\n * - ADD /(tabs,test)/router.tsx\n * - DELETE /(tabs)/router.tsx\n *\n * If you process the types after the ADD, then they will crash as you will have conflicting routes\n */\nexport const regenerateDeclarations = debounce(\n (\n outputDir: string,\n options: { partialTypedGroups?: boolean } = {},\n ctx: RequireContextPonyFill = defaultCtx\n ) => {\n // Don't crash the process, just log the error. The user will most likely fix it and continue\n try {\n const file = getTypedRoutesDeclarationFile(ctx, options);\n if (!file) return;\n fs.writeFileSync(path.resolve(outputDir, './router.d.ts'), file);\n } catch (error) {\n console.error(error);\n }\n }\n);\n\n/**\n * Debounce a function to only run once after a period of inactivity\n * If called while waiting, it will reset the timer\n */\nfunction debounce<T extends (...args: any[]) => any>(fn: T, timeout: number = 1000) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n fn(...args);\n }, timeout);\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=testSetup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testSetup.d.ts","sourceRoot":"","sources":["../../src/typed-routes/testSetup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testSetup.d.ts","sourceRoot":"","sources":["../../src/typed-routes/testSetup.ts"],"names":[],"mappings":""}
|
|
@@ -5,25 +5,37 @@ const path_1 = require("path");
|
|
|
5
5
|
const generate_1 = require("./generate");
|
|
6
6
|
const context_stubs_1 = require("../testing-library/context-stubs");
|
|
7
7
|
const fixtures = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
default: {
|
|
9
|
+
context: {
|
|
10
|
+
'/apple': () => null,
|
|
11
|
+
'/banana': () => null,
|
|
12
|
+
'/colors/[color]': () => null,
|
|
13
|
+
'/animals/[...animal]': () => null,
|
|
14
|
+
'/mix/[fruit]/[color]/[...animals]': () => null,
|
|
15
|
+
'/(group)/static': () => null,
|
|
16
|
+
'/(group)/(a,b)/folder/index': () => null,
|
|
17
|
+
'/(group)/(a,b)/folder/[slug]': () => null,
|
|
18
|
+
'/(group)/(a,b)/folder/[...slug]': () => null,
|
|
19
|
+
'/(c)/folder/[slug]': () => null,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
partialGroups: {
|
|
23
|
+
options: { partialTypedGroups: true },
|
|
24
|
+
context: {
|
|
25
|
+
'/(group)/static': () => null,
|
|
26
|
+
'/(group)/(a,b)/folder/index': () => null,
|
|
27
|
+
'/(group)/(a,b)/folder/[slug]': () => null,
|
|
28
|
+
'/(group)/(a,b)/folder/[...slug]': () => null,
|
|
29
|
+
},
|
|
19
30
|
},
|
|
20
31
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const template = (0, generate_1.getTypedRoutesDeclarationFile)((0, context_stubs_1.inMemoryContext)(value)
|
|
32
|
+
module.exports = function () {
|
|
33
|
+
return Promise.all(Object.entries(fixtures).map(async ([key, value]) => {
|
|
34
|
+
const template = (0, generate_1.getTypedRoutesDeclarationFile)((0, context_stubs_1.inMemoryContext)(value.context), {
|
|
35
|
+
...value.options,
|
|
36
|
+
testIgnoreComments: true,
|
|
37
|
+
});
|
|
24
38
|
return (0, promises_1.writeFile)((0, path_1.join)(__dirname, '/__tests__/fixtures/', key + '.d.ts'), template);
|
|
25
39
|
}));
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
exports.default = default_1;
|
|
40
|
+
};
|
|
29
41
|
//# sourceMappingURL=testSetup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testSetup.js","sourceRoot":"","sources":["../../src/typed-routes/testSetup.ts"],"names":[],"mappings":";;AAAA,0CAAwC;AACxC,+B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AC7E,GAAG,KAAK,CAAC,OAAO;YAChB,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;QAEH,OAAO,IAAA,oBAAS,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,sBAAsB,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;IACrF,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { getTypedRoutesDeclarationFile, GetTypedRoutesDeclarationFileOptions } from './generate';\nimport { inMemoryContext, MemoryContext } from '../testing-library/context-stubs';\n\nconst fixtures: Record<\n string,\n { context: MemoryContext; options?: GetTypedRoutesDeclarationFileOptions }\n> = {\n default: {\n context: {\n '/apple': () => null,\n '/banana': () => null,\n '/colors/[color]': () => null,\n '/animals/[...animal]': () => null,\n '/mix/[fruit]/[color]/[...animals]': () => null,\n '/(group)/static': () => null,\n '/(group)/(a,b)/folder/index': () => null,\n '/(group)/(a,b)/folder/[slug]': () => null,\n '/(group)/(a,b)/folder/[...slug]': () => null,\n '/(c)/folder/[slug]': () => null,\n },\n },\n partialGroups: {\n options: { partialTypedGroups: true },\n context: {\n '/(group)/static': () => null,\n '/(group)/(a,b)/folder/index': () => null,\n '/(group)/(a,b)/folder/[slug]': () => null,\n '/(group)/(a,b)/folder/[...slug]': () => null,\n },\n },\n};\n\nmodule.exports = function () {\n return Promise.all(\n Object.entries(fixtures).map(async ([key, value]) => {\n const template = getTypedRoutesDeclarationFile(inMemoryContext(value.context), {\n ...value.options,\n testIgnoreComments: true,\n });\n\n return writeFile(join(__dirname, '/__tests__/fixtures/', key + '.d.ts'), template);\n })\n );\n};\n"]}
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @hidden
|
|
3
|
-
*/
|
|
4
|
-
type HasTypedRoutes = ExpoRouter.__routes extends {
|
|
5
|
-
StaticRoutes: string;
|
|
6
|
-
} ? true : false;
|
|
7
|
-
/**
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
export type StaticRoutes = ExpoRouter.__routes extends {
|
|
11
|
-
StaticRoutes: string;
|
|
12
|
-
} ? ExpoRouter.__routes['StaticRoutes'] : string;
|
|
13
|
-
/**
|
|
14
|
-
* @hidden
|
|
15
|
-
*/
|
|
16
|
-
export type DynamicRoutes<T extends string> = ExpoRouter.__routes<T> extends {
|
|
17
|
-
DynamicRoutes: any;
|
|
18
|
-
} ? T extends ExpoRouter.__routes<infer _>['DynamicRoutes'] ? T : never : string;
|
|
19
|
-
/**
|
|
20
|
-
* @hidden
|
|
21
|
-
*/
|
|
22
|
-
export type DynamicRouteTemplate = ExpoRouter.__routes extends {
|
|
23
|
-
DynamicRouteTemplate: string;
|
|
24
|
-
} ? ExpoRouter.__routes['DynamicRouteTemplate'] : string;
|
|
25
1
|
/**
|
|
26
2
|
* The main routing type for Expo Router.
|
|
27
3
|
*
|
|
@@ -29,70 +5,54 @@ export type DynamicRouteTemplate = ExpoRouter.__routes extends {
|
|
|
29
5
|
* @hidden
|
|
30
6
|
*/
|
|
31
7
|
export declare namespace ExpoRouter {
|
|
32
|
-
interface __routes
|
|
8
|
+
interface __routes {
|
|
33
9
|
}
|
|
34
10
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export type
|
|
39
|
-
|
|
40
|
-
|
|
11
|
+
export type RelativePathString = `./${string}` | `../${string}` | '..';
|
|
12
|
+
export type SearchOrHash = `?${string}` | `#${string}`;
|
|
13
|
+
export type ExternalPathString = `${string}:${string}` | `//${string}`;
|
|
14
|
+
export type Route = Exclude<Extract<Href, object>['pathname'], // Use the HrefObject, as it doesn't have query params
|
|
15
|
+
// Use the HrefObject, as it doesn't have query params
|
|
16
|
+
RelativePathString | ExternalPathString>;
|
|
17
|
+
/**
|
|
18
|
+
* The main routing type for Expo Router. It includes all available routes with strongly
|
|
19
|
+
* typed parameters. It can either be:
|
|
20
|
+
* - **string**: A full path like `/profile/settings` or a relative path like `../settings`.
|
|
21
|
+
* - **object**: An object with a `pathname` and optional `params`. The `pathname` can be
|
|
22
|
+
* a full path like `/profile/settings` or a relative path like `../settings`.
|
|
23
|
+
* The params can be an object of key-value pairs.
|
|
41
24
|
*
|
|
42
25
|
* A Href can either be a string or an object.
|
|
43
|
-
*
|
|
44
|
-
* Href accepts an optional T parameter to correctly type dynamic routes string.
|
|
45
|
-
*
|
|
46
|
-
* For example: Without the generic the route `/folder/[slug]` will be typed as `/folder/${string}`,
|
|
47
|
-
* which is incorrect as `/folder/apple/orange` would be valid. But by passing desired route as a generic `Href<'/folder/apple'>`,
|
|
48
|
-
* it will validate against this edge case.
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
export type Href<T extends string | object = {
|
|
52
|
-
__branded__: any;
|
|
53
|
-
}> = GeneratedHref<T>;
|
|
54
|
-
/**
|
|
55
|
-
* @hidden
|
|
56
|
-
*/
|
|
57
|
-
type GeneratedHref<T extends string | object> = StaticRouteToHrefString<AllUngroupedRoutes<StaticRoutes> | RelativePathString | ExternalPathString> | StaticRouteToHrefObject<AllUngroupedRoutes<StaticRoutes> | RelativePathString | ExternalPathString> | DynamicRouteString<T> | DynamicTemplateToHrefObject<DynamicRouteTemplate>;
|
|
58
|
-
/**
|
|
59
|
-
* Converts a static route to a Href string type.
|
|
60
26
|
*/
|
|
61
|
-
type
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
27
|
+
export type Href = ExpoRouter.__routes extends {
|
|
28
|
+
href: any;
|
|
29
|
+
} ? ExpoRouter.__routes['href'] : string | {
|
|
30
|
+
pathname: string;
|
|
31
|
+
params?: UnknownInputParams;
|
|
32
|
+
};
|
|
33
|
+
export type HrefInputParams = ExpoRouter.__routes extends {
|
|
34
|
+
hrefInputParams: any;
|
|
35
|
+
} ? ExpoRouter.__routes['hrefInputParams'] : {
|
|
36
|
+
pathname: string;
|
|
37
|
+
params?: UnknownInputParams;
|
|
38
|
+
};
|
|
39
|
+
export type HrefOutputParams = ExpoRouter.__routes extends {
|
|
40
|
+
hrefOutputParams: any;
|
|
41
|
+
} ? ExpoRouter.__routes['hrefOutputParams'] : {
|
|
42
|
+
pathname: string;
|
|
43
|
+
params?: UnknownOutputParams;
|
|
44
|
+
};
|
|
45
|
+
export type RouteInputParams<T extends Route> = Extract<Href, {
|
|
66
46
|
pathname: T;
|
|
67
|
-
|
|
68
|
-
} : never;
|
|
69
|
-
/**
|
|
70
|
-
* Converts a dynamic route template to a `Href` string type.
|
|
71
|
-
*/
|
|
72
|
-
type DynamicRouteString<T extends string | object, P = DynamicRouteTemplate> = '__branded__' extends keyof T ? DynamicTemplateToHrefString<P> : T extends string ? DynamicRoutes<T> : never;
|
|
73
|
-
/**
|
|
74
|
-
* @hidden
|
|
75
|
-
*/
|
|
76
|
-
export type DynamicTemplateToHrefString<Path> = Path extends `${infer PartA}/${infer PartB}` ? `${PartA extends `[${string}]` ? string : PartA}/${DynamicTemplateToHrefString<PartB>}` : Path extends `[${string}]` ? string : Path;
|
|
77
|
-
/**
|
|
78
|
-
* Converts a dynamic route object to a `Href` object.
|
|
79
|
-
*/
|
|
80
|
-
type DynamicTemplateToHrefObject<T extends string> = T extends string ? {
|
|
47
|
+
}> extends never ? HrefInputParams extends infer H ? H extends Record<'pathname' | 'params', any> ? T extends H['pathname'] ? H['params'] : never : never : never : Extract<HrefInputParams, {
|
|
81
48
|
pathname: T;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
type
|
|
89
|
-
type ExternalPathString = `${string}:${string}`;
|
|
90
|
-
/**
|
|
91
|
-
* Given a route. Returns a union of both that route with and without the groups.
|
|
92
|
-
*
|
|
93
|
-
* The type is recursive and will provide a union of all possible routes.
|
|
94
|
-
*/
|
|
95
|
-
type AllUngroupedRoutes<Path> = Path extends `(${infer PartA})/${infer PartB}` ? `(${PartA})/${AllUngroupedRoutes<PartB>}` | AllUngroupedRoutes<PartB> : Path;
|
|
49
|
+
}>['params'];
|
|
50
|
+
export type RouteOutputParams<T extends Route> = Extract<HrefOutputParams, {
|
|
51
|
+
pathname: T;
|
|
52
|
+
}> extends never ? HrefOutputParams extends infer H ? H extends Record<'pathname' | 'params', any> ? T extends H['pathname'] ? H['params'] : never : never : never : Extract<HrefOutputParams, {
|
|
53
|
+
pathname: T;
|
|
54
|
+
}>['params'];
|
|
55
|
+
export type RouteParams<T extends Route> = RouteOutputParams<T>;
|
|
96
56
|
/**
|
|
97
57
|
* Routes can have known inputs (e.g query params).
|
|
98
58
|
* Unlike outputs, inputs can be `undefined` or `null`.
|
|
@@ -107,27 +67,6 @@ export type UnknownInputParams = Record<string, string | number | undefined | nu
|
|
|
107
67
|
* @hidden
|
|
108
68
|
*/
|
|
109
69
|
export type UnknownOutputParams = Record<string, string | string[]>;
|
|
110
|
-
/**
|
|
111
|
-
* Return the name of a route parameter
|
|
112
|
-
* @example
|
|
113
|
-
* ```
|
|
114
|
-
* '[test]' -> 'test'
|
|
115
|
-
* 'test' -> never
|
|
116
|
-
* '[...test]' -> '...test'
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
type IsParameter<Part> = Part extends `[${infer ParamName}]` ? ParamName : never;
|
|
120
|
-
/**
|
|
121
|
-
* Return a union of all raw parameter names. If there are no names return never.
|
|
122
|
-
*
|
|
123
|
-
* This differs from ParameterNames as it returns the `...` for catch all parameters.
|
|
124
|
-
* @example
|
|
125
|
-
* ```
|
|
126
|
-
* /[test] -> 'test'
|
|
127
|
-
* /[abc]/[...def] -> 'abc'|'...def'
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
type ParameterNames<Path> = Path extends `${infer PartA}/${infer PartB}` ? PartA extends '.' ? ParameterNames<PartB> : IsParameter<PartA> | ParameterNames<PartB> : IsParameter<Path>;
|
|
131
70
|
/**
|
|
132
71
|
* Return only the RoutePart of a string. If the string has multiple parts return never
|
|
133
72
|
*
|
|
@@ -142,47 +81,7 @@ type ParameterNames<Path> = Path extends `${infer PartA}/${infer PartB}` ? PartA
|
|
|
142
81
|
*
|
|
143
82
|
* @hidden
|
|
144
83
|
*/
|
|
145
|
-
export type SingleRoutePart<S extends string> = S extends `${string}/${string}` ? never : S extends `${string}${SearchOrHash}` ? never : S extends '' ? never : S extends `(${string})` ? never : S extends `[${string}]` ? never : S;
|
|
146
|
-
/**
|
|
147
|
-
* Returns a Record of the routes parameters as strings and CatchAll parameters
|
|
148
|
-
*
|
|
149
|
-
* There are two versions, input and output, as you can input 'string | number' but
|
|
150
|
-
* the output will always be 'string'
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```
|
|
154
|
-
* /[id]/[...rest] -> { id: string, rest: string[] }
|
|
155
|
-
* /no-params -> {}
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
export type StrictRouteParamsInputs<Path> = {
|
|
159
|
-
[Key in ParameterNames<Path> as Key extends `...${infer Name}` ? Name : Key]: Key extends `...${string}` ? (string | number)[] : string | number;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Returns a Record of the routes parameters as strings and CatchAll parameters
|
|
163
|
-
*
|
|
164
|
-
* There are two versions, input and output, as you can input 'string | number' but
|
|
165
|
-
* the output will always be 'string'
|
|
166
|
-
*
|
|
167
|
-
* @see {@link StrictRouteParamsInputs} for the input version
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```
|
|
171
|
-
* /[id]/[...rest] -> { id: string, rest: string[] }
|
|
172
|
-
* /no-params -> {}
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
export type StrictRouteParamsOutput<Path> = {
|
|
176
|
-
[Key in ParameterNames<Path> as Key extends `...${infer Name}` ? Name : Key]: Key extends `...${string}` ? string[] : string;
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* @hidden
|
|
180
|
-
*/
|
|
181
|
-
export type RouteParamInput<Path> = StrictRouteParamsInputs<Path> & UnknownInputParams;
|
|
182
|
-
/**
|
|
183
|
-
* @hidden
|
|
184
|
-
*/
|
|
185
|
-
export type RouteParams<PathOrObject extends Routes | UnknownOutputParams, ExtraPathOrObject extends UnknownOutputParams = UnknownOutputParams> = PathOrObject extends string ? StrictRouteParamsOutput<PathOrObject> & ExtraPathOrObject : PathOrObject;
|
|
84
|
+
export type SingleRoutePart<S extends string | object> = S extends object ? never : S extends `${string}/${string}` ? never : S extends `${string}${SearchOrHash}` ? never : S extends '' ? never : S extends `(${string})` ? never : S extends `[${string}]` ? never : S;
|
|
186
85
|
/**
|
|
187
86
|
* @deprecated Use `RouteParams` or `StrictRouteParams` instead.
|
|
188
87
|
*
|
|
@@ -192,6 +91,5 @@ export type SearchParams<T extends string = never> = RouteParams<T>;
|
|
|
192
91
|
/**
|
|
193
92
|
* @hidden
|
|
194
93
|
*/
|
|
195
|
-
export type RouteSegments<
|
|
196
|
-
export {};
|
|
94
|
+
export type RouteSegments<HrefOrSegments extends Route | string[]> = HrefOrSegments extends string[] ? HrefOrSegments : HrefOrSegments extends `.${string}` ? never : HrefOrSegments extends `` ? never : HrefOrSegments extends `/${infer PartA}` ? RouteSegments<PartA> : HrefOrSegments extends `${infer PartA}?${string}` ? RouteSegments<PartA> : HrefOrSegments extends `${infer PartA}#${string}` ? RouteSegments<PartA> : HrefOrSegments extends `${infer PartA}/${infer PartB}` ? [PartA, ...RouteSegments<PartB>] : [HrefOrSegments];
|
|
197
95
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,yBAAiB,UAAU,CAAC;IAE1B,UAAiB,QAAQ;KAAG;CAC7B;AAED,MAAM,MAAM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AG,MAAM,IAAI,CAAC,SAAS,MAAM,GACrE,KAAK,GACL,CAAC,SAAS,GAAG,MAAM,IAAI,MAAM,EAAE,GAC7B,KAAK,GACL,CAAC,SAAS,GAAG,MAAM,GAAG,YAAY,EAAE,GAClC,KAAK,GACL,CAAC,SAAS,EAAE,GACV,KAAK,GACL,CAAC,SAAS,IAAI,MAAM,GAAG,GACrB,KAAK,GACL,CAAC,SAAS,IAAI,MAAM,GAAG,GACrB,KAAK,GACL,CAAC,CAAC;AAEhB;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,cAAc,SAAS,KAAK,GAAG,MAAM,EAAE,IAAI,cAAc,SAAS,MAAM,EAAE,GAChG,cAAc,GACd,cAAc,SAAS,IAAI,MAAM,EAAE,GACjC,KAAK,GACL,cAAc,SAAS,EAAE,GACvB,KAAK,GACL,cAAc,SAAS,IAAI,MAAM,KAAK,EAAE,GACtC,aAAa,CAAC,KAAK,CAAC,GACpB,cAAc,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,EAAE,GAC/C,aAAa,CAAC,KAAK,CAAC,GACpB,cAAc,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,EAAE,GAC/C,aAAa,CAAC,KAAK,CAAC,GACpB,cAAc,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK,EAAE,GACpD,CAAC,KAAK,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,GAChC,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The main routing type for Expo Router.\n *\n * @internal\n * @hidden\n */\nexport namespace ExpoRouter {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-object-type\n export interface __routes {}\n}\n\nexport type RelativePathString = `./${string}` | `../${string}` | '..';\nexport type SearchOrHash = `?${string}` | `#${string}`;\nexport type ExternalPathString = `${string}:${string}` | `//${string}`;\nexport type Route = Exclude<\n Extract<Href, object>['pathname'], // Use the HrefObject, as it doesn't have query params\n RelativePathString | ExternalPathString\n>;\n\n/**\n * The main routing type for Expo Router. It includes all available routes with strongly\n * typed parameters. It can either be:\n * - **string**: A full path like `/profile/settings` or a relative path like `../settings`.\n * - **object**: An object with a `pathname` and optional `params`. The `pathname` can be\n * a full path like `/profile/settings` or a relative path like `../settings`.\n * The params can be an object of key-value pairs.\n *\n * A Href can either be a string or an object.\n */\nexport type Href = ExpoRouter.__routes extends { href: any }\n ? ExpoRouter.__routes['href']\n : string | { pathname: string; params?: UnknownInputParams };\n\nexport type HrefInputParams = ExpoRouter.__routes extends { hrefInputParams: any }\n ? ExpoRouter.__routes['hrefInputParams']\n : { pathname: string; params?: UnknownInputParams };\n\nexport type HrefOutputParams = ExpoRouter.__routes extends { hrefOutputParams: any }\n ? ExpoRouter.__routes['hrefOutputParams']\n : { pathname: string; params?: UnknownOutputParams };\n\nexport type RouteInputParams<T extends Route> =\n Extract<Href, { pathname: T }> extends never\n ? HrefInputParams extends infer H\n ? H extends Record<'pathname' | 'params', any>\n ? T extends H['pathname']\n ? H['params']\n : never\n : never\n : never\n : Extract<HrefInputParams, { pathname: T }>['params'];\n\nexport type RouteOutputParams<T extends Route> =\n Extract<HrefOutputParams, { pathname: T }> extends never\n ? HrefOutputParams extends infer H\n ? H extends Record<'pathname' | 'params', any>\n ? T extends H['pathname']\n ? H['params']\n : never\n : never\n : never\n : Extract<HrefOutputParams, { pathname: T }>['params'];\n\nexport type RouteParams<T extends Route> = RouteOutputParams<T>;\n\n/**\n * Routes can have known inputs (e.g query params).\n * Unlike outputs, inputs can be `undefined` or `null`.\n *\n * @hidden\n */\nexport type UnknownInputParams = Record<\n string,\n string | number | undefined | null | (string | number)[]\n>;\n\n/**\n * Routes can have unknown outputs (e.g query params).\n * Unlike inputs, outputs can't be undefined or null.\n *\n * @hidden\n */\nexport type UnknownOutputParams = Record<string, string | string[]>;\n\n/**\n * Return only the RoutePart of a string. If the string has multiple parts return never\n *\n * string | type\n *| ---------|------|\n *| 123 | 123 |\n *| /123/abc | never |\n *| 123?abc | never |\n *| ./123 | never |\n *| /123 | never |\n *| 123/../ | never |\n *\n * @hidden\n */\nexport type SingleRoutePart<S extends string | object> = S extends object\n ? never\n : S extends `${string}/${string}`\n ? never\n : S extends `${string}${SearchOrHash}`\n ? never\n : S extends ''\n ? never\n : S extends `(${string})`\n ? never\n : S extends `[${string}]`\n ? never\n : S;\n\n/**\n * @deprecated Use `RouteParams` or `StrictRouteParams` instead.\n *\n * @hidden\n */\nexport type SearchParams<T extends string = never> = RouteParams<T>;\n\n/**\n * @hidden\n */\nexport type RouteSegments<HrefOrSegments extends Route | string[]> = HrefOrSegments extends string[]\n ? HrefOrSegments\n : HrefOrSegments extends `.${string}`\n ? never\n : HrefOrSegments extends ``\n ? never\n : HrefOrSegments extends `/${infer PartA}`\n ? RouteSegments<PartA>\n : HrefOrSegments extends `${infer PartA}?${string}`\n ? RouteSegments<PartA>\n : HrefOrSegments extends `${infer PartA}#${string}`\n ? RouteSegments<PartA>\n : HrefOrSegments extends `${infer PartA}/${infer PartB}`\n ? [PartA, ...RouteSegments<PartB>]\n : [HrefOrSegments];\n"]}
|
package/build/types.d.ts
CHANGED
|
@@ -15,11 +15,44 @@ export interface RequireContext {
|
|
|
15
15
|
* The list of input keys will become optional, everything else will remain the same.
|
|
16
16
|
*/
|
|
17
17
|
export type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
18
|
+
/**
|
|
19
|
+
* Created by using a special file called `+native-intent.tsx` at the top-level of your
|
|
20
|
+
* project's **app** directory. It exports `redirectSystemPath` or `legacy_subscribe` functions,
|
|
21
|
+
* both methods designed to handle URL/path processing.
|
|
22
|
+
*
|
|
23
|
+
* Useful for re-writing URLs to correctly target a route when unique/referred URLs
|
|
24
|
+
* are incoming from third-party providers or stale URLs from previous versions.
|
|
25
|
+
*
|
|
26
|
+
* @see For more information on how to use `NativeIntent`, see [Customizing links](/router/advanced/native-intent/).
|
|
27
|
+
*/
|
|
18
28
|
export type NativeIntent = {
|
|
29
|
+
/**
|
|
30
|
+
* A special method used to process URLs in native apps. When invoked, it receives an
|
|
31
|
+
* `options` object with the following properties:
|
|
32
|
+
* - **path**: represents the URL or path undergoing processing.
|
|
33
|
+
* - **initial**: a boolean indicating whether the path is the app's initial URL.
|
|
34
|
+
*
|
|
35
|
+
* It's return value should either be a `string` or a `Promise<string>`.
|
|
36
|
+
* Note that throwing errors within this method may result in app crashes. It's recommended to
|
|
37
|
+
* wrap your code inside a `try/catch` block and utilize `.catch()` when appropriate.
|
|
38
|
+
*
|
|
39
|
+
* @see For usage information, see [Redirecting system paths](/router/advanced/native-intent/#redirectsystempath).
|
|
40
|
+
*/
|
|
19
41
|
redirectSystemPath?: (event: {
|
|
20
42
|
path: string;
|
|
21
43
|
initial: boolean;
|
|
22
44
|
}) => Promise<string> | string;
|
|
45
|
+
/**
|
|
46
|
+
* > **warning** Experimentally available in SDK 52.
|
|
47
|
+
*
|
|
48
|
+
* Useful as an alternative API when a third-party provider doesn't support Expo Router
|
|
49
|
+
* but has support for React Navigation via `Linking.subscribe()` for existing projects.
|
|
50
|
+
*
|
|
51
|
+
* Using this API is not recommended for newer projects or integrations since it is
|
|
52
|
+
* incompatible with Server Side Routing and
|
|
53
|
+
* [Static Rendering](/router/reference/static-rendering/), and can become challenging to manage while offline or in a low network environment.
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
23
56
|
legacy_subscribe?: (listener: (url: string) => void) => undefined | void | (() => void);
|
|
24
57
|
};
|
|
25
58
|
export type * from './typed-routes/types';
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;IACnB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEjF,MAAM,MAAM,YAAY,GAAG;IACzB,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC7F,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,KAAK,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CACzF,CAAC;AAEF,mBAAmB,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;IACnB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEjF;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC7F;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,KAAK,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CACzF,CAAC;AAEF,mBAAmB,sBAAsB,CAAC"}
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// TODO: Use the global type\n/**\n * @hidden\n */\nexport interface RequireContext {\n /** Return the keys that can be resolved. */\n keys(): string[];\n (id: string): any;\n <T>(id: string): T;\n /** **Unimplemented:** Return the module identifier for a user request. */\n resolve(id: string): string;\n /** **Unimplemented:** Readable identifier for the context module. */\n id: string;\n}\n\n/**\n * The list of input keys will become optional, everything else will remain the same.\n */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport type NativeIntent = {\n redirectSystemPath?: (event: { path: string; initial: boolean }) => Promise<string> | string;\n legacy_subscribe?: (listener: (url: string) => void) => undefined | void | (() => void);\n};\n\nexport type * from './typed-routes/types';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// TODO: Use the global type\n/**\n * @hidden\n */\nexport interface RequireContext {\n /** Return the keys that can be resolved. */\n keys(): string[];\n (id: string): any;\n <T>(id: string): T;\n /** **Unimplemented:** Return the module identifier for a user request. */\n resolve(id: string): string;\n /** **Unimplemented:** Readable identifier for the context module. */\n id: string;\n}\n\n/**\n * The list of input keys will become optional, everything else will remain the same.\n */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\n/**\n * Created by using a special file called `+native-intent.tsx` at the top-level of your\n * project's **app** directory. It exports `redirectSystemPath` or `legacy_subscribe` functions,\n * both methods designed to handle URL/path processing.\n *\n * Useful for re-writing URLs to correctly target a route when unique/referred URLs\n * are incoming from third-party providers or stale URLs from previous versions.\n *\n * @see For more information on how to use `NativeIntent`, see [Customizing links](/router/advanced/native-intent/).\n */\nexport type NativeIntent = {\n /**\n * A special method used to process URLs in native apps. When invoked, it receives an\n * `options` object with the following properties:\n * - **path**: represents the URL or path undergoing processing.\n * - **initial**: a boolean indicating whether the path is the app's initial URL.\n *\n * It's return value should either be a `string` or a `Promise<string>`.\n * Note that throwing errors within this method may result in app crashes. It's recommended to\n * wrap your code inside a `try/catch` block and utilize `.catch()` when appropriate.\n *\n * @see For usage information, see [Redirecting system paths](/router/advanced/native-intent/#redirectsystempath).\n */\n redirectSystemPath?: (event: { path: string; initial: boolean }) => Promise<string> | string;\n /**\n * > **warning** Experimentally available in SDK 52.\n *\n * Useful as an alternative API when a third-party provider doesn't support Expo Router\n * but has support for React Navigation via `Linking.subscribe()` for existing projects.\n *\n * Using this API is not recommended for newer projects or integrations since it is\n * incompatible with Server Side Routing and\n * [Static Rendering](/router/reference/static-rendering/), and can become challenging to manage while offline or in a low network environment.\n *\n */\n legacy_subscribe?: (listener: (url: string) => void) => undefined | void | (() => void);\n};\n\nexport type * from './typed-routes/types';\n"]}
|