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.
- package/README.md +1 -1
- package/codegen/elm-pages-codegen.js +66 -118
- 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/error-formatter.js +7 -3
- package/generator/src/render.js +6 -15
- package/generator/src/request-cache.js +34 -4
- package/generator/static-code/hmr.js +16 -2
- package/package.json +1 -1
- package/src/ApiRoute.elm +13 -16
- package/src/BackendTask/Env.elm +11 -8
- package/src/BackendTask/File.elm +49 -10
- package/src/BackendTask/Glob.elm +6 -6
- package/src/BackendTask/Http.elm +49 -13
- package/src/BackendTask/Port.elm +59 -47
- package/src/BackendTask.elm +8 -22
- package/src/FatalError.elm +101 -0
- package/src/Form.elm +3 -2
- package/src/Internal/ApiRoute.elm +5 -5
- package/src/Pages/Generate.elm +300 -103
- package/src/Pages/Internal/FatalError.elm +5 -0
- package/src/Pages/Internal/Platform/Cli.elm +21 -41
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +24 -48
- package/src/Pages/Internal/Platform/StaticResponses.elm +18 -31
- 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/Pages/StaticHttpRequest.elm +1 -23
- package/src/Server/Request.elm +3 -2
- package/src/Exception.elm +0 -37
- package/src/MultiDict.elm +0 -49
- package/src/PairingHeap.elm +0 -137
- package/src/Parser/Extra/String.elm +0 -33
- package/src/Parser/Extra.elm +0 -69
- package/src/ProgramTest/ComplexQuery.elm +0 -360
- package/src/ProgramTest/EffectSimulation.elm +0 -122
- package/src/ProgramTest/Failure.elm +0 -367
- package/src/ProgramTest/HtmlHighlighter.elm +0 -116
- package/src/ProgramTest/HtmlParserHacks.elm +0 -58
- package/src/ProgramTest/HtmlRenderer.elm +0 -73
- package/src/ProgramTest/Program.elm +0 -30
- package/src/ProgramTest/StringLines.elm +0 -26
- package/src/ProgramTest/TestHtmlHacks.elm +0 -132
- package/src/ProgramTest/TestHtmlParser.elm +0 -201
- package/src/ProgramTest.elm +0 -2339
- package/src/Query/Extra.elm +0 -55
- package/src/SimulatedEffect/Cmd.elm +0 -69
- package/src/SimulatedEffect/Http.elm +0 -330
- package/src/SimulatedEffect/Navigation.elm +0 -69
- package/src/SimulatedEffect/Ports.elm +0 -62
- package/src/SimulatedEffect/Process.elm +0 -24
- package/src/SimulatedEffect/Sub.elm +0 -48
- package/src/SimulatedEffect/Task.elm +0 -252
- package/src/SimulatedEffect/Time.elm +0 -25
- package/src/SimulatedEffect.elm +0 -42
- package/src/String/Extra.elm +0 -6
- package/src/Test/Http.elm +0 -145
- package/src/TestResult.elm +0 -35
- package/src/TestState.elm +0 -305
- package/src/Url/Extra.elm +0 -100
- package/src/Vendored/Diff.elm +0 -321
- package/src/Vendored/Failure.elm +0 -217
- package/src/Vendored/FormatMonochrome.elm +0 -44
- package/src/Vendored/Highlightable.elm +0 -53
|
@@ -15,7 +15,7 @@ all =
|
|
|
15
15
|
import Server.Request as Request
|
|
16
16
|
|
|
17
17
|
import BackendTask exposing (BackendTask)
|
|
18
|
-
import
|
|
18
|
+
import FatalError
|
|
19
19
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
20
20
|
import Pages.PageUrl exposing (PageUrl)
|
|
21
21
|
import Pages.Url
|
|
@@ -70,7 +70,7 @@ data =
|
|
|
70
70
|
import Server.Request as Request
|
|
71
71
|
|
|
72
72
|
import BackendTask exposing (BackendTask)
|
|
73
|
-
import
|
|
73
|
+
import FatalError
|
|
74
74
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
75
75
|
import Pages.PageUrl exposing (PageUrl)
|
|
76
76
|
import Pages.Url
|
|
@@ -100,7 +100,7 @@ route : StatelessRoute RouteParams Data ActionData
|
|
|
100
100
|
route =
|
|
101
101
|
single
|
|
102
102
|
{ head = head
|
|
103
|
-
, data = BackendTask.fail (
|
|
103
|
+
, data = BackendTask.fail (FatalError.fromString "")
|
|
104
104
|
}
|
|
105
105
|
|> RouteBuilder.buildNoState { view = view }
|
|
106
106
|
|
|
@@ -115,7 +115,7 @@ data =
|
|
|
115
115
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
116
116
|
|
|
117
117
|
import Server.Request as Request
|
|
118
|
-
import
|
|
118
|
+
import FatalError
|
|
119
119
|
import BackendTask as DS
|
|
120
120
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
121
121
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -169,7 +169,7 @@ data =
|
|
|
169
169
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
170
170
|
|
|
171
171
|
import Server.Request as Request
|
|
172
|
-
import
|
|
172
|
+
import FatalError
|
|
173
173
|
import BackendTask as DS
|
|
174
174
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
175
175
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -200,7 +200,7 @@ route : StatelessRoute RouteParams Data ActionData
|
|
|
200
200
|
route =
|
|
201
201
|
single
|
|
202
202
|
{ head = head
|
|
203
|
-
, data = DS.fail (
|
|
203
|
+
, data = DS.fail (FatalError.fromString "")
|
|
204
204
|
}
|
|
205
205
|
|> RouteBuilder.buildNoState { view = view }
|
|
206
206
|
|
|
@@ -217,7 +217,7 @@ data =
|
|
|
217
217
|
import Server.Request as Request
|
|
218
218
|
|
|
219
219
|
import BackendTask exposing (BackendTask)
|
|
220
|
-
import
|
|
220
|
+
import FatalError
|
|
221
221
|
import RouteBuilder exposing (Page, StaticPayload)
|
|
222
222
|
import Pages.PageUrl exposing (PageUrl)
|
|
223
223
|
import Pages.Url
|
|
@@ -272,7 +272,7 @@ data =
|
|
|
272
272
|
import Server.Request as Request
|
|
273
273
|
|
|
274
274
|
import BackendTask exposing (BackendTask)
|
|
275
|
-
import
|
|
275
|
+
import FatalError
|
|
276
276
|
import RouteBuilder exposing (Page, StaticPayload)
|
|
277
277
|
import Pages.PageUrl exposing (PageUrl)
|
|
278
278
|
import Pages.Url
|
|
@@ -301,7 +301,7 @@ type alias Data =
|
|
|
301
301
|
route : StatelessRoute RouteParams Data ActionData
|
|
302
302
|
route =
|
|
303
303
|
RouteBuilder.preRender
|
|
304
|
-
{ data = \\_ -> BackendTask.fail (
|
|
304
|
+
{ data = \\_ -> BackendTask.fail (FatalError.fromString "")
|
|
305
305
|
, head = head
|
|
306
306
|
, pages = pages
|
|
307
307
|
}
|
|
@@ -318,7 +318,7 @@ data =
|
|
|
318
318
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
319
319
|
|
|
320
320
|
import Server.Request as Request
|
|
321
|
-
import
|
|
321
|
+
import FatalError
|
|
322
322
|
|
|
323
323
|
type alias Model =
|
|
324
324
|
{}
|
|
@@ -355,7 +355,7 @@ route =
|
|
|
355
355
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
356
356
|
|
|
357
357
|
import Server.Request as Request
|
|
358
|
-
import
|
|
358
|
+
import FatalError
|
|
359
359
|
|
|
360
360
|
type alias Model =
|
|
361
361
|
{}
|
|
@@ -390,7 +390,7 @@ route =
|
|
|
390
390
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
391
391
|
|
|
392
392
|
import Server.Request as Request
|
|
393
|
-
import
|
|
393
|
+
import FatalError
|
|
394
394
|
|
|
395
395
|
type alias Model =
|
|
396
396
|
{}
|
|
@@ -419,7 +419,7 @@ route =
|
|
|
419
419
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
420
420
|
|
|
421
421
|
import Server.Request
|
|
422
|
-
import
|
|
422
|
+
import FatalError
|
|
423
423
|
|
|
424
424
|
type alias Model =
|
|
425
425
|
{}
|
|
@@ -456,7 +456,7 @@ route =
|
|
|
456
456
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
457
457
|
|
|
458
458
|
import Server.Request
|
|
459
|
-
import
|
|
459
|
+
import FatalError
|
|
460
460
|
|
|
461
461
|
type alias Model =
|
|
462
462
|
{}
|
|
@@ -491,7 +491,7 @@ route =
|
|
|
491
491
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
492
492
|
|
|
493
493
|
import Server.Request
|
|
494
|
-
import
|
|
494
|
+
import FatalError
|
|
495
495
|
|
|
496
496
|
type alias Model =
|
|
497
497
|
{}
|
|
@@ -520,7 +520,7 @@ route =
|
|
|
520
520
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
521
521
|
|
|
522
522
|
import Server.Request as Request
|
|
523
|
-
import
|
|
523
|
+
import FatalError
|
|
524
524
|
|
|
525
525
|
type alias Model =
|
|
526
526
|
{}
|
|
@@ -549,7 +549,7 @@ route =
|
|
|
549
549
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
550
550
|
|
|
551
551
|
import Server.Request as Request
|
|
552
|
-
import
|
|
552
|
+
import FatalError
|
|
553
553
|
|
|
554
554
|
import BackendTask exposing (BackendTask)
|
|
555
555
|
import RouteBuilder exposing (Page, StaticPayload)
|
|
@@ -581,7 +581,7 @@ route : StatelessRoute RouteParams Data ActionData
|
|
|
581
581
|
route =
|
|
582
582
|
RouteBuilder.single
|
|
583
583
|
{ head = head
|
|
584
|
-
, data = BackendTask.fail (
|
|
584
|
+
, data = BackendTask.fail (FatalError.fromString "")
|
|
585
585
|
}
|
|
586
586
|
|> RouteBuilder.buildNoState { view = view }
|
|
587
587
|
|
|
@@ -597,7 +597,7 @@ data =
|
|
|
597
597
|
"""module Shared exposing (Data, Model, Msg, template)
|
|
598
598
|
|
|
599
599
|
import Server.Request as Request
|
|
600
|
-
import
|
|
600
|
+
import FatalError
|
|
601
601
|
|
|
602
602
|
import Browser.Navigation
|
|
603
603
|
import BackendTask
|
|
@@ -648,7 +648,7 @@ type alias Model =
|
|
|
648
648
|
"""module Shared exposing (Data, Model, Msg, template)
|
|
649
649
|
|
|
650
650
|
import Server.Request as Request
|
|
651
|
-
import
|
|
651
|
+
import FatalError
|
|
652
652
|
|
|
653
653
|
import Browser.Navigation
|
|
654
654
|
import BackendTask
|
|
@@ -669,7 +669,7 @@ template =
|
|
|
669
669
|
{ init = init
|
|
670
670
|
, update = update
|
|
671
671
|
, view = view
|
|
672
|
-
, data = BackendTask.fail (
|
|
672
|
+
, data = BackendTask.fail (FatalError.fromString "")
|
|
673
673
|
, subscriptions = subscriptions
|
|
674
674
|
, onPageChange = Just OnPageChange
|
|
675
675
|
}
|
|
Binary file
|
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 4260939212, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
@@ -89,7 +89,7 @@ import BackendTask exposing (BackendTask)
|
|
|
89
89
|
import Dict exposing (Dict)
|
|
90
90
|
import Effect exposing (Effect)
|
|
91
91
|
import ErrorPage exposing (ErrorPage)
|
|
92
|
-
import
|
|
92
|
+
import FatalError exposing (FatalError)
|
|
93
93
|
import Head
|
|
94
94
|
import Http
|
|
95
95
|
import Json.Decode
|
|
@@ -109,9 +109,9 @@ import View exposing (View)
|
|
|
109
109
|
|
|
110
110
|
{-| -}
|
|
111
111
|
type alias StatefulRoute routeParams data action model msg =
|
|
112
|
-
{ data : Json.Decode.Value -> routeParams -> BackendTask
|
|
113
|
-
, action : Json.Decode.Value -> routeParams -> BackendTask
|
|
114
|
-
, staticRoutes : BackendTask
|
|
112
|
+
{ data : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
|
|
113
|
+
, action : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response action ErrorPage)
|
|
114
|
+
, staticRoutes : BackendTask FatalError (List routeParams)
|
|
115
115
|
, view :
|
|
116
116
|
Maybe PageUrl
|
|
117
117
|
-> Shared.Model
|
|
@@ -124,7 +124,7 @@ type alias StatefulRoute routeParams data action model msg =
|
|
|
124
124
|
, init : Maybe PageUrl -> Shared.Model -> StaticPayload data action routeParams -> ( model, Effect msg )
|
|
125
125
|
, update : PageUrl -> StaticPayload data action routeParams -> msg -> model -> Shared.Model -> ( model, Effect msg, Maybe Shared.Msg )
|
|
126
126
|
, subscriptions : Maybe PageUrl -> routeParams -> Path -> model -> Shared.Model -> Sub msg
|
|
127
|
-
, handleRoute : { moduleName : List String, routePattern : RoutePattern } -> (routeParams -> List ( String, String )) -> routeParams -> BackendTask
|
|
127
|
+
, handleRoute : { moduleName : List String, routePattern : RoutePattern } -> (routeParams -> List ( String, String )) -> routeParams -> BackendTask FatalError (Maybe NotFoundReason)
|
|
128
128
|
, kind : String
|
|
129
129
|
, onAction : Maybe (action -> msg)
|
|
130
130
|
}
|
|
@@ -154,9 +154,9 @@ type alias StaticPayload data action routeParams =
|
|
|
154
154
|
{-| -}
|
|
155
155
|
type Builder routeParams data action
|
|
156
156
|
= WithData
|
|
157
|
-
{ data : Json.Decode.Value -> routeParams -> BackendTask
|
|
158
|
-
, action : Json.Decode.Value -> routeParams -> BackendTask
|
|
159
|
-
, staticRoutes : BackendTask
|
|
157
|
+
{ data : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
|
|
158
|
+
, action : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response action ErrorPage)
|
|
159
|
+
, staticRoutes : BackendTask FatalError (List routeParams)
|
|
160
160
|
, head :
|
|
161
161
|
StaticPayload data action routeParams
|
|
162
162
|
-> List Head.Tag
|
|
@@ -165,7 +165,7 @@ type Builder routeParams data action
|
|
|
165
165
|
{ moduleName : List String, routePattern : RoutePattern }
|
|
166
166
|
-> (routeParams -> List ( String, String ))
|
|
167
167
|
-> routeParams
|
|
168
|
-
-> BackendTask
|
|
168
|
+
-> BackendTask FatalError (Maybe NotFoundReason)
|
|
169
169
|
, kind : String
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -292,14 +292,14 @@ buildWithSharedState config builderState =
|
|
|
292
292
|
|
|
293
293
|
{-| -}
|
|
294
294
|
single :
|
|
295
|
-
{ data : BackendTask
|
|
295
|
+
{ data : BackendTask FatalError data
|
|
296
296
|
, head : StaticPayload data action {} -> List Head.Tag
|
|
297
297
|
}
|
|
298
298
|
-> Builder {} data action
|
|
299
299
|
single { data, head } =
|
|
300
300
|
WithData
|
|
301
301
|
{ data = \_ _ -> data |> BackendTask.map Server.Response.render
|
|
302
|
-
, action = \_ _ -> BackendTask.fail (
|
|
302
|
+
, action = \_ _ -> BackendTask.fail (FatalError.fromString "Internal Error - actions should never be called for statically generated pages.")
|
|
303
303
|
, staticRoutes = BackendTask.succeed [ {} ]
|
|
304
304
|
, head = head
|
|
305
305
|
, serverless = False
|
|
@@ -310,15 +310,15 @@ single { data, head } =
|
|
|
310
310
|
|
|
311
311
|
{-| -}
|
|
312
312
|
preRender :
|
|
313
|
-
{ data : routeParams -> BackendTask
|
|
314
|
-
, pages : BackendTask
|
|
313
|
+
{ data : routeParams -> BackendTask FatalError data
|
|
314
|
+
, pages : BackendTask FatalError (List routeParams)
|
|
315
315
|
, head : StaticPayload data action routeParams -> List Head.Tag
|
|
316
316
|
}
|
|
317
317
|
-> Builder routeParams data action
|
|
318
318
|
preRender { data, head, pages } =
|
|
319
319
|
WithData
|
|
320
320
|
{ data = \_ -> data >> BackendTask.map Server.Response.render
|
|
321
|
-
, action = \_ _ -> BackendTask.fail (
|
|
321
|
+
, action = \_ _ -> BackendTask.fail (FatalError.fromString "Internal Error - actions should never be called for statically generated pages.")
|
|
322
322
|
, staticRoutes = pages
|
|
323
323
|
, head = head
|
|
324
324
|
, serverless = False
|
|
@@ -348,15 +348,15 @@ preRender { data, head, pages } =
|
|
|
348
348
|
|
|
349
349
|
{-| -}
|
|
350
350
|
preRenderWithFallback :
|
|
351
|
-
{ data : routeParams -> BackendTask
|
|
352
|
-
, pages : BackendTask
|
|
351
|
+
{ data : routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
|
|
352
|
+
, pages : BackendTask FatalError (List routeParams)
|
|
353
353
|
, head : StaticPayload data action routeParams -> List Head.Tag
|
|
354
354
|
}
|
|
355
355
|
-> Builder routeParams data action
|
|
356
356
|
preRenderWithFallback { data, head, pages } =
|
|
357
357
|
WithData
|
|
358
358
|
{ data = \_ -> data
|
|
359
|
-
, action = \_ _ -> BackendTask.fail (
|
|
359
|
+
, action = \_ _ -> BackendTask.fail (FatalError.fromString "Internal Error - actions should never be called for statically generated pages.")
|
|
360
360
|
, staticRoutes = pages
|
|
361
361
|
, head = head
|
|
362
362
|
, serverless = False
|
|
@@ -369,8 +369,8 @@ preRenderWithFallback { data, head, pages } =
|
|
|
369
369
|
|
|
370
370
|
{-| -}
|
|
371
371
|
serverRender :
|
|
372
|
-
{ data : routeParams -> Server.Request.Parser (BackendTask
|
|
373
|
-
, action : routeParams -> Server.Request.Parser (BackendTask
|
|
372
|
+
{ data : routeParams -> Server.Request.Parser (BackendTask FatalError (Server.Response.Response data ErrorPage))
|
|
373
|
+
, action : routeParams -> Server.Request.Parser (BackendTask FatalError (Server.Response.Response action ErrorPage))
|
|
374
374
|
, head : StaticPayload data action routeParams -> List Head.Tag
|
|
375
375
|
}
|
|
376
376
|
-> Builder routeParams data action
|
|
@@ -386,7 +386,7 @@ serverRender { data, action, head } =
|
|
|
386
386
|
|> Result.mapError Json.Decode.errorToString
|
|
387
387
|
|> BackendTask.fromResult
|
|
388
388
|
-- TODO include title and better error context and formatting
|
|
389
|
-
|> BackendTask.onError (\error -> BackendTask.fail (
|
|
389
|
+
|> BackendTask.onError (\error -> BackendTask.fail (FatalError.fromString error))
|
|
390
390
|
)
|
|
391
391
|
)
|
|
392
392
|
|> BackendTask.andThen
|
|
@@ -397,7 +397,7 @@ serverRender { data, action, head } =
|
|
|
397
397
|
|
|
398
398
|
Err error ->
|
|
399
399
|
Server.Request.errorsToString error
|
|
400
|
-
|>
|
|
400
|
+
|> FatalError.fromString
|
|
401
401
|
|> BackendTask.fail
|
|
402
402
|
)
|
|
403
403
|
, action =
|
|
@@ -410,7 +410,7 @@ serverRender { data, action, head } =
|
|
|
410
410
|
|> Result.mapError Json.Decode.errorToString
|
|
411
411
|
|> BackendTask.fromResult
|
|
412
412
|
-- TODO include title and better error context and formatting
|
|
413
|
-
|> BackendTask.onError (\error -> BackendTask.fail (
|
|
413
|
+
|> BackendTask.onError (\error -> BackendTask.fail (FatalError.fromString error))
|
|
414
414
|
)
|
|
415
415
|
)
|
|
416
416
|
|> BackendTask.andThen
|
|
@@ -421,7 +421,7 @@ serverRender { data, action, head } =
|
|
|
421
421
|
|
|
422
422
|
Err error ->
|
|
423
423
|
Server.Request.errorsToString error
|
|
424
|
-
|>
|
|
424
|
+
|> FatalError.fromString
|
|
425
425
|
|> BackendTask.fail
|
|
426
426
|
)
|
|
427
427
|
, staticRoutes = BackendTask.succeed []
|
|
@@ -2,7 +2,7 @@ module SharedTemplate exposing (SharedTemplate)
|
|
|
2
2
|
|
|
3
3
|
import BackendTask
|
|
4
4
|
import Effect exposing (Effect)
|
|
5
|
-
import
|
|
5
|
+
import FatalError exposing (FatalError)
|
|
6
6
|
import Html exposing (Html)
|
|
7
7
|
import Pages.Flags exposing (Flags)
|
|
8
8
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -36,7 +36,7 @@ type alias SharedTemplate msg sharedModel sharedData mappedMsg =
|
|
|
36
36
|
-> (msg -> mappedMsg)
|
|
37
37
|
-> View mappedMsg
|
|
38
38
|
-> { body : List (Html mappedMsg), title : String }
|
|
39
|
-
, data : BackendTask.BackendTask
|
|
39
|
+
, data : BackendTask.BackendTask FatalError sharedData
|
|
40
40
|
, subscriptions : Path -> sharedModel -> Sub msg
|
|
41
41
|
, onPageChange :
|
|
42
42
|
Maybe
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module 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/generator/src/cli.js
CHANGED
|
@@ -270,7 +270,7 @@ function generatorWrapperFile(moduleName) {
|
|
|
270
270
|
|
|
271
271
|
import Bytes
|
|
272
272
|
import BackendTask exposing (BackendTask)
|
|
273
|
-
import
|
|
273
|
+
import FatalError
|
|
274
274
|
import Cli.Program as Program
|
|
275
275
|
import Json.Decode as Decode
|
|
276
276
|
import Json.Encode as Encode
|
|
@@ -278,7 +278,7 @@ import Pages.Internal.Platform.GeneratorApplication
|
|
|
278
278
|
import ${moduleName}
|
|
279
279
|
|
|
280
280
|
|
|
281
|
-
main : Program.StatefulProgram Pages.Internal.Platform.GeneratorApplication.Model Pages.Internal.Platform.GeneratorApplication.Msg (BackendTask
|
|
281
|
+
main : Program.StatefulProgram Pages.Internal.Platform.GeneratorApplication.Model Pages.Internal.Platform.GeneratorApplication.Msg (BackendTask FatalError.FatalError ()) Pages.Internal.Platform.GeneratorApplication.Flags
|
|
282
282
|
main =
|
|
283
283
|
Pages.Internal.Platform.GeneratorApplication.app
|
|
284
284
|
{ data = ${moduleName}.run
|
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = { compatibilityKey:
|
|
1
|
+
module.exports = { compatibilityKey: 6 };
|
|
@@ -13,11 +13,12 @@ const kleur = require("kleur");
|
|
|
13
13
|
* @param {string} rule
|
|
14
14
|
* @param {string} path
|
|
15
15
|
* */
|
|
16
|
-
|
|
17
|
-
kleur.cyan(
|
|
18
|
-
`-- ${rule.replace("-", " ")} --------------- ${path || ""}
|
|
16
|
+
function parseHeader(rule, path) {
|
|
17
|
+
return kleur.cyan(
|
|
18
|
+
`-- ${(rule || "").replace("-", " ")} --------------- ${path || ""}
|
|
19
19
|
`
|
|
20
20
|
);
|
|
21
|
+
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* parseMsg :: String|Object -> String
|
|
@@ -137,7 +138,10 @@ const restoreProblem =
|
|
|
137
138
|
parseHeader(info.rule, path),
|
|
138
139
|
...info.formatted.map(parseMsg),
|
|
139
140
|
].join("");
|
|
141
|
+
} else if (typeof info.message === "string") {
|
|
142
|
+
return info.message;
|
|
140
143
|
} else {
|
|
144
|
+
// console.log("info.message", info.message);
|
|
141
145
|
return [
|
|
142
146
|
parseHeader(info.title, path),
|
|
143
147
|
...info.message.map(parseMsg),
|
package/generator/src/render.js
CHANGED
|
@@ -143,22 +143,10 @@ function runGeneratorAppHelp(
|
|
|
143
143
|
if (fromElm.command === "log") {
|
|
144
144
|
console.log(fromElm.value);
|
|
145
145
|
} else if (fromElm.tag === "ApiResponse") {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
global.staticHttpCache = args.staticHttpCache;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
resolve({
|
|
152
|
-
kind: "api-response",
|
|
153
|
-
is404: args.is404,
|
|
154
|
-
statusCode: args.statusCode,
|
|
155
|
-
body: args.body,
|
|
156
|
-
});
|
|
146
|
+
// Finished successfully
|
|
147
|
+
process.exit(0);
|
|
157
148
|
} else if (fromElm.tag === "PageProgress") {
|
|
158
149
|
const args = fromElm.args[0];
|
|
159
|
-
if (mode === "build") {
|
|
160
|
-
global.staticHttpCache = args.staticHttpCache;
|
|
161
|
-
}
|
|
162
150
|
|
|
163
151
|
if (isBytes) {
|
|
164
152
|
resolve({
|
|
@@ -653,9 +641,12 @@ function flushIfDone(app) {
|
|
|
653
641
|
}
|
|
654
642
|
|
|
655
643
|
function flushQueue(app) {
|
|
644
|
+
// TODO - could the case where flush is called with size 0 be avoided on the Elm side?
|
|
645
|
+
// if (pendingBackendTaskResponses.size > 0) {
|
|
646
|
+
// console.log("@@@ FLUSHING", pendingBackendTaskResponses.size);
|
|
656
647
|
app.ports.gotBatchSub.send(Object.fromEntries(pendingBackendTaskResponses));
|
|
657
648
|
pendingBackendTaskResponses = new Map();
|
|
658
|
-
//
|
|
649
|
+
// }
|
|
659
650
|
}
|
|
660
651
|
|
|
661
652
|
/**
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
const kleur = require("kleur");
|
|
3
|
+
const fsPromises = require("fs/promises");
|
|
4
|
+
|
|
5
|
+
const defaultHttpCachePath = "./.elm-pages/http-cache";
|
|
3
6
|
|
|
4
7
|
/** @typedef {{kind: 'cache-response-path', value: string} | {kind: 'response-json', value: JSON}} Response */
|
|
5
8
|
|
|
@@ -11,8 +14,7 @@ const kleur = require("kleur");
|
|
|
11
14
|
* @returns {Promise<Response>}
|
|
12
15
|
*/
|
|
13
16
|
function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
14
|
-
const
|
|
15
|
-
cachePath: "./.elm-pages/http-cache",
|
|
17
|
+
const makeFetchHappen = require("make-fetch-happen").defaults({
|
|
16
18
|
cache: mode === "build" ? "no-cache" : "default",
|
|
17
19
|
});
|
|
18
20
|
return new Promise(async (resolve, reject) => {
|
|
@@ -81,7 +83,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
81
83
|
resolve({
|
|
82
84
|
kind: "response-json",
|
|
83
85
|
value: jsonResponse({
|
|
84
|
-
"elm-pages-internal-error": "
|
|
86
|
+
"elm-pages-internal-error": "PortCallException",
|
|
85
87
|
error: portCallError,
|
|
86
88
|
}),
|
|
87
89
|
});
|
|
@@ -97,7 +99,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
97
99
|
} else {
|
|
98
100
|
try {
|
|
99
101
|
console.time(`fetch ${request.url}`);
|
|
100
|
-
const response = await
|
|
102
|
+
const response = await safeFetch(makeFetchHappen, request.url, {
|
|
101
103
|
method: request.method,
|
|
102
104
|
body: request.body,
|
|
103
105
|
headers: {
|
|
@@ -241,4 +243,32 @@ function jsonResponse(json) {
|
|
|
241
243
|
return { bodyKind: "json", body: json };
|
|
242
244
|
}
|
|
243
245
|
|
|
246
|
+
async function safeFetch(makeFetchHappen, url, options) {
|
|
247
|
+
const { cachePath, ...optionsWithoutCachePath } = options;
|
|
248
|
+
const cachePathWithDefault = cachePath || defaultHttpCachePath;
|
|
249
|
+
if (await canAccess(cachePathWithDefault)) {
|
|
250
|
+
return await makeFetchHappen(url, {
|
|
251
|
+
cachePath: cachePathWithDefault,
|
|
252
|
+
...options,
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
return await makeFetchHappen(url, {
|
|
256
|
+
cache: "no-store",
|
|
257
|
+
...optionsWithoutCachePath,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function canAccess(filePath) {
|
|
263
|
+
try {
|
|
264
|
+
await fsPromises.access(
|
|
265
|
+
filePath,
|
|
266
|
+
fsPromises.constants.R_OK | fsPromises.constants.W_OK
|
|
267
|
+
);
|
|
268
|
+
return true;
|
|
269
|
+
} catch {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
244
274
|
module.exports = { lookupOrPerform };
|
|
@@ -224,8 +224,11 @@ function htmlSanitize(str, type) {
|
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
`-- ${title.replace("-", " ")} --------------- ${
|
|
227
|
+
function parseHeader(title, path) {
|
|
228
|
+
return `-- ${(title || "ERROR").replace("-", " ")} --------------- ${
|
|
229
|
+
path || ""
|
|
230
|
+
}`;
|
|
231
|
+
}
|
|
229
232
|
|
|
230
233
|
/*
|
|
231
234
|
|-------------------------------------------------------------------------------
|
|
@@ -253,6 +256,14 @@ const parseConsoleErrors =
|
|
|
253
256
|
* */
|
|
254
257
|
(info) => {
|
|
255
258
|
if (info.rule) {
|
|
259
|
+
if (info.details) {
|
|
260
|
+
return joinMessage(
|
|
261
|
+
info.details.reduce(consoleMsg, {
|
|
262
|
+
error: [consoleHeader(info.rule, path)],
|
|
263
|
+
style: [styleColor("blue")],
|
|
264
|
+
})
|
|
265
|
+
);
|
|
266
|
+
}
|
|
256
267
|
return joinMessage(
|
|
257
268
|
info.formatted.reduce(consoleMsg, {
|
|
258
269
|
error: [consoleHeader(info.rule, path)],
|
|
@@ -313,6 +324,9 @@ const parseHtmlErrors = (path) => (info) => {
|
|
|
313
324
|
if (info.rule) {
|
|
314
325
|
return info.formatted.reduce(htmlMsg, htmlHeader(info.rule, path));
|
|
315
326
|
} else {
|
|
327
|
+
if (info.details) {
|
|
328
|
+
return info.details.reduce(htmlMsg, htmlHeader(info.title, path));
|
|
329
|
+
}
|
|
316
330
|
return info.message.reduce(htmlMsg, htmlHeader(info.title, path));
|
|
317
331
|
}
|
|
318
332
|
};
|
package/package.json
CHANGED