elm-pages 3.0.0-beta.14 → 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 (81) hide show
  1. package/README.md +1 -1
  2. package/codegen/elm-pages-codegen.js +66 -118
  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/error-formatter.js +7 -3
  20. package/generator/src/render.js +6 -15
  21. package/generator/src/request-cache.js +34 -4
  22. package/generator/static-code/hmr.js +16 -2
  23. package/package.json +1 -1
  24. package/src/ApiRoute.elm +13 -16
  25. package/src/BackendTask/Env.elm +11 -8
  26. package/src/BackendTask/File.elm +49 -10
  27. package/src/BackendTask/Glob.elm +6 -6
  28. package/src/BackendTask/Http.elm +49 -13
  29. package/src/BackendTask/Port.elm +59 -47
  30. package/src/BackendTask.elm +8 -22
  31. package/src/FatalError.elm +101 -0
  32. package/src/Form.elm +3 -2
  33. package/src/Internal/ApiRoute.elm +5 -5
  34. package/src/Pages/Generate.elm +300 -103
  35. package/src/Pages/Internal/FatalError.elm +5 -0
  36. package/src/Pages/Internal/Platform/Cli.elm +21 -41
  37. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  38. package/src/Pages/Internal/Platform/GeneratorApplication.elm +24 -48
  39. package/src/Pages/Internal/Platform/StaticResponses.elm +18 -31
  40. package/src/Pages/Internal/Script.elm +2 -2
  41. package/src/Pages/Manifest.elm +2 -2
  42. package/src/Pages/ProgramConfig.elm +7 -7
  43. package/src/Pages/Script.elm +4 -4
  44. package/src/Pages/SiteConfig.elm +2 -2
  45. package/src/Pages/StaticHttpRequest.elm +1 -23
  46. package/src/Server/Request.elm +3 -2
  47. package/src/Exception.elm +0 -37
  48. package/src/MultiDict.elm +0 -49
  49. package/src/PairingHeap.elm +0 -137
  50. package/src/Parser/Extra/String.elm +0 -33
  51. package/src/Parser/Extra.elm +0 -69
  52. package/src/ProgramTest/ComplexQuery.elm +0 -360
  53. package/src/ProgramTest/EffectSimulation.elm +0 -122
  54. package/src/ProgramTest/Failure.elm +0 -367
  55. package/src/ProgramTest/HtmlHighlighter.elm +0 -116
  56. package/src/ProgramTest/HtmlParserHacks.elm +0 -58
  57. package/src/ProgramTest/HtmlRenderer.elm +0 -73
  58. package/src/ProgramTest/Program.elm +0 -30
  59. package/src/ProgramTest/StringLines.elm +0 -26
  60. package/src/ProgramTest/TestHtmlHacks.elm +0 -132
  61. package/src/ProgramTest/TestHtmlParser.elm +0 -201
  62. package/src/ProgramTest.elm +0 -2339
  63. package/src/Query/Extra.elm +0 -55
  64. package/src/SimulatedEffect/Cmd.elm +0 -69
  65. package/src/SimulatedEffect/Http.elm +0 -330
  66. package/src/SimulatedEffect/Navigation.elm +0 -69
  67. package/src/SimulatedEffect/Ports.elm +0 -62
  68. package/src/SimulatedEffect/Process.elm +0 -24
  69. package/src/SimulatedEffect/Sub.elm +0 -48
  70. package/src/SimulatedEffect/Task.elm +0 -252
  71. package/src/SimulatedEffect/Time.elm +0 -25
  72. package/src/SimulatedEffect.elm +0 -42
  73. package/src/String/Extra.elm +0 -6
  74. package/src/Test/Http.elm +0 -145
  75. package/src/TestResult.elm +0 -35
  76. package/src/TestState.elm +0 -305
  77. package/src/Url/Extra.elm +0 -100
  78. package/src/Vendored/Diff.elm +0 -321
  79. package/src/Vendored/Failure.elm +0 -217
  80. package/src/Vendored/FormatMonochrome.elm +0 -44
  81. package/src/Vendored/Highlightable.elm +0 -53
