elm-pages 2.1.9 → 2.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,7 @@ import Pages.Internal.Platform.StaticResponses as StaticResponses exposing (Stat
30
30
  import Pages.Internal.Platform.ToJsPayload as ToJsPayload
31
31
  import Pages.Internal.StaticHttpBody as StaticHttpBody
32
32
  import Pages.ProgramConfig exposing (ProgramConfig)
33
+ import Pages.SiteConfig exposing (SiteConfig)
33
34
  import Pages.StaticHttp.Request
34
35
  import Pages.StaticHttpRequest as StaticHttpRequest
35
36
  import Path exposing (Path)
@@ -85,6 +86,19 @@ cliApplication config =
85
86
  contentCache : ContentCache
86
87
  contentCache =
87
88
  ContentCache.init Nothing
89
+
90
+ site : SiteConfig siteData
91
+ site =
92
+ getSiteConfig config
93
+
94
+ getSiteConfig : ProgramConfig userMsg userModel (Maybe route) siteData pageData sharedData -> SiteConfig siteData
95
+ getSiteConfig fullConfig =
96
+ case fullConfig.site of
97
+ Just mySite ->
98
+ mySite
99
+
100
+ Nothing ->
101
+ getSiteConfig fullConfig
88
102
  in
89
103
  Platform.worker
90
104
  { init =
@@ -95,12 +109,12 @@ cliApplication config =
95
109
  Decode.decodeValue (RenderRequest.decoder config) flags
96
110
  |> Result.withDefault RenderRequest.default
97
111
  in
98
- init renderRequest contentCache config flags
99
- |> Tuple.mapSecond (perform renderRequest config config.toJsPort)
112
+ init site renderRequest contentCache config flags
113
+ |> Tuple.mapSecond (perform site renderRequest config config.toJsPort)
100
114
  , update =
101
115
  \msg model ->
102
- update contentCache config msg model
103
- |> Tuple.mapSecond (perform model.maybeRequestJson config config.toJsPort)
116
+ update site contentCache config msg model
117
+ |> Tuple.mapSecond (perform site model.maybeRequestJson config config.toJsPort)
104
118
  , subscriptions =
105
119
  \_ ->
106
120
  config.fromJsPort
@@ -189,17 +203,18 @@ gotPortDecoder =
189
203
 
190
204
 
191
205
  perform :
192
- RenderRequest route
206
+ SiteConfig siteData
207
+ -> RenderRequest route
193
208
  -> ProgramConfig userMsg userModel route siteData pageData sharedData
194
209
  -> (Codec.Value -> Cmd Never)
195
210
  -> Effect
196
211
  -> Cmd Msg
197
- perform renderRequest config toJsPort effect =
212
+ perform site renderRequest config toJsPort effect =
198
213
  -- elm-review: known-unoptimized-recursion
199
214
  let
200
215
  canonicalSiteUrl : String
201
216
  canonicalSiteUrl =
202
- config.site.canonicalUrl
217
+ site.canonicalUrl
203
218
  in
204
219
  case effect of
205
220
  Effect.NoEffect ->
@@ -207,7 +222,7 @@ perform renderRequest config toJsPort effect =
207
222
 
208
223
  Effect.Batch list ->
209
224
  list
210
- |> List.map (perform renderRequest config toJsPort)
225
+ |> List.map (perform site renderRequest config toJsPort)
211
226
  |> Cmd.batch
212
227
 
213
228
  Effect.FetchHttp ({ unmasked, masked } as requests) ->
@@ -355,18 +370,20 @@ flagsDecoder =
355
370
 
356
371
  {-| -}
357
372
  init :
358
- RenderRequest route
373
+ SiteConfig siteData
374
+ -> RenderRequest route
359
375
  -> ContentCache
360
376
  -> ProgramConfig userMsg userModel route siteData pageData sharedData
361
377
  -> Decode.Value
362
378
  -> ( Model route, Effect )
363
- init renderRequest contentCache config flags =
379
+ init site renderRequest contentCache config flags =
364
380
  case Decode.decodeValue flagsDecoder flags of
365
381
  Ok { secrets, staticHttpCache, isDevServer } ->
366
- initLegacy renderRequest { secrets = secrets, staticHttpCache = staticHttpCache, isDevServer = isDevServer } contentCache config flags
382
+ initLegacy site renderRequest { secrets = secrets, staticHttpCache = staticHttpCache, isDevServer = isDevServer } contentCache config flags
367
383
 
368
384
  Err error ->
369
385
  updateAndSendPortIfDone
386
+ site
370
387
  contentCache
371
388
  config
372
389
  { staticResponses = StaticResponses.error
@@ -388,13 +405,14 @@ init renderRequest contentCache config flags =
388
405
 
389
406
 
390
407
  initLegacy :
391
- RenderRequest route
408
+ SiteConfig siteData
409
+ -> RenderRequest route
392
410
  -> { secrets : SecretsDict, staticHttpCache : Dict String (Maybe String), isDevServer : Bool }
393
411
  -> ContentCache
394
412
  -> ProgramConfig userMsg userModel route siteData pageData sharedData
395
413
  -> Decode.Value
396
414
  -> ( Model route, Effect )
397
- initLegacy renderRequest { secrets, staticHttpCache, isDevServer } contentCache config flags =
415
+ initLegacy site renderRequest { secrets, staticHttpCache, isDevServer } contentCache config flags =
398
416
  let
399
417
  staticResponses : StaticResponses
400
418
  staticResponses =
@@ -465,32 +483,35 @@ initLegacy renderRequest { secrets, staticHttpCache, isDevServer } contentCache
465
483
  }
466
484
  in
467
485
  StaticResponses.nextStep config initialModel Nothing
468
- |> nextStepToEffect contentCache
486
+ |> nextStepToEffect site
487
+ contentCache
469
488
  config
470
489
  initialModel
471
490
 
472
491
 
473
492
  updateAndSendPortIfDone :
474
- ContentCache
493
+ SiteConfig siteData
494
+ -> ContentCache
475
495
  -> ProgramConfig userMsg userModel route siteData pageData sharedData
476
496
  -> Model route
477
497
  -> ( Model route, Effect )
478
- updateAndSendPortIfDone contentCache config model =
498
+ updateAndSendPortIfDone site contentCache config model =
479
499
  StaticResponses.nextStep
480
500
  config
481
501
  model
482
502
  Nothing
483
- |> nextStepToEffect contentCache config model
503
+ |> nextStepToEffect site contentCache config model
484
504
 
485
505
 
486
506
  {-| -}
487
507
  update :
488
- ContentCache
508
+ SiteConfig siteData
509
+ -> ContentCache
489
510
  -> ProgramConfig userMsg userModel route siteData pageData sharedData
490
511
  -> Msg
491
512
  -> Model route
492
513
  -> ( Model route, Effect )
493
- update contentCache config msg model =
514
+ update site contentCache config msg model =
494
515
  case msg of
495
516
  GotDataBatch batch ->
496
517
  let
@@ -517,7 +538,7 @@ update contentCache config msg model =
517
538
  StaticResponses.nextStep config
518
539
  updatedModel
519
540
  Nothing
520
- |> nextStepToEffect contentCache config updatedModel
541
+ |> nextStepToEffect site contentCache config updatedModel
521
542
 
522
543
  Continue ->
523
544
  let
@@ -528,7 +549,7 @@ update contentCache config msg model =
528
549
  StaticResponses.nextStep config
529
550
  updatedModel
530
551
  Nothing
531
- |> nextStepToEffect contentCache config updatedModel
552
+ |> nextStepToEffect site contentCache config updatedModel
532
553
 
533
554
  GotBuildError buildError ->
534
555
  let
@@ -542,16 +563,17 @@ update contentCache config msg model =
542
563
  StaticResponses.nextStep config
543
564
  updatedModel
544
565
  Nothing
545
- |> nextStepToEffect contentCache config updatedModel
566
+ |> nextStepToEffect site contentCache config updatedModel
546
567
 
547
568
 
548
569
  nextStepToEffect :
549
- ContentCache
570
+ SiteConfig siteData
571
+ -> ContentCache
550
572
  -> ProgramConfig userMsg userModel route siteData pageData sharedData
551
573
  -> Model route
552
574
  -> ( StaticResponses, StaticResponses.NextStep route )
553
575
  -> ( Model route, Effect )
554
- nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextStep ) =
576
+ nextStepToEffect site contentCache config model ( updatedStaticResponsesModel, nextStep ) =
555
577
  case nextStep of
556
578
  StaticResponses.Continue updatedAllRawResponses httpRequests maybeRoutes ->
557
579
  let
@@ -609,7 +631,8 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
609
631
  }
