mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 05:13:24 +03:00
Expose some internal modules that are needed in generated code.
This commit is contained in:
parent
041b78bb73
commit
a63dd1b09d
5
elm.json
5
elm.json
@ -25,7 +25,10 @@
|
||||
"Pages.Manifest.Category",
|
||||
"Pages.Flags",
|
||||
"Pages.Internal.Platform",
|
||||
"Pages.Internal.Platform.Cli"
|
||||
"Pages.Internal.Platform.Cli",
|
||||
"Router",
|
||||
"RoutePattern",
|
||||
"NotFoundReason"
|
||||
],
|
||||
"elm-version": "0.19.0 <= v < 0.20.0",
|
||||
"dependencies": {
|
||||
|
@ -1,4 +1,13 @@
|
||||
module NotFoundReason exposing (NotFoundReason(..), Payload, codec, document)
|
||||
module NotFoundReason exposing
|
||||
( codec, ModuleContext, Payload, Record, document
|
||||
, NotFoundReason(..)
|
||||
)
|
||||
|
||||
{-| Exposed for internal use only (used in generated code).
|
||||
|
||||
@docs codec, ModuleContext, NotFoundReason, Payload, Record, document
|
||||
|
||||
-}
|
||||
|
||||
import Codec exposing (Codec)
|
||||
import Html exposing (Html)
|
||||
@ -7,6 +16,7 @@ import Path exposing (Path)
|
||||
import RoutePattern exposing (RoutePattern)
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias ModuleContext =
|
||||
{ moduleName : List String
|
||||
, routePattern : RoutePattern
|
||||
@ -14,16 +24,19 @@ type alias ModuleContext =
|
||||
}
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias Payload =
|
||||
{ path : Path
|
||||
, reason : NotFoundReason
|
||||
}
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias Record =
|
||||
List ( String, String )
|
||||
|
||||
|
||||
{-| -}
|
||||
type NotFoundReason
|
||||
= NoMatchingRoute
|
||||
| NotPrerendered ModuleContext (List Record)
|
||||
@ -31,6 +44,7 @@ type NotFoundReason
|
||||
| UnhandledServerRoute ModuleContext
|
||||
|
||||
|
||||
{-| -}
|
||||
document :
|
||||
List RoutePattern
|
||||
-> Payload
|
||||
@ -176,6 +190,7 @@ prerenderedOptionsView moduleContext routes =
|
||||
]
|
||||
|
||||
|
||||
{-| -}
|
||||
codec : Codec Payload
|
||||
codec =
|
||||
Codec.object Payload
|
||||
|
@ -1,32 +1,36 @@
|
||||
module RoutePattern exposing
|
||||
( Ending(..)
|
||||
, RoutePattern
|
||||
, Segment(..)
|
||||
, codec
|
||||
, view
|
||||
)
|
||||
module RoutePattern exposing (Ending(..), RoutePattern, Segment(..), codec, view)
|
||||
|
||||
{-| Exposed for internal use only (used in generated code).
|
||||
|
||||
@docs Ending, RoutePattern, Segment, codec, view
|
||||
|
||||
-}
|
||||
|
||||
import Codec exposing (Codec)
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias RoutePattern =
|
||||
{ segments : List Segment
|
||||
, ending : Maybe Ending
|
||||
}
|
||||
|
||||
|
||||
{-| -}
|
||||
type Ending
|
||||
= Optional String
|
||||
| RequiredSplat
|
||||
| OptionalSplat
|
||||
|
||||
|
||||
{-| -}
|
||||
type Segment
|
||||
= StaticSegment String
|
||||
| DynamicSegment String
|
||||
|
||||
|
||||
{-| -}
|
||||
codec : Codec RoutePattern
|
||||
codec =
|
||||
Codec.object RoutePattern
|
||||
@ -87,6 +91,7 @@ type alias ModuleContext =
|
||||
}
|
||||
|
||||
|
||||
{-| -}
|
||||
view : RoutePattern -> Html msg
|
||||
view routePattern =
|
||||
Html.span []
|
||||
|
@ -1,9 +1,16 @@
|
||||
module Router exposing (Matcher, firstMatch, fromOptionalSplat, maybeToList, nonEmptyToList, toNonEmpty)
|
||||
|
||||
{-| Exposed for internal use only (used in generated code).
|
||||
|
||||
@docs Matcher, firstMatch, fromOptionalSplat, maybeToList, nonEmptyToList, toNonEmpty
|
||||
|
||||
-}
|
||||
|
||||
import List.Extra
|
||||
import Regex
|
||||
|
||||
|
||||
{-| -}
|
||||
firstMatch : List (Matcher route) -> String -> Maybe route
|
||||
firstMatch matchers path =
|
||||
List.Extra.findMap
|
||||
@ -23,11 +30,13 @@ toRegex pattern =
|
||||
|> Maybe.withDefault Regex.never
|
||||
|
||||
|
||||
{-| -}
|
||||
nonEmptyToList : ( String, List String ) -> List String
|
||||
nonEmptyToList ( string, strings ) =
|
||||
string :: strings
|
||||
|
||||
|
||||
{-| -}
|
||||
fromOptionalSplat : Maybe String -> List String
|
||||
fromOptionalSplat maybeMatch =
|
||||
maybeMatch
|
||||
@ -36,6 +45,7 @@ fromOptionalSplat maybeMatch =
|
||||
|> Maybe.withDefault []
|
||||
|
||||
|
||||
{-| -}
|
||||
maybeToList : Maybe String -> List String
|
||||
maybeToList maybeString =
|
||||
case maybeString of
|
||||
@ -46,6 +56,7 @@ maybeToList maybeString =
|
||||
[]
|
||||
|
||||
|
||||
{-| -}
|
||||
toNonEmpty : String -> ( String, List String )
|
||||
toNonEmpty string =
|
||||
case string |> String.split "/" of
|
||||
@ -56,10 +67,12 @@ toNonEmpty string =
|
||||
( first, rest )
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias Matcher route =
|
||||
{ pattern : String, toRoute : List (Maybe String) -> Maybe route }
|
||||
|
||||
|
||||
{-| -}
|
||||
tryMatch : { pattern : String, toRoute : List (Maybe String) -> Maybe route } -> String -> Maybe route
|
||||
tryMatch { pattern, toRoute } path =
|
||||
path
|
||||
|
Loading…
Reference in New Issue
Block a user