@expo/cli 1.0.0-canary-20250219-4a5dade → 1.0.0-canary-20250303-4dba60e
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/bin/cli +1 -1
- package/build/metro-require/require.js +11 -11
- package/build/src/customize/generate.js +1 -4
- package/build/src/customize/generate.js.map +1 -1
- package/build/src/export/exportDomComponents.js +17 -4
- package/build/src/export/exportDomComponents.js.map +1 -1
- package/build/src/export/exportHermes.js +21 -21
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/publicFolder.js +1 -3
- package/build/src/export/publicFolder.js.map +1 -1
- package/build/src/prebuild/renameTemplateAppName.js +9 -9
- package/build/src/prebuild/renameTemplateAppName.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +2 -1
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +10 -9
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +4 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +17 -20
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +8 -8
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/utils/dir.js +32 -7
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/multipartMixed.js +54 -0
- package/build/src/utils/multipartMixed.js.map +1 -0
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +16 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/type-generation/routes.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport debounce from 'lodash.debounce';\nimport { Server } from 'metro';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { directoryExistsAsync } from '../../../utils/dir';\nimport { unsafeTemplate } from '../../../utils/template';\nimport { ServerLike } from '../BundlerDevServer';\nimport { metroWatchTypeScriptFiles } from '../metro/metroWatchTypeScriptFiles';\n\n// /test/[...param1]/[param2]/[param3] - captures [\"param1\", \"param2\", \"param3\"]\nexport const CAPTURE_DYNAMIC_PARAMS = /\\[(?:\\.{3})?(\\w*?)[\\]$]/g;\n// /[...param1]/ - Match [...param1]\nexport const CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nexport const SLUG = /\\[.+?\\]/g;\n// /(group1,group2,group3)/test - match (group1,group2,group3)\nexport const ARRAY_GROUP_REGEX = /\\(\\s*\\w[\\w\\s]*?,.*?\\)/g;\n// /(group1,group2,group3)/test - captures [\"group1\", \"group2\", \"group3\"]\nexport const CAPTURE_GROUP_REGEX = /[\\\\(,]\\s*(\\w[\\w\\s]*?)\\s*(?=[,\\\\)])/g;\n/**\n * Match:\n * - _layout files, +html, +not-found, string+api, etc\n * - Routes can still use `+`, but it cannot be in the last segment.\n */\nexport const TYPED_ROUTES_EXCLUSION_REGEX = /(_layout|[^/]*?\\+[^/]*?)\\.[tj]sx?$/;\n\nexport interface SetupTypedRoutesOptions {\n server?: ServerLike;\n metro?: Server | null;\n typesDirectory: string;\n projectRoot: string;\n /** Absolute expo router routes directory. */\n routerDirectory: string;\n plugin?: Record<string, any>;\n}\n\nexport async function setupTypedRoutes(options: SetupTypedRoutesOptions) {\n /*\n * In SDK 51, TypedRoutes was moved out of cli and into expo-router. For now we need to support both\n * the legacy and new versions of TypedRoutes.\n *\n * TODO (@marklawlor): Remove this check in SDK 53, only support Expo Router v4 and above.\n */\n const typedRoutesModule = resolveFrom.silent(\n options.projectRoot,\n 'expo-router/build/typed-routes'\n );\n return typedRoutesModule ? typedRoutes(typedRoutesModule, options) : legacyTypedRoutes(options);\n}\n\nasync function typedRoutes(\n typedRoutesModulePath: any,\n { server, metro, typesDirectory, projectRoot, routerDirectory, plugin }: SetupTypedRoutesOptions\n) {\n /*\n * Expo Router uses EXPO_ROUTER_APP_ROOT in multiple places to determine the root of the project.\n * In apps compiled by Metro, this code is compiled away. But Typed Routes run in NodeJS with no compilation\n * so we need to explicitly set it.\n */\n process.env.EXPO_ROUTER_APP_ROOT = routerDirectory;\n\n const typedRoutesModule = require(typedRoutesModulePath);\n\n /*\n * Typed Routes can be run with out Metro or a Server, e.g. `expo customize tsconfig.json`\n */\n if (metro && server) {\n // Setup out watcher first\n metroWatchTypeScriptFiles({\n projectRoot,\n server,\n metro,\n eventTypes: ['add', 'delete', 'change'],\n callback: typedRoutesModule.getWatchHandler(typesDirectory),\n });\n }\n\n /*\n * In SDK 52, the `regenerateDeclarations` was changed to accept plugin options.\n * This function has an optional parameter that we cannot override, so we need to ensure the user\n * is using a compatible version of `expo-router`. Otherwise, we will fallback to the old method.\n *\n * TODO(@marklawlor): In SDK53+ we should remove this check and always use the new method.\n */\n if ('version' in typedRoutesModule && typedRoutesModule.version >= 52) {\n typedRoutesModule.regenerateDeclarations(typesDirectory, plugin);\n } else {\n typedRoutesModule.regenerateDeclarations(typesDirectory);\n }\n}\n\nasync function legacyTypedRoutes({\n server,\n metro,\n typesDirectory,\n projectRoot,\n routerDirectory,\n}: SetupTypedRoutesOptions) {\n const { filePathToRoute, staticRoutes, dynamicRoutes, addFilePath, isRouteFile } =\n getTypedRoutesUtils(routerDirectory);\n\n // Typed Routes can be run with out Metro or a Server, e.g. `expo customize tsconfig.json`\n if (metro && server) {\n metroWatchTypeScriptFiles({\n projectRoot,\n server,\n metro,\n eventTypes: ['add', 'delete', 'change'],\n async callback({ filePath, type }) {\n if (!isRouteFile(filePath)) {\n return;\n }\n\n let shouldRegenerate = false;\n\n if (type === 'delete') {\n const route = filePathToRoute(filePath);\n staticRoutes.delete(route);\n dynamicRoutes.delete(route);\n shouldRegenerate = true;\n } else {\n shouldRegenerate = addFilePath(filePath);\n }\n\n if (shouldRegenerate) {\n regenerateRouterDotTS(\n typesDirectory,\n new Set([...staticRoutes.values()].flatMap((v) => Array.from(v))),\n new Set([...dynamicRoutes.values()].flatMap((v) => Array.from(v))),\n new Set(dynamicRoutes.keys())\n );\n }\n },\n });\n }\n\n if (await directoryExistsAsync(routerDirectory)) {\n // Do we need to walk the entire tree on startup?\n // Idea: Store the list of files in the last write, then simply check Git for what files have changed\n await walk(routerDirectory, addFilePath);\n }\n\n regenerateRouterDotTS(\n typesDirectory,\n new Set([...staticRoutes.values()].flatMap((v) => Array.from(v))),\n new Set([...dynamicRoutes.values()].flatMap((v) => Array.from(v))),\n new Set(dynamicRoutes.keys())\n );\n}\n\n/**\n * Generate a router.d.ts file that contains all of the routes in the project.\n * Should be debounced as its very common for developers to make changes to multiple files at once (eg Save All)\n */\nconst regenerateRouterDotTS = debounce(\n async (\n typesDir: string,\n staticRoutes: Set<string>,\n dynamicRoutes: Set<string>,\n dynamicRouteTemplates: Set<string>\n ) => {\n await fs.mkdir(typesDir, { recursive: true });\n await fs.writeFile(\n path.resolve(typesDir, './router.d.ts'),\n getTemplateString(staticRoutes, dynamicRoutes, dynamicRouteTemplates)\n );\n },\n 100\n);\n\n/*\n * This is exported for testing purposes\n */\nexport function getTemplateString(\n staticRoutes: Set<string>,\n dynamicRoutes: Set<string>,\n dynamicRouteTemplates: Set<string>\n) {\n return routerDotTSTemplate({\n staticRoutes: setToUnionType(staticRoutes),\n dynamicRoutes: setToUnionType(dynamicRoutes),\n dynamicRouteParams: setToUnionType(dynamicRouteTemplates),\n });\n}\n\n/**\n * Utility functions for typed routes\n *\n * These are extracted for easier testing\n */\nexport function getTypedRoutesUtils(appRoot: string, filePathSeperator = path.sep) {\n /*\n * staticRoutes are a map where the key if the route without groups and the value\n * is another set of all group versions of the route. e.g,\n * Map([\n * [\"/\", [\"/(app)/(notes)\", \"/(app)/(profile)\"]\n * ])\n */\n const staticRoutes = new Map<string, Set<string>>([['/', new Set('/')]]);\n /*\n * dynamicRoutes are the same as staticRoutes (key if the resolved route,\n * and the value is a set of possible routes). e.g:\n *\n * /[...fruits] -> /${CatchAllRoutePart<T>}\n * /color/[color] -> /color/${SingleRoutePart<T>}\n *\n * The keys of this map are also important, as they can be used as \"static\" types\n * <Link href={{ pathname: \"/[...fruits]\",params: { fruits: [\"apple\"] } }} />\n */\n const dynamicRoutes = new Map<string, Set<string>>();\n\n function normalizedFilePath(filePath: string) {\n return filePath.replaceAll(filePathSeperator, '/');\n }\n\n const normalizedAppRoot = normalizedFilePath(appRoot);\n\n const filePathToRoute = (filePath: string) => {\n return normalizedFilePath(filePath)\n .replace(normalizedAppRoot, '')\n .replace(/index\\.[jt]sx?/, '')\n .replace(/\\.[jt]sx?$/, '');\n };\n\n const isRouteFile = (filePath: string) => {\n if (filePath.match(TYPED_ROUTES_EXCLUSION_REGEX)) {\n return false;\n }\n\n // Route files must be nested with in the appRoot\n const relative = path.relative(appRoot, filePath);\n return relative && !relative.startsWith('..') && !path.isAbsolute(relative);\n };\n\n const addFilePath = (filePath: string): boolean => {\n if (!isRouteFile(filePath)) {\n return false;\n }\n\n const route = filePathToRoute(filePath);\n\n // We have already processed this file\n if (staticRoutes.has(route) || dynamicRoutes.has(route)) {\n return false;\n }\n\n const dynamicParams = new Set(\n [...route.matchAll(CAPTURE_DYNAMIC_PARAMS)].map((match) => match[1])\n );\n const isDynamic = dynamicParams.size > 0;\n\n const addRoute = (originalRoute: string, route: string) => {\n if (isDynamic) {\n let set = dynamicRoutes.get(originalRoute);\n\n if (!set) {\n set = new Set();\n dynamicRoutes.set(originalRoute, set);\n }\n\n set.add(\n route\n .replaceAll(CATCH_ALL, '${CatchAllRoutePart<T>}')\n .replaceAll(SLUG, '${SingleRoutePart<T>}')\n );\n } else {\n let set = staticRoutes.get(originalRoute);\n\n if (!set) {\n set = new Set();\n staticRoutes.set(originalRoute, set);\n }\n\n set.add(route);\n }\n };\n\n if (!route.match(ARRAY_GROUP_REGEX)) {\n addRoute(route, route);\n }\n\n // Does this route have a group? eg /(group)\n if (route.includes('/(')) {\n const routeWithoutGroups = route.replace(/\\/\\(.+?\\)/g, '');\n addRoute(route, routeWithoutGroups);\n\n // If there are multiple groups, we need to expand them\n // eg /(test1,test2)/page => /test1/page & /test2/page\n for (const routeWithSingleGroup of extrapolateGroupRoutes(route)) {\n addRoute(route, routeWithSingleGroup);\n }\n }\n\n return true;\n };\n\n return {\n staticRoutes,\n dynamicRoutes,\n filePathToRoute,\n addFilePath,\n isRouteFile,\n };\n}\n\nexport const setToUnionType = <T>(set: Set<T>) => {\n return set.size > 0 ? [...set].map((s) => `\\`${s}\\``).join(' | ') : 'never';\n};\n\n/**\n * Recursively walk a directory and call the callback with the file path.\n */\nasync function walk(directory: string, callback: (filePath: string) => void) {\n const files = await fs.readdir(directory);\n for (const file of files) {\n const p = path.join(directory, file);\n if ((await fs.stat(p)).isDirectory()) {\n await walk(p, callback);\n } else {\n // Normalise the paths so they are easier to convert to URLs\n const normalizedPath = p.replaceAll(path.sep, '/');\n callback(normalizedPath);\n }\n }\n}\n\n/**\n * Given a route, return all possible routes that could be generated from it.\n */\nexport function extrapolateGroupRoutes(\n route: string,\n routes: Set<string> = new Set()\n): Set<string> {\n // Create a version with no groups. We will then need to cleanup double and/or trailing slashes\n routes.add(route.replaceAll(ARRAY_GROUP_REGEX, '').replaceAll(/\\/+/g, '/').replace(/\\/$/, ''));\n\n const match = route.match(ARRAY_GROUP_REGEX);\n\n if (!match) {\n routes.add(route);\n return routes;\n }\n\n const groupsMatch = match[0];\n\n for (const group of groupsMatch.matchAll(CAPTURE_GROUP_REGEX)) {\n extrapolateGroupRoutes(route.replace(groupsMatch, `(${group[1].trim()})`), routes);\n }\n\n return routes;\n}\n\n/**\n * NOTE: This code refers to a specific version of `expo-router` and is therefore unsafe to\n * mix with arbitrary versions.\n * TODO: Version this code with `expo-router` or version expo-router with `@expo/cli`.\n */\nconst routerDotTSTemplate = unsafeTemplate`/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable import/export */\n/* eslint-disable @typescript-eslint/ban-types */\ndeclare module \"expo-router\" {\n import type { LinkProps as OriginalLinkProps } from 'expo-router/build/link/Link';\n import type { Router as OriginalRouter } from 'expo-router/build/types';\n export * from 'expo-router/build';\n\n // prettier-ignore\n type StaticRoutes = ${'staticRoutes'};\n // prettier-ignore\n type DynamicRoutes<T extends string> = ${'dynamicRoutes'};\n // prettier-ignore\n type DynamicRouteTemplate = ${'dynamicRouteParams'};\n\n type RelativePathString = \\`./\\${string}\\` | \\`../\\${string}\\` | '..';\n type AbsoluteRoute = DynamicRouteTemplate | StaticRoutes;\n type ExternalPathString = \\`\\${string}:\\${string}\\`;\n\n type ExpoRouterRoutes = DynamicRouteTemplate | StaticRoutes | RelativePathString;\n export type AllRoutes = ExpoRouterRoutes | ExternalPathString;\n\n /****************\n * Route Utils *\n ****************/\n\n type SearchOrHash = \\`?\\${string}\\` | \\`#\\${string}\\`;\n type UnknownInputParams = Record<string, string | number | (string | number)[]>;\n type UnknownOutputParams = Record<string, string | string[]>;\n\n /**\n * Return only the RoutePart of a string. If the string has multiple parts return never\n *\n * string | type\n * ---------|------\n * 123 | 123\n * /123/abc | never\n * 123?abc | never\n * ./123 | never\n * /123 | never\n * 123/../ | never\n */\n type SingleRoutePart<S extends string> = S extends \\`\\${string}/\\${string}\\`\n ? never\n : S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S extends \\`(\\${string})\\`\n ? never\n : S extends \\`[\\${string}]\\`\n ? never\n : S;\n\n /**\n * Return only the CatchAll router part. If the string has search parameters or a hash return never\n */\n type CatchAllRoutePart<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S extends \\`\\${string}(\\${string})\\${string}\\`\n ? never\n : S extends \\`\\${string}[\\${string}]\\${string}\\`\n ? never\n : S;\n\n // type OptionalCatchAllRoutePart<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\` ? never : S\n\n /**\n * Return the name of a route parameter\n * '[test]' -> 'test'\n * 'test' -> never\n * '[...test]' -> '...test'\n */\n type IsParameter<Part> = Part extends \\`[\\${infer ParamName}]\\` ? ParamName : never;\n\n /**\n * Return a union of all parameter names. If there are no names return never\n *\n * /[test] -> 'test'\n * /[abc]/[...def] -> 'abc'|'...def'\n */\n type ParameterNames<Path> = Path extends \\`\\${infer PartA}/\\${infer PartB}\\`\n ? IsParameter<PartA> | ParameterNames<PartB>\n : IsParameter<Path>;\n\n /**\n * Returns all segements of a route.\n *\n * /(group)/123/abc/[id]/[...rest] -> ['(group)', '123', 'abc', '[id]', '[...rest]'\n */\n type RouteSegments<Path> = Path extends \\`\\${infer PartA}/\\${infer PartB}\\`\n ? PartA extends '' | '.'\n ? [...RouteSegments<PartB>]\n : [PartA, ...RouteSegments<PartB>]\n : Path extends ''\n ? []\n : [Path];\n\n /**\n * Returns a Record of the routes parameters as strings and CatchAll parameters\n *\n * There are two versions, input and output, as you can input 'string | number' but\n * the output will always be 'string'\n *\n * /[id]/[...rest] -> { id: string, rest: string[] }\n * /no-params -> {}\n */\n type InputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends \\`...\\${infer Name}\\`\n ? Name\n : Key]: Key extends \\`...\\${string}\\` ? (string | number)[] : string | number;\n } & UnknownInputParams;\n\n type OutputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends \\`...\\${infer Name}\\`\n ? Name\n : Key]: Key extends \\`...\\${string}\\` ? string[] : string;\n } & UnknownOutputParams;\n\n /**\n * Returns the search parameters for a route.\n */\n export type SearchParams<T extends AllRoutes> = T extends DynamicRouteTemplate\n ? OutputRouteParams<T>\n : T extends StaticRoutes\n ? never\n : UnknownOutputParams;\n\n /**\n * Route is mostly used as part of Href to ensure that a valid route is provided\n *\n * Given a dynamic route, this will return never. This is helpful for conditional logic\n *\n * /test -> /test, /test2, etc\n * /test/[abc] -> never\n * /test/resolve -> /test, /test2, etc\n *\n * Note that if we provide a value for [abc] then the route is allowed\n *\n * This is named Route to prevent confusion, as users they will often see it in tooltips\n */\n export type Route<T> = T extends string\n ? T extends DynamicRouteTemplate\n ? never\n :\n | StaticRoutes\n | RelativePathString\n | ExternalPathString\n | (T extends \\`\\${infer P}\\${SearchOrHash}\\`\n ? P extends DynamicRoutes<infer _>\n ? T\n : never\n : T extends DynamicRoutes<infer _>\n ? T\n : never)\n : never;\n\n /*********\n * Href *\n *********/\n\n export type Href<T> = T extends Record<'pathname', string> ? HrefObject<T> : Route<T>;\n\n export type HrefObject<\n R extends Record<'pathname', string>,\n P = R['pathname'],\n > = P extends DynamicRouteTemplate\n ? { pathname: P; params: InputRouteParams<P> }\n : P extends Route<P>\n ? { pathname: Route<P> | DynamicRouteTemplate; params?: never | InputRouteParams<never> }\n : never;\n\n /***********************\n * Expo Router Exports *\n ***********************/\n\n export type Router = Omit<OriginalRouter, 'push' | 'replace' | 'setParams'> & {\n /** Navigate to the provided href. */\n push: <T>(href: Href<T>) => void;\n /** Navigate to route without appending to the history. */\n replace: <T>(href: Href<T>) => void;\n /** Update the current route query params. */\n setParams: <T = ''>(params?: T extends '' ? Record<string, string> : InputRouteParams<T>) => void;\n };\n\n /** The imperative router. */\n export const router: Router;\n\n /************\n * <Link /> *\n ************/\n export interface LinkProps<T> extends OriginalLinkProps {\n href: Href<T>;\n }\n\n export interface LinkComponent {\n <T>(props: React.PropsWithChildren<LinkProps<T>>): JSX.Element;\n /** Helper method to resolve an Href object into a string. */\n resolveHref: <T>(href: Href<T>) => string;\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 */\n export const Link: LinkComponent;\n\n /** Redirects to the href as soon as the component is mounted. */\n export const Redirect: <T>(\n props: React.PropsWithChildren<{ href: Href<T> }>\n ) => JSX.Element;\n\n /************\n * Hooks *\n ************/\n export function useRouter(): Router;\n\n export function useLocalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n >(): T extends AllRoutes ? SearchParams<T> : T;\n\n /** @deprecated renamed to \\`useGlobalSearchParams\\` */\n export function useSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n >(): T extends AllRoutes ? SearchParams<T> : T;\n\n export function useGlobalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n >(): T extends AllRoutes ? SearchParams<T> : T;\n\n export function useSegments<\n T extends AbsoluteRoute | RouteSegments<AbsoluteRoute> | RelativePathString,\n >(): T extends AbsoluteRoute ? RouteSegments<T> : T extends string ? string[] : T;\n}\n`;\n"],"names":["CAPTURE_DYNAMIC_PARAMS","CATCH_ALL","SLUG","ARRAY_GROUP_REGEX","CAPTURE_GROUP_REGEX","TYPED_ROUTES_EXCLUSION_REGEX","setupTypedRoutes","getTemplateString","getTypedRoutesUtils","setToUnionType","extrapolateGroupRoutes","options","typedRoutesModule","resolveFrom","silent","projectRoot","typedRoutes","legacyTypedRoutes","typedRoutesModulePath","server","metro","typesDirectory","routerDirectory","plugin","process","env","EXPO_ROUTER_APP_ROOT","require","metroWatchTypeScriptFiles","eventTypes","callback","getWatchHandler","version","regenerateDeclarations","filePathToRoute","staticRoutes","dynamicRoutes","addFilePath","isRouteFile","filePath","type","shouldRegenerate","route","delete","regenerateRouterDotTS","Set","values","flatMap","v","Array","from","keys","directoryExistsAsync","walk","debounce","typesDir","dynamicRouteTemplates","fs","mkdir","recursive","writeFile","path","resolve","routerDotTSTemplate","dynamicRouteParams","appRoot","filePathSeperator","sep","Map","normalizedFilePath","replaceAll","normalizedAppRoot","replace","match","relative","startsWith","isAbsolute","has","dynamicParams","matchAll","map","isDynamic","size","addRoute","originalRoute","set","get","add","includes","routeWithoutGroups","routeWithSingleGroup","s","join","directory","files","readdir","file","p","stat","isDirectory","normalizedPath","routes","groupsMatch","group","trim","unsafeTemplate"],"mappings":"AAAA;;;;;;;;;;;IAYaA,sBAAsB,MAAtBA,sBAAsB;IAEtBC,SAAS,MAATA,SAAS;IAETC,IAAI,MAAJA,IAAI;IAEJC,iBAAiB,MAAjBA,iBAAiB;IAEjBC,mBAAmB,MAAnBA,mBAAmB;IAMnBC,4BAA4B,MAA5BA,4BAA4B;IAYnBC,gBAAgB,MAAhBA,gBAAgB;IAyItBC,iBAAiB,MAAjBA,iBAAiB;IAiBjBC,mBAAmB,MAAnBA,mBAAmB;IAmHtBC,cAAc,MAAdA,cAAc;IAwBXC,sBAAsB,MAAtBA,sBAAsB;;;8DA3UvB,aAAa;;;;;;;8DACP,iBAAiB;;;;;;;8DAErB,MAAM;;;;;;;8DACC,cAAc;;;;;;qBAED,oBAAoB;0BAC1B,yBAAyB;2CAEd,oCAAoC;;;;;;AAGvE,MAAMV,sBAAsB,6BAA6B,AAAC;AAE1D,MAAMC,SAAS,mBAAmB,AAAC;AAEnC,MAAMC,IAAI,aAAa,AAAC;AAExB,MAAMC,iBAAiB,2BAA2B,AAAC;AAEnD,MAAMC,mBAAmB,wCAAwC,AAAC;AAMlE,MAAMC,4BAA4B,uCAAuC,AAAC;AAY1E,eAAeC,gBAAgB,CAACK,OAAgC,EAAE;IACvE;;;;;GAKC,GACD,MAAMC,iBAAiB,GAAGC,YAAW,EAAA,QAAA,CAACC,MAAM,CAC1CH,OAAO,CAACI,WAAW,EACnB,gCAAgC,CACjC,AAAC;IACF,OAAOH,iBAAiB,GAAGI,WAAW,CAACJ,iBAAiB,EAAED,OAAO,CAAC,GAAGM,iBAAiB,CAACN,OAAO,CAAC,CAAC;AAClG,CAAC;AAED,eAAeK,WAAW,CACxBE,qBAA0B,EAC1B,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,E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;;;;;;;;;sBASrB,EAAE,cAAc,CAAC;;yCAEE,EAAE,eAAe,CAAC;;8BAE7B,EAAE,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqOrD,CAAC,AAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/type-generation/routes.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport { Server } from 'metro';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { directoryExistsAsync } from '../../../utils/dir';\nimport { unsafeTemplate } from '../../../utils/template';\nimport { ServerLike } from '../BundlerDevServer';\nimport { metroWatchTypeScriptFiles } from '../metro/metroWatchTypeScriptFiles';\n\n// /test/[...param1]/[param2]/[param3] - captures [\"param1\", \"param2\", \"param3\"]\nexport const CAPTURE_DYNAMIC_PARAMS = /\\[(?:\\.{3})?(\\w*?)[\\]$]/g;\n// /[...param1]/ - Match [...param1]\nexport const CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nexport const SLUG = /\\[.+?\\]/g;\n// /(group1,group2,group3)/test - match (group1,group2,group3)\nexport const ARRAY_GROUP_REGEX = /\\(\\s*\\w[\\w\\s]*?,.*?\\)/g;\n// /(group1,group2,group3)/test - captures [\"group1\", \"group2\", \"group3\"]\nexport const CAPTURE_GROUP_REGEX = /[\\\\(,]\\s*(\\w[\\w\\s]*?)\\s*(?=[,\\\\)])/g;\n/**\n * Match:\n * - _layout files, +html, +not-found, string+api, etc\n * - Routes can still use `+`, but it cannot be in the last segment.\n */\nexport const TYPED_ROUTES_EXCLUSION_REGEX = /(_layout|[^/]*?\\+[^/]*?)\\.[tj]sx?$/;\n\nexport interface SetupTypedRoutesOptions {\n server?: ServerLike;\n metro?: Server | null;\n typesDirectory: string;\n projectRoot: string;\n /** Absolute expo router routes directory. */\n routerDirectory: string;\n plugin?: Record<string, any>;\n}\n\nexport async function setupTypedRoutes(options: SetupTypedRoutesOptions) {\n /*\n * In SDK 51, TypedRoutes was moved out of cli and into expo-router. For now we need to support both\n * the legacy and new versions of TypedRoutes.\n *\n * TODO (@marklawlor): Remove this check in SDK 53, only support Expo Router v4 and above.\n */\n const typedRoutesModule = resolveFrom.silent(\n options.projectRoot,\n 'expo-router/build/typed-routes'\n );\n return typedRoutesModule ? typedRoutes(typedRoutesModule, options) : legacyTypedRoutes(options);\n}\n\nasync function typedRoutes(\n typedRoutesModulePath: any,\n { server, metro, typesDirectory, projectRoot, routerDirectory, plugin }: SetupTypedRoutesOptions\n) {\n /*\n * Expo Router uses EXPO_ROUTER_APP_ROOT in multiple places to determine the root of the project.\n * In apps compiled by Metro, this code is compiled away. But Typed Routes run in NodeJS with no compilation\n * so we need to explicitly set it.\n */\n process.env.EXPO_ROUTER_APP_ROOT = routerDirectory;\n\n const typedRoutesModule = require(typedRoutesModulePath);\n\n /*\n * Typed Routes can be run with out Metro or a Server, e.g. `expo customize tsconfig.json`\n */\n if (metro && server) {\n // Setup out watcher first\n metroWatchTypeScriptFiles({\n projectRoot,\n server,\n metro,\n eventTypes: ['add', 'delete', 'change'],\n callback: typedRoutesModule.getWatchHandler(typesDirectory),\n });\n }\n\n /*\n * In SDK 52, the `regenerateDeclarations` was changed to accept plugin options.\n * This function has an optional parameter that we cannot override, so we need to ensure the user\n * is using a compatible version of `expo-router`. Otherwise, we will fallback to the old method.\n *\n * TODO(@marklawlor): In SDK53+ we should remove this check and always use the new method.\n */\n if ('version' in typedRoutesModule && typedRoutesModule.version >= 52) {\n typedRoutesModule.regenerateDeclarations(typesDirectory, plugin);\n } else {\n typedRoutesModule.regenerateDeclarations(typesDirectory);\n }\n}\n\nasync function legacyTypedRoutes({\n server,\n metro,\n typesDirectory,\n projectRoot,\n routerDirectory,\n}: SetupTypedRoutesOptions) {\n const { filePathToRoute, staticRoutes, dynamicRoutes, addFilePath, isRouteFile } =\n getTypedRoutesUtils(routerDirectory);\n\n // Typed Routes can be run with out Metro or a Server, e.g. `expo customize tsconfig.json`\n if (metro && server) {\n metroWatchTypeScriptFiles({\n projectRoot,\n server,\n metro,\n eventTypes: ['add', 'delete', 'change'],\n async callback({ filePath, type }) {\n if (!isRouteFile(filePath)) {\n return;\n }\n\n let shouldRegenerate = false;\n\n if (type === 'delete') {\n const route = filePathToRoute(filePath);\n staticRoutes.delete(route);\n dynamicRoutes.delete(route);\n shouldRegenerate = true;\n } else {\n shouldRegenerate = addFilePath(filePath);\n }\n\n if (shouldRegenerate) {\n regenerateRouterDotTS(\n typesDirectory,\n new Set([...staticRoutes.values()].flatMap((v) => Array.from(v))),\n new Set([...dynamicRoutes.values()].flatMap((v) => Array.from(v))),\n new Set(dynamicRoutes.keys())\n );\n }\n },\n });\n }\n\n if (await directoryExistsAsync(routerDirectory)) {\n // Do we need to walk the entire tree on startup?\n // Idea: Store the list of files in the last write, then simply check Git for what files have changed\n await walk(routerDirectory, addFilePath);\n }\n\n regenerateRouterDotTS(\n typesDirectory,\n new Set([...staticRoutes.values()].flatMap((v) => Array.from(v))),\n new Set([...dynamicRoutes.values()].flatMap((v) => Array.from(v))),\n new Set(dynamicRoutes.keys())\n );\n}\n\nfunction debounce<U, T extends (this: U, ...args: any[]) => void>(fn: T, delay: number): T {\n let timeoutId: NodeJS.Timeout | undefined;\n return function (this: U, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), delay);\n } as T;\n}\n\n/**\n * Generate a router.d.ts file that contains all of the routes in the project.\n * Should be debounced as its very common for developers to make changes to multiple files at once (eg Save All)\n */\nconst regenerateRouterDotTS = debounce(\n async (\n typesDir: string,\n staticRoutes: Set<string>,\n dynamicRoutes: Set<string>,\n dynamicRouteTemplates: Set<string>\n ) => {\n await fs.mkdir(typesDir, { recursive: true });\n await fs.writeFile(\n path.resolve(typesDir, './router.d.ts'),\n getTemplateString(staticRoutes, dynamicRoutes, dynamicRouteTemplates)\n );\n },\n 100\n);\n\n/*\n * This is exported for testing purposes\n */\nexport function getTemplateString(\n staticRoutes: Set<string>,\n dynamicRoutes: Set<string>,\n dynamicRouteTemplates: Set<string>\n) {\n return routerDotTSTemplate({\n staticRoutes: setToUnionType(staticRoutes),\n dynamicRoutes: setToUnionType(dynamicRoutes),\n dynamicRouteParams: setToUnionType(dynamicRouteTemplates),\n });\n}\n\n/**\n * Utility functions for typed routes\n *\n * These are extracted for easier testing\n */\nexport function getTypedRoutesUtils(appRoot: string, filePathSeperator = path.sep) {\n /*\n * staticRoutes are a map where the key if the route without groups and the value\n * is another set of all group versions of the route. e.g,\n * Map([\n * [\"/\", [\"/(app)/(notes)\", \"/(app)/(profile)\"]\n * ])\n */\n const staticRoutes = new Map<string, Set<string>>([['/', new Set('/')]]);\n /*\n * dynamicRoutes are the same as staticRoutes (key if the resolved route,\n * and the value is a set of possible routes). e.g:\n *\n * /[...fruits] -> /${CatchAllRoutePart<T>}\n * /color/[color] -> /color/${SingleRoutePart<T>}\n *\n * The keys of this map are also important, as they can be used as \"static\" types\n * <Link href={{ pathname: \"/[...fruits]\",params: { fruits: [\"apple\"] } }} />\n */\n const dynamicRoutes = new Map<string, Set<string>>();\n\n function normalizedFilePath(filePath: string) {\n return filePath.replaceAll(filePathSeperator, '/');\n }\n\n const normalizedAppRoot = normalizedFilePath(appRoot);\n\n const filePathToRoute = (filePath: string) => {\n return normalizedFilePath(filePath)\n .replace(normalizedAppRoot, '')\n .replace(/index\\.[jt]sx?/, '')\n .replace(/\\.[jt]sx?$/, '');\n };\n\n const isRouteFile = (filePath: string) => {\n if (filePath.match(TYPED_ROUTES_EXCLUSION_REGEX)) {\n return false;\n }\n\n // Route files must be nested with in the appRoot\n const relative = path.relative(appRoot, filePath);\n return relative && !relative.startsWith('..') && !path.isAbsolute(relative);\n };\n\n const addFilePath = (filePath: string): boolean => {\n if (!isRouteFile(filePath)) {\n return false;\n }\n\n const route = filePathToRoute(filePath);\n\n // We have already processed this file\n if (staticRoutes.has(route) || dynamicRoutes.has(route)) {\n return false;\n }\n\n const dynamicParams = new Set(\n [...route.matchAll(CAPTURE_DYNAMIC_PARAMS)].map((match) => match[1])\n );\n const isDynamic = dynamicParams.size > 0;\n\n const addRoute = (originalRoute: string, route: string) => {\n if (isDynamic) {\n let set = dynamicRoutes.get(originalRoute);\n\n if (!set) {\n set = new Set();\n dynamicRoutes.set(originalRoute, set);\n }\n\n set.add(\n route\n .replaceAll(CATCH_ALL, '${CatchAllRoutePart<T>}')\n .replaceAll(SLUG, '${SingleRoutePart<T>}')\n );\n } else {\n let set = staticRoutes.get(originalRoute);\n\n if (!set) {\n set = new Set();\n staticRoutes.set(originalRoute, set);\n }\n\n set.add(route);\n }\n };\n\n if (!route.match(ARRAY_GROUP_REGEX)) {\n addRoute(route, route);\n }\n\n // Does this route have a group? eg /(group)\n if (route.includes('/(')) {\n const routeWithoutGroups = route.replace(/\\/\\(.+?\\)/g, '');\n addRoute(route, routeWithoutGroups);\n\n // If there are multiple groups, we need to expand them\n // eg /(test1,test2)/page => /test1/page & /test2/page\n for (const routeWithSingleGroup of extrapolateGroupRoutes(route)) {\n addRoute(route, routeWithSingleGroup);\n }\n }\n\n return true;\n };\n\n return {\n staticRoutes,\n dynamicRoutes,\n filePathToRoute,\n addFilePath,\n isRouteFile,\n };\n}\n\nexport const setToUnionType = <T>(set: Set<T>) => {\n return set.size > 0 ? [...set].map((s) => `\\`${s}\\``).join(' | ') : 'never';\n};\n\n/**\n * Recursively walk a directory and call the callback with the file path.\n */\nasync function walk(directory: string, callback: (filePath: string) => void) {\n const files = await fs.readdir(directory);\n for (const file of files) {\n const p = path.join(directory, file);\n if ((await fs.stat(p)).isDirectory()) {\n await walk(p, callback);\n } else {\n // Normalise the paths so they are easier to convert to URLs\n const normalizedPath = p.replaceAll(path.sep, '/');\n callback(normalizedPath);\n }\n }\n}\n\n/**\n * Given a route, return all possible routes that could be generated from it.\n */\nexport function extrapolateGroupRoutes(\n route: string,\n routes: Set<string> = new Set()\n): Set<string> {\n // Create a version with no groups. We will then need to cleanup double and/or trailing slashes\n routes.add(route.replaceAll(ARRAY_GROUP_REGEX, '').replaceAll(/\\/+/g, '/').replace(/\\/$/, ''));\n\n const match = route.match(ARRAY_GROUP_REGEX);\n\n if (!match) {\n routes.add(route);\n return routes;\n }\n\n const groupsMatch = match[0];\n\n for (const group of groupsMatch.matchAll(CAPTURE_GROUP_REGEX)) {\n extrapolateGroupRoutes(route.replace(groupsMatch, `(${group[1].trim()})`), routes);\n }\n\n return routes;\n}\n\n/**\n * NOTE: This code refers to a specific version of `expo-router` and is therefore unsafe to\n * mix with arbitrary versions.\n * TODO: Version this code with `expo-router` or version expo-router with `@expo/cli`.\n */\nconst routerDotTSTemplate = unsafeTemplate`/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable import/export */\n/* eslint-disable @typescript-eslint/ban-types */\ndeclare module \"expo-router\" {\n import type { LinkProps as OriginalLinkProps } from 'expo-router/build/link/Link';\n import type { Router as OriginalRouter } from 'expo-router/build/types';\n export * from 'expo-router/build';\n\n // prettier-ignore\n type StaticRoutes = ${'staticRoutes'};\n // prettier-ignore\n type DynamicRoutes<T extends string> = ${'dynamicRoutes'};\n // prettier-ignore\n type DynamicRouteTemplate = ${'dynamicRouteParams'};\n\n type RelativePathString = \\`./\\${string}\\` | \\`../\\${string}\\` | '..';\n type AbsoluteRoute = DynamicRouteTemplate | StaticRoutes;\n type ExternalPathString = \\`\\${string}:\\${string}\\`;\n\n type ExpoRouterRoutes = DynamicRouteTemplate | StaticRoutes | RelativePathString;\n export type AllRoutes = ExpoRouterRoutes | ExternalPathString;\n\n /****************\n * Route Utils *\n ****************/\n\n type SearchOrHash = \\`?\\${string}\\` | \\`#\\${string}\\`;\n type UnknownInputParams = Record<string, string | number | (string | number)[]>;\n type UnknownOutputParams = Record<string, string | string[]>;\n\n /**\n * Return only the RoutePart of a string. If the string has multiple parts return never\n *\n * string | type\n * ---------|------\n * 123 | 123\n * /123/abc | never\n * 123?abc | never\n * ./123 | never\n * /123 | never\n * 123/../ | never\n */\n type SingleRoutePart<S extends string> = S extends \\`\\${string}/\\${string}\\`\n ? never\n : S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S extends \\`(\\${string})\\`\n ? never\n : S extends \\`[\\${string}]\\`\n ? never\n : S;\n\n /**\n * Return only the CatchAll router part. If the string has search parameters or a hash return never\n */\n type CatchAllRoutePart<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S extends \\`\\${string}(\\${string})\\${string}\\`\n ? never\n : S extends \\`\\${string}[\\${string}]\\${string}\\`\n ? never\n : S;\n\n // type OptionalCatchAllRoutePart<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\` ? never : S\n\n /**\n * Return the name of a route parameter\n * '[test]' -> 'test'\n * 'test' -> never\n * '[...test]' -> '...test'\n */\n type IsParameter<Part> = Part extends \\`[\\${infer ParamName}]\\` ? ParamName : never;\n\n /**\n * Return a union of all parameter names. If there are no names return never\n *\n * /[test] -> 'test'\n * /[abc]/[...def] -> 'abc'|'...def'\n */\n type ParameterNames<Path> = Path extends \\`\\${infer PartA}/\\${infer PartB}\\`\n ? IsParameter<PartA> | ParameterNames<PartB>\n : IsParameter<Path>;\n\n /**\n * Returns all segements of a route.\n *\n * /(group)/123/abc/[id]/[...rest] -> ['(group)', '123', 'abc', '[id]', '[...rest]'\n */\n type RouteSegments<Path> = Path extends \\`\\${infer PartA}/\\${infer PartB}\\`\n ? PartA extends '' | '.'\n ? [...RouteSegments<PartB>]\n : [PartA, ...RouteSegments<PartB>]\n : Path extends ''\n ? []\n : [Path];\n\n /**\n * Returns a Record of the routes parameters as strings and CatchAll parameters\n *\n * There are two versions, input and output, as you can input 'string | number' but\n * the output will always be 'string'\n *\n * /[id]/[...rest] -> { id: string, rest: string[] }\n * /no-params -> {}\n */\n type InputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends \\`...\\${infer Name}\\`\n ? Name\n : Key]: Key extends \\`...\\${string}\\` ? (string | number)[] : string | number;\n } & UnknownInputParams;\n\n type OutputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends \\`...\\${infer Name}\\`\n ? Name\n : Key]: Key extends \\`...\\${string}\\` ? string[] : string;\n } & UnknownOutputParams;\n\n /**\n * Returns the search parameters for a route.\n */\n export type SearchParams<T extends AllRoutes> = T extends DynamicRouteTemplate\n ? OutputRouteParams<T>\n : T extends StaticRoutes\n ? never\n : UnknownOutputParams;\n\n /**\n * Route is mostly used as part of Href to ensure that a valid route is provided\n *\n * Given a dynamic route, this will return never. This is helpful for conditional logic\n *\n * /test -> /test, /test2, etc\n * /test/[abc] -> never\n * /test/resolve -> /test, /test2, etc\n *\n * Note that if we provide a value for [abc] then the route is allowed\n *\n * This is named Route to prevent confusion, as users they will often see it in tooltips\n */\n export type Route<T> = T extends string\n ? T extends DynamicRouteTemplate\n ? never\n :\n | StaticRoutes\n | RelativePathString\n | ExternalPathString\n | (T extends \\`\\${infer P}\\${SearchOrHash}\\`\n ? P extends DynamicRoutes<infer _>\n ? T\n : never\n : T extends DynamicRoutes<infer _>\n ? T\n : never)\n : never;\n\n /*********\n * Href *\n *********/\n\n export type Href<T> = T extends Record<'pathname', string> ? HrefObject<T> : Route<T>;\n\n export type HrefObject<\n R extends Record<'pathname', string>,\n P = R['pathname'],\n > = P extends DynamicRouteTemplate\n ? { pathname: P; params: InputRouteParams<P> }\n : P extends Route<P>\n ? { pathname: Route<P> | DynamicRouteTemplate; params?: never | InputRouteParams<never> }\n : never;\n\n /***********************\n * Expo Router Exports *\n ***********************/\n\n export type Router = Omit<OriginalRouter, 'push' | 'replace' | 'setParams'> & {\n /** Navigate to the provided href. */\n push: <T>(href: Href<T>) => void;\n /** Navigate to route without appending to the history. */\n replace: <T>(href: Href<T>) => void;\n /** Update the current route query params. */\n setParams: <T = ''>(params?: T extends '' ? Record<string, string> : InputRouteParams<T>) => void;\n };\n\n /** The imperative router. */\n export const router: Router;\n\n /************\n * <Link /> *\n ************/\n export interface LinkProps<T> extends OriginalLinkProps {\n href: Href<T>;\n }\n\n export interface LinkComponent {\n <T>(props: React.PropsWithChildren<LinkProps<T>>): JSX.Element;\n /** Helper method to resolve an Href object into a string. */\n resolveHref: <T>(href: Href<T>) => string;\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 */\n export const Link: LinkComponent;\n\n /** Redirects to the href as soon as the component is mounted. */\n export const Redirect: <T>(\n props: React.PropsWithChildren<{ href: Href<T> }>\n ) => JSX.Element;\n\n /************\n * Hooks *\n ************/\n export function useRouter(): Router;\n\n export function useLocalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n >(): T extends AllRoutes ? SearchParams<T> : T;\n\n /** @deprecated renamed to \\`useGlobalSearchParams\\` */\n export function useSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n >(): T extends AllRoutes ? SearchParams<T> : T;\n\n export function useGlobalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n >(): T extends AllRoutes ? SearchParams<T> : T;\n\n export function useSegments<\n T extends AbsoluteRoute | RouteSegments<AbsoluteRoute> | RelativePathString,\n >(): T extends AbsoluteRoute ? RouteSegments<T> : T extends string ? string[] : T;\n}\n`;\n"],"names":["CAPTURE_DYNAMIC_PARAMS","CATCH_ALL","SLUG","ARRAY_GROUP_REGEX","CAPTURE_GROUP_REGEX","TYPED_ROUTES_EXCLUSION_REGEX","setupTypedRoutes","getTemplateString","getTypedRoutesUtils","setToUnionType","extrapolateGroupRoutes","options","typedRoutesModule","resolveFrom","silent","projectRoot","typedRoutes","legacyTypedRoutes","typedRoutesModulePath","server","metro","typesDirectory","routerDirectory","plugin","process","env","EXPO_ROUTER_APP_ROOT","require","metroWatchTypeScriptFiles","eventTypes","callback","getWatchHandler","version","regenerateDeclarations","filePathToRoute","staticRoutes","dynamicRoutes","addFilePath","isRouteFile","filePath","type","shouldRegenerate","route","delete","regenerateRouterDotTS","Set","values","flatMap","v","Array","from","keys","directoryExistsAsync","walk","debounce","fn","delay","timeoutId","args","clearTimeout","setTimeout","apply","typesDir","dynamicRouteTemplates","fs","mkdir","recursive","writeFile","path","resolve","routerDotTSTemplate","dynamicRouteParams","appRoot","filePathSeperator","sep","Map","normalizedFilePath","replaceAll","normalizedAppRoot","replace","match","relative","startsWith","isAbsolute","has","dynamicParams","matchAll","map","isDynamic","size","addRoute","originalRoute","set","get","add","includes","routeWithoutGroups","routeWithSingleGroup","s","join","directory","files","readdir","file","p","stat","isDirectory","normalizedPath","routes","groupsMatch","group","trim","unsafeTemplate"],"mappings":"AAAA;;;;;;;;;;;IAWaA,sBAAsB,MAAtBA,sBAAsB;IAEtBC,SAAS,MAATA,SAAS;IAETC,IAAI,MAAJA,IAAI;IAEJC,iBAAiB,MAAjBA,iBAAiB;IAEjBC,mBAAmB,MAAnBA,mBAAmB;IAMnBC,4BAA4B,MAA5BA,4BAA4B;IAYnBC,gBAAgB,MAAhBA,gBAAgB;IAiJtBC,iBAAiB,MAAjBA,iBAAiB;IAiBjBC,mBAAmB,MAAnBA,mBAAmB;IAmHtBC,cAAc,MAAdA,cAAc;IAwBXC,sBAAsB,MAAtBA,sBAAsB;;;8DAlVvB,aAAa;;;;;;;8DAEX,MAAM;;;;;;;8DACC,cAAc;;;;;;qBAED,oBAAoB;0BAC1B,yBAAyB;2CA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;;;;;;;;;;;;;;;;;;;;;;;;AAqOrD,CAAC,AAAC"}
|
package/build/src/utils/dir.js
CHANGED
|
@@ -26,9 +26,9 @@ function _fs() {
|
|
|
26
26
|
};
|
|
27
27
|
return data;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("
|
|
31
|
-
|
|
29
|
+
function _path() {
|
|
30
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
31
|
+
_path = function() {
|
|
32
32
|
return data;
|
|
33
33
|
};
|
|
34
34
|
return data;
|
|
@@ -61,11 +61,36 @@ async function fileExistsAsync(file) {
|
|
|
61
61
|
const ensureDirectoryAsync = (path)=>_fs().default.promises.mkdir(path, {
|
|
62
62
|
recursive: true
|
|
63
63
|
});
|
|
64
|
-
const ensureDirectory = (path)=>
|
|
64
|
+
const ensureDirectory = (path)=>{
|
|
65
|
+
_fs().default.mkdirSync(path, {
|
|
65
66
|
recursive: true
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
68
|
+
};
|
|
69
|
+
const copySync = (src, dest)=>{
|
|
70
|
+
const destParent = _path().default.dirname(dest);
|
|
71
|
+
if (!_fs().default.existsSync(destParent)) ensureDirectory(destParent);
|
|
72
|
+
_fs().default.cpSync(src, dest, {
|
|
73
|
+
recursive: true,
|
|
74
|
+
force: true
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const copyAsync = async (src, dest)=>{
|
|
78
|
+
const destParent = _path().default.dirname(dest);
|
|
79
|
+
if (!_fs().default.existsSync(destParent)) {
|
|
80
|
+
await _fs().default.promises.mkdir(destParent, {
|
|
81
|
+
recursive: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
await _fs().default.promises.cp(src, dest, {
|
|
85
|
+
recursive: true,
|
|
86
|
+
force: true
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const removeAsync = (path)=>{
|
|
90
|
+
return _fs().default.promises.rm(path, {
|
|
91
|
+
recursive: true,
|
|
92
|
+
force: true
|
|
93
|
+
});
|
|
94
|
+
};
|
|
70
95
|
|
|
71
96
|
//# sourceMappingURL=dir.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/dir.ts"],"sourcesContent":["import fs from 'fs';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/dir.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nexport function fileExistsSync(file: string): boolean {\n return !!fs\n .statSync(file, {\n throwIfNoEntry: false,\n })\n ?.isFile();\n}\n\nexport function directoryExistsSync(file: string): boolean {\n return !!fs\n .statSync(file, {\n throwIfNoEntry: false,\n })\n ?.isDirectory();\n}\n\nexport async function directoryExistsAsync(file: string): Promise<boolean> {\n return (await fs.promises.stat(file).catch(() => null))?.isDirectory() ?? false;\n}\n\nexport async function fileExistsAsync(file: string): Promise<boolean> {\n return (await fs.promises.stat(file).catch(() => null))?.isFile() ?? false;\n}\n\nexport const ensureDirectoryAsync = (path: string) => fs.promises.mkdir(path, { recursive: true });\n\nexport const ensureDirectory = (path: string): void => {\n fs.mkdirSync(path, {\n recursive: true,\n });\n};\n\nexport const copySync = (src: string, dest: string): void => {\n const destParent = path.dirname(dest);\n if (!fs.existsSync(destParent)) ensureDirectory(destParent);\n fs.cpSync(src, dest, {\n recursive: true,\n force: true,\n });\n};\n\nexport const copyAsync = async (src: string, dest: string): Promise<void> => {\n const destParent = path.dirname(dest);\n if (!fs.existsSync(destParent)) {\n await fs.promises.mkdir(destParent, { recursive: true });\n }\n await fs.promises.cp(src, dest, {\n recursive: true,\n force: true,\n });\n};\n\nexport const removeAsync = (path: string): Promise<void> => {\n return fs.promises.rm(path, {\n recursive: true,\n force: true,\n });\n};\n"],"names":["fileExistsSync","directoryExistsSync","directoryExistsAsync","fileExistsAsync","ensureDirectoryAsync","ensureDirectory","copySync","copyAsync","removeAsync","file","fs","statSync","throwIfNoEntry","isFile","isDirectory","promises","stat","catch","path","mkdir","recursive","mkdirSync","src","dest","destParent","dirname","existsSync","cpSync","force","cp","rm"],"mappings":"AAAA;;;;;;;;;;;IAGgBA,cAAc,MAAdA,cAAc;IAQdC,mBAAmB,MAAnBA,mBAAmB;IAQbC,oBAAoB,MAApBA,oBAAoB;IAIpBC,eAAe,MAAfA,eAAe;IAIxBC,oBAAoB,MAApBA,oBAAoB;IAEpBC,eAAe,MAAfA,eAAe;IAMfC,QAAQ,MAARA,QAAQ;IASRC,SAAS,MAATA,SAAS;IAWTC,WAAW,MAAXA,WAAW;;;8DAvDT,IAAI;;;;;;;8DACF,MAAM;;;;;;;;;;;AAEhB,SAASR,cAAc,CAACS,IAAY,EAAW;QAC3CC,GAGL;IAHJ,OAAO,CAAC,EAACA,CAAAA,GAGL,GAHKA,GAAE,EAAA,QAAA,CACRC,QAAQ,CAACF,IAAI,EAAE;QACdG,cAAc,EAAE,KAAK;KACtB,CAAC,SACM,GAJDF,KAAAA,CAIC,GAJDA,GAGL,CACAG,MAAM,EAAE,CAAA,CAAC;AACf,CAAC;AAEM,SAASZ,mBAAmB,CAACQ,IAAY,EAAW;QAChDC,GAGL;IAHJ,OAAO,CAAC,EAACA,CAAAA,GAGL,GAHKA,GAAE,EAAA,QAAA,CACRC,QAAQ,CAACF,IAAI,EAAE;QACdG,cAAc,EAAE,KAAK;KACtB,CAAC,SACW,GAJNF,KAAAA,CAIM,GAJNA,GAGL,CACAI,WAAW,EAAE,CAAA,CAAC;AACpB,CAAC;AAEM,eAAeZ,oBAAoB,CAACO,IAAY,EAAoB;QAClE,GAAgD;IAAvD,OAAO,CAAA,CAAA,GAAgD,GAA/C,MAAMC,GAAE,EAAA,QAAA,CAACK,QAAQ,CAACC,IAAI,CAACP,IAAI,CAAC,CAACQ,KAAK,CAAC,IAAM,IAAI,CAAC,SAAc,GAA7D,KAAA,CAA6D,GAA7D,GAAgD,CAAEH,WAAW,EAAE,KAAI,KAAK,CAAC;AAClF,CAAC;AA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Md,GAAE,EAAA,QAAA,CAACK,QAAQ,CAACI,KAAK,CAACK,UAAU,EAAE;YAAEJ,SAAS,EAAE,IAAI;SAAE,CAAC,CAAC;IAC3D,CAAC;IACD,MAAMV,GAAE,EAAA,QAAA,CAACK,QAAQ,CAACc,EAAE,CAACP,GAAG,EAAEC,IAAI,EAAE;QAC9BH,SAAS,EAAE,IAAI;QACfQ,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;AACL,CAAC,AAAC;AAEK,MAAMpB,WAAW,GAAG,CAACU,IAAY,GAAoB;IAC1D,OAAOR,GAAE,EAAA,QAAA,CAACK,QAAQ,CAACe,EAAE,CAACZ,IAAI,EAAE;QAC1BE,SAAS,EAAE,IAAI;QACfQ,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;AACL,CAAC,AAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "encodeMultipartMixed", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>encodeMultipartMixed
|
|
8
|
+
});
|
|
9
|
+
function _nodeCrypto() {
|
|
10
|
+
const data = require("node:crypto");
|
|
11
|
+
_nodeCrypto = function() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
const CRLF = "\r\n";
|
|
17
|
+
const BOUNDARY_HYPHEN_CHARACTERS = "-".repeat(2);
|
|
18
|
+
const getFormHeader = (boundary, field)=>{
|
|
19
|
+
let header = `${BOUNDARY_HYPHEN_CHARACTERS}${boundary}${CRLF}`;
|
|
20
|
+
header += `Content-Disposition: form-data; name="${field.name}"`;
|
|
21
|
+
if (typeof field.value !== "string") {
|
|
22
|
+
header += `; filename="${field.value.name ?? "blob"}"${CRLF}`;
|
|
23
|
+
header += `Content-Type: ${field.value.type || "application/octet-stream"}`;
|
|
24
|
+
} else if (field.contentType) {
|
|
25
|
+
header += `${CRLF}Content-Type: ${field.contentType}`;
|
|
26
|
+
}
|
|
27
|
+
if (field.partHeaders) {
|
|
28
|
+
for(const headerName in field.partHeaders){
|
|
29
|
+
header += `${CRLF}${headerName}: ${field.partHeaders[headerName]}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return `${header}${CRLF}${CRLF}`;
|
|
33
|
+
};
|
|
34
|
+
const getFormFooter = (boundary)=>`${BOUNDARY_HYPHEN_CHARACTERS}${boundary}${BOUNDARY_HYPHEN_CHARACTERS}${CRLF}${CRLF}`;
|
|
35
|
+
async function encodeMultipartMixed(fields) {
|
|
36
|
+
const boundary = `formdata-${(0, _nodeCrypto().randomBytes)(8).toString("hex")}`;
|
|
37
|
+
let body = "";
|
|
38
|
+
for (const field of fields){
|
|
39
|
+
if (typeof field.value !== "string") {
|
|
40
|
+
body += getFormHeader(boundary, field);
|
|
41
|
+
body += await field.value.text();
|
|
42
|
+
body += CRLF;
|
|
43
|
+
} else {
|
|
44
|
+
body += getFormHeader(boundary, field) + field.value + CRLF;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
body += getFormFooter(boundary);
|
|
48
|
+
return {
|
|
49
|
+
boundary,
|
|
50
|
+
body
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=multipartMixed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/multipartMixed.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\n\nexport interface FormDataField {\n name: string;\n value: string | File | Blob;\n contentType?: string | null;\n partHeaders?: Record<string, string> | null;\n}\n\nexport interface EncodedFormData {\n boundary: string;\n body: string;\n}\n\nconst CRLF = '\\r\\n';\nconst BOUNDARY_HYPHEN_CHARACTERS = '-'.repeat(2);\n\nconst getFormHeader = (boundary: string, field: FormDataField): string => {\n let header = `${BOUNDARY_HYPHEN_CHARACTERS}${boundary}${CRLF}`;\n header += `Content-Disposition: form-data; name=\"${field.name}\"`;\n if (typeof field.value !== 'string') {\n header += `; filename=\"${(field.value as File).name ?? 'blob'}\"${CRLF}`;\n header += `Content-Type: ${field.value.type || 'application/octet-stream'}`;\n } else if (field.contentType) {\n header += `${CRLF}Content-Type: ${field.contentType}`;\n }\n if (field.partHeaders) {\n for (const headerName in field.partHeaders) {\n header += `${CRLF}${headerName}: ${field.partHeaders[headerName]}`;\n }\n }\n return `${header}${CRLF}${CRLF}`;\n};\n\nconst getFormFooter = (boundary: string) =>\n `${BOUNDARY_HYPHEN_CHARACTERS}${boundary}${BOUNDARY_HYPHEN_CHARACTERS}${CRLF}${CRLF}`;\n\nexport async function encodeMultipartMixed(fields: FormDataField[]): Promise<EncodedFormData> {\n const boundary = `formdata-${randomBytes(8).toString('hex')}`;\n let body = '';\n for (const field of fields) {\n if (typeof field.value !== 'string') {\n body += getFormHeader(boundary, field);\n body += await field.value.text();\n body += CRLF;\n } else {\n body += getFormHeader(boundary, field) + field.value + CRLF;\n }\n }\n body += getFormFooter(boundary);\n return { boundary, body };\n}\n"],"names":["encodeMultipartMixed","CRLF","BOUNDARY_HYPHEN_CHARACTERS","repeat","getFormHeader","boundary","field","header","name","value","type","contentType","partHeaders","headerName","getFormFooter","fields","randomBytes","toString","body","text"],"mappings":"AAAA;;;;+BAqCsBA,sBAAoB;;aAApBA,oBAAoB;;;yBArCd,aAAa;;;;;;AAczC,MAAMC,IAAI,GAAG,MAAM,AAAC;AACpB,MAAMC,0BAA0B,GAAG,GAAG,CAACC,MAAM,CAAC,CAAC,CAAC,AAAC;AAEjD,MAAMC,aAAa,GAAG,CAACC,QAAgB,EAAEC,KAAoB,GAAa;IACxE,IAAIC,MAAM,GAAG,CAAC,EAAEL,0BAA0B,CAAC,EAAEG,QAAQ,CAAC,EAAEJ,IAAI,CAAC,CAAC,AAAC;IAC/DM,MAAM,IAAI,CAAC,sCAAsC,EAAED,KAAK,CAACE,IAAI,CAAC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AM,CAAE;QAC1B,IAAI,OAAOT,KAAK,CAACG,KAAK,KAAK,QAAQ,EAAE;YACnCS,IAAI,IAAId,aAAa,CAACC,QAAQ,EAAEC,KAAK,CAAC,CAAC;YACvCY,IAAI,IAAI,MAAMZ,KAAK,CAACG,KAAK,CAACU,IAAI,EAAE,CAAC;YACjCD,IAAI,IAAIjB,IAAI,CAAC;QACf,OAAO;YACLiB,IAAI,IAAId,aAAa,CAACC,QAAQ,EAAEC,KAAK,CAAC,GAAGA,KAAK,CAACG,KAAK,GAAGR,IAAI,CAAC;QAC9D,CAAC;IACH,CAAC;IACDiB,IAAI,IAAIJ,aAAa,CAACT,QAAQ,CAAC,CAAC;IAChC,OAAO;QAAEA,QAAQ;QAAEa,IAAI;KAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -31,7 +31,7 @@ class FetchClient {
|
|
|
31
31
|
this.headers = {
|
|
32
32
|
accept: "application/json",
|
|
33
33
|
"content-type": "application/json",
|
|
34
|
-
"user-agent": `expo-cli/${"1.0.0-canary-
|
|
34
|
+
"user-agent": `expo-cli/${"1.0.0-canary-20250303-4dba60e"}`,
|
|
35
35
|
authorization: "Basic " + _nodeBuffer().Buffer.from(`${target}:`).toString("base64")
|
|
36
36
|
};
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "1.0.0-canary-
|
|
3
|
+
"version": "1.0.0-canary-20250303-4dba60e",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -42,28 +42,28 @@
|
|
|
42
42
|
"@0no-co/graphql.web": "^1.0.8",
|
|
43
43
|
"@babel/runtime": "^7.20.0",
|
|
44
44
|
"@expo/code-signing-certificates": "^0.0.5",
|
|
45
|
-
"@expo/config": "11.0.0-canary-
|
|
46
|
-
"@expo/config-plugins": "9.0
|
|
45
|
+
"@expo/config": "11.0.0-canary-20250303-4dba60e",
|
|
46
|
+
"@expo/config-plugins": "9.1.0-canary-20250303-4dba60e",
|
|
47
47
|
"@expo/devcert": "^1.1.2",
|
|
48
|
-
"@expo/env": "1.0.1-canary-
|
|
49
|
-
"@expo/image-utils": "0.6.6-canary-
|
|
50
|
-
"@expo/json-file": "9.0.3-canary-
|
|
51
|
-
"@expo/metro-config": "0.20.0-canary-
|
|
52
|
-
"@expo/osascript": "2.1.7-canary-
|
|
53
|
-
"@expo/package-manager": "1.
|
|
54
|
-
"@expo/plist": "0.2.3-canary-
|
|
55
|
-
"@expo/prebuild-config": "
|
|
48
|
+
"@expo/env": "1.0.1-canary-20250303-4dba60e",
|
|
49
|
+
"@expo/image-utils": "0.6.6-canary-20250303-4dba60e",
|
|
50
|
+
"@expo/json-file": "9.0.3-canary-20250303-4dba60e",
|
|
51
|
+
"@expo/metro-config": "0.20.0-canary-20250303-4dba60e",
|
|
52
|
+
"@expo/osascript": "2.1.7-canary-20250303-4dba60e",
|
|
53
|
+
"@expo/package-manager": "1.6.2-canary-20250303-4dba60e",
|
|
54
|
+
"@expo/plist": "0.2.3-canary-20250303-4dba60e",
|
|
55
|
+
"@expo/prebuild-config": "9.0.0-canary-20250303-4dba60e",
|
|
56
56
|
"@expo/rudder-sdk-node": "^1.1.1",
|
|
57
57
|
"@expo/spawn-async": "^1.7.2",
|
|
58
58
|
"@expo/ws-tunnel": "^1.0.1",
|
|
59
59
|
"@expo/xcpretty": "^4.3.0",
|
|
60
|
-
"@react-native/dev-middleware": "0.
|
|
60
|
+
"@react-native/dev-middleware": "0.78.0",
|
|
61
61
|
"@urql/core": "^5.0.6",
|
|
62
62
|
"@urql/exchange-retry": "^1.3.0",
|
|
63
63
|
"accepts": "^1.3.8",
|
|
64
64
|
"arg": "^5.0.2",
|
|
65
65
|
"better-opn": "~3.0.2",
|
|
66
|
-
"bplist-creator": "0.0
|
|
66
|
+
"bplist-creator": "0.1.0",
|
|
67
67
|
"bplist-parser": "^0.3.1",
|
|
68
68
|
"chalk": "^4.0.0",
|
|
69
69
|
"ci-info": "^3.3.0",
|
|
@@ -71,16 +71,10 @@
|
|
|
71
71
|
"connect": "^3.7.0",
|
|
72
72
|
"debug": "^4.3.4",
|
|
73
73
|
"env-editor": "^0.4.1",
|
|
74
|
-
"fast-glob": "^3.3.2",
|
|
75
|
-
"form-data": "^3.0.1",
|
|
76
74
|
"freeport-async": "^2.0.0",
|
|
77
|
-
"fs-extra": "~8.1.0",
|
|
78
75
|
"getenv": "^1.0.0",
|
|
79
76
|
"glob": "^10.4.2",
|
|
80
77
|
"internal-ip": "6.1.0",
|
|
81
|
-
"is-docker": "^2.0.0",
|
|
82
|
-
"is-wsl": "^2.1.1",
|
|
83
|
-
"lodash.debounce": "^4.0.8",
|
|
84
78
|
"minimatch": "^3.0.4",
|
|
85
79
|
"node-forge": "^1.3.1",
|
|
86
80
|
"npm-package-arg": "^11.0.0",
|
|
@@ -119,7 +113,7 @@
|
|
|
119
113
|
"devDependencies": {
|
|
120
114
|
"@expo/multipart-body-parser": "^1.0.0",
|
|
121
115
|
"@expo/ngrok": "4.1.3",
|
|
122
|
-
"@expo/server": "0.5.2-canary-
|
|
116
|
+
"@expo/server": "0.5.2-canary-20250303-4dba60e",
|
|
123
117
|
"@graphql-codegen/cli": "^2.16.3",
|
|
124
118
|
"@graphql-codegen/typescript": "^2.8.7",
|
|
125
119
|
"@graphql-codegen/typescript-operations": "^2.5.12",
|
|
@@ -133,10 +127,8 @@
|
|
|
133
127
|
"@types/cross-spawn": "^6.0.6",
|
|
134
128
|
"@types/debug": "^4.1.7",
|
|
135
129
|
"@types/execa": "^0.9.0",
|
|
136
|
-
"@types/form-data": "^2.2.0",
|
|
137
130
|
"@types/getenv": "^1.0.0",
|
|
138
131
|
"@types/klaw-sync": "^6.0.0",
|
|
139
|
-
"@types/lodash.debounce": "^4.0.9",
|
|
140
132
|
"@types/minimatch": "^3.0.5",
|
|
141
133
|
"@types/node": "^18.19.34",
|
|
142
134
|
"@types/npm-package-arg": "^6.1.0",
|
|
@@ -153,7 +145,7 @@
|
|
|
153
145
|
"@types/ws": "^8.5.4",
|
|
154
146
|
"devtools-protocol": "^0.0.1113120",
|
|
155
147
|
"expo-atlas": "^0.4.0",
|
|
156
|
-
"expo-module-scripts": "4.0.5-canary-
|
|
148
|
+
"expo-module-scripts": "4.0.5-canary-20250303-4dba60e",
|
|
157
149
|
"find-process": "^1.4.7",
|
|
158
150
|
"jest-runner-tsd": "^6.0.0",
|
|
159
151
|
"klaw-sync": "^6.0.0",
|
|
@@ -166,5 +158,5 @@
|
|
|
166
158
|
"tree-kill": "^1.2.2",
|
|
167
159
|
"tsd": "^0.28.1"
|
|
168
160
|
},
|
|
169
|
-
"gitHead": "
|
|
161
|
+
"gitHead": "4dba60e10b5d44b453073aa4968e9dbf312dea6c"
|
|
170
162
|
}
|