elm-pages 3.0.0-beta.14 → 3.0.0-beta.15

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 (65) hide show
  1. package/README.md +1 -1
  2. package/codegen/elm-pages-codegen.js +4 -7
  3. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  4. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  6. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  7. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  8. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  9. package/generator/src/compatibility-key.js +1 -1
  10. package/generator/src/error-formatter.js +7 -3
  11. package/generator/src/render.js +8 -17
  12. package/generator/src/request-cache.js +34 -4
  13. package/generator/static-code/hmr.js +16 -2
  14. package/package.json +1 -1
  15. package/src/ApiRoute.elm +1 -4
  16. package/src/BackendTask/Env.elm +10 -8
  17. package/src/BackendTask/File.elm +10 -10
  18. package/src/BackendTask/Glob.elm +2 -2
  19. package/src/BackendTask/Http.elm +49 -13
  20. package/src/BackendTask/Port.elm +50 -46
  21. package/src/BackendTask.elm +5 -5
  22. package/src/Exception.elm +70 -12
  23. package/src/Form.elm +3 -2
  24. package/src/Pages/Generate.elm +299 -102
  25. package/src/Pages/Internal/Platform/Cli.elm +17 -37
  26. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  27. package/src/Pages/Internal/Platform/GeneratorApplication.elm +17 -41
  28. package/src/Pages/Internal/Platform/StaticResponses.elm +11 -25
  29. package/src/Pages/Script.elm +2 -2
  30. package/src/Pages/StaticHttpRequest.elm +1 -23
  31. package/src/Server/Request.elm +3 -2
  32. package/src/MultiDict.elm +0 -49
  33. package/src/PairingHeap.elm +0 -137
  34. package/src/Parser/Extra/String.elm +0 -33
  35. package/src/Parser/Extra.elm +0 -69
  36. package/src/ProgramTest/ComplexQuery.elm +0 -360
  37. package/src/ProgramTest/EffectSimulation.elm +0 -122
  38. package/src/ProgramTest/Failure.elm +0 -367
  39. package/src/ProgramTest/HtmlHighlighter.elm +0 -116
  40. package/src/ProgramTest/HtmlParserHacks.elm +0 -58
  41. package/src/ProgramTest/HtmlRenderer.elm +0 -73
  42. package/src/ProgramTest/Program.elm +0 -30
  43. package/src/ProgramTest/StringLines.elm +0 -26
  44. package/src/ProgramTest/TestHtmlHacks.elm +0 -132
  45. package/src/ProgramTest/TestHtmlParser.elm +0 -201
  46. package/src/ProgramTest.elm +0 -2339
  47. package/src/Query/Extra.elm +0 -55
  48. package/src/SimulatedEffect/Cmd.elm +0 -69
  49. package/src/SimulatedEffect/Http.elm +0 -330
  50. package/src/SimulatedEffect/Navigation.elm +0 -69
  51. package/src/SimulatedEffect/Ports.elm +0 -62
  52. package/src/SimulatedEffect/Process.elm +0 -24
  53. package/src/SimulatedEffect/Sub.elm +0 -48
  54. package/src/SimulatedEffect/Task.elm +0 -252
  55. package/src/SimulatedEffect/Time.elm +0 -25
  56. package/src/SimulatedEffect.elm +0 -42
  57. package/src/String/Extra.elm +0 -6
  58. package/src/Test/Http.elm +0 -145
  59. package/src/TestResult.elm +0 -35
  60. package/src/TestState.elm +0 -305
  61. package/src/Url/Extra.elm +0 -100
  62. package/src/Vendored/Diff.elm +0 -321
  63. package/src/Vendored/Failure.elm +0 -217
  64. package/src/Vendored/FormatMonochrome.elm +0 -44
  65. package/src/Vendored/Highlightable.elm +0 -53
