elm-pages 3.0.0-beta.6 → 3.0.0-beta.8

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 (29) hide show
  1. package/codegen/elm-pages-codegen.js +121 -102
  2. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +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/js/Reporter.elm.js +1 -1
  7. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +1 -1
  8. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  9. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +4 -4
  10. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
  11. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
  12. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  13. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
  14. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  15. package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1 -1
  16. package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +1 -1
  17. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  18. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +4 -4
  19. package/generator/src/build.js +46 -16
  20. package/generator/src/config.js +41 -0
  21. package/generator/src/dev-server.js +5 -44
  22. package/generator/src/pre-render-html.js +31 -17
  23. package/generator/template/app/Api.elm +1 -1
  24. package/generator/template/app/Site.elm +6 -1
  25. package/package.json +1 -1
  26. package/src/DataSource.elm +28 -28
  27. package/src/HtmlPrinter.elm +7 -3
  28. package/src/Pages/Internal/Platform/Cli.elm +2 -2
  29. package/src/Pages/ProgramConfig.elm +5 -2
@@ -35471,9 +35471,9 @@ var $author$project$GenerateMain$otherFile = F2(
35471
35471
  $author$project$Elm$list(
35472
35472
  A2(
35473
35473
  $elm$core$List$map,
35474
- function (_v59) {
35475
- var route = _v59.a;
35476
- var params = _v59.b;
35474
+ function (_v63) {
35475
+ var route = _v63.a;
35476
+ var params = _v63.b;
35477
35477
  var pattern = '/' + A2(
35478
35478
  $elm$core$String$join,
35479
35479
  '/',
@@ -35523,9 +35523,9 @@ var $author$project$GenerateMain$otherFile = F2(
35523
35523
  $elm$core$List$concatMap,
35524
35524
  function (route) {
35525
35525
  var params = $author$project$Pages$Internal$RoutePattern$toVariantName(route).params;
35526
- var _v58 = $author$project$Pages$Internal$RoutePattern$repeatWithoutOptionalEnding(params);
35527
- if (_v58.$ === 'Just') {
35528
- var repeated = _v58.a;
35526
+ var _v62 = $author$project$Pages$Internal$RoutePattern$repeatWithoutOptionalEnding(params);
35527
+ if (_v62.$ === 'Just') {
35528
+ var repeated = _v62.a;
35529
35529
  return _List_fromArray(
35530
35530
  [
35531
35531
  _Utils_Tuple2(route, repeated),
@@ -35624,9 +35624,9 @@ var $author$project$GenerateMain$otherFile = F2(
35624
35624
  [
35625
35625
  A2(
35626
35626
  $author$project$Elm$Case$patternToBranch,
35627
- function (_v56) {
35628
- var first = _v56.a;
35629
- var rest = _v56.b;
35627
+ function (_v60) {
35628
+ var first = _v60.a;
35629
+ var rest = _v60.b;
35630
35630
  return $author$project$GenerateMain$append(
35631
35631
  _List_fromArray(
35632
35632
  [
@@ -35743,20 +35743,20 @@ var $author$project$GenerateMain$otherFile = F2(
35743
35743
  function (args) {
35744
35744
  if ((((((((args.b && args.b.b) && args.b.b.b) && args.b.b.b.b) && args.b.b.b.b.b) && args.b.b.b.b.b.b) && args.b.b.b.b.b.b.b) && args.b.b.b.b.b.b.b.b) && (!args.b.b.b.b.b.b.b.b.b)) {
35745
35745
  var pageFormState = args.a;
35746
- var _v40 = args.b;
35747
- var fetchers = _v40.a;
35748
- var _v41 = _v40.b;
35749
- var transition = _v41.a;
35750
- var _v42 = _v41.b;
35751
- var page = _v42.a;
35752
- var _v43 = _v42.b;
35753
- var maybePageUrl = _v43.a;
35754
- var _v44 = _v43.b;
35755
- var globalData = _v44.a;
35746
+ var _v44 = args.b;
35747
+ var fetchers = _v44.a;
35756
35748
  var _v45 = _v44.b;
35757
- var pageData = _v45.a;
35749
+ var transition = _v45.a;
35758
35750
  var _v46 = _v45.b;
35759
- var actionData = _v46.a;
35751
+ var page = _v46.a;
35752
+ var _v47 = _v46.b;
35753
+ var maybePageUrl = _v47.a;
35754
+ var _v48 = _v47.b;
35755
+ var globalData = _v48.a;
35756
+ var _v49 = _v48.b;
35757
+ var pageData = _v49.a;
35758
+ var _v50 = _v49.b;
35759
+ var actionData = _v50.a;
35760
35760
  return A2(
35761
35761
  $author$project$Elm$withType,
35762
35762
  $author$project$Elm$Annotation$record(
@@ -35797,8 +35797,8 @@ var $author$project$GenerateMain$otherFile = F2(
35797
35797
  [
35798
35798
  A2(
35799
35799
  $author$project$Elm$Case$patternToBranch,
35800
- function (_v47) {
35801
- var data = _v47.b;
35800
+ function (_v51) {
35801
+ var data = _v51.b;
35802
35802
  return $author$project$Elm$record(
35803
35803
  _List_fromArray(
35804
35804
  [
@@ -35887,7 +35887,7 @@ var $author$project$GenerateMain$otherFile = F2(
35887
35887
  $author$project$Elm$Pattern$var('subModel'))),
35888
35888
  A2(
35889
35889
  $author$project$Elm$Case$patternToBranch,
35890
- function (_v48) {
35890
+ function (_v52) {
35891
35891
  return modelMismatchView.value;
35892
35892
  },
35893
35893
  $author$project$Elm$Pattern$ignore)
@@ -35912,9 +35912,9 @@ var $author$project$GenerateMain$otherFile = F2(
35912
35912
  function (route) {
35913
35913
  return A2(
35914
35914
  $author$project$Elm$Case$patternToBranch,
35915
- function (_v49) {
35916
- var maybeRouteParams = _v49.a;
35917
- var data = _v49.b;
35915
+ function (_v53) {
35916
+ var maybeRouteParams = _v53.a;
35917
+ var data = _v53.b;
35918
35918
  return $author$project$Elm$Let$toExpression(
35919
35919
  A4(
35920
35920
  $author$project$Elm$Let$fn,
@@ -35935,7 +35935,7 @@ var $author$project$GenerateMain$otherFile = F2(
35935
35935
  A3($author$project$GenerateMain$destructureRouteVariant, $author$project$GenerateMain$ActionData, 'justActionData', route)),
35936
35936
  A2(
35937
35937
  $author$project$Elm$Case$patternToBranch,
35938
- function (_v53) {
35938
+ function (_v57) {
35939
35939
  return $author$project$Elm$nothing;
35940
35940
  },
35941
35941
  $author$project$Elm$Pattern$ignore)
@@ -36043,7 +36043,7 @@ var $author$project$GenerateMain$otherFile = F2(
36043
36043
  A2(
36044
36044
  $author$project$Gen$Dict$map,
36045
36045
  F2(
36046
- function (_v50, fetcherState) {
36046
+ function (_v54, fetcherState) {
36047
36047
  return A2(
36048
36048
  $author$project$Gen$Pages$Transition$map,
36049
36049
  function (ad) {
@@ -36061,7 +36061,7 @@ var $author$project$GenerateMain$otherFile = F2(
36061
36061
  A3($author$project$GenerateMain$destructureRouteVariant, $author$project$GenerateMain$Model, 'subModel', route)),
36062
36062
  A2(
36063
36063
  $author$project$Elm$Case$patternToBranch,
36064
- function (_v51) {
36064
+ function (_v55) {
36065
36065
  return modelMismatchView.value;
36066
36066
  },
36067
36067
  $author$project$Elm$Pattern$ignore)
@@ -36125,7 +36125,7 @@ var $author$project$GenerateMain$otherFile = F2(
36125
36125
  _List_fromArray(
36126
36126
  [
36127
36127
  $author$project$Elm$Case$otherwise(
36128
- function (_v54) {
36128
+ function (_v58) {
36129
36129
  return $author$project$Elm$record(
36130
36130
  _List_fromArray(
36131
36131
  [
@@ -36134,7 +36134,7 @@ var $author$project$GenerateMain$otherFile = F2(
36134
36134
  A2(
36135
36135
  $author$project$Elm$fn,
36136
36136
  _Utils_Tuple2('_', $elm$core$Maybe$Nothing),
36137
- function (_v55) {
36137
+ function (_v59) {
36138
36138
  return $author$project$Elm$record(
36139
36139
  _List_fromArray(
36140
36140
  [
@@ -36274,7 +36274,7 @@ var $author$project$GenerateMain$otherFile = F2(
36274
36274
  return errorPage;
36275
36275
  }),
36276
36276
  $author$project$Elm$Case$otherwise(
36277
- function (_v38) {
36277
+ function (_v42) {
36278
36278
  return $author$project$Elm$value(
36279
36279
  {
36280
36280
  annotation: $elm$core$Maybe$Nothing,
@@ -36419,9 +36419,9 @@ var $author$project$GenerateMain$otherFile = F2(
36419
36419
  },
36420
36420
  currentGlobalModel)),
36421
36421
  $author$project$Elm$Let$letIn(
36422
- function (_v33) {
36423
- var sharedModel = _v33.a;
36424
- var globalCmd = _v33.b;
36422
+ function (_v37) {
36423
+ var sharedModel = _v37.a;
36424
+ var globalCmd = _v37.b;
36425
36425
  return $author$project$Elm$Let$toExpression(
36426
36426
  A4(
36427
36427
  $author$project$Elm$Let$tuple,
@@ -36457,9 +36457,9 @@ var $author$project$GenerateMain$otherFile = F2(
36457
36457
  function (route) {
36458
36458
  return A2(
36459
36459
  $author$project$Elm$Case$patternToBranch,
36460
- function (_v35) {
36461
- var maybeRouteParams = _v35.a;
36462
- var thisPageData = _v35.b;
36460
+ function (_v39) {
36461
+ var maybeRouteParams = _v39.a;
36462
+ var thisPageData = _v39.b;
36463
36463
  return A3(
36464
36464
  $author$project$Gen$Tuple$call_.mapBoth,
36465
36465
  A2($author$project$GenerateMain$routeVariantExpression, $author$project$GenerateMain$Model, route),
@@ -36520,7 +36520,7 @@ var $author$project$GenerateMain$otherFile = F2(
36520
36520
  },
36521
36521
  A3($author$project$GenerateMain$destructureRouteVariant, $author$project$GenerateMain$ActionData, 'thisActionData', route)),
36522
36522
  $author$project$Elm$Case$otherwise(
36523
- function (_v36) {
36523
+ function (_v40) {
36524
36524
  return $author$project$Elm$nothing;
36525
36525
  })
36526
36526
  ]));
@@ -36572,7 +36572,7 @@ var $author$project$GenerateMain$otherFile = F2(
36572
36572
  [
36573
36573
  A2(
36574
36574
  $author$project$Elm$Case$patternToBranch,
36575
- function (_v37) {
36575
+ function (_v41) {
36576
36576
  return initErrorPage.call(pageData);
36577
36577
  },
36578
36578
  $author$project$Elm$Pattern$ignore)
@@ -36581,9 +36581,9 @@ var $author$project$GenerateMain$otherFile = F2(
36581
36581
  nothing: initErrorPage.call(pageData)
36582
36582
  }),
36583
36583
  $author$project$Elm$Let$letIn(
36584
- function (_v34) {
36585
- var templateModel = _v34.a;
36586
- var templateCmd = _v34.b;
36584
+ function (_v38) {
36585
+ var templateModel = _v38.a;
36586
+ var templateCmd = _v38.b;
36587
36587
  return A2(
36588
36588
  $author$project$Elm$tuple,
36589
36589
  $author$project$Elm$record(
@@ -36693,6 +36693,13 @@ var $author$project$GenerateMain$otherFile = F2(
36693
36693
  $author$project$Elm$Annotation$function,
36694
36694
  _List_fromArray(
36695
36695
  [
36696
+ $author$project$Elm$Annotation$maybe(
36697
+ $author$project$Elm$Annotation$record(
36698
+ _List_fromArray(
36699
+ [
36700
+ _Utils_Tuple2('indent', $author$project$Elm$Annotation$int),
36701
+ _Utils_Tuple2('newLines', $author$project$Elm$Annotation$bool)
36702
+ ]))),
36696
36703
  $author$project$Gen$Html$annotation_.html($author$project$Gen$Basics$annotation_.never)
36697
36704
  ]),
36698
36705
  $author$project$Elm$Annotation$string))),
@@ -36824,10 +36831,10 @@ var $author$project$GenerateMain$otherFile = F2(
36824
36831
  [
36825
36832
  A2(
36826
36833
  $author$project$Elm$Case$patternToBranch,
36827
- function (_v32) {
36828
- var a = _v32.a;
36829
- var b = _v32.b;
36830
- var c = _v32.c;
36834
+ function (_v36) {
36835
+ var a = _v36.a;
36836
+ var b = _v36.b;
36837
+ var c = _v36.c;
36831
36838
  return A3(
36832
36839
  $author$project$Elm$triple,
36833
36840
  A2(
@@ -36947,20 +36954,20 @@ var $author$project$GenerateMain$otherFile = F2(
36947
36954
  function (args) {
36948
36955
  if ((((((((args.b && args.b.b) && args.b.b.b) && args.b.b.b.b) && args.b.b.b.b.b) && args.b.b.b.b.b.b) && args.b.b.b.b.b.b.b) && args.b.b.b.b.b.b.b.b) && (!args.b.b.b.b.b.b.b.b.b)) {
36949
36956
  var pageFormState = args.a;
36950
- var _v11 = args.b;
36951
- var fetchers = _v11.a;
36952
- var _v12 = _v11.b;
36953
- var transition = _v12.a;
36954
- var _v13 = _v12.b;
36955
- var sharedData = _v13.a;
36956
- var _v14 = _v13.b;
36957
- var pageData = _v14.a;
36958
- var _v15 = _v14.b;
36959
- var navigationKey = _v15.a;
36957
+ var _v15 = args.b;
36958
+ var fetchers = _v15.a;
36960
36959
  var _v16 = _v15.b;
36961
- var msg = _v16.a;
36960
+ var transition = _v16.a;
36962
36961
  var _v17 = _v16.b;
36963
- var model = _v17.a;
36962
+ var sharedData = _v17.a;
36963
+ var _v18 = _v17.b;
36964
+ var pageData = _v18.a;
36965
+ var _v19 = _v18.b;
36966
+ var navigationKey = _v19.a;
36967
+ var _v20 = _v19.b;
36968
+ var msg = _v20.a;
36969
+ var _v21 = _v20.b;
36970
+ var model = _v21.a;
36964
36971
  return A2(
36965
36972
  $author$project$Elm$withType,
36966
36973
  A2(
@@ -37003,9 +37010,9 @@ var $author$project$GenerateMain$otherFile = F2(
37003
37010
  [
37004
37011
  A2(
37005
37012
  $author$project$Elm$Case$patternToBranch,
37006
- function (_v19) {
37007
- var pageModel = _v19.a;
37008
- var thisPageData = _v19.b;
37013
+ function (_v23) {
37014
+ var pageModel = _v23.a;
37015
+ var thisPageData = _v23.b;
37009
37016
  return A3(
37010
37017
  $author$project$Gen$Tuple$call_.mapBoth,
37011
37018
  $author$project$Elm$val('ModelErrorPage____'),
@@ -37035,7 +37042,7 @@ var $author$project$GenerateMain$otherFile = F2(
37035
37042
  $author$project$Elm$Pattern$var('thisPageData')))),
37036
37043
  A2(
37037
37044
  $author$project$Elm$Case$patternToBranch,
37038
- function (_v20) {
37045
+ function (_v24) {
37039
37046
  return A2(
37040
37047
  $author$project$Elm$tuple,
37041
37048
  A2($author$project$Elm$get, 'page', model),
@@ -37044,9 +37051,9 @@ var $author$project$GenerateMain$otherFile = F2(
37044
37051
  $author$project$Elm$Pattern$ignore)
37045
37052
  ])),
37046
37053
  $author$project$Elm$Let$letIn(
37047
- function (_v18) {
37048
- var updatedPageModel = _v18.a;
37049
- var pageCmd = _v18.b;
37054
+ function (_v22) {
37055
+ var updatedPageModel = _v22.a;
37056
+ var pageCmd = _v22.b;
37050
37057
  return A2(
37051
37058
  $author$project$Elm$tuple,
37052
37059
  A2(
@@ -37091,9 +37098,9 @@ var $author$project$GenerateMain$otherFile = F2(
37091
37098
  A2($author$project$Elm$get, 'global', model)
37092
37099
  ])),
37093
37100
  $author$project$Elm$Let$letIn(
37094
- function (_v21) {
37095
- var sharedModel = _v21.a;
37096
- var globalCmd = _v21.b;
37101
+ function (_v25) {
37102
+ var sharedModel = _v25.a;
37103
+ var globalCmd = _v25.b;
37097
37104
  return A2(
37098
37105
  $author$project$Elm$tuple,
37099
37106
  A2(
@@ -37194,9 +37201,9 @@ var $author$project$GenerateMain$otherFile = F2(
37194
37201
  navigationKey,
37195
37202
  $author$project$Elm$Let$letIn(
37196
37203
  F2(
37197
- function (_v22, _v23) {
37198
- var updatedModel = _v23.a;
37199
- var cmd = _v23.b;
37204
+ function (_v26, _v27) {
37205
+ var updatedModel = _v27.a;
37206
+ var cmd = _v27.b;
37200
37207
  return A2(
37201
37208
  $author$project$Elm$Case$maybe,
37202
37209
  A2(
@@ -37256,9 +37263,9 @@ var $author$project$GenerateMain$otherFile = F2(
37256
37263
  A2($author$project$Elm$get, 'global', model)
37257
37264
  ])),
37258
37265
  $author$project$Elm$Let$letIn(
37259
- function (_v24) {
37260
- var updatedGlobalModel = _v24.a;
37261
- var globalCmd = _v24.b;
37266
+ function (_v28) {
37267
+ var updatedGlobalModel = _v28.a;
37268
+ var globalCmd = _v28.b;
37262
37269
  return A2(
37263
37270
  $author$project$Elm$tuple,
37264
37271
  A2(
@@ -37332,13 +37339,13 @@ var $author$project$GenerateMain$otherFile = F2(
37332
37339
  [
37333
37340
  A2(
37334
37341
  $author$project$Elm$Case$patternToBranch,
37335
- function (_v25) {
37336
- var pageModel = _v25.a;
37337
- var thisPageData = _v25.b;
37338
- var _v26 = _v25.c;
37339
- var maybeRouteParams = _v26.a;
37340
- var pageUrl = _v26.b;
37341
- var justPage = _v26.c;
37342
+ function (_v29) {
37343
+ var pageModel = _v29.a;
37344
+ var thisPageData = _v29.b;
37345
+ var _v30 = _v29.c;
37346
+ var maybeRouteParams = _v30.a;
37347
+ var pageUrl = _v30.b;
37348
+ var justPage = _v30.c;
37342
37349
  return $author$project$Elm$Let$toExpression(
37343
37350
  A3(
37344
37351
  $author$project$Elm$Let$destructure,
@@ -37400,7 +37407,7 @@ var $author$project$GenerateMain$otherFile = F2(
37400
37407
  A2(
37401
37408
  $author$project$Gen$Dict$map,
37402
37409
  F2(
37403
- function (_v29, fetcherState) {
37410
+ function (_v33, fetcherState) {
37404
37411
  return A2(
37405
37412
  $author$project$Gen$Pages$Transition$map,
37406
37413
  function (ad) {
@@ -37417,7 +37424,7 @@ var $author$project$GenerateMain$otherFile = F2(
37417
37424
  },
37418
37425
  A3($author$project$GenerateMain$destructureRouteVariant, $author$project$GenerateMain$ActionData, 'justActionData', route)),
37419
37426
  $author$project$Elm$Case$otherwise(
37420
- function (_v30) {
37427
+ function (_v34) {
37421
37428
  return $author$project$Elm$nothing;
37422
37429
  })
37423
37430
  ]));
@@ -37432,12 +37439,12 @@ var $author$project$GenerateMain$otherFile = F2(
37432
37439
  A2($author$project$Elm$get, 'global', model)
37433
37440
  ]))),
37434
37441
  $author$project$Elm$Let$letIn(
37435
- function (_v27) {
37436
- var updatedPageModel = _v27.a;
37437
- var pageCmd = _v27.b;
37438
- var _v28 = _v27.c;
37439
- var newGlobalModel = _v28.a;
37440
- var newGlobalCmd = _v28.b;
37442
+ function (_v31) {
37443
+ var updatedPageModel = _v31.a;
37444
+ var pageCmd = _v31.b;
37445
+ var _v32 = _v31.c;
37446
+ var newGlobalModel = _v32.a;
37447
+ var newGlobalCmd = _v32.b;
37441
37448
  return A2(
37442
37449
  $author$project$Elm$tuple,
37443
37450
  A2(
@@ -37495,7 +37502,7 @@ var $author$project$GenerateMain$otherFile = F2(
37495
37502
  $author$project$Elm$Pattern$var('justPage'))))),
37496
37503
  A2(
37497
37504
  $author$project$Elm$Case$patternToBranch,
37498
- function (_v31) {
37505
+ function (_v35) {
37499
37506
  return A2($author$project$Elm$tuple, model, $author$project$GenerateMain$effectNone);
37500
37507
  },
37501
37508
  $author$project$Elm$Pattern$ignore)
@@ -37735,7 +37742,7 @@ var $author$project$GenerateMain$otherFile = F2(
37735
37742
  $author$project$Elm$Case$branch1,
37736
37743
  routeVariant,
37737
37744
  _Utils_Tuple2('_', $author$project$Elm$Annotation$unit),
37738
- function (_v9) {
37745
+ function (_v13) {
37739
37746
  return mappedDecoder;
37740
37747
  }) : A2($author$project$Elm$Case$branch0, routeVariant, mappedDecoder);
37741
37748
  },
@@ -37917,9 +37924,9 @@ var $author$project$GenerateMain$otherFile = F2(
37917
37924
  return $author$project$Elm$list(
37918
37925
  A2(
37919
37926
  $elm$core$List$map,
37920
- function (_v8) {
37921
- var key = _v8.a;
37922
- var value = _v8.b;
37927
+ function (_v12) {
37928
+ var key = _v12.a;
37929
+ var value = _v12.b;
37923
37930
  return A2(
37924
37931
  $author$project$Elm$tuple,
37925
37932
  $author$project$Elm$string(key),
@@ -38054,7 +38061,7 @@ var $author$project$GenerateMain$otherFile = F2(
38054
38061
  },
38055
38062
  A3($author$project$GenerateMain$destructureRouteVariant, $author$project$GenerateMain$Model, 'templateModel', route)),
38056
38063
  $author$project$Elm$Case$otherwise(
38057
- function (_v6) {
38064
+ function (_v10) {
38058
38065
  return $author$project$Gen$Platform$Sub$none;
38059
38066
  })
38060
38067
  ]));
@@ -38152,8 +38159,14 @@ var $author$project$GenerateMain$otherFile = F2(
38152
38159
  _List_fromArray(
38153
38160
  [
38154
38161
  getStaticRoutes.reference,
38155
- $author$project$Elm$Extra$fnIgnore(
38156
- $author$project$Elm$string(''))
38162
+ A3(
38163
+ $author$project$Elm$fn2,
38164
+ _Utils_Tuple2('a', $elm$core$Maybe$Nothing),
38165
+ _Utils_Tuple2('b', $elm$core$Maybe$Nothing),
38166
+ F2(
38167
+ function (_v8, _v9) {
38168
+ return $author$project$Elm$string('');
38169
+ }))
38157
38170
  ])))))))))));
38158
38171
  var pathsToGenerateHandler = A2(
38159
38172
  $author$project$Elm$Extra$topLevelValue,
@@ -38235,8 +38248,14 @@ var $author$project$GenerateMain$otherFile = F2(
38235
38248
  _List_fromArray(
38236
38249
  [
38237
38250
  getStaticRoutes.reference,
38238
- $author$project$Elm$Extra$fnIgnore(
38239
- $author$project$Elm$string(''))
38251
+ A3(
38252
+ $author$project$Elm$fn2,
38253
+ _Utils_Tuple2('a', $elm$core$Maybe$Nothing),
38254
+ _Utils_Tuple2('b', $elm$core$Maybe$Nothing),
38255
+ F2(
38256
+ function (_v6, _v7) {
38257
+ return $author$project$Elm$string('');
38258
+ }))
38240
38259
  ]))))))))))));
38241
38260
  var action = A3(
38242
38261
  $author$project$Elm$Declare$fn,
@@ -38904,7 +38923,7 @@ _Platform_export({'Generate':{'init':$author$project$Generate$main(
38904
38923
  $elm$json$Json$Decode$field,
38905
38924
  'templates',
38906
38925
  $elm$json$Json$Decode$list(
38907
- $elm$json$Json$Decode$list($elm$json$Json$Decode$string)))))(0)}});var isBackend = false && typeof isLamdera !== 'undefined';
38926
+ $elm$json$Json$Decode$list($elm$json$Json$Decode$string)))))(0)}});var isBackend = false && typeof isLamdera !== 'undefined'
38908
38927
 
38909
38928
  function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
38910
38929
  {
@@ -6692,7 +6692,7 @@ _Platform_export({'Reporter':{'init':$author$project$Reporter$main(
6692
6692
  'paths',
6693
6693
  $elm$json$Json$Decode$list($elm$json$Json$Decode$string)));
6694
6694
  },
6695
- A2($elm$json$Json$Decode$field, 'verbosity', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined';
6695
+ A2($elm$json$Json$Decode$field, 'verbosity', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined'
6696
6696
 
6697
6697
  function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
6698
6698
  {
@@ -25732,7 +25732,7 @@ _Platform_export({'Runner':{'init':$author$project$Runner$main(
25732
25732
  },
25733
25733
  A2($elm$json$Json$Decode$field, 'fuzzRuns', $elm$json$Json$Decode$int));
25734
25734
  },
25735
- A2($elm$json$Json$Decode$field, 'initialSeed', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined';
25735
+ A2($elm$json$Json$Decode$field, 'initialSeed', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined'
25736
25736
 
25737
25737
  function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
25738
25738
  {
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
75
75
  const { Elm } = require("./Runner.elm.js");
76
76
 
77
77
  // Start the Elm app
78
- const flags = { initialSeed: 1035103192, fuzzRuns: 100, filter: null };
78
+ const flags = { initialSeed: 343221655, fuzzRuns: 100, filter: null };
79
79
  const app = Elm.Runner.init({ flags: flags });
80
80
 
81
81
  // Record the timing at which we received the last "runTest" message
@@ -75,19 +75,19 @@ let testsCount, todoTests;
75
75
  let reporter;
76
76
  let runners = [];
77
77
  let working = false;
78
- let workersCount = 10;
78
+ let workersCount = 2;
79
79
  let startWorkCallback = function(){};
80
80
  const verbosity = 0;
81
81
 
82
82
  // Create a long lived reporter worker
83
83
  const { Elm } = require("./Reporter.elm.js");
84
84
  const flags = {
85
- initialSeed: 1035103192,
85
+ initialSeed: 343221655,
86
86
  fuzzRuns: 100,
87
- mode: "consoleColor",
87
+ mode: "consoleNoColor",
88
88
  verbosity: verbosity,
89
89
  globs: [],
90
- paths: ["/Users/dillonkearns/src/github.com/dillonkearns/elm-pages-v3-beta/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm"],
90
+ paths: ["/home/runner/work/elm-pages-v3-beta/elm-pages-v3-beta/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm"],
91
91
  };
92
92
  reporter = Elm.Reporter.init({ flags: flags });
93
93
 
@@ -6692,7 +6692,7 @@ _Platform_export({'Reporter':{'init':$author$project$Reporter$main(
6692
6692
  'paths',
6693
6693
  $elm$json$Json$Decode$list($elm$json$Json$Decode$string)));
6694
6694
  },
6695
- A2($elm$json$Json$Decode$field, 'verbosity', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined';
6695
+ A2($elm$json$Json$Decode$field, 'verbosity', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined'
6696
6696
 
6697
6697
  function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
6698
6698
  {
@@ -27514,7 +27514,7 @@ _Platform_export({'Runner':{'init':$author$project$Runner$main(
27514
27514
  },
27515
27515
  A2($elm$json$Json$Decode$field, 'fuzzRuns', $elm$json$Json$Decode$int));
27516
27516
  },
27517
- A2($elm$json$Json$Decode$field, 'initialSeed', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined';
27517
+ A2($elm$json$Json$Decode$field, 'initialSeed', $elm$json$Json$Decode$int)))(0)}});var isBackend = false && typeof isLamdera !== 'undefined'
27518
27518
 
27519
27519
  function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
27520
27520
  {
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
75
75
  const { Elm } = require("./Runner.elm.js");
76
76
 
77
77
  // Start the Elm app
78
- const flags = { initialSeed: 1889275192, fuzzRuns: 100, filter: null };
78
+ const flags = { initialSeed: 2255331163, fuzzRuns: 100, filter: null };
79
79
  const app = Elm.Runner.init({ flags: flags });
80
80
 
81
81
  // Record the timing at which we received the last "runTest" message
@@ -75,19 +75,19 @@ let testsCount, todoTests;
75
75
  let reporter;
76
76
  let runners = [];
77
77
  let working = false;
78
- let workersCount = 10;
78
+ let workersCount = 2;
79
79
  let startWorkCallback = function(){};
80
80
  const verbosity = 0;
81
81
 
82
82
  // Create a long lived reporter worker
83
83
  const { Elm } = require("./Reporter.elm.js");
84
84
  const flags = {
85
- initialSeed: 1889275192,
85
+ initialSeed: 2255331163,
86
86
  fuzzRuns: 100,
87
- mode: "consoleColor",
87
+ mode: "consoleNoColor",
88
88
  verbosity: verbosity,
89
89
  globs: [],
90
- paths: ["/Users/dillonkearns/src/github.com/dillonkearns/elm-pages-v3-beta/generator/review/tests/Pages/Review/NoContractViolationsTest.elm"],
90
+ paths: ["/home/runner/work/elm-pages-v3-beta/elm-pages-v3-beta/generator/review/tests/Pages/Review/NoContractViolationsTest.elm"],
91
91
  };
92
92
  reporter = Elm.Reporter.init({ flags: flags });
93
93
 
@@ -17,6 +17,7 @@ const preRenderHtml = require("./pre-render-html.js");
17
17
  const esbuild = require("esbuild");
18
18
  const { createHash } = require("crypto");
19
19
  const { merge_vite_configs } = require("./vite-utils.js");
20
+ const { resolveConfig } = require("./config.js");
20
21
 
21
22
  let pool = [];
22
23
  let pagesReady;
@@ -76,23 +77,12 @@ async function run(options) {
76
77
  const generateCode = codegen.generate(options.base);
77
78
 
78
79
  await generateCode;
80
+
81
+ const config = await resolveConfig();
79
82
  await fsPromises.writeFile(
80
83
  "elm-stuff/elm-pages/index.html",
81
- preRenderHtml.templateHtml()
84
+ preRenderHtml.templateHtml(false, config.headTagsTemplate)
82
85
  );
83
-
84
- const config = await import(
85
- path.join(process.cwd(), "elm-pages.config.mjs")
86
- )
87
- .then(async (elmPagesConfig) => {
88
- return elmPagesConfig.default || {};
89
- })
90
- .catch((error) => {
91
- console.warn(
92
- "No `elm-pages.config.mjs` file found. Using default config."
93
- );
94
- return {};
95
- });
96
86
  const viteConfig = merge_vite_configs(
97
87
  {
98
88
  configFile: false,
@@ -127,10 +117,25 @@ async function run(options) {
127
117
  "dist/elm-stuff/elm-pages/index.html",
128
118
  "utf-8"
129
119
  );
130
- const preloads = `<link rel="modulepreload" href="/${manifest["elm-stuff/elm-pages/index.html"]["file"]}" />`;
120
+ const preloadFiles = [
121
+ `elm.${browserElmHash}.js`,
122
+ ...Object.entries(manifest).map((entry) => entry[1].file),
123
+ ].map((file) => path.join(options.base, file));
124
+ const userProcessedPreloads = preloadFiles.flatMap((file) => {
125
+ const userPreloadForFile = config.preloadTagForFile(file);
126
+ if (userPreloadForFile === true) {
127
+ return [defaultPreloadForFile(file)];
128
+ } else if (userPreloadForFile === false) {
129
+ return [];
130
+ } else if (typeof userPreloadForFile === "string") {
131
+ return [userPreloadForFile];
132
+ } else {
133
+ throw `I expected preloadTagForFile in elm-pages.config.mjs to return a string or boolean, but instead it returned: ${userPreloadForFile}`;
134
+ }
135
+ });
131
136
 
132
137
  const processedIndexTemplate = indexTemplate
133
- .replace("<!-- PLACEHOLDER_PRELOADS -->", preloads)
138
+ .replace("<!-- PLACEHOLDER_PRELOADS -->", userProcessedPreloads.join(""))
134
139
  .replace(
135
140
  '<script defer src="/elm.js" type="text/javascript"></script>',
136
141
  `<script defer src="/elm.${browserElmHash}.js" type="text/javascript"></script>`
@@ -630,6 +635,31 @@ async function runAdapter(adaptFn, processedIndexTemplate) {
630
635
  }
631
636
  }
632
637
 
638
+ // Source: https://github.com/vitejs/vite/blob/c53ffec3465d2d28d08d29ca61313469e03f5dd6/playground/ssr-vue/src/entry-server.js#L50-L68
639
+ /**
640
+ * @param {string} file
641
+ */
642
+ function defaultPreloadForFile(file) {
643
+ if (file.endsWith(".js")) {
644
+ return `<link rel="modulepreload" crossorigin href="${file}">`;
645
+ } else if (file.endsWith(".css")) {
646
+ return `<link rel="preload" href="${file}" as="style">`;
647
+ } else if (file.endsWith(".woff")) {
648
+ return ` <link rel="preload" href="${file}" as="font" type="font/woff" crossorigin>`;
649
+ } else if (file.endsWith(".woff2")) {
650
+ return ` <link rel="preload" href="${file}" as="font" type="font/woff2" crossorigin>`;
651
+ } else if (file.endsWith(".gif")) {
652
+ return ` <link rel="preload" href="${file}" as="image" type="image/gif">`;
653
+ } else if (file.endsWith(".jpg") || file.endsWith(".jpeg")) {
654
+ return ` <link rel="preload" href="${file}" as="image" type="image/jpeg">`;
655
+ } else if (file.endsWith(".png")) {
656
+ return ` <link rel="preload" href="${file}" as="image" type="image/png">`;
657
+ } else {
658
+ // TODO
659
+ return "";
660
+ }
661
+ }
662
+
633
663
  /** @typedef { { route : string; contentJson : string; head : SeoTag[]; html: string; body: string; } } FromElm */
634
664
  /** @typedef {HeadTag | JsonLdTag} SeoTag */
635
665
  /** @typedef {{ name: string; attributes: string[][]; type: 'head' }} HeadTag */
@@ -0,0 +1,41 @@
1
+ const path = require("path");
2
+
3
+ async function resolveConfig() {
4
+ const initialConfig = await await import(
5
+ path.join(process.cwd(), "elm-pages.config.mjs")
6
+ )
7
+ .then(async (elmPagesConfig) => {
8
+ return (
9
+ elmPagesConfig.default || {
10
+ headTagsTemplate: defaultHeadTagsTemplate,
11
+ }
12
+ );
13
+ })
14
+ .catch((error) => {
15
+ console.warn(
16
+ "No `elm-pages.config.mjs` file found. Using default config."
17
+ );
18
+ return {
19
+ headTagsTemplate: defaultHeadTagsTemplate,
20
+ vite: {},
21
+ };
22
+ });
23
+
24
+ return {
25
+ preloadTagForFile: function () {
26
+ return true;
27
+ },
28
+ headTagsTemplate: defaultHeadTagsTemplate,
29
+ vite: {},
30
+ ...initialConfig,
31
+ };
32
+ }
33
+
34
+ function defaultHeadTagsTemplate(context) {
35
+ return `
36
+ <link rel="stylesheet" href="/style.css" />
37
+ <meta name="generator" content="elm-pages v${context.cliVersion}" />
38
+ `;
39
+ }
40
+
41
+ module.exports = { resolveConfig };
@@ -25,6 +25,8 @@ const { createServer: createViteServer } = require("vite");
25
25
  const cliVersion = require("../../package.json").version;
26
26
  const esbuild = require("esbuild");
27
27
  const { merge_vite_configs } = require("./vite-utils.js");
28
+ const { templateHtml } = require("./pre-render-html.js");
29
+ const { resolveConfig } = require("./config.js");
28
30
 
29
31
  /**
30
32
  * @param {{ port: string; base: string; https: boolean; debug: boolean; }} options
@@ -118,20 +120,7 @@ async function start(options) {
118
120
  watcher.add(sourceDirs);
119
121
  }
120
122
 
121
- const viteConfig = await import(
122
- path.join(process.cwd(), "elm-pages.config.mjs")
123
- )
124
- .then(async (elmPagesConfig) => {
125
- return elmPagesConfig.default.vite || {};
126
- })
127
- .catch((error) => {
128
- console.warn(
129
- kleur.yellow(
130
- "No `elm-pages.config.mjs` file found. Using default config."
131
- )
132
- );
133
- return {};
134
- });
123
+ const config = await resolveConfig();
135
124
  const vite = await createViteServer(
136
125
  merge_vite_configs(
137
126
  {
@@ -145,7 +134,7 @@ async function start(options) {
145
134
  base: options.base,
146
135
  },
147
136
 
148
- viteConfig
137
+ config.vite
149
138
  )
150
139
  );
151
140
  esbuild
@@ -469,35 +458,7 @@ async function start(options) {
469
458
  }
470
459
  case "html": {
471
460
  try {
472
- const template =
473
- /*html*/
474
- `<!DOCTYPE html>
475
- <!-- ROOT --><html lang="en">
476
- <head>
477
- <script src="/hmr.js" type="text/javascript"></script>
478
- <script src="/elm.js" type="text/javascript"></script>
479
- <link rel="stylesheet" href="/style.css">
480
- <link rel="stylesheet" href="/dev-style.css">
481
- <script src="/elm-pages.js" type="module"></script>
482
- <meta charset="UTF-8" />
483
- <meta name="viewport" content="width=device-width,initial-scale=1" />
484
- <title><!-- PLACEHOLDER_TITLE --></title>
485
- <meta name="generator" content="elm-pages v${cliVersion}" />
486
- <meta name="mobile-web-app-capable" content="yes" />
487
- <meta name="theme-color" content="#ffffff" />
488
- <meta name="apple-mobile-web-app-capable" content="yes" />
489
- <meta
490
- name="apple-mobile-web-app-status-bar-style"
491
- content="black-translucent"
492
- />
493
- <!-- PLACEHOLDER_HEAD_AND_DATA -->
494
- </head>
495
- <body>
496
- <div data-url="" display="none"></div>
497
- <!-- PLACEHOLDER_HTML -->
498
- </body>
499
- </html>
500
- `;
461
+ const template = templateHtml(true, config.headTagsTemplate);
501
462
  const processedTemplate = await vite.transformIndexHtml(
502
463
  req.originalUrl,
503
464
  template
@@ -17,28 +17,32 @@ function wrapHtml(basePath, fromElm, contentDatPayload) {
17
17
  };
18
18
  }
19
19
 
20
- function templateHtml() {
20
+ /**
21
+ * @param {boolean} devMode
22
+ * @param {(context: {cliVersion: string;}) => string} userHeadTagsTemplate
23
+ */
24
+ function templateHtml(devMode, userHeadTagsTemplate) {
21
25
  return /* html */ `<!DOCTYPE html>
22
26
  <!-- ROOT --><html lang="en">
23
27
  <head>
24
- <!-- PLACEHOLDER_PRELOADS -->
25
- <script defer src="/elm.js" type="text/javascript"></script>
26
- <script defer src="${path.join(
27
- __dirname,
28
- "../static-code/elm-pages.js"
29
- )}" type="module"></script>
30
- <link rel="stylesheet" href="/style.css" />
31
28
  <meta charset="UTF-8" />
32
- <meta name="viewport" content="width=device-width,initial-scale=1" />
33
29
  <title><!-- PLACEHOLDER_TITLE --></title>
34
- <meta name="generator" content="elm-pages v${cliVersion}" />
35
- <meta name="mobile-web-app-capable" content="yes" />
36
- <meta name="theme-color" content="#ffffff" />
37
- <meta name="apple-mobile-web-app-capable" content="yes" />
38
- <meta
39
- name="apple-mobile-web-app-status-bar-style"
40
- content="black-translucent"
41
- />
30
+ ${
31
+ devMode
32
+ ? `<script src="/hmr.js" type="text/javascript"></script>
33
+ <link rel="stylesheet" href="/dev-style.css">`
34
+ : `<!-- PLACEHOLDER_PRELOADS -->`
35
+ }
36
+ <script defer src="/elm.js" type="text/javascript"></script>
37
+ ${
38
+ devMode
39
+ ? `<script src="/elm-pages.js" type="module"></script>`
40
+ : `<script defer src="${path.join(
41
+ __dirname,
42
+ "../static-code/elm-pages.js"
43
+ )}" type="module"></script>`
44
+ }
45
+ ${indent(userHeadTagsTemplate({ cliVersion }))}
42
46
  <!-- PLACEHOLDER_HEAD_AND_DATA -->
43
47
  </head>
44
48
  <body>
@@ -48,6 +52,16 @@ function templateHtml() {
48
52
  </html>`;
49
53
  }
50
54
 
55
+ /**
56
+ * @param {string} snippet
57
+ */
58
+ function indent(snippet) {
59
+ return snippet
60
+ .split("\n")
61
+ .map((line) => ` ${line}`)
62
+ .join("\n");
63
+ }
64
+
51
65
  /**
52
66
  * @param {string} processedTemplate
53
67
  */
@@ -9,7 +9,7 @@ import Route exposing (Route)
9
9
 
10
10
  routes :
11
11
  DataSource (List Route)
12
- -> (Html Never -> String)
12
+ -> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
13
13
  -> List (ApiRoute ApiRoute.Response)
14
14
  routes getStaticRoutes htmlToString =
15
15
  []
@@ -14,6 +14,11 @@ config =
14
14
 
15
15
  head : DataSource (List Head.Tag)
16
16
  head =
17
- [ Head.sitemapLink "/sitemap.xml"
17
+ [ Head.metaName "viewport" (Head.raw "width=device-width,initial-scale=1")
18
+ , Head.metaName "mobile-web-app-capable" (Head.raw "yes")
19
+ , Head.metaName "theme-color" (Head.raw "#ffffff")
20
+ , Head.metaName "apple-mobile-web-app-capable" (Head.raw "yes")
21
+ , Head.metaName "apple-mobile-web-app-status-bar-style" (Head.raw "black-translucent")
22
+ , Head.sitemapLink "/sitemap.xml"
18
23
  ]
19
24
  |> DataSource.succeed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elm-pages",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.0-beta.8",
4
4
  "homepage": "https://elm-pages.com",
5
5
  "moduleResolution": "node",
6
6
  "description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
@@ -123,16 +123,16 @@ A common use for this is to map your data into your elm-pages view:
123
123
  map : (a -> b) -> DataSource a -> DataSource b
124
124
  map fn requestInfo =
125
125
  case requestInfo of
126
- RequestError error ->
127
- RequestError error
126
+ ApiRoute value ->
127
+ ApiRoute (fn value)
128
128
 
129
129
  Request urls lookupFn ->
130
130
  Request
131
131
  urls
132
132
  (mapLookupFn fn lookupFn)
133
133
 
134
- ApiRoute value ->
135
- ApiRoute (fn value)
134
+ RequestError error ->
135
+ RequestError error
136
136
 
137
137
 
138
138
  mapLookupFn : (a -> b) -> (d -> c -> DataSource a) -> d -> c -> DataSource b
@@ -182,8 +182,8 @@ resolve =
182
182
 
183
183
  -}
184
184
  combine : List (DataSource value) -> DataSource (List value)
185
- combine =
186
- List.foldr (map2 (::)) (succeed [])
185
+ combine items =
186
+ List.foldl (map2 (::)) (succeed []) items |> map List.reverse
187
187
 
188
188
 
189
189
  {-| Like map, but it takes in two `Request`s.
@@ -212,11 +212,8 @@ combine =
212
212
  map2 : (a -> b -> c) -> DataSource a -> DataSource b -> DataSource c
213
213
  map2 fn request1 request2 =
214
214
  case ( request1, request2 ) of
215
- ( RequestError error, _ ) ->
216
- RequestError error
217
-
218
- ( _, RequestError error ) ->
219
- RequestError error
215
+ ( ApiRoute value1, ApiRoute value2 ) ->
216
+ ApiRoute (fn value1 value2)
220
217
 
221
218
  ( Request urls1 lookupFn1, Request urls2 lookupFn2 ) ->
222
219
  Request
@@ -233,8 +230,11 @@ map2 fn request1 request2 =
233
230
  urls1
234
231
  (mapReq fn (\_ _ -> ApiRoute value2) lookupFn1)
235
232
 
236
- ( ApiRoute value1, ApiRoute value2 ) ->
237
- ApiRoute (fn value1 value2)
233
+ ( RequestError error, _ ) ->
234
+ RequestError error
235
+
236
+ ( _, RequestError error ) ->
237
+ RequestError error
238
238
 
239
239
 
240
240
  mapReq : (a -> b -> c) -> (e -> d -> DataSource a) -> (e -> d -> DataSource b) -> e -> d -> DataSource c
@@ -247,9 +247,6 @@ mapReq fn lookupFn1 lookupFn2 maybeMock rawResponses =
247
247
  lookup : Maybe Pages.StaticHttpRequest.MockResolver -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error value
248
248
  lookup maybeMockResolver requestInfo rawResponses =
249
249
  case requestInfo of
250
- RequestError error ->
251
- Err error
252
-
253
250
  Request urls lookupFn ->
254
251
  lookup maybeMockResolver
255
252
  (addUrls urls (lookupFn maybeMockResolver rawResponses))
@@ -258,18 +255,21 @@ lookup maybeMockResolver requestInfo rawResponses =
258
255
  ApiRoute value ->
259
256
  Ok value
260
257
 
258
+ RequestError error ->
259
+ Err error
260
+
261
261
 
262
262
  addUrls : List HashRequest.Request -> DataSource value -> DataSource value
263
263
  addUrls urlsToAdd requestInfo =
264
264
  case requestInfo of
265
- RequestError error ->
266
- RequestError error
265
+ ApiRoute value ->
266
+ ApiRoute value
267
267
 
268
268
  Request initialUrls function ->
269
269
  Request (initialUrls ++ urlsToAdd) function
270
270
 
271
- ApiRoute value ->
272
- ApiRoute value
271
+ RequestError error ->
272
+ RequestError error
273
273
 
274
274
 
275
275
  {-| The full details to perform a StaticHttp request.
@@ -286,14 +286,14 @@ type alias RequestDetails =
286
286
  lookupUrls : DataSource value -> List RequestDetails
287
287
  lookupUrls requestInfo =
288
288
  case requestInfo of
289
- RequestError _ ->
290
- -- TODO should this have URLs passed through?
289
+ ApiRoute _ ->
291
290
  []
292
291
 
293
292
  Request urls _ ->
294
293
  urls
295
294
 
296
- ApiRoute _ ->
295
+ RequestError _ ->
296
+ -- TODO should this have URLs passed through?
297
297
  []
298
298
 
299
299
 
@@ -324,19 +324,19 @@ andThen fn requestInfo =
324
324
  rawResponses
325
325
  |> (\result ->
326
326
  case result of
327
- Err error ->
328
- RequestError error
329
-
330
327
  Ok value ->
331
328
  case fn value of
329
+ ApiRoute finalValue ->
330
+ ApiRoute finalValue
331
+
332
332
  Request values function ->
333
333
  Request values function
334
334
 
335
335
  RequestError error ->
336
336
  RequestError error
337
337
 
338
- ApiRoute finalValue ->
339
- ApiRoute finalValue
338
+ Err error ->
339
+ RequestError error
340
340
  )
341
341
  )
342
342
 
@@ -8,15 +8,19 @@ import Test.Html.Internal.ElmHtml.ToString exposing (defaultFormatOptions, nodeT
8
8
  import VirtualDom
9
9
 
10
10
 
11
- htmlToString : Html msg -> String
12
- htmlToString viewHtml =
11
+ htmlToString : Maybe { indent : Int, newLines : Bool } -> Html msg -> String
12
+ htmlToString formatOptions viewHtml =
13
13
  case
14
14
  Decode.decodeValue
15
15
  (decodeElmHtml (\_ _ -> VirtualDom.Normal (Decode.succeed ())))
16
16
  (asJsonView viewHtml)
17
17
  of
18
18
  Ok str ->
19
- nodeToStringWithOptions defaultFormatOptions str
19
+ nodeToStringWithOptions
20
+ (formatOptions
21
+ |> Maybe.withDefault defaultFormatOptions
22
+ )
23
+ str
20
24
 
21
25
  Err err ->
22
26
  "Error pre-rendering HTML in HtmlPrinter.elm: " ++ Decode.errorToString err
@@ -880,7 +880,7 @@ sendSinglePageProgress site contentJson config model info =
880
880
  , headers = record.headers
881
881
  }
882
882
  { head = config.view Dict.empty Dict.empty Nothing currentPage Nothing sharedData pageData Nothing |> .head
883
- , view = viewValue.body |> List.map HtmlPrinter.htmlToString |> String.join "\n"
883
+ , view = viewValue.body |> List.map (HtmlPrinter.htmlToString Nothing) |> String.join "\n"
884
884
  , title = viewValue.title
885
885
  }
886
886
  )
@@ -1221,7 +1221,7 @@ render404Page config sharedData model path notFoundReason =
1221
1221
 
1222
1222
  bodyToString : List (Html msg) -> String
1223
1223
  bodyToString body =
1224
- body |> List.map HtmlPrinter.htmlToString |> String.join "\n"
1224
+ body |> List.map (HtmlPrinter.htmlToString Nothing) |> String.join "\n"
1225
1225
 
1226
1226
 
1227
1227
  urlToRoute : ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage -> Url -> route
@@ -88,7 +88,10 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
88
88
  }
89
89
  -> userMsg
90
90
  , apiRoutes :
91
- (Html Never -> String)
91
+ (Maybe { indent : Int, newLines : Bool }
92
+ -> Html Never
93
+ -> String
94
+ )
92
95
  -> List (ApiRoute.ApiRoute ApiRoute.Response)
93
96
  , pathPatterns : List RoutePattern
94
97
  , basePath : List String
@@ -98,7 +101,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
98
101
  , encodeResponse : ResponseSketch pageData actionData sharedData -> Bytes.Encode.Encoder
99
102
  , encodeAction : actionData -> Bytes.Encode.Encoder
100
103
  , decodeResponse : Bytes.Decode.Decoder (ResponseSketch pageData actionData sharedData)
101
- , globalHeadTags : Maybe ((Html Never -> String) -> DataSource (List Head.Tag))
104
+ , globalHeadTags : Maybe ((Maybe { indent : Int, newLines : Bool } -> Html Never -> String) -> DataSource (List Head.Tag))
102
105
  , cmdToEffect : Cmd userMsg -> effect
103
106
  , perform :
104
107
  { fetchRouteData :