elm-pages 3.0.9 → 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 +1 -1
- 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 -3
- 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/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 +45 -34
- package/src/BackendTask/File.elm +2 -1
- package/src/BackendTask.elm +28 -40
- package/src/FatalError.elm +2 -2
- package/src/Head/Seo.elm +3 -3
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Manifest.elm +2 -2
- package/src/Scaffold/Route.elm +95 -49
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 4173409726, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
@@ -75,14 +75,14 @@ let testsCount, todoTests;
|
|
|
75
75
|
let reporter;
|
|
76
76
|
let runners = [];
|
|
77
77
|
let working = false;
|
|
78
|
-
let workersCount =
|
|
78
|
+
let workersCount = 4;
|
|
79
79
|
let startWorkCallback = function(){};
|
|
80
80
|
const verbosity = 0;
|
|
81
81
|
|
|
82
82
|
// Create a long lived reporter worker
|
|
83
83
|
const { Elm } = require("./Reporter.elm.js");
|
|
84
84
|
const flags = {
|
|
85
|
-
initialSeed:
|
|
85
|
+
initialSeed: 4173409726,
|
|
86
86
|
fuzzRuns: 100,
|
|
87
87
|
mode: "consoleNoColor",
|
|
88
88
|
verbosity: verbosity,
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"elm/html": "1.0.0",
|
|
12
12
|
"elm/json": "1.1.3",
|
|
13
13
|
"elm/regex": "1.0.0",
|
|
14
|
-
"jfmengels/elm-review": "2.13.
|
|
15
|
-
"mdgriffith/elm-codegen": "
|
|
16
|
-
"stil4m/elm-syntax": "7.2
|
|
14
|
+
"jfmengels/elm-review": "2.13.1",
|
|
15
|
+
"mdgriffith/elm-codegen": "4.1.1",
|
|
16
|
+
"stil4m/elm-syntax": "7.3.2",
|
|
17
17
|
"the-sett/elm-syntax-dsl": "6.0.2"
|
|
18
18
|
},
|
|
19
19
|
"indirect": {
|
|
@@ -25,18 +25,17 @@
|
|
|
25
25
|
"elm/time": "1.0.0",
|
|
26
26
|
"elm/virtual-dom": "1.0.3",
|
|
27
27
|
"elm-community/basics-extra": "4.1.0",
|
|
28
|
-
"elm-community/list-extra": "8.7.0",
|
|
29
28
|
"elm-community/maybe-extra": "5.3.0",
|
|
30
|
-
"elm-explorations/test": "2.1.
|
|
31
|
-
"miniBill/elm-unicode": "1.0
|
|
29
|
+
"elm-explorations/test": "2.1.2",
|
|
30
|
+
"miniBill/elm-unicode": "1.1.0",
|
|
32
31
|
"rtfeldman/elm-hex": "1.0.0",
|
|
33
32
|
"stil4m/structured-writer": "1.0.3",
|
|
34
|
-
"the-sett/elm-pretty-printer": "3.
|
|
33
|
+
"the-sett/elm-pretty-printer": "3.1.0"
|
|
35
34
|
}
|
|
36
35
|
},
|
|
37
36
|
"test-dependencies": {
|
|
38
37
|
"direct": {
|
|
39
|
-
"elm-explorations/test": "2.1.
|
|
38
|
+
"elm-explorations/test": "2.1.2"
|
|
40
39
|
},
|
|
41
40
|
"indirect": {}
|
|
42
41
|
}
|
package/generator/src/build.js
CHANGED
|
@@ -100,7 +100,7 @@ export async function run(options) {
|
|
|
100
100
|
ssr: false,
|
|
101
101
|
|
|
102
102
|
build: {
|
|
103
|
-
manifest:
|
|
103
|
+
manifest: '___vite-manifest___.json',
|
|
104
104
|
outDir: "dist",
|
|
105
105
|
rollupOptions: {
|
|
106
106
|
input: "elm-stuff/elm-pages/index.html",
|
|
@@ -123,7 +123,7 @@ export async function run(options) {
|
|
|
123
123
|
fullOutputPath,
|
|
124
124
|
withoutExtension
|
|
125
125
|
);
|
|
126
|
-
const assetManifestPath = path.join(process.cwd(), "dist/
|
|
126
|
+
const assetManifestPath = path.join(process.cwd(), "dist/___vite-manifest___.json");
|
|
127
127
|
const manifest = JSON.parse(
|
|
128
128
|
await fsPromises.readFile(assetManifestPath, { encoding: "utf-8" })
|
|
129
129
|
);
|
|
@@ -155,7 +155,7 @@ export async function run(options) {
|
|
|
155
155
|
`<script defer src="/elm.${browserElmHash}.js" type="text/javascript"></script>`
|
|
156
156
|
);
|
|
157
157
|
await fsPromises.writeFile("dist/template.html", processedIndexTemplate);
|
|
158
|
-
await fsPromises.unlink(assetManifestPath);
|
|
158
|
+
// await fsPromises.unlink(assetManifestPath);
|
|
159
159
|
const portBackendTaskCompiled = esbuild
|
|
160
160
|
.build({
|
|
161
161
|
entryPoints: ["./custom-backend-task"],
|
package/generator/src/cli.js
CHANGED
|
@@ -346,7 +346,7 @@ async function requireElm(compiledElmPath) {
|
|
|
346
346
|
const warnOriginal = console.warn;
|
|
347
347
|
console.warn = function () {};
|
|
348
348
|
|
|
349
|
-
let Elm = (await import(path.resolve(compiledElmPath))).default;
|
|
349
|
+
let Elm = (await import(url.pathToFileURL(path.resolve(compiledElmPath)).href)).default;
|
|
350
350
|
console.warn = warnOriginal;
|
|
351
351
|
return Elm;
|
|
352
352
|
}
|
package/generator/src/codegen.js
CHANGED
|
@@ -72,7 +72,7 @@ export async function generate(basePath) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function writeFetcherModules(basePath, fetcherData) {
|
|
75
|
-
Promise.all(
|
|
75
|
+
return Promise.all(
|
|
76
76
|
fetcherData.map(([name, fileContent]) => {
|
|
77
77
|
let filePath = path.join(basePath, `/Fetcher/${name.join("/")}.elm`);
|
|
78
78
|
ensureDirSync(path.dirname(filePath));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const compatibilityKey =
|
|
1
|
+
export const compatibilityKey = 21;
|
|
2
2
|
|
|
3
|
-
export const packageVersion = "3.0.
|
|
3
|
+
export const packageVersion = "3.0.10";
|
package/generator/src/render.js
CHANGED
|
@@ -512,12 +512,7 @@ async function readFileJobNew(req, patternsToWatch) {
|
|
|
512
512
|
try {
|
|
513
513
|
patternsToWatch.add(filePath);
|
|
514
514
|
|
|
515
|
-
const fileContents =
|
|
516
|
-
(
|
|
517
|
-
await fsPromises.readFile(
|
|
518
|
-
path.join(process.env.LAMBDA_TASK_ROOT || process.cwd(), filePath)
|
|
519
|
-
)
|
|
520
|
-
).toString();
|
|
515
|
+
const fileContents = (await fsPromises.readFile(filePath)).toString();
|
|
521
516
|
// TODO does this throw an error if there is invalid frontmatter?
|
|
522
517
|
const parsedFile = matter(fileContents);
|
|
523
518
|
|
|
@@ -3,7 +3,6 @@ module ErrorPage exposing (ErrorPage(..), Model, Msg, head, init, internalError,
|
|
|
3
3
|
import Effect exposing (Effect)
|
|
4
4
|
import Head
|
|
5
5
|
import Html exposing (Html)
|
|
6
|
-
import Html.Events exposing (onClick)
|
|
7
6
|
import View exposing (View)
|
|
8
7
|
|
|
9
8
|
|
|
@@ -54,20 +53,24 @@ view : ErrorPage -> Model -> View Msg
|
|
|
54
53
|
view error model =
|
|
55
54
|
{ body =
|
|
56
55
|
[ Html.div []
|
|
57
|
-
[ Html.p []
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
)
|
|
66
|
-
]
|
|
56
|
+
[ Html.p []
|
|
57
|
+
[ Html.text <|
|
|
58
|
+
case error of
|
|
59
|
+
NotFound ->
|
|
60
|
+
"Page not found. Maybe try another URL?"
|
|
61
|
+
|
|
62
|
+
InternalError string ->
|
|
63
|
+
"Something went wrong.\n" ++ string
|
|
67
64
|
]
|
|
68
65
|
]
|
|
69
66
|
]
|
|
70
|
-
, title =
|
|
67
|
+
, title =
|
|
68
|
+
case error of
|
|
69
|
+
NotFound ->
|
|
70
|
+
"Page Not Found"
|
|
71
|
+
|
|
72
|
+
InternalError string ->
|
|
73
|
+
"Unexpected Error"
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"elm-codegen-version": "0.
|
|
2
|
+
"elm-codegen-version": "0.5.1",
|
|
3
3
|
"codegen-helpers": {
|
|
4
4
|
"packages": {
|
|
5
5
|
"elm/core": "1.0.5",
|
|
6
6
|
"dillonkearns/elm-form": "3.0.0",
|
|
7
7
|
"elm/html": "1.0.0",
|
|
8
8
|
"rtfeldman/elm-css": "18.0.0",
|
|
9
|
-
"dillonkearns/elm-pages": "10.0.
|
|
9
|
+
"dillonkearns/elm-pages": "10.0.3",
|
|
10
10
|
"elm/json": "1.1.3"
|
|
11
11
|
},
|
|
12
12
|
"local": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[build]
|
|
2
2
|
functions = "functions/"
|
|
3
3
|
publish = "dist/"
|
|
4
|
-
command = "
|
|
4
|
+
command = "export ELM_HOME=\"$NETLIFY_BUILD_BASE/cache/elm\" && npm install && npm run build"
|
|
5
5
|
|
|
6
6
|
[dev]
|
|
7
7
|
command = "npm start"
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
"build": "elm-pages build"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"elm-codegen": "^0.
|
|
10
|
+
"elm-codegen": "^0.5.1",
|
|
11
11
|
"elm-optimize-level-2": "^0.3.5",
|
|
12
|
-
"elm-pages": "^3.0.
|
|
13
|
-
"elm-review": "^2.10.
|
|
14
|
-
"elm-tooling": "^1.
|
|
15
|
-
"
|
|
12
|
+
"elm-pages": "^3.0.10",
|
|
13
|
+
"elm-review": "^2.10.3",
|
|
14
|
+
"elm-tooling": "^1.15.0",
|
|
15
|
+
"lamdera": "^0.19.1-1.2.1-1",
|
|
16
|
+
"vite": "^5.0.11"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@netlify/functions": "^1.4.0"
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"direct": {
|
|
10
10
|
"dillonkearns/elm-cli-options-parser": "3.2.0",
|
|
11
|
-
"dillonkearns/elm-pages": "10.0.
|
|
11
|
+
"dillonkearns/elm-pages": "10.0.3",
|
|
12
12
|
"elm/bytes": "1.0.8",
|
|
13
13
|
"elm/core": "1.0.5",
|
|
14
14
|
"elm/html": "1.0.0",
|
|
15
15
|
"elm/json": "1.1.3",
|
|
16
|
-
"mdgriffith/elm-codegen": "
|
|
16
|
+
"mdgriffith/elm-codegen": "4.1.1"
|
|
17
17
|
},
|
|
18
18
|
"indirect": {
|
|
19
19
|
"Chadtech/elm-bool-extra": "2.4.2",
|
|
20
20
|
"avh4/elm-color": "1.0.0",
|
|
21
21
|
"danfishgold/base64-bytes": "1.1.0",
|
|
22
22
|
"danyx23/elm-mimetype": "4.0.1",
|
|
23
|
-
"dillonkearns/elm-bcp47-language-tag": "
|
|
23
|
+
"dillonkearns/elm-bcp47-language-tag": "2.0.0",
|
|
24
24
|
"dillonkearns/elm-date-or-date-time": "2.0.0",
|
|
25
25
|
"dillonkearns/elm-form": "3.0.0",
|
|
26
26
|
"elm/browser": "1.0.2",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module AddStaticRoute exposing (run)
|
|
2
|
+
|
|
3
|
+
import BackendTask
|
|
4
|
+
import Cli.Option as Option
|
|
5
|
+
import Cli.OptionsParser as OptionsParser
|
|
6
|
+
import Cli.Program as Program
|
|
7
|
+
import Elm
|
|
8
|
+
import Elm.Annotation as Type
|
|
9
|
+
import Elm.Case
|
|
10
|
+
import Gen.BackendTask
|
|
11
|
+
import Gen.Effect as Effect
|
|
12
|
+
import Gen.Html as Html
|
|
13
|
+
import Gen.Platform.Sub
|
|
14
|
+
import Gen.View
|
|
15
|
+
import Pages.Script as Script exposing (Script)
|
|
16
|
+
import Scaffold.Route exposing (Type(..))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
type alias CliOptions =
|
|
20
|
+
{ moduleName : List String
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
run : Script
|
|
25
|
+
run =
|
|
26
|
+
Script.withCliOptions program
|
|
27
|
+
(\cliOptions ->
|
|
28
|
+
cliOptions
|
|
29
|
+
|> createFile
|
|
30
|
+
|> Script.writeFile
|
|
31
|
+
|> BackendTask.allowFatal
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
program : Program.Config CliOptions
|
|
36
|
+
program =
|
|
37
|
+
Program.config
|
|
38
|
+
|> Program.add
|
|
39
|
+
(OptionsParser.build CliOptions
|
|
40
|
+
|> OptionsParser.with (Option.requiredPositionalArg "module" |> Scaffold.Route.moduleNameCliArg)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
createFile : CliOptions -> { path : String, body : String }
|
|
45
|
+
createFile { moduleName } =
|
|
46
|
+
Scaffold.Route.preRender
|
|
47
|
+
{ moduleName = moduleName
|
|
48
|
+
, pages =
|
|
49
|
+
Gen.BackendTask.succeed
|
|
50
|
+
(Elm.list [])
|
|
51
|
+
, data =
|
|
52
|
+
( Alias (Type.record [])
|
|
53
|
+
, \routeParams ->
|
|
54
|
+
Gen.BackendTask.succeed (Elm.record [])
|
|
55
|
+
)
|
|
56
|
+
, head = \app -> Elm.list []
|
|
57
|
+
}
|
|
58
|
+
|> Scaffold.Route.buildWithLocalState
|
|
59
|
+
{ view =
|
|
60
|
+
\{ shared, model, app } ->
|
|
61
|
+
Gen.View.make_.view
|
|
62
|
+
{ title = moduleName |> String.join "." |> Elm.string
|
|
63
|
+
, body =
|
|
64
|
+
Elm.list
|
|
65
|
+
[ Html.h2 [] [ Html.text "New Page" ]
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
, update =
|
|
69
|
+
\{ shared, app, msg, model } ->
|
|
70
|
+
Elm.Case.custom msg
|
|
71
|
+
(Type.named [] "Msg")
|
|
72
|
+
[ Elm.Case.branch0 "NoOp"
|
|
73
|
+
(Elm.tuple model
|
|
74
|
+
Effect.none
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
, init =
|
|
78
|
+
\{ shared, app } ->
|
|
79
|
+
Elm.tuple (Elm.record []) Effect.none
|
|
80
|
+
, subscriptions =
|
|
81
|
+
\{ routeParams, path, shared, model } ->
|
|
82
|
+
Gen.Platform.Sub.none
|
|
83
|
+
, model =
|
|
84
|
+
Alias (Type.record [])
|
|
85
|
+
, msg =
|
|
86
|
+
Custom [ Elm.variant "NoOp" ]
|
|
87
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.10",
|
|
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.",
|
|
@@ -27,45 +27,46 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"busboy": "^1.6.0",
|
|
29
29
|
"chokidar": "^3.5.3",
|
|
30
|
-
"commander": "^
|
|
30
|
+
"commander": "^11.1.0",
|
|
31
31
|
"connect": "^3.7.0",
|
|
32
32
|
"cookie-signature": "^1.2.1",
|
|
33
33
|
"cross-spawn": "7.0.3",
|
|
34
34
|
"devcert": "^1.2.2",
|
|
35
35
|
"elm-doc-preview": "^5.0.5",
|
|
36
36
|
"elm-hot": "^1.1.6",
|
|
37
|
-
"esbuild": "^0.
|
|
38
|
-
"fs-extra": "^11.
|
|
39
|
-
"globby": "
|
|
37
|
+
"esbuild": "^0.19.11",
|
|
38
|
+
"fs-extra": "^11.2.0",
|
|
39
|
+
"globby": "14.0.0",
|
|
40
40
|
"gray-matter": "^4.0.3",
|
|
41
41
|
"jsesc": "^3.0.2",
|
|
42
42
|
"kleur": "^4.1.5",
|
|
43
|
-
"make-fetch-happen": "^
|
|
44
|
-
"memfs": "^
|
|
43
|
+
"make-fetch-happen": "^13.0.0",
|
|
44
|
+
"memfs": "^4.6.0",
|
|
45
45
|
"micromatch": "^4.0.5",
|
|
46
46
|
"serve-static": "^1.15.0",
|
|
47
|
-
"terser": "^5.
|
|
48
|
-
"vite": "^
|
|
49
|
-
"which": "^
|
|
47
|
+
"terser": "^5.26.0",
|
|
48
|
+
"vite": "^5.0.11",
|
|
49
|
+
"which": "^4.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/cross-spawn": "^6.0.
|
|
53
|
-
"@types/fs-extra": "^11.0.
|
|
54
|
-
"@types/make-fetch-happen": "^10.0.
|
|
55
|
-
"@types/micromatch": "^4.0.
|
|
56
|
-
"@types/node": "^20.
|
|
57
|
-
"@types/serve-static": "^1.15.
|
|
58
|
-
"cypress": "^13.
|
|
59
|
-
"elm-codegen": "^0.
|
|
52
|
+
"@types/cross-spawn": "^6.0.6",
|
|
53
|
+
"@types/fs-extra": "^11.0.4",
|
|
54
|
+
"@types/make-fetch-happen": "^10.0.4",
|
|
55
|
+
"@types/micromatch": "^4.0.6",
|
|
56
|
+
"@types/node": "^20.10.7",
|
|
57
|
+
"@types/serve-static": "^1.15.5",
|
|
58
|
+
"cypress": "^13.6.2",
|
|
59
|
+
"elm-codegen": "^0.5.1",
|
|
60
60
|
"elm-optimize-level-2": "^0.3.5",
|
|
61
|
-
"elm-review": "^2.10.
|
|
61
|
+
"elm-review": "^2.10.3",
|
|
62
62
|
"elm-test": "^0.19.1-revision12",
|
|
63
|
-
"elm-tooling": "^1.
|
|
64
|
-
"elm-verify-examples": "^5.
|
|
63
|
+
"elm-tooling": "^1.15.0",
|
|
64
|
+
"elm-verify-examples": "^5.3.0",
|
|
65
65
|
"elmi-to-json": "^1.4.3",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
66
|
+
"lamdera": "^0.19.1-1.2.1-1",
|
|
67
|
+
"typescript": "^5.3.3",
|
|
68
|
+
"vite": "^5.0.11",
|
|
69
|
+
"vitest": "^1.1.3"
|
|
69
70
|
},
|
|
70
71
|
"files": [
|
|
71
72
|
"adapter/",
|
package/src/ApiRoute.elm
CHANGED
|
@@ -120,41 +120,52 @@ You define your ApiRoute's in `app/Api.elm`. Here's a simple example:
|
|
|
120
120
|
requestPrinterExample : ApiRoute ApiRoute.Response
|
|
121
121
|
requestPrinterExample =
|
|
122
122
|
ApiRoute.succeed
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
123
|
+
(\pageId revisionId request ->
|
|
124
|
+
Encode.object
|
|
125
|
+
[ ( "pageId"
|
|
126
|
+
, Encode.string pageId
|
|
127
|
+
)
|
|
128
|
+
, ( "revisionId"
|
|
129
|
+
, Encode.string revisionId
|
|
130
|
+
)
|
|
131
|
+
, ( "body"
|
|
132
|
+
, request
|
|
133
|
+
|> Server.Request.body
|
|
134
|
+
|> Maybe.map Encode.string
|
|
135
|
+
|> Maybe.withDefault Encode.null
|
|
136
|
+
)
|
|
137
|
+
, ( "method"
|
|
138
|
+
, request
|
|
139
|
+
|> Server.Request.method
|
|
140
|
+
|> Server.Request.methodToString
|
|
141
|
+
|> Encode.string
|
|
142
|
+
)
|
|
143
|
+
, ( "cookies"
|
|
144
|
+
, request
|
|
145
|
+
|> Server.Request.cookies
|
|
146
|
+
|> Encode.dict
|
|
147
|
+
identity
|
|
148
|
+
Encode.string
|
|
149
|
+
)
|
|
150
|
+
, ( "queryParams"
|
|
151
|
+
, request
|
|
152
|
+
|> Server.Request.queryParams
|
|
153
|
+
|> Encode.dict
|
|
154
|
+
identity
|
|
155
|
+
(Encode.list Encode.string)
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
|> Response.json
|
|
159
|
+
|> BackendTask.succeed
|
|
156
160
|
)
|
|
157
|
-
|
|
161
|
+
-- Path: /pages/:pageId/revisions/:revisionId/request-test
|
|
162
|
+
|> ApiRoute.literal "pages"
|
|
163
|
+
|> ApiRoute.slash
|
|
164
|
+
|> ApiRoute.capture
|
|
165
|
+
|> ApiRoute.slash
|
|
166
|
+
|> ApiRoute.literal "revisions"
|
|
167
|
+
|> ApiRoute.slash
|
|
168
|
+
|> ApiRoute.capture
|
|
158
169
|
|> ApiRoute.slash
|
|
159
170
|
|> ApiRoute.literal "request-test"
|
|
160
171
|
|> ApiRoute.serverRender
|
package/src/BackendTask/File.elm
CHANGED
|
@@ -5,7 +5,8 @@ module BackendTask.File exposing
|
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
{-| This module lets you read files from the local filesystem as a [`BackendTask`](BackendTask#BackendTask).
|
|
8
|
-
File paths are relative to the root of your `elm-pages` project (next to the `elm.json` file and `src/` directory)
|
|
8
|
+
File paths are relative to the root of your `elm-pages` project (next to the `elm.json` file and `src/` directory), or
|
|
9
|
+
you can pass in absolute paths beginning with a `/`.
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
## Files With Frontmatter
|
package/src/BackendTask.elm
CHANGED
|
@@ -199,27 +199,28 @@ combineHelp items =
|
|
|
199
199
|
List.foldl (map2 (::)) (succeed []) items |> map List.reverse
|
|
200
200
|
|
|
201
201
|
|
|
202
|
-
{-| Like map, but it takes in two `
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
202
|
+
{-| Like map, but it takes in two `BackendTask`s.
|
|
203
|
+
|
|
204
|
+
import BackendTask exposing (BackendTask)
|
|
205
|
+
import BackendTask.Env as Env
|
|
206
|
+
import BackendTask.Http
|
|
207
|
+
import FatalError exposing (FatalError)
|
|
208
|
+
import Json.Decode as Decode
|
|
209
|
+
|
|
210
|
+
type alias Data =
|
|
211
|
+
{ pokemon : List String, envValue : Maybe String }
|
|
212
|
+
|
|
213
|
+
data : BackendTask FatalError Data
|
|
214
|
+
data =
|
|
215
|
+
BackendTask.map2 Data
|
|
216
|
+
(BackendTask.Http.getJson
|
|
217
|
+
"https://pokeapi.co/api/v2/pokemon/?limit=100&offset=0"
|
|
218
|
+
(Decode.field "results"
|
|
219
|
+
(Decode.list (Decode.field "name" Decode.string))
|
|
220
|
+
)
|
|
221
|
+
|> BackendTask.allowFatal
|
|
222
222
|
)
|
|
223
|
+
(Env.get "HELLO")
|
|
223
224
|
|
|
224
225
|
-}
|
|
225
226
|
map2 : (a -> b -> c) -> BackendTask error a -> BackendTask error b -> BackendTask error c
|
|
@@ -334,28 +335,15 @@ andMap =
|
|
|
334
335
|
map2 (|>)
|
|
335
336
|
|
|
336
337
|
|
|
337
|
-
{-| This is useful for prototyping with some hardcoded data, or for having a view that doesn't have any
|
|
338
|
+
{-| This is useful for prototyping with some hardcoded data, or for having a view that doesn't have any BackendTask data.
|
|
338
339
|
|
|
339
|
-
import BackendTask
|
|
340
|
+
import BackendTask exposing (BackendTask)
|
|
341
|
+
|
|
342
|
+
type alias RouteParams = { name : String }
|
|
340
343
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
{ path : PagePath
|
|
345
|
-
, frontmatter : Metadata
|
|
346
|
-
}
|
|
347
|
-
->
|
|
348
|
-
StaticHttp.Request
|
|
349
|
-
{ view : Model -> View -> { title : String, body : Html Msg }
|
|
350
|
-
, head : List (Head.Tag Pages.PathKey)
|
|
351
|
-
}
|
|
352
|
-
view siteMetadata page =
|
|
353
|
-
StaticHttp.succeed
|
|
354
|
-
{ view =
|
|
355
|
-
\model viewForPage ->
|
|
356
|
-
mainView model viewForPage
|
|
357
|
-
, head = head page.frontmatter
|
|
358
|
-
}
|
|
344
|
+
pages : BackendTask error (List RouteParams)
|
|
345
|
+
pages =
|
|
346
|
+
BackendTask.succeed [ { name = "elm-pages" } ]
|
|
359
347
|
|
|
360
348
|
-}
|
|
361
349
|
succeed : a -> BackendTask error a
|
package/src/FatalError.elm
CHANGED
|
@@ -20,8 +20,8 @@ For example, if you wanted to handle possible errors to present them to the user
|
|
|
20
20
|
BackendTask.Http.getJson "https://api.github.com/repos/dillonkearns/elm-pages"
|
|
21
21
|
(Decode.field "description" Decode.string)
|
|
22
22
|
|> BackendTask.onError
|
|
23
|
-
(\
|
|
24
|
-
case
|
|
23
|
+
(\{ recoverable } ->
|
|
24
|
+
case recoverable of
|
|
25
25
|
BackendTask.Http.BadStatus metadata string ->
|
|
26
26
|
if metadata.statusCode == 401 || metadata.statusCode == 403 || metadata.statusCode == 404 then
|
|
27
27
|
BackendTask.succeed "Either this repo doesn't exist or you don't have access to it."
|