elm-pages 3.0.0-beta.31 → 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/cli.js +10 -9
- package/generator/src/compatibility-key.js +2 -2
- package/generator/src/render.js +1 -0
- package/generator/src/request-cache.js +20 -6
- package/generator/src/resolve-elm-module.js +3 -2
- 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/src/Scaffold/Form.elm +3 -17
- package/src/Scaffold/Route.elm +19 -5
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
|
|
package/generator/src/cli.js
CHANGED
|
@@ -103,9 +103,11 @@ async function main() {
|
|
|
103
103
|
|
|
104
104
|
const portBackendTaskCompiled = esbuild
|
|
105
105
|
.build({
|
|
106
|
-
entryPoints: [
|
|
106
|
+
entryPoints: [
|
|
107
|
+
path.resolve(projectDirectory, "./custom-backend-task"),
|
|
108
|
+
],
|
|
107
109
|
platform: "node",
|
|
108
|
-
outfile: path.
|
|
110
|
+
outfile: path.resolve(
|
|
109
111
|
projectDirectory,
|
|
110
112
|
".elm-pages/compiled-ports/custom-backend-task.mjs"
|
|
111
113
|
),
|
|
@@ -126,14 +128,13 @@ async function main() {
|
|
|
126
128
|
})
|
|
127
129
|
.catch((error) => {
|
|
128
130
|
const portBackendTaskFileFound =
|
|
129
|
-
globby.globbySync(
|
|
131
|
+
globby.globbySync(
|
|
132
|
+
path.resolve(projectDirectory, "./custom-backend-task.*")
|
|
133
|
+
).length > 0;
|
|
130
134
|
if (portBackendTaskFileFound) {
|
|
131
135
|
// don't present error if there are no files matching custom-backend-task
|
|
132
136
|
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
|
|
133
|
-
console.error(
|
|
134
|
-
"Failed to start custom-backend-task watcher",
|
|
135
|
-
error
|
|
136
|
-
);
|
|
137
|
+
console.error("Failed to load custom-backend-task file.", error);
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
140
|
const portsPath = await portBackendTaskCompiled;
|
|
@@ -204,12 +205,12 @@ async function main() {
|
|
|
204
205
|
|
|
205
206
|
const portBackendTaskFileFound =
|
|
206
207
|
globby.globbySync(
|
|
207
|
-
path.
|
|
208
|
+
path.resolve(projectDirectory, "custom-backend-task.*")
|
|
208
209
|
).length > 0;
|
|
209
210
|
|
|
210
211
|
const scriptRunner = `${
|
|
211
212
|
portBackendTaskFileFound
|
|
212
|
-
? `import * as customBackendTask from "${path.
|
|
213
|
+
? `import * as customBackendTask from "${path.resolve(
|
|
213
214
|
projectDirectory,
|
|
214
215
|
"./custom-backend-task"
|
|
215
216
|
)}";`
|
|
@@ -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
|
});
|
|
@@ -52,10 +52,11 @@ export function resolveInputPathOrModuleName(inputPathOrModuleName) {
|
|
|
52
52
|
if (
|
|
53
53
|
/^[A-Z][a-zA-Z0-9_]*(\.[A-Z][a-zA-Z0-9_]*)*$/.test(inputPathOrModuleName)
|
|
54
54
|
) {
|
|
55
|
+
const absolutePathForScript = path.resolve("./script/src");
|
|
55
56
|
return {
|
|
56
57
|
moduleName: inputPathOrModuleName,
|
|
57
|
-
projectDirectory: "./script",
|
|
58
|
-
sourceDirectory: "./script/src",
|
|
58
|
+
projectDirectory: path.resolve("./script"),
|
|
59
|
+
sourceDirectory: path.resolve("./script/src"),
|
|
59
60
|
};
|
|
60
61
|
} else {
|
|
61
62
|
return getElmModuleName(inputPathOrModuleName);
|
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
|
+
)
|
package/src/Scaffold/Form.elm
CHANGED
|
@@ -44,17 +44,7 @@ type alias Context =
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
{
|
|
48
|
-
formWithFields :
|
|
49
|
-
Bool
|
|
50
|
-
-> List ( String, Kind )
|
|
51
|
-
->
|
|
52
|
-
({ formState : Context
|
|
53
|
-
, params : List { name : String, kind : Kind, param : Elm.Expression }
|
|
54
|
-
}
|
|
55
|
-
-> Elm.Expression
|
|
56
|
-
)
|
|
57
|
-
-> { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression }
|
|
47
|
+
formWithFields : Bool -> List ( String, Kind ) -> ({ formState : { errors : Elm.Expression, isTransitioning : Elm.Expression, submitAttempted : Elm.Expression, data : Elm.Expression, expression : Elm.Expression }, params : List { name : String, kind : Kind, param : Elm.Expression } } -> Elm.Expression) -> { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression }
|
|
58
48
|
formWithFields elmCssView fields viewFn =
|
|
59
49
|
Elm.Declare.function "form"
|
|
60
50
|
[]
|
|
@@ -235,15 +225,11 @@ provide { fields, view, elmCssView } =
|
|
|
235
225
|
|
|
236
226
|
else
|
|
237
227
|
let
|
|
238
|
-
form : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression }
|
|
228
|
+
form : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression }
|
|
239
229
|
form =
|
|
240
230
|
formWithFields elmCssView fields view
|
|
241
231
|
|
|
242
|
-
formHandlersDeclaration :
|
|
243
|
-
{ declaration : Elm.Declaration
|
|
244
|
-
, call : List Elm.Expression -> Elm.Expression
|
|
245
|
-
, callFrom : List String -> List Elm.Expression -> Elm.Expression
|
|
246
|
-
}
|
|
232
|
+
formHandlersDeclaration : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression }
|
|
247
233
|
formHandlersDeclaration =
|
|
248
234
|
-- TODO customizable formHandlers name?
|
|
249
235
|
Elm.Declare.function "formHandlers"
|
package/src/Scaffold/Route.elm
CHANGED
|
@@ -516,6 +516,7 @@ userFunction moduleName definitions =
|
|
|
516
516
|
{ declaration : Elm.Declaration
|
|
517
517
|
, call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
518
518
|
, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
519
|
+
, value : List String -> Elm.Expression
|
|
519
520
|
}
|
|
520
521
|
viewFn =
|
|
521
522
|
case definitions.localState of
|
|
@@ -545,6 +546,7 @@ userFunction moduleName definitions =
|
|
|
545
546
|
{ declaration : Elm.Declaration
|
|
546
547
|
, call : Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
547
548
|
, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
549
|
+
, value : List String -> Elm.Expression
|
|
548
550
|
}
|
|
549
551
|
viewDeclaration =
|
|
550
552
|
Elm.Declare.fn2 "view"
|
|
@@ -568,6 +570,7 @@ userFunction moduleName definitions =
|
|
|
568
570
|
{ declaration = viewDeclaration.declaration
|
|
569
571
|
, call = \app shared _ -> viewDeclaration.call app shared
|
|
570
572
|
, callFrom = \a _ c d -> viewDeclaration.callFrom a c d
|
|
573
|
+
, value = viewDeclaration.value
|
|
571
574
|
}
|
|
572
575
|
|
|
573
576
|
localDefinitions :
|
|
@@ -576,9 +579,20 @@ userFunction moduleName definitions =
|
|
|
576
579
|
{ declaration : Elm.Declaration
|
|
577
580
|
, call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
578
581
|
, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
582
|
+
, value : List String -> Elm.Expression
|
|
583
|
+
}
|
|
584
|
+
, initFn :
|
|
585
|
+
{ declaration : Elm.Declaration
|
|
586
|
+
, call : Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
587
|
+
, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
588
|
+
, value : List String -> Elm.Expression
|
|
589
|
+
}
|
|
590
|
+
, subscriptionsFn :
|
|
591
|
+
{ declaration : Elm.Declaration
|
|
592
|
+
, call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
593
|
+
, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
|
|
594
|
+
, value : List String -> Elm.Expression
|
|
579
595
|
}
|
|
580
|
-
, initFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression }
|
|
581
|
-
, subscriptionsFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression }
|
|
582
596
|
, state : State
|
|
583
597
|
}
|
|
584
598
|
localDefinitions =
|
|
@@ -626,7 +640,7 @@ userFunction moduleName definitions =
|
|
|
626
640
|
}
|
|
627
641
|
)
|
|
628
642
|
|
|
629
|
-
dataFn : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression }
|
|
643
|
+
dataFn : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression }
|
|
630
644
|
dataFn =
|
|
631
645
|
case definitions.action of
|
|
632
646
|
Pages Nothing ->
|
|
@@ -669,7 +683,7 @@ userFunction moduleName definitions =
|
|
|
669
683
|
Elm.unit
|
|
670
684
|
)
|
|
671
685
|
|
|
672
|
-
actionFn : Maybe { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression }
|
|
686
|
+
actionFn : Maybe { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression }
|
|
673
687
|
actionFn =
|
|
674
688
|
case definitions.action of
|
|
675
689
|
Action action_ ->
|
|
@@ -699,7 +713,7 @@ userFunction moduleName definitions =
|
|
|
699
713
|
(\_ -> justPagesExpression)
|
|
700
714
|
)
|
|
701
715
|
|
|
702
|
-
headFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression }
|
|
716
|
+
headFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression }
|
|
703
717
|
headFn =
|
|
704
718
|
Elm.Declare.fn "head"
|
|
705
719
|
( "app", Just appType )
|