elm-pages 3.0.0-beta.8 → 3.0.0-beta.9
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 +10 -1
- package/codegen/elm-pages-codegen.js +1 -1
- 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/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +1 -1
- 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 +4 -4
- 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/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +1 -1
- 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 +4 -4
- package/generator/src/build.js +11 -11
- package/generator/src/dev-server.js +15 -6
- package/generator/src/render.js +2 -0
- package/generator/src/seo-renderer.js +11 -4
- package/package.json +1 -1
- package/src/ApiRoute.elm +0 -3
- package/src/DataSource.elm +11 -3
- package/src/Head.elm +126 -0
- package/src/Pages/Generate.elm +101 -10
- package/src/Pages/Internal/Platform/Cli.elm +50 -6
- package/src/Pages/Internal/Platform/Cli.elm.bak +1276 -0
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +6 -0
package/src/Pages/Generate.elm
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Pages.Generate exposing
|
|
2
|
-
( buildWithLocalState, buildNoState, Builder
|
|
2
|
+
( buildWithLocalState, buildWithSharedState, buildNoState, Builder
|
|
3
3
|
, Type(..)
|
|
4
4
|
, serverRender
|
|
5
5
|
, preRender, single
|
|
@@ -10,7 +10,7 @@ module Pages.Generate exposing
|
|
|
10
10
|
|
|
11
11
|
## Initializing the Generator Builder
|
|
12
12
|
|
|
13
|
-
@docs buildWithLocalState, buildNoState, Builder
|
|
13
|
+
@docs buildWithLocalState, buildWithSharedState, buildNoState, Builder
|
|
14
14
|
|
|
15
15
|
@docs Type
|
|
16
16
|
|
|
@@ -190,6 +190,7 @@ buildWithLocalState definitions builder_ =
|
|
|
190
190
|
{ update = definitions.update
|
|
191
191
|
, init = definitions.init
|
|
192
192
|
, subscriptions = definitions.subscriptions
|
|
193
|
+
, state = LocalState
|
|
193
194
|
}
|
|
194
195
|
, data = builder.data |> Tuple.second
|
|
195
196
|
, action = builder.action |> Tuple.second |> Action
|
|
@@ -210,6 +211,7 @@ buildWithLocalState definitions builder_ =
|
|
|
210
211
|
{ update = definitions.update
|
|
211
212
|
, init = definitions.init
|
|
212
213
|
, subscriptions = definitions.subscriptions
|
|
214
|
+
, state = LocalState
|
|
213
215
|
}
|
|
214
216
|
, data = builder.data |> Tuple.second
|
|
215
217
|
, action = builder.pages |> Pages
|
|
@@ -228,6 +230,72 @@ buildWithLocalState definitions builder_ =
|
|
|
228
230
|
}
|
|
229
231
|
|
|
230
232
|
|
|
233
|
+
{-| -}
|
|
234
|
+
buildWithSharedState :
|
|
235
|
+
{ view : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
236
|
+
, update : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
237
|
+
, init : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
238
|
+
, subscriptions : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
239
|
+
, msg : Type
|
|
240
|
+
, model : Type
|
|
241
|
+
}
|
|
242
|
+
-> Builder
|
|
243
|
+
-> Elm.File
|
|
244
|
+
buildWithSharedState definitions builder_ =
|
|
245
|
+
case builder_ of
|
|
246
|
+
ServerRender builder ->
|
|
247
|
+
userFunction builder.moduleName
|
|
248
|
+
{ view = definitions.view
|
|
249
|
+
, localState =
|
|
250
|
+
Just
|
|
251
|
+
{ update = definitions.update
|
|
252
|
+
, init = definitions.init
|
|
253
|
+
, subscriptions = definitions.subscriptions
|
|
254
|
+
, state = SharedState
|
|
255
|
+
}
|
|
256
|
+
, data = builder.data |> Tuple.second
|
|
257
|
+
, action = builder.action |> Tuple.second |> Action
|
|
258
|
+
, head = builder.head
|
|
259
|
+
, types =
|
|
260
|
+
{ model = definitions.model
|
|
261
|
+
, msg = definitions.msg
|
|
262
|
+
, data = builder.data |> Tuple.first
|
|
263
|
+
, actionData = builder.action |> Tuple.first
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
PreRender builder ->
|
|
268
|
+
userFunction builder.moduleName
|
|
269
|
+
{ view = definitions.view
|
|
270
|
+
, localState =
|
|
271
|
+
Just
|
|
272
|
+
{ update = definitions.update
|
|
273
|
+
, init = definitions.init
|
|
274
|
+
, subscriptions = definitions.subscriptions
|
|
275
|
+
, state = SharedState
|
|
276
|
+
}
|
|
277
|
+
, data = builder.data |> Tuple.second
|
|
278
|
+
, action = builder.pages |> Pages
|
|
279
|
+
, head = builder.head
|
|
280
|
+
, types =
|
|
281
|
+
{ model = definitions.model
|
|
282
|
+
, msg = definitions.msg
|
|
283
|
+
, data = builder.data |> Tuple.first
|
|
284
|
+
, actionData =
|
|
285
|
+
Elm.Annotation.namedWith [ "DataSource" ]
|
|
286
|
+
"DataSource"
|
|
287
|
+
[ Elm.Annotation.list (Elm.Annotation.named [] "RouteParams")
|
|
288
|
+
]
|
|
289
|
+
|> Alias
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
type State
|
|
295
|
+
= SharedState
|
|
296
|
+
| LocalState
|
|
297
|
+
|
|
298
|
+
|
|
231
299
|
type ActionOrPages
|
|
232
300
|
= Action (Elm.Expression -> Elm.Expression)
|
|
233
301
|
| Pages (Maybe Elm.Expression)
|
|
@@ -243,6 +311,7 @@ userFunction :
|
|
|
243
311
|
{ update : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
244
312
|
, init : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
245
313
|
, subscriptions : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
314
|
+
, state : State
|
|
246
315
|
}
|
|
247
316
|
, data : Elm.Expression -> Elm.Expression
|
|
248
317
|
, action : ActionOrPages
|
|
@@ -309,6 +378,7 @@ userFunction moduleName definitions =
|
|
|
309
378
|
}
|
|
310
379
|
, initFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression }
|
|
311
380
|
, subscriptionsFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression }
|
|
381
|
+
, state : State
|
|
312
382
|
}
|
|
313
383
|
localDefinitions =
|
|
314
384
|
definitions.localState
|
|
@@ -351,6 +421,7 @@ userFunction moduleName definitions =
|
|
|
351
421
|
( "sharedModel", Nothing )
|
|
352
422
|
( "model", Nothing )
|
|
353
423
|
localState.subscriptions
|
|
424
|
+
, state = localState.state
|
|
354
425
|
}
|
|
355
426
|
)
|
|
356
427
|
|
|
@@ -512,6 +583,7 @@ userFunction moduleName definitions =
|
|
|
512
583
|
, update = local.updateFn.call
|
|
513
584
|
, init = local.initFn.call
|
|
514
585
|
, subscriptions = local.subscriptionsFn.call
|
|
586
|
+
, state = local.state
|
|
515
587
|
}
|
|
516
588
|
>> Elm.withType
|
|
517
589
|
(Elm.Annotation.namedWith [ "RouteBuilder" ]
|
|
@@ -837,6 +909,7 @@ buildWithLocalState_ :
|
|
|
837
909
|
-> Elm.Expression
|
|
838
910
|
-> Elm.Expression
|
|
839
911
|
-> Elm.Expression
|
|
912
|
+
, state : State
|
|
840
913
|
}
|
|
841
914
|
-> Elm.Expression
|
|
842
915
|
-> Elm.Expression
|
|
@@ -844,7 +917,13 @@ buildWithLocalState_ buildWithLocalStateArg buildWithLocalStateArg0 =
|
|
|
844
917
|
Elm.apply
|
|
845
918
|
(Elm.value
|
|
846
919
|
{ importFrom = [ "RouteBuilder" ]
|
|
847
|
-
, name =
|
|
920
|
+
, name =
|
|
921
|
+
case buildWithLocalStateArg.state of
|
|
922
|
+
LocalState ->
|
|
923
|
+
"buildWithLocalState"
|
|
924
|
+
|
|
925
|
+
SharedState ->
|
|
926
|
+
"buildWithSharedState"
|
|
848
927
|
, annotation =
|
|
849
928
|
Just
|
|
850
929
|
(Elm.Annotation.function
|
|
@@ -920,13 +999,25 @@ buildWithLocalState_ buildWithLocalStateArg buildWithLocalStateArg0 =
|
|
|
920
999
|
, Elm.Annotation.var "msg"
|
|
921
1000
|
, Elm.Annotation.var "model"
|
|
922
1001
|
]
|
|
923
|
-
(
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1002
|
+
(case buildWithLocalStateArg.state of
|
|
1003
|
+
LocalState ->
|
|
1004
|
+
Elm.Annotation.tuple
|
|
1005
|
+
(Elm.Annotation.var "model")
|
|
1006
|
+
(Elm.Annotation.namedWith
|
|
1007
|
+
[ "Effect" ]
|
|
1008
|
+
"Effect"
|
|
1009
|
+
[ Elm.Annotation.var "msg" ]
|
|
1010
|
+
)
|
|
1011
|
+
|
|
1012
|
+
SharedState ->
|
|
1013
|
+
Elm.Annotation.triple
|
|
1014
|
+
(Elm.Annotation.var "model")
|
|
1015
|
+
(Elm.Annotation.namedWith
|
|
1016
|
+
[ "Effect" ]
|
|
1017
|
+
"Effect"
|
|
1018
|
+
[ Elm.Annotation.var "msg" ]
|
|
1019
|
+
)
|
|
1020
|
+
(Elm.Annotation.maybe (Elm.Annotation.named [ "Shared" ] "Msg"))
|
|
930
1021
|
)
|
|
931
1022
|
)
|
|
932
1023
|
, ( "subscriptions"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module Pages.Internal.Platform.Cli exposing (Flags, Model, Msg(..), Program, cliApplication, init, requestDecoder, update)
|
|
1
|
+
module Pages.Internal.Platform.Cli exposing (Flags, Model, Msg(..), Program, cliApplication, init, requestDecoder, update, currentCompatibilityKey)
|
|
2
2
|
|
|
3
3
|
{-| Exposed for internal use only (used in generated code).
|
|
4
4
|
|
|
5
|
-
@docs Flags, Model, Msg, Program, cliApplication, init, requestDecoder, update
|
|
5
|
+
@docs Flags, Model, Msg, Program, cliApplication, init, requestDecoder, update, currentCompatibilityKey
|
|
6
6
|
|
|
7
7
|
-}
|
|
8
8
|
|
|
@@ -23,6 +23,7 @@ import PageServerResponse exposing (PageServerResponse)
|
|
|
23
23
|
import Pages.Flags
|
|
24
24
|
import Pages.Http
|
|
25
25
|
import Pages.Internal.NotFoundReason as NotFoundReason exposing (NotFoundReason)
|
|
26
|
+
import Pages.Internal.Platform.CompatibilityKey
|
|
26
27
|
import Pages.Internal.Platform.Effect as Effect exposing (Effect)
|
|
27
28
|
import Pages.Internal.Platform.StaticResponses as StaticResponses exposing (StaticResponses)
|
|
28
29
|
import Pages.Internal.Platform.ToJsPayload as ToJsPayload
|
|
@@ -46,6 +47,12 @@ type alias Flags =
|
|
|
46
47
|
Decode.Value
|
|
47
48
|
|
|
48
49
|
|
|
50
|
+
{-| -}
|
|
51
|
+
currentCompatibilityKey : Int
|
|
52
|
+
currentCompatibilityKey =
|
|
53
|
+
Pages.Internal.Platform.CompatibilityKey.currentCompatibilityKey
|
|
54
|
+
|
|
55
|
+
|
|
49
56
|
{-| -}
|
|
50
57
|
type alias Model route =
|
|
51
58
|
{ staticResponses : StaticResponses
|
|
@@ -336,12 +343,14 @@ flagsDecoder :
|
|
|
336
343
|
Decode.Decoder
|
|
337
344
|
{ staticHttpCache : RequestsAndPending
|
|
338
345
|
, isDevServer : Bool
|
|
346
|
+
, compatibilityKey : Int
|
|
339
347
|
}
|
|
340
348
|
flagsDecoder =
|
|
341
|
-
Decode.
|
|
342
|
-
(\staticHttpCache isDevServer ->
|
|
349
|
+
Decode.map3
|
|
350
|
+
(\staticHttpCache isDevServer compatibilityKey ->
|
|
343
351
|
{ staticHttpCache = staticHttpCache
|
|
344
352
|
, isDevServer = isDevServer
|
|
353
|
+
, compatibilityKey = compatibilityKey
|
|
345
354
|
}
|
|
346
355
|
)
|
|
347
356
|
--(Decode.field "staticHttpCache"
|
|
@@ -354,6 +363,7 @@ flagsDecoder =
|
|
|
354
363
|
-- TODO remove hardcoding and decode staticHttpCache here
|
|
355
364
|
(Decode.succeed Dict.empty)
|
|
356
365
|
(Decode.field "mode" Decode.string |> Decode.map (\mode -> mode == "dev-server"))
|
|
366
|
+
(Decode.field "compatibilityKey" Decode.int)
|
|
357
367
|
|
|
358
368
|
|
|
359
369
|
{-| -}
|
|
@@ -365,8 +375,42 @@ init :
|
|
|
365
375
|
-> ( Model route, Effect )
|
|
366
376
|
init site renderRequest config flags =
|
|
367
377
|
case Decode.decodeValue flagsDecoder flags of
|
|
368
|
-
Ok { staticHttpCache, isDevServer } ->
|
|
369
|
-
|
|
378
|
+
Ok { staticHttpCache, isDevServer, compatibilityKey } ->
|
|
379
|
+
if compatibilityKey == currentCompatibilityKey then
|
|
380
|
+
initLegacy site renderRequest { staticHttpCache = staticHttpCache, isDevServer = isDevServer } config
|
|
381
|
+
|
|
382
|
+
else
|
|
383
|
+
let
|
|
384
|
+
elmPackageAheadOfNpmPackage : Bool
|
|
385
|
+
elmPackageAheadOfNpmPackage =
|
|
386
|
+
currentCompatibilityKey > compatibilityKey
|
|
387
|
+
|
|
388
|
+
message : String
|
|
389
|
+
message =
|
|
390
|
+
"The NPM package and Elm package you have installed are incompatible. If you are updating versions, be sure to update both the elm-pages Elm and NPM package.\n\n"
|
|
391
|
+
++ (if elmPackageAheadOfNpmPackage then
|
|
392
|
+
"The elm-pages Elm package is ahead of the elm-pages NPM package. Try updating the elm-pages NPM package?"
|
|
393
|
+
|
|
394
|
+
else
|
|
395
|
+
"The elm-pages NPM package is ahead of the elm-pages Elm package. Try updating the elm-pages Elm package?"
|
|
396
|
+
)
|
|
397
|
+
in
|
|
398
|
+
updateAndSendPortIfDone
|
|
399
|
+
site
|
|
400
|
+
config
|
|
401
|
+
{ staticResponses = StaticResponses.empty
|
|
402
|
+
, errors =
|
|
403
|
+
[ { title = "Incompatible NPM and Elm package versions"
|
|
404
|
+
, message = [ Terminal.text <| message ]
|
|
405
|
+
, fatal = True
|
|
406
|
+
, path = ""
|
|
407
|
+
}
|
|
408
|
+
]
|
|
409
|
+
, allRawResponses = Dict.empty
|
|
410
|
+
, unprocessedPages = []
|
|
411
|
+
, maybeRequestJson = renderRequest
|
|
412
|
+
, isDevServer = False
|
|
413
|
+
}
|
|
370
414
|
|
|
371
415
|
Err error ->
|
|
372
416
|
updateAndSendPortIfDone
|