610
632
  in
611
633
  if List.isEmpty doNow && updatedRoutes /= model.staticRoutes then
612
- nextStepToEffect contentCache
634
+ nextStepToEffect site
635
+ contentCache
613
636
  config
614
637
  updatedModel
615
638
  (StaticResponses.nextStep config
@@ -688,7 +711,7 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
688
711
  currentUrl : Url.Url
689
712
  currentUrl =
690
713
  { protocol = Url.Https
691
- , host = config.site.canonicalUrl
714
+ , host = site.canonicalUrl
692
715
  , port_ = Nothing
693
716
  , path = payload.path |> Path.toRelative
694
717
  , query = Nothing
@@ -767,7 +790,7 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
767
790
  siteDataResult : Result BuildError siteData
768
791
  siteDataResult =
769
792
  StaticHttpRequest.resolve ApplicationType.Cli
770
- config.site.data
793
+ site.data
771
794
  (staticData |> Dict.map (\_ v -> Just v))
772
795
  |> Result.mapError (StaticHttpRequest.toBuildError "Site.elm")
773
796
  in
@@ -809,7 +832,7 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
809
832
  case model.unprocessedPages |> List.head of
810
833
  Just pageAndMetadata ->
811
834
  ( model
812
- , sendSinglePageProgress contentJson config model pageAndMetadata
835
+ , sendSinglePageProgress site contentJson config model pageAndMetadata
813
836
  )
814
837
 
815
838
  Nothing ->
@@ -824,12 +847,13 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
824
847
 
825
848
 
826
849
  sendSinglePageProgress :
827
- Dict String String
850
+ SiteConfig siteData
851
+ -> Dict String String
828
852
  -> ProgramConfig userMsg userModel route siteData pageData sharedData
829
853
  -> Model route
830
854
  -> ( Path, route )
831
855
  -> Effect
832
- sendSinglePageProgress contentJson config model =
856
+ sendSinglePageProgress site contentJson config model =
833
857
  \( page, route ) ->
834
858
  case model.maybeRequestJson of
835
859
  RenderRequest.SinglePage includeHtml _ _ ->
@@ -893,7 +917,7 @@ sendSinglePageProgress contentJson config model =
893
917
  currentUrl : Url.Url
894
918
  currentUrl =
895
919
  { protocol = Url.Https
896
- , host = config.site.canonicalUrl
920
+ , host = site.canonicalUrl
897
921
  , port_ = Nothing
898
922
  , path = page |> Path.toRelative
899
923
  , query = Nothing
@@ -921,7 +945,7 @@ sendSinglePageProgress contentJson config model =
921
945
  siteDataResult : Result BuildError siteData
922
946
  siteDataResult =
923
947
  StaticHttpRequest.resolve ApplicationType.Cli
924
- config.site.data
948
+ site.data
925
949
  (contentJson |> Dict.map (\_ v -> Just v))
926
950
  |> Result.mapError (StaticHttpRequest.toBuildError "Site.elm")
927
951
  in
@@ -933,7 +957,7 @@ sendSinglePageProgress contentJson config model =
933
957
  , contentJson = contentJson
934
958
  , html = rendered.view
935
959
  , errors = []
936
- , head = rendered.head ++ config.site.head siteData
960
+ , head = rendered.head ++ site.head siteData
937
961
  , title = rendered.title
938
962
  , staticHttpCache = model.allRawResponses |> Dict.Extra.filterMap (\_ v -> v)
939
963
  , is404 = False
@@ -189,7 +189,7 @@ nextStep :
189
189
  , routeToPath : route -> List String
190
190
  , data : route -> DataSource pageData
191
191
  , sharedData : DataSource sharedData
192
- , site : SiteConfig siteData
192
+ , site : Maybe (SiteConfig siteData)
193
193
  , apiRoutes : (Html Never -> String) -> List (ApiRoute.ApiRoute ApiRoute.Response)
194
194
  }
195
195
  ->
@@ -52,7 +52,7 @@ type alias ProgramConfig userMsg userModel route siteData pageData sharedData =
52
52
  , getStaticRoutes : DataSource.DataSource (List route)
53
53
  , urlToRoute : Url -> route
54
54
  , routeToPath : route -> List String
55
- , site : SiteConfig siteData
55
+ , site : Maybe (SiteConfig siteData)
56
56
  , toJsPort : Json.Encode.Value -> Cmd Never
57
57
  , fromJsPort : Sub Decode.Value
58
58
  , onPageChange :
@@ -12,7 +12,6 @@ import Elm.Syntax.Exposing as Exposing exposing (Exposing)
12
12
  import Elm.Syntax.Module as Module exposing (Module)
13
13
  import Elm.Syntax.Node as Node exposing (Node)
14
14
  import Elm.Syntax.TypeAnnotation as TypeAnnotation exposing (TypeAnnotation)
15
- import Result.Extra
16
15
  import Review.Rule as Rule exposing (Direction, Error, Rule)
17
16
  import Set exposing (Set)
18
17
 
@@ -69,7 +68,7 @@ type alias Context =
69
68
 
70
69
 
71
70
  moduleDefinitionVisitor : Node Module -> Context -> ( List (Error {}), Context )
72
- moduleDefinitionVisitor node context =
71
+ moduleDefinitionVisitor node _ =
73
72
  let
74
73
  isPageModule : Bool
75
74
  isPageModule =
@@ -137,7 +136,7 @@ routeParamsMatchesNameOrError annotation moduleName =
137
136
  expectedFields =
138
137
  expectedRouteParamsFromModuleName moduleName
139
138
  in
140
- if actualStringFields == (expectedFields |> Dict.map (\key value -> Ok value)) then
139
+ if actualStringFields == (expectedFields |> Dict.map (\_ value -> Ok value)) then
141
140
  []
142
141
 
143
142
  else
@@ -348,7 +347,7 @@ isString typeAnnotation =
348
347
  declarationVisitor : Node Declaration -> Direction -> Context -> ( List (Error {}), Context )
349
348
  declarationVisitor node direction context =
350
349
  case ( direction, Node.value node ) of
351
- ( Rule.OnEnter, Declaration.AliasDeclaration { name, generics, typeAnnotation } ) ->
350
+ ( Rule.OnEnter, Declaration.AliasDeclaration { name, typeAnnotation } ) ->
352
351
  -- TODO check that generics is empty
353
352
  if context.isPageModule && Node.value name == "RouteParams" then
354
353
  ( routeParamsMatchesNameOrError typeAnnotation context.moduleName
@@ -375,7 +374,7 @@ getExposedName exposedValue =
375
374
  Exposing.FunctionExpose name ->
376
375
  Just name
377
376
 
378
- Exposing.InfixExpose string ->
377
+ Exposing.InfixExpose _ ->
379
378
  Nothing
380
379
 
381
380
  Exposing.TypeOrAliasExpose name ->
@@ -57,6 +57,8 @@ type alias Value value =
57
57
  {-| Hardcode a secret value. Or, this can be used to start a pipeline-style value with several different secrets (see
58
58
  the example at the top of this page).
59
59
 
60
+ Warning: a hardcoded value is not protected by masking! Make sure to to use `Secrets.with` to fetch sentitive values from environment variables.
61
+
60
62
  import Pages.Secrets as Secrets
61
63
 
62
64
  Secrets.succeed "hardcoded-secret"
@@ -1,12 +1,23 @@
1
- module ElmHtml.Constants exposing (styleKey, eventKey, attributeKey, attributeNamespaceKey, knownKeys)
1
+ module Test.Html.Internal.ElmHtml.Constants exposing
2
+ ( propKey, styleKey, eventKey, attributeKey, attributeNamespaceKey
3
+ , knownKeys
4
+ )
2
5
 
3
6
  {-| Constants for representing internal keys for Elm's vdom implementation
4
7
 
5
- @docs styleKey, eventKey, attributeKey, attributeNamespaceKey, knownKeys
8
+ @docs propKey, styleKey, eventKey, attributeKey, attributeNamespaceKey
9
+ @docs knownKeys
6
10
 
7
11
  -}
8
12
 
9
13
 
14
+ {-| Internal key for attribute properties
15
+ -}
16
+ propKey : String
17
+ propKey =
18
+ "a2"
19
+
20
+
10
21
  {-| Internal key for style
11
22
  -}
12
23
  styleKey : String
@@ -14,26 +25,21 @@ styleKey =
14
25
  "a1"
15
26
 
16
27
 
17
- {-| Internal key for 'on' events
28
+ {-| Internal key for style
18
29
  -}
19
30
  eventKey : String
20
31
  eventKey =
21
32
  "a0"
22
33
 
23
34
 
24
- propertyKey : String
25
- propertyKey =
26
- "a2"
27
-
28
-
29
- {-| Internal key for attributes
35
+ {-| Internal key for style
30
36
  -}
31
37
  attributeKey : String
32
38
  attributeKey =
33
39
  "a3"
34
40
 
35
41
 
36
- {-| Internal key for namespaced attributes
42
+ {-| Internal key for style
37
43
  -}
38
44
  attributeNamespaceKey : String
39
45
  attributeNamespaceKey =
@@ -1,4 +1,4 @@
1
- module ElmHtml.Helpers exposing (filterKnownKeys)
1
+ module Test.Html.Internal.ElmHtml.Helpers exposing (filterKnownKeys)
2
2
 
3
3
  {-| Internal helpers for ElmHtml
4
4
 
@@ -7,7 +7,7 @@ module ElmHtml.Helpers exposing (filterKnownKeys)
7
7
  -}
8
8
 
9
9
  import Dict exposing (Dict)
10
- import ElmHtml.Constants exposing (..)
10
+ import Test.Html.Internal.ElmHtml.Constants exposing (knownKeys)
11
11
 
12
12
 
13
13
  {-| Filter out keys that we don't know