elm-pages 2.1.6 → 2.1.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.
Files changed (75) hide show
  1. package/generator/review/elm.json +34 -0
  2. package/generator/review/src/ReviewConfig.elm +10 -0
  3. package/generator/src/basepath-middleware.js +15 -9
  4. package/generator/src/build.js +100 -6
  5. package/generator/src/cli.js +13 -9
  6. package/generator/src/compile-elm.js +43 -0
  7. package/generator/src/dev-server.js +63 -11
  8. package/generator/src/error-formatter.js +62 -9
  9. package/generator/src/generate-template-module-connector.js +17 -4
  10. package/generator/src/init.js +4 -0
  11. package/generator/src/pre-render-html.js +19 -12
  12. package/generator/src/render-worker.js +0 -1
  13. package/generator/src/render.js +1 -2
  14. package/generator/src/seo-renderer.js +21 -2
  15. package/generator/static-code/hmr.js +43 -6
  16. package/generator/template/elm-tooling.json +9 -0
  17. package/generator/template/package.json +5 -1
  18. package/package.json +16 -9
  19. package/src/ApiRoute.elm +178 -0
  20. package/src/AriaLiveAnnouncer.elm +36 -0
  21. package/src/BuildError.elm +60 -0
  22. package/src/DataSource/File.elm +288 -0
  23. package/src/DataSource/Glob.elm +1050 -0
  24. package/src/DataSource/Http.elm +467 -0
  25. package/src/DataSource/Internal/Glob.elm +74 -0
  26. package/src/DataSource/Port.elm +87 -0
  27. package/src/DataSource/ServerRequest.elm +60 -0
  28. package/src/DataSource.elm +801 -0
  29. package/src/Head/Seo.elm +516 -0
  30. package/src/Head/Twitter.elm +109 -0
  31. package/src/Head.elm +452 -0
  32. package/src/HtmlPrinter.elm +27 -0
  33. package/src/Internal/ApiRoute.elm +89 -0
  34. package/src/Internal/OptimizedDecoder.elm +18 -0
  35. package/src/KeepOrDiscard.elm +6 -0
  36. package/src/OptimizedDecoder/Pipeline.elm +335 -0
  37. package/src/OptimizedDecoder.elm +818 -0
  38. package/src/Pages/ContentCache.elm +248 -0
  39. package/src/Pages/Flags.elm +26 -0
  40. package/src/Pages/Http.elm +10 -0
  41. package/src/Pages/Internal/ApplicationType.elm +6 -0
  42. package/src/Pages/Internal/NotFoundReason.elm +256 -0
  43. package/src/Pages/Internal/Platform/Cli.elm +1015 -0
  44. package/src/Pages/Internal/Platform/Effect.elm +14 -0
  45. package/src/Pages/Internal/Platform/StaticResponses.elm +540 -0
  46. package/src/Pages/Internal/Platform/ToJsPayload.elm +138 -0
  47. package/src/Pages/Internal/Platform.elm +745 -0
  48. package/src/Pages/Internal/RoutePattern.elm +122 -0
  49. package/src/Pages/Internal/Router.elm +116 -0
  50. package/src/Pages/Internal/StaticHttpBody.elm +54 -0
  51. package/src/Pages/Internal/String.elm +39 -0
  52. package/src/Pages/Manifest/Category.elm +240 -0
  53. package/src/Pages/Manifest.elm +412 -0
  54. package/src/Pages/PageUrl.elm +38 -0
  55. package/src/Pages/ProgramConfig.elm +73 -0
  56. package/src/Pages/Review/NoContractViolations.elm +397 -0
  57. package/src/Pages/Secrets.elm +83 -0
  58. package/src/Pages/SiteConfig.elm +13 -0
  59. package/src/Pages/StaticHttp/Request.elm +42 -0
  60. package/src/Pages/StaticHttpRequest.elm +320 -0
  61. package/src/Pages/Url.elm +60 -0
  62. package/src/Path.elm +96 -0
  63. package/src/QueryParams.elm +216 -0
  64. package/src/RenderRequest.elm +163 -0
  65. package/src/RequestsAndPending.elm +20 -0
  66. package/src/Secrets.elm +111 -0
  67. package/src/SecretsDict.elm +45 -0
  68. package/src/StructuredData.elm +236 -0
  69. package/src/TerminalText.elm +242 -0
  70. package/src/Test/Html/Internal/ElmHtml/Constants.elm +53 -0
  71. package/src/Test/Html/Internal/ElmHtml/Helpers.elm +17 -0
  72. package/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +529 -0
  73. package/src/Test/Html/Internal/ElmHtml/Markdown.elm +56 -0
  74. package/src/Test/Html/Internal/ElmHtml/ToString.elm +197 -0
  75. package/src/Test/Internal/KernelConstants.elm +34 -0