@@ -1,252 +0,0 @@
1
- module SimulatedEffect.Task exposing
2
- ( perform, attempt
3
- , andThen, succeed, fail, sequence
4
- , map, map2, map3, map4, map5
5
- , mapError, onError
6
- )
7
-
8
- {-| This module parallels [elm/core's `Task` module](https://package.elm-lang.org/packages/elm/core/1.0.2/Task).
9
- _Pull requests are welcome to add any functions that are missing._
10
-
11
- The functions here produce `SimulatedTasks`s instead of `Tasks`s
12
- and `SimulatedEffect`s instead of `Cmd`s, which are meant to be used
13
- to help you implement the function to provide when using [`ProgramTest.withSimulatedEffects`](ProgramTest#withSimulatedEffects).
14
-
15
-
16
- # Tasks
17
-
18
- @docs perform, attempt
19
-
20
-
21
- # Chains
22
-
23
- @docs andThen, succeed, fail, sequence
24
-
25
-
26
- # Maps
27
-
28
- @docs map, map2, map3, map4, map5
29
-
30
-
31
- # Errors
32
-
33
- @docs mapError, onError
34
-
35
- -}
36
-
37
- import ProgramTest exposing (SimulatedEffect, SimulatedTask)
38
- import SimulatedEffect
39
-
40
-
41
- {-| -}
42
- perform : (a -> msg) -> SimulatedTask Never a -> SimulatedEffect msg
43
- perform f task =
44
- task
45
- |> map f
46
- |> mapError never
47
- |> SimulatedEffect.Task
48
-
49
-
50
- {-| This is very similar to [`perform`](#perform) except it can handle failures!
51
- -}
52
- attempt : (Result x a -> msg) -> SimulatedTask x a -> SimulatedEffect msg
53
- attempt f task =
54
- task
55
- |> map (Ok >> f)
56
- |> mapError (Err >> f)
57
- |> SimulatedEffect.Task
58
-
59
-
60
- {-| Chain together a task and a callback.
61
- -}
62
- andThen : (a -> SimulatedTask x b) -> SimulatedTask x a -> SimulatedTask x b
63
- andThen f task =
64
- case task of
65
- SimulatedEffect.Succeed a ->
66
- f a
67
-
68
- SimulatedEffect.Fail x ->
69
- SimulatedEffect.Fail x
70
-
71
- SimulatedEffect.HttpTask request ->
72
- SimulatedEffect.HttpTask
73
- { method = request.method
74
- , url = request.url
75
- , body = request.body
76
- , headers = request.headers
77
- , onRequestComplete = request.onRequestComplete >> andThen f
78
- }
79
-
80
- SimulatedEffect.SleepTask delay onResult ->
81
- SimulatedEffect.SleepTask delay (onResult >> andThen f)
82
-
83
- SimulatedEffect.NowTask onResult ->
84
- SimulatedEffect.NowTask (onResult >> andThen f)
85
-
86
-
87
- {-| A task that succeeds immediately when run.
88
- -}
89
- succeed : a -> SimulatedTask x a
90
- succeed =
91
- SimulatedEffect.Succeed
92
-
93
-
94
- {-| A task that fails immediately when run.
95
- -}
96
- fail : x -> SimulatedTask x a
97
- fail =
98
- SimulatedEffect.Fail
99
-
100
-
101
- {-| Start with a list of tasks, and turn them into a single task that returns a
102
- list.
103
- -}
104
- sequence : List (SimulatedTask x a) -> SimulatedTask x (List a)
105
- sequence tasks =
106
- List.foldr (map2 (::)) (succeed []) tasks
107
-
108
-
109
- {-| Transform a task.
110
- -}
111
- map : (a -> b) -> SimulatedTask x a -> SimulatedTask x b
112
- map f =
113
- andThen (f >> SimulatedEffect.Succeed)
114
-
115
-
116
- {-| Put the results of two tasks together.
117
- -}
118
- map2 : (a -> b -> result) -> SimulatedTask x a -> SimulatedTask x b -> SimulatedTask x result
119
- map2 func taskA taskB =
120
- taskA
121
- |> andThen
122
- (\a ->
123
- taskB
124
- |> andThen (\b -> succeed (func a b))
125
- )
126
-
127
-
128
- {-| Put the results of three tasks together.
129
- -}
130
- map3 : (a -> b -> c -> result) -> SimulatedTask x a -> SimulatedTask x b -> SimulatedTask x c -> SimulatedTask x result
131
- map3 func taskA taskB taskC =
132
- taskA
133
- |> andThen
134
- (\a ->
135
- taskB
136
- |> andThen
137
- (\b ->
138
- taskC
139
- |> andThen (\c -> succeed (func a b c))
140
- )
141
- )
142
-
143
-
144
- {-| Put the results of four tasks together.
145
- -}
146
- map4 :
147
- (a -> b -> c -> d -> result)
148
- -> SimulatedTask x a
149
- -> SimulatedTask x b
150
- -> SimulatedTask x c
151
- -> SimulatedTask x d
152
- -> SimulatedTask x result
153
- map4 func taskA taskB taskC taskD =
154
- taskA
155
- |> andThen
156
- (\a ->
157
- taskB
158
- |> andThen
159
- (\b ->
160
- taskC
161
- |> andThen
162
- (\c ->
163
- taskD
164
- |> andThen (\d -> succeed (func a b c d))
165
- )
166
- )
167
- )
168
-
169
-
170
- {-| Put the results of five tasks together.
171
- -}
172
- map5 :
173
- (a -> b -> c -> d -> e -> result)
174
- -> SimulatedTask x a
175
- -> SimulatedTask x b
176
- -> SimulatedTask x c
177
- -> SimulatedTask x d
178
- -> SimulatedTask x e
179
- -> SimulatedTask x result
180
- map5 func taskA taskB taskC taskD taskE =
181
- taskA
182
- |> andThen
183
- (\a ->
184
- taskB
185
- |> andThen
186
- (\b ->
187
- taskC
188
- |> andThen
189
- (\c ->
190
- taskD
191
- |> andThen
192
- (\d ->
193
- taskE
194
- |> andThen (\e -> succeed (func a b c d e))
195
- )
196
- )
197
- )
198
- )
199
-
200
-
201
- {-| Transform the error value.
202
- -}
203
- mapError : (x -> y) -> SimulatedTask x a -> SimulatedTask y a
204
- mapError f task =
205
- case task of
206
- SimulatedEffect.Succeed a ->
207
- SimulatedEffect.Succeed a
208
-
209
- SimulatedEffect.Fail x ->
210
- SimulatedEffect.Fail (f x)
211
-
212
- SimulatedEffect.HttpTask request ->
213
- SimulatedEffect.HttpTask
214
- { method = request.method
215
- , url = request.url
216
- , body = request.body
217
- , headers = request.headers
218
- , onRequestComplete = request.onRequestComplete >> mapError f
219
- }
220
-
221
- SimulatedEffect.SleepTask delay onResult ->
222
- SimulatedEffect.SleepTask delay (onResult >> mapError f)
223
-
224
- SimulatedEffect.NowTask onResult ->
225
- SimulatedEffect.NowTask (onResult >> mapError f)
226
-
227
-
228
- {-| Recover from a failure in a task.
229
- -}
230
- onError : (x -> SimulatedTask y a) -> SimulatedTask x a -> SimulatedTask y a
231
- onError f task =
232
- case task of
233
- SimulatedEffect.Succeed a ->
234
- SimulatedEffect.Succeed a
235
-
236
- SimulatedEffect.Fail x ->
237
- f x
238
-
239
- SimulatedEffect.HttpTask request ->
240
- SimulatedEffect.HttpTask
241
- { method = request.method
242
- , url = request.url
243
- , body = request.body
244
- , headers = request.headers
245
- , onRequestComplete = request.onRequestComplete >> onError f
246
- }
247
-
248
- SimulatedEffect.SleepTask delay onResult ->
249
- SimulatedEffect.SleepTask delay (onResult >> onError f)
250
-
251
- SimulatedEffect.NowTask onResult ->
252
- SimulatedEffect.NowTask (onResult >> onError f)
@@ -1,25 +0,0 @@
1
- module SimulatedEffect.Time exposing (now)
2
-
3
- {-| This module parallels [elm/time's `Time` module](https://package.elm-lang.org/packages/elm/time/1.0.0/Time).
4
- _Pull requests are welcome to add any functions that are missing._
5
-
6
- The functions here produce `SimulatedEffect`s instead of `Cmd`s, which are meant to be used
7
- to help you implement the function to provide when using [`ProgramTest.withSimulatedEffects`](ProgramTest#withSimulatedEffects).
8
-
9
-
10
- # Time
11
-
12
- @docs now
13
-
14
- -}
15
-
16
- import ProgramTest exposing (SimulatedTask)
17
- import SimulatedEffect
18
- import Time
19
-
20
-
21
- {-| Get the POSIX time at the moment when this task is run.
22
- -}
23
- now : SimulatedTask x Time.Posix
24
- now =
25
- SimulatedEffect.NowTask SimulatedEffect.Succeed
@@ -1,42 +0,0 @@
1
- module SimulatedEffect exposing (HttpRequest, SimulatedEffect(..), SimulatedSub(..), SimulatedTask(..))
2
-
3
- import Http
4
- import Json.Decode
5
- import Json.Encode
6
- import Time
7
-
8
-
9
- type SimulatedEffect msg
10
- = None
11
- | Batch (List (SimulatedEffect msg))
12
- | Task (SimulatedTask msg msg)
13
- | PortEffect String Json.Encode.Value
14
- -- Navigation
15
- | PushUrl String
16
- | ReplaceUrl String
17
- | Back Int
18
- | Load String
19
- | Reload Bool
20
-
21
-
22
- type SimulatedTask x a
23
- = Succeed a
24
- | Fail x
25
- | HttpTask (HttpRequest x a)
26
- | SleepTask Float (() -> SimulatedTask x a)
27
- | NowTask (Time.Posix -> SimulatedTask x a)
28
-
29
-
30
- type alias HttpRequest x a =
31
- { method : String
32
- , url : String
33
- , body : String
34
- , headers : List ( String, String )
35
- , onRequestComplete : Http.Response String -> SimulatedTask x a
36
- }
37
-
38
-
39
- type SimulatedSub msg
40
- = NoneSub
41
- | BatchSub (List (SimulatedSub msg))
42
- | PortSub String (Json.Decode.Decoder msg)
@@ -1,6 +0,0 @@
1
- module String.Extra exposing (escape)
2
-
3
-
4
- escape : String -> String
5
- escape s =
6
- "\"" ++ s ++ "\""
package/src/Test/Http.elm DELETED
@@ -1,145 +0,0 @@
1
- module Test.Http exposing
2
- ( expectJsonBody, HttpRequest, hasHeader
3
- , timeout, networkError, httpResponse
4
- )
5
-
6
- {-| Convenience functions for testing HTTP requests.
7
- _Pull requests are welcome to add more useful functions._
8
-
9
-
10
- ## Expectations
11
-
12
- These functions provide some convenient checks that can be used with [`ProgramTest.expectHttpRequest`](ProgramTest#expectHttpRequest).
13
-
14
- @docs expectJsonBody, HttpRequest, hasHeader
15
-
16
-
17
- ## Responses
18
-
19
- These are ways to easily make `Http.Response` values for use with [`ProgramTest.simulateHttpResponse`](ProgramTest#simulateHttpResponse).
20
-
21
- @docs timeout, networkError, httpResponse
22
-
23
- -}
24
-
25
- import Dict exposing (Dict)
26
- import Expect exposing (Expectation)
27
- import Http
28
- import Json.Decode
29
- import SimulatedEffect exposing (SimulatedTask)
30
-
31
-
32
- {-| -}
33
- type alias HttpRequest x a =
34
- { method : String
35
- , url : String
36
- , body : String
37
- , headers : List ( String, String )
38
- , onRequestComplete : Http.Response String -> SimulatedTask x a
39
- }
40
-
41
-
42
- {-| A convenient way to check something about the request body of a pending HTTP request.
43
-
44
- ...
45
- |> ProgramTest.expectHttpRequest "POST"
46
- "https://example.com/ok"
47
- (Test.Http.expectJsonBody
48
- (Json.Decode.field "version" Json.Decode.string)
49
- (Expect.equal "3.1.5")
50
- )
51
-
52
- -}
53
- expectJsonBody :
54
- Json.Decode.Decoder requestBody
55
- -> (requestBody -> Expectation)
56
- -> HttpRequest x a
57
- -> Expectation
58
- expectJsonBody decoder check request =
59
- case Json.Decode.decodeString decoder request.body of
60
- Err err ->
61
- Expect.fail ("expectJsonBody: Failed to decode HTTP request body: " ++ Json.Decode.errorToString err)
62
-
63
- Ok responseBody ->
64
- check responseBody
65
-
66
-
67
- {-| Assert that the given HTTP request has the specified header.
68
-
69
- ...
70
- |> ProgramTest.expectHttpRequest "POST"
71
- "https://example.com/ok"
72
- (Test.Http.hasHeader "Content-Type" "application/json")
73
-
74
- -}
75
- hasHeader : String -> String -> HttpRequest x a -> Expectation
76
- hasHeader key value { headers } =
77
- let
78
- key_ =
79
- String.toLower key
80
-
81
- value_ =
82
- String.toLower value
83
-
84
- matches ( k, v ) =
85
- ( String.toLower k, String.toLower v )
86
- == ( key_, value_ )
87
- in
88
- if List.any matches headers then
89
- Expect.pass
90
-
91
- else
92
- Expect.fail <|
93
- String.join "\n"
94
- [ "Expected HTTP header " ++ key ++ ": " ++ value
95
- , "but got headers:"
96
- , List.map (\( k, v ) -> " " ++ k ++ ": " ++ v) headers
97
- |> String.join "\n"
98
- ]
99
-
100
-
101
- {-| This is the same as `Http.Timeout_`,
102
- but is exposed here so that your test doesn't need to import both `Http` and `Test.Http`.
103
- -}
104
- timeout : Http.Response body
105
- timeout =
106
- Http.Timeout_
107
-
108
-
109
- {-| This is the same as `Http.NetworkError_`,
110
- but is exposed here so that your test doesn't need to import both `Http` and `Test.Http`.
111
- -}
112
- networkError : Http.Response body
113
- networkError =
114
- Http.NetworkError_
115
-
116
-
117
- {-| This is a more convenient way to create `Http.BadStatus_` and `Http.GoodStatus_` values.
118
-
119
- Following the [logic in elm/http](https://github.com/elm/http/blob/2.0.0/src/Elm/Kernel/Http.js#L65),
120
- this will produce `Http.GoodStatus_` if the given status code is in the 200 series, otherwise
121
- it will produce `Http.BadStatus_`.
122
-
123
- -}
124
- httpResponse :
125
- { statusCode : Int
126
- , headers : List ( String, String )
127
- , body : body
128
- }
129
- -> Http.Response body
130
- httpResponse response =
131
- let
132
- variant =
133
- if response.statusCode >= 200 && response.statusCode < 300 then
134
- Http.GoodStatus_
135
-
136
- else
137
- Http.BadStatus_
138
- in
139
- variant
140
- { url = ""
141
- , statusCode = response.statusCode
142
- , statusText = "TODO: if you need this, please report to https://github.com/avh4/elm-program-test/issues"
143
- , headers = Dict.fromList response.headers
144
- }
145
- response.body
@@ -1,35 +0,0 @@
1
- module TestResult exposing (TestResult, andThen, fail)
2
-
3
- import ProgramTest.Failure exposing (Failure)
4
- import TestState exposing (TestState)
5
-
6
-
7
- {-| TODO: what's a better name?
8
- -}
9
- type alias TestResult model msg effect =
10
- Result
11
- { reason : Failure
12
- }
13
- (TestState model msg effect)
14
-
15
-
16
- fail : Failure -> TestState model msg effect -> TestResult model msg effect
17
- fail failure state =
18
- Err
19
- { reason = failure
20
- }
21
-
22
-
23
- andThen : (TestState model msg effect -> Result Failure (TestState model msg effect)) -> TestResult model msg effect -> TestResult model msg effect
24
- andThen f testResult =
25
- case testResult of
26
- Ok state ->
27
- case f state of
28
- Err failure ->
29
- fail failure state
30
-
31
- Ok newState ->
32
- Ok newState
33
-
34
- Err _ ->
35
- testResult