@@ -21,6 +21,7 @@ import {
2121 type ComponentProps ,
2222 type UnPackedPageProps ,
2323} from './types.ts'
24+ import { type ContainerResolver } from '@adonisjs/core/container'
2425
2526/**
2627 * Type guard to check if a value is a plain object
@@ -308,8 +309,11 @@ export function isOptionalProp<T extends UnPackedPageProps>(
308309 * @param value - The prop value to serialize
309310 * @returns Promise resolving to the serialized JSON data
310311 */
311- async function unpackPropValue ( value : UnPackedPageProps < JSONDataTypes > ) {
312- return serialize ( value ) as Promise < JSONDataTypes >
312+ async function unpackPropValue (
313+ value : UnPackedPageProps < JSONDataTypes > ,
314+ containerResolver : ContainerResolver < any >
315+ ) {
316+ return serialize ( value , containerResolver ) as Promise < JSONDataTypes >
313317}
314318
315319/**
@@ -335,7 +339,10 @@ async function unpackPropValue(value: UnPackedPageProps<JSONDataTypes>) {
335339 * // Returns: { props: { user: {...} }, deferredProps: { default: ['posts'] }, mergeProps: ['settings'] }
336340 * ```
337341 */
338- export async function buildStandardVisitProps ( pageProps : PageProps ) {
342+ export async function buildStandardVisitProps (
343+ pageProps : PageProps ,
344+ containerResolver : ContainerResolver < any >
345+ ) {
339346 const mergeProps : string [ ] = [ ]
340347 const deepMergeProps : string [ ] = [ ]
341348 const newProps : ComponentProps = { }
@@ -431,12 +438,12 @@ export async function buildStandardVisitProps(pageProps: PageProps) {
431438 unpackedValues . map ( async ( { key, value } ) => {
432439 if ( typeof value === 'function' ) {
433440 return Promise . resolve ( value ( ) )
434- . then ( ( r ) => unpackPropValue ( r ) )
441+ . then ( ( r ) => unpackPropValue ( r , containerResolver ) )
435442 . then ( ( jsonValue ) => {
436443 newProps [ key ] = jsonValue
437444 } )
438445 } else {
439- return unpackPropValue ( value ) . then ( ( jsonValue ) => {
446+ return unpackPropValue ( value , containerResolver ) . then ( ( jsonValue ) => {
440447 newProps [ key ] = jsonValue
441448 } )
442449 }
@@ -474,7 +481,11 @@ export async function buildStandardVisitProps(pageProps: PageProps) {
474481 * // Returns: { props: { posts: [...], stats: [...] }, mergeProps: [], deferredProps: {} }
475482 * ```
476483 */
477- export async function buildPartialRequestProps ( pageProps : PageProps , cherryPickProps : string [ ] ) {
484+ export async function buildPartialRequestProps (
485+ pageProps : PageProps ,
486+ cherryPickProps : string [ ] ,
487+ containerResolver : ContainerResolver < any >
488+ ) {
478489 const mergeProps : string [ ] = [ ]
479490 const deepMergeProps : string [ ] = [ ]
480491 const newProps : ComponentProps = { }
@@ -567,12 +578,12 @@ export async function buildPartialRequestProps(pageProps: PageProps, cherryPickP
567578 unpackedValues . map ( async ( { key, value } ) => {
568579 if ( typeof value === 'function' ) {
569580 return Promise . resolve ( value ( ) )
570- . then ( ( r ) => unpackPropValue ( r ) )
581+ . then ( ( r ) => unpackPropValue ( r , containerResolver ) )
571582 . then ( ( jsonValue ) => {
572583 newProps [ key ] = jsonValue
573584 } )
574585 } else {
575- return unpackPropValue ( value ) . then ( ( jsonValue ) => {
586+ return unpackPropValue ( value , containerResolver ) . then ( ( jsonValue ) => {
576587 newProps [ key ] = jsonValue
577588 } )
578589 }
0 commit comments