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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/codegen/elm-pages-codegen.js +66 -115
  3. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
  4. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  6. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +20 -20
  7. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  8. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  9. package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +5 -5
  10. package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +21 -21
  11. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  12. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  13. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  14. package/generator/src/RouteBuilder.elm +23 -23
  15. package/generator/src/SharedTemplate.elm +2 -2
  16. package/generator/src/SiteConfig.elm +2 -2
  17. package/generator/src/cli.js +2 -2
  18. package/generator/src/compatibility-key.js +1 -1
  19. package/generator/src/render.js +5 -5
  20. package/package.json +1 -1
  21. package/src/ApiRoute.elm +13 -13
  22. package/src/BackendTask/Env.elm +9 -8
  23. package/src/BackendTask/File.elm +49 -10
  24. package/src/BackendTask/Glob.elm +6 -6
  25. package/src/BackendTask/Http.elm +12 -12
  26. package/src/BackendTask/Port.elm +22 -14
  27. package/src/BackendTask.elm +8 -22
  28. package/src/{Exception.elm → FatalError.elm} +37 -31
  29. package/src/Form.elm +3 -3
  30. package/src/Internal/ApiRoute.elm +5 -5
  31. package/src/Pages/Generate.elm +1 -1
  32. package/src/Pages/Internal/FatalError.elm +5 -0
  33. package/src/Pages/Internal/Platform/Cli.elm +4 -4
  34. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  35. package/src/Pages/Internal/Platform/GeneratorApplication.elm +7 -7
  36. package/src/Pages/Internal/Platform/StaticResponses.elm +10 -9
  37. package/src/Pages/Internal/Script.elm +2 -2
  38. package/src/Pages/Manifest.elm +2 -2
  39. package/src/Pages/ProgramConfig.elm +7 -7
  40. package/src/Pages/Script.elm +4 -4
  41. package/src/Pages/SiteConfig.elm +2 -2
  42. 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 Exception exposing (Throwable)
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 Throwable Effect
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 Throwable (List Tag)
379
+ globalHeadTags : BackendTask FatalError (List Tag)
380
380
  globalHeadTags =
381
381
  (config.globalHeadTags |> Maybe.withDefault (\_ -> BackendTask.succeed [])) HtmlPrinter.htmlToString
382
382
 
383
- staticResponsesNew : BackendTask Throwable Effect
383
+ staticResponsesNew : BackendTask FatalError Effect
384
384
  staticResponsesNew =
385
385
  StaticResponses.renderApiRequest
386
386
  (case singleRequest of
@@ -3,4 +3,4 @@ module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKe
3
3
 
4
4
  currentCompatibilityKey : Int
5
5
  currentCompatibilityKey =
6
- 5
6
+ 6
@@ -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 Exception exposing (Throwable)
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 Throwable ()
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 Throwable ()) Flags
50
+ -> Program.StatefulProgram Model Msg (BackendTask FatalError ()) Flags
51
51
  app config =
52
52
  let
53
- cliConfig : Program.Config (BackendTask Throwable ())
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 Throwable ()
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 Throwable ()
285
+ BackendTask FatalError ()
286
286
  -> ( Model, Effect )
287
287
  initLegacy execute =
288
288
  let
289
- staticResponses : BackendTask Throwable ()
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 Exception exposing (Exception(..), Throwable)
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 Throwable a
14
+ empty : a -> BackendTask FatalError a
14
15
  empty a =
15
16
  BackendTask.succeed a
16
17
 
17
18
 
18
19
  renderApiRequest :
19
- BackendTask Throwable response
20
- -> BackendTask Throwable response
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 Throwable value)
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 Throwable a
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 Throwable a
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 (Exception.fromString "TODO this shouldn't happen")
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 (Exception () buildError)) ->
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 Exception exposing (Throwable)
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 Throwable ())
16
+ -> Program.Config (BackendTask FatalError ())
17
17
  )
@@ -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 Exception exposing (Throwable)
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 Throwable Config -> ApiRoute.ApiRoute ApiRoute.Response
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 Exception exposing (Throwable)
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 Throwable sharedData
53
- , data : Decode.Value -> route -> BackendTask Throwable (PageServerResponse pageData errorPage)
54
- , action : Decode.Value -> route -> BackendTask Throwable (PageServerResponse actionData errorPage)
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 Throwable (Maybe NotFoundReason)
73
- , getStaticRoutes : BackendTask Throwable (List route)
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 Throwable (List Head.Tag))
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 :
@@ -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 Exception exposing (Exception, Throwable)
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 (Exception Error) ()
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 Throwable () -> Script
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 Throwable ()) -> Script
103
+ withCliOptions : Program.Config cliOptions -> (cliOptions -> BackendTask FatalError ()) -> Script
104
104
  withCliOptions config execute =
105
105
  Pages.Internal.Script.Script
106
106
  (\_ ->
@@ -1,11 +1,11 @@
1
1
  module Pages.SiteConfig exposing (SiteConfig)
2
2
 
3
3
  import BackendTask exposing (BackendTask)
4
- import Exception exposing (Throwable)
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 Throwable (List Head.Tag)
10
+ , head : BackendTask FatalError (List Head.Tag)
11
11
  }
@@ -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 Exception exposing (Throwable)
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 Throwable (Validation.Validation error combined kind constraints))
886
- -> Parser (BackendTask Throwable (Result (Form.Response error) ( Form.Response error, combined )))
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