@@ -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,9 +51,8 @@ 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
- , allRawResponses : RequestsAndPending
57
56
  , maybeRequestJson : RenderRequest route
58
57
  , isDevServer : Bool
59
58
  }
@@ -310,7 +309,6 @@ init site renderRequest config flags =
310
309
  , path = ""
311
310
  }
312
311
  ]
313
- , allRawResponses = Json.Encode.object []
314
312
  , maybeRequestJson = renderRequest
315
313
  , isDevServer = False
316
314
  }
@@ -325,7 +323,6 @@ init site renderRequest config flags =
325
323
  , path = ""
326
324
  }
327
325
  ]
328
- , allRawResponses = Json.Encode.object []
329
326
  , maybeRequestJson = renderRequest
330
327
  , isDevServer = False
331
328
  }
@@ -379,11 +376,11 @@ initLegacy :
379
376
  -> ( Model route, Effect )
380
377
  initLegacy site ((RenderRequest.SinglePage includeHtml singleRequest _) as renderRequest) { isDevServer } config =
381
378
  let
382
- globalHeadTags : BackendTask Throwable (List Tag)
379
+ globalHeadTags : BackendTask FatalError (List Tag)
383
380
  globalHeadTags =
384
381
  (config.globalHeadTags |> Maybe.withDefault (\_ -> BackendTask.succeed [])) HtmlPrinter.htmlToString
385
382
 
386
- staticResponsesNew : BackendTask Throwable Effect
383
+ staticResponsesNew : BackendTask FatalError Effect
387
384
  staticResponsesNew =
388
385
  StaticResponses.renderApiRequest
