elm-pages 3.0.0-beta.25 → 3.0.0-beta.26

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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +0 -0
  3. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
  4. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmi +0 -0
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
  6. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmi +0 -0
  7. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmo +0 -0
  8. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmi +0 -0
  9. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmo +0 -0
  10. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  11. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
  12. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/lock +0 -0
  13. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  14. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -0
  15. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +8000 -0
  16. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +27859 -0
  17. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +110 -0
  18. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +187 -0
  19. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/package.json +1 -0
  20. package/generator/dead-code-review/elm-stuff/tests-0.19.1/src/Reporter.elm +26 -0
  21. package/generator/dead-code-review/elm-stuff/tests-0.19.1/src/Runner.elm +62 -0
  22. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
  23. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmo +0 -0
  24. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
  25. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmo +0 -0
  26. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolationsTest.elmi +0 -0
  27. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolationsTest.elmo +0 -0
  28. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmi +0 -0
  29. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmo +0 -0
  30. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmi +0 -0
  31. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmo +0 -0
  32. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  33. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
  34. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/lock +0 -0
  35. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  36. package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -0
  37. package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +8000 -0
  38. package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +29601 -0
  39. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +110 -0
  40. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +187 -0
  41. package/generator/review/elm-stuff/tests-0.19.1/js/package.json +1 -0
  42. package/generator/review/elm-stuff/tests-0.19.1/src/Reporter.elm +26 -0
  43. package/generator/review/elm-stuff/tests-0.19.1/src/Runner.elm +62 -0
  44. package/generator/src/build.js +3 -3
  45. package/generator/src/cli.js +3 -3
  46. package/generator/src/codegen.js +1 -1
  47. package/generator/src/compatibility-key.js +2 -2
  48. package/generator/src/dev-server.js +2 -2
  49. package/generator/src/generate-template-module-connector.js +11 -9
  50. package/generator/src/init.js +2 -2
  51. package/package.json +6 -6
  52. package/src/Form/FieldView.elm +10 -26
  53. package/src/Form.elm +15 -1
  54. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
