expo-router 3.1.2 → 3.3.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/_ctx.android.js +1 -1
- package/_ctx.ios.js +1 -1
- package/_ctx.web.js +1 -1
- package/babel.js +1 -209
- package/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +57 -15
- package/build/ExpoRoot.js.map +1 -1
- package/build/LocationProvider.d.ts +3 -2
- package/build/LocationProvider.d.ts.map +1 -1
- package/build/LocationProvider.js +31 -7
- package/build/LocationProvider.js.map +1 -1
- package/build/Route.d.ts +3 -0
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js +1 -1
- package/build/Route.js.map +1 -1
- package/build/fork/NavigationContainer.native.js +5 -3
- package/build/fork/NavigationContainer.native.js.map +1 -1
- package/build/fork/extractPathFromURL.d.ts.map +1 -1
- package/build/fork/extractPathFromURL.js +17 -16
- package/build/fork/extractPathFromURL.js.map +1 -1
- package/build/fork/getPathFromState.d.ts +1 -1
- package/build/fork/getPathFromState.d.ts.map +1 -1
- package/build/fork/getPathFromState.js +17 -38
- package/build/fork/getPathFromState.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts +2 -2
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +71 -52
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getDevServer/index.d.ts +0 -3
- package/build/getDevServer/index.d.ts.map +1 -1
- package/build/getDevServer/index.js +1 -28
- package/build/getDevServer/index.js.map +1 -1
- package/build/getReactNavigationConfig.d.ts.map +1 -1
- package/build/getReactNavigationConfig.js +3 -0
- package/build/getReactNavigationConfig.js.map +1 -1
- package/build/getRoutes.d.ts +8 -5
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js +150 -67
- package/build/getRoutes.js.map +1 -1
- package/build/getServerManifest.d.ts +14 -33
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +6 -5
- package/build/getServerManifest.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +29 -3
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +0 -4
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +76 -96
- package/build/global-state/routing.js.map +1 -1
- package/build/head/ExpoHead.ios.js +4 -4
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/head/ExpoHead.js +1 -1
- package/build/head/ExpoHead.js.map +1 -1
- package/build/head/url.d.ts.map +1 -1
- package/build/head/url.js +5 -6
- package/build/head/url.js.map +1 -1
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +24 -5
- package/build/hooks.js.map +1 -1
- package/build/import-mode/index.d.ts +1 -1
- package/build/import-mode/index.d.ts.map +1 -1
- package/build/import-mode/index.js +1 -1
- package/build/import-mode/index.js.map +1 -1
- package/build/layouts/Tabs.js +2 -2
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/withLayoutContext.js +1 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +54 -1
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +54 -12
- package/build/link/Link.js.map +1 -1
- package/build/link/useLinkToPathProps.js +2 -2
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/loadStaticParamsAsync.d.ts +1 -0
- package/build/loadStaticParamsAsync.d.ts.map +1 -1
- package/build/loadStaticParamsAsync.js +107 -72
- package/build/loadStaticParamsAsync.js.map +1 -1
- package/build/matchers.js +1 -1
- package/build/matchers.js.map +1 -1
- package/build/onboard/Tutorial.js +41 -34
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/qualified-entry.d.ts.map +1 -1
- package/build/qualified-entry.js +10 -7
- package/build/qualified-entry.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +28 -4
- package/build/renderRootComponent.js.map +1 -1
- package/build/routes-manifest.d.ts +1 -0
- package/build/routes-manifest.d.ts.map +1 -1
- package/build/routes-manifest.js +1 -0
- package/build/routes-manifest.js.map +1 -1
- package/build/sortRoutes.d.ts.map +1 -1
- package/build/sortRoutes.js +21 -2
- package/build/sortRoutes.js.map +1 -1
- package/build/static/html.d.ts.map +1 -1
- package/build/static/html.js +12 -10
- package/build/static/html.js.map +1 -1
- package/build/static/renderStaticContent.d.ts +13 -3
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +35 -11
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/index.js +3 -5
- package/build/testing-library/index.js.map +1 -1
- package/build/testing-library/mocks.d.ts +1 -3
- package/build/testing-library/mocks.d.ts.map +1 -1
- package/build/testing-library/mocks.js +17 -10
- package/build/testing-library/mocks.js.map +1 -1
- package/build/testing-library/require-context-ponyfill.js +3 -3
- package/build/testing-library/require-context-ponyfill.js.map +1 -1
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +19 -23
- package/build/useScreens.js.map +1 -1
- package/build/utils/url.d.ts +2 -0
- package/build/utils/url.d.ts.map +1 -1
- package/build/utils/url.js +13 -1
- package/build/utils/url.js.map +1 -1
- package/build/views/EmptyRoute.js +5 -2
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.js +50 -31
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +16 -10
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Sitemap.js +54 -36
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/Splash.d.ts +1 -27
- package/build/views/Splash.d.ts.map +1 -1
- package/build/views/Splash.js +2 -112
- package/build/views/Splash.js.map +1 -1
- package/build/views/SuspenseFallback.d.ts +1 -1
- package/build/views/SuspenseFallback.d.ts.map +1 -1
- package/build/views/SuspenseFallback.js +7 -2
- package/build/views/SuspenseFallback.js.map +1 -1
- package/build/views/Toast.js +23 -18
- package/build/views/Toast.js.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/build/views/Unmatched.js +29 -17
- package/build/views/Unmatched.js.map +1 -1
- package/html.d.ts +1 -0
- package/ios/ExpoHead.podspec +1 -1
- package/ios/ExpoHeadModule.swift +0 -2
- package/package.json +11 -19
- package/plugin/build/index.d.ts +2 -2
- package/plugin/options.json +3 -3
- package/build/fork/react-native-web-container.d.ts +0 -8
- package/build/fork/react-native-web-container.d.ts.map +0 -1
- package/build/fork/react-native-web-container.js +0 -8
- package/build/fork/react-native-web-container.js.map +0 -1
- package/build/import-mode/index.android.d.ts +0 -3
- package/build/import-mode/index.android.d.ts.map +0 -1
- package/build/import-mode/index.android.js +0 -4
- package/build/import-mode/index.android.js.map +0 -1
- package/build/import-mode/index.ios.d.ts +0 -3
- package/build/import-mode/index.ios.d.ts.map +0 -1
- package/build/import-mode/index.ios.js +0 -4
- package/build/import-mode/index.ios.js.map +0 -1
- package/build/import-mode/index.web.d.ts +0 -3
- package/build/import-mode/index.web.d.ts.map +0 -1
- package/build/import-mode/index.web.js +0 -4
- package/build/import-mode/index.web.js.map +0 -1
- package/build/link/stateOperations.d.ts +0 -81
- package/build/link/stateOperations.d.ts.map +0 -1
- package/build/link/stateOperations.js +0 -105
- package/build/link/stateOperations.js.map +0 -1
- package/types/global.d.ts +0 -38
- package/types/metro-require.d.ts +0 -52
- package/types/react-native-web.d.ts +0 -295
package/build/head/ExpoHead.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Head = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_helmet_async_1 = require("react-helmet-async");
|
|
9
9
|
const Head = ({ children }) => {
|
|
10
|
-
return
|
|
10
|
+
return <react_helmet_async_1.Helmet>{children}</react_helmet_async_1.Helmet>;
|
|
11
11
|
};
|
|
12
12
|
exports.Head = Head;
|
|
13
13
|
exports.Head.Provider = react_helmet_async_1.HelmetProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoHead.js","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2DAA4D;AAErD,MAAM,IAAI,GAEb,CAAC,EAAE,QAAQ,EAAsB,EAAE,EAAE;IACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"ExpoHead.js","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2DAA4D;AAErD,MAAM,IAAI,GAEb,CAAC,EAAE,QAAQ,EAAsB,EAAE,EAAE;IACvC,OAAO,CAAC,2BAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,2BAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAJW,QAAA,IAAI,QAIf;AAEF,YAAI,CAAC,QAAQ,GAAG,mCAAc,CAAC","sourcesContent":["import React from 'react';\nimport { Helmet, HelmetProvider } from 'react-helmet-async';\n\nexport const Head: React.FC<{ children?: React.ReactNode }> & {\n Provider: typeof HelmetProvider;\n} = ({ children }: { children?: any }) => {\n return <Helmet>{children}</Helmet>;\n};\n\nHead.Provider = HelmetProvider;\n"]}
|
package/build/head/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":"AA+EA,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,UAI1D"}
|
package/build/head/url.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getStaticUrlFromExpoRouter = void 0;
|
|
7
7
|
const expo_constants_1 = __importDefault(require("expo-constants"));
|
|
8
|
-
const url_parse_1 = __importDefault(require("url-parse"));
|
|
9
8
|
const protocolWarningString = `{ plugins: [["expo-router", { origin: "...<URL>..." }]] }`;
|
|
10
9
|
/** `lodash.memoize` */
|
|
11
10
|
function memoize(fn) {
|
|
@@ -21,16 +20,16 @@ function memoize(fn) {
|
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
function sanitizeUrl(url) {
|
|
24
|
-
const parsed = new
|
|
23
|
+
const parsed = new URL(url);
|
|
25
24
|
// Allow empty protocol, http, and https
|
|
26
25
|
const validProtocol = !parsed.protocol || parsed.protocol === 'http:' || parsed.protocol === 'https:';
|
|
27
26
|
if (!validProtocol) {
|
|
28
27
|
throwOrAlert(`Expo Head: Native origin has invalid protocol "${parsed.protocol}" for URL in Expo Config: ${protocolWarningString}.`);
|
|
29
28
|
}
|
|
30
|
-
parsed.
|
|
31
|
-
parsed.
|
|
32
|
-
parsed.
|
|
33
|
-
parsed.
|
|
29
|
+
parsed.pathname = '';
|
|
30
|
+
parsed.search = '';
|
|
31
|
+
parsed.hash = '';
|
|
32
|
+
parsed.protocol ??= 'https:';
|
|
34
33
|
return parsed.toString().replace(/\/$/, '');
|
|
35
34
|
}
|
|
36
35
|
const memoSanitizeUrl = memoize(sanitizeUrl);
|
package/build/head/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AAEvC,MAAM,qBAAqB,GAAG,2DAA2D,CAAC;AAE1F,uBAAuB;AACvB,SAAS,OAAO,CAAoC,EAAK;IACvD,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;YACd,OAA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,uEAAuE;IACvE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE;QACnC,OAAO,CAAC,IAAI,CACV,sBAAsB,MAAM,yCAAyC,qBAAqB,GAAG,CAC9F,CAAC;KACH;IAED,kFAAkF;IAClF,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,4DAA4D;IAC5D;IACE,iCAAiC;IACjC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EACrC;QACA,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,KAAK,CAAC,GAAG,CAAC,CAAC;KACZ;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;AACH,CAAC;AAED,SAAgB,0BAA0B,CAAC,QAAgB;IACzD,kCAAkC;IAClC,sCAAsC;IACtC,OAAO,mBAAmB,EAAE,GAAG,QAAQ,CAAC;AAC1C,CAAC;AAJD,gEAIC","sourcesContent":["import Constants from 'expo-constants';\n\nconst protocolWarningString = `{ plugins: [[\"expo-router\", { origin: \"...<URL>...\" }]] }`;\n\n/** `lodash.memoize` */\nfunction memoize<T extends (...args: any[]) => any>(fn: T): T {\n const cache: { [key: string]: any } = {};\n return ((...args: any[]) => {\n const key = JSON.stringify(args);\n if (cache[key]) {\n return cache[key];\n }\n const result = fn(...args);\n cache[key] = result;\n return result;\n }) as any;\n}\n\nfunction sanitizeUrl(url: string): string {\n const parsed = new URL(url);\n\n // Allow empty protocol, http, and https\n const validProtocol =\n !parsed.protocol || parsed.protocol === 'http:' || parsed.protocol === 'https:';\n\n if (!validProtocol) {\n throwOrAlert(\n `Expo Head: Native origin has invalid protocol \"${parsed.protocol}\" for URL in Expo Config: ${protocolWarningString}.`\n );\n }\n\n parsed.pathname = '';\n parsed.search = '';\n parsed.hash = '';\n parsed.protocol ??= 'https:';\n\n return parsed.toString().replace(/\\/$/, '');\n}\n\nconst memoSanitizeUrl = memoize(sanitizeUrl);\n\nfunction getUrlFromConstants(): string | null {\n // This will require a rebuild in bare-workflow to update.\n const manifest = Constants.expoConfig;\n\n const origin = manifest?.extra?.router?.headOrigin ?? manifest?.extra?.router?.origin;\n\n if (!origin) {\n throwOrAlert(\n `Expo Head: Add the handoff origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \\`origin\\` is the hosted URL.`\n );\n // Fallback value that shouldn't be used for real.\n return 'https://expo.dev';\n }\n\n // Without this, the URL will go to an IP address which is not allowed.\n if (!origin.match(/^http(s)?:\\/\\//)) {\n console.warn(\n `Expo Head: origin \"${origin}\" is missing a \\`https://\\` protocol. ${protocolWarningString}.`\n );\n }\n\n // Return the development URL last so the user gets all production warnings first.\n return memoSanitizeUrl(origin);\n}\n\nfunction throwOrAlert(msg: string) {\n // Production apps fatally crash which is often not helpful.\n if (\n // @ts-ignore: process is defined\n process.env.NODE_ENV === 'production'\n ) {\n console.error(msg);\n alert(msg);\n } else {\n throw new Error(msg);\n }\n}\n\nexport function getStaticUrlFromExpoRouter(pathname: string) {\n // const host = \"https://expo.io\";\n // Append the URL we'd find in context\n return getUrlFromConstants() + pathname;\n}\n"]}
|
package/build/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,wBAAgB,sBAAsB,kDAErC;AAED,wBAAgB,YAAY,2CAE3B;AAED,wBAAgB,iBAAiB,oGAEhC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAYlC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,KAAK,SAAS,CAE9E;AAED,kEAAkE;AAClE,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,wBAAgB,sBAAsB,kDAErC;AAED,wBAAgB,YAAY,2CAE3B;AAED,wBAAgB,iBAAiB,oGAEhC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAYlC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,KAAK,SAAS,CAE9E;AAED,kEAAkE;AAClE,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAwBpB"}
|
package/build/hooks.js
CHANGED
|
@@ -86,11 +86,30 @@ exports.useGlobalSearchParams = useGlobalSearchParams;
|
|
|
86
86
|
* To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.
|
|
87
87
|
*/
|
|
88
88
|
function useLocalSearchParams() {
|
|
89
|
-
|
|
89
|
+
const params = react_1.default.useContext(native_1.NavigationRouteContext)?.params ?? {};
|
|
90
|
+
return Object.fromEntries(Object.entries(params).map(([key, value]) => {
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
return [
|
|
93
|
+
key,
|
|
94
|
+
value.map((v) => {
|
|
95
|
+
try {
|
|
96
|
+
return decodeURIComponent(v);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return v;
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
try {
|
|
106
|
+
return [key, decodeURIComponent(value)];
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return [key, value];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
90
113
|
}
|
|
91
114
|
exports.useLocalSearchParams = useLocalSearchParams;
|
|
92
|
-
function useOptionalLocalRoute() {
|
|
93
|
-
const route = react_1.default.useContext(native_1.NavigationRouteContext);
|
|
94
|
-
return route;
|
|
95
|
-
}
|
|
96
115
|
//# sourceMappingURL=hooks.js.map
|
package/build/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkE;AAClE,kDAA0B;AAE1B,8DAA0F;AAK1F,SAAgB,sBAAsB;IACpC,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,wDAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,oCAEC;AAED,SAAgB,iBAAiB;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ACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACd,IAAI;wBACF,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;qBAC9B;oBAAC,MAAM;wBACN,OAAO,CAAC,CAAC;qBACV;gBACH,CAAC,CAAC;aACH,CAAC;SACH;aAAM;YACL,IAAI;gBACF,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAe,CAAC,CAAC,CAAC;aACnD;YAAC,MAAM;gBACN,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC,CAAC,CACiB,CAAC;AACxB,CAAC;AA1BD,oDA0BC","sourcesContent":["import { NavigationRouteContext } from '@react-navigation/native';\nimport React from 'react';\n\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './types';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n push: store.push,\n back: store.goBack,\n replace: store.replace,\n setParams: store.setParams,\n canGoBack: store.canGoBack,\n // TODO(EvanBacon): add `reload`\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns the current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link, i.e. `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. e.g. /[id]?id=normal -> [\"[id]\"]\n *\n * `useSegments` can be typed using an abstract.\n * Consider the following file structure, and strictly typed `useSegments` function:\n *\n * ```md\n * - app\n * - [user]\n * - index.js\n * - followers.js\n * - settings.js\n * ```\n * This can be strictly typed using the following abstract:\n *\n * ```ts\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends string[] = string[]>(): TSegments {\n return useStoreRouteInfo().segments as TSegments;\n}\n\n/** @returns global selected pathname without query parameters. */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * Get the globally selected query parameters, including dynamic path segments. This function will update even when the route is not focused.\n * Useful for analytics or other background operations that don't draw to the screen.\n *\n * When querying search params in a stack, opt-towards using `useLocalSearchParams` as these will only\n * update when the route is focused.\n *\n * @see `useLocalSearchParams`\n */\nexport function useGlobalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n return useStoreRouteInfo().params as Partial<TParams>;\n}\n\n/**\n * Returns the URL search parameters for the contextually focused route. e.g. `/acme?foo=bar` -> `{ foo: \"bar\" }`.\n * This is useful for stacks where you may push a new screen that changes the query parameters.\n *\n * To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.\n */\nexport function useLocalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n const params = React.useContext(NavigationRouteContext)?.params ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as Partial<TParams>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";AAAA,wBAAkF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";;AAAA,kBAAe,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";;AAAA,kBAAe,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAK,MAA0B,CAAC","sourcesContent":["export default process.env.EXPO_ROUTER_IMPORT_MODE || ('sync' as 'sync' | 'lazy');\n"]}
|
package/build/layouts/Tabs.js
CHANGED
|
@@ -27,8 +27,8 @@ exports.Tabs = (0, withLayoutContext_1.withLayoutContext)(BottomTabNavigator, (s
|
|
|
27
27
|
if (href == null) {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
-
const children = react_native_1.Platform.OS === 'web' ? props.children :
|
|
31
|
-
return (
|
|
30
|
+
const children = react_native_1.Platform.OS === 'web' ? props.children : <react_native_1.Pressable>{props.children}</react_native_1.Pressable>;
|
|
31
|
+
return (<Link_1.Link {...props} style={[{ display: 'flex' }, props.style]} href={href} asChild={react_native_1.Platform.OS !== 'web'} children={children}/>);
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/layouts/Tabs.tsx"],"names":[],"mappings":";;;;;;AAAA,+DAIuC;AAEvC,kDAA0B;AAC1B,+CAAmD;AAEnD,2DAAwD;AACxD,uCAAoC;AAGpC,gDAAgD;AAChD,MAAM,kBAAkB,GAAG,IAAA,sCAAwB,GAAE,CAAC,SAAS,CAAC;AAEnD,QAAA,IAAI,GAAG,IAAA,qCAAiB,EAKnC,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,oCAAoC;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE;YAC9E,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,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IAAI,CAAC;yBACb;wBACD,MAAM,QAAQ,GACZ,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,wBAAS,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAS,CAAC,CAAC;wBACnF,OAAO,CACL,CAAC,WAAI,CACH,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAC1C,IAAI,CAAC,CAAC,IAAI,CAAC,CACX,OAAO,CAAC,CAAC,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAC/B,QAAQ,CAAC,CAAC,QAAQ,CAAC,EACnB,CACH,CAAC;oBACJ,CAAC;iBACF;aACF,CAAC;SACH;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,kBAAe,YAAI,CAAC","sourcesContent":["import {\n BottomTabNavigationEventMap,\n BottomTabNavigationOptions,\n createBottomTabNavigator,\n} from '@react-navigation/bottom-tabs';\nimport { ParamListBase, TabNavigationState } from '@react-navigation/native';\nimport React from 'react';\nimport { Pressable, Platform } from 'react-native';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { Link } from '../link/Link';\nimport { Href } from '../link/href';\n\n// This is the only way to access the navigator.\nconst BottomTabNavigator = createBottomTabNavigator().Navigator;\n\nexport const Tabs = withLayoutContext<\n BottomTabNavigationOptions & { href?: Href | null },\n typeof BottomTabNavigator,\n TabNavigationState<ParamListBase>,\n BottomTabNavigationEventMap\n>(BottomTabNavigator, (screens) => {\n // Support the `href` shortcut prop.\n return screens.map((screen) => {\n if (typeof screen.options !== 'function' && screen.options?.href !== undefined) {\n const { href, ...options } = screen.options;\n if (options.tabBarButton) {\n throw new Error('Cannot use `href` and `tabBarButton` together.');\n }\n return {\n ...screen,\n options: {\n ...options,\n tabBarButton: (props) => {\n if (href == null) {\n return null;\n }\n const children =\n Platform.OS === 'web' ? props.children : <Pressable>{props.children}</Pressable>;\n return (\n <Link\n {...props}\n style={[{ display: 'flex' }, props.style]}\n href={href}\n asChild={Platform.OS !== 'web'}\n children={children}\n />\n );\n },\n },\n };\n }\n return screen;\n });\n});\n\nexport default Tabs;\n"]}
|
|
@@ -62,7 +62,7 @@ function withLayoutContext(Nav, processor) {
|
|
|
62
62
|
}
|
|
63
63
|
return (
|
|
64
64
|
// @ts-expect-error
|
|
65
|
-
|
|
65
|
+
<Nav {...props} id={contextKey} ref={ref} children={sorted}/>);
|
|
66
66
|
});
|
|
67
67
|
// @ts-expect-error
|
|
68
68
|
Navigator.Screen = Screen_1.Screen;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLayoutContext.js","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAE1B,oCAAyC;AAEzC,8CAA8D;AAC9D,4CAAyC;AAEzC,SAAgB,uBAAuB,CACrC,QAAyB,EACzB,EACE,iBAAiB,EACjB,UAAU,MAKR,EAAE;IAEN,OAAO,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxB,MAAM,cAAc,GAAU,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,eAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YACrD,IAAI,eAAK,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,eAAM,EAAE;gBACjE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;oBACrB,MAAM,IAAI,KAAK,CACb,sDAAsD,UAAU,8EAA8E,CAC/I,CAAC;iBACH;gBACD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;oBACzC,IAAI,CAAC,UAAU,EAAE,W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,CAAC;QAEjE,MAAM,MAAM,GAAG,IAAA,6BAAgB,EAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QAEjD,uDAAuD;QACvD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,OAAO,IAAI,CAAC;SACb;QAED,OAAO;QACL,mBAAmB;QACnB,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAG,CAC/D,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,mBAAmB;IACnB,SAAS,CAAC,MAAM,GAAG,eAAM,CAAC;IAC1B,mBAAmB;IACnB,OAAO,SAAS,CAAC;AACnB,CAAC;AA/CD,8CA+CC","sourcesContent":["import { EventMapBase, NavigationState } from '@react-navigation/native';\nimport React from 'react';\n\nimport { useContextKey } from '../Route';\nimport { PickPartial } from '../types';\nimport { useSortedScreens, ScreenProps } from '../useScreens';\nimport { Screen } from '../views/Screen';\n\nexport function useFilterScreenChildren(\n children: React.ReactNode,\n {\n isCustomNavigator,\n contextKey,\n }: {\n isCustomNavigator?: boolean;\n /** Used for sending developer hints */\n contextKey?: string;\n } = {}\n) {\n return React.useMemo(() => {\n const customChildren: any[] = [];\n const screens = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child && child.type === Screen) {\n if (!child.props.name) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n if (process.env.NODE_ENV !== 'production') {\n if (['children', 'component', 'getComponent'].some((key) => key in child.props)) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`children\\`, \\`component\\`, or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n return child.props;\n } else {\n if (isCustomNavigator) {\n customChildren.push(child);\n } else {\n console.warn(\n `Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: \"app${contextKey}/_layout\"`\n );\n }\n }\n });\n\n // Add an assertion for development\n if (process.env.NODE_ENV !== 'production') {\n // Assert if names are not unique\n const names = screens?.map((screen) => screen.name);\n if (names && new Set(names).size !== names.length) {\n throw new Error('Screen names must be unique: ' + names);\n }\n }\n\n return {\n screens,\n children: customChildren,\n };\n }, [children]);\n}\n\n/** Return a navigator that automatically injects matched routes and renders nothing when there are no children. Return type with children prop optional */\nexport function withLayoutContext<\n TOptions extends object,\n T extends React.ComponentType<any>,\n State extends NavigationState,\n EventMap extends EventMapBase,\n>(\n Nav: T,\n processor?: (\n options: ScreenProps<TOptions, State, EventMap>[]\n ) => ScreenProps<TOptions, State, EventMap>[]\n): React.ForwardRefExoticComponent<\n React.PropsWithoutRef<PickPartial<React.ComponentProps<T>, 'children'>> &\n React.RefAttributes<unknown>\n> & {\n Screen: (props: ScreenProps<TOptions, State, EventMap>) => null;\n} {\n const Navigator = React.forwardRef(\n (\n { children: userDefinedChildren, ...props }: PickPartial<React.ComponentProps<T>, 'children'>,\n ref\n ) => {\n const contextKey = useContextKey();\n\n const { screens } = useFilterScreenChildren(userDefinedChildren, {\n contextKey,\n });\n\n const processed = processor ? processor(screens ?? []) : screens;\n\n const sorted = useSortedScreens(processed ?? []);\n\n // Prevent throwing an error when there are no screens.\n if (!sorted.length) {\n return null;\n }\n\n return (\n // @ts-expect-error\n <Nav {...props} id={contextKey} ref={ref} children={sorted} />\n );\n }\n );\n\n // @ts-expect-error\n Navigator.Screen = Screen;\n // @ts-expect-error\n return Navigator;\n}\n"]}
|
package/build/link/Link.d.ts
CHANGED
|
@@ -1,13 +1,64 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextProps, GestureResponderEvent } from 'react-native';
|
|
3
3
|
import { Href, resolveHref } from './href';
|
|
4
|
-
|
|
4
|
+
interface WebAnchorProps {
|
|
5
|
+
/**
|
|
6
|
+
* **Web only:** Specifies where to open the `href`.
|
|
7
|
+
*
|
|
8
|
+
* - **_self**: the current tab.
|
|
9
|
+
* - **_blank**: opens in a new tab or window.
|
|
10
|
+
* - **_parent**: opens in the parent browsing context. If no parent, defaults to **_self**.
|
|
11
|
+
* - **_top**: opens in the highest browsing context ancestor. If no ancestors, defaults to **_self**.
|
|
12
|
+
*
|
|
13
|
+
* This property is passed to the underlying anchor (`<a>`) tag.
|
|
14
|
+
*
|
|
15
|
+
* @default '_self'
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* <Link href="https://expo.dev" target="_blank">Go to Expo in new tab</Link>
|
|
19
|
+
*/
|
|
20
|
+
target?: '_self' | '_blank' | '_parent' | '_top' | (string & object);
|
|
21
|
+
/**
|
|
22
|
+
* **Web only:** Specifies the relationship between the `href` and the current route.
|
|
23
|
+
*
|
|
24
|
+
* Common values:
|
|
25
|
+
* - **nofollow**: Indicates to search engines that they should not follow the `href`. This is often used for user-generated content or links that should not influence search engine rankings.
|
|
26
|
+
* - **noopener**: Suggests that the `href` should not have access to the opening window's `window.opener` object, which is a security measure to prevent potentially harmful behavior in cases of links that open new tabs or windows.
|
|
27
|
+
* - **noreferrer**: Requests that the browser not send the `Referer` HTTP header when navigating to the `href`. This can enhance user privacy.
|
|
28
|
+
*
|
|
29
|
+
* The `rel` property is primarily used for informational and instructive purposes, helping browsers and web
|
|
30
|
+
* crawlers make better decisions about how to handle and interpret the links on a web page. It is important
|
|
31
|
+
* to use appropriate `rel` values to ensure that links behave as intended and adhere to best practices for web
|
|
32
|
+
* development and SEO (Search Engine Optimization).
|
|
33
|
+
*
|
|
34
|
+
* This property is passed to the underlying anchor (`<a>`) tag.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* <Link href="https://expo.dev" rel="nofollow">Go to Expo</Link>
|
|
38
|
+
*/
|
|
39
|
+
rel?: string;
|
|
40
|
+
/**
|
|
41
|
+
* **Web only:** Specifies that the `href` should be downloaded when the user clicks on the link,
|
|
42
|
+
* instead of navigating to it. It is typically used for links that point to files that the user should download,
|
|
43
|
+
* such as PDFs, images, documents, etc.
|
|
44
|
+
*
|
|
45
|
+
* The value of the `download` property, which represents the filename for the downloaded file.
|
|
46
|
+
* This property is passed to the underlying anchor (`<a>`) tag.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* <Link href="/image.jpg" download="my-image.jpg">Download image</Link>
|
|
50
|
+
*/
|
|
51
|
+
download?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {
|
|
5
54
|
/** Path to route to. */
|
|
6
55
|
href: Href;
|
|
7
56
|
/** Forward props to child component. Useful for custom buttons. */
|
|
8
57
|
asChild?: boolean;
|
|
9
58
|
/** Should replace the current route without adding to the history. */
|
|
10
59
|
replace?: boolean;
|
|
60
|
+
/** On web, this sets the HTML `class` directly. On native, this can be used with CSS interop tools like Nativewind. */
|
|
61
|
+
className?: string;
|
|
11
62
|
onPress?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;
|
|
12
63
|
}
|
|
13
64
|
/** Redirects to the href as soon as the component is mounted. */
|
|
@@ -27,6 +78,8 @@ export interface LinkComponent {
|
|
|
27
78
|
* @param props.replace Should replace the current route without adding to the history.
|
|
28
79
|
* @param props.asChild Forward props to child component. Useful for custom buttons.
|
|
29
80
|
* @param props.children Child elements to render the content.
|
|
81
|
+
* @param props.className On web, this sets the HTML `class` directly. On native, this can be used with CSS interop tools like Nativewind.
|
|
30
82
|
*/
|
|
31
83
|
export declare const Link: LinkComponent;
|
|
84
|
+
export {};
|
|
32
85
|
//# sourceMappingURL=Link.d.ts.map
|
package/build/link/Link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAA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AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;IACzD,6DAA6D;IAC7D,WAAW,EAAE,OAAO,WAAW,CAAC;CACjC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,eAA+D,CAAC"}
|
package/build/link/Link.js
CHANGED
|
@@ -58,12 +58,57 @@ exports.Redirect = Redirect;
|
|
|
58
58
|
* @param props.replace Should replace the current route without adding to the history.
|
|
59
59
|
* @param props.asChild Forward props to child component. Useful for custom buttons.
|
|
60
60
|
* @param props.children Child elements to render the content.
|
|
61
|
+
* @param props.className On web, this sets the HTML `class` directly. On native, this can be used with CSS interop tools like Nativewind.
|
|
61
62
|
*/
|
|
62
63
|
exports.Link = React.forwardRef(ExpoRouterLink);
|
|
63
64
|
exports.Link.resolveHref = href_1.resolveHref;
|
|
65
|
+
// Mutate the style prop to add the className on web.
|
|
66
|
+
function useInteropClassName(props) {
|
|
67
|
+
if (react_native_1.Platform.OS !== 'web') {
|
|
68
|
+
return props.style;
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
71
|
+
return React.useMemo(() => {
|
|
72
|
+
if (props.className == null) {
|
|
73
|
+
return props.style;
|
|
74
|
+
}
|
|
75
|
+
const cssStyle = {
|
|
76
|
+
$$css: true,
|
|
77
|
+
__routerLinkClassName: props.className,
|
|
78
|
+
};
|
|
79
|
+
if (Array.isArray(props.style)) {
|
|
80
|
+
return [...props.style, cssStyle];
|
|
81
|
+
}
|
|
82
|
+
return [props.style, cssStyle];
|
|
83
|
+
}, [props.style, props.className]);
|
|
84
|
+
}
|
|
85
|
+
const useHrefAttrs = react_native_1.Platform.select({
|
|
86
|
+
web: function useHrefAttrs({ asChild, rel, target, download }) {
|
|
87
|
+
return React.useMemo(() => {
|
|
88
|
+
const hrefAttrs = {
|
|
89
|
+
rel,
|
|
90
|
+
target,
|
|
91
|
+
download,
|
|
92
|
+
};
|
|
93
|
+
if (asChild) {
|
|
94
|
+
return hrefAttrs;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
hrefAttrs,
|
|
98
|
+
};
|
|
99
|
+
}, [asChild, rel, target, download]);
|
|
100
|
+
},
|
|
101
|
+
default: function useHrefAttrs() {
|
|
102
|
+
return {};
|
|
103
|
+
},
|
|
104
|
+
});
|
|
64
105
|
function ExpoRouterLink({ href, replace,
|
|
65
106
|
// TODO: This does not prevent default on the anchor tag.
|
|
66
|
-
asChild, ...rest }, ref) {
|
|
107
|
+
asChild, rel, target, download, ...rest }, ref) {
|
|
108
|
+
// Mutate the style prop to add the className on web.
|
|
109
|
+
const style = useInteropClassName(rest);
|
|
110
|
+
// If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.
|
|
111
|
+
const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });
|
|
67
112
|
const resolvedHref = React.useMemo(() => {
|
|
68
113
|
if (href == null) {
|
|
69
114
|
throw new Error('Link: href is required');
|
|
@@ -77,16 +122,13 @@ asChild, ...rest }, ref) {
|
|
|
77
122
|
}
|
|
78
123
|
props.onPress(e);
|
|
79
124
|
};
|
|
80
|
-
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
default: { onPress },
|
|
89
|
-
}),
|
|
90
|
-
});
|
|
125
|
+
const Element = asChild ? react_slot_1.Slot : react_native_1.Text;
|
|
126
|
+
// Avoid using createElement directly, favoring JSX, to allow tools like Nativewind to perform custom JSX handling on native.
|
|
127
|
+
return (<Element ref={ref} {...props} {...hrefAttrs} {...rest} style={style} {...react_native_1.Platform.select({
|
|
128
|
+
web: {
|
|
129
|
+
onClick: onPress,
|
|
130
|
+
},
|
|
131
|
+
default: { onPress },
|
|
132
|
+
})}/>);
|
|
91
133
|
}
|
|
92
134
|
//# sourceMappingURL=Link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AAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CAAC,CAA0E,EAAE,EAAE;QAC7F,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACxB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,iBAAI,CAAC,CAAC,CAAC,mBAAI,EACrB;QACE,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,uBAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC;KACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport { Text, TextProps, GestureResponderEvent, Platform } from 'react-native';\n\nimport { Href, resolveHref } from './href';\nimport useLinkToPathProps from './useLinkToPathProps';\nimport { useRouter } from '../hooks';\nimport { useFocusEffect } from '../useFocusEffect';\n\nexport interface LinkProps extends Omit<TextProps, 'href' | 'hoverStyle'> {\n /** Path to route to. */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /** Forward props to child component. Useful for custom buttons. */\n asChild?: boolean;\n\n /** Should replace the current route without adding to the history. */\n replace?: boolean;\n\n onPress?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;\n}\n\n/** Redirects to the href as soon as the component is mounted. */\nexport function Redirect({ href }: { href: Href }) {\n const router = useRouter();\n useFocusEffect(() => {\n try {\n router.replace(href);\n } catch (error) {\n console.error(error);\n }\n });\n return null;\n}\n\nexport interface LinkComponent {\n (props: React.PropsWithChildren<LinkProps>): JSX.Element;\n /** Helper method to resolve an Href object into a string. */\n resolveHref: typeof resolveHref;\n}\n\n/**\n * Component to render link to another route using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to route (e.g. `/feeds/hot`).\n * @param props.replace Should replace the current route without adding to the history.\n * @param props.asChild Forward props to child component. Useful for custom buttons.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n // TODO: This does not prevent default on the anchor tag.\n asChild,\n ...rest\n }: LinkProps,\n ref: React.ForwardedRef<Text>\n) {\n const resolvedHref = React.useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n const props = useLinkToPathProps({ href: resolvedHref, replace });\n\n const onPress = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n }\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wFAAwF;AACxF,mCAAmC;AACnC,qDAA4C;AAC5C,6CAA+B;AAC/B,+CAAgF;AAEhF,iCAA2C;AAC3C,8EAAsD;AACtD,oCAAqC;AACrC,sDAAmD;AAuEnD,iEAAiE;AACjE,SAAgB,QAAQ,CAAC,EAAE,IAAI,EAAkB;IAC/C,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,IAAA,+BAAc,EAAC,GAAG,EAAE;QAClB,IAAI;YACF,MAAM,CAAC,OAAO,CAAC,IAAI,CA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AAC,CAAC,CAAC,mBAAI,CAAC;IAEtC,6HAA6H;IAC7H,OAAO,CACL,CAAC,OAAO,CACN,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,IAAI,KAAK,CAAC,CACV,IAAI,SAAS,CAAC,CACd,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,IAAI,uBAAQ,CAAC,MAAM,CAAC;QAClB,GAAG,EAAE;YACH,OAAO,EAAE,OAAO;SACV;QACR,OAAO,EAAE,EAAE,OAAO,EAAE;KACrB,CAAC,CAAC,EACH,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport { Text, TextProps, GestureResponderEvent, Platform } from 'react-native';\n\nimport { Href, resolveHref } from './href';\nimport useLinkToPathProps from './useLinkToPathProps';\nimport { useRouter } from '../hooks';\nimport { useFocusEffect } from '../useFocusEffect';\n\ninterface WebAnchorProps {\n /**\n * **Web only:** Specifies where to open the `href`.\n *\n * - **_self**: the current tab.\n * - **_blank**: opens in a new tab or window.\n * - **_parent**: opens in the parent browsing context. If no parent, defaults to **_self**.\n * - **_top**: opens in the highest browsing context ancestor. If no ancestors, defaults to **_self**.\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @default '_self'\n *\n * @example\n * <Link href=\"https://expo.dev\" target=\"_blank\">Go to Expo in new tab</Link>\n */\n target?: '_self' | '_blank' | '_parent' | '_top' | (string & object);\n\n /**\n * **Web only:** Specifies the relationship between the `href` and the current route.\n *\n * Common values:\n * - **nofollow**: Indicates to search engines that they should not follow the `href`. This is often used for user-generated content or links that should not influence search engine rankings.\n * - **noopener**: Suggests that the `href` should not have access to the opening window's `window.opener` object, which is a security measure to prevent potentially harmful behavior in cases of links that open new tabs or windows.\n * - **noreferrer**: Requests that the browser not send the `Referer` HTTP header when navigating to the `href`. This can enhance user privacy.\n *\n * The `rel` property is primarily used for informational and instructive purposes, helping browsers and web\n * crawlers make better decisions about how to handle and interpret the links on a web page. It is important\n * to use appropriate `rel` values to ensure that links behave as intended and adhere to best practices for web\n * development and SEO (Search Engine Optimization).\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * <Link href=\"https://expo.dev\" rel=\"nofollow\">Go to Expo</Link>\n */\n rel?: string;\n\n /**\n * **Web only:** Specifies that the `href` should be downloaded when the user clicks on the link,\n * instead of navigating to it. It is typically used for links that point to files that the user should download,\n * such as PDFs, images, documents, etc.\n *\n * The value of the `download` property, which represents the filename for the downloaded file.\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * <Link href=\"/image.jpg\" download=\"my-image.jpg\">Download image</Link>\n */\n download?: string;\n}\n\nexport interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {\n /** Path to route to. */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /** Forward props to child component. Useful for custom buttons. */\n asChild?: boolean;\n\n /** Should replace the current route without adding to the history. */\n replace?: boolean;\n\n /** On web, this sets the HTML `class` directly. On native, this can be used with CSS interop tools like Nativewind. */\n className?: string;\n\n onPress?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;\n}\n\n/** Redirects to the href as soon as the component is mounted. */\nexport function Redirect({ href }: { href: Href }) {\n const router = useRouter();\n useFocusEffect(() => {\n try {\n router.replace(href);\n } catch (error) {\n console.error(error);\n }\n });\n return null;\n}\n\nexport interface LinkComponent {\n (props: React.PropsWithChildren<LinkProps>): JSX.Element;\n /** Helper method to resolve an Href object into a string. */\n resolveHref: typeof resolveHref;\n}\n\n/**\n * Component to render link to another route using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to route (e.g. `/feeds/hot`).\n * @param props.replace Should replace the current route without adding to the history.\n * @param props.asChild Forward props to child component. Useful for custom buttons.\n * @param props.children Child elements to render the content.\n * @param props.className On web, this sets the HTML `class` directly. On native, this can be used with CSS interop tools like Nativewind.\n */\nexport const Link = React.forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\n// Mutate the style prop to add the className on web.\nfunction useInteropClassName(props: { style?: TextProps['style']; className?: string }) {\n if (Platform.OS !== 'web') {\n return props.style;\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (props.className == null) {\n return props.style;\n }\n const cssStyle = {\n $$css: true,\n __routerLinkClassName: props.className,\n };\n\n if (Array.isArray(props.style)) {\n return [...props.style, cssStyle];\n }\n return [props.style, cssStyle];\n }, [props.style, props.className]);\n}\n\nconst useHrefAttrs = Platform.select<\n (props: Partial<LinkProps>) => { hrefAttrs?: any } & Partial<LinkProps>\n>({\n web: function useHrefAttrs({ asChild, rel, target, download }: Partial<LinkProps>) {\n return React.useMemo(() => {\n const hrefAttrs = {\n rel,\n target,\n download,\n };\n if (asChild) {\n return hrefAttrs;\n }\n return {\n hrefAttrs,\n };\n }, [asChild, rel, target, download]);\n },\n default: function useHrefAttrs() {\n return {};\n },\n});\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n // TODO: This does not prevent default on the anchor tag.\n asChild,\n rel,\n target,\n download,\n ...rest\n }: LinkProps,\n ref: React.ForwardedRef<Text>\n) {\n // Mutate the style prop to add the className on web.\n const style = useInteropClassName(rest);\n\n // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.\n const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });\n\n const resolvedHref = React.useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n const props = useLinkToPathProps({ href: resolvedHref, replace });\n\n const onPress = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n const Element = asChild ? Slot : Text;\n\n // Avoid using createElement directly, favoring JSX, to allow tools like Nativewind to perform custom JSX handling on native.\n return (\n <Element\n ref={ref}\n {...props}\n {...hrefAttrs}\n {...rest}\n style={style}\n {...Platform.select({\n web: {\n onClick: onPress,\n } as any,\n default: { onPress },\n })}\n />\n );\n}\n"]}
|
|
@@ -39,8 +39,8 @@ function useLinkToPathProps(props) {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
return {
|
|
42
|
-
// Ensure there's always a value for href. Manually append the
|
|
43
|
-
href: (0, getPathFromState_1.
|
|
42
|
+
// Ensure there's always a value for href. Manually append the baseUrl to the href prop that shows in the static HTML.
|
|
43
|
+
href: (0, getPathFromState_1.appendBaseUrl)((0, matchers_1.stripGroupSegmentsFromPath)(props.href) || '/'),
|
|
44
44
|
role: 'link',
|
|
45
45
|
onPress,
|
|
46
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkToPathProps.js","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":";;AACA,+CAA+D;AAE/D,+
|
|
1
|
+
{"version":3,"file":"useLinkToPathProps.js","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":";;AACA,+CAA+D;AAE/D,+DAAyD;AACzD,+DAA6D;AAC7D,0CAAyD;AAEzD,SAAS,yBAAyB,CAChC,CAA0E;IAE1E,IAAI,CAAC,EAAE,gBAAgB,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;IAED;IACE,yBAAyB;IACzB,QAAQ,IAAI,CAAC;QACb,mCAAmC;QACnC,CAAC,CAAC,CAAC,OAAO;QACV,CAAC,CAAC,CAAC,MAAM;QACT,CAAC,CAAC,CAAC,OAAO;QACV,CAAC,CAAC,CAAC,QAAQ;QACX,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,0BAA0B;QAClE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,0CAA0C;MACzG;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAwB,kBAAkB,CAAC,KAA0C;IACnF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,4BAAa,GAAE,CAAC;IAEnC,MAAM,OAAO,GAAG,CAAC,CAA2E,EAAE,EAAE;QAC9F,IAAI,YAAY,GAAG,KAAK,CAAC;QAEzB,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,EAAE;YAC/B,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC;SAC/C;aAAM,IAAI,yBAAyB,CAAC,CAAC,CAAC,EAAE;YACvC,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,YAAY,GAAG,IAAI,CAAC;SACrB;QAED,IAAI,YAAY,EAAE;YAChB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,sHAAsH;QACtH,IAAI,EAAE,IAAA,gCAAa,EAAC,IAAA,qCAA0B,EAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;QAClE,IAAI,EAAE,MAAe;QACrB,OAAO;KACR,CAAC;AACJ,CAAC;AAxBD,qCAwBC","sourcesContent":["import * as React from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\n\nimport { appendBaseUrl } from '../fork/getPathFromState';\nimport { useExpoRouter } from '../global-state/router-store';\nimport { stripGroupSegmentsFromPath } from '../matchers';\n\nfunction eventShouldPreventDefault(\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n): boolean {\n if (e?.defaultPrevented) {\n return false;\n }\n\n if (\n // Only check MouseEvents\n 'button' in e &&\n // ignore clicks with modifier keys\n !e.metaKey &&\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey &&\n (e.button == null || e.button === 0) && // Only accept left clicks\n [undefined, null, '', 'self'].includes(e.currentTarget.target) // let browser handle \"target=_blank\" etc.\n ) {\n return true;\n }\n\n return false;\n}\n\nexport default function useLinkToPathProps(props: { href: string; replace?: boolean }) {\n const { linkTo } = useExpoRouter();\n\n const onPress = (e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => {\n let shouldHandle = false;\n\n if (Platform.OS !== 'web' || !e) {\n shouldHandle = e ? !e.defaultPrevented : true;\n } else if (eventShouldPreventDefault(e)) {\n e.preventDefault();\n shouldHandle = true;\n }\n\n if (shouldHandle) {\n linkTo(props.href, props.replace ? 'REPLACE' : undefined);\n }\n };\n\n return {\n // Ensure there's always a value for href. Manually append the baseUrl to the href prop that shows in the static HTML.\n href: appendBaseUrl(stripGroupSegmentsFromPath(props.href) || '/'),\n role: 'link' as const,\n onPress,\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { RouteNode } from './Route';
|
|
2
2
|
export declare function loadStaticParamsAsync(route: RouteNode): Promise<RouteNode>;
|
|
3
|
+
export declare function assertStaticParams(route: Pick<RouteNode, 'contextKey' | 'dynamic'>, params: Record<string, string | string[]>): void;
|
|
3
4
|
//# sourceMappingURL=loadStaticParamsAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadStaticParamsAsync.d.ts","sourceRoot":"","sources":["../src/loadStaticParamsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"loadStaticParamsAsync.d.ts","sourceRoot":"","sources":["../src/loadStaticParamsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAC;AAE5D,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAMhF;AAgID,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,GAAG,SAAS,CAAC,EAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,QA2D1C"}
|