elm-pages 3.0.0-beta.32 → 3.0.0-beta.33
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/generator/src/compatibility-key.js +2 -2
- package/generator/src/render.js +1 -0
- package/generator/src/request-cache.js +20 -6
- package/package.json +1 -1
- package/src/BackendTask/Http.elm +8 -2
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/RequestsAndPending.elm +31 -3
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ https://github.com/dillonkearns/elm-pages/projects
|
|
|
81
81
|
You will see an error if the NPM and Elm package do not have a matching Compatibility Key. Usually it's best to upgrade to the latest version of both the Elm and NPM
|
|
82
82
|
packages when you upgrade. However, in case you want to install versions that are behind the latest, the Compatibility Key is included here for reference.
|
|
83
83
|
|
|
84
|
-
Current Compatibility Key:
|
|
84
|
+
Current Compatibility Key: 13.
|
|
85
85
|
|
|
86
86
|
## Contributors ✨
|
|
87
87
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const compatibilityKey =
|
|
1
|
+
export const compatibilityKey = 13;
|
|
2
2
|
|
|
3
|
-
export const packageVersion = "3.0.0-beta.
|
|
3
|
+
export const packageVersion = "3.0.0-beta.33";
|
package/generator/src/render.js
CHANGED
|
@@ -202,12 +202,26 @@ export function lookupOrPerform(
|
|
|
202
202
|
},
|
|
203
203
|
});
|
|
204
204
|
} catch (error) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
205
|
+
if (error.code === "ECONNREFUSED") {
|
|
206
|
+
resolve({
|
|
207
|
+
kind: "response-json",
|
|
208
|
+
value: { "elm-pages-internal-error": "NetworkError" },
|
|
209
|
+
});
|
|
210
|
+
} else if (
|
|
211
|
+
error.code === "ETIMEDOUT" ||
|
|
212
|
+
error.code === "ERR_SOCKET_TIMEOUT"
|
|
213
|
+
) {
|
|
214
|
+
resolve({
|
|
215
|
+
kind: "response-json",
|
|
216
|
+
value: { "elm-pages-internal-error": "Timeout" },
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
console.trace("elm-pages unhandled HTTP error", error);
|
|
220
|
+
resolve({
|
|
221
|
+
kind: "response-json",
|
|
222
|
+
value: { "elm-pages-internal-error": "NetworkError" },
|
|
223
|
+
});
|
|
224
|
+
}
|
|
211
225
|
}
|
|
212
226
|
}
|
|
213
227
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.33",
|
|
5
5
|
"homepage": "https://elm-pages.com",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
|
package/src/BackendTask/Http.elm
CHANGED
|
@@ -494,19 +494,25 @@ requestRaw request__ expect =
|
|
|
494
494
|
(\maybeMockResolver rawResponseDict ->
|
|
495
495
|
(case maybeMockResolver of
|
|
496
496
|
Just mockResolver ->
|
|
497
|
-
mockResolver request_
|
|
497
|
+
mockResolver request_ |> Maybe.map Ok
|
|
498
498
|
|
|
499
499
|
Nothing ->
|
|
500
500
|
rawResponseDict |> RequestsAndPending.get (request_ |> HashRequest.hash)
|
|
501
501
|
)
|
|
502
502
|
|> (\maybeResponse ->
|
|
503
503
|
case maybeResponse of
|
|
504
|
-
Just rawResponse ->
|
|
504
|
+
Just (Ok rawResponse) ->
|
|
505
505
|
Ok rawResponse
|
|
506
506
|
|
|
507
507
|
Nothing ->
|
|
508
508
|
--Err (Pages.StaticHttpRequest.UserCalledStaticHttpFail ("INTERNAL ERROR - expected request" ++ request_.url))
|
|
509
509
|
Err (BadBody Nothing ("INTERNAL ERROR - expected request" ++ request_.url))
|
|
510
|
+
|
|
511
|
+
Just (Err RequestsAndPending.NetworkError) ->
|
|
512
|
+
Err NetworkError
|
|
513
|
+
|
|
514
|
+
Just (Err RequestsAndPending.Timeout) ->
|
|
515
|
+
Err Timeout
|
|
510
516
|
)
|
|
511
517
|
|> Result.andThen
|
|
512
518
|
(\(RequestsAndPending.Response maybeResponse body) ->
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module RequestsAndPending exposing (RawResponse, RequestsAndPending, Response(..), ResponseBody(..), bodyEncoder, get)
|
|
1
|
+
module RequestsAndPending exposing (HttpError(..), RawResponse, RequestsAndPending, Response(..), ResponseBody(..), bodyEncoder, get)
|
|
2
2
|
|
|
3
3
|
import Base64
|
|
4
4
|
import Bytes exposing (Bytes)
|
|
@@ -101,11 +101,39 @@ responseDecoder =
|
|
|
101
101
|
(Decode.field "url" Decode.string)
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
get : String -> RequestsAndPending -> Maybe Response
|
|
104
|
+
get : String -> RequestsAndPending -> Maybe (Result HttpError Response)
|
|
105
105
|
get key requestsAndPending =
|
|
106
106
|
Decode.decodeValue
|
|
107
107
|
(Decode.field key
|
|
108
|
-
(Decode.field "response"
|
|
108
|
+
(Decode.field "response"
|
|
109
|
+
(Decode.oneOf
|
|
110
|
+
[ Decode.field "elm-pages-internal-error" errorDecoder |> Decode.map Err
|
|
111
|
+
, decoder |> Decode.map Ok
|
|
112
|
+
]
|
|
113
|
+
)
|
|
114
|
+
)
|
|
109
115
|
)
|
|
110
116
|
requestsAndPending
|
|
111
117
|
|> Result.toMaybe
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
type HttpError
|
|
121
|
+
= NetworkError
|
|
122
|
+
| Timeout
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
errorDecoder : Decoder HttpError
|
|
126
|
+
errorDecoder =
|
|
127
|
+
Decode.string
|
|
128
|
+
|> Decode.andThen
|
|
129
|
+
(\errorCode ->
|
|
130
|
+
case errorCode of
|
|
131
|
+
"NetworkError" ->
|
|
132
|
+
Decode.succeed NetworkError
|
|
133
|
+
|
|
134
|
+
"Timeout" ->
|
|
135
|
+
Decode.succeed Timeout
|
|
136
|
+
|
|
137
|
+
_ ->
|
|
138
|
+
Decode.fail "Unhandled error code."
|
|
139
|
+
)
|