389
386
  (case singleRequest of
@@ -763,12 +760,11 @@ initLegacy site ((RenderRequest.SinglePage includeHtml singleRequest _) as rende
763
760
  initialModel =
764
761
  { staticResponses = staticResponsesNew
765
762
  , errors = []
766
- , allRawResponses = Json.Encode.object []
767
763
  , maybeRequestJson = renderRequest
768
764
  , isDevServer = isDevServer
769
765
  }
770
766
  in
771
- StaticResponses.nextStep initialModel
767
+ StaticResponses.nextStep (Json.Encode.object []) initialModel.staticResponses initialModel
772
768
  |> nextStepToEffect
773
769
  initialModel
774
770
 
@@ -777,7 +773,8 @@ updateAndSendPortIfDone :
777
773
  Model route
778
774
  -> ( Model route, Effect )
779
775
  updateAndSendPortIfDone model =
780
- StaticResponses.nextStep
776
+ StaticResponses.nextStep (Json.Encode.object [])
777
+ model.staticResponses
781
778
  model
782
779
  |> nextStepToEffect model
783
780
 
@@ -790,15 +787,10 @@ update :
790
787
  update msg model =
791
788
  case msg of
792
789
  GotDataBatch batch ->
793
- let
794
- updatedModel : Model route
795
- updatedModel =
796
- model
797
- |> StaticResponses.batchUpdate batch
798
- in
799
- StaticResponses.nextStep
800
- updatedModel
801
- |> nextStepToEffect updatedModel
790
+ StaticResponses.nextStep batch
791
+ model.staticResponses
792
+ model
793
+ |> nextStepToEffect model
802
794
 
803
795
  GotBuildError buildError ->
804
796
  let
@@ -809,7 +801,8 @@ update msg model =
809
801
  buildError :: model.errors
810
802
  }
811
803
  in
812
- StaticResponses.nextStep
804
+ StaticResponses.nextStep (Json.Encode.object [])
805
+ updatedModel.staticResponses
813
806
  updatedModel
814
807
  |> nextStepToEffect updatedModel
815
808
 
@@ -821,27 +814,14 @@ nextStepToEffect :
821
814
  nextStepToEffect model nextStep =
822
815
  case nextStep of
823
816
  StaticResponses.Continue httpRequests updatedStaticResponsesModel ->
824
- let
825
- updatedModel : Model route
826
- updatedModel =
827
- { model
828
- | staticResponses = updatedStaticResponsesModel
829
- }
830
- in
831
- if List.isEmpty httpRequests then
832
- nextStepToEffect
833
- updatedModel
834
- (StaticResponses.nextStep
835
- updatedModel
836
- )
837
-
838
- else
839
- ( updatedModel
840
- , (httpRequests
841
- |> List.map Effect.FetchHttp
842
- )
843
- |> Effect.Batch
844
- )
817
+ ( { model
818
+ | staticResponses = updatedStaticResponsesModel
819
+ }
820
+ , (httpRequests
821
+ |> List.map Effect.FetchHttp
822
+ )
823
+ |> Effect.Batch
824
+ )
845
825
 
846
826
  StaticResponses.FinishedWithErrors errors ->
847
827
  ( model
@@ -3,4 +3,4 @@ module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKe
3
3
 
4
4
  currentCompatibilityKey : Int
5
5
  currentCompatibilityKey =
6
- 4
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
@@ -22,7 +22,6 @@ import Pages.Internal.Platform.StaticResponses as StaticResponses
22
22
  import Pages.Internal.Platform.ToJsPayload as ToJsPayload
23
23
  import Pages.Internal.Script
24
24
  import Pages.StaticHttp.Request
25
- import RequestsAndPending exposing (RequestsAndPending)
26
25
  import TerminalText as Terminal
27
26
 
28
27
 
@@ -34,10 +33,8 @@ type alias Flags =
34
33
 
35
34
  {-| -}
36
35
  type alias Model =
37
- { staticResponses : BackendTask Throwable ()
36
+ { staticResponses : BackendTask FatalError ()
38
37
  , errors : List BuildError
39
- , allRawResponses : RequestsAndPending
40
- , done : Bool
41
38
  }
42
39
 
43
40
 
@@ -50,10 +47,10 @@ type Msg
50
47
  {-| -}
51
48
  app :
52
49
  GeneratorProgramConfig
53
- -> Program.StatefulProgram Model Msg (BackendTask Throwable ()) Flags
50
+ -> Program.StatefulProgram Model Msg (BackendTask FatalError ()) Flags
54
51
  app config =
55
52
  let
56
- cliConfig : Program.Config (BackendTask Throwable ())
53
+ cliConfig : Program.Config (BackendTask FatalError ())
57
54
  cliConfig =
58
55
  case config.data of
59
56
  Pages.Internal.Script.Script theCliConfig ->
@@ -249,7 +246,7 @@ perform config effect =
249
246
 
250
247
  {-| -}
251
248
  init :
252
- BackendTask Throwable ()
249
+ BackendTask FatalError ()
253
250
  -> FlagsIncludingArgv Flags
254
251
  -> ( Model, Effect )
255
252
  init execute flags =
@@ -281,17 +278,15 @@ init execute flags =
281
278
  , path = ""
282
279
  }
283
280
  ]
284
- , allRawResponses = Encode.object []
285
- , done = False
286
281
  }
287
282
 
288
283
 
289
284
  initLegacy :
290
- BackendTask Throwable ()
285
+ BackendTask FatalError ()
291
286
  -> ( Model, Effect )
292
287
  initLegacy execute =
293
288
  let
294
- staticResponses : BackendTask Throwable ()
289
+ staticResponses : BackendTask FatalError ()
295
290
  staticResponses =
296
291
  StaticResponses.renderApiRequest execute
297
292
 
@@ -299,11 +294,9 @@ initLegacy execute =
299
294
  initialModel =
300
295
  { staticResponses = staticResponses
301
296
  , errors = []
302
- , allRawResponses = Encode.object []
303
- , done = False
304
297
  }
305
298
  in