@@ -0,0 +1,110 @@
1
+ const { parentPort } = require("worker_threads");
2
+ const { performance } = require("perf_hooks");
3
+
4
+ // From templates/polyfills.js
5
+ // Apply Node polyfills as necessary.
6
+ var window = {
7
+ Date: Date,
8
+ addEventListener: function () {},
9
+ removeEventListener: function () {},
10
+ };
11
+
12
+ var location = {
13
+ href: "",
14
+ host: "",
15
+ hostname: "",
16
+ protocol: "",
17
+ origin: "",
18
+ port: "",
19
+ pathname: "",
20
+ search: "",
21
+ hash: "",
22
+ username: "",
23
+ password: "",
24
+ };
25
+
26
+ var document = {
27
+ body: {},
28
+ createTextNode: function () {},
29
+ location: location,
30
+ };
31
+
32
+ var oldConsoleWarn = console.warn;
33
+ console.warn = function () {
34
+ if (
35
+ arguments.length === 1 &&
36
+ arguments[0].indexOf("Compiled in DEV mode") === 0
37
+ )
38
+ return;
39
+ return oldConsoleWarn.apply(console, arguments);
40
+ };
41
+
42
+ if (typeof FileList === "undefined") {
43
+ var FileList = function () {};
44
+ }
45
+
46
+ if (typeof File === "undefined") {
47
+ var File = function () {};
48
+ }
49
+
50
+ if (typeof XMLHttpRequest === "undefined") {
51
+ var XMLHttpRequest = function () {
52
+ return {
53
+ addEventListener: function () {},
54
+ open: function () {},
55
+ send: function () {},
56
+ };
57
+ };
58
+ }
59
+
60
+ if (typeof FormData === "undefined") {
61
+ var FormData = function () {
62
+ this._data = [];
63
+ };
64
+ FormData.prototype.append = function () {
65
+ this._data.push(Array.prototype.slice.call(arguments));
66
+ };
67
+ }
68
+
69
+
70
+ // Capture Debug.log from elm code
71
+ let logs = [];
72
+ console.elmlog = (str) => logs.push(str + "\n");
73
+
74
+ // Compiled by elm-test-rs from templates/Runner.elm
75
+ const { Elm } = require("./Runner.elm.js");
76
+
77
+ // Start the Elm app
78
+ const flags = { initialSeed: 2394734000, fuzzRuns: 100, filter: null };
79
+ const app = Elm.Runner.init({ flags: flags });
80
+
81
+ // Record the timing at which we received the last "runTest" message
82
+ let startTime;
83
+
84
+ // Communication from Supervisor to Elm runner via port
85
+ parentPort.on("message", (msg) => {
86
+ if (msg.type_ == "askTestsCount") {
87
+ app.ports.askTestsCount.send();
88
+ } else if (msg.type_ == "runTest") {
89
+ startTime = performance.now();
90
+ app.ports.receiveRunTest.send(msg.id);
91
+ } else {
92
+ console.error("Invalid supervisor msg.type_:", msg.type_);
93
+ }
94
+ });
95
+
96
+ // Communication from Elm runner to Supervisor via port
97
+ // Subscribe to outgoing Elm ports defined in templates/Runner.elm
98
+ app.ports.sendResult.subscribe((msg) => {
99
+ msg.type_ = "testResult";
100
+ msg.duration = performance.now() - startTime;
101
+ msg.logs = logs;
102
+ parentPort.postMessage(msg);
103
+ logs.length = 0;
104
+ });
105
+ app.ports.sendTestsCount.subscribe((msg) => {
106
+ msg.type_ = "testsCount";
107
+ msg.logs = logs;
108
+ parentPort.postMessage(msg);
109
+ logs.length = 0;
110
+ });
@@ -0,0 +1,187 @@
1
+ process.chdir(__dirname);
2
+
3
+ // From templates/polyfills.js
4
+ // Apply Node polyfills as necessary.
5
+ var window = {
6
+ Date: Date,
7
+ addEventListener: function () {},
8
+ removeEventListener: function () {},
9
+ };
10
+
11
+ var location = {
12
+ href: "",
13
+ host: "",
14
+ hostname: "",
15
+ protocol: "",
16
+ origin: "",
17
+ port: "",
18
+ pathname: "",
19
+ search: "",
20
+ hash: "",
21
+ username: "",
22
+ password: "",
23
+ };
24
+
25
+ var document = {
26
+ body: {},
27
+ createTextNode: function () {},
28
+ location: location,
29
+ };
30
+
31
+ var oldConsoleWarn = console.warn;
32
+ console.warn = function () {
33
+ if (
34
+ arguments.length === 1 &&
35
+ arguments[0].indexOf("Compiled in DEV mode") === 0
36
+ )
37
+ return;
38
+ return oldConsoleWarn.apply(console, arguments);
39
+ };
40
+
41
+ if (typeof FileList === "undefined") {
42
+ var FileList = function () {};
43
+ }
44
+
45
+ if (typeof File === "undefined") {
46
+ var File = function () {};
47
+ }
48
+
49
+ if (typeof XMLHttpRequest === "undefined") {
50
+ var XMLHttpRequest = function () {
51
+ return {
52
+ addEventListener: function () {},
53
+ open: function () {},
54
+ send: function () {},
55
+ };
56
+ };
57
+ }
58
+
59
+ if (typeof FormData === "undefined") {
60
+ var FormData = function () {
61
+ this._data = [];
62
+ };
63
+ FormData.prototype.append = function () {
64
+ this._data.push(Array.prototype.slice.call(arguments));
65
+ };
66
+ }
67
+
68
+
69
+ const { Worker } = require("worker_threads");
70
+ const readline = require("readline");
71
+ const { performance } = require("perf_hooks");
72
+
73
+ // Global variables
74
+ let testsCount, todoTests;
75
+ let reporter;
76
+ let runners = [];
77
+ let working = false;
78
+ let workersCount = 10;
79
+ let startWorkCallback = function(){};
80
+ const verbosity = 0;
81
+
82
+ // Create a long lived reporter worker
83
+ const { Elm } = require("./Reporter.elm.js");
84
+ const flags = {
85
+ initialSeed: 2394734000,
86
+ fuzzRuns: 100,
87
+ mode: "consoleColor",
88
+ verbosity: verbosity,
89
+ globs: [],
90
+ paths: ["/Users/dillonkearns/src/github.com/dillonkearns/elm-pages-v3-beta/generator/review/tests/Pages/Review/NoContractViolationsTest.elm"],
91
+ };
92
+ reporter = Elm.Reporter.init({ flags: flags });
93
+
94
+ // Pipe the Elm stdout port to stdout
95
+ reporter.ports.stdout.subscribe((str) => process.stdout.write(str));
96
+
97
+ // When the reporter has finished clean runners
98
+ reporter.ports.signalFinished.subscribe(async ({ exitCode, testsCount }) => {
99
+ await Promise.all(runners.map((runner) => runner.terminate()));
100
+ working = false;
101
+ startWorkCallback();
102
+ if (verbosity >= 1) {
103
+ console.warn("Running duration (since Node.js start):", Math.round(performance.now()), "ms\n");
104
+ }
105
+ process.exit(exitCode);
106
+ });
107
+
108
+ // When receiving a CLI message, start test workers
109
+ // The message is a string containing "/path/to/node_runner.js"
110
+ const rl = readline.createInterface({ input: process.stdin });
111
+ rl.on("line", (runnerFile) => {
112
+ working ? registerWork(runnerFile) : startWork(runnerFile);
113
+ });
114
+
115
+ function registerWork(runnerFile) {
116
+ startWorkCallback = () => startWork(runnerFile);
117
+ }
118
+
119
+ function startWork(runnerFile) {
120
+ startWorkCallback = function(){};
121
+ working = true;
122
+ // Start first runner worker and prevent piped stdout and sdterr
123
+ runners[0] = new Worker(runnerFile, { stdout: true }); //, stderr: true });
124
+ runners[0].on("message", (msg) =>
125
+ handleRunnerMsg(runners[0], runnerFile, msg)
126
+ );
127
+ runners[0].on("online", () =>
128
+ runners[0].postMessage({ type_: "askTestsCount" })
129
+ );
130
+ }
131
+
132
+ // Handle a test result
133
+ function handleRunnerMsg(runner, runnerFile, msg) {
134
+ if (msg.type_ == "testsCount") {
135
+ if (msg.logs.length > 0) {
136
+ console.warn("Debug logs captured when setting up tests: -----------\n");
137
+ msg.logs.forEach((str) => process.stderr.write(str));
138
+ console.warn("\n------------------------------------------------------\n");
139
+ }
140
+ setupWithTestsCount(runnerFile, msg);
141
+ } else if (msg.type_ == "testResult") {
142
+ dispatchWork(runner, todoTests.pop());
143
+ reporter.ports.incomingResult.send(msg);
144
+ } else {
145
+ console.error("Invalid runner msg.type_:", msg.type_);
146
+ }
147
+ }
148
+
149
+ // Reset supervisor tests count and reporter
150
+ // Start work on all runners
151
+ function setupWithTestsCount(runnerFile, msg) {
152
+ // Reset supervisor tests
153
+ testsCount = msg.testsCount;
154
+ todoTests = Array(testsCount)
155
+ .fill(0)
156
+ .map((_, id) => id)
157
+ .reverse();
158
+
159
+ // Reset reporter
160
+ reporter.ports.restart.send(msg);
161
+
162
+ // Send first runner job
163
+ if (testsCount == 0) {
164
+ console.error("No exposed values of type Test was found. Did you forget to expose them?");
165
+ return;
166
+ } else {
167
+ runners[0].postMessage({ type_: "runTest", id: todoTests.pop() });
168
+ }
169
+
170
+ // Create and send work to all other workers.
171
+ let max_workers = Math.min(workersCount, testsCount);
172
+ for (let i = 1; i < max_workers; i++) {
173
+ let runner = new Worker(runnerFile); //, { stdout: true, stderr: true });
174
+ runners[i] = runner;
175
+ runner.on("message", (msg) =>
176
+ handleRunnerMsg(runner, runnerFile, msg)
177
+ );
178
+ runner.on("online", () => dispatchWork(runner, todoTests.pop()));
179
+ }
180
+ }
181
+
182
+ // Ask runner to run some test.
183
+ function dispatchWork(runner, testId) {
184
+ if (testId != undefined) {
185
+ runner.postMessage({ type_: "runTest", id: testId });
186
+ }
187
+ }
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -0,0 +1,26 @@
1
+ port module Reporter exposing (main)
2
+
3
+ import ElmTestRunner.Reporter exposing (Flags, Model, Msg)
4
+ import Json.Decode exposing (Value)
5
+
6
+
7
+ port restart : ({ kind : String, testsCount : Int } -> msg) -> Sub msg
8
+
9
+
10
+ port incomingResult : ({ duration : Float, result : Value, logs : List String } -> msg) -> Sub msg
11
+
12
+
13
+ port signalFinished : { exitCode : Int, testsCount : Int } -> Cmd msg
14
+
15
+
16
+ port stdout : String -> Cmd msg
17
+
18
+
19
+ main : Program Flags Model Msg
20
+ main =
21
+ ElmTestRunner.Reporter.worker
22
+ { restart = restart
23
+ , incomingResult = incomingResult
24
+ , stdout = stdout
25
+ , signalFinished = signalFinished
26
+ }
@@ -0,0 +1,62 @@
1
+ port module Runner exposing (main)
2
+
3
+ import Pages.Review.NoContractViolationsTest
4
+
5
+ import ElmTestRunner.Runner exposing (Flags, Model, Msg)
6
+ import Json.Encode exposing (Value)
7
+ import Test exposing (Test)
8
+
9
+
10
+ port askTestsCount : (Value -> msg) -> Sub msg
11
+
12
+
13
+ port sendTestsCount : { kind : String, testsCount : Int } -> Cmd msg
14
+
15
+
16
+ port receiveRunTest : (Int -> msg) -> Sub msg
17
+
18
+
19
+ port sendResult : { id : Int, result : Value } -> Cmd msg
20
+
21
+
22
+ {-| The implementation of this function will be replaced in the generated JS
23
+ with a version that returns `Just value` if `value` is a `Test`, otherwise `Nothing`.
24
+ If you rename or change this function you also need to update the regex that looks for it.
25
+ -}
26
+ check : a -> Maybe Test
27
+ check =
28
+ checkHelperReplaceMe___
29
+
30
+
31
+ checkHelperReplaceMe___ : a -> b
32
+ checkHelperReplaceMe___ _ =
33
+ Debug.todo """The regex for replacing this Debug.todo with some real code must have failed since you see this message!
34
+
35
+ Please report this bug: https://github.com/mpizenberg/elm-test-rs/issues/new
36
+ """
37
+
38
+
39
+ tests : List Test
40
+ tests =
41
+ [ check Pages.Review.NoContractViolationsTest.all ]
42
+ |> List.filterMap identity
43
+
44
+
45
+ main : Program Flags Model Msg
46
+ main =
47
+ let
48
+ concatenatedTest =
49
+ case tests of
50
+ [] ->
51
+ Nothing
52
+
53
+ _ ->
54
+ Just (Test.concat tests)
55
+ in
56
+ concatenatedTest
57
+ |> ElmTestRunner.Runner.worker
58
+ { askTestsCount = askTestsCount
59
+ , sendTestsCount = sendTestsCount
60
+ , receiveRunTest = receiveRunTest
61
+ , sendResult = sendResult
62
+ }
@@ -17,7 +17,7 @@ import * as esbuild from "esbuild";
17
17
  import { createHash } from "crypto";
