elm-pages 3.0.0-beta.15 → 3.0.0-beta.16
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.
- package/README.md +1 -1
- package/codegen/elm-pages-codegen.js +66 -115
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +20 -20
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +5 -5
- package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +21 -21
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/src/RouteBuilder.elm +23 -23
- package/generator/src/SharedTemplate.elm +2 -2
- package/generator/src/SiteConfig.elm +2 -2
- package/generator/src/cli.js +2 -2
- package/generator/src/compatibility-key.js +1 -1
- package/generator/src/render.js +5 -5
- package/package.json +1 -1
- package/src/ApiRoute.elm +13 -13
- package/src/BackendTask/Env.elm +9 -8
- package/src/BackendTask/File.elm +49 -10
- package/src/BackendTask/Glob.elm +6 -6
- package/src/BackendTask/Http.elm +12 -12
- package/src/BackendTask/Port.elm +22 -14
- package/src/BackendTask.elm +8 -22
- package/src/{Exception.elm → FatalError.elm} +37 -31
- package/src/Form.elm +3 -3
- package/src/Internal/ApiRoute.elm +5 -5
- package/src/Pages/Generate.elm +1 -1
- package/src/Pages/Internal/FatalError.elm +5 -0
- package/src/Pages/Internal/Platform/Cli.elm +4 -4
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +7 -7
- package/src/Pages/Internal/Platform/StaticResponses.elm +10 -9
- package/src/Pages/Internal/Script.elm +2 -2
- package/src/Pages/Manifest.elm +2 -2
- package/src/Pages/ProgramConfig.elm +7 -7
- package/src/Pages/Script.elm +4 -4
- package/src/Pages/SiteConfig.elm +2 -2
- package/src/Server/Request.elm +3 -3
|
@@ -12,7 +12,7 @@ import Bytes exposing (Bytes)
|
|
|
12
12
|
import Bytes.Encode
|
|
13
13
|
import Codec
|
|
14
14
|
import Dict
|
|
15
|
-
import
|
|
15
|
+
import FatalError exposing (FatalError)
|
|
16
16
|
import Head exposing (Tag)
|
|
17
17
|
import Html exposing (Html)
|
|
18
18
|
import HtmlPrinter
|
|
@@ -51,7 +51,7 @@ currentCompatibilityKey =
|
|
|
51
51
|
|
|
52
52
|
{-| -}
|
|
53
53
|
type alias Model route =
|
|
54
|
-
{ staticResponses : BackendTask
|
|
54
|
+
{ staticResponses : BackendTask FatalError Effect
|
|
55
55
|
, errors : List BuildError
|
|
56
56
|
, maybeRequestJson : RenderRequest route
|
|
57
57
|
, isDevServer : Bool
|
|
@@ -376,11 +376,11 @@ initLegacy :
|
|
|
376
376
|
-> ( Model route, Effect )
|
|
377
377
|
initLegacy site ((RenderRequest.SinglePage includeHtml singleRequest _) as renderRequest) { isDevServer } config =
|
|
378
378
|
let
|
|
379
|
-
globalHeadTags : BackendTask
|
|
379
|
+
globalHeadTags : BackendTask FatalError (List Tag)
|
|
380
380
|
globalHeadTags =
|
|
381
381
|
(config.globalHeadTags |> Maybe.withDefault (\_ -> BackendTask.succeed [])) HtmlPrinter.htmlToString
|
|
382
382
|
|
|
383
|
-
staticResponsesNew : BackendTask
|
|
383
|
+
staticResponsesNew : BackendTask FatalError Effect
|
|
384
384
|
staticResponsesNew =
|
|
385
385
|
StaticResponses.renderApiRequest
|
|
386
386
|
(case singleRequest of
|
|
@@ -11,7 +11,7 @@ import BuildError exposing (BuildError)
|
|
|
11
11
|
import Cli.Program as Program exposing (FlagsIncludingArgv)
|
|
12
12
|
import Codec
|
|
13
13
|
import Dict
|
|
14
|
-
import
|
|
14
|
+
import FatalError exposing (FatalError)
|
|
15
15
|
import HtmlPrinter
|
|
16
16
|
import Json.Decode as Decode
|
|
17
17
|
import Json.Encode as Encode
|
|
@@ -33,7 +33,7 @@ type alias Flags =
|
|
|
33
33
|
|
|
34
34
|
{-| -}
|
|
35
35
|
type alias Model =
|
|
36
|
-
{ staticResponses : BackendTask
|
|
36
|
+
{ staticResponses : BackendTask FatalError ()
|
|
37
37
|
, errors : List BuildError
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -47,10 +47,10 @@ type Msg
|
|
|
47
47
|
{-| -}
|
|
48
48
|
app :
|
|
49
49
|
GeneratorProgramConfig
|
|
50
|
-
-> Program.StatefulProgram Model Msg (BackendTask
|
|
50
|
+
-> Program.StatefulProgram Model Msg (BackendTask FatalError ()) Flags
|
|
51
51
|
app config =
|
|
52
52
|
let
|
|
53
|
-
cliConfig : Program.Config (BackendTask
|
|
53
|
+
cliConfig : Program.Config (BackendTask FatalError ())
|
|
54
54
|
cliConfig =
|
|
55
55
|
case config.data of
|
|
56
56
|
Pages.Internal.Script.Script theCliConfig ->
|
|
@@ -246,7 +246,7 @@ perform config effect =
|
|
|
246
246
|
|
|
247
247
|
{-| -}
|
|
248
248
|
init :
|
|
249
|
-
BackendTask
|
|
249
|
+
BackendTask FatalError ()
|
|
250
250
|
-> FlagsIncludingArgv Flags
|
|
251
251
|
-> ( Model, Effect )
|
|
252
252
|
init execute flags =
|
|
@@ -282,11 +282,11 @@ init execute flags =
|
|
|
282
282
|
|
|
283
283
|
|
|
284
284
|
initLegacy :
|
|
285
|
-
BackendTask
|
|
285
|
+
BackendTask FatalError ()
|
|
286
286
|
-> ( Model, Effect )
|
|
287
287
|
initLegacy execute =
|
|
288
288
|
let
|
|
289
|
-
staticResponses : BackendTask
|
|
289
|
+
staticResponses : BackendTask FatalError ()
|
|
290
290
|
staticResponses =
|
|
291
291
|
StaticResponses.renderApiRequest execute
|
|
292
292
|
|
|
@@ -2,35 +2,36 @@ module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), empty, ne
|
|
|
2
2
|
|
|
3
3
|
import BackendTask exposing (BackendTask)
|
|
4
4
|
import BuildError exposing (BuildError)
|
|
5
|
-
import
|
|
5
|
+
import FatalError exposing (FatalError, Recoverable)
|
|
6
6
|
import List.Extra
|
|
7
|
+
import Pages.Internal.FatalError
|
|
7
8
|
import Pages.StaticHttp.Request as HashRequest
|
|
8
9
|
import Pages.StaticHttpRequest as StaticHttpRequest
|
|
9
10
|
import RequestsAndPending exposing (RequestsAndPending)
|
|
10
11
|
import TerminalText
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
empty : a -> BackendTask
|
|
14
|
+
empty : a -> BackendTask FatalError a
|
|
14
15
|
empty a =
|
|
15
16
|
BackendTask.succeed a
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
renderApiRequest :
|
|
19
|
-
BackendTask
|
|
20
|
-
-> BackendTask
|
|
20
|
+
BackendTask FatalError response
|
|
21
|
+
-> BackendTask FatalError response
|
|
21
22
|
renderApiRequest request =
|
|
22
23
|
request
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
type NextStep route value
|
|
26
|
-
= Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest
|
|
27
|
+
= Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest FatalError value)
|
|
27
28
|
| Finish value
|
|
28
29
|
| FinishedWithErrors (List BuildError)
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
nextStep :
|
|
32
33
|
RequestsAndPending
|
|
33
|
-
-> BackendTask
|
|
34
|
+
-> BackendTask FatalError a
|
|
34
35
|
->
|
|
35
36
|
{ model
|
|
36
37
|
| errors : List BuildError
|
|
@@ -38,7 +39,7 @@ nextStep :
|
|
|
38
39
|
-> NextStep route a
|
|
39
40
|
nextStep allRawResponses staticResponses { errors } =
|
|
40
41
|
let
|
|
41
|
-
staticRequestsStatus : StaticHttpRequest.Status
|
|
42
|
+
staticRequestsStatus : StaticHttpRequest.Status FatalError a
|
|
42
43
|
staticRequestsStatus =
|
|
43
44
|
allRawResponses
|
|
44
45
|
|> StaticHttpRequest.cacheRequestResolution staticResponses
|
|
@@ -63,7 +64,7 @@ nextStep allRawResponses staticResponses { errors } =
|
|
|
63
64
|
StaticHttpRequest.HasPermanentError _ ->
|
|
64
65
|
( ( False, Nothing )
|
|
65
66
|
, []
|
|
66
|
-
, BackendTask.fail (
|
|
67
|
+
, BackendTask.fail (FatalError.fromString "TODO this shouldn't happen")
|
|
67
68
|
)
|
|
68
69
|
in
|
|
69
70
|
if pendingRequests then
|
|
@@ -111,7 +112,7 @@ nextStep allRawResponses staticResponses { errors } =
|
|
|
111
112
|
Just (Ok completed) ->
|
|
112
113
|
Finish completed
|
|
113
114
|
|
|
114
|
-
Just (Err (
|
|
115
|
+
Just (Err (Pages.Internal.FatalError.FatalError buildError)) ->
|
|
115
116
|
FinishedWithErrors
|
|
116
117
|
[ { title = buildError.title |> String.toUpper
|
|
117
118
|
, path = "" -- TODO include path here
|
|
@@ -2,7 +2,7 @@ module Pages.Internal.Script exposing (Script(..))
|
|
|
2
2
|
|
|
3
3
|
import BackendTask exposing (BackendTask)
|
|
4
4
|
import Cli.Program as Program
|
|
5
|
-
import
|
|
5
|
+
import FatalError exposing (FatalError)
|
|
6
6
|
import Html exposing (Html)
|
|
7
7
|
|
|
8
8
|
|
|
@@ -13,5 +13,5 @@ type Script
|
|
|
13
13
|
-> Html Never
|
|
14
14
|
-> String
|
|
15
15
|
)
|
|
16
|
-
-> Program.Config (BackendTask
|
|
16
|
+
-> Program.Config (BackendTask FatalError ())
|
|
17
17
|
)
|
package/src/Pages/Manifest.elm
CHANGED
|
@@ -68,7 +68,7 @@ import BackendTask exposing (BackendTask)
|
|
|
68
68
|
import Color exposing (Color)
|
|
69
69
|
import Color.Convert
|
|
70
70
|
import Dict exposing (Dict)
|
|
71
|
-
import
|
|
71
|
+
import FatalError exposing (FatalError)
|
|
72
72
|
import Head
|
|
73
73
|
import Json.Encode as Encode
|
|
74
74
|
import LanguageTag exposing (LanguageTag, emptySubtags)
|
|
@@ -345,7 +345,7 @@ nonEmptyList list =
|
|
|
345
345
|
|
|
346
346
|
{-| A generator for Api.elm to include a manifest.json.
|
|
347
347
|
-}
|
|
348
|
-
generator : String -> BackendTask
|
|
348
|
+
generator : String -> BackendTask FatalError Config -> ApiRoute.ApiRoute ApiRoute.Response
|
|
349
349
|
generator canonicalSiteUrl config =
|
|
350
350
|
ApiRoute.succeed
|
|
351
351
|
(config
|
|
@@ -7,7 +7,7 @@ import Bytes exposing (Bytes)
|
|
|
7
7
|
import Bytes.Decode
|
|
8
8
|
import Bytes.Encode
|
|
9
9
|
import Dict exposing (Dict)
|
|
10
|
-
import
|
|
10
|
+
import FatalError exposing (FatalError)
|
|
11
11
|
import Form.FormData exposing (FormData)
|
|
12
12
|
import Head
|
|
13
13
|
import Html exposing (Html)
|
|
@@ -49,9 +49,9 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
|
|
49
49
|
-> ( userModel, effect )
|
|
50
50
|
, update : Pages.FormState.PageFormState -> Dict String (Pages.Transition.FetcherState actionData) -> Maybe Pages.Transition.Transition -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect )
|
|
51
51
|
, subscriptions : route -> Path -> userModel -> Sub userMsg
|
|
52
|
-
, sharedData : BackendTask
|
|
53
|
-
, data : Decode.Value -> route -> BackendTask
|
|
54
|
-
, action : Decode.Value -> route -> BackendTask
|
|
52
|
+
, sharedData : BackendTask FatalError sharedData
|
|
53
|
+
, data : Decode.Value -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
|
|
54
|
+
, action : Decode.Value -> route -> BackendTask FatalError (PageServerResponse actionData errorPage)
|
|
55
55
|
, onActionData : actionData -> Maybe userMsg
|
|
56
56
|
, view :
|
|
57
57
|
Pages.FormState.PageFormState
|
|
@@ -69,8 +69,8 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
|
|
69
69
|
{ view : userModel -> { title : String, body : List (Html (Pages.Msg.Msg userMsg)) }
|
|
70
70
|
, head : List Head.Tag
|
|
71
71
|
}
|
|
72
|
-
, handleRoute : route -> BackendTask
|
|
73
|
-
, getStaticRoutes : BackendTask
|
|
72
|
+
, handleRoute : route -> BackendTask FatalError (Maybe NotFoundReason)
|
|
73
|
+
, getStaticRoutes : BackendTask FatalError (List route)
|
|
74
74
|
, urlToRoute : Url -> route
|
|
75
75
|
, routeToPath : route -> List String
|
|
76
76
|
, site : Maybe SiteConfig
|
|
@@ -102,7 +102,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
|
|
102
102
|
, encodeResponse : ResponseSketch pageData actionData sharedData -> Bytes.Encode.Encoder
|
|
103
103
|
, encodeAction : actionData -> Bytes.Encode.Encoder
|
|
104
104
|
, decodeResponse : Bytes.Decode.Decoder (ResponseSketch pageData actionData sharedData)
|
|
105
|
-
, globalHeadTags : Maybe ((Maybe { indent : Int, newLines : Bool } -> Html Never -> String) -> BackendTask
|
|
105
|
+
, globalHeadTags : Maybe ((Maybe { indent : Int, newLines : Bool } -> Html Never -> String) -> BackendTask FatalError (List Head.Tag))
|
|
106
106
|
, cmdToEffect : Cmd userMsg -> effect
|
|
107
107
|
, perform :
|
|
108
108
|
{ fetchRouteData :
|
package/src/Pages/Script.elm
CHANGED
|
@@ -34,7 +34,7 @@ import BackendTask.Http
|
|
|
34
34
|
import BackendTask.Internal.Request
|
|
35
35
|
import Cli.OptionsParser as OptionsParser
|
|
36
36
|
import Cli.Program as Program
|
|
37
|
-
import
|
|
37
|
+
import FatalError exposing (FatalError, Recoverable)
|
|
38
38
|
import Json.Decode as Decode
|
|
39
39
|
import Json.Encode as Encode
|
|
40
40
|
import Pages.Internal.Script
|
|
@@ -52,7 +52,7 @@ type Error
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
{-| -}
|
|
55
|
-
writeFile : { path : String, body : String } -> BackendTask (
|
|
55
|
+
writeFile : { path : String, body : String } -> BackendTask (Recoverable Error) ()
|
|
56
56
|
writeFile { path, body } =
|
|
57
57
|
BackendTask.Internal.Request.request
|
|
58
58
|
{ name = "write-file"
|
|
@@ -85,7 +85,7 @@ log message =
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
{-| -}
|
|
88
|
-
withoutCliOptions : BackendTask
|
|
88
|
+
withoutCliOptions : BackendTask FatalError () -> Script
|
|
89
89
|
withoutCliOptions execute =
|
|
90
90
|
Pages.Internal.Script.Script
|
|
91
91
|
(\_ ->
|
|
@@ -100,7 +100,7 @@ withoutCliOptions execute =
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
{-| -}
|
|
103
|
-
withCliOptions : Program.Config cliOptions -> (cliOptions -> BackendTask
|
|
103
|
+
withCliOptions : Program.Config cliOptions -> (cliOptions -> BackendTask FatalError ()) -> Script
|
|
104
104
|
withCliOptions config execute =
|
|
105
105
|
Pages.Internal.Script.Script
|
|
106
106
|
(\_ ->
|
package/src/Pages/SiteConfig.elm
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Pages.SiteConfig exposing (SiteConfig)
|
|
2
2
|
|
|
3
3
|
import BackendTask exposing (BackendTask)
|
|
4
|
-
import
|
|
4
|
+
import FatalError exposing (FatalError)
|
|
5
5
|
import Head
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
type alias SiteConfig =
|
|
9
9
|
{ canonicalUrl : String
|
|
10
|
-
, head : BackendTask
|
|
10
|
+
, head : BackendTask FatalError (List Head.Tag)
|
|
11
11
|
}
|
package/src/Server/Request.elm
CHANGED
|
@@ -89,7 +89,7 @@ module Server.Request exposing
|
|
|
89
89
|
import BackendTask exposing (BackendTask)
|
|
90
90
|
import CookieParser
|
|
91
91
|
import Dict exposing (Dict)
|
|
92
|
-
import
|
|
92
|
+
import FatalError exposing (FatalError)
|
|
93
93
|
import Form
|
|
94
94
|
import Form.Validation as Validation
|
|
95
95
|
import FormData
|
|
@@ -882,8 +882,8 @@ fileField_ name =
|
|
|
882
882
|
|
|
883
883
|
{-| -}
|
|
884
884
|
formDataWithServerValidation :
|
|
885
|
-
Form.ServerForms error (BackendTask
|
|
886
|
-
-> Parser (BackendTask
|
|
885
|
+
Form.ServerForms error (BackendTask FatalError (Validation.Validation error combined kind constraints))
|
|
886
|
+
-> Parser (BackendTask FatalError (Result (Form.Response error) ( Form.Response error, combined )))
|
|
887
887
|
formDataWithServerValidation formParsers =
|
|
888
888
|
rawFormData
|
|
889
889
|
|> andThen
|