elm-pages 3.0.0-beta.9 → 3.0.0
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 +2 -2
- package/adapter/netlify.js +207 -0
- package/codegen/{elm-pages-codegen.js → elm-pages-codegen.cjs} +2731 -2939
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +0 -0
- 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 +1527 -422
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +16840 -13653
- 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/dead-code-review/elm.json +9 -7
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +59 -10
- package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +52 -36
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmo +0 -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 +1527 -422
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +25118 -21832
- 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/review/elm.json +10 -10
- package/generator/src/RouteBuilder.elm +93 -128
- package/generator/src/SharedTemplate.elm +8 -7
- package/generator/src/SiteConfig.elm +3 -2
- package/generator/src/basepath-middleware.js +3 -3
- package/generator/src/build.js +143 -59
- package/generator/src/cli.js +292 -88
- package/generator/src/codegen.js +29 -27
- package/generator/src/compatibility-key.js +3 -0
- package/generator/src/compile-elm.js +43 -26
- package/generator/src/config.js +2 -4
- package/generator/src/copy-dir.js +2 -2
- package/generator/src/dev-server.js +160 -102
- package/generator/src/dir-helpers.js +9 -26
- package/generator/src/elm-codegen.js +5 -4
- package/generator/src/elm-file-constants.js +2 -3
- package/generator/src/error-formatter.js +12 -11
- package/generator/src/file-helpers.js +3 -4
- package/generator/src/generate-template-module-connector.js +23 -23
- package/generator/src/init.js +9 -8
- package/generator/src/pre-render-html.js +10 -13
- package/generator/src/render-test.js +109 -0
- package/generator/src/render-worker.js +25 -28
- package/generator/src/render.js +320 -143
- package/generator/src/request-cache.js +265 -162
- package/generator/src/resolve-elm-module.js +64 -0
- package/generator/src/rewrite-client-elm-json.js +6 -5
- package/generator/src/rewrite-elm-json-help.js +56 -0
- package/generator/src/rewrite-elm-json.js +17 -7
- package/generator/src/route-codegen-helpers.js +16 -31
- package/generator/src/seo-renderer.js +1 -3
- package/generator/src/vite-utils.js +1 -2
- package/generator/static-code/elm-pages.js +10 -0
- package/generator/static-code/hmr.js +79 -13
- package/generator/template/app/Api.elm +3 -2
- package/generator/template/app/Effect.elm +155 -0
- package/generator/template/app/ErrorPage.elm +49 -6
- package/generator/template/app/Route/Blog/Slug_.elm +86 -0
- package/generator/template/app/Route/Greet.elm +107 -0
- package/generator/template/app/Route/Hello.elm +119 -0
- package/generator/template/app/Route/Index.elm +26 -25
- package/generator/template/app/Shared.elm +38 -39
- package/generator/template/app/Site.elm +4 -7
- package/generator/template/app/View.elm +9 -8
- package/generator/template/codegen/elm.codegen.json +18 -0
- package/generator/template/custom-backend-task.ts +3 -0
- package/generator/template/elm-pages.config.mjs +13 -0
- package/generator/template/elm-tooling.json +0 -3
- package/generator/template/elm.json +25 -20
- package/generator/template/index.ts +1 -2
- package/generator/template/netlify.toml +4 -1
- package/generator/template/package.json +10 -4
- package/generator/template/script/.elm-pages/compiled-ports/custom-backend-task.mjs +7 -0
- package/generator/template/script/custom-backend-task.ts +3 -0
- package/generator/template/script/elm.json +61 -0
- package/generator/template/script/src/AddRoute.elm +312 -0
- package/generator/template/script/src/Stars.elm +42 -0
- package/package.json +30 -27
- package/src/ApiRoute.elm +249 -82
- package/src/BackendTask/Custom.elm +325 -0
- package/src/BackendTask/Env.elm +90 -0
- package/src/{DataSource → BackendTask}/File.elm +171 -56
- package/src/{DataSource → BackendTask}/Glob.elm +136 -125
- package/src/BackendTask/Http.elm +679 -0
- package/src/{DataSource → BackendTask}/Internal/Glob.elm +1 -1
- package/src/BackendTask/Internal/Request.elm +69 -0
- package/src/BackendTask/Random.elm +79 -0
- package/src/BackendTask/Time.elm +47 -0
- package/src/BackendTask.elm +531 -0
- package/src/FatalError.elm +90 -0
- package/src/FormData.elm +21 -18
- package/src/Head/Seo.elm +4 -4
- package/src/Head.elm +112 -8
- package/src/Internal/ApiRoute.elm +7 -5
- package/src/Internal/Request.elm +84 -4
- package/src/PageServerResponse.elm +6 -1
- package/src/Pages/ConcurrentSubmission.elm +127 -0
- package/src/Pages/Form.elm +340 -0
- package/src/Pages/FormData.elm +19 -0
- package/src/Pages/GeneratorProgramConfig.elm +15 -0
- package/src/Pages/Internal/FatalError.elm +5 -0
- package/src/Pages/Internal/Msg.elm +93 -0
- package/src/Pages/Internal/NotFoundReason.elm +4 -4
- package/src/Pages/Internal/Platform/Cli.elm +586 -768
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Internal/Platform/Effect.elm +1 -2
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +379 -0
- package/src/Pages/Internal/Platform/StaticResponses.elm +65 -276
- package/src/Pages/Internal/Platform/ToJsPayload.elm +6 -9
- package/src/Pages/Internal/Platform.elm +330 -203
- package/src/Pages/Internal/ResponseSketch.elm +2 -2
- package/src/Pages/Internal/Script.elm +17 -0
- package/src/Pages/Internal/StaticHttpBody.elm +35 -1
- package/src/Pages/Manifest.elm +52 -11
- package/src/Pages/Navigation.elm +85 -0
- package/src/Pages/PageUrl.elm +26 -12
- package/src/Pages/ProgramConfig.elm +32 -22
- package/src/Pages/Script.elm +166 -0
- package/src/Pages/SiteConfig.elm +3 -2
- package/src/Pages/StaticHttp/Request.elm +2 -2
- package/src/Pages/StaticHttpRequest.elm +23 -99
- package/src/Pages/Url.elm +3 -3
- package/src/PagesMsg.elm +88 -0
- package/src/QueryParams.elm +21 -172
- package/src/RenderRequest.elm +7 -7
- package/src/RequestsAndPending.elm +37 -20
- package/src/Result/Extra.elm +26 -0
- package/src/Scaffold/Form.elm +569 -0
- package/src/Scaffold/Route.elm +1431 -0
- package/src/Server/Request.elm +476 -1001
- package/src/Server/Response.elm +130 -36
- package/src/Server/Session.elm +181 -111
- package/src/Server/SetCookie.elm +80 -32
- package/src/Stub.elm +53 -0
- package/src/Test/Html/Internal/ElmHtml/ToString.elm +8 -9
- package/src/{Path.elm → UrlPath.elm} +33 -36
- package/generator/template/public/images/icon-png.png +0 -0
- package/src/DataSource/Env.elm +0 -38
- package/src/DataSource/Http.elm +0 -446
- package/src/DataSource/Internal/Request.elm +0 -20
- package/src/DataSource/Port.elm +0 -90
- package/src/DataSource.elm +0 -546
- package/src/Form/Field.elm +0 -717
- package/src/Form/FieldStatus.elm +0 -36
- package/src/Form/FieldView.elm +0 -417
- package/src/Form/FormData.elm +0 -22
- package/src/Form/Validation.elm +0 -391
- package/src/Form/Value.elm +0 -118
- package/src/Form.elm +0 -1683
- package/src/FormDecoder.elm +0 -102
- package/src/Pages/FormState.elm +0 -256
- package/src/Pages/Generate.elm +0 -1242
- package/src/Pages/Internal/Form.elm +0 -17
- package/src/Pages/Internal/Platform/Cli.elm.bak +0 -1276
- package/src/Pages/Msg.elm +0 -79
- package/src/Pages/Transition.elm +0 -70
|
@@ -7,8 +7,7 @@ import Pages.StaticHttp.Request as StaticHttp
|
|
|
7
7
|
|
|
8
8
|
type Effect
|
|
9
9
|
= NoEffect
|
|
10
|
-
| FetchHttp StaticHttp.Request
|
|
10
|
+
| FetchHttp (List StaticHttp.Request)
|
|
11
11
|
| Batch (List Effect)
|
|
12
12
|
| SendSinglePage ToJsSuccessPayloadNewCombined
|
|
13
13
|
| SendSinglePageNew Bytes ToJsSuccessPayloadNewCombined
|
|
14
|
-
| Continue
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
module Pages.Internal.Platform.GeneratorApplication exposing (Program, Flags, Model, Msg(..), init, requestDecoder, update, app, JsonValue)
|
|
2
|
+
|
|
3
|
+
{-| Exposed for internal use only (used in generated code).
|
|
4
|
+
|
|
5
|
+
@docs Program, Flags, Model, Msg, init, requestDecoder, update, app, JsonValue
|
|
6
|
+
|
|
7
|
+
-}
|
|
8
|
+
|
|
9
|
+
import BackendTask exposing (BackendTask)
|
|
10
|
+
import BuildError exposing (BuildError)
|
|
11
|
+
import Cli.Program as Program exposing (FlagsIncludingArgv)
|
|
12
|
+
import Codec
|
|
13
|
+
import Dict
|
|
14
|
+
import FatalError exposing (FatalError)
|
|
15
|
+
import HtmlPrinter
|
|
16
|
+
import Json.Decode as Decode
|
|
17
|
+
import Json.Encode as Encode
|
|
18
|
+
import Pages.GeneratorProgramConfig exposing (GeneratorProgramConfig)
|
|
19
|
+
import Pages.Internal.Platform.CompatibilityKey
|
|
20
|
+
import Pages.Internal.Platform.Effect as Effect exposing (Effect)
|
|
21
|
+
import Pages.Internal.Platform.StaticResponses as StaticResponses
|
|
22
|
+
import Pages.Internal.Platform.ToJsPayload as ToJsPayload
|
|
23
|
+
import Pages.Internal.Script
|
|
24
|
+
import Pages.StaticHttp.Request
|
|
25
|
+
import TerminalText as Terminal
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
{-| -}
|
|
29
|
+
type alias JsonValue =
|
|
30
|
+
Decode.Value
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
{-| -}
|
|
34
|
+
type alias Program =
|
|
35
|
+
Program.StatefulProgram Model Msg (BackendTask FatalError ()) Flags
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
{-| -}
|
|
39
|
+
type alias Flags =
|
|
40
|
+
{ compatibilityKey : Int
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
{-| -}
|
|
45
|
+
type alias Model =
|
|
46
|
+
{ staticResponses : BackendTask FatalError ()
|
|
47
|
+
, errors : List BuildError
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
{-| -}
|
|
52
|
+
type Msg
|
|
53
|
+
= GotDataBatch Decode.Value
|
|
54
|
+
| GotBuildError BuildError
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
{-| -}
|
|
58
|
+
app :
|
|
59
|
+
GeneratorProgramConfig
|
|
60
|
+
-> Program
|
|
61
|
+
app config =
|
|
62
|
+
let
|
|
63
|
+
cliConfig : Program.Config (BackendTask FatalError ())
|
|
64
|
+
cliConfig =
|
|
65
|
+
case config.data of
|
|
66
|
+
Pages.Internal.Script.Script theCliConfig ->
|
|
67
|
+
theCliConfig HtmlPrinter.htmlToString
|
|
68
|
+
in
|
|
69
|
+
Program.stateful
|
|
70
|
+
{ init =
|
|
71
|
+
\flags cliOptions ->
|
|
72
|
+
init cliOptions flags
|
|
73
|
+
|> Tuple.mapSecond (perform config)
|
|
74
|
+
, update =
|
|
75
|
+
\_ msg model ->
|
|
76
|
+
update msg model
|
|
77
|
+
|> Tuple.mapSecond (perform config)
|
|
78
|
+
, subscriptions =
|
|
79
|
+
\_ ->
|
|
80
|
+
Sub.batch
|
|
81
|
+
[ config.fromJsPort
|
|
82
|
+
|> Sub.map
|
|
83
|
+
(\jsonValue ->
|
|
84
|
+
let
|
|
85
|
+
decoder : Decode.Decoder Msg
|
|
86
|
+
decoder =
|
|
87
|
+
Decode.field "tag" Decode.string
|
|
88
|
+
|> Decode.andThen
|
|
89
|
+
(\tag ->
|
|
90
|
+
case tag of
|
|
91
|
+
"BuildError" ->
|
|
92
|
+
Decode.field "data"
|
|
93
|
+
(Decode.map2
|
|
94
|
+
(\message title ->
|
|
95
|
+
{ title = title
|
|
96
|
+
, message = message
|
|
97
|
+
, fatal = True
|
|
98
|
+
, path = "" -- TODO wire in current path here
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
(Decode.field "message" Decode.string |> Decode.map Terminal.fromAnsiString)
|
|
102
|
+
(Decode.field "title" Decode.string)
|
|
103
|
+
)
|
|
104
|
+
|> Decode.map GotBuildError
|
|
105
|
+
|
|
106
|
+
_ ->
|
|
107
|
+
Decode.fail "Unhandled msg"
|
|
108
|
+
)
|
|
109
|
+
in
|
|
110
|
+
Decode.decodeValue decoder jsonValue
|
|
111
|
+
|> Result.mapError
|
|
112
|
+
(\error ->
|
|
113
|
+
("From location 1: "
|
|
114
|
+
++ (error
|
|
115
|
+
|> Decode.errorToString
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
|> BuildError.internal
|
|
119
|
+
|> GotBuildError
|
|
120
|
+
)
|
|
121
|
+
|> mergeResult
|
|
122
|
+
)
|
|
123
|
+
, config.gotBatchSub |> Sub.map GotDataBatch
|
|
124
|
+
]
|
|
125
|
+
, config = cliConfig
|
|
126
|
+
, printAndExitFailure =
|
|
127
|
+
\string ->
|
|
128
|
+
ToJsPayload.Errors
|
|
129
|
+
[ { title = "Invalid CLI arguments"
|
|
130
|
+
, path = ""
|
|
131
|
+
, message =
|
|
132
|
+
[ Terminal.text string
|
|
133
|
+
]
|
|
134
|
+
, fatal = True
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
|> Codec.encodeToValue (ToJsPayload.successCodecNew2 "" "")
|
|
138
|
+
|> config.toJsPort
|
|
139
|
+
|> Cmd.map never
|
|
140
|
+
, printAndExitSuccess = \string -> config.toJsPort (Encode.string string) |> Cmd.map never
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
mergeResult : Result a a -> a
|
|
145
|
+
mergeResult r =
|
|
146
|
+
case r of
|
|
147
|
+
Ok rr ->
|
|
148
|
+
rr
|
|
149
|
+
|
|
150
|
+
Err rr ->
|
|
151
|
+
rr
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
{-| -}
|
|
155
|
+
requestDecoder : Decode.Decoder Pages.StaticHttp.Request.Request
|
|
156
|
+
requestDecoder =
|
|
157
|
+
Pages.StaticHttp.Request.codec
|
|
158
|
+
|> Codec.decoder
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
flatten : GeneratorProgramConfig -> List Effect -> Cmd Msg
|
|
162
|
+
flatten config list =
|
|
163
|
+
Cmd.batch (flattenHelp [] config list)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
flattenHelp : List (Cmd Msg) -> GeneratorProgramConfig -> List Effect -> List (Cmd Msg)
|
|
167
|
+
flattenHelp soFar config list =
|
|
168
|
+
case list of
|
|
169
|
+
first :: rest ->
|
|
170
|
+
flattenHelp
|
|
171
|
+
(perform config first :: soFar)
|
|
172
|
+
config
|
|
173
|
+
rest
|
|
174
|
+
|
|
175
|
+
[] ->
|
|
176
|
+
soFar
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
perform :
|
|
180
|
+
GeneratorProgramConfig
|
|
181
|
+
-> Effect
|
|
182
|
+
-> Cmd Msg
|
|
183
|
+
perform config effect =
|
|
184
|
+
let
|
|
185
|
+
canonicalSiteUrl : String
|
|
186
|
+
canonicalSiteUrl =
|
|
187
|
+
""
|
|
188
|
+
in
|
|
189
|
+
case effect of
|
|
190
|
+
Effect.NoEffect ->
|
|
191
|
+
Cmd.none
|
|
192
|
+
|
|
193
|
+
Effect.Batch list ->
|
|
194
|
+
flatten config list
|
|
195
|
+
|
|
196
|
+
Effect.FetchHttp requests ->
|
|
197
|
+
requests
|
|
198
|
+
|> List.map
|
|
199
|
+
(\request ->
|
|
200
|
+
( Pages.StaticHttp.Request.hash request, request )
|
|
201
|
+
)
|
|
202
|
+
|> ToJsPayload.DoHttp
|
|
203
|
+
|> Codec.encoder (ToJsPayload.successCodecNew2 canonicalSiteUrl "")
|
|
204
|
+
|> config.toJsPort
|
|
205
|
+
|> Cmd.map never
|
|
206
|
+
|
|
207
|
+
Effect.SendSinglePage info ->
|
|
208
|
+
let
|
|
209
|
+
currentPagePath : String
|
|
210
|
+
currentPagePath =
|
|
211
|
+
case info of
|
|
212
|
+
ToJsPayload.PageProgress toJsSuccessPayloadNew ->
|
|
213
|
+
toJsSuccessPayloadNew.route
|
|
214
|
+
|
|
215
|
+
_ ->
|
|
216
|
+
""
|
|
217
|
+
in
|
|
218
|
+
info
|
|
219
|
+
|> Codec.encoder (ToJsPayload.successCodecNew2 canonicalSiteUrl currentPagePath)
|
|
220
|
+
|> config.toJsPort
|
|
221
|
+
|> Cmd.map never
|
|
222
|
+
|
|
223
|
+
Effect.SendSinglePageNew rawBytes info ->
|
|
224
|
+
let
|
|
225
|
+
currentPagePath : String
|
|
226
|
+
currentPagePath =
|
|
227
|
+
case info of
|
|
228
|
+
ToJsPayload.PageProgress toJsSuccessPayloadNew ->
|
|
229
|
+
toJsSuccessPayloadNew.route
|
|
230
|
+
|
|
231
|
+
_ ->
|
|
232
|
+
""
|
|
233
|
+
in
|
|
234
|
+
{ oldThing =
|
|
235
|
+
info
|
|
236
|
+
|> Codec.encoder (ToJsPayload.successCodecNew2 canonicalSiteUrl currentPagePath)
|
|
237
|
+
, binaryPageData = rawBytes
|
|
238
|
+
}
|
|
239
|
+
|> config.sendPageData
|
|
240
|
+
|> Cmd.map never
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
-- TODO use Json.Decode.Value for flagsDecoder instead of hardcoded record flags
|
|
245
|
+
--flagsDecoder :
|
|
246
|
+
-- Decode.Decoder
|
|
247
|
+
-- { staticHttpCache : RequestsAndPending
|
|
248
|
+
-- , compatibilityKey : Int
|
|
249
|
+
-- }
|
|
250
|
+
--flagsDecoder =
|
|
251
|
+
-- Decode.map3
|
|
252
|
+
-- (\staticHttpCache compatibilityKey ->
|
|
253
|
+
-- { staticHttpCache = staticHttpCache
|
|
254
|
+
-- , isDevServer = isDevServer
|
|
255
|
+
-- , compatibilityKey = compatibilityKey
|
|
256
|
+
-- }
|
|
257
|
+
-- )
|
|
258
|
+
-- (Decode.succeed Dict.empty)
|
|
259
|
+
-- (Decode.field "compatibilityKey" Decode.int)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
{-| -}
|
|
263
|
+
init :
|
|
264
|
+
BackendTask FatalError ()
|
|
265
|
+
-> FlagsIncludingArgv Flags
|
|
266
|
+
-> ( Model, Effect )
|
|
267
|
+
init execute flags =
|
|
268
|
+
if flags.compatibilityKey == Pages.Internal.Platform.CompatibilityKey.currentCompatibilityKey then
|
|
269
|
+
initLegacy execute
|
|
270
|
+
|
|
271
|
+
else
|
|
272
|
+
let
|
|
273
|
+
elmPackageAheadOfNpmPackage : Bool
|
|
274
|
+
elmPackageAheadOfNpmPackage =
|
|
275
|
+
Pages.Internal.Platform.CompatibilityKey.currentCompatibilityKey > flags.compatibilityKey
|
|
276
|
+
|
|
277
|
+
message : String
|
|
278
|
+
message =
|
|
279
|
+
"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"
|
|
280
|
+
++ (if elmPackageAheadOfNpmPackage then
|
|
281
|
+
"The elm-pages Elm package is ahead of the elm-pages NPM package. Try updating the elm-pages NPM package?"
|
|
282
|
+
|
|
283
|
+
else
|
|
284
|
+
"The elm-pages NPM package is ahead of the elm-pages Elm package. Try updating the elm-pages Elm package?"
|
|
285
|
+
)
|
|
286
|
+
in
|
|
287
|
+
updateAndSendPortIfDone
|
|
288
|
+
{ staticResponses = StaticResponses.empty ()
|
|
289
|
+
, errors =
|
|
290
|
+
[ { title = "Incompatible NPM and Elm package versions"
|
|
291
|
+
, message = [ Terminal.text <| message ]
|
|
292
|
+
, fatal = True
|
|
293
|
+
, path = ""
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
initLegacy :
|
|
300
|
+
BackendTask FatalError ()
|
|
301
|
+
-> ( Model, Effect )
|
|
302
|
+
initLegacy execute =
|
|
303
|
+
let
|
|
304
|
+
initialModel : Model
|
|
305
|
+
initialModel =
|
|
306
|
+
{ staticResponses = execute
|
|
307
|
+
, errors = []
|
|
308
|
+
}
|
|
309
|
+
in
|
|
310
|
+
StaticResponses.nextStep (Encode.object []) initialModel.staticResponses initialModel
|
|
311
|
+
|> nextStepToEffect
|
|
312
|
+
initialModel
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
updateAndSendPortIfDone :
|
|
316
|
+
Model
|
|
317
|
+
-> ( Model, Effect )
|
|
318
|
+
updateAndSendPortIfDone model =
|
|
319
|
+
StaticResponses.nextStep (Encode.object [])
|
|
320
|
+
model.staticResponses
|
|
321
|
+
model
|
|
322
|
+
|> nextStepToEffect model
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
{-| -}
|
|
326
|
+
update :
|
|
327
|
+
Msg
|
|
328
|
+
-> Model
|
|
329
|
+
-> ( Model, Effect )
|
|
330
|
+
update msg model =
|
|
331
|
+
case msg of
|
|
332
|
+
GotDataBatch batch ->
|
|
333
|
+
StaticResponses.nextStep batch
|
|
334
|
+
model.staticResponses
|
|
335
|
+
model
|
|
336
|
+
|> nextStepToEffect model
|
|
337
|
+
|
|
338
|
+
GotBuildError buildError ->
|
|
339
|
+
let
|
|
340
|
+
updatedModel : Model
|
|
341
|
+
updatedModel =
|
|
342
|
+
{ model
|
|
343
|
+
| errors =
|
|
344
|
+
buildError :: model.errors
|
|
345
|
+
}
|
|
346
|
+
in
|
|
347
|
+
StaticResponses.nextStep (Encode.object [])
|
|
348
|
+
updatedModel.staticResponses
|
|
349
|
+
updatedModel
|
|
350
|
+
|> nextStepToEffect updatedModel
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
nextStepToEffect :
|
|
354
|
+
Model
|
|
355
|
+
-> StaticResponses.NextStep route ()
|
|
356
|
+
-> ( Model, Effect )
|
|
357
|
+
nextStepToEffect model nextStep =
|
|
358
|
+
case nextStep of
|
|
359
|
+
StaticResponses.Continue httpRequests updatedStaticResponsesModel ->
|
|
360
|
+
( { model
|
|
361
|
+
| staticResponses = updatedStaticResponsesModel
|
|
362
|
+
}
|
|
363
|
+
, Effect.FetchHttp httpRequests
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
StaticResponses.Finish () ->
|
|
367
|
+
( model
|
|
368
|
+
, { body = Encode.null
|
|
369
|
+
, staticHttpCache = Dict.empty
|
|
370
|
+
, statusCode = 200
|
|
371
|
+
}
|
|
372
|
+
|> ToJsPayload.SendApiResponse
|
|
373
|
+
|> Effect.SendSinglePage
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
StaticResponses.FinishedWithErrors buildErrors ->
|
|
377
|
+
( model
|
|
378
|
+
, buildErrors |> ToJsPayload.Errors |> Effect.SendSinglePage
|
|
379
|
+
)
|