@@ -0,0 +1,122 @@
1
+ module Pages.Internal.RoutePattern exposing (Ending(..), RoutePattern, Segment(..), codec, view)
2
+
3
+ {-| Exposed for internal use only (used in generated code).
4
+
5
+ @docs Ending, RoutePattern, Segment, codec, view
6
+
7
+ -}
8
+
9
+ import Codec exposing (Codec)
10
+ import Html exposing (Html)
11
+
12
+
13
+ {-| -}
14
+ type alias RoutePattern =
15
+ { segments : List Segment
16
+ , ending : Maybe Ending
17
+ }
18
+
19
+
20
+ {-| -}
21
+ type Ending
22
+ = Optional String
23
+ | RequiredSplat
24
+ | OptionalSplat
25
+
26
+
27
+ {-| -}
28
+ type Segment
29
+ = StaticSegment String
30
+ | DynamicSegment String
31
+
32
+
33
+ {-| -}
34
+ codec : Codec RoutePattern
35
+ codec =
36
+ Codec.object RoutePattern
37
+ |> Codec.field "segments" .segments (Codec.list segmentCodec)
38
+ |> Codec.field "ending" .ending (Codec.maybe endingCodec)
39
+ |> Codec.buildObject
40
+
41
+
42
+ segmentCodec : Codec Segment
43
+ segmentCodec =
44
+ Codec.custom
45
+ (\vStatic vDynamic value ->
46
+ case value of
47
+ StaticSegment string ->
48
+ vStatic string
49
+
50
+ DynamicSegment string ->
51
+ vDynamic string
52
+ )
53
+ |> Codec.variant1 "StaticSegment" StaticSegment Codec.string
54
+ |> Codec.variant1 "DynamicSegment" DynamicSegment Codec.string
55
+ |> Codec.buildCustom
56
+
57
+
58
+ endingCodec : Codec Ending
59
+ endingCodec =
60
+ Codec.custom
61
+ (\vOptional vRequiredSplat vOptionalSplat value ->
62
+ case value of
63
+ Optional string ->
64
+ vOptional string
65
+
66
+ RequiredSplat ->
67
+ vRequiredSplat
68
+
69
+ OptionalSplat ->
70
+ vOptionalSplat
71
+ )
72
+ |> Codec.variant1 "Optional" Optional Codec.string
73
+ |> Codec.variant0 "RequiredSplat" RequiredSplat
74
+ |> Codec.variant0 "OptionalSplat" OptionalSplat
75
+ |> Codec.buildCustom
76
+
77
+
78
+ segmentToString : Segment -> String
79
+ segmentToString segment =
80
+ case segment of
81
+ StaticSegment string ->
82
+ string
83
+
84
+ DynamicSegment name ->
85
+ ":" ++ name
86
+
87
+
88
+ {-| -}
89
+ view : RoutePattern -> Html msg
90
+ view routePattern =
91
+ Html.span []
92
+ (case routePattern.ending of
93
+ Nothing ->
94
+ [ Html.code [] [ Html.text <| toString_ routePattern.segments ] ]
95
+
96
+ Just (Optional optionalName) ->
97
+ [ Html.code []
98
+ [ Html.text <| toString_ routePattern.segments ]
99
+ , Html.text " or "
100
+ , Html.code []
101
+ [ Html.text <|
102
+ toString_ routePattern.segments
103
+ ++ "/:"
104
+ ++ optionalName
105
+ ]
106
+ ]
107
+
108
+ Just RequiredSplat ->
109
+ [ Html.code [] [ Html.text <| toString_ routePattern.segments ] ]
110
+
111
+ Just OptionalSplat ->
112
+ [ Html.code [] [ Html.text <| toString_ routePattern.segments ] ]
113
+ )
114
+
115
+
116
+ toString_ : List Segment -> String
117
+ toString_ segments =
118
+ "/"
119
+ ++ (segments
120
+ |> List.map segmentToString
121
+ |> String.join "/"
122
+ )
@@ -0,0 +1,116 @@
1
+ module Pages.Internal.Router exposing (Matcher, firstMatch, fromOptionalSplat, maybeToList, nonEmptyToList, toNonEmpty)
2
+
3
+ {-| Exposed for internal use only (used in generated code).
4
+
5
+ @docs Matcher, firstMatch, fromOptionalSplat, maybeToList, nonEmptyToList, toNonEmpty
6
+
7
+ -}
8
+
9
+ import List.Extra
10
+ import Regex
11
+
12
+
13
+ {-| -}
14
+ firstMatch : List (Matcher route) -> String -> Maybe route
15
+ firstMatch matchers path =
16
+ List.Extra.findMap
17
+ (\matcher ->
18
+ if Regex.contains (matcher.pattern |> toRegex) (normalizePath path) then
19
+ tryMatch matcher path
20
+
21
+ else
22
+ Nothing
23
+ )
24
+ matchers
25
+
26
+
27
+ toRegex : String -> Regex.Regex
28
+ toRegex pattern =
29
+ Regex.fromString pattern
30
+ |> Maybe.withDefault Regex.never
31
+
32
+
33
+ {-| -}
34
+ nonEmptyToList : ( String, List String ) -> List String
35
+ nonEmptyToList ( string, strings ) =
36
+ string :: strings
37
+
38
+
39
+ {-| -}
40
+ fromOptionalSplat : Maybe String -> List String
41
+ fromOptionalSplat maybeMatch =
42
+ maybeMatch
43
+ |> Maybe.map (\match -> match |> String.split "/")
44
+ |> Maybe.map (List.filter (\item -> item /= ""))
45
+ |> Maybe.withDefault []
46
+
47
+
48
+ {-| -}
49
+ maybeToList : Maybe String -> List String
50
+ maybeToList maybeString =
51
+ case maybeString of
52
+ Just string ->
53
+ [ string ]
54
+
55
+ Nothing ->
56
+ []
57
+
58
+
59
+ {-| -}
60
+ toNonEmpty : String -> ( String, List String )
61
+ toNonEmpty string =
62
+ case string |> String.split "/" of
63
+ [] ->
64
+ ( "ERROR", [] )
65
+
66
+ first :: rest ->
67
+ ( first, rest )
68
+
69
+
70
+ {-| -}
71
+ type alias Matcher route =
72
+ { pattern : String, toRoute : List (Maybe String) -> Maybe route }
73
+
74
+
75
+ {-| -}
76
+ tryMatch : { pattern : String, toRoute : List (Maybe String) -> Maybe route } -> String -> Maybe route
77
+ tryMatch { pattern, toRoute } path =
78
+ path
79
+ |> normalizePath
80
+ |> submatches pattern
81
+ |> toRoute
82
+
83
+
84
+ submatches : String -> String -> List (Maybe String)
85
+ submatches pattern path =
86
+ Regex.find
87
+ (Regex.fromString pattern
88
+ |> Maybe.withDefault Regex.never
89
+ )
90
+ path
91
+ |> List.concatMap .submatches
92
+
93
+
94
+ normalizePath : String -> String
95
+ normalizePath path =
96
+ path
97
+ |> ensureLeadingSlash
98
+ |> stripTrailingSlash
99
+
100
+
101
+ ensureLeadingSlash : String -> String
102
+ ensureLeadingSlash path =
103
+ if path |> String.startsWith "/" then
104
+ path
105
+
106
+ else
107
+ "/" ++ path
108
+
109
+
110
+ stripTrailingSlash : String -> String
111
+ stripTrailingSlash path =
112
+ if (path |> String.endsWith "/") && (String.length path > 1) then
113
+ String.dropRight 1 path
114
+
115
+ else
116
+ path
@@ -0,0 +1,54 @@
1
+ module Pages.Internal.StaticHttpBody exposing (Body(..), codec, encode)
2
+
3
+ import Codec exposing (Codec)
4
+ import Json.Encode as Encode
5
+
6
+
7
+ type Body
8
+ = EmptyBody
9
+ | StringBody String String
10
+ | JsonBody Encode.Value
11
+
12
+
13
+ encode : Body -> Encode.Value
14
+ encode body =
15
+ case body of
16
+ EmptyBody ->
17
+ encodeWithType "empty" []
18
+
19
+ StringBody _ content ->
20
+ encodeWithType "string"
21
+ [ ( "content", Encode.string content )
22
+ ]
23
+
24
+ JsonBody content ->
25
+ encodeWithType "json"
26
+ [ ( "content", content )
27
+ ]
28
+
29
+
30
+ encodeWithType : String -> List ( String, Encode.Value ) -> Encode.Value
31
+ encodeWithType typeName otherFields =
32
+ Encode.object <|
33
+ ( "type", Encode.string typeName )
34
+ :: otherFields
35
+
36
+
37
+ codec : Codec Body
38
+ codec =
39
+ Codec.custom
40
+ (\vEmpty vString vJson value ->
41
+ case value of
42
+ EmptyBody ->
43
+ vEmpty
44
+
45
+ StringBody a b ->
46
+ vString a b
47
+
48
+ JsonBody body ->
49
+ vJson body
50
+ )
51
+ |> Codec.variant0 "EmptyBody" EmptyBody
52
+ |> Codec.variant2 "StringBody" StringBody Codec.string Codec.string
53
+ |> Codec.variant1 "JsonBody" JsonBody Codec.value
54
+ |> Codec.buildCustom
@@ -0,0 +1,39 @@
1
+ module Pages.Internal.String exposing (chopEnd, chopForwardSlashes, chopStart)
2
+
3
+ {-| Remove a piece from the beginning of a string until it's not there anymore.
4
+
5
+ >>> chopStart "{" "{{{<-"
6
+ "<-"
7
+
8
+ -}
9
+
10
+
11
+ chopStart : String -> String -> String
12
+ chopStart needle string =
13
+ if String.startsWith needle string then
14
+ chopStart needle (String.dropLeft (String.length needle) string)
15
+
16
+ else
17
+ string
18
+
19
+
20
+ {-| Remove a piece from the end of a string until it's not there anymore.
21
+
22
+ >>> chopEnd "}" "->}}}"
23
+ "->"
24
+
25
+ -}
26
+ chopEnd : String -> String -> String
27
+ chopEnd needle string =
28
+ if String.endsWith needle string then
29
+ chopEnd needle (String.dropRight (String.length needle) string)
30
+
31
+ else
32
+ string
33
+
34
+
35
+ {-| Removes `/` characters from both ends of a string.
36
+ -}
37
+ chopForwardSlashes : String -> String
38
+ chopForwardSlashes =
39
+ chopStart "/" >> chopEnd "/"
@@ -0,0 +1,240 @@
1
+ module Pages.Manifest.Category exposing
2
+ ( toString, Category
3
+ , books, business, education, entertainment, finance, fitness, food, games, government, health, kids, lifestyle, magazines, medical, music, navigation, news, personalization, photo, politics, productivity, security, shopping, social, sports, travel, utilities, weather
4
+ , custom
5
+ )
6
+
7
+ {-| See <https://github.com/w3c/manifest/wiki/Categories> and
8
+ <https://developer.mozilla.org/en-US/docs/Web/Manifest/categories>
9
+
10
+ @docs toString, Category
11
+
12
+ @docs books, business, education, entertainment, finance, fitness, food, games, government, health, kids, lifestyle, magazines, medical, music, navigation, news, personalization, photo, politics, productivity, security, shopping, social, sports, travel, utilities, weather
13
+
14
+
15
+ ## Custom categories
16
+
17
+ @docs custom
18
+
19
+ -}
20
+
21
+
22
+ {-| Turn a category into its official String representation, as seen
23
+ here: <https://github.com/w3c/manifest/wiki/Categories>.
24
+ -}
25
+ toString : Category -> String
26
+ toString (Category raw) =
27
+ raw
28
+
29
+
30
+ {-| Represents a known, valid category, as specified by
31
+ <https://github.com/w3c/manifest/wiki/Categories>. If this document is updated
32
+ and I don't add it, please open an issue or pull request to let me know!
33
+ -}
34
+ type Category
35
+ = Category String
36
+
37
+
38
+ {-| It's best to use the pre-defined categories to ensure that clients (Android, iOS,
39
+ Chrome, Windows app store, etc.) are aware of it and can handle it appropriately.
40
+ But, if you're confident about using a custom one, you can do so with `Pages.Manifest.custom`.
41
+ -}
42
+ custom : String -> Category
43
+ custom name =
44
+ Category name
45
+
46
+
47
+ {-| Creates the described category.
48
+ -}
49
+ books : Category
50
+ books =
51
+ Category "books"
52
+
53
+
54
+ {-| Creates the described category.
55
+ -}
56
+ business : Category
57
+ business =
58
+ Category "business"
59
+
60
+
61
+ {-| Creates the described category.
62
+ -}
63
+ education : Category
64
+ education =
65
+ Category "education"
66
+
67
+
68
+ {-| Creates the described category.
69
+ -}
70
+ entertainment : Category
71
+ entertainment =
72
+ Category "entertainment"
73
+
74
+
75
+ {-| Creates the described category.
76
+ -}
77
+ finance : Category
78
+ finance =
79
+ Category "finance"
80
+
81
+
82
+ {-| Creates the described category.
83
+ -}
84
+ fitness : Category
85
+ fitness =
86
+ Category "fitness"
87
+
88
+
89
+ {-| Creates the described category.
90
+ -}
91
+ food : Category
92
+ food =
93
+ Category "food"
94
+
95
+
96
+ {-| Creates the described category.
97
+ -}
98
+ games : Category
99
+ games =
100
+ Category "games"
101
+
102
+
103
+ {-| Creates the described category.
104
+ -}
105
+ government : Category
106
+ government =
107
+ Category "government"
108
+
109
+
110
+ {-| Creates the described category.
111
+ -}
112
+ health : Category
113
+ health =
114
+ Category "health"
115
+
116
+
117
+ {-| Creates the described category.
118
+ -}
119
+ kids : Category
120
+ kids =
121
+ Category "kids"
122
+
123
+
124
+ {-| Creates the described category.
125
+ -}
126
+ lifestyle : Category
127
+ lifestyle =
128
+ Category "lifestyle"
129
+
130
+
131
+ {-| Creates the described category.
132
+ -}
133
+ magazines : Category
134
+ magazines =
135
+ Category "magazines"
136
+
137
+
138
+ {-| Creates the described category.
139
+ -}
140
+ medical : Category
141
+ medical =
142
+ Category "medical"
143
+
144
+
145
+ {-| Creates the described category.
146
+ -}
147
+ music : Category
148
+ music =
149
+ Category "music"
150
+
151
+
152
+ {-| Creates the described category.
153
+ -}
154
+ navigation : Category
155
+ navigation =
156
+ Category "navigation"
157
+
158
+
159
+ {-| Creates the described category.
160
+ -}
161
+ news : Category
162
+ news =
163
+ Category "news"
164
+
165
+
166
+ {-| Creates the described category.
167
+ -}
168
+ personalization : Category
169
+ personalization =
170
+ Category "personalization"
171
+
172
+
173
+ {-| Creates the described category.
174
+ -}
175
+ photo : Category
176
+ photo =
177
+ Category "photo"
178
+
179
+
180
+ {-| Creates the described category.
181
+ -}
182
+ politics : Category
183
+ politics =
184
+ Category "politics"
185
+
186
+
187
+ {-| Creates the described category.
188
+ -}
189
+ productivity : Category
190
+ productivity =
191
+ Category "productivity"
192
+
193
+
194
+ {-| Creates the described category.
195
+ -}
196
+ security : Category
197
+ security =
198
+ Category "security"
199
+
200
+
201
+ {-| Creates the described category.
202
+ -}
203
+ shopping : Category
204
+ shopping =
205
+ Category "shopping"
206
+
207
+
208
+ {-| Creates the described category.
209
+ -}
210
+ social : Category
211
+ social =
212
+ Category "social"
213
+
214
+
215
+ {-| Creates the described category.
216
+ -}
217
+ sports : Category
218
+ sports =
219
+ Category "sports"
220
+
221
+
222
+ {-| Creates the described category.
223
+ -}
224
+ travel : Category
225
+ travel =
226
+ Category "travel"
227
+
228
+
229
+ {-| Creates the described category.
230
+ -}
231
+ utilities : Category
232
+ utilities =
233
+ Category "utilities"
234
+
235
+
236
+ {-| Creates the described category.
237
+ -}
238
+ weather : Category
239
+ weather =
240
+ Category "weather"