18
18
  import { merge_vite_configs } from "./vite-utils.js";
19
19
  import { resolveConfig } from "./config.js";
20
- import { globbySync } from "globby";
20
+ import * as globby from "globby";
21
21
  import { fileURLToPath } from "url";
22
22
  import { copyFile } from "fs/promises";
23
23
 
@@ -166,7 +166,7 @@ export async function run(options) {
166
166
  })
167
167
  .catch((error) => {
168
168
  const portBackendTaskFileFound =
169
- globbySync("./custom-backend-task.*").length > 0;
169
+ globby.globbySync("./custom-backend-task.*").length > 0;
170
170
  if (portBackendTaskFileFound) {
171
171
  // don't present error if there are no files matching custom-backend-task
172
172
  // if there are files matching custom-backend-task, warn the user in case something went wrong loading it
@@ -416,7 +416,7 @@ async function spawnElmMake(mode, options, elmEntrypointPath, outputPath, cwd) {
416
416
  "function appendSubmitter (myFormData, event) { event.submitter && event.submitter.name && event.submitter.name.length > 0 ? myFormData.append(event.submitter.name, event.submitter.value) : myFormData; return myFormData }; return " +
417
417
  (options.debug
418
418
  ? "_Json_wrap(Array.from(appendSubmitter(new FormData(_Json_unwrap(event).target), _Json_unwrap(event))))"
419
- : "Array.from(new FormData(event.target))")
419
+ : "[...(appendSubmitter(new FormData(event.target), event))]")
420
420
  )
421
421
  );
422
422
  }