306
- StaticResponses.nextStep initialModel
299
+ StaticResponses.nextStep (Encode.object []) initialModel.staticResponses initialModel
307
300
  |> nextStepToEffect
308
301
  initialModel
309
302
 
@@ -312,7 +305,8 @@ updateAndSendPortIfDone :
312
305
  Model
313
306
  -> ( Model, Effect )
314
307
  updateAndSendPortIfDone model =
315
- StaticResponses.nextStep
308
+ StaticResponses.nextStep (Encode.object [])
309
+ model.staticResponses
316
310
  model
317
311
  |> nextStepToEffect model
318
312
 
@@ -325,15 +319,10 @@ update :
325
319
  update msg model =
326
320
  case msg of
327
321
  GotDataBatch batch ->
328
- let
329
- updatedModel : Model
330
- updatedModel =
331
- model
332
- |> StaticResponses.batchUpdate batch
333
- in
334
- StaticResponses.nextStep
335
- updatedModel
336
- |> nextStepToEffect updatedModel
322
+ StaticResponses.nextStep batch
323
+ model.staticResponses
324
+ model
325
+ |> nextStepToEffect model
337
326
 
338
327
  GotBuildError buildError ->
339
328
  let
@@ -344,7 +333,8 @@ update msg model =
344
333
  buildError :: model.errors
345
334
  }
346
335
  in
347
- StaticResponses.nextStep
336
+ StaticResponses.nextStep (Encode.object [])
337
+ updatedModel.staticResponses
348
338
  updatedModel
349
339
  |> nextStepToEffect updatedModel
350
340
 
@@ -356,28 +346,14 @@ nextStepToEffect :
356
346
  nextStepToEffect model nextStep =
357
347
  case nextStep of
358
348
  StaticResponses.Continue httpRequests updatedStaticResponsesModel ->
359
- let
360
- updatedModel : Model
361
- updatedModel =
362
- { model
363
- | allRawResponses = Encode.object []
364
- , staticResponses = updatedStaticResponsesModel
365
- }
366
- in
367
- if List.isEmpty httpRequests then
368
- nextStepToEffect
369
- updatedModel
370
- (StaticResponses.nextStep
371
- updatedModel
372
- )
373
-
374
- else
375
- ( updatedModel
376
- , (httpRequests
377
- |> List.map Effect.FetchHttp
378
- )
379
- |> Effect.Batch
380
- )
349
+ ( { model
350
+ | staticResponses = updatedStaticResponsesModel
351
+ }
352
+ , (httpRequests
353
+ |> List.map Effect.FetchHttp
354
+ )
355
+ |> Effect.Batch
356
+ )
381
357
 
382
358
  StaticResponses.Finish () ->
383
359
  ( model
@@ -1,61 +1,48 @@
1
- module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), batchUpdate, empty, nextStep, renderApiRequest)
1
+ module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), empty, nextStep, renderApiRequest)
2
2
 
3
3
  import BackendTask exposing (BackendTask)
4
4
  import BuildError exposing (BuildError)
5
- import Exception exposing (Catchable(..), Throwable)
6
- import Json.Decode as Decode
5
+ import FatalError exposing (FatalError, Recoverable)
7
6
  import List.Extra
7
+ import Pages.Internal.FatalError
8
8
  import Pages.StaticHttp.Request as HashRequest
9
9
  import Pages.StaticHttpRequest as StaticHttpRequest
10
10
  import RequestsAndPending exposing (RequestsAndPending)
11
11
  import TerminalText
12
12
 
13
13
 
14
- empty : a -> BackendTask Throwable a
14
+ empty : a -> BackendTask FatalError a
15
15
  empty a =
16
16
  BackendTask.succeed a
17
17
 
18
18
 
19
19
  renderApiRequest :
20
- BackendTask Throwable response
21
- -> BackendTask Throwable response
20
+ BackendTask FatalError response
21
+ -> BackendTask FatalError response
22
22
  renderApiRequest request =
23
23
  request
24
24
 
