expo-router 6.0.0-preview.13 → 6.0.0-preview.15
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/build/getServerManifest.d.ts +0 -6
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +0 -1
- package/build/getServerManifest.js.map +1 -1
- package/build/link/LinkWithPreview.d.ts.map +1 -1
- package/build/link/LinkWithPreview.js +1 -2
- package/build/link/LinkWithPreview.js.map +1 -1
- package/build/link/elements.d.ts +10 -1
- package/build/link/elements.d.ts.map +1 -1
- package/build/link/elements.js +3 -5
- package/build/link/elements.js.map +1 -1
- package/build/link/preview/HrefPreview.js +7 -1
- package/build/link/preview/HrefPreview.js.map +1 -1
- package/build/routes-manifest.d.ts +0 -33
- package/build/routes-manifest.d.ts.map +1 -1
- package/build/routes-manifest.js.map +1 -1
- package/ios/LinkPreview/LinkPreviewNativeModule.swift +0 -6
- package/ios/LinkPreview/LinkPreviewNativeView.swift +4 -4
- package/package.json +4 -4
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts
|
|
9
9
|
*/
|
|
10
10
|
import type { RouteNode } from './Route';
|
|
11
|
-
import type { MiddlewareMatcher } from './routes-manifest';
|
|
12
11
|
export type ExpoRouterServerManifestV1Route<TRegex = string> = {
|
|
13
12
|
file: string;
|
|
14
13
|
page: string;
|
|
@@ -36,11 +35,6 @@ export type ExpoRouterServerManifestV1Middleware = {
|
|
|
36
35
|
* @example _expo/functions/+middleware.js
|
|
37
36
|
*/
|
|
38
37
|
file: string;
|
|
39
|
-
/**
|
|
40
|
-
* Optional matcher configuration for conditional middleware execution.
|
|
41
|
-
* When undefined, middleware runs on all requests.
|
|
42
|
-
*/
|
|
43
|
-
matcher?: MiddlewareMatcher;
|
|
44
38
|
};
|
|
45
39
|
export type ExpoRouterServerManifestV1<TRegex = string> = {
|
|
46
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMzC,MAAM,MAAM,+BAA+B,CAAC,MAAM,GAAG,MAAM,IAAI;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,6GAA6G;IAC7G,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,MAAM,GAAG,MAAM,IAAI;IACxD;;;OAGG;IACH,UAAU,CAAC,EAAE,oCAAoC,CAAC;IAClD;;OAEG;IACH,QAAQ,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACpD;;OAEG;IACH,SAAS,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACrD;;;OAGG;IACH,UAAU,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACtD;;OAEG;IACH,SAAS,EAAE,+BAA+B,CAAC,MAAM,CA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,IAAI,CAAC,EAAE,CAAC;QAC1B,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright © 2023 Vercel, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts\n */\nimport type { RouteNode } from './Route';\nimport { getContextKey, matchGroupName } from './matchers';\nimport type { MiddlewareMatcher } from './routes-manifest';\nimport { sortRoutes } from './sortRoutes';\nimport { shouldLinkExternally } from './utils/url';\n\n// TODO: Share these types across cli, server, router, etc.\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n /**\n * Keys are route param names that have been normalized for a regex named-matcher, values are the original route param names.\n */\n routeKeys: Record<string, string>;\n /**\n * Regex for matching a path against the route.\n * The regex is normalized for named matchers so keys must be looked up against the `routeKeys` object to collect the original route param names.\n * Regex matching alone cannot accurately route to a file, the order in which routes are matched is equally important to ensure correct priority.\n */\n namedRegex: TRegex;\n /** Indicates that the route was generated and does not map to any file in the project's routes directory. */\n generated?: boolean;\n /** Indicates that this is a redirect that should use 301 instead of 307 */\n permanent?: boolean;\n /** If a redirect, which methods are allowed. Undefined represents all methods */\n methods?: string[];\n};\n\nexport type ExpoRouterServerManifestV1Middleware = {\n /**\n * Path to the module that contains the middleware function as a default export.\n *\n * @example _expo/functions/+middleware.js\n */\n file: string;\n /**\n * Optional matcher configuration for conditional middleware execution.\n * When undefined, middleware runs on all requests.\n */\n matcher?: MiddlewareMatcher;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n /**\n * Middleware function that runs before any route matching.\n * Only allowed at the root level and requires web.output: \"server\".\n */\n middleware?: ExpoRouterServerManifestV1Middleware;\n /**\n * Rewrites. After middleware has processed and regular routing resumes, these occur first.\n */\n rewrites: ExpoRouterServerManifestV1Route<TRegex>[];\n /**\n * List of routes that match second. Returns 301 and redirects to another path.\n */\n redirects: ExpoRouterServerManifestV1Route<TRegex>[];\n /**\n * Routes that return static HTML files for a given path.\n * These are only matched against requests with method `GET` and `HEAD`.\n */\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n /**\n * Routes that are matched after HTML routes and invoke WinterCG-compliant functions.\n */\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n /** List of routes that are matched last and return with status code 404. */\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: Record<string, Group>;\n re: RegExp;\n}\n\nfunction isNotFoundRoute(route: RouteNode) {\n return route.dynamic && route.dynamic[route.dynamic.length - 1].notFound;\n}\n\nfunction uniqueBy<T>(arr: T[], key: (item: T) => string): T[] {\n const seen = new Set<string>();\n return arr.filter((item) => {\n const id = key(item);\n if (seen.has(id)) {\n return false;\n }\n seen.add(id);\n return true;\n });\n}\n\n// TODO(@hassankhan): ENG-16575\ntype FlatNodeTuple = [contextKey: string, absoluteRoute: string, node: RouteNode];\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(route: RouteNode): ExpoRouterServerManifestV1 {\n function getFlatNodes(route: RouteNode, parentRoute: string = ''): FlatNodeTuple[] {\n // Use a recreated route instead of contextKey because we duplicate nodes to support array syntax.\n const absoluteRoute = [parentRoute, route.route].filter(Boolean).join('/');\n\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child, absoluteRoute)).flat();\n }\n\n // API Routes are handled differently to HTML routes because they have no nested behavior.\n // An HTML route can be different based on parent segments due to layout routes, therefore multiple\n // copies should be rendered. However, an API route is always the same regardless of parent segments.\n let key: string;\n if (route.type.includes('api')) {\n key = getContextKey(route.contextKey).replace(/\\/index$/, '') ?? '/';\n } else {\n key = getContextKey(absoluteRoute).replace(/\\/index$/, '') ?? '/';\n }\n return [[key, '/' + absoluteRoute, route]];\n }\n\n // Remove duplicates from the runtime manifest which expands array syntax.\n const flat = getFlatNodes(route)\n .sort(([, , a], [, , b]) => sortRoutes(b, a))\n .reverse();\n\n const apiRoutes = uniqueBy(\n flat.filter(([, , route]) => route.type === 'api'),\n ([path]) => path\n );\n\n const otherRoutes = uniqueBy(\n flat.filter(\n ([, , route]) =>\n route.type === 'route' ||\n (route.type === 'rewrite' && (route.methods === undefined || route.methods.includes('GET')))\n ),\n ([path]) => path\n );\n\n const redirects = uniqueBy(\n flat.filter(([, , route]) => route.type === 'redirect'),\n ([path]) => path\n )\n .map((redirect) => {\n // TODO(@hassankhan): ENG-16577\n // For external redirects, use `destinationContextKey` as the destination URL\n if (shouldLinkExternally(redirect[2].destinationContextKey!)) {\n redirect[1] = redirect[2].destinationContextKey!;\n } else {\n redirect[1] =\n flat.find(([, , route]) => route.contextKey === redirect[2].destinationContextKey)?.[0] ??\n '/';\n }\n\n return redirect;\n })\n .reverse();\n\n const rewrites = uniqueBy(\n flat.filter(([, , route]) => route.type === 'rewrite'),\n ([path]) => path\n )\n .map((rewrite) => {\n rewrite[1] =\n flat.find(([, , route]) => route.contextKey === rewrite[2].destinationContextKey)?.[0] ??\n '/';\n\n return rewrite;\n })\n .reverse();\n\n const standardRoutes = otherRoutes.filter(([, , route]) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(([, , route]) => isNotFoundRoute(route));\n\n const manifest: ExpoRouterServerManifestV1 = {\n apiRoutes: getMatchableManifestForPaths(apiRoutes),\n htmlRoutes: getMatchableManifestForPaths(standardRoutes),\n notFoundRoutes: getMatchableManifestForPaths(notFoundRoutes),\n redirects: getMatchableManifestForPaths(redirects),\n rewrites: getMatchableManifestForPaths(rewrites),\n };\n\n if (route.middleware) {\n manifest.middleware = {\n file: route.middleware.contextKey,\n matcher: route.middleware.loadRoute().unstable_settings?.matcher ?? undefined,\n };\n }\n\n return manifest;\n}\n\nfunction getMatchableManifestForPaths(\n paths: [string, string, RouteNode][]\n): ExpoRouterServerManifestV1Route[] {\n return paths.map(([normalizedRoutePath, absoluteRoute, node]) => {\n const matcher: ExpoRouterServerManifestV1Route = getNamedRouteRegex(\n normalizedRoutePath,\n absoluteRoute,\n node.contextKey\n );\n if (node.generated) {\n matcher.generated = true;\n }\n\n if (node.permanent) {\n matcher.permanent = true;\n }\n\n if (node.methods) {\n matcher.methods = node.methods;\n }\n\n return matcher;\n });\n}\n\nfunction getNamedRouteRegex(\n normalizedRoute: string,\n page: string,\n file: string\n): ExpoRouterServerManifestV1Route {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n file,\n page,\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string): string {\n return route.replace(/\\/$/, '') || '/';\n}\n\nfunction getNamedParametrizedRoute(route: string) {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: Record<string, string> = {};\n return {\n namedParameterizedRoute: segments\n .map((segment, index) => {\n if (segment === '+not-found' && index === segments.length - 1) {\n segment = '[...not-found]';\n }\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment);\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n const groupName = matchGroupName(segment)!\n .split(',')\n .map((group) => group.trim())\n .filter(Boolean);\n if (groupName.length > 1) {\n const optionalSegment = `\\\\((?:${groupName.map(escapeStringRegexp).join('|')})\\\\)`;\n // Make section optional\n return `(?:/${optionalSegment})?`;\n } else {\n // Use simpler regex for single groups\n return `(?:/${escapeStringRegexp(segment)})?`;\n }\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join(''),\n routeKeys,\n };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nexport function parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":";;AAuGA,8CA0FC;AA4JD,wCAgBC;AAnWD,yCAA2D;AAC3D,6CAA0C;AAC1C,qCAAmD;AAuEnD,SAAS,eAAe,CAAC,KAAgB;IACvC,OAAO,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC3E,CAAC;AAED,SAAS,QAAQ,CAAI,GAAQ,EAAE,GAAwB;IACrD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAKD,yFAAyF;AACzF,SAAgB,iBAAiB,CAAC,KAAgB;IAChD,SAAS,YAAY,CAAC,KAAgB,EAAE,cAAsB,EAAE;QAC9D,kGAAkG;QAClG,MAAM,aAAa,GAAG,CAAC,WAAW,EAAE,KAAK,CAA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,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright © 2023 Vercel, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts\n */\nimport type { RouteNode } from './Route';\nimport { getContextKey, matchGroupName } from './matchers';\nimport { sortRoutes } from './sortRoutes';\nimport { shouldLinkExternally } from './utils/url';\n\n// TODO: Share these types across cli, server, router, etc.\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n /**\n * Keys are route param names that have been normalized for a regex named-matcher, values are the original route param names.\n */\n routeKeys: Record<string, string>;\n /**\n * Regex for matching a path against the route.\n * The regex is normalized for named matchers so keys must be looked up against the `routeKeys` object to collect the original route param names.\n * Regex matching alone cannot accurately route to a file, the order in which routes are matched is equally important to ensure correct priority.\n */\n namedRegex: TRegex;\n /** Indicates that the route was generated and does not map to any file in the project's routes directory. */\n generated?: boolean;\n /** Indicates that this is a redirect that should use 301 instead of 307 */\n permanent?: boolean;\n /** If a redirect, which methods are allowed. Undefined represents all methods */\n methods?: string[];\n};\n\nexport type ExpoRouterServerManifestV1Middleware = {\n /**\n * Path to the module that contains the middleware function as a default export.\n *\n * @example _expo/functions/+middleware.js\n */\n file: string;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n /**\n * Middleware function that runs before any route matching.\n * Only allowed at the root level and requires web.output: \"server\".\n */\n middleware?: ExpoRouterServerManifestV1Middleware;\n /**\n * Rewrites. After middleware has processed and regular routing resumes, these occur first.\n */\n rewrites: ExpoRouterServerManifestV1Route<TRegex>[];\n /**\n * List of routes that match second. Returns 301 and redirects to another path.\n */\n redirects: ExpoRouterServerManifestV1Route<TRegex>[];\n /**\n * Routes that return static HTML files for a given path.\n * These are only matched against requests with method `GET` and `HEAD`.\n */\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n /**\n * Routes that are matched after HTML routes and invoke WinterCG-compliant functions.\n */\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n /** List of routes that are matched last and return with status code 404. */\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: Record<string, Group>;\n re: RegExp;\n}\n\nfunction isNotFoundRoute(route: RouteNode) {\n return route.dynamic && route.dynamic[route.dynamic.length - 1].notFound;\n}\n\nfunction uniqueBy<T>(arr: T[], key: (item: T) => string): T[] {\n const seen = new Set<string>();\n return arr.filter((item) => {\n const id = key(item);\n if (seen.has(id)) {\n return false;\n }\n seen.add(id);\n return true;\n });\n}\n\n// TODO(@hassankhan): ENG-16575\ntype FlatNodeTuple = [contextKey: string, absoluteRoute: string, node: RouteNode];\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(route: RouteNode): ExpoRouterServerManifestV1 {\n function getFlatNodes(route: RouteNode, parentRoute: string = ''): FlatNodeTuple[] {\n // Use a recreated route instead of contextKey because we duplicate nodes to support array syntax.\n const absoluteRoute = [parentRoute, route.route].filter(Boolean).join('/');\n\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child, absoluteRoute)).flat();\n }\n\n // API Routes are handled differently to HTML routes because they have no nested behavior.\n // An HTML route can be different based on parent segments due to layout routes, therefore multiple\n // copies should be rendered. However, an API route is always the same regardless of parent segments.\n let key: string;\n if (route.type.includes('api')) {\n key = getContextKey(route.contextKey).replace(/\\/index$/, '') ?? '/';\n } else {\n key = getContextKey(absoluteRoute).replace(/\\/index$/, '') ?? '/';\n }\n return [[key, '/' + absoluteRoute, route]];\n }\n\n // Remove duplicates from the runtime manifest which expands array syntax.\n const flat = getFlatNodes(route)\n .sort(([, , a], [, , b]) => sortRoutes(b, a))\n .reverse();\n\n const apiRoutes = uniqueBy(\n flat.filter(([, , route]) => route.type === 'api'),\n ([path]) => path\n );\n\n const otherRoutes = uniqueBy(\n flat.filter(\n ([, , route]) =>\n route.type === 'route' ||\n (route.type === 'rewrite' && (route.methods === undefined || route.methods.includes('GET')))\n ),\n ([path]) => path\n );\n\n const redirects = uniqueBy(\n flat.filter(([, , route]) => route.type === 'redirect'),\n ([path]) => path\n )\n .map((redirect) => {\n // TODO(@hassankhan): ENG-16577\n // For external redirects, use `destinationContextKey` as the destination URL\n if (shouldLinkExternally(redirect[2].destinationContextKey!)) {\n redirect[1] = redirect[2].destinationContextKey!;\n } else {\n redirect[1] =\n flat.find(([, , route]) => route.contextKey === redirect[2].destinationContextKey)?.[0] ??\n '/';\n }\n\n return redirect;\n })\n .reverse();\n\n const rewrites = uniqueBy(\n flat.filter(([, , route]) => route.type === 'rewrite'),\n ([path]) => path\n )\n .map((rewrite) => {\n rewrite[1] =\n flat.find(([, , route]) => route.contextKey === rewrite[2].destinationContextKey)?.[0] ??\n '/';\n\n return rewrite;\n })\n .reverse();\n\n const standardRoutes = otherRoutes.filter(([, , route]) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(([, , route]) => isNotFoundRoute(route));\n\n const manifest: ExpoRouterServerManifestV1 = {\n apiRoutes: getMatchableManifestForPaths(apiRoutes),\n htmlRoutes: getMatchableManifestForPaths(standardRoutes),\n notFoundRoutes: getMatchableManifestForPaths(notFoundRoutes),\n redirects: getMatchableManifestForPaths(redirects),\n rewrites: getMatchableManifestForPaths(rewrites),\n };\n\n if (route.middleware) {\n manifest.middleware = {\n file: route.middleware.contextKey,\n };\n }\n\n return manifest;\n}\n\nfunction getMatchableManifestForPaths(\n paths: [string, string, RouteNode][]\n): ExpoRouterServerManifestV1Route[] {\n return paths.map(([normalizedRoutePath, absoluteRoute, node]) => {\n const matcher: ExpoRouterServerManifestV1Route = getNamedRouteRegex(\n normalizedRoutePath,\n absoluteRoute,\n node.contextKey\n );\n if (node.generated) {\n matcher.generated = true;\n }\n\n if (node.permanent) {\n matcher.permanent = true;\n }\n\n if (node.methods) {\n matcher.methods = node.methods;\n }\n\n return matcher;\n });\n}\n\nfunction getNamedRouteRegex(\n normalizedRoute: string,\n page: string,\n file: string\n): ExpoRouterServerManifestV1Route {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n file,\n page,\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string): string {\n return route.replace(/\\/$/, '') || '/';\n}\n\nfunction getNamedParametrizedRoute(route: string) {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: Record<string, string> = {};\n return {\n namedParameterizedRoute: segments\n .map((segment, index) => {\n if (segment === '+not-found' && index === segments.length - 1) {\n segment = '[...not-found]';\n }\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment);\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n const groupName = matchGroupName(segment)!\n .split(',')\n .map((group) => group.trim())\n .filter(Boolean);\n if (groupName.length > 1) {\n const optionalSegment = `\\\\((?:${groupName.map(escapeStringRegexp).join('|')})\\\\)`;\n // Make section optional\n return `(?:/${optionalSegment})?`;\n } else {\n // Use simpler regex for single groups\n return `(?:/${escapeStringRegexp(segment)})?`;\n }\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join(''),\n routeKeys,\n };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nexport function parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkWithPreview.d.ts","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"LinkWithPreview.d.ts","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,qBAwH/D"}
|
|
@@ -85,7 +85,6 @@ function LinkWithPreview({ children, ...rest }) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
const trigger = react_1.default.useMemo(() => triggerElement ?? <elements_1.LinkTrigger>{children}</elements_1.LinkTrigger>, [triggerElement, children]);
|
|
88
|
-
const highlightBorderRadius = rest.style && 'borderRadius' in rest.style ? rest.style.borderRadius : undefined;
|
|
89
88
|
const preview = react_1.default.useMemo(() => ((0, url_1.shouldLinkExternally)(String(rest.href)) || !previewElement ? null : previewElement), [previewElement, rest.href]);
|
|
90
89
|
const isPreviewTapped = (0, react_1.useRef)(false);
|
|
91
90
|
const tabPathValue = (0, react_1.useMemo)(() => ({
|
|
@@ -119,7 +118,7 @@ function LinkWithPreview({ children, ...rest }) {
|
|
|
119
118
|
if (!isPad) {
|
|
120
119
|
router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });
|
|
121
120
|
}
|
|
122
|
-
}} style={
|
|
121
|
+
}} style={{ display: 'contents' }} disableForceFlatten>
|
|
123
122
|
<InternalLinkPreviewContext_1.InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>
|
|
124
123
|
<BaseExpoRouterLink_1.BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref}/>
|
|
125
124
|
{preview}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkWithPreview.js","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBb,
|
|
1
|
+
{"version":3,"file":"LinkWithPreview.js","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBb,0CAwHC;AA9ID,+CAOe;AACf,+CAAwC;AAExC,oCAAqC;AACrC,6DAA0D;AAC1D,6EAA0E;AAC1E,yCAAgE;AAChE,qEAAqE;AACrE,6CAAqD;AACrD,+DAA4D;AAE5D,sCAAoD;AAEpD,MAAM,KAAK,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,uBAAQ,CAAC,KAAK,CAAC;AAEtD,SAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAa;IAC9D,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAA,0CAAqB,GAAE,CAAC;IACtD,MAAM,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEvE,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,oBAAoB,GAAG,IAAA,cAAM,EAAC,gBAAgB,CAAC,CAAC;IAEtD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE,CAAC;YACzB,IAAI,oBAAoB,CAAC,OAAO,KAAK,gBAAgB,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CACb,iKAAiK,CAClK,CA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CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC/D;QAAA,CAAC,OAAO,CACR;QAAA,CAAC,WAAW,CACd;MAAA,EAAE,uDAA0B,CAC9B;IAAA,EAAE,0BAAiB,CAAC,CACrB,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,QAA6C,EAC7C,IAAgC;IAEhC,OAAO,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC1C,CAAC,KAAK,EAAiC,EAAE,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CACvF,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport React, {\n isValidElement,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport { Platform } from 'react-native';\n\nimport { useRouter } from '../hooks';\nimport { BaseExpoRouterLink } from './BaseExpoRouterLink';\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { LinkMenu, LinkPreview, LinkTrigger } from './elements';\nimport { useLinkPreviewContext } from './preview/LinkPreviewContext';\nimport { NativeLinkPreview } from './preview/native';\nimport { useNextScreenId } from './preview/useNextScreenId';\nimport { LinkProps } from './useLinkHooks';\nimport { shouldLinkExternally } from '../utils/url';\n\nconst isPad = Platform.OS === 'ios' && Platform.isPad;\n\nexport function LinkWithPreview({ children, ...rest }: LinkProps) {\n const router = useRouter();\n const { setOpenPreviewKey } = useLinkPreviewContext();\n const [isCurrentPreviewOpen, setIsCurrenPreviewOpen] = useState(false);\n\n const hrefWithoutQuery = String(rest.href).split('?')[0];\n const prevHrefWithoutQuery = useRef(hrefWithoutQuery);\n\n useEffect(() => {\n if (isCurrentPreviewOpen) {\n if (prevHrefWithoutQuery.current !== hrefWithoutQuery) {\n throw new Error(\n 'Link does not support changing the href prop after the preview has been opened. Please ensure that the href prop is stable and does not change between renders.'\n );\n }\n } else {\n prevHrefWithoutQuery.current = hrefWithoutQuery;\n }\n }, [hrefWithoutQuery]);\n\n const [{ nextScreenId, tabPath }, prefetch] = useNextScreenId();\n\n useEffect(() => {\n if (rest.replace) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('Using replace links with preview is not supported');\n } else {\n console.warn('Using replace links with preview is not supported');\n }\n }\n }, [rest.href, rest.replace]);\n\n const triggerElement = React.useMemo(\n () => getFirstChildOfType(children, LinkTrigger),\n [children]\n );\n const menuElement = React.useMemo(() => getFirstChildOfType(children, LinkMenu), [children]);\n const previewElement = React.useMemo(\n () => getFirstChildOfType(children, LinkPreview),\n [children]\n );\n\n if ((previewElement || menuElement) && !triggerElement) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'When you use Link.Preview, you must use Link.Trigger to specify the trigger element.'\n );\n } else {\n console.warn(\n 'When you use Link.Preview, you must use Link.Trigger to specify the trigger element.'\n );\n }\n }\n\n const trigger = React.useMemo(\n () => triggerElement ?? <LinkTrigger>{children}</LinkTrigger>,\n [triggerElement, children]\n );\n\n const preview = React.useMemo(\n () => (shouldLinkExternally(String(rest.href)) || !previewElement ? null : previewElement),\n [previewElement, rest.href]\n );\n\n const isPreviewTapped = useRef(false);\n\n const tabPathValue = useMemo(\n () => ({\n path: tabPath,\n }),\n [tabPath]\n );\n\n const hasPreview = !!previewElement;\n\n if (rest.replace) {\n return <BaseExpoRouterLink children={children} {...rest} />;\n }\n\n return (\n <NativeLinkPreview\n nextScreenId={isPad ? undefined : nextScreenId}\n tabPath={isPad ? undefined : tabPathValue}\n onWillPreviewOpen={() => {\n if (hasPreview) {\n isPreviewTapped.current = false;\n prefetch(rest.href);\n setIsCurrenPreviewOpen(true);\n }\n }}\n onPreviewWillClose={() => {\n if (hasPreview) {\n setIsCurrenPreviewOpen(false);\n // When preview was not tapped, then we need to enable the screen stack animation\n // Otherwise this will happen in StackNavigator, when new screen is opened\n if (!isPreviewTapped.current || isPad) {\n setOpenPreviewKey(undefined);\n }\n }\n }}\n onPreviewDidClose={() => {\n if (hasPreview && isPreviewTapped.current && isPad) {\n router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });\n }\n }}\n onPreviewTapped={() => {\n isPreviewTapped.current = true;\n if (!isPad) {\n router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });\n }\n }}\n style={{ display: 'contents' }}\n disableForceFlatten>\n <InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>\n <BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref} />\n {preview}\n {menuElement}\n </InternalLinkPreviewContext>\n </NativeLinkPreview>\n );\n}\n\nfunction getFirstChildOfType<PropsT>(\n children: React.ReactNode | React.ReactNode[],\n type: (props: PropsT) => unknown\n) {\n return React.Children.toArray(children).find(\n (child): child is ReactElement<PropsT> => isValidElement(child) && child.type === type\n );\n}\n"]}
|
package/build/link/elements.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { type PropsWithChildren, type ReactElement } from 'react';
|
|
2
|
+
import type { ViewStyle } from 'react-native';
|
|
2
3
|
import type { SFSymbol } from 'sf-symbols-typescript';
|
|
3
4
|
export interface LinkMenuActionProps {
|
|
4
5
|
/**
|
|
@@ -95,7 +96,7 @@ export interface LinkMenuProps {
|
|
|
95
96
|
* @platform ios
|
|
96
97
|
*/
|
|
97
98
|
export declare const LinkMenu: React.FC<LinkMenuProps>;
|
|
98
|
-
export
|
|
99
|
+
export type LinkPreviewStyle = Omit<ViewStyle, 'position' | 'width' | 'height'> & {
|
|
99
100
|
/**
|
|
100
101
|
* Sets the preferred width of the preview.
|
|
101
102
|
* If not set, full width of the screen will be used.
|
|
@@ -110,7 +111,15 @@ export interface LinkPreviewProps {
|
|
|
110
111
|
* This is only **preferred** height, the actual height may be different
|
|
111
112
|
*/
|
|
112
113
|
height?: number;
|
|
114
|
+
};
|
|
115
|
+
export interface LinkPreviewProps {
|
|
113
116
|
children?: React.ReactNode;
|
|
117
|
+
/**
|
|
118
|
+
* Custom styles for the preview container.
|
|
119
|
+
*
|
|
120
|
+
* Note that some styles may not work, as they are limited or reset by the native view
|
|
121
|
+
*/
|
|
122
|
+
style?: LinkPreviewStyle;
|
|
114
123
|
}
|
|
115
124
|
/**
|
|
116
125
|
* A component used to render and customize the link preview.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAuB,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,4BAYxD;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC,mBAAmB,CAAC,GAAG,YAAY,CAAC,mBAAmB,CAAC,EAAE,CAAC;CACnF;AAED;;;;;;;;;;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AO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAe5C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG;IAChF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,4BAwBlD;AAED,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,mSAYlD"}
|
package/build/link/elements.js
CHANGED
|
@@ -115,12 +115,13 @@ exports.LinkMenu = LinkMenu;
|
|
|
115
115
|
* @platform ios
|
|
116
116
|
*/
|
|
117
117
|
function LinkPreview(props) {
|
|
118
|
-
const {
|
|
118
|
+
const { children, style } = props;
|
|
119
119
|
const internalPreviewContext = (0, react_1.use)(InternalLinkPreviewContext_1.InternalLinkPreviewContext);
|
|
120
120
|
if ((0, PreviewRouteContext_1.useIsPreview)() || process.env.EXPO_OS !== 'ios' || !internalPreviewContext) {
|
|
121
121
|
return null;
|
|
122
122
|
}
|
|
123
123
|
const { isVisible, href } = internalPreviewContext;
|
|
124
|
+
const { width, height, ...restOfStyle } = style ?? {};
|
|
124
125
|
const contentSize = {
|
|
125
126
|
width: width ?? 0,
|
|
126
127
|
height: height ?? 0,
|
|
@@ -132,10 +133,7 @@ function LinkPreview(props) {
|
|
|
132
133
|
else {
|
|
133
134
|
content = isVisible ? <HrefPreview_1.HrefPreview href={href}/> : null;
|
|
134
135
|
}
|
|
135
|
-
return (<native_1.NativeLinkPreviewContent style={{
|
|
136
|
-
/* Setting default background here, so that the preview is not transparent */
|
|
137
|
-
backgroundColor: '#fff',
|
|
138
|
-
}} preferredContentSize={contentSize}>
|
|
136
|
+
return (<native_1.NativeLinkPreviewContent style={restOfStyle} preferredContentSize={contentSize}>
|
|
139
137
|
{content}
|
|
140
138
|
</native_1.NativeLinkPreviewContent>);
|
|
141
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDb,wCAYC;AAqHD,kCA4BC;AAuBD,kCAYC;AAtPD,+CAA8F;AAG9F,6EAA0E;AAC1E,uDAAoD;AACpD,uEAA6D;AAC7D,6CAAqF;AACrF,qCAAkC;AAuClC;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,KAA0B;IACvD,IAAI,IAAA,kCAAY,GAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC,IAAA,WAAG,EAAC,uDAA0B,CAAC,EAAE,CAAC;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC3D,OAAO,CACL,CAAC,gCAAuB,CACtB,IAAI,IAAI,CAAC,CACT,UAAU,CAAC,CAAC,OAAO,CAAC,CACpB,aAAa,CAAC,CAAC,sBAAsB,CAAC,EACtC,CACH,CAAC;AACJ,CAAC;AAkCD;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,QAAQ,GAA4B,CAAC,KAAK,EAAE,EAAE;IACzD,IAAI,IAAA,kCAAY,GAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK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AG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,CAAC;IAED,OAAO,CACL,CAAC,iCAAwB,CACvB,KAAK,CAAC,CAAC;YACL,6EAA6E;YAC7E,eAAe,EAAE,MAAM;SACxB,CAAC,CACF,oBAAoB,CAAC,CAAC,WAAW,CAAC,CAClC;MAAA,CAAC,OAAO,CACV;IAAA,EAAE,iCAAwB,CAAC,CAC5B,CAAC;AACJ,CAAC;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChF,6EAA6E;QAC7E,qGAAqG;QACrG,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IACD,OAAO,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7B,CAAC","sourcesContent":["'use client';\n\nimport React, { isValidElement, use, type PropsWithChildren, type ReactElement } from 'react';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { HrefPreview } from './preview/HrefPreview';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { NativeLinkPreviewAction, NativeLinkPreviewContent } from './preview/native';\nimport { Slot } from '../ui/Slot';\n\nexport interface LinkMenuActionProps {\n /**\n * The title of the menu item.\n */\n title: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * If `true`, the menu item will be disabled and not selectable.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/disabled) for more information.\n */\n disabled?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/destructive) for more information.\n */\n destructive?: boolean;\n /**\n * If `true`, the menu will be kept presented after the action is selected.\n *\n * This is marked as unstable, because when action is selected it will recreate the menu,\n * which will close all opened submenus and reset the scroll position.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/keepsmenupresented) for more information.\n */\n unstable_keepPresented?: boolean;\n /**\n * If `true`, the menu item will be displayed as selected.\n */\n isOn?: boolean;\n onPress: () => void;\n}\n\n/**\n * This component renders a context menu action for a link.\n * It should only be used as a child of `Link.Menu` or `LinkMenu`.\n *\n * > **Note**: You can use the alias `Link.MenuAction` for this component.\n *\n * @platform ios\n */\nexport function LinkMenuAction(props: LinkMenuActionProps) {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const { unstable_keepPresented, onPress, ...rest } = props;\n return (\n <NativeLinkPreviewAction\n {...rest}\n onSelected={onPress}\n keepPresented={unstable_keepPresented}\n />\n );\n}\n\nexport interface LinkMenuProps {\n /**\n * The title of the menu item\n */\n title?: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: string;\n /**\n * If `true`, the menu will be displayed as a palette.\n * This means that the menu will be displayed as one row\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n displayAsPalette?: boolean;\n /**\n * If `true`, the menu will be displayed inline.\n * This means that the menu will not be collapsed\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayinline) for more information.\n */\n displayInline?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/destructive) for more information.\n */\n destructive?: boolean;\n children: ReactElement<LinkMenuActionProps> | ReactElement<LinkMenuActionProps>[];\n}\n\n/**\n * Groups context menu actions for a link.\n *\n * If multiple `Link.Menu` components are used within a single `Link`, only the first will be rendered.\n * Only `Link.MenuAction` and `LinkMenuAction` components are allowed as children.\n *\n * @example\n * ```tsx\n * <Link.Menu>\n * <Link.MenuAction title=\"Action 1\" onPress={() => {}} />\n * <Link.MenuAction title=\"Action 2\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n *\n * > **Note**: You can use the alias `Link.Menu` for this component.\n *\n * @platform ios\n */\nexport const LinkMenu: React.FC<LinkMenuProps> = (props) => {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const children = React.Children.toArray(props.children).filter(\n (child) => isValidElement(child) && (child.type === LinkMenuAction || child.type === LinkMenu)\n );\n return (\n <NativeLinkPreviewAction\n {...props}\n title={props.title ?? ''}\n onSelected={() => {}}\n children={children}\n />\n );\n};\n\nexport interface LinkPreviewProps {\n /**\n * Sets the preferred width of the preview.\n * If not set, full width of the screen will be used.\n *\n * This is only **preferred** width, the actual width may be different\n */\n width?: number;\n\n /**\n * Sets the preferred height of the preview.\n * If not set, full height of the screen will be used.\n *\n * This is only **preferred** height, the actual height may be different\n */\n height?: number;\n children?: React.ReactNode;\n}\n\n/**\n * A component used to render and customize the link preview.\n *\n * If `Link.Preview` is used without any props, it will render a preview of the `href` passed to the `Link`.\n *\n * If multiple `Link.Preview` components are used within a single `Link`, only the first one will be rendered.\n *\n * To customize the preview, you can pass custom content as children.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview>\n * <Text>Custom Preview Content</Text>\n * </Link.Preview>\n * </Link>\n * ```\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview />\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Preview` for this component.\n *\n * @platform ios\n */\nexport function LinkPreview(props: LinkPreviewProps) {\n const { width, height, children } = props;\n const internalPreviewContext = use(InternalLinkPreviewContext);\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !internalPreviewContext) {\n return null;\n }\n const { isVisible, href } = internalPreviewContext;\n const contentSize = {\n width: width ?? 0,\n height: height ?? 0,\n };\n let content: React.ReactNode;\n if (children) {\n content = isVisible ? children : null;\n } else {\n content = isVisible ? <HrefPreview href={href} /> : null;\n }\n\n return (\n <NativeLinkPreviewContent\n style={{\n /* Setting default background here, so that the preview is not transparent */\n backgroundColor: '#fff',\n }}\n preferredContentSize={contentSize}>\n {content}\n </NativeLinkPreviewContent>\n );\n}\n\nexport type LinkTriggerProps = PropsWithChildren;\n\n/**\n * Serves as the trigger for a link.\n * The content inside this component will be rendered as part of the base link.\n *\n * If multiple `Link.Trigger` components are used within a single `Link`, only the first will be rendered.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Trigger>\n * Trigger\n * </Link.Trigger>\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Trigger` for this component.\n *\n * @platform ios\n */\nexport function LinkTrigger(props: LinkTriggerProps) {\n if (React.Children.count(props.children) > 1 || !isValidElement(props.children)) {\n // If onPress is passed, this means that Link passed props to this component.\n // We can assume that asChild is used, so we throw an error, because link will not work in this case.\n if (props && typeof props === 'object' && 'onPress' in props) {\n throw new Error(\n 'When using Link.Trigger in an asChild Link, you must pass a single child element that will emit onPress event.'\n );\n }\n return props.children;\n }\n return <Slot {...props} />;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDb,wCAYC;AA8HD,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;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChF,6EAA6E;QAC7E,qGAAqG;QACrG,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IACD,OAAO,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7B,CAAC","sourcesContent":["'use client';\n\nimport React, { isValidElement, use, type PropsWithChildren, type ReactElement } from 'react';\nimport type { ViewStyle } from 'react-native';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { HrefPreview } from './preview/HrefPreview';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { NativeLinkPreviewAction, NativeLinkPreviewContent } from './preview/native';\nimport { Slot } from '../ui/Slot';\n\nexport interface LinkMenuActionProps {\n /**\n * The title of the menu item.\n */\n title: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * If `true`, the menu item will be disabled and not selectable.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/disabled) for more information.\n */\n disabled?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/destructive) for more information.\n */\n destructive?: boolean;\n /**\n * If `true`, the menu will be kept presented after the action is selected.\n *\n * This is marked as unstable, because when action is selected it will recreate the menu,\n * which will close all opened submenus and reset the scroll position.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/keepsmenupresented) for more information.\n */\n unstable_keepPresented?: boolean;\n /**\n * If `true`, the menu item will be displayed as selected.\n */\n isOn?: boolean;\n onPress: () => void;\n}\n\n/**\n * This component renders a context menu action for a link.\n * It should only be used as a child of `Link.Menu` or `LinkMenu`.\n *\n * > **Note**: You can use the alias `Link.MenuAction` for this component.\n *\n * @platform ios\n */\nexport function LinkMenuAction(props: LinkMenuActionProps) {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const { unstable_keepPresented, onPress, ...rest } = props;\n return (\n <NativeLinkPreviewAction\n {...rest}\n onSelected={onPress}\n keepPresented={unstable_keepPresented}\n />\n );\n}\n\nexport interface LinkMenuProps {\n /**\n * The title of the menu item\n */\n title?: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: string;\n /**\n * If `true`, the menu will be displayed as a palette.\n * This means that the menu will be displayed as one row\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n displayAsPalette?: boolean;\n /**\n * If `true`, the menu will be displayed inline.\n * This means that the menu will not be collapsed\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayinline) for more information.\n */\n displayInline?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/destructive) for more information.\n */\n destructive?: boolean;\n children: ReactElement<LinkMenuActionProps> | ReactElement<LinkMenuActionProps>[];\n}\n\n/**\n * Groups context menu actions for a link.\n *\n * If multiple `Link.Menu` components are used within a single `Link`, only the first will be rendered.\n * Only `Link.MenuAction` and `LinkMenuAction` components are allowed as children.\n *\n * @example\n * ```tsx\n * <Link.Menu>\n * <Link.MenuAction title=\"Action 1\" onPress={() => {}} />\n * <Link.MenuAction title=\"Action 2\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n *\n * > **Note**: You can use the alias `Link.Menu` for this component.\n *\n * @platform ios\n */\nexport const LinkMenu: React.FC<LinkMenuProps> = (props) => {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const children = React.Children.toArray(props.children).filter(\n (child) => isValidElement(child) && (child.type === LinkMenuAction || child.type === LinkMenu)\n );\n return (\n <NativeLinkPreviewAction\n {...props}\n title={props.title ?? ''}\n onSelected={() => {}}\n children={children}\n />\n );\n};\n\nexport type LinkPreviewStyle = Omit<ViewStyle, 'position' | 'width' | 'height'> & {\n /**\n * Sets the preferred width of the preview.\n * If not set, full width of the screen will be used.\n *\n * This is only **preferred** width, the actual width may be different\n */\n width?: number;\n\n /**\n * Sets the preferred height of the preview.\n * If not set, full height of the screen will be used.\n *\n * This is only **preferred** height, the actual height may be different\n */\n height?: number;\n};\n\nexport interface LinkPreviewProps {\n children?: React.ReactNode;\n /**\n * Custom styles for the preview container.\n *\n * Note that some styles may not work, as they are limited or reset by the native view\n */\n style?: LinkPreviewStyle;\n}\n\n/**\n * A component used to render and customize the link preview.\n *\n * If `Link.Preview` is used without any props, it will render a preview of the `href` passed to the `Link`.\n *\n * If multiple `Link.Preview` components are used within a single `Link`, only the first one will be rendered.\n *\n * To customize the preview, you can pass custom content as children.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview>\n * <Text>Custom Preview Content</Text>\n * </Link.Preview>\n * </Link>\n * ```\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview />\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Preview` for this component.\n *\n * @platform ios\n */\nexport function LinkPreview(props: LinkPreviewProps) {\n const { children, style } = props;\n const internalPreviewContext = use(InternalLinkPreviewContext);\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !internalPreviewContext) {\n return null;\n }\n const { isVisible, href } = internalPreviewContext;\n const { width, height, ...restOfStyle } = style ?? {};\n const contentSize = {\n width: width ?? 0,\n height: height ?? 0,\n };\n let content: React.ReactNode;\n if (children) {\n content = isVisible ? children : null;\n } else {\n content = isVisible ? <HrefPreview href={href} /> : null;\n }\n\n return (\n <NativeLinkPreviewContent style={restOfStyle} preferredContentSize={contentSize}>\n {content}\n </NativeLinkPreviewContent>\n );\n}\n\nexport type LinkTriggerProps = PropsWithChildren;\n\n/**\n * Serves as the trigger for a link.\n * The content inside this component will be rendered as part of the base link.\n *\n * If multiple `Link.Trigger` components are used within a single `Link`, only the first will be rendered.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Trigger>\n * Trigger\n * </Link.Trigger>\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Trigger` for this component.\n *\n * @platform ios\n */\nexport function LinkTrigger(props: LinkTriggerProps) {\n if (React.Children.count(props.children) > 1 || !isValidElement(props.children)) {\n // If onPress is passed, this means that Link passed props to this component.\n // We can assume that asChild is used, so we throw an error, because link will not work in this case.\n if (props && typeof props === 'object' && 'onPress' in props) {\n throw new Error(\n 'When using Link.Trigger in an asChild Link, you must pass a single child element that will emit onPress event.'\n );\n }\n return props.children;\n }\n return <Slot {...props} />;\n}\n"]}
|
|
@@ -73,7 +73,13 @@ function PreviewForRootHrefState({ hrefState, href }) {
|
|
|
73
73
|
}
|
|
74
74
|
function PreviewForInternalRoutes() {
|
|
75
75
|
const pathname = (0, hooks_1.usePathname)();
|
|
76
|
-
return (<react_native_1.View style={{
|
|
76
|
+
return (<react_native_1.View style={{
|
|
77
|
+
flex: 1,
|
|
78
|
+
justifyContent: 'center',
|
|
79
|
+
alignItems: 'center',
|
|
80
|
+
gap: 8,
|
|
81
|
+
backgroundColor: 'white',
|
|
82
|
+
}}>
|
|
77
83
|
<react_native_1.Text style={{ fontWeight: '600', fontSize: 24 }}>Invalid preview</react_native_1.Text>
|
|
78
84
|
<react_native_1.Text style={{ fontWeight: '200', fontSize: 14 }}>{pathname}</react_native_1.Text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nC,GAAG,EAAE,qBAAqB,CAAC,KAAK,CAAC;IACjC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;IAC3C,kBAAkB,EAAE,qBAAqB,CAAC,oBAAoB,CAAC;IAC/D,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC;IACzC,KAAK,EAAE,GAAG,EAAE;QACV,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,mBAAmB;IACnB,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC;IAC7C,QAAQ,EAAE,GAAG,EAAE;QACb,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO;YACL,GAAG,EAAE,EAAE;YACP,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContext,\n type NavigationProp,\n type ParamListBase,\n} from '@react-navigation/native';\nimport { useMemo } from 'react';\nimport { Text, View } from 'react-native';\n\nimport { PreviewRouteContext } from './PreviewRouteContext';\nimport { RouteNode } from '../../Route';\nimport { INTERNAL_SLOT_NAME, NOT_FOUND_ROUTE_NAME, SITEMAP_ROUTE_NAME } from '../../constants';\nimport { type ResultState } from '../../exports';\nimport { store } from '../../global-state/router-store';\nimport { getRootStackRouteNames } from '../../global-state/utils';\nimport { usePathname } from '../../hooks';\nimport { Href, UnknownOutputParams } from '../../types';\nimport { useNavigation } from '../../useNavigation';\nimport { getQualifiedRouteComponent } from '../../useScreens';\nimport { getPathFromState } from '../linking';\n\nexport function HrefPreview({ href }: { href: Href }) {\n const hrefState = useMemo(() => getHrefState(href), [href]);\n const index = hrefState?.index ?? 0;\n\n let isProtected = false;\n if (hrefState?.routes[index]?.name === INTERNAL_SLOT_NAME) {\n let routerState: typeof hrefState | undefined = hrefState;\n let rnState = store.state;\n while (routerState && rnState) {\n const routerRoute: ResultState['routes'][number] = routerState.routes[0];\n // When the route we want to show is not present in react-navigation state\n // Then most likely it is a protected route\n if (rnState.stale === false && !rnState.routeNames?.includes(routerRoute.name)) {\n isProtected = true;\n break;\n }\n const rnIndex = rnState.routes.findIndex((route) => route.name === routerRoute.name);\n if (rnIndex === -1) {\n break;\n }\n routerState = routerRoute.state;\n rnState = rnState.routes[rnIndex]?.state;\n }\n if (!isProtected) {\n return <PreviewForRootHrefState hrefState={hrefState} href={href} />;\n }\n }\n\n const pathname = href.toString();\n const segments = pathname.split('/').filter(Boolean);\n\n return (\n <PreviewRouteContext.Provider\n value={{\n params: {},\n pathname,\n segments,\n }}>\n <PreviewForInternalRoutes />\n </PreviewRouteContext.Provider>\n );\n}\n\nfunction PreviewForRootHrefState({ hrefState, href }: { hrefState: ResultState; href: Href }) {\n const navigation = useNavigation();\n const { routeNode, params, state } = getParamsAndNodeFromHref(hrefState);\n\n const path = state ? getPathFromState(state) : undefined;\n\n const value = useMemo(\n () => ({\n params,\n pathname: href.toString(),\n segments: path?.split('/').filter(Boolean) || [],\n }),\n [params, href]\n );\n\n // This can happen in a theoretical case where the state is not yet initialized or is incorrectly initialized.\n // This check ensures TypeScript type safety as well.\n if (!routeNode) {\n return null;\n }\n\n const Component = getQualifiedRouteComponent(routeNode);\n\n return (\n <PreviewRouteContext value={value}>\n {/* Using NavigationContext to override useNavigation */}\n <NavigationContext value={navigationPropWithWarnings}>\n <Component navigation={navigation} />\n </NavigationContext>\n </PreviewRouteContext>\n );\n}\n\nfunction PreviewForInternalRoutes() {\n const pathname = usePathname();\n return (\n <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', gap: 8 }}>\n <Text style={{ fontWeight: '600', fontSize: 24 }}>Invalid preview</Text>\n <Text style={{ fontWeight: '200', fontSize: 14 }}>{pathname}</Text>\n </View>\n );\n}\n\nfunction getHrefState(href: Href) {\n const hrefState = store.getStateForHref(href as any);\n return hrefState;\n}\n\nfunction getParamsAndNodeFromHref(hrefState: ResultState) {\n const index = hrefState?.index ?? 0;\n if (hrefState?.routes[index] && hrefState.routes[index].name !== INTERNAL_SLOT_NAME) {\n const name = hrefState.routes[index].name;\n if (name === SITEMAP_ROUTE_NAME || name === NOT_FOUND_ROUTE_NAME) {\n console.log(store.routeNode);\n console.log(hrefState);\n }\n const error = `Expo Router Error: Expected navigation state to begin with one of [${getRootStackRouteNames().join(', ')}] routes`;\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(error);\n } else {\n console.warn(error);\n }\n }\n const initialState = hrefState?.routes[index]?.state;\n let state = initialState;\n let routeNode: RouteNode | undefined | null = store.routeNode;\n\n const params: UnknownOutputParams = {};\n\n while (state && routeNode) {\n const route = state.routes[state.index || state.routes.length - 1];\n Object.assign(params, route.params);\n state = route.state;\n routeNode = routeNode.children.find((child) => child.route === route.name);\n }\n\n return { params, routeNode, state: initialState };\n}\n\nconst displayWarningForProp = (prop: string) => {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `navigation.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`\n );\n }\n};\n\nconst createNOOPWithWarning = (prop: string) => () => displayWarningForProp(prop);\n\nconst navigationPropWithWarnings: NavigationProp<ParamListBase> = {\n setParams: createNOOPWithWarning('setParams'),\n setOptions: createNOOPWithWarning('setOptions'),\n addListener: (() => () => {}) as NavigationProp<ParamListBase>['addListener'],\n removeListener: () => {},\n isFocused: () => true,\n canGoBack: () => false,\n dispatch: createNOOPWithWarning('dispatch'),\n navigate: createNOOPWithWarning('navigate'),\n goBack: createNOOPWithWarning('goBack'),\n reset: createNOOPWithWarning('reset'),\n push: createNOOPWithWarning('push'),\n pop: createNOOPWithWarning('pop'),\n popToTop: createNOOPWithWarning('popToTop'),\n navigateDeprecated: createNOOPWithWarning('navigateDeprecated'),\n preload: createNOOPWithWarning('preload'),\n getId: () => {\n displayWarningForProp('getId');\n return '';\n },\n // @ts-expect-error\n getParent: createNOOPWithWarning('getParent'),\n getState: () => {\n displayWarningForProp('getState');\n return {\n key: '',\n index: 0,\n routeNames: [],\n routes: [],\n type: '',\n stale: false,\n };\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"HrefPreview.js","sourceRoot":"","sources":["../../../src/link/preview/HrefPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAsBb,kCAyCC;AA7DD,qDAIkC;AAClC,iCAAgC;AAChC,+CAA0C;AAE1C,+DAA4D;AAE5D,+CAA+F;AAE/F,kEAAwD;AACxD,oDAAkE;AAClE,uCAA0C;AAE1C,uDAAoD;AACpD,iDAA8D;AAC9D,wCAA8C;AAE9C,SAAgB,WAAW,CAAC,EAAE,IAAI,EAAkB;IAClD,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,SAAS,EAAE,KAAK,IAAI,CAAC,CAAC;IAEpC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,8BAAkB,EAAE,CAAC;QAC1D,IAAI,WAAW,GAAiC,SAAS,CAAC;QAC1D,IAAI,OAAO,GAAG,oBAAK,CAAC,KAAK,CAAC;QAC1B,OAAO,WAAW,IAAI,OAAO,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAkC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACzE,0EAA0E;YAC1E,2CAA2C;YAC3C,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/E,WAAW,GAAG,IAAI,CAAC;gBACnB,MAAM;YACR,CAAC;YACD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,SA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IACvC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC;IACrC,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,qBAAqB,CAAC,KAAK,CAAC;IACjC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;IAC3C,kBAAkB,EAAE,qBAAqB,CAAC,oBAAoB,CAAC;IAC/D,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC;IACzC,KAAK,EAAE,GAAG,EAAE;QACV,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,mBAAmB;IACnB,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC;IAC7C,QAAQ,EAAE,GAAG,EAAE;QACb,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO;YACL,GAAG,EAAE,EAAE;YACP,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContext,\n type NavigationProp,\n type ParamListBase,\n} from '@react-navigation/native';\nimport { useMemo } from 'react';\nimport { Text, View } from 'react-native';\n\nimport { PreviewRouteContext } from './PreviewRouteContext';\nimport { RouteNode } from '../../Route';\nimport { INTERNAL_SLOT_NAME, NOT_FOUND_ROUTE_NAME, SITEMAP_ROUTE_NAME } from '../../constants';\nimport { type ResultState } from '../../exports';\nimport { store } from '../../global-state/router-store';\nimport { getRootStackRouteNames } from '../../global-state/utils';\nimport { usePathname } from '../../hooks';\nimport { Href, UnknownOutputParams } from '../../types';\nimport { useNavigation } from '../../useNavigation';\nimport { getQualifiedRouteComponent } from '../../useScreens';\nimport { getPathFromState } from '../linking';\n\nexport function HrefPreview({ href }: { href: Href }) {\n const hrefState = useMemo(() => getHrefState(href), [href]);\n const index = hrefState?.index ?? 0;\n\n let isProtected = false;\n if (hrefState?.routes[index]?.name === INTERNAL_SLOT_NAME) {\n let routerState: typeof hrefState | undefined = hrefState;\n let rnState = store.state;\n while (routerState && rnState) {\n const routerRoute: ResultState['routes'][number] = routerState.routes[0];\n // When the route we want to show is not present in react-navigation state\n // Then most likely it is a protected route\n if (rnState.stale === false && !rnState.routeNames?.includes(routerRoute.name)) {\n isProtected = true;\n break;\n }\n const rnIndex = rnState.routes.findIndex((route) => route.name === routerRoute.name);\n if (rnIndex === -1) {\n break;\n }\n routerState = routerRoute.state;\n rnState = rnState.routes[rnIndex]?.state;\n }\n if (!isProtected) {\n return <PreviewForRootHrefState hrefState={hrefState} href={href} />;\n }\n }\n\n const pathname = href.toString();\n const segments = pathname.split('/').filter(Boolean);\n\n return (\n <PreviewRouteContext.Provider\n value={{\n params: {},\n pathname,\n segments,\n }}>\n <PreviewForInternalRoutes />\n </PreviewRouteContext.Provider>\n );\n}\n\nfunction PreviewForRootHrefState({ hrefState, href }: { hrefState: ResultState; href: Href }) {\n const navigation = useNavigation();\n const { routeNode, params, state } = getParamsAndNodeFromHref(hrefState);\n\n const path = state ? getPathFromState(state) : undefined;\n\n const value = useMemo(\n () => ({\n params,\n pathname: href.toString(),\n segments: path?.split('/').filter(Boolean) || [],\n }),\n [params, href]\n );\n\n // This can happen in a theoretical case where the state is not yet initialized or is incorrectly initialized.\n // This check ensures TypeScript type safety as well.\n if (!routeNode) {\n return null;\n }\n\n const Component = getQualifiedRouteComponent(routeNode);\n\n return (\n <PreviewRouteContext value={value}>\n {/* Using NavigationContext to override useNavigation */}\n <NavigationContext value={navigationPropWithWarnings}>\n <Component navigation={navigation} />\n </NavigationContext>\n </PreviewRouteContext>\n );\n}\n\nfunction PreviewForInternalRoutes() {\n const pathname = usePathname();\n return (\n <View\n style={{\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n gap: 8,\n backgroundColor: 'white',\n }}>\n <Text style={{ fontWeight: '600', fontSize: 24 }}>Invalid preview</Text>\n <Text style={{ fontWeight: '200', fontSize: 14 }}>{pathname}</Text>\n </View>\n );\n}\n\nfunction getHrefState(href: Href) {\n const hrefState = store.getStateForHref(href as any);\n return hrefState;\n}\n\nfunction getParamsAndNodeFromHref(hrefState: ResultState) {\n const index = hrefState?.index ?? 0;\n if (hrefState?.routes[index] && hrefState.routes[index].name !== INTERNAL_SLOT_NAME) {\n const name = hrefState.routes[index].name;\n if (name === SITEMAP_ROUTE_NAME || name === NOT_FOUND_ROUTE_NAME) {\n console.log(store.routeNode);\n console.log(hrefState);\n }\n const error = `Expo Router Error: Expected navigation state to begin with one of [${getRootStackRouteNames().join(', ')}] routes`;\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(error);\n } else {\n console.warn(error);\n }\n }\n const initialState = hrefState?.routes[index]?.state;\n let state = initialState;\n let routeNode: RouteNode | undefined | null = store.routeNode;\n\n const params: UnknownOutputParams = {};\n\n while (state && routeNode) {\n const route = state.routes[state.index || state.routes.length - 1];\n Object.assign(params, route.params);\n state = route.state;\n routeNode = routeNode.children.find((child) => child.route === route.name);\n }\n\n return { params, routeNode, state: initialState };\n}\n\nconst displayWarningForProp = (prop: string) => {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `navigation.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`\n );\n }\n};\n\nconst createNOOPWithWarning = (prop: string) => () => displayWarningForProp(prop);\n\nconst navigationPropWithWarnings: NavigationProp<ParamListBase> = {\n setParams: createNOOPWithWarning('setParams'),\n setOptions: createNOOPWithWarning('setOptions'),\n addListener: (() => () => {}) as NavigationProp<ParamListBase>['addListener'],\n removeListener: () => {},\n isFocused: () => true,\n canGoBack: () => false,\n dispatch: createNOOPWithWarning('dispatch'),\n navigate: createNOOPWithWarning('navigate'),\n goBack: createNOOPWithWarning('goBack'),\n reset: createNOOPWithWarning('reset'),\n push: createNOOPWithWarning('push'),\n pop: createNOOPWithWarning('pop'),\n popToTop: createNOOPWithWarning('popToTop'),\n navigateDeprecated: createNOOPWithWarning('navigateDeprecated'),\n preload: createNOOPWithWarning('preload'),\n getId: () => {\n displayWarningForProp('getId');\n return '';\n },\n // @ts-expect-error\n getParent: createNOOPWithWarning('getParent'),\n getState: () => {\n displayWarningForProp('getState');\n return {\n key: '',\n index: 0,\n routeNames: [],\n routes: [],\n type: '',\n stale: false,\n };\n },\n};\n"]}
|
|
@@ -8,23 +8,6 @@ export type RouteInfo<TRegex = string> = {
|
|
|
8
8
|
permanent?: boolean;
|
|
9
9
|
methods?: string[];
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Middleware pattern type that can be a string (including globs) or a regular expression.
|
|
13
|
-
*/
|
|
14
|
-
export type MiddlewarePattern = string | RegExp;
|
|
15
|
-
export type MiddlewareMatcher = {
|
|
16
|
-
/**
|
|
17
|
-
* Array of path patterns to match against.
|
|
18
|
-
* Supports string literals, glob patterns, and regex.
|
|
19
|
-
* @example ['/api/*', '/admin/*', { pattern: '^/(auth)/(login|logout)$', regex: true }]
|
|
20
|
-
*/
|
|
21
|
-
patterns: MiddlewarePattern[];
|
|
22
|
-
/**
|
|
23
|
-
* HTTP methods to match (undefined = all methods)
|
|
24
|
-
* @example ['POST', 'PUT', 'DELETE']
|
|
25
|
-
*/
|
|
26
|
-
methods?: string[];
|
|
27
|
-
};
|
|
28
11
|
export type MiddlewareInfo = {
|
|
29
12
|
/**
|
|
30
13
|
* Path to the module that contains the middleware function as a default export.
|
|
@@ -32,22 +15,6 @@ export type MiddlewareInfo = {
|
|
|
32
15
|
* @example _expo/functions/+middleware.js
|
|
33
16
|
*/
|
|
34
17
|
file: string;
|
|
35
|
-
/**
|
|
36
|
-
* Optional matcher configuration for conditional middleware execution.
|
|
37
|
-
* When undefined, middleware runs on all requests.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* // In +middleware.ts
|
|
42
|
-
* export const settings = {
|
|
43
|
-
* matcher: {
|
|
44
|
-
* patterns: ['/api/*', '/(auth)/*'],
|
|
45
|
-
* methods: ['POST', 'PUT', 'DELETE']
|
|
46
|
-
* }
|
|
47
|
-
* };
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
matcher?: MiddlewareMatcher;
|
|
51
18
|
};
|
|
52
19
|
export type ExpoRoutesManifestV1<TRegex = string> = {
|
|
53
20
|
middleware?: MiddlewareInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-manifest.d.ts","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,gBAAgB,CAAC;AAIzD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,MAAM,MAAM,SAAS,CAAC,MAAM,GAAG,MAAM,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"routes-manifest.d.ts","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,gBAAgB,CAAC;AAIzD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,MAAM,MAAM,SAAS,CAAC,MAAM,GAAG,MAAM,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,MAAM,GAAG,MAAM,IAAI;IAClD,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC/B,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,cAAc,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IACpC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC/B,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;CAC/B,CAAC;AAYF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,OAAO,GACf,oBAAoB,GAAG,IAAI,CAe7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-manifest.js","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"routes-manifest.js","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":";;AA6CA,oDAkBC;AA/DD,0CAA0C;AAC1C,sBAAsB;AACtB,iDAAyD;AACzD,2DAAwD;AAgCxD,SAAS,uBAAuB,CAAC,MAAgB,EAAE;IACjD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAI,CAAC,EAAE,CAAC,CAAC;IAE3D,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE;QAC3C,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG;KACjB,CAAC,CAAC;IAEH,OAAO,aAA+B,CAAC;AACzC,CAAC;AAED,SAAgB,oBAAoB,CAClC,KAAe,EACf,OAAgB;IAEhB,mCAAmC;IACnC,MAAM,SAAS,GAAG,IAAA,wBAAS,EAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAC1D,GAAG,OAAO;QACV,iBAAiB,EAAE,IAAI;QACvB,2BAA2B,EAAE,IAAI;QACjC,mBAAmB,EAAE,IAAI;QACzB,iBAAiB,EAAE,IAAI;QACvB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// This file runs in Node.js environments.\n// no relative imports\nimport { type Options, getRoutes } from './getRoutesSSR';\nimport { getServerManifest } from './getServerManifest';\nimport { type RequireContext } from './types';\n\nexport { Options };\n\nexport type RouteInfo<TRegex = string> = {\n file: string;\n page: string;\n namedRegex: TRegex;\n routeKeys: Record<string, string>;\n permanent?: boolean;\n methods?: string[];\n};\n\nexport type MiddlewareInfo = {\n /**\n * Path to the module that contains the middleware function as a default export.\n *\n * @example _expo/functions/+middleware.js\n */\n file: string;\n};\n\nexport type ExpoRoutesManifestV1<TRegex = string> = {\n middleware?: MiddlewareInfo;\n apiRoutes: RouteInfo<TRegex>[];\n htmlRoutes: RouteInfo<TRegex>[];\n notFoundRoutes: RouteInfo<TRegex>[];\n redirects: RouteInfo<TRegex>[];\n rewrites: RouteInfo<TRegex>[];\n};\n\nfunction createMockContextModule(map: string[] = []) {\n const contextModule = (_key: string) => ({ default() {} });\n\n Object.defineProperty(contextModule, 'keys', {\n value: () => map,\n });\n\n return contextModule as RequireContext;\n}\n\nexport function createRoutesManifest(\n paths: string[],\n options: Options\n): ExpoRoutesManifestV1 | null {\n // TODO: Drop this part for Node.js\n const routeTree = getRoutes(createMockContextModule(paths), {\n ...options,\n preserveApiRoutes: true,\n preserveRedirectAndRewrites: true,\n ignoreRequireErrors: true,\n ignoreEntryPoints: true,\n platform: 'web',\n });\n\n if (!routeTree) {\n return null;\n }\n return getServerManifest(routeTree);\n}\n"]}
|
|
@@ -13,12 +13,6 @@ public class LinkPreviewNativeModule: Module {
|
|
|
13
13
|
view.tabPath = tabPath
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
Prop("borderRadius") { (view, borderRadius: Double?) in
|
|
17
|
-
if let borderRadius = borderRadius {
|
|
18
|
-
view.triggerBorderRadius = borderRadius
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
16
|
Prop("disableForceFlatten") { (_: NativeLinkPreviewView, _: Bool) in
|
|
23
17
|
// This prop is used in ExpoShadowNode in order to disable force flattening, when display: contents is used
|
|
24
18
|
}
|
|
@@ -2,7 +2,6 @@ import ExpoModulesCore
|
|
|
2
2
|
|
|
3
3
|
class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
|
|
4
4
|
LinkPreviewModalDismissible, LinkPreviewMenuUpdatable {
|
|
5
|
-
var triggerBorderRadius: Double = 0
|
|
6
5
|
private var preview: NativeLinkPreviewContentView?
|
|
7
6
|
private var interaction: UIContextMenuInteraction?
|
|
8
7
|
private var directChild: UIView?
|
|
@@ -131,8 +130,6 @@ class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
|
|
|
131
130
|
|
|
132
131
|
let parameters = UIPreviewParameters()
|
|
133
132
|
parameters.backgroundColor = .clear
|
|
134
|
-
parameters.shadowPath = UIBezierPath(
|
|
135
|
-
roundedRect: directChild.bounds, cornerRadius: self.triggerBorderRadius)
|
|
136
133
|
|
|
137
134
|
return UITargetedPreview(view: directChild, parameters: parameters, target: target)
|
|
138
135
|
}
|
|
@@ -185,7 +182,6 @@ class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
|
|
|
185
182
|
}
|
|
186
183
|
|
|
187
184
|
let vc = PreviewViewController(linkPreviewNativePreview: preview)
|
|
188
|
-
vc.view.addSubview(preview)
|
|
189
185
|
let preferredSize = preview.preferredContentSize
|
|
190
186
|
vc.preferredContentSize.width = preferredSize.width
|
|
191
187
|
vc.preferredContentSize.height = preferredSize.height
|
|
@@ -218,6 +214,10 @@ class PreviewViewController: UIViewController {
|
|
|
218
214
|
super.init(nibName: nil, bundle: nil)
|
|
219
215
|
}
|
|
220
216
|
|
|
217
|
+
override func loadView() {
|
|
218
|
+
self.view = linkPreviewNativePreview
|
|
219
|
+
}
|
|
220
|
+
|
|
221
221
|
@available(*, unavailable)
|
|
222
222
|
required init?(coder: NSCoder) {
|
|
223
223
|
fatalError("init(coder:) has not been implemented")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "6.0.0-preview.
|
|
3
|
+
"version": "6.0.0-preview.15",
|
|
4
4
|
"description": "Expo Router is a file-based router for React Native and web applications.",
|
|
5
5
|
"author": "650 Industries, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@testing-library/react-native": ">= 12.0.0",
|
|
82
82
|
"expo": "*",
|
|
83
83
|
"expo-constants": "^18.0.7",
|
|
84
|
-
"expo-linking": "^8.0.
|
|
84
|
+
"expo-linking": "^8.0.7",
|
|
85
85
|
"react": "*",
|
|
86
86
|
"react-dom": "*",
|
|
87
87
|
"react-native": "*",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"dependencies": {
|
|
130
130
|
"@expo/metro-runtime": "6.1.1",
|
|
131
131
|
"@expo/schema-utils": "^0.1.6",
|
|
132
|
-
"@expo/server": "^0.7.
|
|
132
|
+
"@expo/server": "^0.7.3",
|
|
133
133
|
"@radix-ui/react-slot": "1.2.0",
|
|
134
134
|
"@radix-ui/react-tabs": "^1.1.12",
|
|
135
135
|
"@react-navigation/bottom-tabs": "^7.4.0",
|
|
@@ -151,5 +151,5 @@
|
|
|
151
151
|
"use-latest-callback": "^0.2.1",
|
|
152
152
|
"vaul": "^1.1.2"
|
|
153
153
|
},
|
|
154
|
-
"gitHead": "
|
|
154
|
+
"gitHead": "8cafaff8076e443e6c80e8013ec809f4f290f24d"
|
|
155
155
|
}
|