mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-24 06:54:03 +03:00
Send manifest config through port.
This commit is contained in:
parent
17997d7ea0
commit
789cc59d88
@ -27,6 +27,7 @@
|
||||
"lukewestby/elm-string-interpolate": "1.0.4",
|
||||
"mdgriffith/elm-markup": "3.0.1",
|
||||
"mdgriffith/elm-ui": "1.1.5",
|
||||
"miniBill/elm-codec": "1.2.0",
|
||||
"noahzgordon/elm-color-extra": "1.0.2",
|
||||
"rtfeldman/elm-hex": "1.0.0"
|
||||
},
|
||||
@ -47,4 +48,4 @@
|
||||
"elm/random": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,13 @@ function runElm(callback) {
|
||||
|
||||
app.ports.toJsPort.subscribe(payload => {
|
||||
process.chdir(startingDir);
|
||||
callback(payload);
|
||||
|
||||
if (payload.tag === "Success") {
|
||||
callback(payload.args[0]);
|
||||
} else {
|
||||
console.log("ERROR bad payload", payload);
|
||||
process.exit(1);
|
||||
}
|
||||
delete Elm;
|
||||
console.warn = warnOriginal;
|
||||
});
|
||||
|
@ -25,6 +25,7 @@ import Json.Encode
|
||||
import Mark
|
||||
import Pages.ContentCache as ContentCache exposing (ContentCache)
|
||||
import Pages.Document
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.Manifest as Manifest
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
@ -32,17 +33,18 @@ import Pages.StaticHttpRequest as StaticHttpRequest
|
||||
import Url exposing (Url)
|
||||
|
||||
|
||||
type ToJsPayload
|
||||
type ToJsPayload pathKey
|
||||
= Errors (Dict String String)
|
||||
| Success ToJsSuccessPayload
|
||||
| Success (ToJsSuccessPayload pathKey)
|
||||
|
||||
|
||||
type alias ToJsSuccessPayload =
|
||||
type alias ToJsSuccessPayload pathKey =
|
||||
{ pages : Dict String (Dict String String)
|
||||
, manifest : Manifest.Config pathKey
|
||||
}
|
||||
|
||||
|
||||
toJsCodec : Codec ToJsPayload
|
||||
toJsCodec : Codec (ToJsPayload pathKey)
|
||||
toJsCodec =
|
||||
Codec.custom
|
||||
(\errors success value ->
|
||||
@ -50,8 +52,8 @@ toJsCodec =
|
||||
Errors errorList ->
|
||||
errors errorList
|
||||
|
||||
Success { pages } ->
|
||||
success (ToJsSuccessPayload pages)
|
||||
Success { pages, manifest } ->
|
||||
success (ToJsSuccessPayload pages manifest)
|
||||
)
|
||||
|> Codec.variant1 "Errors" Errors (Codec.dict Codec.string)
|
||||
|> Codec.variant1 "Success"
|
||||
@ -60,20 +62,39 @@ toJsCodec =
|
||||
|> Codec.buildCustom
|
||||
|
||||
|
||||
successCodec : Codec ToJsSuccessPayload
|
||||
stubManifest : Manifest.Config pathKey
|
||||
stubManifest =
|
||||
{ backgroundColor = Nothing
|
||||
, categories = []
|
||||
, displayMode = Manifest.Standalone
|
||||
, orientation = Manifest.Portrait
|
||||
, description = "elm-pages - A statically typed site generator."
|
||||
, iarcRatingId = Nothing
|
||||
, name = "elm-pages docs"
|
||||
, themeColor = Nothing
|
||||
, startUrl = PagePath.external ""
|
||||
, shortName = Just "elm-pages"
|
||||
, sourceIcon = ImagePath.external ""
|
||||
}
|
||||
|
||||
|
||||
successCodec : Codec (ToJsSuccessPayload pathKey)
|
||||
successCodec =
|
||||
Codec.object ToJsSuccessPayload
|
||||
|> Codec.field "pages"
|
||||
(\{ pages } -> pages)
|
||||
.pages
|
||||
(Codec.dict (Codec.dict Codec.string))
|
||||
|> Codec.field "manifest"
|
||||
.manifest
|
||||
(Codec.build Manifest.toJson (Decode.succeed stubManifest))
|
||||
|> Codec.buildObject
|
||||
|
||||
|
||||
type Effect
|
||||
type Effect pathKey
|
||||
= NoEffect
|
||||
| SendJsData ToJsPayload
|
||||
| SendJsData (ToJsPayload pathKey)
|
||||
| FetchHttp StaticHttp.Request
|
||||
| Batch (List Effect)
|
||||
| Batch (List (Effect pathKey))
|
||||
|
||||
|
||||
type alias Page metadata view pathKey =
|
||||
@ -188,7 +209,7 @@ cliApplication cliMsgConstructor narrowMsg toModel fromModel config =
|
||||
}
|
||||
|
||||
|
||||
perform : (Msg -> msg) -> (Json.Encode.Value -> Cmd Never) -> Effect -> Cmd msg
|
||||
perform : (Msg -> msg) -> (Json.Encode.Value -> Cmd Never) -> Effect pathKey -> Cmd msg
|
||||
perform cliMsgConstructor toJsPort effect =
|
||||
case effect of
|
||||
NoEffect ->
|
||||
@ -326,7 +347,12 @@ update siteMetadata config msg model =
|
||||
in
|
||||
( model
|
||||
, SendJsData
|
||||
(Success (encodeStaticResponses staticResponses |> ToJsSuccessPayload))
|
||||
(Success
|
||||
(ToJsSuccessPayload
|
||||
(encodeStaticResponses staticResponses)
|
||||
config.manifest
|
||||
)
|
||||
)
|
||||
-- (Json.Encode.object
|
||||
-- [ ( "manifest", Manifest.toJson config.manifest )
|
||||
-- , ( "pages", encodeStaticResponses staticResponses )
|
||||
@ -335,7 +361,7 @@ update siteMetadata config msg model =
|
||||
)
|
||||
|
||||
|
||||
performStaticHttpRequests : List ( PagePath pathKey, ( StaticHttp.Request, Decode.Value -> Result error value ) ) -> Effect
|
||||
performStaticHttpRequests : List ( PagePath pathKey, ( StaticHttp.Request, Decode.Value -> Result error value ) ) -> Effect pathKey
|
||||
performStaticHttpRequests staticRequests =
|
||||
-- @@@@@@@@ TODO
|
||||
-- NoEffect
|
||||
|
@ -43,13 +43,14 @@ all =
|
||||
]
|
||||
)
|
||||
]
|
||||
, manifest = manifest
|
||||
}
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
start : ProgramTest Main.Model Main.Msg Main.Effect
|
||||
start : ProgramTest Main.Model Main.Msg (Main.Effect PathKey)
|
||||
start =
|
||||
let
|
||||
document =
|
||||
@ -114,7 +115,7 @@ start =
|
||||
|> ProgramTest.start ()
|
||||
|
||||
|
||||
simulateEffects : Main.Effect -> ProgramTest.SimulatedEffect Main.Msg
|
||||
simulateEffects : Main.Effect PathKey -> ProgramTest.SimulatedEffect Main.Msg
|
||||
simulateEffects effect =
|
||||
case effect of
|
||||
NoEffect ->
|
||||
@ -161,7 +162,7 @@ manifest =
|
||||
, iarcRatingId = Nothing
|
||||
, name = "elm-pages docs"
|
||||
, themeColor = Nothing
|
||||
, startUrl = PagePath.build PathKey []
|
||||
, startUrl = PagePath.external ""
|
||||
, shortName = Just "elm-pages"
|
||||
, sourceIcon = ImagePath.build PathKey []
|
||||
, sourceIcon = ImagePath.external ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user