expo-router 5.0.2-preview.3 → 5.0.2-preview.5
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/ExpoRoot.js +1 -1
- package/build/ExpoRoot.js.map +1 -1
- package/build/Route.js +1 -1
- package/build/Route.js.map +1 -1
- package/build/exports.d.ts +1 -0
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js.map +1 -1
- package/build/fast-refresh.d.ts.map +1 -1
- package/build/fast-refresh.js +1 -0
- package/build/fast-refresh.js.map +1 -1
- package/build/fork/getStateFromPath.js +1 -0
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/global-state/router-store.d.ts +14 -14
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +1 -1
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +6 -6
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +1 -0
- package/build/global-state/routing.js.map +1 -1
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/hooks.js +1 -1
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/DrawerClient.js +1 -1
- package/build/layouts/DrawerClient.js.map +1 -1
- package/build/layouts/StackClient.js +1 -1
- package/build/layouts/StackClient.js.map +1 -1
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/TabsClient.js +2 -1
- package/build/layouts/TabsClient.js.map +1 -1
- package/build/link/Link.js +1 -1
- package/build/link/Link.js.map +1 -1
- package/build/link/useDomComponentNavigation.d.ts +1 -1
- package/build/link/useDomComponentNavigation.d.ts.map +1 -1
- package/build/link/useDomComponentNavigation.js.map +1 -1
- package/build/link/useLinkHooks.d.ts +3 -4
- package/build/link/useLinkHooks.d.ts.map +1 -1
- package/build/link/useLinkHooks.js.map +1 -1
- package/build/routes-manifest.js +1 -1
- package/build/routes-manifest.js.map +1 -1
- package/build/rsc/entry.js +7 -1
- package/build/rsc/entry.js.map +1 -1
- package/build/rsc/middleware.js +1 -1
- package/build/rsc/middleware.js.map +1 -1
- package/build/rsc/router/client.js +10 -1
- package/build/rsc/router/client.js.map +1 -1
- package/build/rsc/router/host.d.ts.map +1 -1
- package/build/rsc/router/host.js +10 -1
- package/build/rsc/router/host.js.map +1 -1
- package/build/rsc/rsc-renderer.d.ts.map +1 -1
- package/build/rsc/rsc-renderer.js.map +1 -1
- package/build/static/getRootComponent.js +1 -1
- package/build/static/getRootComponent.js.map +1 -1
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +1 -0
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/mocks.d.ts +1 -0
- package/build/testing-library/mocks.js +2 -0
- package/build/testing-library/mocks.js.map +1 -1
- package/build/ts-declarations/expo-router-internal-globals.d.ts +9 -0
- package/build/ts-declarations/expo-router-internal-globals.d.ts.map +1 -0
- package/build/ts-declarations/expo-router-internal-globals.js +4 -0
- package/build/ts-declarations/expo-router-internal-globals.js.map +1 -0
- package/build/typed-routes/index.d.ts +6 -2
- package/build/typed-routes/index.d.ts.map +1 -1
- package/build/typed-routes/index.js +3 -1
- package/build/typed-routes/index.js.map +1 -1
- package/build/useFocusEffect.js +1 -1
- package/build/useFocusEffect.js.map +1 -1
- package/build/useNavigation.js +1 -1
- package/build/useNavigation.js.map +1 -1
- package/build/useScreens.d.ts +2 -2
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +1 -1
- package/build/useScreens.js.map +1 -1
- package/build/views/EmptyRoute.js +1 -1
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.js +1 -1
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +1 -1
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Screen.js +1 -1
- package/build/views/Screen.js.map +1 -1
- package/build/views/Sitemap.js +1 -1
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/Splash.js +1 -1
- package/build/views/Splash.js.map +1 -1
- package/build/views/Toast.js +2 -2
- package/build/views/Toast.js.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/build/views/Unmatched.js +1 -1
- package/build/views/Unmatched.js.map +1 -1
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-renderer.js","sourceRoot":"","sources":["../../src/rsc/rsc-renderer.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAiDH,8BAwKC;AAvND,kEAAkE;AAElE,iGAAiG;AACjG,2CAAyC;AAGzC,4DAAsF;AAEtF,iCAA2C;AAC3C,0CAAgD;AAChD,qCAAgF;AAqCzE,KAAK,UAAU,SAAS,CAAC,IAAmB,EAAE,IAAmB;IACtE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5D,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE7C,MAAM,EACJ,OAAO,EAAE,EAAE,aAAa,EAAE;IAC1B,mBAAmB;IACnB,WAAW,GACZ,GAAG,OAAgF,CAAC;IAErF,SAAS,cAAc,CAAC,QAAiB,EAAE,SAAiB;QAC1D,MAAM;QACJ,+GAA+G;QAC/G,IAAI;QACJ,gDAAgD;QAChD,0EAA0E;QAC1E,IAAI,GAAG,EAAE,EACV,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;QAE7C,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,wBAAiB,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE7E,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,EAAE,EAAE,QAAQ;YACZ,MAAM,EAAE;gBACN,uFAAuF;gBACvF,+HAA+H;gBAC/H,QAAQ,GAAG,QAAQ;aACpB;YACD,IAAI;YACJ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AM,CAAC,IAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,MAAM,CAAC,IAAK,EAAE,OAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,KAAK,EAAE,MAAsB,EAAmB,EAAE;IACvE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,MAAyC,CAAC;IAC9C,GAAG,CAAC;QACF,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC7C,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;IACvB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 dai-shi.\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 * From waku https://github.com/dai-shi/waku/blob/32d52242c1450b5f5965860e671ff73c42da8bd0/packages/waku/src/lib/renderers/rsc-renderer.ts\n */\n\n// This file must remain platform agnostic for production exports.\n\n// Import the runtime to support polyfills for webpack to load modules in the server using Metro.\nimport '@expo/metro-runtime/rsc/runtime';\n\nimport type { ReactNode } from 'react';\nimport { renderToReadableStream, decodeReply } from 'react-server-dom-webpack/server';\n\nimport { fileURLToFilePath } from './path';\nimport { decodeActionId } from './router/utils';\nimport { runWithRenderStore, type EntriesDev, type EntriesPrd } from './server';\n\nexport interface RenderContext<T = unknown> {\n rerender: (input: string, searchParams?: URLSearchParams) => void;\n context: T;\n}\n\ntype ResolvedConfig = any;\n\nexport type RenderRscArgs = {\n // TODO:\n config: ResolvedConfig;\n\n // Done\n input: string;\n context: Record<string, unknown> | undefined;\n body?: ReadableStream | undefined;\n contentType?: string | undefined;\n decodedBody?: unknown;\n moduleIdCallback?: (module: {\n id: string;\n chunks: string[];\n name: string;\n async: boolean;\n }) => void;\n onError?: (err: unknown) => void;\n};\n\ntype ResolveClientEntry = (id: string, server: boolean) => { id: string; chunks: string[] };\n\ntype RenderRscOpts = {\n isExporting: boolean;\n entries: EntriesDev;\n resolveClientEntry: ResolveClientEntry;\n loadServerModuleRsc: (url: string) => Promise<any>;\n};\n\nexport async function renderRsc(args: RenderRscArgs, opts: RenderRscOpts): Promise<ReadableStream> {\n const { input, body, contentType, context, onError } = args;\n const { resolveClientEntry, entries } = opts;\n\n const {\n default: { renderEntries },\n // @ts-expect-error\n buildConfig,\n } = entries as (EntriesDev & { loadModule: never; buildConfig: never }) | EntriesPrd;\n\n function resolveRequest(isServer: boolean, encodedId: string) {\n const [\n // File is the on-disk location of the module, this is injected during the \"use client\" transformation (babel).\n file,\n // The name of the import (e.g. \"default\" or \"\")\n // This will be empty when using `module.exports = ` and `require('...')`.\n name = '',\n ] = encodedId.split('#') as [string, string];\n\n const filePath = file.startsWith('file://') ? fileURLToFilePath(file) : file;\n\n args.moduleIdCallback?.({\n id: filePath,\n chunks: [\n // TODO: Add a lookup later which reads from the SSR manifest to get the correct chunk.\n // NOTE(EvanBacon): This is a placeholder since we need to render RSC to get the client boundaries, which we then inject later.\n 'chunk:' + filePath,\n ],\n name,\n async: true,\n });\n // We'll augment the file path with the incoming RSC request which will forward the metro props required to make a cache hit, e.g. platform=web&...\n // This is similar to how we handle lazy bundling.\n const resolved = resolveClientEntry(filePath, isServer);\n return { id: resolved.id, chunks: resolved.chunks, name, async: true };\n }\n\n const bundlerConfig = new Proxy(\n {},\n {\n get(_target, encodedId: string) {\n return resolveRequest(false, encodedId);\n },\n }\n );\n\n const serverConfig = new Proxy(\n {},\n {\n get(_target, encodedId: string) {\n return resolveRequest(true, encodedId);\n },\n }\n );\n\n // @ts-ignore: Not part of global types. This is added to support server actions loading more actions.\n global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`] = opts.loadServerModuleRsc;\n\n const renderWithContext = async (\n context: Record<string, unknown> | undefined,\n input: string,\n params: unknown\n ) => {\n const renderStore = {\n context: context || {},\n rerender: () => {\n throw new Error('Cannot rerender');\n },\n };\n return runWithRenderStore(renderStore, async () => {\n const elements = await renderEntries(input, {\n params,\n buildConfig,\n });\n if (elements === null) {\n const err = new Error('No function component found at: ' + input);\n (err as any).statusCode = 404;\n throw err;\n }\n if (Object.keys(elements).some((key) => key.startsWith('_'))) {\n throw new Error('\"_\" prefix is reserved');\n }\n return renderToReadableStream(elements, bundlerConfig, {\n onError,\n });\n });\n };\n\n const renderWithContextWithAction = async (\n context: Record<string, unknown> | undefined,\n actionFn: (...args: unknown[]) => unknown,\n actionArgs: unknown[]\n ) => {\n let elementsPromise: Promise<Record<string, ReactNode>> = Promise.resolve({});\n let rendered = false;\n const renderStore = {\n context: context || {},\n rerender: async (input: string, params?: unknown) => {\n if (rendered) {\n throw new Error('already rendered');\n }\n elementsPromise = Promise.all([\n elementsPromise,\n renderEntries(input, { params, buildConfig }),\n ]).then(([oldElements, newElements]) => ({\n ...oldElements,\n // FIXME we should actually check if newElements is null and send an error\n ...newElements,\n }));\n },\n };\n return runWithRenderStore(renderStore, async () => {\n const actionValue = await actionFn(...actionArgs);\n const elements = await elementsPromise;\n rendered = true;\n if (Object.keys(elements).some((key) => key.startsWith('_'))) {\n throw new Error('\"_\" prefix is reserved');\n }\n return renderToReadableStream({ ...elements, _value: actionValue }, bundlerConfig, {\n onError,\n });\n });\n };\n\n let decodedBody: unknown | undefined = args.decodedBody;\n if (body) {\n const bodyStr = await streamToString(body);\n if (typeof contentType === 'string' && contentType.startsWith('multipart/form-data')) {\n // XXX This doesn't support streaming unlike busboy\n const formData = parseFormData(bodyStr, contentType);\n decodedBody = await decodeReply(formData, serverConfig);\n } else if (bodyStr) {\n decodedBody = await decodeReply(bodyStr, serverConfig);\n }\n }\n\n const actionId = decodeActionId(input);\n if (actionId) {\n if (\n !opts.isExporting &&\n // @ts-ignore\n !process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS\n ) {\n throw new Error('Experimental support for React Server Functions is not enabled');\n }\n\n const args = Array.isArray(decodedBody) ? decodedBody : [];\n\n const chunkInfo = serverConfig[actionId];\n\n // Load module into memory.\n await Promise.all(chunkInfo.chunks.map((chunk) => globalThis.__webpack_chunk_load__(chunk)));\n\n // Import module.\n const mod: any = globalThis.__webpack_require__(chunkInfo.id);\n const fn = chunkInfo.name === '*' ? chunkInfo.name : mod[chunkInfo.name] || mod;\n\n if (!fn) {\n throw new Error(\n `Could not find server action: ${actionId}. Module: ${JSON.stringify(chunkInfo, null, 2)}`\n );\n }\n\n return renderWithContextWithAction(context, fn, args);\n }\n\n // method === 'GET'\n return renderWithContext(context, input, decodedBody);\n}\n\n// TODO is this correct? better to use a library?\nconst parseFormData = (body: string, contentType: string) => {\n const boundary = contentType.split('boundary=')[1];\n const parts = body.split(`--${boundary}`);\n const formData = new FormData();\n for (const part of parts) {\n if (part.trim() === '' || part === '--') continue;\n const [rawHeaders, content] = part.split('\\r\\n\\r\\n', 2);\n const headers = rawHeaders!.split('\\r\\n').reduce(\n (acc, currentHeader) => {\n const [key, value] = currentHeader.split(': ');\n acc[key!.toLowerCase()] = value!;\n return acc;\n },\n {} as Record<string, string>\n );\n const contentDisposition = headers['content-disposition'];\n const nameMatch = /name=\"([^\"]+)\"/.exec(contentDisposition!);\n const filenameMatch = /filename=\"([^\"]+)\"/.exec(contentDisposition!);\n if (nameMatch) {\n const name = nameMatch[1];\n if (filenameMatch) {\n const filename = filenameMatch[1];\n const type = headers['content-type'] || 'application/octet-stream';\n const blob = new Blob([content!], { type });\n formData.append(name!, blob, filename);\n } else {\n formData.append(name!, content!.trim());\n }\n }\n }\n return formData;\n};\n\nconst streamToString = async (stream: ReadableStream): Promise<string> => {\n const decoder = new TextDecoder();\n const reader = stream.getReader();\n const outs: string[] = [];\n let result: ReadableStreamReadResult<unknown>;\n do {\n result = await reader.read();\n if (result.value) {\n if (!(result.value instanceof Uint8Array)) {\n throw new Error('Unexepected buffer type');\n }\n outs.push(decoder.decode(result.value, { stream: true }));\n }\n } while (!result.done);\n outs.push(decoder.decode());\n return outs.join('');\n};\n"]}
|
|
1
|
+
{"version":3,"file":"rsc-renderer.js","sourceRoot":"","sources":["../../src/rsc/rsc-renderer.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAsDH,8BAwKC;AA5ND,kEAAkE;AAElE,iGAAiG;AACjG,2CAAyC;AAGzC,4DAAsF;AAEtF,iCAA2C;AAC3C,0CAAgD;AAChD,qCAAgF;AA0CzE,KAAK,UAAU,SAAS,CAAC,IAAmB,EAAE,IAAmB;IACtE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5D,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE7C,MAAM,EACJ,OAAO,EAAE,EAAE,aAAa,EAAE;IAC1B,mBAAmB;IACnB,WAAW,GACZ,GAAG,OAAgF,CAAC;IAErF,SAAS,cAAc,CAAC,QAAiB,EAAE,SAAiB;QAC1D,MAAM;QACJ,+GAA+G;QAC/G,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I,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;IACvB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 dai-shi.\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 * From waku https://github.com/dai-shi/waku/blob/32d52242c1450b5f5965860e671ff73c42da8bd0/packages/waku/src/lib/renderers/rsc-renderer.ts\n */\n\n// This file must remain platform agnostic for production exports.\n\n// Import the runtime to support polyfills for webpack to load modules in the server using Metro.\nimport '@expo/metro-runtime/rsc/runtime';\n\nimport type { ReactNode } from 'react';\nimport { renderToReadableStream, decodeReply } from 'react-server-dom-webpack/server';\n\nimport { fileURLToFilePath } from './path';\nimport { decodeActionId } from './router/utils';\nimport { runWithRenderStore, type EntriesDev, type EntriesPrd } from './server';\n\ndeclare namespace globalThis {\n function __webpack_chunk_load__(id: string): Promise<unknown>;\n function __webpack_require__(id: string): any;\n}\n\nexport interface RenderContext<T = unknown> {\n rerender: (input: string, searchParams?: URLSearchParams) => void;\n context: T;\n}\n\ntype ResolvedConfig = any;\n\nexport type RenderRscArgs = {\n // TODO:\n config: ResolvedConfig;\n\n // Done\n input: string;\n context: Record<string, unknown> | undefined;\n body?: ReadableStream | undefined;\n contentType?: string | undefined;\n decodedBody?: unknown;\n moduleIdCallback?: (module: {\n id: string;\n chunks: string[];\n name: string;\n async: boolean;\n }) => void;\n onError?: (err: unknown) => void;\n};\n\ntype ResolveClientEntry = (id: string, server: boolean) => { id: string; chunks: string[] };\n\ntype RenderRscOpts = {\n isExporting: boolean;\n entries: EntriesDev;\n resolveClientEntry: ResolveClientEntry;\n loadServerModuleRsc: (url: string) => Promise<any>;\n};\n\nexport async function renderRsc(args: RenderRscArgs, opts: RenderRscOpts): Promise<ReadableStream> {\n const { input, body, contentType, context, onError } = args;\n const { resolveClientEntry, entries } = opts;\n\n const {\n default: { renderEntries },\n // @ts-expect-error\n buildConfig,\n } = entries as (EntriesDev & { loadModule: never; buildConfig: never }) | EntriesPrd;\n\n function resolveRequest(isServer: boolean, encodedId: string) {\n const [\n // File is the on-disk location of the module, this is injected during the \"use client\" transformation (babel).\n file,\n // The name of the import (e.g. \"default\" or \"\")\n // This will be empty when using `module.exports = ` and `require('...')`.\n name = '',\n ] = encodedId.split('#') as [string, string];\n\n const filePath = file.startsWith('file://') ? fileURLToFilePath(file) : file;\n\n args.moduleIdCallback?.({\n id: filePath,\n chunks: [\n // TODO: Add a lookup later which reads from the SSR manifest to get the correct chunk.\n // NOTE(EvanBacon): This is a placeholder since we need to render RSC to get the client boundaries, which we then inject later.\n 'chunk:' + filePath,\n ],\n name,\n async: true,\n });\n // We'll augment the file path with the incoming RSC request which will forward the metro props required to make a cache hit, e.g. platform=web&...\n // This is similar to how we handle lazy bundling.\n const resolved = resolveClientEntry(filePath, isServer);\n return { id: resolved.id, chunks: resolved.chunks, name, async: true };\n }\n\n const bundlerConfig: Record<string, ReturnType<typeof resolveRequest>> = new Proxy(\n {},\n {\n get(_target, encodedId: string) {\n return resolveRequest(false, encodedId);\n },\n }\n );\n\n const serverConfig: Record<string, ReturnType<typeof resolveRequest>> = new Proxy(\n {},\n {\n get(_target, encodedId: string) {\n return resolveRequest(true, encodedId);\n },\n }\n );\n\n // @ts-ignore: Not part of global types. This is added to support server actions loading more actions.\n global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`] = opts.loadServerModuleRsc;\n\n const renderWithContext = async (\n context: Record<string, unknown> | undefined,\n input: string,\n params: unknown\n ) => {\n const renderStore = {\n context: context || {},\n rerender: () => {\n throw new Error('Cannot rerender');\n },\n };\n return runWithRenderStore(renderStore, async () => {\n const elements = await renderEntries(input, {\n params,\n buildConfig,\n });\n if (elements === null) {\n const err = new Error('No function component found at: ' + input);\n (err as any).statusCode = 404;\n throw err;\n }\n if (Object.keys(elements).some((key) => key.startsWith('_'))) {\n throw new Error('\"_\" prefix is reserved');\n }\n return renderToReadableStream(elements, bundlerConfig, {\n onError,\n });\n });\n };\n\n const renderWithContextWithAction = async (\n context: Record<string, unknown> | undefined,\n actionFn: (...args: unknown[]) => unknown,\n actionArgs: unknown[]\n ) => {\n let elementsPromise: Promise<Record<string, ReactNode>> = Promise.resolve({});\n let rendered = false;\n const renderStore = {\n context: context || {},\n rerender: async (input: string, params?: unknown) => {\n if (rendered) {\n throw new Error('already rendered');\n }\n elementsPromise = Promise.all([\n elementsPromise,\n renderEntries(input, { params, buildConfig }),\n ]).then(([oldElements, newElements]) => ({\n ...oldElements,\n // FIXME we should actually check if newElements is null and send an error\n ...newElements,\n }));\n },\n };\n return runWithRenderStore(renderStore, async () => {\n const actionValue = await actionFn(...actionArgs);\n const elements = await elementsPromise;\n rendered = true;\n if (Object.keys(elements).some((key) => key.startsWith('_'))) {\n throw new Error('\"_\" prefix is reserved');\n }\n return renderToReadableStream({ ...elements, _value: actionValue }, bundlerConfig, {\n onError,\n });\n });\n };\n\n let decodedBody: unknown | undefined = args.decodedBody;\n if (body) {\n const bodyStr = await streamToString(body);\n if (typeof contentType === 'string' && contentType.startsWith('multipart/form-data')) {\n // XXX This doesn't support streaming unlike busboy\n const formData = parseFormData(bodyStr, contentType);\n decodedBody = await decodeReply(formData, serverConfig);\n } else if (bodyStr) {\n decodedBody = await decodeReply(bodyStr, serverConfig);\n }\n }\n\n const actionId = decodeActionId(input);\n if (actionId) {\n if (\n !opts.isExporting &&\n // @ts-ignore\n !process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS\n ) {\n throw new Error('Experimental support for React Server Functions is not enabled');\n }\n\n const args = Array.isArray(decodedBody) ? decodedBody : [];\n\n const chunkInfo = serverConfig[actionId];\n\n // Load module into memory.\n await Promise.all(chunkInfo.chunks.map((chunk) => globalThis.__webpack_chunk_load__(chunk)));\n\n // Import module.\n const mod: any = globalThis.__webpack_require__(chunkInfo.id);\n const fn = chunkInfo.name === '*' ? chunkInfo.name : mod[chunkInfo.name] || mod;\n\n if (!fn) {\n throw new Error(\n `Could not find server action: ${actionId}. Module: ${JSON.stringify(chunkInfo, null, 2)}`\n );\n }\n\n return renderWithContextWithAction(context, fn, args);\n }\n\n // method === 'GET'\n return renderWithContext(context, input, decodedBody);\n}\n\n// TODO is this correct? better to use a library?\nconst parseFormData = (body: string, contentType: string) => {\n const boundary = contentType.split('boundary=')[1];\n const parts = body.split(`--${boundary}`);\n const formData = new FormData();\n for (const part of parts) {\n if (part.trim() === '' || part === '--') continue;\n const [rawHeaders, content] = part.split('\\r\\n\\r\\n', 2);\n const headers = rawHeaders!.split('\\r\\n').reduce(\n (acc, currentHeader) => {\n const [key, value] = currentHeader.split(': ');\n acc[key!.toLowerCase()] = value!;\n return acc;\n },\n {} as Record<string, string>\n );\n const contentDisposition = headers['content-disposition'];\n const nameMatch = /name=\"([^\"]+)\"/.exec(contentDisposition!);\n const filenameMatch = /filename=\"([^\"]+)\"/.exec(contentDisposition!);\n if (nameMatch) {\n const name = nameMatch[1];\n if (filenameMatch) {\n const filename = filenameMatch[1];\n const type = headers['content-type'] || 'application/octet-stream';\n const blob = new Blob([content!], { type });\n formData.append(name!, blob, filename);\n } else {\n formData.append(name!, content!.trim());\n }\n }\n }\n return formData;\n};\n\nconst streamToString = async (stream: ReadableStream): Promise<string> => {\n const decoder = new TextDecoder();\n const reader = stream.getReader();\n const outs: string[] = [];\n let result: ReadableStreamReadResult<unknown>;\n do {\n result = await reader.read();\n if (result.value) {\n if (!(result.value instanceof Uint8Array)) {\n throw new Error('Unexepected buffer type');\n }\n outs.push(decoder.decode(result.value, { stream: true }));\n }\n } while (!result.done);\n outs.push(decoder.decode());\n return outs.join('');\n};\n"]}
|
|
@@ -7,7 +7,7 @@ exports.getRootComponent = getRootComponent;
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
const _ctx_html_1 = require("
|
|
10
|
+
const _ctx_html_1 = require("expo-router/_ctx-html");
|
|
11
11
|
function getRootComponent() {
|
|
12
12
|
const keys = _ctx_html_1.ctx.keys();
|
|
13
13
|
if (!keys.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRootComponent.js","sourceRoot":"","sources":["../../src/static/getRootComponent.ts"],"names":[],"mappings":";;AAQA,4CAeC;AAvBD;;;;;GAKG;AACH
|
|
1
|
+
{"version":3,"file":"getRootComponent.js","sourceRoot":"","sources":["../../src/static/getRootComponent.ts"],"names":[],"mappings":";;AAQA,4CAeC;AAvBD;;;;;GAKG;AACH,qDAA2D;AAE3D,SAAgB,gBAAgB;IAC9B,MAAM,IAAI,GAAG,eAAW,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAQ,OAAO,CAAC,QAAQ,CAA6B,CAAC,IAAI,CAAC;IAC7D,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,oDAAoD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM,GAAG,GAAG,IAAA,eAAW,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,CAAC,CAAC,2CAA2C,CAAC,CAAC;IAChG,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\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 */\nimport { ctx as rootContext } from 'expo-router/_ctx-html';\n\nexport function getRootComponent() {\n const keys = rootContext.keys();\n if (!keys.length) {\n return (require('./html') as typeof import('./html')).Html;\n }\n if (keys.length > 1) {\n throw new Error(`Multiple components match the root HTML element: ${keys.join(', ')}`);\n }\n const exp = rootContext(keys[0]);\n\n if (!exp.default) {\n throw new Error(`The root HTML element \"${keys[0]}\" is missing the required default export.`);\n }\n\n return exp.default;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderStaticContent.d.ts","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderStaticContent.d.ts","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,qBAAqB,CAAC;AA4B7B,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAoDrE;AAmBD,OAAO,EAAE,+BAA+B,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -49,6 +49,7 @@ const native_1 = require("@react-navigation/native");
|
|
|
49
49
|
const Font = __importStar(require("expo-font/build/server"));
|
|
50
50
|
const react_1 = __importDefault(require("react"));
|
|
51
51
|
const server_node_1 = __importDefault(require("react-dom/server.node"));
|
|
52
|
+
// @ts-expect-error: TODO(@kitten): Define this type (seems to differ from react-native)
|
|
52
53
|
const react_native_web_1 = require("react-native-web");
|
|
53
54
|
const getRootComponent_1 = require("./getRootComponent");
|
|
54
55
|
const _ctx_1 = require("../../_ctx");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderStaticContent.js","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"renderStaticContent.js","sourceRoot":"","sources":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EAAE,CAAC;QACzC,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,aAAa;IACb,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7E,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE7E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,8BAA8B;AAC9B,yDAAmF;AAA1E,oIAAA,+BAA+B,OAAA;AAAE,gHAAA,WAAW,OAAA","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\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 */\nimport '@expo/metro-runtime';\n\nimport { ServerContainer, ServerContainerRef } from '@react-navigation/native';\nimport * as Font from 'expo-font/build/server';\nimport React from 'react';\nimport ReactDOMServer from 'react-dom/server.node';\n// @ts-expect-error: TODO(@kitten): Define this type (seems to differ from react-native)\nimport { AppRegistry } from 'react-native-web';\n\nimport { getRootComponent } from './getRootComponent';\nimport { ctx } from '../../_ctx';\nimport { ExpoRoot } from '../ExpoRoot';\nimport { Head } from '../head';\n\nconst debug = require('debug')('expo:router:renderStaticContent');\n\nAppRegistry.registerComponent('App', () => ExpoRoot);\n\nfunction resetReactNavigationContexts() {\n // https://github.com/expo/router/discussions/588\n // https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/elements/src/getNamedContext.tsx#LL3C1-L4C1\n\n // React Navigation is storing providers in a global, this is fine for the first static render\n // but subsequent static renders of Stack or Tabs will cause React to throw a warning. To prevent this warning, we'll reset the globals before rendering.\n const contexts = '__react_navigation__elements_contexts';\n global[contexts] = new Map<string, React.Context<any>>();\n}\n\nexport async function getStaticContent(location: URL): Promise<string> {\n const headContext: { helmet?: any } = {};\n\n const ref = React.createRef<ServerContainerRef>();\n\n const {\n // NOTE: The `element` that's returned adds two extra Views and\n // the seemingly unused `RootTagContext.Provider`.\n element,\n getStyleElement,\n } = AppRegistry.getApplication('App', {\n initialProps: {\n location,\n context: ctx,\n wrapper: ({ children }: React.ComponentProps<any>) => (\n <Root>\n <div id=\"root\">{children}</div>\n </Root>\n ),\n },\n });\n\n const Root = getRootComponent();\n\n // Clear any existing static resources from the global scope to attempt to prevent leaking between pages.\n // This could break if pages are rendered in parallel or if fonts are loaded outside of the React tree\n Font.resetServerContext();\n\n // This MUST be run before `ReactDOMServer.renderToString` to prevent\n // \"Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.\"\n resetReactNavigationContexts();\n\n const html = await ReactDOMServer.renderToString(\n <Head.Provider context={headContext}>\n <ServerContainer ref={ref}>{element}</ServerContainer>\n </Head.Provider>\n );\n\n // Eval the CSS after the HTML is rendered so that the CSS is in the same order\n const css = ReactDOMServer.renderToStaticMarkup(getStyleElement());\n\n let output = mixHeadComponentsWithStaticResults(headContext.helmet, html);\n\n output = output.replace('</head>', `${css}</head>`);\n\n const fonts = Font.getServerResources();\n debug(`Pushing static fonts: (count: ${fonts.length})`, fonts);\n // debug('Push static fonts:', fonts)\n // Inject static fonts loaded with expo-font\n output = output.replace('</head>', `${fonts.join('')}</head>`);\n\n return '<!DOCTYPE html>' + output;\n}\n\nfunction mixHeadComponentsWithStaticResults(helmet: any, html: string) {\n // Head components\n for (const key of ['title', 'priority', 'meta', 'link', 'script', 'style'].reverse()) {\n const result = helmet?.[key]?.toString();\n if (result) {\n html = html.replace('<head>', `<head>${result}`);\n }\n }\n\n // attributes\n html = html.replace('<html ', `<html ${helmet?.htmlAttributes.toString()} `);\n html = html.replace('<body ', `<body ${helmet?.bodyAttributes.toString()} `);\n\n return html;\n}\n\n// Re-export for use in server\nexport { getBuildTimeServerManifestAsync, getManifest } from './getServerManifest';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,IAAI,CAAC;IACH,OAAO,CAAC,4CAA4C,CAAC,CAAC;AACxD,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC;IACH,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACpD,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC;IACH,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACxC,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;YAC3D,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,yCAAyC;YAC7E,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAkC;QAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;QACrC,SAAS,CAAC,IAAY;YACpB,OAAO,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QACD,aAAa;YACX,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,gBAAgB;YACd,OAAO,EAAE,MAAM,KAAI,CAAC,EAAS,CAAC;QAChC,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Optionally enable @testing-library/jest-native/extend-expect. We use this internally for the `toBeOnTheScreen` matcher()\n */\ntry {\n require('@testing-library/jest-native/extend-expect');\n} catch {}\n\ntry {\n require('react-native-gesture-handler/jestSetup');\n} catch {}\n\ntry {\n require('react-native-reanimated');\n jest.mock('react-native-reanimated', () => {\n try {\n const Reanimated = require('react-native-reanimated/mock');\n Reanimated.default.call = () => {}; // Override `call` with a no-op if needed\n return Reanimated;\n } catch {\n return {};\n }\n });\n} catch {}\n\njest.mock('expo-linking', () => {\n const module: typeof import('expo-linking') = {\n ...jest.requireActual('expo-linking'),\n createURL(path: string) {\n return 'yourscheme://' + path;\n },\n resolveScheme() {\n return 'yourscheme';\n },\n addEventListener() {\n return { remove() {} } as any;\n },\n };\n\n return module;\n});\n"]}
|
|
1
|
+
{"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAI,CAAC;IACH,OAAO,CAAC,4CAA4C,CAAC,CAAC;AACxD,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC;IACH,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACpD,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC;IACH,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACxC,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;YAC3D,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,yCAAyC;YAC7E,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAkC;QAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;QACrC,SAAS,CAAC,IAAY;YACpB,OAAO,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QACD,aAAa;YACX,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,gBAAgB;YACd,OAAO,EAAE,MAAM,KAAI,CAAC,EAAS,CAAC;QAChC,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Optionally enable @testing-library/jest-native/extend-expect. We use this internally for the `toBeOnTheScreen` matcher()\n */\ntry {\n require('@testing-library/jest-native/extend-expect');\n} catch {}\n\ntry {\n require('react-native-gesture-handler/jestSetup');\n} catch {}\n\ntry {\n require('react-native-reanimated');\n jest.mock('react-native-reanimated', () => {\n try {\n const Reanimated = require('react-native-reanimated/mock');\n Reanimated.default.call = () => {}; // Override `call` with a no-op if needed\n return Reanimated;\n } catch {\n return {};\n }\n });\n} catch {}\n\njest.mock('expo-linking', () => {\n const module: typeof import('expo-linking') = {\n ...jest.requireActual('expo-linking'),\n createURL(path: string) {\n return 'yourscheme://' + path;\n },\n resolveScheme() {\n return 'yourscheme';\n },\n addEventListener() {\n return { remove() {} } as any;\n },\n };\n\n return module;\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
var __EXPO_RSC_RELOAD_LISTENERS__: undefined | (() => void)[];
|
|
3
|
+
var __EXPO_REFETCH_RSC__: undefined | (() => void);
|
|
4
|
+
var __EXPO_REFETCH_ROUTE__: undefined | (() => void);
|
|
5
|
+
var __EXPO_REFETCH_ROUTE_NO_CACHE__: undefined | (() => void);
|
|
6
|
+
var __expo_platform_header: undefined | string;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=expo-router-internal-globals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expo-router-internal-globals.d.ts","sourceRoot":"","sources":["../../src/ts-declarations/expo-router-internal-globals.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,6BAA6B,EAAE,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAC9D,IAAI,oBAAoB,EAAE,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACnD,IAAI,sBAAsB,EAAE,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACrD,IAAI,+BAA+B,EAAE,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9D,IAAI,sBAAsB,EAAE,SAAS,GAAG,MAAM,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expo-router-internal-globals.js","sourceRoot":"","sources":["../../src/ts-declarations/expo-router-internal-globals.ts"],"names":[],"mappings":";AAAA,2BAA2B","sourcesContent":["/* eslint-disable no-var */\n\ndeclare global {\n var __EXPO_RSC_RELOAD_LISTENERS__: undefined | (() => void)[];\n var __EXPO_REFETCH_RSC__: undefined | (() => void);\n var __EXPO_REFETCH_ROUTE__: undefined | (() => void);\n var __EXPO_REFETCH_ROUTE_NO_CACHE__: undefined | (() => void);\n var __expo_platform_header: undefined | string;\n}\n"]}
|
|
@@ -10,7 +10,9 @@ export declare const version = 52;
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function getWatchHandler(outputDir: string, { ctx, regenerateFn }?: {
|
|
12
12
|
ctx?: RequireContextPonyFill | undefined;
|
|
13
|
-
regenerateFn?: ((
|
|
13
|
+
regenerateFn?: ((outputDir: string, options?: {
|
|
14
|
+
partialTypedGroups?: boolean;
|
|
15
|
+
} | undefined, ctx?: RequireContextPonyFill | undefined) => void) | undefined;
|
|
14
16
|
}): ({ filePath, type }: {
|
|
15
17
|
filePath: string;
|
|
16
18
|
type: string;
|
|
@@ -27,5 +29,7 @@ export declare function getWatchHandler(outputDir: string, { ctx, regenerateFn }
|
|
|
27
29
|
*
|
|
28
30
|
* If you process the types after the ADD, then they will crash as you will have conflicting routes
|
|
29
31
|
*/
|
|
30
|
-
export declare const regenerateDeclarations: (
|
|
32
|
+
export declare const regenerateDeclarations: (outputDir: string, options?: {
|
|
33
|
+
partialTypedGroups?: boolean;
|
|
34
|
+
} | undefined, ctx?: RequireContextPonyFill | undefined) => void;
|
|
31
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/typed-routes/index.ts"],"names":[],"mappings":"AAMA,OAAuB,EACrB,sBAAsB,EACvB,MAAM,6CAA6C,CAAC;AAIrD,YAAY,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAE1F;;;GAGG;AACH,eAAO,MAAM,OAAO,KAAK,CAAC;AAE1B;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,EAAE,GAAgB,EAAE,YAAqC,EAAE;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/typed-routes/index.ts"],"names":[],"mappings":"AAMA,OAAuB,EACrB,sBAAsB,EACvB,MAAM,6CAA6C,CAAC;AAIrD,YAAY,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAE1F;;;GAGG;AACH,eAAO,MAAM,OAAO,KAAK,CAAC;AAE1B;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,EAAE,GAAgB,EAAE,YAAqC,EAAE;;;6BAyDzB,OAAO;gEAqBZ,IAAI;CA9E+B,IAIjC,oBAAoB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,mBAoCtF;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB;yBAGC,OAAO;4DAqBZ,IAAI,AATlC,CAAC"}
|
|
@@ -53,7 +53,9 @@ function getWatchHandler(outputDir, { ctx = defaultCtx, regenerateFn = exports.r
|
|
|
53
53
|
shouldRegenerate = routeFiles.has(relativePath);
|
|
54
54
|
}
|
|
55
55
|
if (shouldRegenerate) {
|
|
56
|
-
regenerateFn(outputDir, ctx)
|
|
56
|
+
// TODO(@kitten): This was altered from `regenerateFn(outputDir, ctx)` which, as per the types, is incorrect
|
|
57
|
+
// It's unclear whether fixing this will have other unintended consequences!
|
|
58
|
+
regenerateFn(outputDir, {}, ctx);
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/typed-routes/index.ts"],"names":[],"mappings":";;;;;;AAuBA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/typed-routes/index.ts"],"names":[],"mappings":";;;;;;AAuBA,0CA0CC;AAjED,yDAAiE;AACjE,sDAAyB;AACzB,0DAA6B;AAE7B,yCAA2D;AAC3D,0CAA2C;AAC3C,2GAEqD;AAErD,MAAM,UAAU,GAAG,IAAA,kCAAc,EAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,oCAAsB,CAAC,CAAC;AAIlG;;;GAGG;AACU,QAAA,OAAO,GAAG,EAAE,CAAC;AAE1B;;GAEG;AACH,SAAgB,eAAe,CAC7B,SAAiB,EACjB,EAAE,GAAG,GAAG,UAAU,EAAE,YAAY,GAAG,8BAAsB,EAAE,GAAG,EAAE,CAAC,sBAAsB;;IAEvF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE1E,OAAO,KAAK,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAsC;QACnF,qDAAqD;QACrD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB;YAAE,OAAO;QAE9C,I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4C,EAAE,EAC9C,MAA8B,UAAU,EACxC,EAAE;IACF,6FAA6F;IAC7F,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAA,wCAA6B,EAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,iBAAE,CAAC,aAAa,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CACF,CAAC;AAEF;;;GAGG;AACH,SAAS,QAAQ,CACf,EAAK,EACL,UAAkB,IAAI;IAEtB,IAAI,KAAoC,CAAC;IACzC,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;QACjB,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACd,CAAC,EAAE,OAAO,CAAC,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { EXPO_ROUTER_CTX_IGNORE } from 'expo-router/_ctx-shared';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { getTypedRoutesDeclarationFile } from './generate';\nimport { isTypedRoute } from '../matchers';\nimport requireContext, {\n RequireContextPonyFill,\n} from '../testing-library/require-context-ponyfill';\n\nconst defaultCtx = requireContext(process.env.EXPO_ROUTER_APP_ROOT, true, EXPO_ROUTER_CTX_IGNORE);\n\nexport type { RequireContextPonyFill } from '../testing-library/require-context-ponyfill';\n\n/**\n * This file is imported via `@expo/cli`. While users should be using the same SDK version of `expo-router` as `@expo/cli`,\n * this export allows us to ensure that the version of the `expo-router` package is compatible with the version of `@expo/cli`.\n */\nexport const version = 52;\n\n/**\n * Generate a Metro watch handler that regenerates the typed routes declaration file\n */\nexport function getWatchHandler(\n outputDir: string,\n { ctx = defaultCtx, regenerateFn = regenerateDeclarations } = {} // Exposed for testing\n) {\n const routeFiles = new Set(ctx.keys().filter((key) => isTypedRoute(key)));\n\n return async function callback({ filePath, type }: { filePath: string; type: string }) {\n // Sanity check that we are in an Expo Router project\n if (!process.env.EXPO_ROUTER_APP_ROOT) return;\n\n let shouldRegenerate = false;\n let relativePath = path.relative(process.env.EXPO_ROUTER_APP_ROOT, filePath);\n const isInsideAppRoot = !relativePath.startsWith('../');\n const basename = path.basename(relativePath);\n\n if (!isInsideAppRoot) return;\n\n // require.context paths always start with './' when relative to the root\n relativePath = `./${relativePath}`;\n\n if (type === 'delete') {\n ctx.__delete(relativePath);\n if (routeFiles.has(relativePath)) {\n routeFiles.delete(relativePath);\n shouldRegenerate = true;\n }\n } else if (type === 'add') {\n ctx.__add(relativePath);\n if (isTypedRoute(basename)) {\n routeFiles.add(relativePath);\n shouldRegenerate = true;\n }\n } else {\n shouldRegenerate = routeFiles.has(relativePath);\n }\n\n if (shouldRegenerate) {\n // TODO(@kitten): This was altered from `regenerateFn(outputDir, ctx)` which, as per the types, is incorrect\n // It's unclear whether fixing this will have other unintended consequences!\n regenerateFn(outputDir, {}, ctx);\n }\n };\n}\n\n/**\n * Regenerate the declaration file.\n *\n * This function needs to be debounced due to Metro's handling of renaming folders.\n * For example, if you have the file /(tabs)/route.tsx and you rename the folder to /(tabs,test)/route.tsx\n *\n * Metro will fire 2 filesystem events:\n * - ADD /(tabs,test)/router.tsx\n * - DELETE /(tabs)/router.tsx\n *\n * If you process the types after the ADD, then they will crash as you will have conflicting routes\n */\nexport const regenerateDeclarations = debounce(\n (\n outputDir: string,\n options: { partialTypedGroups?: boolean } = {},\n ctx: RequireContextPonyFill = defaultCtx\n ) => {\n // Don't crash the process, just log the error. The user will most likely fix it and continue\n try {\n const file = getTypedRoutesDeclarationFile(ctx, options);\n if (!file) return;\n fs.writeFileSync(path.resolve(outputDir, './router.d.ts'), file);\n } catch (error) {\n console.error(error);\n }\n }\n);\n\n/**\n * Debounce a function to only run once after a period of inactivity\n * If called while waiting, it will reset the timer\n */\nfunction debounce<T extends (...args: any[]) => any>(\n fn: T,\n timeout: number = 1000\n): (...args: Parameters<T>) => void {\n let timer: ReturnType<typeof setTimeout>;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n fn(...args);\n }, timeout);\n };\n}\n"]}
|
package/build/useFocusEffect.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusEffect.js","sourceRoot":"","sources":["../src/useFocusEffect.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"useFocusEffect.js","sourceRoot":"","sources":["../src/useFocusEffect.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Cb,wCAsGC;AAnJD,gFAAgF;AAChF,sEAAsE;AACtE,6CAA+B;AAE/B,oEAAmE;AAOnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,cAAc,CAAC,MAAsB,EAAE,yBAAiC;IACtF,MAAM,UAAU,GAAG,IAAA,2CAAqB,GAAE,CAAC;IAE3C,IAAI,yBAAyB,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,OAAO,GACX,sFAAsF;YACtF,8EAA8E;YAC9E,mBAAmB;YACnB,+BAA+B;YAC/B,yBAAyB;YACzB,sBAAsB;YACtB,QAAQ;YACR,oEAAoE,CAAC;QAEvE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,OAAwC,CAAC;QAE7C,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,MAAM,OAAO,GAAG,MAAM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,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,UAAU,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE;YAC1D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,OAAO,GAAG,SAAS,CAAC;YACpB,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["'use client';\n// A fork of `useFocusEffect` that waits for the navigation state to load before\n// running the effect. This is especially useful for native redirects.\nimport * as React from 'react';\n\nimport { useOptionalNavigation } from './link/useLoadedNavigation';\n\n/**\n * Memoized callback containing the effect, should optionally return a cleanup function.\n */\nexport type EffectCallback = () => undefined | void | (() => void);\n\n/**\n * Hook to run an effect whenever a route is **focused**. Similar to\n * [`React.useEffect`](https://react.dev/reference/react/useEffect).\n *\n * This can be used to perform side-effects such as fetching data or subscribing to events.\n * The passed callback should be wrapped in [`React.useCallback`](https://react.dev/reference/react/useCallback)\n * to avoid running the effect too often.\n *\n * @example\n * ```tsx\n * import { useFocusEffect } from 'expo-router';\n * import { useCallback } from 'react';\n *\n * export default function Route() {\n * useFocusEffect(\n * // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.\n * useCallback(() => {\n * // Invoked whenever the route is focused.\n * console.log('Hello, I'm focused!');\n *\n * // Return function is invoked whenever the route gets out of focus.\n * return () => {\n * console.log('This route is now unfocused.');\n * };\n * }, []);\n * );\n *\n * return </>;\n * }\n *```\n *\n * @param effect Memoized callback containing the effect, should optionally return a cleanup function.\n * @param do_not_pass_a_second_prop\n */\nexport function useFocusEffect(effect: EffectCallback, do_not_pass_a_second_prop?: never) {\n const navigation = useOptionalNavigation();\n\n if (do_not_pass_a_second_prop !== undefined) {\n const message =\n \"You passed a second argument to 'useFocusEffect', but it only accepts one argument. \" +\n \"If you want to pass a dependency array, you can use 'React.useCallback':\\n\\n\" +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' // Your code here\\n' +\n ' }, [depA, depB])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n\n console.error(message);\n }\n\n React.useEffect(() => {\n if (!navigation) {\n return;\n }\n\n let isFocused = false;\n let cleanup: undefined | void | (() => void);\n\n const callback = () => {\n const destroy = effect();\n\n if (destroy === undefined || typeof destroy === 'function') {\n return destroy;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n let message =\n 'An effect function must not return anything besides a function, which is used for clean-up.';\n\n if (destroy === null) {\n message +=\n \" You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing).\";\n } else if (typeof (destroy as any).then === 'function') {\n message +=\n \"\\n\\nIt looks like you wrote 'useFocusEffect(async () => ...)' or returned a Promise. \" +\n 'Instead, write the async function inside your effect ' +\n 'and call it immediately:\\n\\n' +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' async function fetchData() {\\n' +\n ' // You can await here\\n' +\n ' const response = await MyAPI.getData(someId);\\n' +\n ' // ...\\n' +\n ' }\\n\\n' +\n ' fetchData();\\n' +\n ' }, [someId])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n } else {\n message += ` You returned '${JSON.stringify(destroy)}'.`;\n }\n\n console.error(message);\n }\n };\n\n // We need to run the effect on initial render/dep changes if the screen is focused\n if (navigation.isFocused()) {\n cleanup = callback();\n isFocused = true;\n }\n\n const unsubscribeFocus = navigation.addListener('focus', () => {\n // If callback was already called for focus, avoid calling it again\n // The focus event may also fire on initial render, so we guard against running the effect twice\n if (isFocused) {\n return;\n }\n\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = callback();\n isFocused = true;\n });\n\n const unsubscribeBlur = navigation.addListener('blur', () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = undefined;\n isFocused = false;\n });\n\n return () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n unsubscribeFocus();\n unsubscribeBlur();\n };\n }, [effect, navigation]);\n}\n"]}
|
package/build/useNavigation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAiEb,sCAwFC;AAxJD,qDAIkC;AAClC,kDAA0B;AAE1B,8DAAoD;AACpD,mCAAsC;AACtC,sCAA0C;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,SAAgB,aAAa,CAI3B,MAAsB;IACtB,IAAI,UAAU,GAAG,IAAA,sBAAqB,GAAO,CAAC;IAC9C,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAA,mBAAW,GAAE,CAAC;IAE/B,IAAI,yBAAyB,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACjD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;QACT,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,GAAG,IAAA,kBAAW,EAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,KAAK,GAAG,oBAAK,CAAC,gBA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C,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvB,2DAA2D;IAC3D,yBAAyB,GAAG,yBAAyB,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAE9E,IAAI,yBAAyB,KAAK,SAAS,EAAE,CAAC;QAC5C,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,yBAAgC,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,GAAG,GAA2B,EAAE,CAAC;QAEvC,UAAU,GAAG,iBAAiB,CAAC;QAE/B,OAAO,UAAU,EAAE,CAAC;YAClB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC;YACpC,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;QACtC,CAAC;QAED,MAAM,IAAI,KAAK,CACb,gDAAgD,MAAM,6BAA6B,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CACvG,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["'use client';\nimport {\n useNavigation as useUpstreamNavigation,\n NavigationProp,\n NavigationState,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { store } from './global-state/router-store';\nimport { useSegments } from './hooks';\nimport { resolveHref } from './link/href';\nimport { Href } from './types';\n\n/**\n * Returns the underlying React Navigation [`navigation` object](https://reactnavigation.org/docs/navigation-object)\n * to imperatively access layout-specific functionality like `navigation.openDrawer()` in a\n * [Drawer](/router/advanced/drawer/) layout.\n *\n * @example\n * ```tsx app/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function Route() {\n * // Access the current navigation object for the current route.\n * const navigation = useNavigation();\n *\n * return (\n * <View>\n * <Text onPress={() => {\n * // Open the drawer view.\n * navigation.openDrawer();\n * }}>\n * Open Drawer\n * </Text>\n * </View>\n * );\n * }\n * ```\n *\n * When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.\n * For example, `/menu/_layout.tsx` is nested inside `/app/orders/`, you can use `useNavigation('/orders/menu/')`.\n *\n * @example\n * ```tsx app/orders/menu/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function MenuRoute() {\n * const rootLayout = useNavigation('/');\n * const ordersLayout = useNavigation('/orders');\n *\n * // Same as the default results of `useNavigation()` when invoked in this route.\n * const parentLayout = useNavigation('/orders/menu');\n * }\n * ```\n *\n * If you attempt to access a layout that doesn't exist, an error such as\n * `Could not find parent navigation with route \"/non-existent\"` is thrown.\n *\n *\n * @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.\n * @returns The navigation object for the current route.\n *\n * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-object/#navigator-dependent-functions)\n * for more information.\n */\nexport function useNavigation<\n T = Omit<NavigationProp<ReactNavigation.RootParamList>, 'getState'> & {\n getState(): NavigationState | undefined;\n },\n>(parent?: string | Href): T {\n let navigation = useUpstreamNavigation<any>();\n const initialNavigation = navigation;\n const segments = useSegments();\n\n let targetNavigatorContextKey = React.useMemo(() => {\n if (!parent) {\n return;\n }\n\n if (typeof parent === 'object') {\n parent = resolveHref(parent);\n }\n\n if (parent === '/') {\n return '';\n }\n\n let state = store.getStateFromPath(parent.startsWith('../') ? segments.join('/') : parent);\n\n // Reconstruct the context key from the state\n let contextKey = '';\n const names: string[] = [];\n\n while (state) {\n const routes = state.routes;\n const route = routes[state.index ?? routes.length - 1];\n\n if (route.state) {\n contextKey = `${contextKey}/${route.name}`;\n names.push(route.name);\n\n if (parent === contextKey) {\n break;\n }\n\n state = route.state;\n } else {\n break;\n }\n }\n\n if (parent.startsWith('../')) {\n const parentSegments = parent.split('/').filter(Boolean);\n\n for (const segment of parentSegments) {\n if (segment === '..') {\n names.pop();\n } else {\n throw new Error(\n \"Relative parent paths may only contain '..' and cannot contain other segments\"\n );\n }\n }\n\n contextKey = names.length > 0 ? `/${names.join('/')}` : '';\n }\n\n return contextKey;\n }, [segments, parent]);\n\n // Remove the root Slot to generate the correct context key\n targetNavigatorContextKey = targetNavigatorContextKey?.replace('/__root', '');\n\n if (targetNavigatorContextKey !== undefined) {\n navigation = navigation.getParent(targetNavigatorContextKey as any);\n }\n\n if (!navigation) {\n const ids: (string | undefined)[] = [];\n\n navigation = initialNavigation;\n\n while (navigation) {\n ids.push(navigation.getId() || '/');\n navigation = navigation.getParent();\n }\n\n throw new Error(\n `Could not find parent navigation with route \"${parent}\". Available routes are: '${ids.join(\"', '\")}'`\n );\n }\n\n return navigation;\n}\n"]}
|
package/build/useScreens.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventMapBase, NavigationState, ParamListBase,
|
|
1
|
+
import type { EventMapBase, NavigationState, ParamListBase, RouteProp, ScreenListeners } from '@react-navigation/native';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { RouteNode } from './Route';
|
|
4
4
|
import { UnknownOutputParams } from './types';
|
|
@@ -34,7 +34,7 @@ export declare function getQualifiedRouteComponent(value: RouteNode): React.Comp
|
|
|
34
34
|
({ route, navigation, ...props }: any): React.JSX.Element;
|
|
35
35
|
displayName: string;
|
|
36
36
|
};
|
|
37
|
-
export declare function screenOptionsFactory(route: RouteNode, options?: ScreenProps['options']):
|
|
37
|
+
export declare function screenOptionsFactory(route: RouteNode, options?: ScreenProps['options']): ScreenProps['options'];
|
|
38
38
|
export declare function routeToScreen(route: RouteNode, { options, getId, ...props }?: Partial<ScreenProps>): React.JSX.Element;
|
|
39
39
|
export declare function getSingularId(name: string, options?: {
|
|
40
40
|
params?: Record<string, any> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAEA,OAA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EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,KAAK,MAAM,GAAG,SAAS,CAAC;IAE7E,mBAAmB,CAAC,EAAE,eAAe,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;AA2FxE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAUxE;AAkDD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS;sCAiCtD,GAAG;;EAqBP;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAC/B,WAAW,CAAC,SAAS,CAAC,CAqBxB;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,EAChB,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAE,OAAO,CAAC,WAAW,CAAM,qBAYxD;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;CAAO,UAc3D"}
|
package/build/useScreens.js
CHANGED
package/build/useScreens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAiJb,4CAUC;AAmDD,gEAsDC;AAED,oDAwBC;AAED,sCAcC;AAED,sCAgBC;AAtTD,kDAA0B;AAE1B,mCAA6F;AAC7F,gEAAoD;AACpD,6CAAsC;AAEtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AA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E,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EACtD,CACH,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAC3B,IAAY,EACZ,UAAwD,EAAE;IAE1D,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACf,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC;QACtE,CAAC;aAAM,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["'use client';\n\nimport type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteConfig,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { LoadedRoute, Route, RouteNode, sortRoutesWithInitial, useRouteNode } from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { UnknownOutputParams } from './types';\nimport { EmptyRoute } from './views/EmptyRoute';\nimport { SuspenseFallback } from './views/SuspenseFallback';\nimport { Try } from './views/Try';\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>,\n TState extends NavigationState = NavigationState,\n TEventMap extends EventMapBase = EventMapBase,\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n /**\n * Redirect to the nearest sibling route.\n * If all children are `redirect={true}`, the layout will render `null` as there are no children to render.\n */\n redirect?: boolean;\n initialParams?: Record<string, any>;\n options?:\n | TOptions\n | ((prop: { route: RouteProp<ParamListBase, string>; navigation: any }) => TOptions);\n\n listeners?:\n | ScreenListeners<TState, TEventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<TState, TEventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> }) => string | undefined;\n\n dangerouslySingular?: SingularOptions;\n};\n\nexport type SingularOptions =\n | boolean\n | ((name: string, params: UnknownOutputParams) => string | undefined);\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[],\n initialRouteName?: string\n): { route: RouteNode; props: Partial<ScreenProps> }[] {\n if (!order?.length) {\n return children\n .sort(sortRoutesWithInitial(initialRouteName))\n .map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(\n ({\n name,\n redirect,\n initialParams,\n listeners,\n options,\n getId,\n dangerouslySingular: singular,\n }) => {\n if (!entries.length) {\n console.warn(\n `[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`\n );\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n // Ensure to return null after removing from entries.\n if (redirect) {\n if (typeof redirect === 'string') {\n throw new Error(`Redirecting to a specific route is not supported yet.`);\n }\n return null;\n }\n\n if (getId) {\n console.warn(\n `Deprecated: prop 'getId' on screen ${name} is deprecated. Please rename the prop to 'dangerouslySingular'`\n );\n if (singular) {\n console.warn(\n `Screen ${name} cannot use both getId and dangerouslySingular together.`\n );\n }\n } else if (singular) {\n // If singular is set, use it as the getId function.\n if (typeof singular === 'string') {\n getId = () => singular;\n } else if (typeof singular === 'function' && name) {\n getId = (options) => singular(name, options.params || {});\n } else if (singular === true && name) {\n getId = (options) => getSingularId(name, options);\n }\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\n }\n }\n )\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutesWithInitial(initialRouteName)).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const node = useRouteNode();\n\n const sorted = node?.children?.length\n ? getSortedChildren(node.children, order, node.initialRouteName)\n : [];\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\nfunction fromImport(value: RouteNode, { ErrorBoundary, ...component }: LoadedRoute) {\n // If possible, add a more helpful display name for the component stack to improve debugging of React errors such as `Text strings must be rendered within a <Text> component.`.\n if (component?.default && __DEV__) {\n component.default.displayName ??= `${component.default.name ?? 'Route'}(${value.contextKey})`;\n }\n\n if (ErrorBoundary) {\n const Wrapped = React.forwardRef((props: any, ref: any) => {\n const children = React.createElement(component.default || EmptyRoute, {\n ...props,\n ref,\n });\n return <Try catch={ErrorBoundary}>{children}</Try>;\n });\n\n if (__DEV__) {\n Wrapped.displayName = `ErrorBoundary(${value.contextKey})`;\n }\n\n return {\n default: Wrapped,\n };\n }\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof component.default === 'object' &&\n component.default &&\n Object.keys(component.default).length === 0\n ) {\n return { default: EmptyRoute };\n }\n }\n\n return { default: component.default };\n}\n\nfunction fromLoadedRoute(value: RouteNode, res: LoadedRoute) {\n if (!(res instanceof Promise)) {\n return fromImport(value, res);\n }\n\n return res.then(fromImport.bind(null, value));\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nexport function getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\n }\n\n let ScreenComponent:\n | React.ForwardRefExoticComponent<React.RefAttributes<unknown>>\n | React.ComponentType<any>;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n ScreenComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(value, res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n\n if (__DEV__) {\n ScreenComponent.displayName = `AsyncRoute(${value.route})`;\n }\n } else {\n const res = value.loadRoute();\n ScreenComponent = fromImport(value, res).default!;\n }\n function BaseRoute({\n // Remove these React Navigation props to\n // enforce usage of expo-router hooks (where the query params are correct).\n route,\n navigation,\n\n // Pass all other props to the component\n ...props\n }: any) {\n return (\n <Route node={value} route={route}>\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <ScreenComponent\n {...props}\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment={value.route}\n />\n </React.Suspense>\n </Route>\n );\n }\n\n if (__DEV__) {\n BaseRoute.displayName = `Route(${value.route})`;\n }\n\n qualifiedStore.set(value, BaseRoute);\n return BaseRoute;\n}\n\nexport function screenOptionsFactory(\n route: RouteNode,\n options?: ScreenProps['options']\n): RouteConfig<any, any, any, any, any, any>['options'] {\n return (args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult = typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;\n const dynamicResult = typeof options === 'function' ? options?.(args) : options;\n const output = {\n ...staticResult,\n ...dynamicResult,\n };\n\n // Prevent generated screens from showing up in the tab bar.\n if (route.generated) {\n output.tabBarItemStyle = { display: 'none' };\n output.tabBarButton = () => null;\n // TODO: React Navigation doesn't provide a way to prevent rendering the drawer item.\n output.drawerItemStyle = { height: 0, display: 'none' };\n }\n\n return output;\n };\n}\n\nexport function routeToScreen(\n route: RouteNode,\n { options, getId, ...props }: Partial<ScreenProps> = {}\n) {\n return (\n <Screen\n {...props}\n name={route.route}\n key={route.route}\n getId={getId}\n options={screenOptionsFactory(route, options)}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n\nexport function getSingularId(\n name: string,\n options: { params?: Record<string, any> | undefined } = {}\n) {\n return name\n .split('/')\n .map((segment) => {\n if (segment.startsWith('[...')) {\n return options.params?.[segment.slice(4, -1)]?.join('/') || segment;\n } else if (segment.startsWith('[')) {\n return options.params?.[segment.slice(1, -1)] || segment;\n } else {\n return segment;\n }\n })\n .join('/');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAgJb,4CAUC;AAmDD,gEAsDC;AAED,oDAwBC;AAED,sCAcC;AAED,sCAgBC;AAtTD,kDAA0B;AAE1B,mCAA6F;AAC7F,gEAAoD;AACpD,6CAAsC;AAEtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AAmClC,SAAS,iBAAiB,CACxB,QAAqB,EACrB,KAAqB,EACrB,gBAAyB;IAEzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,QAAQ;aACZ,IAAI,CAAC,IAAA,6BAAqB,EAAC,gBAAgB,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAE9B,MAAM,OAAO,GAAG,KAAK;SAClB,GAAG,CACF,CAAC,EACC,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,KAAK,EACL,mBAAmB,EAAE,QAAQ,GAC9B,EA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CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["'use client';\n\nimport type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { LoadedRoute, Route, RouteNode, sortRoutesWithInitial, useRouteNode } from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { UnknownOutputParams } from './types';\nimport { EmptyRoute } from './views/EmptyRoute';\nimport { SuspenseFallback } from './views/SuspenseFallback';\nimport { Try } from './views/Try';\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>,\n TState extends NavigationState = NavigationState,\n TEventMap extends EventMapBase = EventMapBase,\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n /**\n * Redirect to the nearest sibling route.\n * If all children are `redirect={true}`, the layout will render `null` as there are no children to render.\n */\n redirect?: boolean;\n initialParams?: Record<string, any>;\n options?:\n | TOptions\n | ((prop: { route: RouteProp<ParamListBase, string>; navigation: any }) => TOptions);\n\n listeners?:\n | ScreenListeners<TState, TEventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<TState, TEventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> }) => string | undefined;\n\n dangerouslySingular?: SingularOptions;\n};\n\nexport type SingularOptions =\n | boolean\n | ((name: string, params: UnknownOutputParams) => string | undefined);\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[],\n initialRouteName?: string\n): { route: RouteNode; props: Partial<ScreenProps> }[] {\n if (!order?.length) {\n return children\n .sort(sortRoutesWithInitial(initialRouteName))\n .map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(\n ({\n name,\n redirect,\n initialParams,\n listeners,\n options,\n getId,\n dangerouslySingular: singular,\n }) => {\n if (!entries.length) {\n console.warn(\n `[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`\n );\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n // Ensure to return null after removing from entries.\n if (redirect) {\n if (typeof redirect === 'string') {\n throw new Error(`Redirecting to a specific route is not supported yet.`);\n }\n return null;\n }\n\n if (getId) {\n console.warn(\n `Deprecated: prop 'getId' on screen ${name} is deprecated. Please rename the prop to 'dangerouslySingular'`\n );\n if (singular) {\n console.warn(\n `Screen ${name} cannot use both getId and dangerouslySingular together.`\n );\n }\n } else if (singular) {\n // If singular is set, use it as the getId function.\n if (typeof singular === 'string') {\n getId = () => singular;\n } else if (typeof singular === 'function' && name) {\n getId = (options) => singular(name, options.params || {});\n } else if (singular === true && name) {\n getId = (options) => getSingularId(name, options);\n }\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\n }\n }\n )\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutesWithInitial(initialRouteName)).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const node = useRouteNode();\n\n const sorted = node?.children?.length\n ? getSortedChildren(node.children, order, node.initialRouteName)\n : [];\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\nfunction fromImport(value: RouteNode, { ErrorBoundary, ...component }: LoadedRoute) {\n // If possible, add a more helpful display name for the component stack to improve debugging of React errors such as `Text strings must be rendered within a <Text> component.`.\n if (component?.default && __DEV__) {\n component.default.displayName ??= `${component.default.name ?? 'Route'}(${value.contextKey})`;\n }\n\n if (ErrorBoundary) {\n const Wrapped = React.forwardRef((props: any, ref: any) => {\n const children = React.createElement(component.default || EmptyRoute, {\n ...props,\n ref,\n });\n return <Try catch={ErrorBoundary}>{children}</Try>;\n });\n\n if (__DEV__) {\n Wrapped.displayName = `ErrorBoundary(${value.contextKey})`;\n }\n\n return {\n default: Wrapped,\n };\n }\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof component.default === 'object' &&\n component.default &&\n Object.keys(component.default).length === 0\n ) {\n return { default: EmptyRoute };\n }\n }\n\n return { default: component.default };\n}\n\nfunction fromLoadedRoute(value: RouteNode, res: LoadedRoute) {\n if (!(res instanceof Promise)) {\n return fromImport(value, res);\n }\n\n return res.then(fromImport.bind(null, value));\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nexport function getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\n }\n\n let ScreenComponent:\n | React.ForwardRefExoticComponent<React.RefAttributes<unknown>>\n | React.ComponentType<any>;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n ScreenComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(value, res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n\n if (__DEV__) {\n ScreenComponent.displayName = `AsyncRoute(${value.route})`;\n }\n } else {\n const res = value.loadRoute();\n ScreenComponent = fromImport(value, res).default!;\n }\n function BaseRoute({\n // Remove these React Navigation props to\n // enforce usage of expo-router hooks (where the query params are correct).\n route,\n navigation,\n\n // Pass all other props to the component\n ...props\n }: any) {\n return (\n <Route node={value} route={route}>\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <ScreenComponent\n {...props}\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment={value.route}\n />\n </React.Suspense>\n </Route>\n );\n }\n\n if (__DEV__) {\n BaseRoute.displayName = `Route(${value.route})`;\n }\n\n qualifiedStore.set(value, BaseRoute);\n return BaseRoute;\n}\n\nexport function screenOptionsFactory(\n route: RouteNode,\n options?: ScreenProps['options']\n): ScreenProps['options'] {\n return (args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult = typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;\n const dynamicResult = typeof options === 'function' ? options?.(args) : options;\n const output = {\n ...staticResult,\n ...dynamicResult,\n };\n\n // Prevent generated screens from showing up in the tab bar.\n if (route.generated) {\n output.tabBarItemStyle = { display: 'none' };\n output.tabBarButton = () => null;\n // TODO: React Navigation doesn't provide a way to prevent rendering the drawer item.\n output.drawerItemStyle = { height: 0, display: 'none' };\n }\n\n return output;\n };\n}\n\nexport function routeToScreen(\n route: RouteNode,\n { options, getId, ...props }: Partial<ScreenProps> = {}\n) {\n return (\n <Screen\n {...props}\n name={route.route}\n key={route.route}\n getId={getId}\n options={screenOptionsFactory(route, options)}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n\nexport function getSingularId(\n name: string,\n options: { params?: Record<string, any> | undefined } = {}\n) {\n return name\n .split('/')\n .map((segment) => {\n if (segment.startsWith('[...')) {\n return options.params?.[segment.slice(4, -1)]?.join('/') || segment;\n } else if (segment.startsWith('[')) {\n return options.params?.[segment.slice(1, -1)] || segment;\n } else {\n return segment;\n }\n })\n .join('/');\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyRoute.js","sourceRoot":"","sources":["../../src/views/EmptyRoute.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"EmptyRoute.js","sourceRoot":"","sources":["../../src/views/EmptyRoute.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAOb,gCAUC;AAfD,kDAA0B;AAE1B,mCAA8C;AAC9C,oCAAwC;AAExC,SAAgB,UAAU;IACxB,MAAM,KAAK,GAAG,IAAA,oBAAY,GAAE,CAAC;IAE7B,OAAO,CACL,CAAC,oBAAY,CACX;MAAA,CAAC,aAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,CACzC;;MACF,EAAE,aAAK,CACT;IAAA,EAAE,oBAAY,CAAC,CAChB,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport { Toast, ToastWrapper } from './Toast';\nimport { useRouteNode } from '../Route';\n\nexport function EmptyRoute() {\n const route = useRouteNode();\n\n return (\n <ToastWrapper>\n <Toast warning filename={route?.contextKey}>\n Missing default export\n </Toast>\n </ToastWrapper>\n );\n}\n"]}
|