@@ -9,7 +9,7 @@ import * as fs from "node:fs";
9
9
  import * as path from "node:path";
10
10
  import { restoreColorSafe } from "./error-formatter.js";
11
11
  import * as renderer from "./render.js";
12
- import { globbySync } from "globby";
12
+ import * as globby from "globby";
13
13
  import * as esbuild from "esbuild";
14
14
  import { rewriteElmJson } from "./rewrite-elm-json.js";
15
15
  import { ensureDirSync } from "./file-helpers.js";
@@ -148,7 +148,7 @@ async function main() {
148
148
  })
149
149
  .catch((error) => {
150
150
  const portBackendTaskFileFound =
151
- globbySync("./custom-backend-task.*").length > 0;
151
+ globby.globbySync("./custom-backend-task.*").length > 0;
152
152
  if (portBackendTaskFileFound) {
153
153
  // don't present error if there are no files matching custom-backend-task
154
154
  // if there are files matching custom-backend-task, warn the user in case something went wrong loading it
@@ -247,7 +247,7 @@ async function main() {
247
247
  );
248
248
  // TODO allow no custom-backend-task
249
249
  const portBackendTaskFileFound =
250
- globbySync("./custom-backend-task.*").length > 0;
250
+ globby.globbySync("./custom-backend-task.*").length > 0;
251
251
 
252
252
  const scriptRunner = `${
253
253
  portBackendTaskFileFound
@@ -1,5 +1,5 @@
1
1
  import * as fs from "node:fs";
2
- import * as fsExtra from "fs-extra/esm";
2
+ import * as fsExtra from "fs-extra";
3
3
  import { rewriteElmJson } from "./rewrite-elm-json.js";
4
4
  import { rewriteClientElmJson } from "./rewrite-client-elm-json.js";
5
5
  import { elmPagesCliFile, elmPagesUiFile } from "./elm-file-constants.js";
@@ -1,3 +1,3 @@
1
- export const compatibilityKey = 9;
1
+ export const compatibilityKey = 10;
2
2
 
3
- export const packageVersion = "3.0.0-beta.25";
3
+ export const packageVersion = "3.0.0-beta.26";
@@ -26,7 +26,7 @@ import * as esbuild from "esbuild";
26
26
  import { merge_vite_configs } from "./vite-utils.js";
27
27
  import { templateHtml } from "./pre-render-html.js";
28
28
  import { resolveConfig } from "./config.js";
29
- import { globbySync } from "globby";
29
+ import * as globby from "globby";
30
30
  import { fileURLToPath } from "url";
31
31
 
32
32
  const __filename = fileURLToPath(import.meta.url);
@@ -206,7 +206,7 @@ export async function start(options) {
206
206
  });
207
207
  } catch (e) {
208
208
  const portBackendTaskFileFound =
209
- globbySync("./custom-backend-task.*").length > 0;
209
+ globby.globbySync("./custom-backend-task.*").length > 0;
210
210
  if (portBackendTaskFileFound) {
211
211
  // don't present error if there are no files matching custom-backend-task
212
212
  // if there are files matching custom-backend-task, warn the user in case something went wrong loading it
@@ -1,4 +1,4 @@
1
- import { globbySync } from "globby";
1
+ import * as globby from "globby";
2
2
  import * as path from "path";
3
3
  import { default as mm } from "micromatch";
4
4
  import * as routeHelpers from "./route-codegen-helpers.js";
@@ -10,14 +10,16 @@ import { fileURLToPath } from "url";
10
10
  * @param {'browser' | 'cli'} phase
11
11
  */
12
12
  export async function generateTemplateModuleConnector(basePath, phase) {
13
- const templates = globbySync(["app/Route/**/*.elm"], {}).map((file) => {
14
- const captures = mm.capture("app/Route/**/*.elm", file);
15
- if (captures) {
16
- return path.join(captures[0], captures[1]).split(path.sep);
17
- } else {
18
- return [];
19
- }
20
- });
13
+ const templates = globby
14
+ .globbySync(["app/Route/**/*.elm"], {})
15
+ .map((file) => {
16
+ const captures = mm.capture("app/Route/**/*.elm", file);
17
+ if (captures) {
18
+ return path.join(captures[0], captures[1]).split(path.sep);
19
+ } else {
20
+ return [];
21
+ }
22
+ });
21
23
  if (templates.length <= 0) {
22
24
  throw {
23
25
  path: "",
@@ -1,5 +1,5 @@
1
1
  import * as fs from "fs";
2
- import { copySync } from "fs-extra/esm";
2
+ import * as fsExtra from "fs-extra";
3
3
  import * as path from "path";
4
4
  import * as kleur from "kleur/colors";
5
5
  import { fileURLToPath } from "url";
@@ -17,7 +17,7 @@ export async function run(name) {
17
17
 
18
18
  if (!fs.existsSync(name)) {
19
19
  try {
20
- copySync(template, appRoot);
20
+ fsExtra.copySync(template, appRoot);
21
21
  fs.renameSync(
22
22
  path.resolve(appRoot, "gitignore"),
23
23
  path.resolve(appRoot, ".gitignore")
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.25",
4
+ "version": "3.0.0-beta.26",
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.",
@@ -34,9 +34,9 @@
34
34
  "devcert": "^1.2.2",
35
35
  "elm-doc-preview": "^5.0.5",
36
36
  "elm-hot": "^1.1.6",
37
- "esbuild": "^0.17.8",
37
+ "esbuild": "0.17.10",
38
38
  "fs-extra": "^11.1.0",
39
- "globby": "^13.1.3",
39
+ "globby": "13.1.3",
40
40
  "gray-matter": "^4.0.3",
41
41
  "jsesc": "^3.0.2",
42
42
  "kleur": "^4.1.5",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/cross-spawn": "^6.0.2",
53
- "@types/fs-extra": "^9.0.13",
53
+ "@types/fs-extra": "^11.0.1",
54
54
  "@types/make-fetch-happen": "^10.0.1",
55
55
  "@types/micromatch": "^4.0.2",
56
56
  "@types/node": "^18.11.9",
@@ -63,8 +63,8 @@
63
63
  "elm-tooling": "^1.12.0",
64
64
  "elm-verify-examples": "^5.2.0",
65
65
  "elmi-to-json": "^1.2.0",
66
- "mocha": "^10.2.0",
67
- "typescript": "^4.9.5"
66
+ "typescript": "^4.9.5",
67
+ "vitest": "^0.28.5"
68
68
  },
69
69
  "files": [
70
70
  "generator/src/",
@@ -109,15 +109,15 @@ valueButton :
109
109
  String
110
110
  -> List (Html.Attribute msg)
111
111
  -> List (Html msg)
112
- -> Form.Validation.Field error parsed Input
112
+ -> Form.Validation.Field error parsed kind
113
113
  -> Html msg
114
114
  valueButton exactValue attrs children (Validation viewField fieldName _) =
115
115
  let
116
- justViewField : ViewField Input
116
+ justViewField : ViewField kind
117
117
  justViewField =
118
118
  expectViewField viewField
119
119
 
120
- rawField : { name : String, value : Maybe String, kind : ( Input, List ( String, Encode.Value ) ) }
120
+ rawField : { name : String, value : Maybe String, kind : ( kind, List ( String, Encode.Value ) ) }
121
121
  rawField =
122
122
  { name = fieldName |> Maybe.withDefault ""
123
123
  , value = Just exactValue --justViewField.value
@@ -125,20 +125,12 @@ valueButton exactValue attrs children (Validation viewField fieldName _) =
125
125
  }
126
126
  in
127
127
  case rawField.kind of
128
- ( Input inputType, properties ) ->
128
+ ( _, properties ) ->
129
129
  Html.button
130
130
  (attrs
131
131
  ++ toHtmlProperties properties
132
- ++ [ (case inputType of
133
- Checkbox ->
134
- Attr.checked ((rawField.value |> Maybe.withDefault "") == "on")
135
-
136
- _ ->
137
- Attr.value (rawField.value |> Maybe.withDefault "")
138
- -- TODO is this an okay default?
139
- )
132
+ ++ [ Attr.value (rawField.value |> Maybe.withDefault "")
140
133
  , Attr.name rawField.name
141
- , inputType |> inputTypeToString |> Attr.type_
142
134
  ]
143
135
  )
144
136
  children
@@ -150,15 +142,15 @@ valueButtonStyled :
150
142
  String
151
143
  -> List (Html.Styled.Attribute msg)
152
144
  -> List (Html.Styled.Html msg)
153
- -> Form.Validation.Field error parsed Input
145
+ -> Form.Validation.Field error parsed kind
154
146
  -> Html.Styled.Html msg
155
147
  valueButtonStyled exactValue attrs children (Validation viewField fieldName _) =
156
148
  let
157
- justViewField : ViewField Input
149
+ justViewField : ViewField kind
158
150
  justViewField =
159
151
  expectViewField viewField
160
152
 
161
- rawField : { name : String, value : Maybe String, kind : ( Input, List ( String, Encode.Value ) ) }
153
+ rawField : { name : String, value : Maybe String, kind : ( kind, List ( String, Encode.Value ) ) }
162
154
  rawField =
163
155
  { name = fieldName |> Maybe.withDefault ""
164
156
  , value = Just exactValue
@@ -166,20 +158,12 @@ valueButtonStyled exactValue attrs children (Validation viewField fieldName _) =
166
158
  }
167
159
  in
168
160
  case rawField.kind of
169
- ( Input inputType, properties ) ->
161
+ ( _, properties ) ->
170
162
  Html.Styled.button
171
163
  (attrs
172
164
  ++ (toHtmlProperties properties |> List.map StyledAttr.fromUnstyled)
173
- ++ ([ (case inputType of
174
- Checkbox ->
175
- Attr.checked ((rawField.value |> Maybe.withDefault "") == "on")
176
-
177
- _ ->
178
- Attr.value (rawField.value |> Maybe.withDefault "")
179
- -- TODO is this an okay default?
180
- )
165
+ ++ ([ Attr.value (rawField.value |> Maybe.withDefault "")
181
166
  , Attr.name rawField.name
182
- , inputType |> inputTypeToString |> Attr.type_
183
167
  ]
184
168
  |> List.map StyledAttr.fromUnstyled
185
169
  )
package/src/Form.elm CHANGED
@@ -1386,7 +1386,21 @@ helperValues toHiddenInput accessResponse options formState data (FormInternal f
1386
1386
  |> Errors
1387
1387
  , isTransitioning =
1388
1388
  -- TODO instead of isTransitioning : Bool, it would be useful to get a custom type with the exact state
1389
- (formState.fetchers |> Dict.member formId)
1389
+ (case formState.fetchers |> Dict.get formId of
1390
+ Just { status } ->
1391
+ case status of
1392
+ Pages.Transition.FetcherComplete _ ->
1393
+ False
1394
+
1395
+ Pages.Transition.FetcherSubmitting ->
1396
+ True
1397
+
1398
+ Pages.Transition.FetcherReloading _ ->
1399
+ True
1400
+
1401
+ Nothing ->
1402
+ False
1403
+ )
1390
1404
  || (case formState.transition of
1391
1405
  Just (Submitting formData) ->
1392
1406
  formData.id == Just formId
@@ -3,4 +3,4 @@ module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKe
3
3
 
4
4
  currentCompatibilityKey : Int
5
5
  currentCompatibilityKey =
6
- 9
6
+ 10