25
25
 
26
- batchUpdate :
27
- Decode.Value
28
- ->
29
- { model
30
- | allRawResponses : Decode.Value
31
- }
32
- ->
33
- { model
34
- | allRawResponses : Decode.Value
35
- }
36
- batchUpdate newEntries model =
37
- { model | allRawResponses = newEntries }
38
-
39
-
40
26
  type NextStep route value
41
- = Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest Throwable value)
27
+ = Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest FatalError value)
42
28
  | Finish value
43
29
  | FinishedWithErrors (List BuildError)
44
30
 
45
31
 
46
32
  nextStep :
47
- { model
48
- | staticResponses : BackendTask Throwable a
49
- , errors : List BuildError
50
- , allRawResponses : RequestsAndPending
51
- }
33
+ RequestsAndPending
34
+ -> BackendTask FatalError a
35
+ ->
36
+ { model
37
+ | errors : List BuildError
38
+ }
52
39
  -> NextStep route a
53
- nextStep ({ allRawResponses, errors } as model) =
40
+ nextStep allRawResponses staticResponses { errors } =
54
41
  let
55
- staticRequestsStatus : StaticHttpRequest.Status Throwable a
42
+ staticRequestsStatus : StaticHttpRequest.Status FatalError a
56
43
  staticRequestsStatus =
57
44
  allRawResponses
58
- |> StaticHttpRequest.cacheRequestResolution model.staticResponses
45
+ |> StaticHttpRequest.cacheRequestResolution staticResponses
59
46
 
60
47
  ( ( pendingRequests, completedValue ), urlsToPerform, progressedBackendTask ) =
61
48
  case staticRequestsStatus of
@@ -77,7 +64,7 @@ nextStep ({ allRawResponses, errors } as model) =
77
64
  StaticHttpRequest.HasPermanentError _ ->
78
65
  ( ( False, Nothing )
79
66
  , []
80
- , BackendTask.fail (Exception.fromString "TODO this shouldn't happen")
67
+ , BackendTask.fail (FatalError.fromString "TODO this shouldn't happen")
81
68
  )
82
69
  in
83
70
  if pendingRequests then
@@ -125,7 +112,7 @@ nextStep ({ allRawResponses, errors } as model) =
125
112
  Just (Ok completed) ->
126
113
  Finish completed
127
114
 
128
- Just (Err (Catchable () buildError)) ->
115
+ Just (Err (Pages.Internal.FatalError.FatalError buildError)) ->
129
116
  FinishedWithErrors
