Fix renderer code error.

This commit is contained in:
Dillon Kearns 2023-01-06 10:34:57 -08:00
parent 9db4a351c4
commit 7b4aafa03e
3 changed files with 15 additions and 38 deletions

View File

@ -178,7 +178,8 @@ function runGeneratorAppHelp(
);
}
} else if (fromElm.tag === "DoHttp") {
const requestToPerform = fromElm.args[0];
const requestHash = fromElm.args[0];
const requestToPerform = fromElm.args[1];
if (
requestToPerform.url !== "elm-pages-internal://port" &&
requestToPerform.url.startsWith("elm-pages-internal://")

View File

@ -5,8 +5,7 @@ module BackendTask exposing
, andThen, resolve, combine
, andMap
, map2, map3, map4, map5, map6, map7, map8, map9
, catch, throw, mapError, onError
, toResult
, catch, throw, mapError, onError, toResult
)
{-| In an `elm-pages` app, each Route Module can define a value `data` which is a `BackendTask` that will be resolved **before** `init` is called. That means it is also available
@ -83,11 +82,10 @@ Any place in your `elm-pages` app where the framework lets you pass in a value o
## Exception Handling
@docs catch, throw, mapError, onError
@docs catch, throw, mapError, onError, toResult
-}
import Dict
import Exception exposing (Catchable(..), Throwable)
import Json.Encode
import Pages.StaticHttpRequest exposing (RawRequest(..))

View File

@ -14,7 +14,7 @@ import Dict
import Exception exposing (Throwable)
import HtmlPrinter
import Json.Decode as Decode
import Json.Encode
import Json.Encode as Encode
import Pages.GeneratorProgramConfig exposing (GeneratorProgramConfig)
import Pages.Internal.Platform.CompatibilityKey
import Pages.Internal.Platform.Effect as Effect exposing (Effect)
@ -43,12 +43,7 @@ type alias Model =
{-| -}
type Msg
= GotDataBatch
(List
{ request : Pages.StaticHttp.Request.Request
, response : RequestsAndPending.Response
}
)
= GotDataBatch Decode.Value
| GotBuildError BuildError
@ -118,23 +113,7 @@ app config =
)
|> mergeResult
)
, config.gotBatchSub
|> Sub.map
(\newBatch ->
Decode.decodeValue batchDecoder newBatch
|> Result.map GotDataBatch
|> Result.mapError
(\error ->
("From location 2: "
++ (error
|> Decode.errorToString
)
)
|> BuildError.internal
|> GotBuildError
)
|> mergeResult
)
, config.gotBatchSub |> Sub.map GotDataBatch
]
, config = cliConfig
, printAndExitFailure =
@ -151,7 +130,7 @@ app config =
|> Codec.encodeToValue (ToJsPayload.successCodecNew2 "" "")
|> config.toJsPort
|> Cmd.map never
, printAndExitSuccess = \string -> config.toJsPort (Json.Encode.string string) |> Cmd.map never
, printAndExitSuccess = \string -> config.toJsPort (Encode.string string) |> Cmd.map never
}
@ -216,7 +195,7 @@ perform config effect =
flatten config list
Effect.FetchHttp unmasked ->
ToJsPayload.DoHttp unmasked unmasked.useCache
ToJsPayload.DoHttp (Pages.StaticHttp.Request.hash unmasked) unmasked unmasked.useCache
|> Codec.encoder (ToJsPayload.successCodecNew2 canonicalSiteUrl "")
|> config.toJsPort
|> Cmd.map never
@ -283,7 +262,7 @@ init :
-> ( Model, Effect )
init execute flags =
if flags.compatibilityKey == Pages.Internal.Platform.CompatibilityKey.currentCompatibilityKey then
initLegacy execute { staticHttpCache = Dict.empty }
initLegacy execute
else
let
@ -310,16 +289,15 @@ init execute flags =
, path = ""
}
]
, allRawResponses = Dict.empty
, allRawResponses = Encode.object []
, done = False
}
initLegacy :
BackendTask Throwable ()
-> { staticHttpCache : RequestsAndPending }
-> ( Model, Effect )
initLegacy execute { staticHttpCache } =
initLegacy execute =
let
staticResponses : BackendTask Throwable ()
staticResponses =
@ -329,7 +307,7 @@ initLegacy execute { staticHttpCache } =
initialModel =
{ staticResponses = staticResponses
, errors = []
, allRawResponses = staticHttpCache
, allRawResponses = Encode.object []
, done = False
}
in
@ -390,7 +368,7 @@ nextStepToEffect model nextStep =
updatedModel : Model
updatedModel =
{ model
| allRawResponses = Dict.empty
| allRawResponses = Encode.object []
, staticResponses = updatedStaticResponsesModel
}
in
@ -411,7 +389,7 @@ nextStepToEffect model nextStep =
StaticResponses.Finish () ->
( model
, { body = Json.Encode.null
, { body = Encode.null
, staticHttpCache = Dict.empty
, statusCode = 200
}