@expo/router-server 56.0.18 → 56.0.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"renderStreamingContent.d.ts","sourceRoot":"","sources":["../../src/server/renderStreamingContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA0BzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,oEAAoE;QACpE,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,SAAS,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,IAAI,CAAC;IACT,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,MAAM,CAAC,EAAE;QACP,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,4EAA4E;QAC5E,SAAS,CAAC,EAAE;YACV,MAAM,EAAE,MAAM,CAAC;YACf,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;QACJ,EAAE,EAAE,MAAM,EAAE,CAAC;QACb,+EAA+E;QAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAkDF;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,GAAG,EACb,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CA8CrC;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"renderStreamingContent.d.ts","sourceRoot":"","sources":["../../src/server/renderStreamingContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA2BzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,oEAAoE;QACpE,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,SAAS,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,IAAI,CAAC;IACT,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,MAAM,CAAC,EAAE;QACP,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,4EAA4E;QAC5E,SAAS,CAAC,EAAE;YACV,MAAM,EAAE,MAAM,CAAC;YACf,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;QACJ,EAAE,EAAE,MAAM,EAAE,CAAC;QACb,+EAA+E;QAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAkDF;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,GAAG,EACb,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAoDrC;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -111,6 +111,7 @@ async function getStreamingContent(location, options) {
111
111
  const faviconNode = options?.assets?.favicon
112
112
  ? (0, react_1.createFaviconAsNode)(options?.assets?.favicon)
113
113
  : undefined;
114
+ const { headNodes: headJsNodes, bodyNodes: bodyJsNodes } = (0, react_1.createInjectedScriptAsNodes)(options?.assets?.js ?? []);
114
115
  const serverDocumentData = {
115
116
  headNodes: [
116
117
  ...(options?.metadata?.headNodes ?? []),
@@ -118,15 +119,17 @@ async function getStreamingContent(location, options) {
118
119
  getStyleElement({ key: 'rnw-style-element' }),
119
120
  ...(headCssNodes ?? []),
120
121
  ...(inlineCssNodes ?? []),
122
+ ...(headJsNodes ?? []),
121
123
  ].filter(Boolean),
122
- bodyNodes: [(0, jsx_runtime_1.jsx)(FontResources, {}, "font-resources")],
124
+ // NOTE(@hassankhan): React's bootstrapScripts emits async scripts, but Metro chunks must
125
+ // execute in asset order so the runtime initializes before dependent chunks.
126
+ bodyNodes: [(0, jsx_runtime_1.jsx)(FontResources, {}, "font-resources"), ...(bodyJsNodes ?? [])],
123
127
  };
124
128
  return await server_2.default.renderToReadableStream((0, jsx_runtime_1.jsx)(server_1.ServerDocument, { data: serverDocumentData, children: (0, jsx_runtime_1.jsx)(head_1.default.Provider, { context: headContext, children: (0, jsx_runtime_1.jsx)(static_1.InnerRoot, { loadedData: loadedData, children: element }) }) }), {
125
129
  // TODO(@hassankhan): Experiment and see if we can calculate a better default
126
130
  // We're doubling the default here so non-JavaScript renders show some content
127
131
  progressiveChunkSize: 12800 * 2,
128
132
  bootstrapScriptContent: (0, react_1.getBootstrapContents)({ hydrate: true, loadedData }),
129
- bootstrapScripts: options?.assets?.js,
130
133
  signal: options?.request?.signal,
131
134
  onError(error) {
132
135
  if (options?.request?.signal.aborted) {
@@ -1 +1 @@
1
- {"version":3,"file":"renderStreamingContent.js","sourceRoot":"","sources":["../../src/server/renderStreamingContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqHA,kDAiDC;;AAtKD;;;;;GAKG;AACH,kEAAkE;AAClE,gCAAgC;AAEhC,6DAA+C;AAC/C,6CAAuC;AACvC,2CAAuC;AACvC,4DAAoC;AACpC,wDAA6D;AAC7D,wDAAqF;AAErF,8DAA8C;AAE9C,iEAA8D;AAC9D,0CAA6C;AAC7C,0CAMwB;AAExB,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,2CAA2C,CAAC,CAAC;AAEvE,SAAS,4BAA4B;IACnC,iDAAiD;IACjD,0JAA0J;IAE1J,8FAA8F;IAC9F,yJAAyJ;IACzJ,MAAM,QAAQ,GAAG,uCAAuC,CAAC;IACxD,UAAkB,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,EAA8B,CAAC;AACxE,CAAC;AA2BD;;;GAGG;AACH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AE,IAAI,EAAE,UAAU,EAAE,CAAC;QAC3E,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM;QAChC,OAAO,CAAC,KAAK;YACX,IAAI,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;gBACrC,OAAO;YACT,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACtD,CAAC;KACF,CACF,CAAC;AACJ,CAAC;AAED,uCAA6C;AAApC,2GAAA,eAAe,OAAA","sourcesContent":["/**\n * Copyright © 2026 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 */\n// NOTE(@hassankhan): disable when this file is its own entrypoint\n// import '@expo/metro-runtime';\n\nimport * as Font from 'expo-font/build/server';\nimport { ExpoRoot } from 'expo-router';\nimport { ctx } from 'expo-router/_ctx';\nimport Head from 'expo-router/head';\nimport { ServerDocument } from 'expo-router/internal/server';\nimport { InnerRoot, registerStaticRootComponent } from 'expo-router/internal/static';\nimport React, { ReactNode } from 'react';\nimport ReactDOMServer from 'react-dom/server';\n\nimport { getRootComponent } from '../static/getRootComponent';\nimport { createDebug } from '../utils/debug';\nimport {\n createFaviconAsNode,\n createInjectedCssAsNodes,\n createInjectedFontsAsNodes,\n createInjectedInlineCssAsNodes,\n getBootstrapContents,\n} from '../utils/react';\n\nconst debug = createDebug('expo:router:server:renderStreamingContent');\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 (globalThis as any)[contexts] = new Map<string, React.Context<any>>();\n}\n\n// NOTE(@hassankhan): Keep in sync with `expo-server/src/manifest.ts`\nexport type GetStreamingContentOptions = {\n loader?: {\n data?: any;\n /** Unique key for the route. Derived from the route's contextKey */\n key: string;\n };\n metadata?: {\n headNodes: ReactNode[];\n } | null;\n request?: Request;\n /** Assets for hydration bundles and development-only inline CSS. */\n assets?: {\n css: string[];\n /** CSS source to inline into the document head, used by development SSR. */\n inlineCss?: {\n source: string;\n hmrId?: string;\n }[];\n js: string[];\n /** Public href of a favicon generated from `web.favicon` in the app config. */\n favicon?: string;\n };\n};\n\n/**\n * Shared setup for both `getStaticContent()` and `getStreamingContent()`. Creates the React element\n * tree, resets server contexts, and computes loader data.\n */\nfunction prepareRenderContext(location: URL, options?: GetStreamingContentOptions) {\n const headContext: { helmet?: any } = {};\n const Root = getRootComponent();\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 } = registerStaticRootComponent(ExpoRoot, {\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 // 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 loaderKey = options?.loader ? options.loader.key + location.search : null;\n\n const loadedData = loaderKey\n ? {\n [loaderKey]: options?.loader?.data ?? null,\n }\n : null;\n\n return { headContext, element, getStyleElement, loadedData };\n}\n\nfunction FontResources() {\n const descriptors = Font.getServerResourceDescriptors();\n debug(`Pushing fonts: (count: ${descriptors.length})`, descriptors);\n return createInjectedFontsAsNodes(descriptors);\n}\n\n/**\n * Streaming SSR renderer using `renderToReadableStream`. Returns a web `ReadableStream`\n * that emits the full HTML document with head injections applied.\n */\nexport async function getStreamingContent(\n location: URL,\n options?: GetStreamingContentOptions\n): Promise<ReadableStream<Uint8Array>> {\n const { headContext, element, getStyleElement, loadedData } = prepareRenderContext(\n location,\n options\n );\n\n const { headNodes: headCssNodes } = createInjectedCssAsNodes(options?.assets?.css ?? []);\n const { headNodes: inlineCssNodes } = createInjectedInlineCssAsNodes(options?.assets?.inlineCss);\n const faviconNode = options?.assets?.favicon\n ? createFaviconAsNode(options?.assets?.favicon)\n : undefined;\n\n const serverDocumentData = {\n headNodes: [\n ...(options?.metadata?.headNodes ?? []),\n faviconNode,\n getStyleElement({ key: 'rnw-style-element' }),\n ...(headCssNodes ?? []),\n ...(inlineCssNodes ?? []),\n ].filter(Boolean),\n bodyNodes: [<FontResources key=\"font-resources\" />],\n };\n\n return await ReactDOMServer.renderToReadableStream(\n <ServerDocument data={serverDocumentData}>\n {/* TODO(@hassankhan): Remove `<Head.Provider>` when `unstable_useServerRendering` is stabilized */}\n <Head.Provider context={headContext}>\n <InnerRoot loadedData={loadedData}>{element}</InnerRoot>\n </Head.Provider>\n </ServerDocument>,\n {\n // TODO(@hassankhan): Experiment and see if we can calculate a better default\n // We're doubling the default here so non-JavaScript renders show some content\n progressiveChunkSize: 12800 * 2,\n bootstrapScriptContent: getBootstrapContents({ hydrate: true, loadedData }),\n bootstrapScripts: options?.assets?.js,\n signal: options?.request?.signal,\n onError(error) {\n if (options?.request?.signal.aborted) {\n return;\n }\n\n console.error('SSR streaming render error:', error);\n },\n }\n );\n}\n\nexport { resolveMetadata } from './metadata';\n"]}
1
+ {"version":3,"file":"renderStreamingContent.js","sourceRoot":"","sources":["../../src/server/renderStreamingContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHA,kDAuDC;;AA7KD;;;;;GAKG;AACH,kEAAkE;AAClE,gCAAgC;AAEhC,6DAA+C;AAC/C,6CAAuC;AACvC,2CAAuC;AACvC,4DAAoC;AACpC,wDAA6D;A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;YACvB,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;YACzB,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;SACvB,CAAC,MAAM,CAAC,OAAO,CAAC;QACjB,yFAAyF;QACzF,6EAA6E;QAC7E,SAAS,EAAE,CAAC,uBAAC,aAAa,MAAK,gBAAgB,CAAG,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;KAC5E,CAAC;IAEF,OAAO,MAAM,gBAAc,CAAC,sBAAsB,CAChD,uBAAC,uBAAc,IAAC,IAAI,EAAE,kBAAkB,YAEtC,uBAAC,cAAI,CAAC,QAAQ,IAAC,OAAO,EAAE,WAAW,YACjC,uBAAC,kBAAS,IAAC,UAAU,EAAE,UAAU,YAAG,OAAO,GAAa,GAC1C,GACD,EACjB;QACE,6EAA6E;QAC7E,8EAA8E;QAC9E,oBAAoB,EAAE,KAAK,GAAG,CAAC;QAC/B,sBAAsB,EAAE,IAAA,4BAAoB,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAC3E,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM;QAChC,OAAO,CAAC,KAAK;YACX,IAAI,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;gBACrC,OAAO;YACT,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACtD,CAAC;KACF,CACF,CAAC;AACJ,CAAC;AAED,uCAA6C;AAApC,2GAAA,eAAe,OAAA","sourcesContent":["/**\n * Copyright © 2026 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 */\n// NOTE(@hassankhan): disable when this file is its own entrypoint\n// import '@expo/metro-runtime';\n\nimport * as Font from 'expo-font/build/server';\nimport { ExpoRoot } from 'expo-router';\nimport { ctx } from 'expo-router/_ctx';\nimport Head from 'expo-router/head';\nimport { ServerDocument } from 'expo-router/internal/server';\nimport { InnerRoot, registerStaticRootComponent } from 'expo-router/internal/static';\nimport React, { ReactNode } from 'react';\nimport ReactDOMServer from 'react-dom/server';\n\nimport { getRootComponent } from '../static/getRootComponent';\nimport { createDebug } from '../utils/debug';\nimport {\n createFaviconAsNode,\n createInjectedCssAsNodes,\n createInjectedFontsAsNodes,\n createInjectedInlineCssAsNodes,\n createInjectedScriptAsNodes,\n getBootstrapContents,\n} from '../utils/react';\n\nconst debug = createDebug('expo:router:server:renderStreamingContent');\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 (globalThis as any)[contexts] = new Map<string, React.Context<any>>();\n}\n\n// NOTE(@hassankhan): Keep in sync with `expo-server/src/manifest.ts`\nexport type GetStreamingContentOptions = {\n loader?: {\n data?: any;\n /** Unique key for the route. Derived from the route's contextKey */\n key: string;\n };\n metadata?: {\n headNodes: ReactNode[];\n } | null;\n request?: Request;\n /** Assets for hydration bundles and development-only inline CSS. */\n assets?: {\n css: string[];\n /** CSS source to inline into the document head, used by development SSR. */\n inlineCss?: {\n source: string;\n hmrId?: string;\n }[];\n js: string[];\n /** Public href of a favicon generated from `web.favicon` in the app config. */\n favicon?: string;\n };\n};\n\n/**\n * Shared setup for both `getStaticContent()` and `getStreamingContent()`. Creates the React element\n * tree, resets server contexts, and computes loader data.\n */\nfunction prepareRenderContext(location: URL, options?: GetStreamingContentOptions) {\n const headContext: { helmet?: any } = {};\n const Root = getRootComponent();\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 } = registerStaticRootComponent(ExpoRoot, {\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 // 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 loaderKey = options?.loader ? options.loader.key + location.search : null;\n\n const loadedData = loaderKey\n ? {\n [loaderKey]: options?.loader?.data ?? null,\n }\n : null;\n\n return { headContext, element, getStyleElement, loadedData };\n}\n\nfunction FontResources() {\n const descriptors = Font.getServerResourceDescriptors();\n debug(`Pushing fonts: (count: ${descriptors.length})`, descriptors);\n return createInjectedFontsAsNodes(descriptors);\n}\n\n/**\n * Streaming SSR renderer using `renderToReadableStream`. Returns a web `ReadableStream`\n * that emits the full HTML document with head injections applied.\n */\nexport async function getStreamingContent(\n location: URL,\n options?: GetStreamingContentOptions\n): Promise<ReadableStream<Uint8Array>> {\n const { headContext, element, getStyleElement, loadedData } = prepareRenderContext(\n location,\n options\n );\n\n const { headNodes: headCssNodes } = createInjectedCssAsNodes(options?.assets?.css ?? []);\n const { headNodes: inlineCssNodes } = createInjectedInlineCssAsNodes(options?.assets?.inlineCss);\n const faviconNode = options?.assets?.favicon\n ? createFaviconAsNode(options?.assets?.favicon)\n : undefined;\n\n const { headNodes: headJsNodes, bodyNodes: bodyJsNodes } = createInjectedScriptAsNodes(\n options?.assets?.js ?? []\n );\n\n const serverDocumentData = {\n headNodes: [\n ...(options?.metadata?.headNodes ?? []),\n faviconNode,\n getStyleElement({ key: 'rnw-style-element' }),\n ...(headCssNodes ?? []),\n ...(inlineCssNodes ?? []),\n ...(headJsNodes ?? []),\n ].filter(Boolean),\n // NOTE(@hassankhan): React's bootstrapScripts emits async scripts, but Metro chunks must\n // execute in asset order so the runtime initializes before dependent chunks.\n bodyNodes: [<FontResources key=\"font-resources\" />, ...(bodyJsNodes ?? [])],\n };\n\n return await ReactDOMServer.renderToReadableStream(\n <ServerDocument data={serverDocumentData}>\n {/* TODO(@hassankhan): Remove `<Head.Provider>` when `unstable_useServerRendering` is stabilized */}\n <Head.Provider context={headContext}>\n <InnerRoot loadedData={loadedData}>{element}</InnerRoot>\n </Head.Provider>\n </ServerDocument>,\n {\n // TODO(@hassankhan): Experiment and see if we can calculate a better default\n // We're doubling the default here so non-JavaScript renders show some content\n progressiveChunkSize: 12800 * 2,\n bootstrapScriptContent: getBootstrapContents({ hydrate: true, loadedData }),\n signal: options?.request?.signal,\n onError(error) {\n if (options?.request?.signal.aborted) {\n return;\n }\n\n console.error('SSR streaming render error:', error);\n },\n }\n );\n}\n\nexport { resolveMetadata } from './metadata';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/router-server",
3
- "version": "56.0.18",
3
+ "version": "56.0.19",
4
4
  "description": "Expo Router is a file-based router for React Native and web applications.",
5
5
  "author": "650 Industries, Inc.",
6
6
  "license": "MIT",
@@ -24,9 +24,9 @@
24
24
  "expo"
25
25
  ],
26
26
  "peerDependencies": {
27
- "@expo/metro-runtime": "^56.0.20",
27
+ "@expo/metro-runtime": "^56.0.21",
28
28
  "expo": "*",
29
- "expo-constants": "^56.0.24",
29
+ "expo-constants": "^56.0.26",
30
30
  "expo-font": "^56.0.7",
31
31
  "expo-router": "*",
32
32
  "expo-server": "^56.0.6",
@@ -56,11 +56,12 @@
56
56
  "@types/react": "~19.2.0",
57
57
  "@types/react-dom": "^19.1.7",
58
58
  "jest-runner-tsd": "^6.0.0",
59
+ "node-html-parser": "^6.1.5",
59
60
  "react-server-dom-webpack": "~19.0.6",
60
61
  "tsd": "^0.33.0",
61
62
  "tsd-lite": "^0.9.0",
62
- "expo": "56.0.20",
63
- "expo-router": "56.2.19"
63
+ "expo-router": "56.2.21",
64
+ "expo": "56.0.22"
64
65
  },
65
66
  "dependencies": {
66
67
  "debug": "^4.3.4"
@@ -68,7 +69,7 @@
68
69
  "publishConfig": {
69
70
  "access": "public"
70
71
  },
71
- "gitHead": "39f9dc47fb5ddd099a2533dd0ff24be7126a1ed0",
72
+ "gitHead": "6a613ddc65139388dc1d25ccef2e88721fc66384",
72
73
  "scripts": {
73
74
  "build": "expo-module build",
74
75
  "clean": "expo-module clean",