elm-pages 3.0.0-beta.10 → 3.0.0-beta.12

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 (78) 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.elmo +0 -0
  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/elm-stuff/0.19.1/i.dat +0 -0
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  6. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
  7. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1326 -121
  8. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +15156 -13244
  9. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  10. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  11. package/generator/dead-code-review/elm.json +6 -5
  12. package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +1 -0
  13. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  14. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
  15. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  16. package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
  17. package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1326 -121
  18. package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +14574 -12631
  19. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  20. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  21. package/generator/review/elm.json +6 -6
  22. package/generator/src/build.js +6 -9
  23. package/generator/src/cli.js +120 -42
  24. package/generator/src/codegen.js +11 -10
  25. package/generator/src/compatibility-key.js +1 -1
  26. package/generator/src/elm-codegen.js +3 -0
  27. package/generator/src/render-worker.js +1 -1
  28. package/generator/src/render.js +222 -37
  29. package/generator/src/request-cache.js +1 -0
  30. package/generator/src/rewrite-elm-json.js +3 -3
  31. package/package.json +12 -12
  32. package/src/ApiRoute.elm +147 -9
  33. package/src/DataSource/Env.elm +27 -3
  34. package/src/DataSource.elm +11 -22
  35. package/src/Form.elm +32 -32
  36. package/src/Head.elm +112 -8
  37. package/src/MultiDict.elm +49 -0
  38. package/src/Pages/Generate.elm +4 -1
  39. package/src/Pages/GeneratorProgramConfig.elm +15 -0
  40. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  41. package/src/Pages/Internal/Platform/GeneratorApplication.elm +455 -0
  42. package/src/Pages/Manifest.elm +24 -0
  43. package/src/Pages/Script.elm +100 -0
  44. package/src/PairingHeap.elm +137 -0
  45. package/src/Parser/Extra/String.elm +33 -0
  46. package/src/Parser/Extra.elm +69 -0
  47. package/src/ProgramTest/ComplexQuery.elm +360 -0
  48. package/src/ProgramTest/EffectSimulation.elm +122 -0
  49. package/src/ProgramTest/Failure.elm +367 -0
  50. package/src/ProgramTest/HtmlHighlighter.elm +116 -0
  51. package/src/ProgramTest/HtmlParserHacks.elm +58 -0
  52. package/src/ProgramTest/HtmlRenderer.elm +73 -0
  53. package/src/ProgramTest/Program.elm +30 -0
  54. package/src/ProgramTest/StringLines.elm +26 -0
  55. package/src/ProgramTest/TestHtmlHacks.elm +132 -0
  56. package/src/ProgramTest/TestHtmlParser.elm +201 -0
  57. package/src/ProgramTest.elm +2339 -0
  58. package/src/Query/Extra.elm +55 -0
  59. package/src/Result/Extra.elm +21 -0
  60. package/src/Server/Request.elm +2 -2
  61. package/src/SimulatedEffect/Cmd.elm +69 -0
  62. package/src/SimulatedEffect/Http.elm +330 -0
  63. package/src/SimulatedEffect/Navigation.elm +69 -0
  64. package/src/SimulatedEffect/Ports.elm +62 -0
  65. package/src/SimulatedEffect/Process.elm +24 -0
  66. package/src/SimulatedEffect/Sub.elm +48 -0
  67. package/src/SimulatedEffect/Task.elm +252 -0
  68. package/src/SimulatedEffect/Time.elm +25 -0
  69. package/src/SimulatedEffect.elm +42 -0
  70. package/src/String/Extra.elm +6 -0
  71. package/src/Test/Http.elm +145 -0
  72. package/src/TestResult.elm +35 -0
  73. package/src/TestState.elm +305 -0
  74. package/src/Url/Extra.elm +100 -0
  75. package/src/Vendored/Diff.elm +321 -0
  76. package/src/Vendored/Failure.elm +217 -0
  77. package/src/Vendored/FormatMonochrome.elm +44 -0
  78. package/src/Vendored/Highlightable.elm +53 -0
