elm-pages 3.0.8 → 3.0.10
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 +4 -4
- package/codegen/elm-pages-codegen.cjs +732 -350
- 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/elm-stuff/0.19.1/i.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 +2 -2
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +7328 -7699
- 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 +2 -2
- package/generator/dead-code-review/elm.json +2 -2
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +1 -1
- package/generator/dead-code-review/src/ReviewConfig.elm +3 -1
- package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +63 -0
- 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/i.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 +2 -2
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +2768 -3160
- 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 +2 -2
- package/generator/review/elm.json +7 -8
- package/generator/src/build.js +3 -4
- package/generator/src/cli.js +1 -1
- package/generator/src/codegen.js +1 -1
- package/generator/src/compatibility-key.js +2 -2
- package/generator/src/render.js +1 -6
- package/generator/static-code/elm-pages.js +12 -9
- package/generator/template/app/ErrorPage.elm +15 -12
- package/generator/template/codegen/elm.codegen.json +2 -2
- package/generator/template/elm-tooling.json +1 -1
- package/generator/template/gitignore +2 -1
- package/generator/template/netlify.toml +1 -1
- package/generator/template/package.json +6 -5
- package/generator/template/script/elm.json +3 -3
- package/generator/template/script/src/AddStaticRoute.elm +87 -0
- package/package.json +25 -24
- package/src/ApiRoute.elm +47 -35
- package/src/BackendTask/Custom.elm +12 -15
- package/src/BackendTask/File.elm +4 -1
- package/src/BackendTask/Glob.elm +34 -31
- package/src/BackendTask.elm +57 -44
- package/src/FatalError.elm +2 -2
- package/src/Head/Seo.elm +3 -3
- package/src/List/Chunks.elm +51 -0
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Manifest.elm +2 -2
- package/src/Scaffold/Route.elm +95 -49
- package/src/Server/Session.elm +9 -6
package/src/Scaffold/Route.elm
CHANGED
|
@@ -118,7 +118,15 @@ serverRender =
|
|
|
118
118
|
ServerRender []
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
{-|
|
|
121
|
+
{-| Will scaffold using `RouteBuilder.preRender` if there are any dynamic segments (as in `Company.Team.Name_`),
|
|
122
|
+
or using `RouteBuilder.single` if there are no dynamic segments (as in `Company.AboutUs`).
|
|
123
|
+
|
|
124
|
+
When there are no dynamic segments, the `pages` field will be ignored as it is only relevant for Routes with dynamic segments.
|
|
125
|
+
|
|
126
|
+
For dynamic segments, the `routeParams` parameter in the `data` function will be an `Elm.Expression` with the `RouteParams` parameter in the `data` function.
|
|
127
|
+
For static segments, it will be a hardcoded empty record (`{}`).
|
|
128
|
+
|
|
129
|
+
-}
|
|
122
130
|
preRender :
|
|
123
131
|
{ data : ( Type, Elm.Expression -> Elm.Expression )
|
|
124
132
|
, pages : Elm.Expression
|
|
@@ -127,29 +135,41 @@ preRender :
|
|
|
127
135
|
}
|
|
128
136
|
-> Builder
|
|
129
137
|
preRender input =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
138
|
+
let
|
|
139
|
+
hasDynamicRouteSegments : Bool
|
|
140
|
+
hasDynamicRouteSegments =
|
|
141
|
+
RoutePattern.fromModuleName input.moduleName
|
|
142
|
+
|> Maybe.map RoutePattern.hasRouteParams
|
|
143
|
+
|> Maybe.withDefault False
|
|
144
|
+
in
|
|
145
|
+
if hasDynamicRouteSegments then
|
|
146
|
+
PreRender []
|
|
147
|
+
{ data = input.data
|
|
148
|
+
, pages =
|
|
149
|
+
input.pages
|
|
150
|
+
|> Elm.withType
|
|
151
|
+
(throwableTask
|
|
152
|
+
(Elm.Annotation.list <| Elm.Annotation.named [] "RouteParams")
|
|
153
|
+
)
|
|
154
|
+
|> Just
|
|
155
|
+
, head = input.head
|
|
156
|
+
, moduleName = input.moduleName
|
|
157
|
+
}
|
|
150
158
|
|
|
159
|
+
else
|
|
160
|
+
PreRender []
|
|
161
|
+
{ data = input.data
|
|
162
|
+
, pages = Nothing
|
|
163
|
+
, head = input.head
|
|
164
|
+
, moduleName = input.moduleName
|
|
165
|
+
}
|
|
151
166
|
|
|
152
|
-
|
|
167
|
+
|
|
168
|
+
{-| @depreacted. This is obsolete and will be removed in a future release. Use [`preRender`](#preRender) instead.
|
|
169
|
+
|
|
170
|
+
If you pass in only static route segments as the `moduleName` to `preRender` it will yield the same result as `single`.
|
|
171
|
+
|
|
172
|
+
-}
|
|
153
173
|
single :
|
|
154
174
|
{ data : ( Type, Elm.Expression )
|
|
155
175
|
, head : Elm.Expression -> Elm.Expression
|
|
@@ -656,7 +676,7 @@ userFunction moduleName definitions =
|
|
|
656
676
|
Elm.Declare.function "data"
|
|
657
677
|
[]
|
|
658
678
|
(\_ ->
|
|
659
|
-
definitions.data Elm.unit Elm.
|
|
679
|
+
definitions.data Elm.unit (Elm.record [])
|
|
660
680
|
|> Elm.withType
|
|
661
681
|
(case definitions.action of
|
|
662
682
|
Pages _ ->
|
|
@@ -668,34 +688,60 @@ userFunction moduleName definitions =
|
|
|
668
688
|
)
|
|
669
689
|
|
|
670
690
|
_ ->
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
+
case definitions.action of
|
|
692
|
+
Pages _ ->
|
|
693
|
+
Elm.Declare.function "data"
|
|
694
|
+
[ ( "routeParams"
|
|
695
|
+
, "RouteParams"
|
|
696
|
+
|> Elm.Annotation.named []
|
|
697
|
+
|> Just
|
|
698
|
+
)
|
|
699
|
+
]
|
|
700
|
+
(\args ->
|
|
701
|
+
case args of
|
|
702
|
+
[ arg ] ->
|
|
703
|
+
definitions.data
|
|
704
|
+
(arg
|
|
705
|
+
|> Elm.withType
|
|
706
|
+
(throwableTask
|
|
707
|
+
(Elm.Annotation.named [] "Data")
|
|
708
|
+
)
|
|
709
|
+
)
|
|
710
|
+
Elm.unit
|
|
691
711
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
712
|
+
_ ->
|
|
713
|
+
Elm.unit
|
|
714
|
+
)
|
|
695
715
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
716
|
+
Action _ ->
|
|
717
|
+
Elm.Declare.function "data"
|
|
718
|
+
[ ( "routeParams"
|
|
719
|
+
, "RouteParams"
|
|
720
|
+
|> Elm.Annotation.named []
|
|
721
|
+
|> Just
|
|
722
|
+
)
|
|
723
|
+
, ( "request"
|
|
724
|
+
, "Request"
|
|
725
|
+
|> Elm.Annotation.named [ "Server", "Request" ]
|
|
726
|
+
|> Just
|
|
727
|
+
)
|
|
728
|
+
]
|
|
729
|
+
(\args ->
|
|
730
|
+
case args of
|
|
731
|
+
[ arg, arg2 ] ->
|
|
732
|
+
definitions.data arg arg2
|
|
733
|
+
|> Elm.withType
|
|
734
|
+
(case definitions.action of
|
|
735
|
+
Pages _ ->
|
|
736
|
+
throwableTask (Elm.Annotation.named [] "Data")
|
|
737
|
+
|
|
738
|
+
Action _ ->
|
|
739
|
+
myType "Data"
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
_ ->
|
|
743
|
+
Elm.unit
|
|
744
|
+
)
|
|
699
745
|
|
|
700
746
|
actionFn : Maybe { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression }
|
|
701
747
|
actionFn =
|
package/src/Server/Session.elm
CHANGED
|
@@ -27,7 +27,7 @@ Using these functions, you can store and read session data in cookies to maintai
|
|
|
27
27
|
type alias Data =
|
|
28
28
|
{ darkMode : Bool }
|
|
29
29
|
|
|
30
|
-
data : RouteParams -> Request -> BackendTask (Response Data ErrorPage)
|
|
30
|
+
data : RouteParams -> Request -> BackendTask FatalError (Response Data ErrorPage)
|
|
31
31
|
data routeParams request =
|
|
32
32
|
request
|
|
33
33
|
|> Session.withSession
|
|
@@ -42,12 +42,15 @@ Using these functions, you can store and read session data in cookies to maintai
|
|
|
42
42
|
(session |> Session.get "mode" |> Maybe.withDefault "light")
|
|
43
43
|
== "dark"
|
|
44
44
|
in
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
BackendTask.succeed
|
|
46
|
+
( session
|
|
47
|
+
, Response.render
|
|
48
|
+
{ darkMode = darkMode
|
|
49
|
+
}
|
|
50
|
+
)
|
|
48
51
|
)
|
|
49
52
|
|
|
50
|
-
The elm-pages framework will manage signing these cookies using the `secrets : BackendTask (List String)` you pass in.
|
|
53
|
+
The elm-pages framework will manage signing these cookies using the `secrets : BackendTask FatalError (List String)` you pass in.
|
|
51
54
|
That means that the values you set in your session will be directly visible to anyone who has access to the cookie
|
|
52
55
|
(so don't directly store sensitive data in your session). Since the session cookie is signed using the secret you provide,
|
|
53
56
|
the cookie will be invalidated if it is tampered with because it won't match when elm-pages verifies that it has been
|
|
@@ -56,7 +59,7 @@ signed with your secrets. Of course you need to provide secure secrets and treat
|
|
|
56
59
|
|
|
57
60
|
### Rotating Secrets
|
|
58
61
|
|
|
59
|
-
The first String in `secrets : BackendTask (List String)` will be used to sign sessions, while the remaining String's will
|
|
62
|
+
The first String in `secrets : BackendTask FatalError (List String)` will be used to sign sessions, while the remaining String's will
|
|
60
63
|
still be used to attempt to "unsign" the cookies. So if you have a single secret:
|
|
61
64
|
|
|
62
65
|
Session.withSession
|