elm-pages 2.1.7 → 2.1.11

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 +77 -4
  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.json +13 -5
  17. package/generator/template/package.json +3 -2
  18. package/package.json +14 -8
  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,197 @@
1
+ module Test.Html.Internal.ElmHtml.ToString exposing
2
+ ( nodeRecordToString, nodeToString, nodeToStringWithOptions
3
+ , FormatOptions, defaultFormatOptions
4
+ )
5
+
6
+ {-| Convert ElmHtml to string.
7
+
8
+ @docs nodeRecordToString, nodeToString, nodeToStringWithOptions
9
+
10
+ @docs FormatOptions, defaultFormatOptions
11
+
12
+ -}
13
+
14
+ import Dict exposing (Dict)
15
+ import String
16
+ import Test.Html.Internal.ElmHtml.InternalTypes exposing (..)
17
+
18
+
19
+ {-| Formatting options to be used for converting to string
20
+ -}
21
+ type alias FormatOptions =
22
+ { indent : Int
23
+ , newLines : Bool
24
+ }
25
+
26
+
27
+ {-| default formatting options
28
+ -}
29
+ defaultFormatOptions : FormatOptions
30
+ defaultFormatOptions =
31
+ { indent = 0
32
+ , newLines = False
33
+ }
34
+
35
+
36
+ nodeToLines : ElementKind -> FormatOptions -> ElmHtml msg -> List String
37
+ nodeToLines kind options nodeType =
38
+ case nodeType of
39
+ TextTag { text } ->
40
+ [ escapeRawText kind text ]
41
+
42
+ NodeEntry record ->
43
+ nodeRecordToString options record
44
+
45
+ CustomNode record ->
46
+ []
47
+
48
+ MarkdownNode record ->
49
+ [ record.model.markdown ]
50
+
51
+ NoOp ->
52
+ []
53
+
54
+
55
+ {-| Convert a given html node to a string based on the type
56
+ -}
57
+ nodeToString : ElmHtml msg -> String
58
+ nodeToString =
59
+ nodeToStringWithOptions defaultFormatOptions
60
+
61
+
62
+ {-| same as nodeToString, but with options
63
+ -}
64
+ nodeToStringWithOptions : FormatOptions -> ElmHtml msg -> String
65
+ nodeToStringWithOptions options =
66
+ nodeToLines RawTextElements options
67
+ >> String.join
68
+ (if options.newLines then
69
+ "\n"
70
+
71
+ else
72
+ ""
73
+ )
74
+
75
+
76
+ {-| Convert a node record to a string. This basically takes the tag name, then
77
+ pulls all the facts into tag declaration, then goes through the children and
78
+ nests them under this one
79
+ -}
80
+ nodeRecordToString : FormatOptions -> NodeRecord msg -> List String
81
+ nodeRecordToString options { tag, children, facts } =
82
+ let
83
+ openTag : List (Maybe String) -> String
84
+ openTag extras =
85
+ let
86
+ trimmedExtras =
87
+ List.filterMap (\x -> x) extras
88
+ |> List.map String.trim
89
+ |> List.filter ((/=) "")
90
+
91
+ filling =
92
+ case trimmedExtras of
93
+ [] ->
94
+ ""
95
+
96
+ more ->
97
+ " " ++ String.join " " more
98
+ in
99
+ "<" ++ tag ++ filling ++ ">"
100
+
101
+ closeTag =
102
+ "</" ++ tag ++ ">"
103
+
104
+ childrenStrings =
105
+ List.map (nodeToLines (toElementKind tag) options) children
106
+ |> List.concat
107
+ |> List.map ((++) (String.repeat options.indent " "))
108
+
109
+ styles =
110
+ case Dict.toList facts.styles of
111
+ [] ->
112
+ Nothing
113
+
114
+ styleValues ->
115
+ styleValues
116
+ |> List.map (\( key, value ) -> key ++ ":" ++ value ++ ";")
117
+ |> String.join ""
118
+ |> (\styleString -> "style=\"" ++ styleString ++ "\"")
119
+ |> Just
120
+
121
+ classes =
122
+ Dict.get "className" facts.stringAttributes
123
+ |> Maybe.map (\name -> "class=\"" ++ name ++ "\"")
124
+
125
+ stringAttributes =
126
+ Dict.filter (\k v -> k /= "className") facts.stringAttributes
127
+ |> Dict.toList
128
+ |> List.map (Tuple.mapFirst propertyToAttributeName)
129
+ |> List.map (\( k, v ) -> k ++ "=\"" ++ v ++ "\"")
130
+ |> String.join " "
131
+ |> Just
132
+
133
+ boolToString b =
134
+ case b of
135
+ True ->
136
+ "True"
137
+
138
+ False ->
139
+ "False"
140
+
141
+ boolAttributes =
142
+ Dict.toList facts.boolAttributes
143
+ |> List.map (\( k, v ) -> k ++ "=" ++ (String.toLower <| boolToString v))
144
+ |> String.join " "
145
+ |> Just
146
+ in
147
+ case toElementKind tag of
148
+ {- Void elements only have a start tag; end tags must not be
149
+ specified for void elements.
150
+ -}
151
+ VoidElements ->
152
+ [ openTag [ classes, styles, stringAttributes, boolAttributes ] ]
153
+
154
+ _ ->
155
+ [ openTag [ classes, styles, stringAttributes, boolAttributes ] ]
156
+ ++ childrenStrings
157
+ ++ [ closeTag ]
158
+
159
+
160
+ {-| <https://github.com/elm/virtual-dom/blob/5a5bcf48720bc7d53461b3cd42a9f19f119c5503/src/Elm/Kernel/VirtualDom.server.js#L196-L201>
161
+ -}
162
+ propertyToAttributeName : String.String -> String.String
163
+ propertyToAttributeName propertyName =
164
+ case propertyName of
165
+ "className" ->
166
+ "class"
167
+
168
+ "htmlFor" ->
169
+ "for"
170
+
171
+ "httpEquiv" ->
172
+ "http-equiv"
173
+
174
+ "acceptCharset" ->
175
+ "accept-charset"
176
+
177
+ _ ->
178
+ propertyName
179
+
180
+
181
+ escapeRawText : ElementKind -> String.String -> String.String
182
+ escapeRawText kind rawText =
183
+ case kind of
184
+ VoidElements ->
185
+ rawText
186
+
187
+ RawTextElements ->
188
+ rawText
189
+
190
+ _ ->
191
+ {- https://github.com/elm/virtual-dom/blob/5a5bcf48720bc7d53461b3cd42a9f19f119c5503/src/Elm/Kernel/VirtualDom.server.js#L8-L26 -}
192
+ rawText
193
+ |> String.replace "&" "&amp;"
194
+ |> String.replace "<" "&lt;"
195
+ |> String.replace ">" "&gt;"
196
+ |> String.replace "\"" "&quot;"
197
+ |> String.replace "'" "&#039;"
@@ -0,0 +1,34 @@
1
+ module Test.Internal.KernelConstants exposing (kernelConstants)
2
+
3
+ {-| This module defines the mapping of optimized field name and enum values
4
+ for kernel code in other packages the we depend on.
5
+ -}
6
+
7
+
8
+ {-| NOTE: this is duplicating constants also defined in src/Elm/Kernel/HtmlAsJson.js
9
+ so if you make any changes here, be sure to synchronize them there!
10
+ -}
11
+ kernelConstants =
12
+ { virtualDom =
13
+ { nodeType = "$"
14
+ , nodeTypeText = 0
15
+ , nodeTypeKeyedNode = 2
16
+ , nodeTypeNode = 1
17
+ , nodeTypeCustom = 3
18
+ , nodeTypeTagger = 4
19
+ , nodeTypeThunk = 5
20
+ , tag = "c"
21
+ , kids = "e"
22
+ , facts = "d"
23
+ , descendantsCount = "b"
24
+ , text = "a"
25
+ , refs = "l"
26
+ , node = "k"
27
+ , tagger = "j"
28
+ , model = "g"
29
+ }
30
+ , markdown =
31
+ { options = "a"
32
+ , markdown = "b"
33
+ }
34
+ }