130
117
  [ { title = buildError.title |> String.toUpper
131
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 (Catchable, 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 (Catchable 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
  }
@@ -65,7 +65,7 @@ cacheRequestResolution request rawResponses =
65
65
  case request of
66
66
  Request urlList lookupFn ->
67
67
  if List.isEmpty urlList then
68
- cacheRequestResolutionHelp urlList rawResponses (lookupFn Nothing rawResponses)
68
+ cacheRequestResolution (lookupFn Nothing rawResponses) rawResponses
69
69
 
70
70
  else
71
71
  Incomplete urlList (Request [] lookupFn)
@@ -78,25 +78,3 @@ type Status error value
78
78
  = Incomplete (List Pages.StaticHttp.Request.Request) (RawRequest error value)
79
79
  | HasPermanentError Error
80
80
  | Complete (Result error value)
81
-
82
-
83
- cacheRequestResolutionHelp :
84
- List Pages.StaticHttp.Request.Request
85
- -> RequestsAndPending
86
- -> RawRequest error value
87
- -> Status error value
88
- cacheRequestResolutionHelp foundUrls rawResponses request =
89
- case request of
90
- Request urlList lookupFn ->
91
- if (urlList ++ foundUrls) |> List.isEmpty then
92
- cacheRequestResolutionHelp
93
- []
94
- rawResponses
95
- (lookupFn Nothing rawResponses)
96
-
97
- else
98
- Incomplete (urlList ++ foundUrls)
99
- (Request [] lookupFn)
100
-
101
- ApiRoute value ->
102
- Complete value
@@ -89,6 +89,7 @@ module Server.Request exposing
89
89
  import BackendTask exposing (BackendTask)
90
90
  import CookieParser
91
91
  import Dict exposing (Dict)
92
+ import FatalError exposing (FatalError)
92
93
  import Form
93
94
  import Form.Validation as Validation
94
95
  import FormData
@@ -881,8 +882,8 @@ fileField_ name =
881
882
 
882
883
  {-| -}
883
884
  formDataWithServerValidation :
884
- Form.ServerForms error (BackendTask error (Validation.Validation error combined kind constraints))
885
- -> Parser (BackendTask error (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 )))
886
887
  formDataWithServerValidation formParsers =
887
888
  rawFormData
888
889
  |> andThen
package/src/Exception.elm DELETED
@@ -1,37 +0,0 @@
1
- module Exception exposing (Throwable, Catchable(..), fromString, fromStringWithValue, throw)
2
-
3
- {-|
4
-
5
- @docs Throwable, Catchable, fromString, fromStringWithValue, throw
6
-
7
- -}
8
-
9
-
10
- {-| -}
11
- type alias Throwable =
12
- Catchable ()
13
-
14
-
15
- {-| -}
16
- type Catchable error
17
- = Catchable error { title : String, body : String }
18
-
19
-
20
- {-| -}
21
- fromString : String -> Catchable ()
22
- fromString string =
23
- fromStringWithValue string ()
24
-
25
-
26
- {-| -}
27
- fromStringWithValue : String -> value -> Catchable value
28
- fromStringWithValue string value =
29
- Catchable value { title = "Custom Error", body = string }
30
-
31
-
32
- {-| -}
33
- throw : Catchable error -> Catchable ()
34
- throw exception =
35
- case exception of
36
- Catchable _ string ->
37
- Catchable () string
package/src/MultiDict.elm DELETED
@@ -1,49 +0,0 @@
1
- module MultiDict exposing (MultiDict, empty, get, insert, keys, remove, set)
2
-
3
- import Dict exposing (Dict)
4
- import List.Extra
5
- import List.Nonempty as NonEmpty
6
-
7
-
8
- type alias NonEmpty a =
9
- NonEmpty.Nonempty a
10
-
11
-
12
- type MultiDict k v
13
- = MultiDict (Dict k (NonEmpty v))
14
-
15
-
16
- empty : MultiDict k v
17
- empty =
18
- MultiDict Dict.empty
19
-
20
-
21
- insert : comparable -> v -> MultiDict comparable v -> MultiDict comparable v
22
- insert key value (MultiDict dict) =
23
- MultiDict
24
- (Dict.update key (Maybe.map (NonEmpty.cons value) >> Maybe.withDefault (NonEmpty.fromElement value) >> Just) dict)
25
-
26
-
27
- get : comparable -> MultiDict comparable v -> List v
28
- get key (MultiDict dict) =
29
- Dict.get key dict
30
- |> Maybe.map NonEmpty.toList
31
- |> Maybe.withDefault []
32
-
33
-
34
- keys : MultiDict k v -> List k
35
- keys (MultiDict dict) =
36
- Dict.toList dict
37
- |> List.concatMap (\( k, vs ) -> List.repeat (NonEmpty.length vs) k)
38
-
39
-
40
- remove : comparable -> v -> MultiDict comparable v -> MultiDict comparable v
41
- remove key value (MultiDict dict) =
42
- MultiDict
43
- (Dict.update key (Maybe.andThen (NonEmpty.toList >> List.Extra.remove value >> NonEmpty.fromList)) dict)
44
-
45
-
46
- set : comparable -> List v -> MultiDict comparable v -> MultiDict comparable v
47
- set key values (MultiDict dict) =
48
- MultiDict
49
- (Dict.update key (\_ -> NonEmpty.fromList values) dict)