elm-pages 3.0.8 → 3.0.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 (52) hide show
  1. package/README.md +4 -4
  2. package/codegen/elm-pages-codegen.cjs +732 -350
  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.elmo +0 -0
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  6. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
  7. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  8. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
  9. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +2 -2
  10. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +7328 -7699
  11. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  12. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +2 -2
  13. package/generator/dead-code-review/elm.json +2 -2
  14. package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +1 -1
  15. package/generator/dead-code-review/src/ReviewConfig.elm +3 -1
  16. package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +63 -0
  17. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  18. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
  19. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  20. package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
  21. package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +2 -2
  22. package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +2768 -3160
  23. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  24. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +2 -2
  25. package/generator/review/elm.json +7 -8
  26. package/generator/src/build.js +3 -4
  27. package/generator/src/cli.js +1 -1
  28. package/generator/src/codegen.js +1 -1
  29. package/generator/src/compatibility-key.js +2 -2
  30. package/generator/src/render.js +1 -6
  31. package/generator/static-code/elm-pages.js +12 -9
  32. package/generator/template/app/ErrorPage.elm +15 -12
  33. package/generator/template/codegen/elm.codegen.json +2 -2
  34. package/generator/template/elm-tooling.json +1 -1
  35. package/generator/template/gitignore +2 -1
  36. package/generator/template/netlify.toml +1 -1
  37. package/generator/template/package.json +6 -5
  38. package/generator/template/script/elm.json +3 -3
  39. package/generator/template/script/src/AddStaticRoute.elm +87 -0
  40. package/package.json +25 -24
  41. package/src/ApiRoute.elm +47 -35
  42. package/src/BackendTask/Custom.elm +12 -15
  43. package/src/BackendTask/File.elm +4 -1
  44. package/src/BackendTask/Glob.elm +34 -31
  45. package/src/BackendTask.elm +57 -44
  46. package/src/FatalError.elm +2 -2
  47. package/src/Head/Seo.elm +3 -3
  48. package/src/List/Chunks.elm +51 -0
  49. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  50. package/src/Pages/Manifest.elm +2 -2
  51. package/src/Scaffold/Route.elm +95 -49
  52. package/src/Server/Session.elm +9 -6
@@ -28,7 +28,7 @@ With the `BackendTask.Glob` API, you could get all of those files like so:
28
28
 
29
29
  import BackendTask exposing (BackendTask)
30
30
 
31
- blogPostsGlob : BackendTask (List String)
31
+ blogPostsGlob : BackendTask error (List String)
32
32
  blogPostsGlob =
33
33
  Glob.succeed (\slug -> slug)
34
34
  |> Glob.match (Glob.literal "content/blog/")
@@ -69,7 +69,7 @@ There will be one argument for every `capture` in your pipeline, whereas `match`
69
69
  import BackendTask exposing (BackendTask)
70
70
  import BackendTask.Glob as Glob
71
71
 
72
- blogPostsGlob : BackendTask (List String)
72
+ blogPostsGlob : BackendTask error (List String)
73
73
  blogPostsGlob =
74
74
  Glob.succeed (\slug -> slug)
75
75
  -- no argument from this, but we will only
@@ -97,7 +97,7 @@ Let's try our blogPostsGlob from before, but change every `match` to `capture`.
97
97
  import BackendTask exposing (BackendTask)
98
98
 
99
99
  blogPostsGlob :