@@ -2,6 +2,7 @@ module Pages.Manifest exposing
2
2
  ( Config, Icon
3
3
  , init
4
4
  , withBackgroundColor, withCategories, withDisplayMode, withIarcRatingId, withLang, withOrientation, withShortName, withThemeColor
5
+ , withField
5
6
  , DisplayMode(..), Orientation(..), IconPurpose(..)
6
7
  , generator
7
8
  , toJson
@@ -41,6 +42,11 @@ You pass your `Pages.Manifest.Config` record into the `Pages.application` functi
41
42
  @docs withBackgroundColor, withCategories, withDisplayMode, withIarcRatingId, withLang, withOrientation, withShortName, withThemeColor
42
43
 
43
44
 
45
+ ## Arbitrary Fields Escape Hatch
46
+
47
+ @docs withField
48
+
49
+
44
50
  ## Config options
45
51
 
46
52
  @docs DisplayMode, Orientation, IconPurpose
@@ -61,6 +67,7 @@ import ApiRoute
61
67
  import Color exposing (Color)
62
68
  import Color.Convert
63
69
  import DataSource exposing (DataSource)
70
+ import Dict exposing (Dict)
64
71
  import Head
65
72
  import Json.Encode as Encode
66
73
  import LanguageTag exposing (LanguageTag, emptySubtags)
@@ -123,6 +130,7 @@ init options =
123
130
  , shortName = Nothing
124
131
  , icons = options.icons
125
132
  , lang = usEnglish
133
+ , otherFields = Dict.empty
126
134
  }
127
135
 
128
136
 
@@ -191,6 +199,17 @@ withLang languageTag config =
191
199
  { config | lang = languageTag }
192
200
 
193
201
 
202
+ {-| Escape hatch for specifying fields that aren't exposed through this module otherwise. The possible supported properties
203
+ in a manifest file can change over time, so see [MDN manifest.json docs](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json)
204
+ for a full listing of the current supported properties.
205
+ -}
206
+ withField : String -> Encode.Value -> Config -> Config
207
+ withField name value config =
208
+ { config
209
+ | otherFields = config.otherFields |> Dict.insert name value
210
+ }
211
+
212
+
194
213
  orientationToString : Orientation -> String
195
214
  orientationToString orientation =
196
215
  case orientation of
@@ -239,6 +258,7 @@ type alias Config =
239
258
  , shortName : Maybe String
240
259
  , icons : List Icon
241
260
  , lang : LanguageTag
261
+ , otherFields : Dict String Encode.Value
242
262
  }
243
263
 
244
264
 
@@ -420,6 +440,10 @@ toJson canonicalSiteUrl config =
420
440
  , Encode.string "/" |> Just
421
441
  )
422
442
  ]
443
+ ++ (config.otherFields
444
+ |> Dict.toList
445
+ |> List.map (Tuple.mapSecond Just)
446
+ )
423
447
  |> encodeMaybeObject
424
448
 
425
449
 
