diff --git a/examples/client-rendering/src/routes/Root__Todos__ByStatus_route_renderer.res b/examples/client-rendering/src/routes/Root__Todos__ByStatus_route_renderer.res index f618a5a..3686a9d 100644 --- a/examples/client-rendering/src/routes/Root__Todos__ByStatus_route_renderer.res +++ b/examples/client-rendering/src/routes/Root__Todos__ByStatus_route_renderer.res @@ -1,8 +1,8 @@ -let renderer = Routes.Root.Todos.ByStatus.Route.makeRenderer( - ~prepare=_props => { +let renderer: Routes.Root.Todos.ByStatus.Route.routeRenderer<'prepared> = { + prepare: _props => { () }, - ~render=_props => { + render: _props => { React.null }, -) +} diff --git a/examples/client-rendering/src/routes/Root__Todos__Single_route_renderer.res b/examples/client-rendering/src/routes/Root__Todos__Single_route_renderer.res index 388b6ff..e267c53 100644 --- a/examples/client-rendering/src/routes/Root__Todos__Single_route_renderer.res +++ b/examples/client-rendering/src/routes/Root__Todos__Single_route_renderer.res @@ -1,5 +1,5 @@ -let renderer = Routes.Root.Todos.Single.Route.makeRenderer( - ~prepare=({environment, showMore, todoId}) => { +let renderer: Routes.Root.Todos.Single.Route.routeRenderer<'prepared> = { + prepare: ({environment, params: {showMore, todoId}}) => { SingleTodoQuery_graphql.load( ~environment, ~fetchPolicy=StoreOrNetwork, @@ -9,7 +9,7 @@ let renderer = Routes.Root.Todos.Single.Route.makeRenderer( }, ) }, - ~render=({prepared}) => { + render: ({prepared}) => { }, -) +} diff --git a/examples/client-rendering/src/routes/Root__Todos_route_renderer.res b/examples/client-rendering/src/routes/Root__Todos_route_renderer.res index 2d9ca07..fe3ef92 100644 --- a/examples/client-rendering/src/routes/Root__Todos_route_renderer.res +++ b/examples/client-rendering/src/routes/Root__Todos_route_renderer.res @@ -1,8 +1,8 @@ -let renderer = Route__Root__Todos_route.makeRenderer( - ~prepare=({environment}) => { +let renderer: Route__Root__Todos_route.routeRenderer<'prepared> = { + prepare: ({environment}) => { TodosListQuery_graphql.load(~environment, ~fetchPolicy=StoreOrNetwork, ~variables=()) }, - ~render=({prepared, childRoutes}) => { + render: ({prepared, childRoutes}) => { {childRoutes} }, -) +} diff --git a/examples/client-rendering/src/routes/Root_route_renderer.res b/examples/client-rendering/src/routes/Root_route_renderer.res index 8f3de6c..09b8b57 100644 --- a/examples/client-rendering/src/routes/Root_route_renderer.res +++ b/examples/client-rendering/src/routes/Root_route_renderer.res @@ -1,8 +1,8 @@ -let renderer = Route__Root_route.makeRenderer( - ~prepare=({environment}) => { +let renderer: Routes.Root.Route.routeRenderer<'prepared> = { + prepare: ({environment}) => { LayoutQuery_graphql.load(~environment, ~variables=(), ~fetchPolicy=StoreOrNetwork) }, - ~render=props => { + render: props => { {props.childRoutes} }, -) +} diff --git a/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res b/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res index 5ad1d7d..90457bd 100644 --- a/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res +++ b/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res @@ -1,8 +1,6 @@ open RelayRouter__Internal__DeclarationsSupport -external unsafe_toPrepareProps: 'any => prepareProps = "%identity" - let loadedRouteRenderers: Belt.HashMap.String.t = Belt.HashMap.String.make( ~hintSize=4, ) @@ -13,20 +11,23 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { ignore(pathParams) ignore(queryParams) let prepareProps: Route__Root_route.Internal.prepareProps = { environment: environment, location: location, + + params: { } + } prepareProps->unsafe_toPrepareProps } @@ -82,20 +83,23 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root__Todos_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { ignore(pathParams) let prepareProps: Route__Root__Todos_route.Internal.prepareProps = { environment: environment, location: location, + + params: { statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } + } prepareProps->unsafe_toPrepareProps } @@ -150,20 +154,23 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root__Todos__ByStatus_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__ByStatus_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { let prepareProps: Route__Root__Todos__ByStatus_route.Internal.prepareProps = { environment: environment, location: location, + + params: { byStatus: pathParams->Js.Dict.unsafeGet("byStatus")->Obj.magic, statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } + } prepareProps->unsafe_toPrepareProps } @@ -220,17 +227,19 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root__Todos__Single_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__Single_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { let prepareProps: Route__Root__Todos__Single_route.Internal.prepareProps = { environment: environment, location: location, + + params: { todoId: pathParams->Js.Dict.unsafeGet("todoId"), statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), showMore: queryParams->RelayRouter.Bindings.QueryParams.getParamByKey("showMore")->Belt.Option.flatMap(value => switch value { @@ -239,6 +248,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array None }), } + } prepareProps->unsafe_toPrepareProps } diff --git a/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res b/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res index 214b1cd..d2fca3a 100644 --- a/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res +++ b/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res @@ -2,44 +2,32 @@ // This file is autogenerated from `todoRoutes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { byStatus: [#completed | #notCompleted], statuses: option>, } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - byStatus: [#completed | #notCompleted], - statuses: option>, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { { environment: environment, location: location, + + params: { byStatus: pathParams->Js.Dict.unsafeGet("byStatus")->Obj.magic, statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } } + } } @@ -175,9 +163,4 @@ let useIsRouteActive = (~exact=false) => { React.useMemo2(() => location->isRouteActive(~exact), (location, exact)) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__Single_route.res b/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__Single_route.res index 4ad6c7a..e9bc4f7 100644 --- a/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__Single_route.res +++ b/examples/client-rendering/src/routes/__generated__/Route__Root__Todos__Single_route.res @@ -2,42 +2,28 @@ // This file is autogenerated from `todoRoutes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { todoId: string, statuses: option>, showMore: option, } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - todoId: string, - statuses: option>, - showMore: option, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { { environment: environment, location: location, + + params: { todoId: pathParams->Js.Dict.unsafeGet("todoId"), statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), showMore: queryParams->RelayRouter.Bindings.QueryParams.getParamByKey("showMore")->Belt.Option.flatMap(value => switch value { @@ -47,6 +33,7 @@ module Internal = { }), } } + } } @@ -194,9 +181,4 @@ let useIsRouteActive = (~exact=false) => { React.useMemo2(() => location->isRouteActive(~exact), (location, exact)) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/examples/client-rendering/src/routes/__generated__/Route__Root__Todos_route.res b/examples/client-rendering/src/routes/__generated__/Route__Root__Todos_route.res index 69c2246..6043019 100644 --- a/examples/client-rendering/src/routes/__generated__/Route__Root__Todos_route.res +++ b/examples/client-rendering/src/routes/__generated__/Route__Root__Todos_route.res @@ -2,42 +2,31 @@ // This file is autogenerated from `todoRoutes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { statuses: option>, } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - statuses: option>, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { ignore(pathParams) { environment: environment, location: location, + + params: { statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } } + } } @@ -192,9 +181,4 @@ let useActiveSubRoute = (): option<[#ByStatus | #Single]> => { }, [location]) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/examples/client-rendering/src/routes/__generated__/Route__Root_route.res b/examples/client-rendering/src/routes/__generated__/Route__Root_route.res index c069fa0..4d5247e 100644 --- a/examples/client-rendering/src/routes/__generated__/Route__Root_route.res +++ b/examples/client-rendering/src/routes/__generated__/Route__Root_route.res @@ -2,40 +2,30 @@ // This file is autogenerated from `routes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { ignore(pathParams) ignore(queryParams) { environment: environment, location: location, + + params: { } } + } } @@ -80,9 +70,4 @@ let useActiveSubRoute = (): option<[#Todos]> => { }, [location]) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/examples/express/src/routes/Root__Todos__ByStatus_route_renderer.res b/examples/express/src/routes/Root__Todos__ByStatus_route_renderer.res index f618a5a..3686a9d 100644 --- a/examples/express/src/routes/Root__Todos__ByStatus_route_renderer.res +++ b/examples/express/src/routes/Root__Todos__ByStatus_route_renderer.res @@ -1,8 +1,8 @@ -let renderer = Routes.Root.Todos.ByStatus.Route.makeRenderer( - ~prepare=_props => { +let renderer: Routes.Root.Todos.ByStatus.Route.routeRenderer<'prepared> = { + prepare: _props => { () }, - ~render=_props => { + render: _props => { React.null }, -) +} diff --git a/examples/express/src/routes/Root__Todos__Single_route_renderer.res b/examples/express/src/routes/Root__Todos__Single_route_renderer.res index 388b6ff..e267c53 100644 --- a/examples/express/src/routes/Root__Todos__Single_route_renderer.res +++ b/examples/express/src/routes/Root__Todos__Single_route_renderer.res @@ -1,5 +1,5 @@ -let renderer = Routes.Root.Todos.Single.Route.makeRenderer( - ~prepare=({environment, showMore, todoId}) => { +let renderer: Routes.Root.Todos.Single.Route.routeRenderer<'prepared> = { + prepare: ({environment, params: {showMore, todoId}}) => { SingleTodoQuery_graphql.load( ~environment, ~fetchPolicy=StoreOrNetwork, @@ -9,7 +9,7 @@ let renderer = Routes.Root.Todos.Single.Route.makeRenderer( }, ) }, - ~render=({prepared}) => { + render: ({prepared}) => { }, -) +} diff --git a/examples/express/src/routes/Root__Todos_route_renderer.res b/examples/express/src/routes/Root__Todos_route_renderer.res index 2d9ca07..22a9c9c 100644 --- a/examples/express/src/routes/Root__Todos_route_renderer.res +++ b/examples/express/src/routes/Root__Todos_route_renderer.res @@ -1,8 +1,8 @@ -let renderer = Route__Root__Todos_route.makeRenderer( - ~prepare=({environment}) => { +let renderer: Routes.Root.Todos.Route.routeRenderer<'prepared> = { + prepare: ({environment}) => { TodosListQuery_graphql.load(~environment, ~fetchPolicy=StoreOrNetwork, ~variables=()) }, - ~render=({prepared, childRoutes}) => { + render: ({prepared, childRoutes}) => { {childRoutes} }, -) +} diff --git a/examples/express/src/routes/Root_route_renderer.res b/examples/express/src/routes/Root_route_renderer.res index 8f3de6c..09b8b57 100644 --- a/examples/express/src/routes/Root_route_renderer.res +++ b/examples/express/src/routes/Root_route_renderer.res @@ -1,8 +1,8 @@ -let renderer = Route__Root_route.makeRenderer( - ~prepare=({environment}) => { +let renderer: Routes.Root.Route.routeRenderer<'prepared> = { + prepare: ({environment}) => { LayoutQuery_graphql.load(~environment, ~variables=(), ~fetchPolicy=StoreOrNetwork) }, - ~render=props => { + render: props => { {props.childRoutes} }, -) +} diff --git a/examples/express/src/routes/__generated__/RouteDeclarations.res b/examples/express/src/routes/__generated__/RouteDeclarations.res index 5ad1d7d..90457bd 100644 --- a/examples/express/src/routes/__generated__/RouteDeclarations.res +++ b/examples/express/src/routes/__generated__/RouteDeclarations.res @@ -1,8 +1,6 @@ open RelayRouter__Internal__DeclarationsSupport -external unsafe_toPrepareProps: 'any => prepareProps = "%identity" - let loadedRouteRenderers: Belt.HashMap.String.t = Belt.HashMap.String.make( ~hintSize=4, ) @@ -13,20 +11,23 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { ignore(pathParams) ignore(queryParams) let prepareProps: Route__Root_route.Internal.prepareProps = { environment: environment, location: location, + + params: { } + } prepareProps->unsafe_toPrepareProps } @@ -82,20 +83,23 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root__Todos_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { ignore(pathParams) let prepareProps: Route__Root__Todos_route.Internal.prepareProps = { environment: environment, location: location, + + params: { statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } + } prepareProps->unsafe_toPrepareProps } @@ -150,20 +154,23 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root__Todos__ByStatus_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__ByStatus_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { let prepareProps: Route__Root__Todos__ByStatus_route.Internal.prepareProps = { environment: environment, location: location, + + params: { byStatus: pathParams->Js.Dict.unsafeGet("byStatus")->Obj.magic, statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } + } prepareProps->unsafe_toPrepareProps } @@ -220,17 +227,19 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array (() => Js.import(Root__Todos__Single_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__Single_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ) => { let prepareProps: Route__Root__Todos__Single_route.Internal.prepareProps = { environment: environment, location: location, + + params: { todoId: pathParams->Js.Dict.unsafeGet("todoId"), statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), showMore: queryParams->RelayRouter.Bindings.QueryParams.getParamByKey("showMore")->Belt.Option.flatMap(value => switch value { @@ -239,6 +248,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array None }), } + } prepareProps->unsafe_toPrepareProps } diff --git a/examples/express/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res b/examples/express/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res index 214b1cd..d2fca3a 100644 --- a/examples/express/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res +++ b/examples/express/src/routes/__generated__/Route__Root__Todos__ByStatus_route.res @@ -2,44 +2,32 @@ // This file is autogenerated from `todoRoutes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { byStatus: [#completed | #notCompleted], statuses: option>, } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - byStatus: [#completed | #notCompleted], - statuses: option>, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { { environment: environment, location: location, + + params: { byStatus: pathParams->Js.Dict.unsafeGet("byStatus")->Obj.magic, statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } } + } } @@ -175,9 +163,4 @@ let useIsRouteActive = (~exact=false) => { React.useMemo2(() => location->isRouteActive(~exact), (location, exact)) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/examples/express/src/routes/__generated__/Route__Root__Todos__Single_route.res b/examples/express/src/routes/__generated__/Route__Root__Todos__Single_route.res index 4ad6c7a..e9bc4f7 100644 --- a/examples/express/src/routes/__generated__/Route__Root__Todos__Single_route.res +++ b/examples/express/src/routes/__generated__/Route__Root__Todos__Single_route.res @@ -2,42 +2,28 @@ // This file is autogenerated from `todoRoutes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { todoId: string, statuses: option>, showMore: option, } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - todoId: string, - statuses: option>, - showMore: option, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { { environment: environment, location: location, + + params: { todoId: pathParams->Js.Dict.unsafeGet("todoId"), statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), showMore: queryParams->RelayRouter.Bindings.QueryParams.getParamByKey("showMore")->Belt.Option.flatMap(value => switch value { @@ -47,6 +33,7 @@ module Internal = { }), } } + } } @@ -194,9 +181,4 @@ let useIsRouteActive = (~exact=false) => { React.useMemo2(() => location->isRouteActive(~exact), (location, exact)) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/examples/express/src/routes/__generated__/Route__Root__Todos_route.res b/examples/express/src/routes/__generated__/Route__Root__Todos_route.res index 69c2246..6043019 100644 --- a/examples/express/src/routes/__generated__/Route__Root__Todos_route.res +++ b/examples/express/src/routes/__generated__/Route__Root__Todos_route.res @@ -2,42 +2,31 @@ // This file is autogenerated from `todoRoutes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { statuses: option>, } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - statuses: option>, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { ignore(pathParams) { environment: environment, location: location, + + params: { statuses: queryParams->RelayRouter.Bindings.QueryParams.getArrayParamByKey("statuses")->Belt.Option.map(value => value->Belt.Array.keepMap(value => value->Js.Global.decodeURIComponent->TodoStatus.parse)), } } + } } @@ -192,9 +181,4 @@ let useActiveSubRoute = (): option<[#ByStatus | #Single]> => { }, [location]) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/examples/express/src/routes/__generated__/Route__Root_route.res b/examples/express/src/routes/__generated__/Route__Root_route.res index c069fa0..4d5247e 100644 --- a/examples/express/src/routes/__generated__/Route__Root_route.res +++ b/examples/express/src/routes/__generated__/Route__Root_route.res @@ -2,40 +2,30 @@ // This file is autogenerated from `routes.json`, do not edit manually. module Internal = { @live - type prepareProps = { - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, + type params = { } @live - type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared, - environment: RescriptRelay.Environment.t, - location: RelayRouter.History.location, - } + type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps - @live - type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } @live let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, - ): prepareProps => { + ): prepareProps => { ignore(pathParams) ignore(queryParams) { environment: environment, location: location, + + params: { } } + } } @@ -80,9 +70,4 @@ let useActiveSubRoute = (): option<[#Todos]> => { }, [location]) } -@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = "" \ No newline at end of file + type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t diff --git a/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res b/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res index f6ec28e..3e0e9a6 100644 --- a/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res +++ b/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res @@ -328,8 +328,7 @@ let getRouteParamRecordFields = (route: printableRoute) => { )) }) - let recordFields = - standardRecordFields->Array.concatMany([pathParamsRecordFields, queryParamsRecordFields]) + let recordFields = Array.concat(pathParamsRecordFields, queryParamsRecordFields) { pathParamsRecordFields, @@ -349,12 +348,17 @@ let getMakePrepareProps = (route: printableRoute, ~returnMode) => { let hasQueryParams = route.queryParams->Dict.keysToArray->Array.length > 0 let params = route.params - let str = ref(`(. + let str = ref( + `(. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter.History.location, -): prepareProps => {\n`) +)${switch returnMode { + | ForInlinedRouteFn => "" + | ForDedicatedRouteFile => ": prepareProps" + }} => {\n`, + ) let propsToIgnore = [ params->Array.length === 0 ? Some("pathParams") : None, @@ -378,8 +382,8 @@ let getMakePrepareProps = (route: printableRoute, ~returnMode) => { str.contents = str.contents ++ " { environment: environment,\n - location: location,\n" - + location: location,\n + params: {\n" params->Array.forEach(param => { str.contents = str.contents ++ @@ -407,7 +411,7 @@ let getMakePrepareProps = (route: printableRoute, ~returnMode) => { }) } - str.contents = str.contents ++ " }\n" + str.contents = str.contents ++ " }\n}\n" if returnMode == ForInlinedRouteFn { str.contents = str.contents ++ ` prepareProps->unsafe_toPrepareProps\n` @@ -455,7 +459,7 @@ ${queryParamsRecordFields } let getPrepareTypeDefinitions = (route: printableRoute) => { - let str = ref(` @live\n type prepareProps = {\n`) + let str = ref(` @live\n type params = {\n`) let {allRecordFields: recordFields} = getRouteParamRecordFields(route) @@ -466,23 +470,7 @@ let getPrepareTypeDefinitions = (route: printableRoute) => { str.contents = str.contents ++ " }\n\n" str.contents = - str.contents ++ ` @live\n type renderProps<'prepared> = { - childRoutes: React.element, - prepared: 'prepared,\n` - - recordFields->Array.forEach(((key, typ)) => { - str.contents = str.contents ++ ` ${key}: ${typ},\n` - }) - - str.contents = str.contents ++ " }\n\n" - - str.contents = - str.contents ++ ` @live\n type renderers<'prepared> = { - prepare: prepareProps => 'prepared, - prepareCode: option<(. prepareProps) => array>, - render: renderProps<'prepared> => React.element, - } -` + str.contents ++ " @live\n type prepareProps = RelayRouter__Internal__DeclarationsSupport.prepareProps\n\n" str.contents = str.contents ++ @@ -501,12 +489,7 @@ let getPrepareAssets = () => { let str = ref("") str.contents = - str.contents ++ `@obj -external makeRenderer: ( - ~prepare: Internal.prepareProps => 'prepared, - ~prepareCode: Internal.prepareProps => array=?, - ~render: Internal.renderProps<'prepared> => React.element, -) => Internal.renderers<'prepared> = ""` + str.contents ++ " type routeRenderer<'prepared> = RelayRouter__Internal__DeclarationsSupport.RouteRenderer.t\n" str.contents } @@ -520,7 +503,7 @@ let rec getRouteDefinition = (route: printableRoute, ~indentation): string => { let str = `{ let routeName = "${routeName}" - let loadRouteRenderer = () => (() => Js.import(${routeName}_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(${routeName}_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = ${route->getMakePrepareProps(~returnMode=ForInlinedRouteFn)} { diff --git a/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Commands.res b/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Commands.res index c11c7d7..94de65d 100644 --- a/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Commands.res +++ b/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Commands.res @@ -44,15 +44,14 @@ let scaffoldRouteRenderers = (~deleteRemoved, ~config) => { Fs.writeFileIfChanged( Utils.pathInRoutesFolder(~config, ~fileName=Utils.toRendererFileName(routeName)), - `let renderer = Routes.${route.name->Types.RouteName.getFullRouteAccessPath}.makeRenderer( - ~prepare=props => { + `let renderer: Routes.${route.name->Types.RouteName.getFullRouteAccessPath}.routeRenderer<'prepared> = { + prepare: props => { () }, - ~render=props => { + render: props => { React.null }, - (), -)`, +}`, ) Console.log("Added \"" ++ Utils.toRendererFileName(routeName) ++ "\"") @@ -135,8 +134,6 @@ let generateRoutes = (~scaffoldAfter, ~deleteRemoved, ~config) => { let fileContents = ` open RelayRouter__Internal__DeclarationsSupport -external unsafe_toPrepareProps: 'any => prepareProps = "%identity" - let loadedRouteRenderers: Belt.HashMap.String.t = Belt.HashMap.String.make( ~hintSize=${routeNamesEntries->Array.length->Int.toString}, ) diff --git a/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.res b/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.res index de2dc55..7b2efe4 100644 --- a/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.res +++ b/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.res @@ -2,33 +2,39 @@ exception Route_loading_failed(string) -type prepareProps -type prepared -type renderProps - -// This works because the render props for a route is always the prepared props -// + prepared + childRoutes. If that changes, this will also need to change -// accordingly. -@val -external unsafe_createRenderProps: ( - {"prepared": prepared}, - {"childRoutes": React.element}, - prepareProps, -) => renderProps = "Object.assign" +type prepareProps<'params> = { + environment: RescriptRelay.Environment.t, + location: RelayRouter.History.location, + params: 'params, +} + +type renderProps<'params, 'prepared> = { + childRoutes: React.element, + prepared: 'prepared, + environment: RescriptRelay.Environment.t, + location: RelayRouter.History.location, + params: 'params, +} module RouteRenderer = { - type t = { - prepareCode: option array>, - prepare: prepareProps => prepared, - render: renderProps => React.element, + type t<'params, 'prepared> = { + prepare: prepareProps<'params> => 'prepared, + prepareCode?: prepareProps<'params> => array, + render: renderProps<'params, 'prepared> => React.element, } } +@unboxed type rec routeRenderer = RouteRenderer(RouteRenderer.t<'params, 'prepared>): routeRenderer + +type opaquePrepareProps + +external unsafe_toPrepareProps: prepareProps<'a> => prepareProps<'b> = "%identity" + // This holder makes it easy to suspend (throwing the promise) or synchronously // return the loaded thing once availabile. type suspenseEnabledHolder<'thing> = NotInitiated | Pending(promise<'thing>) | Loaded('thing) -type loadedRouteRenderer = suspenseEnabledHolder +type loadedRouteRenderer = suspenseEnabledHolder // This holds meta data for a route that has been prepared. type preparedContainer = { @@ -37,19 +43,19 @@ type preparedContainer = { mutable timeout: option, } -type makePrepareProps = ( +type makePrepareProps<'params> = ( ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter__History.location, -) => prepareProps +) => prepareProps<'params> let doLoadRouteRenderer = ( - loadFn: unit => promise, + loadFn: unit => promise>, ~routeName, - ~loadedRouteRenderers, + ~loadedRouteRenderers: Belt.HashMap.String.t, ) => { - let promise = loadFn() + let promise = loadFn()->Promise.thenResolve(p => RouteRenderer(p)) loadedRouteRenderers->Belt.HashMap.String.set(routeName, Pending(promise)) promise->(Js.Promise.then_(routeRenderer => { @@ -58,10 +64,13 @@ let doLoadRouteRenderer = ( }, _)) } +external opaqueRouteRenderer: RouteRenderer.t<'a, 'b> => RouteRenderer.t<'c, 'd> = "%identity" +let unwrapRouteRenderer = (RouteRenderer(routeRenderer)) => opaqueRouteRenderer(routeRenderer) + // This does a bunch of suspense/React gymnastics for kicking off code // preloading for a matched route.. let preloadCode = ( - ~loadedRouteRenderers, + ~loadedRouteRenderers: Belt.HashMap.String.t, ~routeName, ~loadRouteRenderer, ~makePrepareProps, @@ -70,10 +79,10 @@ let preloadCode = ( ~queryParams, ~location, ) => { - let apply = (routeRenderer: RouteRenderer.t) => { + let apply = (routeRenderer: routeRenderer) => { let preparedProps = makePrepareProps(~environment, ~pathParams, ~queryParams, ~location) - switch routeRenderer.prepareCode { + switch unwrapRouteRenderer(routeRenderer).prepareCode { | Some(prepareCode) => prepareCode(preparedProps) | None => [] } @@ -101,7 +110,7 @@ let preloadCode = ( } } -type prepareAssets = { +type prepareAssets<'params> = { getPrepared: (~routeKey: Belt.HashMap.String.key) => option, prepareRoute: ( ~environment: RescriptRelay.Environment.t, @@ -113,7 +122,7 @@ type prepareAssets = { ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter__History.location, - ) => prepareProps, + ) => prepareProps<'params>, ~makeRouteKey: ( ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, @@ -126,7 +135,10 @@ type prepareAssets = { } // Creates the assets needed for preparing routes. -let makePrepareAssets = (~loadedRouteRenderers, ~prepareDisposeTimeout): prepareAssets => { +let makePrepareAssets = ( + ~loadedRouteRenderers: Belt.HashMap.String.t, + ~prepareDisposeTimeout, +): prepareAssets<'params> => { let preparedMap: Belt.HashMap.String.t = Belt.HashMap.String.make(~hintSize=3) let getPrepared = (~routeKey) => preparedMap->Belt.HashMap.String.get(routeKey) @@ -226,7 +238,7 @@ let makePrepareAssets = (~loadedRouteRenderers, ~prepareDisposeTimeout): prepare ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter__History.location, - ) => prepareProps, + ) => prepareProps<'params>, ~makeRouteKey: ( ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, @@ -267,9 +279,10 @@ let makePrepareAssets = (~loadedRouteRenderers, ~prepareDisposeTimeout): prepare | (Some(_), Render) | // Same goes if we had no previous prepare, do a fresh instantiation. (None, _) => - let preparedRef: ref> = ref(NotInitiated) + let preparedRef: ref> = ref(NotInitiated) - let doPrepare = (routeRenderer: RouteRenderer.t) => { + let doPrepare = routeRenderer => { + let routeRenderer = unwrapRouteRenderer(routeRenderer) switch routeRenderer.prepareCode { | Some(prepareCode) => let _ = prepareCode(preparedProps) @@ -342,13 +355,14 @@ let makePrepareAssets = (~loadedRouteRenderers, ~prepareDisposeTimeout): prepare suspend(promise) React.null | (Some(Loaded(routeRenderer)), Loaded(prepared)) => - routeRenderer.render( - unsafe_createRenderProps( - {"prepared": prepared}, - {"childRoutes": childRoutes}, - preparedProps, - ), - ) + let routeRenderer = unwrapRouteRenderer(routeRenderer) + routeRenderer.render({ + childRoutes, + prepared, + environment: preparedProps.environment, + location: preparedProps.location, + params: preparedProps.params, + }) | _ => Js.log("Warning: Invalid state") React.null diff --git a/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.resi b/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.resi index 95d7552..20ad6c1 100644 --- a/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.resi +++ b/packages/rescript-relay-router/src/RelayRouter__Internal__DeclarationsSupport.resi @@ -1,12 +1,34 @@ -type prepareProps +type prepareProps<'params> = { + environment: RescriptRelay.Environment.t, + location: RelayRouter.History.location, + params: 'params, +} + +type renderProps<'params, 'prepared> = { + childRoutes: React.element, + prepared: 'prepared, + environment: RescriptRelay.Environment.t, + location: RelayRouter.History.location, + params: 'params, +} module RouteRenderer: { - type t + type t<'params, 'prepared> = { + prepare: prepareProps<'params> => 'prepared, + prepareCode?: prepareProps<'params> => array, + render: renderProps<'params, 'prepared> => React.element, + } } +@unboxed type rec routeRenderer = RouteRenderer(RouteRenderer.t<'params, 'prepared>): routeRenderer + +type opaquePrepareProps + +external unsafe_toPrepareProps: prepareProps<'a> => prepareProps<'b> = "%identity" + type suspenseEnabledHolder<'thing> = NotInitiated | Pending(promise<'thing>) | Loaded('thing) -type loadedRouteRenderer = suspenseEnabledHolder +type loadedRouteRenderer = suspenseEnabledHolder type preparedContainer = { disposables: array unit>, @@ -14,31 +36,31 @@ type preparedContainer = { mutable timeout: option, } -type makePrepareProps = ( +type makePrepareProps<'params> = ( ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter__History.location, -) => prepareProps +) => prepareProps<'params> let doLoadRouteRenderer: ( - unit => promise, + unit => promise>, ~routeName: Belt.HashMap.String.key, - ~loadedRouteRenderers: Belt.HashMap.String.t>, + ~loadedRouteRenderers: Belt.HashMap.String.t, ) => promise let preloadCode: ( - ~loadedRouteRenderers: Belt.HashMap.String.t>, + ~loadedRouteRenderers: Belt.HashMap.String.t, ~routeName: Belt.HashMap.String.key, ~loadRouteRenderer: unit => promise, - ~makePrepareProps: makePrepareProps, + ~makePrepareProps: makePrepareProps<'params>, ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter__History.location, ) => promise> -type prepareAssets = { +type prepareAssets<'params> = { getPrepared: (~routeKey: Belt.HashMap.String.key) => option, prepareRoute: ( ~environment: RescriptRelay.Environment.t, @@ -50,7 +72,7 @@ type prepareAssets = { ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, ~location: RelayRouter__History.location, - ) => prepareProps, + ) => prepareProps<'params>, ~makeRouteKey: ( ~pathParams: Js.Dict.t, ~queryParams: RelayRouter.Bindings.QueryParams.t, @@ -63,6 +85,6 @@ type prepareAssets = { } let makePrepareAssets: ( - ~loadedRouteRenderers: Belt.HashMap.String.t>, + ~loadedRouteRenderers: Belt.HashMap.String.t, ~prepareDisposeTimeout: int, -) => prepareAssets +) => prepareAssets<'params>