elm-pages 3.0.0-beta.15 → 3.0.0-beta.17
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/build.js +7 -7
- package/generator/src/cli.js +11 -8
- package/generator/src/compatibility-key.js +1 -1
- package/generator/src/dev-server.js +6 -6
- package/generator/src/render-test.js +1 -1
- package/generator/src/render.js +5 -5
- package/generator/src/request-cache.js +5 -5
- package/package.json +1 -1
- package/src/ApiRoute.elm +13 -13
- package/src/BackendTask/{Port.elm → Custom.elm} +60 -52
- 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.elm +9 -23
- 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
|
@@ -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: 1374716823, 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/build.js
CHANGED
|
@@ -143,9 +143,9 @@ async function run(options) {
|
|
|
143
143
|
|
|
144
144
|
const portBackendTaskCompiled = esbuild
|
|
145
145
|
.build({
|
|
146
|
-
entryPoints: ["./
|
|
146
|
+
entryPoints: ["./custom-backend-task"],
|
|
147
147
|
platform: "node",
|
|
148
|
-
outfile: ".elm-pages/compiled-ports/
|
|
148
|
+
outfile: ".elm-pages/compiled-ports/custom-backend-task.js",
|
|
149
149
|
assetNames: "[name]-[hash]",
|
|
150
150
|
chunkNames: "chunks/[name]-[hash]",
|
|
151
151
|
outExtension: { ".js": ".js" },
|
|
@@ -161,11 +161,11 @@ async function run(options) {
|
|
|
161
161
|
})
|
|
162
162
|
.catch((error) => {
|
|
163
163
|
const portBackendTaskFileFound =
|
|
164
|
-
globby.sync("./
|
|
164
|
+
globby.sync("./custom-backend-task.*").length > 0;
|
|
165
165
|
if (portBackendTaskFileFound) {
|
|
166
|
-
// don't present error if there are no files matching
|
|
167
|
-
// if there are files matching
|
|
168
|
-
console.error("Failed to start
|
|
166
|
+
// don't present error if there are no files matching custom-backend-task
|
|
167
|
+
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
|
|
168
|
+
console.error("Failed to start custom-backend-task watcher", error);
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
// TODO extract common code for compiling ports file?
|
|
@@ -617,7 +617,7 @@ async function runAdapter(adaptFn, processedIndexTemplate) {
|
|
|
617
617
|
apiRoutePatterns: JSON.parse(
|
|
618
618
|
await fsPromises.readFile("./dist/api-patterns.json", "utf-8")
|
|
619
619
|
),
|
|
620
|
-
portsFilePath: "./.elm-pages/compiled-ports/
|
|
620
|
+
portsFilePath: "./.elm-pages/compiled-ports/custom-backend-task.js",
|
|
621
621
|
htmlTemplate: processedIndexTemplate,
|
|
622
622
|
});
|
|
623
623
|
console.log("Success - Adapter script complete");
|
package/generator/src/cli.js
CHANGED
|
@@ -131,9 +131,9 @@ async function main() {
|
|
|
131
131
|
|
|
132
132
|
const portBackendTaskCompiled = esbuild
|
|
133
133
|
.build({
|
|
134
|
-
entryPoints: ["./
|
|
134
|
+
entryPoints: ["./custom-backend-task"],
|
|
135
135
|
platform: "node",
|
|
136
|
-
outfile: ".elm-pages/compiled-ports/
|
|
136
|
+
outfile: ".elm-pages/compiled-ports/custom-backend-task.js",
|
|
137
137
|
assetNames: "[name]-[hash]",
|
|
138
138
|
chunkNames: "chunks/[name]-[hash]",
|
|
139
139
|
outExtension: { ".js": ".js" },
|
|
@@ -151,11 +151,14 @@ async function main() {
|
|
|
151
151
|
})
|
|
152
152
|
.catch((error) => {
|
|
153
153
|
const portBackendTaskFileFound =
|
|
154
|
-
globby.sync("./
|
|
154
|
+
globby.sync("./custom-backend-task.*").length > 0;
|
|
155
155
|
if (portBackendTaskFileFound) {
|
|
156
|
-
// don't present error if there are no files matching
|
|
157
|
-
// if there are files matching
|
|
158
|
-
console.error(
|
|
156
|
+
// don't present error if there are no files matching custom-backend-task
|
|
157
|
+
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
|
|
158
|
+
console.error(
|
|
159
|
+
"Failed to start custom-backend-task watcher",
|
|
160
|
+
error
|
|
161
|
+
);
|
|
159
162
|
}
|
|
160
163
|
});
|
|
161
164
|
const portsPath = await portBackendTaskCompiled;
|
|
@@ -270,7 +273,7 @@ function generatorWrapperFile(moduleName) {
|
|
|
270
273
|
|
|
271
274
|
import Bytes
|
|
272
275
|
import BackendTask exposing (BackendTask)
|
|
273
|
-
import
|
|
276
|
+
import FatalError
|
|
274
277
|
import Cli.Program as Program
|
|
275
278
|
import Json.Decode as Decode
|
|
276
279
|
import Json.Encode as Encode
|
|
@@ -278,7 +281,7 @@ import Pages.Internal.Platform.GeneratorApplication
|
|
|
278
281
|
import ${moduleName}
|
|
279
282
|
|
|
280
283
|
|
|
281
|
-
main : Program.StatefulProgram Pages.Internal.Platform.GeneratorApplication.Model Pages.Internal.Platform.GeneratorApplication.Msg (BackendTask
|
|
284
|
+
main : Program.StatefulProgram Pages.Internal.Platform.GeneratorApplication.Model Pages.Internal.Platform.GeneratorApplication.Msg (BackendTask FatalError.FatalError ()) Pages.Internal.Platform.GeneratorApplication.Flags
|
|
282
285
|
main =
|
|
283
286
|
Pages.Internal.Platform.GeneratorApplication.app
|
|
284
287
|
{ data = ${moduleName}.run
|
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = { compatibilityKey:
|
|
1
|
+
module.exports = { compatibilityKey: 6 };
|
|
@@ -140,7 +140,7 @@ async function start(options) {
|
|
|
140
140
|
);
|
|
141
141
|
esbuild
|
|
142
142
|
.build({
|
|
143
|
-
entryPoints: ["./
|
|
143
|
+
entryPoints: ["./custom-backend-task"],
|
|
144
144
|
platform: "node",
|
|
145
145
|
assetNames: "[name]-[hash]",
|
|
146
146
|
chunkNames: "chunks/[name]-[hash]",
|
|
@@ -171,15 +171,15 @@ async function start(options) {
|
|
|
171
171
|
],
|
|
172
172
|
})
|
|
173
173
|
.then((result) => {
|
|
174
|
-
console.log("Watching
|
|
174
|
+
console.log("Watching custom-backend-task...");
|
|
175
175
|
})
|
|
176
176
|
.catch((error) => {
|
|
177
177
|
const portBackendTaskFileFound =
|
|
178
|
-
globby.sync("./
|
|
178
|
+
globby.sync("./custom-backend-task.*").length > 0;
|
|
179
179
|
if (portBackendTaskFileFound) {
|
|
180
|
-
// don't present error if there are no files matching
|
|
181
|
-
// if there are files matching
|
|
182
|
-
console.error("Failed to start
|
|
180
|
+
// don't present error if there are no files matching custom-backend-task
|
|
181
|
+
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
|
|
182
|
+
console.error("Failed to start custom-backend-task watcher", error);
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
|
|
@@ -27,7 +27,7 @@ async function run({ pathname, serverRequest }) {
|
|
|
27
27
|
console.log("Compiling DONE");
|
|
28
28
|
|
|
29
29
|
const portsFilePath =
|
|
30
|
-
".elm-pages/compiled-ports/
|
|
30
|
+
".elm-pages/compiled-ports/custom-backend-task-FA2IJND6.js";
|
|
31
31
|
const mode = "dev-server";
|
|
32
32
|
|
|
33
33
|
const renderResult = await renderer.render(
|
package/generator/src/render.js
CHANGED
|
@@ -642,11 +642,11 @@ function flushIfDone(app) {
|
|
|
642
642
|
|
|
643
643
|
function flushQueue(app) {
|
|
644
644
|
// TODO - could the case where flush is called with size 0 be avoided on the Elm side?
|
|
645
|
-
if (pendingBackendTaskResponses.size > 0) {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
645
|
+
// if (pendingBackendTaskResponses.size > 0) {
|
|
646
|
+
// console.log("@@@ FLUSHING", pendingBackendTaskResponses.size);
|
|
647
|
+
app.ports.gotBatchSub.send(Object.fromEntries(pendingBackendTaskResponses));
|
|
648
|
+
pendingBackendTaskResponses = new Map();
|
|
649
|
+
// }
|
|
650
650
|
}
|
|
651
651
|
|
|
652
652
|
/**
|
|
@@ -43,21 +43,21 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
43
43
|
resolve({
|
|
44
44
|
kind: "response-json",
|
|
45
45
|
value: jsonResponse({
|
|
46
|
-
"elm-pages-internal-error": "
|
|
46
|
+
"elm-pages-internal-error": "CustomBackendTaskNotDefined",
|
|
47
47
|
}),
|
|
48
48
|
});
|
|
49
49
|
} else if (portBackendTaskImportError === "missing") {
|
|
50
50
|
resolve({
|
|
51
51
|
kind: "response-json",
|
|
52
52
|
value: jsonResponse({
|
|
53
|
-
"elm-pages-internal-error": "
|
|
53
|
+
"elm-pages-internal-error": "MissingCustomBackendTaskFile",
|
|
54
54
|
}),
|
|
55
55
|
});
|
|
56
56
|
} else {
|
|
57
57
|
resolve({
|
|
58
58
|
kind: "response-json",
|
|
59
59
|
value: jsonResponse({
|
|
60
|
-
"elm-pages-internal-error": "
|
|
60
|
+
"elm-pages-internal-error": "ErrorInCustomBackendTaskFile",
|
|
61
61
|
error:
|
|
62
62
|
(portBackendTaskImportError &&
|
|
63
63
|
portBackendTaskImportError.stack) ||
|
|
@@ -83,7 +83,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
83
83
|
resolve({
|
|
84
84
|
kind: "response-json",
|
|
85
85
|
value: jsonResponse({
|
|
86
|
-
"elm-pages-internal-error": "
|
|
86
|
+
"elm-pages-internal-error": "CustomBackendTaskException",
|
|
87
87
|
error: portCallError,
|
|
88
88
|
}),
|
|
89
89
|
});
|
|
@@ -92,7 +92,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
|
|
92
92
|
} catch (error) {
|
|
93
93
|
console.trace(error);
|
|
94
94
|
reject({
|
|
95
|
-
title: "BackendTask.
|
|
95
|
+
title: "BackendTask.Custom Error",
|
|
96
96
|
message: error.toString(),
|
|
97
97
|
});
|
|
98
98
|
}
|
package/package.json
CHANGED