@@ -0,0 +1,100 @@
1
+ module Pages.Script exposing
2
+ ( Script(..)
3
+ , withCliOptions, withoutCliOptions
4
+ , writeFile
5
+ , log
6
+ )
7
+
8
+ {-|
9
+
10
+ @docs Script
11
+
12
+ @docs withCliOptions, withoutCliOptions
13
+
14
+
15
+ ## File System Utilities
16
+
17
+ @docs writeFile
18
+
19
+
20
+ ## Utilities
21
+
22
+ @docs log
23
+
24
+ -}
25
+
26
+ import Cli.OptionsParser as OptionsParser
27
+ import Cli.Program as Program
28
+ import DataSource exposing (DataSource)
29
+ import DataSource.Http
30
+ import DataSource.Internal.Request
31
+ import Html exposing (Html)
32
+ import Json.Decode as Decode
33
+ import Json.Encode as Encode
34
+
35
+
36
+ {-| -}
37
+ type Script
38
+ = Generator
39
+ ((Maybe { indent : Int, newLines : Bool }
40
+ -> Html Never
41
+ -> String
42
+ )
43
+ -> Program.Config (DataSource ())
44
+ )
45
+
46
+
47
+ {-| -}
48
+ writeFile : { path : String, body : String } -> DataSource ()
49
+ writeFile { path, body } =
50
+ DataSource.Internal.Request.request
51
+ { name = "write-file"
52
+ , body =
53
+ DataSource.Http.jsonBody
54
+ (Encode.object
55
+ [ ( "path", Encode.string path )
56
+ , ( "body", Encode.string body )
57
+ ]
58
+ )
59
+ , expect = DataSource.Http.expectJson (Decode.succeed ())
60
+ }
61
+
62
+
63
+ {-| -}
64
+ log : String -> DataSource ()
65
+ log message =
66
+ DataSource.Internal.Request.request
67
+ { name = "log"
68
+ , body =
69
+ DataSource.Http.jsonBody
70
+ (Encode.object
71
+ [ ( "message", Encode.string message )
72
+ ]
73
+ )
74
+ , expect = DataSource.Http.expectJson (Decode.succeed ())
75
+ }
76
+
77
+
78
+ {-| -}
79
+ withoutCliOptions : DataSource () -> Script
80
+ withoutCliOptions execute =
81
+ Generator
82
+ (\_ ->
83
+ Program.config
84
+ |> Program.add
85
+ (OptionsParser.build ())
86
+ |> Program.mapConfig
87
+ (\() ->
88
+ execute
89
+ )
90
+ )
91
+
92
+
93
+ {-| -}
94
+ withCliOptions : Program.Config cliOptions -> (cliOptions -> DataSource ()) -> Script
95
+ withCliOptions config execute =
96
+ Generator
97
+ (\_ ->
98
+ config
99
+ |> Program.mapConfig execute
100
+ )
@@ -0,0 +1,137 @@
1
+ module PairingHeap exposing
2
+ ( PairingHeap, empty
3
+ , insert, merge, findMin, deleteMin
4
+ , fromList, toSortedList
5
+ )
6
+
7
+ {-| This is a simple pairing heap implementation written in Elm usable as a priority queue. This code is
8
+ based heavily on the pseudocode available at [the Wikipedia page](https://en.wikipedia.org/wiki/Pairing_heap).
9
+
10
+
11
+ # Type and Constructor
12
+
13
+ @docs PairingHeap, empty
14
+
15
+
16
+ # Operations
17
+
18
+ @docs insert, merge, findMin, deleteMin
19
+
20
+
21
+ # Convenience functions
22
+
23
+ @docs fromList, toSortedList
24
+
25
+ -}
26
+
27
+
28
+ {-| A `PairingHeap` has comparable keys and values of an arbitrary type.
29
+ -}
30
+ type PairingHeap comparable a
31
+ = Empty
32
+ | Heap comparable a (List (PairingHeap comparable a))
33
+
34
+
35
+ {-| Create an empty PairingHeap.
36
+ -}
37
+ empty : PairingHeap comparable a
38
+ empty =
39
+ Empty
40
+
41
+
42
+ {-| Find the minimum value in a heap returning Nothing if the heap is empty.
43
+ Complexity: O(1)
44
+
45
+ findMin (fromList [ ( 10, () ), ( 3, () ), ( 8, () ) ]) == Just 3
46
+
47
+ -}
48
+ findMin : PairingHeap comparable a -> Maybe ( comparable, a )
49
+ findMin x =
50
+ case x of
51
+ Empty ->
52
+ Nothing
53
+
54
+ Heap k v _ ->
55
+ Just ( k, v )
56
+
57
+
58
+ {-| Merges two `PairingHeap`s together into one new heap containing all of the key-value pairs from both inputs.
59
+ Complexity: O(1)
60
+ -}
61
+ merge : PairingHeap comparable a -> PairingHeap comparable a -> PairingHeap comparable a
62
+ merge heap1 heap2 =
63
+ case ( heap1, heap2 ) of
64
+ ( Empty, _ ) ->
65
+ heap2
66
+
67
+ ( _, Empty ) ->
68
+ heap1
69
+
70
+ ( Heap k1 v1 hs1, Heap k2 v2 hs2 ) ->
71
+ if k1 < k2 then
72
+ Heap k1 v1 (heap2 :: hs1)
73
+
74
+ else
75
+ Heap k2 v2 (heap1 :: hs2)
76
+
77
+
78
+ {-| Inserts a new element into a `PairingHeap`.
79
+ Complexity: O(1)
80
+ -}
81
+ insert : comparable -> a -> PairingHeap comparable a -> PairingHeap comparable a
82
+ insert k v heap =
83
+ merge (Heap k v []) heap
84
+
85
+
86
+ {-| Removes the minimum element from a `PairingHeap` returning a new heap without that element.
87
+ This will return an empty heap if given an empty heap as input.
88
+ Complexity: O(log n)
89
+ -}
90
+ deleteMin : PairingHeap comparable a -> PairingHeap comparable a
91
+ deleteMin heap =
92
+ case heap of
93
+ Empty ->
94
+ Empty
95
+
96
+ Heap k v heaps ->
97
+ mergePairs heaps
98
+
99
+
100
+ {-| This is an internal function used by deleteMin.
101
+ -}
102
+ mergePairs : List (PairingHeap comparable a) -> PairingHeap comparable a
103
+ mergePairs heaps =
104
+ case heaps of
105
+ [] ->
106
+ Empty
107
+
108
+ x :: [] ->
109
+ x
110
+
111
+ x :: (y :: xs) ->
112
+ merge (merge x y) (mergePairs xs)
113
+
114
+
115
+
116
+ -- Extra convenience functions
117
+
118
+
119
+ {-| This function turns a list of key-value pairs into a `PairingHeap`.
120
+ Complexity: O(n)
121
+ -}
122
+ fromList : List ( comparable, a ) -> PairingHeap comparable a
123
+ fromList =
124
+ List.foldl (\( k, v ) -> insert k v) empty
125
+
126
+
127
+ {-| This function turns a `PairingHeap` into a sorted list of key-value pairs.
128
+ Complexity: O(n log n)
129
+ -}
130
+ toSortedList : PairingHeap comparable a -> List ( comparable, a )
131
+ toSortedList heap =
132
+ case heap of
133
+ Empty ->
134
+ []
135
+
136
+ Heap k v _ ->
137
+ ( k, v ) :: toSortedList (deleteMin heap)
@@ -0,0 +1,33 @@
1
+ module Parser.Extra.String exposing (string)
2
+
3
+ import Parser exposing (..)
4
+
5
+
6
+ string : Parser String
7
+ string =
8
+ succeed identity
9
+ |. token "\""
10
+ |= loop [] stringHelp
11
+
12
+
13
+ stringHelp : List String -> Parser (Step (List String) String)
14
+ stringHelp revChunks =
15
+ oneOf
16
+ [ succeed (\chunk -> Loop (chunk :: revChunks))
17
+ |. token "\\"
18
+ |= oneOf
19
+ [ map (\_ -> "\n") (token "n")
20
+ , map (\_ -> "\t") (token "t")
21
+ , map (\_ -> "\u{000D}") (token "r")
22
+ ]
23
+ , token "\""
24
+ |> map (\_ -> Done (String.join "" (List.reverse revChunks)))
25
+ , chompWhile isUninteresting
26
+ |> getChompedString
27
+ |> map (\chunk -> Loop (chunk :: revChunks))
28
+ ]
29
+
30
+
31
+ isUninteresting : Char -> Bool
32
+ isUninteresting char =
33
+ char /= '\\' && char /= '"'
@@ -0,0 +1,69 @@
1
+ module Parser.Extra exposing (deadEndsToString)
2
+
3
+ {-| [No implementation for deadEndsToString · Issue #9 · elm/parser](https://github.com/elm/parser/issues/9)
4
+ -}
5
+
6
+ import Parser exposing (DeadEnd, Problem(..))
7
+
8
+
9
+ deadEndsToString : List DeadEnd -> String
10
+ deadEndsToString deadEnds =
11
+ String.join "\n" (List.map deadEndToString deadEnds)
12
+
13
+
14
+ deadEndToString : DeadEnd -> String
15
+ deadEndToString deadEnd =
16
+ problemToString deadEnd.problem
17
+ ++ " at "
18
+ ++ deadEndToRowColString deadEnd
19
+
20
+
21
+ problemToString : Problem -> String
22
+ problemToString prob =
23
+ case prob of
24
+ Expecting s ->
25
+ "Expecting " ++ s
26
+
27
+ ExpectingInt ->
28
+ "Expecting Int"
29
+
30
+ ExpectingHex ->
31
+ "Expecting Hex"
32
+
33
+ ExpectingOctal ->
34
+ "Expecting Octal"
35
+
36
+ ExpectingBinary ->
37
+ "Expecting Binary"
38
+
39
+ ExpectingFloat ->
40
+ "Expecting Float"
41
+
42
+ ExpectingNumber ->
43
+ "Expecting Number"
44
+
45
+ ExpectingVariable ->
46
+ "Expecting Variable"
47
+
48
+ ExpectingSymbol s ->
49
+ "Expecting Symbol " ++ s
50
+
51
+ ExpectingKeyword s ->
52
+ "Expecting Keyword " ++ s
53
+
54
+ ExpectingEnd ->
55
+ "Expecting End"
56
+
57
+ UnexpectedChar ->
58
+ "Unexpected Char"
59
+
60
+ Problem s ->
61
+ "Problem: " ++ s
62
+
63
+ BadRepeat ->
64
+ "Bad Repeat"
65
+
66
+
67
+ deadEndToRowColString : DeadEnd -> String
68
+ deadEndToRowColString deadEnd =
69
+ "row " ++ String.fromInt deadEnd.row ++ ", " ++ "col " ++ String.fromInt deadEnd.col