100
- BackendTask
100
+ BackendTask error
101
101
  (List
102
102
  { filePath : String
103
103
  , slug : String
@@ -155,20 +155,22 @@ This is my first post!
155
155
  Then we could read that title for our blog post list page using our `blogPosts` `BackendTask` that we defined above.
156
156
 
157
157
  import BackendTask.File
158
+ import FatalError exposing (FatalError)
158
159
  import Json.Decode as Decode exposing (Decoder)
159
160
 
160
- titles : BackendTask (List BlogPost)
161
+ titles : BackendTask FatalError (List BlogPost)
161
162
  titles =
162
163
  blogPosts
163
164
  |> BackendTask.map
164
165
  (List.map
165
166
  (\blogPost ->
166
- BackendTask.File.request
167
+ BackendTask.File.onlyFrontmatter
168
+ blogFrontmatterDecoder
167
169
  blogPost.filePath
168
- (BackendTask.File.frontmatter blogFrontmatterDecoder)
169
170
  )
170
171
  )
171
172
  |> BackendTask.resolve
173
+ |> BackendTask.allowFatal
172
174
 
173
175
  type alias BlogPost =
174
176
  { title : String }
@@ -249,7 +251,7 @@ could use
249
251
  import BackendTask exposing (BackendTask)
250
252
  import BackendTask.Glob as Glob
251
253
 
252
- blogPostsGlob : BackendTask (List String)
254
+ blogPostsGlob : BackendTask error (List String)
253
255
  blogPostsGlob =
254
256
  Glob.succeed (\slug -> slug)
255
257
  |> Glob.match (Glob.literal "content/blog/")
@@ -258,14 +260,14 @@ could use
258
260
  |> Glob.toBackendTask
259
261
 
260
262
  If you want to validate file formats, you can combine that with some `BackendTask` helpers to turn a `Glob (Result String value)` into
261
- a `BackendTask (List value)`.
263
+ a `BackendTask FatalError (List value)`.
262
264
 
263
265
  For example, you could take a date and parse it.
264
266
 
265
267
  import BackendTask exposing (BackendTask)
266
268
  import BackendTask.Glob as Glob
267
269
 
268
- example : BackendTask (List ( String, String ))
270
+ example : BackendTask FatalError (List ( String, String ))
269
271
  example =
270
272
  Glob.succeed
271
273
  (\dateResult slug ->
@@ -281,14 +283,14 @@ For example, you could take a date and parse it.
281
283
  |> BackendTask.map (List.map BackendTask.fromResult)
282
284
  |> BackendTask.resolve
283
285
 
284
- expectDateFormat : List String -> Result String String
286
+ expectDateFormat : List String -> Result FatalError String
285
287
  expectDateFormat dateParts =
286
288
  case dateParts of
287
289
  [ year, month, date ] ->
288
290
  Ok (String.join "-" [ year, month, date ])
289
291
 
290
292
  _ ->
291
- Err "Unexpected date format, expected yyyy/mm/dd folder structure."
293
+ Err <| FatalError.fromString "Unexpected date format, expected yyyy/mm/dd folder structure."
292
294
 
293
295
  -}
294
296
  map : (a -> b) -> Glob a -> Glob b
@@ -322,7 +324,7 @@ fullFilePath =
322
324
  import BackendTask.Glob as Glob
323
325
 
324
326
  blogPosts :
325
- BackendTask
327
+ BackendTask error
326
328
  (List
327
329
  { filePath : String
328
330
  , slug : String
@@ -368,11 +370,11 @@ match 0 or more path parts like, see `recursiveWildcard`.
368
370
  , slug : String
369
371
  }
370
372
 
371
- example : BackendTask (List BlogPost)
373
+ example : BackendTask error (List BlogPost)
372
374
  example =
373
375
  Glob.succeed BlogPost
374
376
  |> Glob.match (Glob.literal "blog/")
375
- |> Glob.match Glob.wildcard
377
+ |> Glob.capture Glob.wildcard
376
378
  |> Glob.match (Glob.literal "-")
377
379
  |> Glob.capture Glob.wildcard
378
380
  |> Glob.match (Glob.literal "-")
@@ -391,7 +393,7 @@ match 0 or more path parts like, see `recursiveWildcard`.
391
393
 
392
394
  That will match to:
393
395
 
394
- results : BackendTask (List BlogPost)
396
+ results : BackendTask error (List BlogPost)
395
397
  results =
396
398
  BackendTask.succeed
397
399
  [ { year = "2021"
@@ -443,7 +445,7 @@ Leading 0's are ignored.
443
445
  import BackendTask exposing (BackendTask)
444
446
  import BackendTask.Glob as Glob
445
447
 
446
- slides : BackendTask (List Int)
448
+ slides : BackendTask error (List Int)
447
449
  slides =
448
450
  Glob.succeed identity
449
451
  |> Glob.match (Glob.literal "slide-")
@@ -472,7 +474,7 @@ With files
472
474
 
473
475
  Yields
474
476
 
475
- matches : BackendTask (List Int)
477
+ matches : BackendTask error (List Int)
476
478
  matches =
477
479
  BackendTask.succeed
478
480
  [ 1
@@ -513,7 +515,7 @@ This is the elm-pages equivalent of `**/*.txt` in standard shell syntax:
513
515
  import BackendTask exposing (BackendTask)
514
516
  import BackendTask.Glob as Glob
515
517
 
516
- example : BackendTask (List ( List String, String ))
518
+ example : BackendTask error (List ( List String, String ))
517
519
  example =
518
520
  Glob.succeed Tuple.pair
519
521
  |> Glob.match (Glob.literal "articles/")
@@ -537,7 +539,7 @@ With these files:
537
539
 
538
540
  We would get the following matches:
539
541
 
540
- matches : BackendTask (List ( List String, String ))
542
+ matches : BackendTask error (List ( List String, String ))
541
543
  matches =
542
544
  BackendTask.succeed
543
545
  [ ( [ "archive", "1977", "06", "10" ], "apple-2-announced" )
@@ -552,14 +554,14 @@ And also note that it matches 0 path parts into an empty list.
552
554
  If we didn't include the `wildcard` after the `recursiveWildcard`, then we would only get
553
555
  a single level of matches because it is followed by a file extension.
554
556
 
555
- example : BackendTask (List String)
557
+ example : BackendTask error (List String)
556
558
  example =
557
559
  Glob.succeed identity
558
560
  |> Glob.match (Glob.literal "articles/")
559
561
  |> Glob.capture Glob.recursiveWildcard
560
562
  |> Glob.match (Glob.literal ".txt")
561
563
 
562
- matches : BackendTask (List String)
564
+ matches : BackendTask error (List String)
563
565
  matches =
564
566
  BackendTask.succeed
565
567
  [ "google-io-2021-recap"
@@ -677,7 +679,7 @@ Exactly the same as `match` except it also captures the matched sub-pattern.
677
679
  , slug : String
678
680
  }
679
681
 
680
- archives : BackendTask ArchivesArticle
682
+ archives : BackendTask error ArchivesArticle
681
683
  archives =
682
684
  Glob.succeed ArchivesArticle
683
685
  |> Glob.match (Glob.literal "archive/")
@@ -693,7 +695,7 @@ Exactly the same as `match` except it also captures the matched sub-pattern.
693
695
 
694
696
  The file `archive/1977/06/10/apple-2-released.md` will give us this match:
695
697
 
696
- matches : List ArchivesArticle
698
+ matches : List error ArchivesArticle
697
699
  matches =
698
700
  BackendTask.succeed
699
701
  [ { year = 1977
@@ -744,7 +746,7 @@ capture (Glob matcherPattern apply1) (Glob pattern apply2) =
744
746
  , extension : String
745
747
  }
746
748
 
747
- dataFiles : BackendTask (List DataFile)
749
+ dataFiles : BackendTask error (List DataFile)
748
750
  dataFiles =
749
751
  Glob.succeed DataFile
750
752
  |> Glob.match (Glob.literal "my-data/")
@@ -768,7 +770,7 @@ If we have the following files
768
770
 
769
771
  That gives us
770
772
 
771
- results : BackendTask (List DataFile)
773
+ results : BackendTask error (List DataFile)
772
774
  results =
773
775
  BackendTask.succeed
774
776
  [ { name = "authors"
@@ -781,7 +783,7 @@ That gives us
781
783
 
782
784
  You could also match an optional file path segment using `oneOf`.
783
785
 
784
- rootFilesMd : BackendTask (List String)
786
+ rootFilesMd : BackendTask error (List String)
785
787
  rootFilesMd =
786
788
  Glob.succeed (\slug -> slug)
787
789
  |> Glob.match (Glob.literal "blog/")
@@ -806,7 +808,7 @@ With these files:
806
808
 
807
809
  This would give us:
808
810
 
809
- results : BackendTask (List String)
811
+ results : BackendTask error (List String)
810
812
  results =
811
813
  BackendTask.succeed
812
814
  [ "first-post"
@@ -965,7 +967,7 @@ encodeOptions options =
965
967
 
966
968
  import BackendTask.Glob as Glob exposing (OnlyFolders, defaultOptions)
967
969
 
968
- matchingFiles : Glob a -> BackendTask (List a)
970
+ matchingFiles : Glob a -> BackendTask error (List a)
969
971
  matchingFiles glob =
970
972
  glob
971
973
  |> Glob.toBackendTaskWithOptions { defaultOptions | include = OnlyFolders }
@@ -1010,12 +1012,12 @@ For example, maybe you can have
1010
1012
  import BackendTask exposing (BackendTask)
1011
1013
  import BackendTask.Glob as Glob
1012
1014
 
1013
- findBlogBySlug : String -> BackendTask String
1015
+ findBlogBySlug : String -> BackendTask FatalError String
1014
1016
  findBlogBySlug slug =
1015
1017
  Glob.succeed identity
1016
1018
  |> Glob.captureFilePath
1017
1019
  |> Glob.match (Glob.literal "blog/")
1018
- |> Glob.capture (Glob.literal slug)
1020
+ |> Glob.match (Glob.literal slug)
1019
1021
  |> Glob.match
1020
1022
  (Glob.oneOf
1021
1023
  ( ( "", () )
@@ -1024,6 +1026,7 @@ For example, maybe you can have
1024
1026
  )
1025
1027
  |> Glob.match (Glob.literal ".md")
1026
1028
  |> Glob.expectUniqueMatch
1029
+ |> BackendTask.allowFatal
1027
1030
 
1028
1031
  If we used `findBlogBySlug "first-post"` with these files:
1029
1032
 
@@ -1035,7 +1038,7 @@ If we used `findBlogBySlug "first-post"` with these files:
1035
1038
 
1036
1039
  This would give us:
1037
1040
 
1038
- results : BackendTask String
1041
+ results : BackendTask FatalError String
1039
1042
  results =
1040
1043
  BackendTask.succeed "blog/first-post/index.md"
1041
1044
 
@@ -88,6 +88,7 @@ Any place in your `elm-pages` app where the framework lets you pass in a value o
88
88
 
89
89
  import FatalError exposing (FatalError)
90
90
  import Json.Encode
91
+ import List.Chunks
91
92
  import Pages.StaticHttpRequest exposing (RawRequest(..))
92
93
 
93
94
 
@@ -140,6 +141,7 @@ resolve =
140
141
  {-| Turn a list of `BackendTask`s into a single one.
141
142
 
142
143
  import BackendTask
144
+ import FatalError exposing (FatalError)
143
145
  import Json.Decode as Decode exposing (Decoder)
144
146
 
145
147
  type alias Pokemon =
@@ -147,7 +149,7 @@ resolve =
147
149
  , sprite : String
148
150
  }
149
151
 
150
- pokemonDetailRequest : BackendTask (List Pokemon)
152
+ pokemonDetailRequest : BackendTask FatalError (List Pokemon)
151
153
  pokemonDetailRequest =
152
154
  BackendTask.Http.getJson
153
155
  "https://pokeapi.co/api/v2/pokemon/?limit=3"
@@ -169,34 +171,56 @@ resolve =
169
171
  )
170
172
  )
171
173
  |> BackendTask.andThen BackendTask.combine
174
+ |> BackendTask.allowFatal
172
175
 
173
176
  -}
174
177
  combine : List (BackendTask error value) -> BackendTask error (List value)
175
178
  combine items =
179
+ items
180
+ |> List.Chunks.chunk 100
181
+ |> List.map combineHelp
182
+ |> List.Chunks.chunk 100
183
+ |> List.map combineHelp
184
+ |> List.Chunks.chunk 100
185
+ |> List.map combineHelp
186
+ |> combineHelp
187
+ |> map (List.concat >> List.concat >> List.concat)
188
+
189
+
190
+ {-| `combineHelp` on its own will overflow the stack with larger lists of tasks
191
+
192
+ dividing the tasks into smaller nested chunks and recombining makes `combine` stack safe
193
+
194
+ There's probably a way of doing this without the Lists but it's a neat trick to safely combine lots of tasks!
195
+
196
+ -}
197
+ combineHelp : List (BackendTask error value) -> BackendTask error (List value)
198
+ combineHelp items =
176
199
  List.foldl (map2 (::)) (succeed []) items |> map List.reverse
177
200
 
178
201
 
179
- {-| Like map, but it takes in two `Request`s.
202
+ {-| Like map, but it takes in two `BackendTask`s.
180
203
 
181
- view siteMetadata page =
182
- StaticHttp.map2
183
- (\elmPagesStars elmMarkdownStars ->
184
- { view =
185
- \model viewForPage ->
186
- { title = "Repo Stargazers"
187
- , body = starsView elmPagesStars elmMarkdownStars
188
- }
189
- , head = head elmPagesStars elmMarkdownStars
190
- }
191
- )
192
- (get
193
- (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
194
- (Decode.field "stargazers_count" Decode.int)
195
- )
196
- (get
197
- (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-markdown")
198
- (Decode.field "stargazers_count" Decode.int)
204
+ import BackendTask exposing (BackendTask)
205
+ import BackendTask.Env as Env
206
+ import BackendTask.Http
207
+ import FatalError exposing (FatalError)
208
+ import Json.Decode as Decode
209
+
210
+ type alias Data =
211
+ { pokemon : List String, envValue : Maybe String }
212
+
213
+ data : BackendTask FatalError Data
214
+ data =
215
+ BackendTask.map2 Data
216
+ (BackendTask.Http.getJson
217
+ "https://pokeapi.co/api/v2/pokemon/?limit=100&offset=0"
218
+ (Decode.field "results"
219
+ (Decode.list (Decode.field "name" Decode.string))
220
+ )
221
+ |> BackendTask.allowFatal
199
222
  )
223
+ (Env.get "HELLO")
200
224
 
201
225
  -}
202
226
  map2 : (a -> b -> c) -> BackendTask error a -> BackendTask error b -> BackendTask error c
@@ -239,17 +263,19 @@ map2 fn request1 request2 =
239
263
  from the previous response to build up the URL, headers, etc. that you send to the subsequent request.
240
264
 
241
265
  import BackendTask
266
+ import FatalError exposing (FatalError)
242
267
  import Json.Decode as Decode exposing (Decoder)
243
268
 
244
- licenseData : BackendTask String
269
+ licenseData : BackendTask FatalError String
245
270
  licenseData =
246
- BackendTask.Http.get
247
- (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
271
+ BackendTask.Http.getJson
272
+ "https://api.github.com/repos/dillonkearns/elm-pages"
248
273
  (Decode.at [ "license", "url" ] Decode.string)
249
274
  |> BackendTask.andThen
250
275
  (\licenseUrl ->
251
- BackendTask.Http.get (Secrets.succeed licenseUrl) (Decode.field "description" Decode.string)
276
+ BackendTask.Http.getJson licenseUrl (Decode.field "description" Decode.string)
252
277
  )
278
+ |> BackendTask.allowFatal
253
279
 
254
280
  -}
255
281
  andThen : (a -> BackendTask error b) -> BackendTask error a -> BackendTask error b
@@ -309,28 +335,15 @@ andMap =
309
335
  map2 (|>)
310
336
 
311
337
 
312
- {-| This is useful for prototyping with some hardcoded data, or for having a view that doesn't have any StaticHttp data.
338
+ {-| This is useful for prototyping with some hardcoded data, or for having a view that doesn't have any BackendTask data.
313
339
 
314
- import BackendTask
340
+ import BackendTask exposing (BackendTask)
341
+
342
+ type alias RouteParams = { name : String }
315
343
 
316
- view :
317
- List ( PagePath, Metadata )
318
- ->
319
- { path : PagePath
320
- , frontmatter : Metadata
321
- }
322
- ->
323
- StaticHttp.Request
324
- { view : Model -> View -> { title : String, body : Html Msg }
325
- , head : List (Head.Tag Pages.PathKey)
326
- }
327
- view siteMetadata page =
328
- StaticHttp.succeed
329
- { view =
330
- \model viewForPage ->
331
- mainView model viewForPage
332
- , head = head page.frontmatter
333
- }
344
+ pages : BackendTask error (List RouteParams)
345
+ pages =
346
+ BackendTask.succeed [ { name = "elm-pages" } ]
334
347
 
335
348
  -}
336
349
  succeed : a -> BackendTask error a
@@ -20,8 +20,8 @@ For example, if you wanted to handle possible errors to present them to the user
20
20
  BackendTask.Http.getJson "https://api.github.com/repos/dillonkearns/elm-pages"
21
21
  (Decode.field "description" Decode.string)
22
22
  |> BackendTask.onError
23
- (\error ->
24
- case FatalError.unwrap error of
23
+ (\{ recoverable } ->
24
+ case recoverable of
25
25
  BackendTask.Http.BadStatus metadata string ->
26
26
  if metadata.statusCode == 401 || metadata.statusCode == 403 || metadata.statusCode == 404 then
27
27
  BackendTask.succeed "Either this repo doesn't exist or you don't have access to it."
package/src/Head/Seo.elm CHANGED
@@ -52,8 +52,8 @@ includes common meta tags used for rich link previews, namely [OpenGraph tags](h
52
52
  import DateOrDateTime exposing (DateOrDateTime)
53
53
  import Head
54
54
  import Head.Twitter as Twitter
55
- import LanguageTag.Country
56
55
  import LanguageTag.Language
56
+ import LanguageTag.Region
57
57
  import MimeType exposing (MimeType)
58
58
  import Pages.Url
59
59
 
@@ -315,7 +315,7 @@ localeToString : Locale -> String
315
315
  localeToString ( language, territory ) =
316
316
  LanguageTag.Language.toCodeString language
317
317
  ++ "_"
318
- ++ LanguageTag.Country.toCodeString territory
318
+ ++ LanguageTag.Region.toCodeString territory
319
319
 
320
320
 
321
321
  tagsForCommon : Common -> List ( String, Maybe Head.AttributeValue )
@@ -361,7 +361,7 @@ tagsForAudio audio =
361
361
 
362
362
 
363
363
  type alias Locale =
364
- ( LanguageTag.Language.Language, LanguageTag.Country.Country )
364
+ ( LanguageTag.Language.Language, LanguageTag.Region.Region )
365
365
 
366
366
 
367
367
  type Content
@@ -0,0 +1,51 @@
1
+ module List.Chunks exposing (chunk)
2
+
3
+ import Array exposing (Array)
4
+
5
+
6
+ {-| Adapted from <https://package.elm-lang.org/packages/krisajenkins/elm-exts/latest/Exts-List>
7
+
8
+ Split a list into chunks of length `n`.
9
+
10
+ Be aware that the last sub-list may be smaller than `n`-items long.
11
+
12
+ For example `chunk 3 [1..10] => [[1,2,3], [4,5,6], [7,8,9], [10]]`
13
+
14
+ -}
15
+ chunk : Int -> List a -> List (List a)
16
+ chunk n xs =
17
+ if n < 1 then
18
+ List.singleton xs
19
+
20
+ else
21
+ evaluate (chunkInternal n xs Array.empty)
22
+
23
+
24
+ chunkInternal : Int -> List a -> Array (List a) -> Trampoline (List (List a))
25
+ chunkInternal n xs acc =
26
+ -- elm-review: known-unoptimized-recursion
27
+ if List.isEmpty xs then
28
+ Done (Array.toList acc)
29
+
30
+ else
31
+ Jump
32
+ (\_ ->
33
+ chunkInternal n
34
+ (List.drop n xs)
35
+ (Array.push (List.take n xs) acc)
36
+ )
37
+
38
+
39
+ type Trampoline a
40
+ = Done a
41
+ | Jump (() -> Trampoline a)
42
+
43
+
44
+ evaluate : Trampoline a -> a
45
+ evaluate trampoline =
46
+ case trampoline of
47
+ Done value ->
48
+ value
49
+
50
+ Jump f ->
51
+ evaluate (f ())
@@ -3,4 +3,4 @@ module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKe
3
3
 
4
4
  currentCompatibilityKey : Int
5
5
  currentCompatibilityKey =
6
- 20
6
+ 21
@@ -72,8 +72,8 @@ import FatalError exposing (FatalError)
72
72
  import Head
73
73
  import Json.Encode as Encode
74
74
  import LanguageTag exposing (LanguageTag, emptySubtags)
75
- import LanguageTag.Country as Country
76
75
  import LanguageTag.Language
76
+ import LanguageTag.Region as Region
77
77
  import MimeType
78
78
  import Pages.Manifest.Category as Category exposing (Category)
79
79
  import Pages.Url
@@ -140,7 +140,7 @@ usEnglish =
140
140
  LanguageTag.Language.en
141
141
  |> LanguageTag.build
142
142
  { emptySubtags
143
- | region = Just Country.us
143
+ | region = Just Region.us
144
144
  }
145
145
 
146
146