diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 456e8b5eb..a07ffabf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,12 +83,12 @@ jobs: wait-on: "http://localhost:1234" wait-on-timeout: 120 - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-screenshots path: cypress/screenshots - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-videos diff --git a/CHANGELOG-ELM.md b/CHANGELOG-ELM.md index c05cacfd8..94569cbc6 100644 --- a/CHANGELOG-ELM.md +++ b/CHANGELOG-ELM.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Changed +- Updated version constraint so users now need to use "mdgriffith/elm-codegen": "5.0.0 <= v < 6.0.0" (be sure to update your `scripts/elm.json` as well!) + ## [10.1.0] - 2024-04-28 ### Added diff --git a/codegen/Elm/Extra.elm b/codegen/Elm/Extra.elm deleted file mode 100644 index d885cad2e..000000000 --- a/codegen/Elm/Extra.elm +++ /dev/null @@ -1,48 +0,0 @@ -module Elm.Extra exposing (expose, fnIgnore, topLevelValue) - -import Elm -import Elm.Declare - - -topLevelValue : - String - -> Elm.Expression - -> - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } -topLevelValue name expression = - let - declaration_ : - { declaration : Elm.Declaration - , call : List Elm.Expression -> Elm.Expression - , callFrom : List String -> List Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } - declaration_ = - Elm.Declare.function name - [] - (\_ -> expression) - in - { declaration = declaration_.declaration - , reference = declaration_.call [] - , referenceFrom = \from -> declaration_.callFrom from [] - } - - -expose : Elm.Declaration -> Elm.Declaration -expose declaration = - declaration - |> Elm.exposeWith - { exposeConstructor = True - , group = Nothing - } - - -fnIgnore : Elm.Expression -> Elm.Expression -fnIgnore expression = - Elm.fn ( "_", Nothing ) - (\_ -> - expression - ) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index c318d8f5d..e29fa0e3b 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -4,10 +4,10 @@ port module Generate exposing (main) import Elm exposing (File) import Elm.Annotation +import Elm.Arg import Elm.Case import Elm.CodeGen import Elm.Declare -import Elm.Extra exposing (topLevelValue) import Elm.Op import Elm.Pretty import Gen.Basics @@ -64,43 +64,43 @@ file templates basePath = templates |> List.filterMap RoutePattern.fromModuleName - segmentsToRouteFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + segmentsToRouteFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression) segmentsToRouteFn = segmentsToRoute routes - routeToPathFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + routeToPathFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression) routeToPathFn = - routeToPath routes + routeToPath routeType routes - toPath : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + toPath : Elm.Declare.Function (Elm.Expression -> Elm.Expression) toPath = Elm.Declare.fn "toPath" - ( "route", Elm.Annotation.named [] "Route" |> Just ) + (Elm.Arg.varWith "route" routeType.annotation) (\route -> Gen.UrlPath.call_.fromString (Gen.String.call_.join (Elm.string "/") (Elm.Op.append - baseUrlAsPath.reference + baseUrlAsPath.value (routeToPathFn.call route) ) ) |> Elm.withType (Elm.Annotation.named [ "UrlPath" ] "UrlPath") ) - baseUrlAsPath : { declaration : Elm.Declaration, reference : Elm.Expression, referenceFrom : List String -> Elm.Expression } + baseUrlAsPath : Elm.Declare.Value baseUrlAsPath = - topLevelValue + Elm.Declare.value "baseUrlAsPath" (Gen.List.call_.filter - (Elm.fn ( "item", Nothing ) + (Elm.fn (Elm.Arg.var "item") (\item -> Gen.Basics.call_.not (Gen.String.call_.isEmpty item) ) ) (Gen.String.call_.split (Elm.string "/") - baseUrl.reference + baseUrl.value ) ) @@ -108,44 +108,43 @@ file templates basePath = urlToRoute = Elm.declaration "urlToRoute" (Elm.fn - ( "url" - , Elm.Annotation.extensible "url" [ ( "path", Elm.Annotation.string ) ] - |> Just + (Elm.Arg.varWith "url" + (Elm.Annotation.extensible "url" [ ( "path", Elm.Annotation.string ) ]) ) (\url -> segmentsToRouteFn.call (splitPath.call (url |> Elm.get "path") ) - |> Elm.withType (Elm.Annotation.maybe (Elm.Annotation.named [] "Route")) + |> Elm.withType (Elm.Annotation.maybe routeType.annotation) ) ) withoutBaseUrl : Elm.Declaration withoutBaseUrl = Elm.declaration "withoutBaseUrl" - (Elm.fn ( "path", Just Elm.Annotation.string ) + (Elm.fn (Elm.Arg.varWith "path" Elm.Annotation.string) (\path -> Elm.ifThen - (path |> Gen.String.call_.startsWith baseUrl.reference) + (path |> Gen.String.call_.startsWith baseUrl.value) (Gen.String.call_.dropLeft - (Gen.String.call_.length baseUrl.reference) + (Gen.String.call_.length baseUrl.value) path ) path ) ) - toString : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + toString : Elm.Declare.Function (Elm.Expression -> Elm.Expression) toString = Elm.Declare.fn "toString" - ( "route", Elm.Annotation.named [] "Route" |> Just ) + (Elm.Arg.varWith "route" routeType.annotation) (\route -> Gen.UrlPath.toAbsolute (toPath.call route) |> Elm.withType Elm.Annotation.string) redirectTo : Elm.Declaration redirectTo = Elm.declaration "redirectTo" - (Elm.fn ( "route", Elm.Annotation.named [] "Route" |> Just ) + (Elm.fn (Elm.Arg.varWith "route" routeType.annotation) (\route -> Gen.Server.Response.call_.temporaryRedirect (toString.call route) @@ -159,17 +158,17 @@ file templates basePath = ) ) - toLink : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + toLink : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression) toLink = Elm.Declare.fn2 "toLink" - ( "toAnchorTag" - , Elm.Annotation.function - [ Elm.Annotation.list (Elm.Annotation.namedWith [ "Html" ] "Attribute" [ Elm.Annotation.var "msg" ]) - ] - (Elm.Annotation.var "abc") - |> Just + (Elm.Arg.varWith "toAnchorTag" + (Elm.Annotation.function + [ Elm.Annotation.list (Gen.Html.annotation_.attribute (Elm.Annotation.var "msg")) + ] + (Elm.Annotation.var "abc") + ) ) - ( "route", Just (Elm.Annotation.named [] "Route") ) + (Elm.Arg.varWith "route" routeType.annotation) (\toAnchorTag route -> Elm.apply toAnchorTag @@ -186,13 +185,13 @@ file templates basePath = link = Elm.declaration "link" (Elm.fn3 - ( "attributes", Nothing ) - ( "children", Nothing ) - ( "route", Just (Elm.Annotation.named [] "Route") ) + (Elm.Arg.var "attributes") + (Elm.Arg.var "children") + (Elm.Arg.varWith "route" routeType.annotation) (\attributes children route -> toLink.call (Elm.fn - ( "anchorAttrs", Nothing ) + (Elm.Arg.var "anchorAttrs") (\anchorAttrs -> Gen.Html.call_.a (Elm.Op.append anchorAttrs attributes) @@ -203,21 +202,25 @@ file templates basePath = ) |> Elm.withType (Elm.Annotation.function - [ Elm.Annotation.list (Elm.Annotation.namedWith [ "Html" ] "Attribute" [ Elm.Annotation.var "msg" ]) - , Elm.Annotation.list (Elm.Annotation.namedWith [ "Html" ] "Html" [ Elm.Annotation.var "msg" ]) - , Elm.Annotation.named [] "Route" + [ Elm.Annotation.list (Gen.Html.annotation_.attribute (Elm.Annotation.var "msg")) + , Elm.Annotation.list (Gen.Html.annotation_.html (Elm.Annotation.var "msg")) + , routeType.annotation ] - (Elm.Annotation.namedWith [ "Html" ] "Html" [ Elm.Annotation.var "msg" ]) + (Gen.Html.annotation_.html (Elm.Annotation.var "msg")) ) ) - baseUrl : { declaration : Elm.Declaration, reference : Elm.Expression, referenceFrom : List String -> Elm.Expression } + baseUrl : Elm.Declare.Value baseUrl = - topLevelValue "baseUrl" (Elm.string basePath) + Elm.Declare.value "baseUrl" (Elm.string basePath) + + routeType : Elm.Declare.Annotation + routeType = + Elm.Declare.customType "Route" (routes |> List.map RoutePattern.toVariant) in Elm.file [ "Route" ] - ([ [ Elm.customType "Route" (routes |> List.map RoutePattern.toVariant) + ([ [ routeType.declaration , segmentsToRouteFn.declaration , urlToRoute , baseUrl.declaration @@ -231,7 +234,7 @@ file templates basePath = , withoutBaseUrl ] |> List.map (Elm.withDocumentation ".") - |> List.map expose + |> List.map Elm.exposeConstructor , [ splitPath.declaration , maybeToList.declaration ] @@ -240,23 +243,23 @@ file templates basePath = ) -splitPath : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } +splitPath : Elm.Declare.Function (Elm.Expression -> Elm.Expression) splitPath = Elm.Declare.fn "splitPath" - ( "path", Just Gen.UrlPath.annotation_.urlPath ) + (Elm.Arg.varWith "path" Gen.UrlPath.annotation_.urlPath) (\path -> Gen.List.call_.filter - (Elm.fn ( "item", Just Elm.Annotation.string ) + (Elm.fn (Elm.Arg.varWith "item" Elm.Annotation.string) (\item -> Elm.Op.notEqual item (Elm.string "")) ) (Gen.String.call_.split (Elm.string "/") path) ) -maybeToList : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } +maybeToList : Elm.Declare.Function (Elm.Expression -> Elm.Expression) maybeToList = Elm.Declare.fn "maybeToList" - ( "maybeString", Just (Elm.Annotation.maybe Elm.Annotation.string) ) + (Elm.Arg.varWith "maybeString" (Elm.Annotation.maybe Elm.Annotation.string)) (\maybeString -> Elm.Case.maybe maybeString { nothing = Elm.list [] @@ -266,15 +269,13 @@ maybeToList = ) -segmentsToRoute : - List RoutePattern - -> { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } +segmentsToRoute : List RoutePattern -> Elm.Declare.Function (Elm.Expression -> Elm.Expression) segmentsToRoute routes = Elm.Declare.fn "segmentsToRoute" - ( "segments" - , Elm.Annotation.list Elm.Annotation.string |> Just + (Elm.Arg.varWith "segments" + (Elm.Annotation.list Elm.Annotation.string) ) - (\segments -> + (\_ -> let alreadyHasCatchallBranch : Bool alreadyHasCatchallBranch = @@ -314,11 +315,12 @@ segmentsToRoute routes = routeToPath : - List RoutePattern - -> { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } -routeToPath routes = + Elm.Declare.Annotation + -> List RoutePattern + -> Elm.Declare.Function (Elm.Expression -> Elm.Expression) +routeToPath routeType routes = Elm.Declare.fn "routeToPath" - ( "route", Just (Elm.Annotation.named [] "Route") ) + (Elm.Arg.varWith "route" routeType.annotation) (\route_ -> Elm.Case.custom route_ (Elm.Annotation.list Elm.Annotation.string) @@ -344,17 +346,26 @@ routeToPath routes = (Just []) of Just staticOnlyName -> - Elm.Case.branch0 (RoutePattern.toVariantName route |> .variantName) - (staticOnlyName - |> List.map (\kebabName -> Elm.string kebabName) - |> Elm.list - |> List.singleton - |> Elm.list + Elm.Case.branch + (Elm.Arg.customType + (RoutePattern.toVariantName route |> .variantName) + () + ) + (\_ -> + staticOnlyName + |> List.map (\kebabName -> Elm.string kebabName) + |> Elm.list + |> List.singleton + |> Elm.list ) Nothing -> - Elm.Case.branch1 (RoutePattern.toVariantName route |> .variantName) - ( "params", Elm.Annotation.record [] ) + Elm.Case.branch + (Elm.Arg.customType + (RoutePattern.toVariantName route |> .variantName) + identity + |> Elm.Arg.item (Elm.Arg.varWith "params" (Elm.Annotation.record [])) + ) (\params -> RoutePattern.toVariantName route |> .params @@ -387,15 +398,6 @@ routeToPath routes = ) -expose : Elm.Declaration -> Elm.Declaration -expose declaration = - declaration - |> Elm.exposeWith - { exposeConstructor = True - , group = Nothing - } - - {-| Decapitalize the first letter of a string. decapitalize "This is a phrase" == "this is a phrase" decapitalize "Hello, World" == "hello, World" diff --git a/codegen/GenerateMain.elm b/codegen/GenerateMain.elm index 04d29e4f3..535df1943 100644 --- a/codegen/GenerateMain.elm +++ b/codegen/GenerateMain.elm @@ -2,10 +2,9 @@ module GenerateMain exposing (..) import Elm exposing (File) import Elm.Annotation as Type +import Elm.Arg import Elm.Case -import Elm.Case.Branch import Elm.Declare -import Elm.Extra exposing (expose, fnIgnore, topLevelValue) import Elm.Let import Elm.Op import Gen.Api @@ -71,23 +70,23 @@ otherFile routes phaseString = -- } config = { init = Elm.apply (Elm.val "init") [ Elm.nothing ] - , update = update.value [] - , subscriptions = subscriptions.value [] + , update = update.value + , subscriptions = subscriptions.value , sharedData = Gen.Shared.values_.template |> Elm.get "data" - , data = dataForRoute.value [] - , action = action.value [] - , onActionData = onActionData.value [] - , view = view.value [] - , handleRoute = handleRoute.value [] + , data = dataForRoute.value + , action = action.value + , onActionData = onActionData.value + , view = view.value + , handleRoute = handleRoute.value , getStaticRoutes = case phase of Browser -> Gen.BackendTask.succeed (Elm.list []) Cli -> - getStaticRoutes.reference + getStaticRoutes.value |> Gen.BackendTask.map (Gen.List.call_.map (Elm.functionReduced "x" Gen.Maybe.make_.just)) , urlToRoute = Elm.value @@ -96,7 +95,7 @@ otherFile routes phaseString = , importFrom = [ "Route" ] } , routeToPath = - Elm.fn ( "route", Nothing ) + Elm.fn (Elm.Arg.var "route") (\route -> route |> Gen.Maybe.map @@ -132,24 +131,24 @@ otherFile routes phaseString = applyIdentityTo (Elm.val "hotReloadData") , onPageChange = Elm.val "OnPageChange" , apiRoutes = - Elm.fn ( "htmlToString", Nothing ) + Elm.fn (Elm.Arg.var "htmlToString") (\htmlToString -> case phase of Browser -> Elm.list [] Cli -> - Elm.Op.cons pathsToGenerateHandler.reference - (Elm.Op.cons routePatterns.reference - (Elm.Op.cons apiPatterns.reference + Elm.Op.cons pathsToGenerateHandler.value + (Elm.Op.cons routePatterns.value + (Elm.Op.cons apiPatterns.value (Gen.Api.call_.routes - getStaticRoutes.reference + getStaticRoutes.value htmlToString ) ) ) ) - , pathPatterns = pathPatterns.reference + , pathPatterns = pathPatterns.value , basePath = Elm.value { name = "baseUrlAsPath" @@ -157,18 +156,18 @@ otherFile routes phaseString = , annotation = Nothing } , sendPageData = Elm.val "sendPageData" - , byteEncodePageData = byteEncodePageData.value [] - , byteDecodePageData = byteDecodePageData.value [] - , encodeResponse = encodeResponse.reference - , encodeAction = encodeActionData.value [] - , decodeResponse = decodeResponse.reference + , byteEncodePageData = byteEncodePageData.value + , byteDecodePageData = byteDecodePageData.value + , encodeResponse = encodeResponse.value + , encodeAction = encodeActionData.value + , decodeResponse = decodeResponse.value , globalHeadTags = case phase of Browser -> Elm.nothing Cli -> - Elm.just (globalHeadTags.value []) + Elm.just globalHeadTags.value , cmdToEffect = Gen.Effect.values_.fromCmd , perform = Gen.Effect.values_.perform , errorStatusCode = Gen.ErrorPage.values_.statusCode @@ -182,41 +181,32 @@ otherFile routes phaseString = --|> Elm.withType -- (Gen.Pages.ProgramConfig.annotation_.programConfig - -- (Type.named [] "Msg") - -- (Type.named [] "Model") + -- (msgType.annotation) + -- (modelType.annotation) -- (Type.maybe (Type.named [ "Route" ] "Route")) - -- (Type.named [] "PageData") - -- (Type.named [] "ActionData") + -- (pageDataType.annotation) + -- (actionDataType.annotation) -- (Type.named [ "Shared" ] "Data") - -- (Type.namedWith [ "Effect" ] "Effect" [ Type.named [] "Msg" ]) + -- (Type.namedWith [ "Effect" ] "Effect" [ msgType.annotation ]) -- (Type.var "mappedMsg") -- (Type.named [ "ErrorPage" ] "ErrorPage") -- ) - --|> topLevelValue "config" - pathPatterns : - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } + --|> Elm.Declare.value "config" + pathPatterns : Elm.Declare.Value pathPatterns = - topLevelValue "routePatterns3" + Elm.Declare.value "routePatterns3" (routes |> List.map routePatternToExpression |> Elm.list ) - view : - { declaration : Elm.Declaration - , call : List Elm.Expression -> Elm.Expression - , callFrom : List String -> List Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + view : Elm.Declare.Function (List Elm.Expression -> Elm.Expression) view = Elm.Declare.function "view" [ ( "pageFormState", Type.named [ "Form" ] "Model" |> Just ) , ( "concurrentSubmissions" , Gen.Dict.annotation_.dict Type.string - (Gen.Pages.ConcurrentSubmission.annotation_.concurrentSubmission (Type.named [] "ActionData")) + (Gen.Pages.ConcurrentSubmission.annotation_.concurrentSubmission actionDataType.annotation) |> Just ) , ( "navigation", Type.named [ "Pages", "Navigation" ] "Navigation" |> Type.maybe |> Just ) @@ -229,180 +219,188 @@ otherFile routes phaseString = ) , ( "maybePageUrl", Type.maybe (Type.named [ "Pages", "PageUrl" ] "PageUrl") |> Just ) , ( "globalData", Type.named [ "Shared" ] "Data" |> Just ) - , ( "pageData", Type.named [] "PageData" |> Just ) - , ( "actionData", Type.maybe (Type.named [] "ActionData") |> Just ) + , ( "pageData", pageDataType.annotation |> Just ) + , ( "actionData", Type.maybe actionDataType.annotation |> Just ) ] (\args -> case args of [ pageFormState, concurrentSubmissions, navigation, page, maybePageUrl, globalData, pageData, actionData ] -> let routeToBranch route = - Elm.Case.Branch.tuple - (Elm.Case.Branch.variant1 "Just" (routeToSyntaxPattern route) identity) - (Elm.Case.Branch.variant1 (prefixedRouteType "Data" route) (Elm.Case.Branch.var "data") identity) - |> Elm.Case.Branch.map - (\( maybeRouteParams, data ) -> - Elm.Let.letIn - (\actionDataOrNothing -> - Elm.record - [ ( "view" - , Elm.fn ( "model", Nothing ) - (\model -> - Elm.Case.custom (model |> Elm.get "page") - Type.unit - [ destructureRouteVariant Model "subModel" route - |> Elm.Case.Branch.map - (\subModel -> - Elm.apply - (Gen.Shared.values_.template - |> Elm.get "view" - ) - [ globalData - , page - , model |> Elm.get "global" - , Elm.fn ( "myMsg", Nothing ) - (\myMsg -> - Gen.PagesMsg.fromMsg - (Elm.apply (Elm.val "MsgGlobal") [ myMsg ]) - ) - , Gen.View.call_.map - (Elm.functionReduced - "innerPageMsg" - (Gen.PagesMsg.call_.map (route |> routeVariantExpression Msg)) - ) - (Elm.apply (route |> routeTemplateFunction "view") - [ model |> Elm.get "global" - , subModel - , Elm.record - [ ( "data", data ) - , ( "sharedData", globalData ) - , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) - , ( "action", Gen.Maybe.andThen actionDataOrNothing actionData ) - , ( "path", page |> Elm.get "path" ) - , ( "url", maybePageUrl ) - , ( "submit" - , Elm.functionReduced - "fetcherArg" - (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) - ) - , ( "navigation", navigation ) - , ( "concurrentSubmissions" - , concurrentSubmissions - |> Gen.Dict.map - (\_ fetcherState -> - fetcherState - |> Gen.Pages.ConcurrentSubmission.map (\ad -> actionDataOrNothing ad) - ) - ) - , ( "pageFormState", pageFormState ) - ] - ] - ) - ] + Elm.Case.branch + (Elm.Arg.tuple + (Elm.Arg.customType "Just" identity |> Elm.Arg.item (routeToSyntaxPattern route)) + (Elm.Arg.customType (prefixedRouteType "Data" route) identity |> Elm.Arg.item (Elm.Arg.var "data")) + ) + (\( maybeRouteParams, data ) -> + Elm.Let.letIn + (\actionDataOrNothing -> + Elm.record + [ ( "view" + , Elm.fn (Elm.Arg.var "model") + (\model -> + Elm.Case.custom (model |> Elm.get "page") + Type.unit + [ Elm.Case.branch + (destructureRouteVariant Model "subModel" route) + (\subModel -> + Elm.apply + (Gen.Shared.values_.template + |> Elm.get "view" ) - , Elm.Case.Branch.ignore modelMismatchView.value - ] - ) - ) - , ( "head" - , case phase of - Browser -> - Elm.list [] - - Cli -> - Elm.apply - (route - |> routeTemplateFunction "head" + [ globalData + , page + , model |> Elm.get "global" + , Elm.fn (Elm.Arg.var "myMsg") + (\myMsg -> + Gen.PagesMsg.fromMsg + (Elm.apply (Elm.val "MsgGlobal") [ myMsg ]) + ) + , Gen.View.call_.map + (Elm.functionReduced + "innerPageMsg" + (Gen.PagesMsg.call_.map (route |> routeVariantExpression Msg)) + ) + (Elm.apply (route |> routeTemplateFunction "view") + [ model |> Elm.get "global" + , subModel + , Elm.record + [ ( "data", data ) + , ( "sharedData", globalData ) + , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) + , ( "action", Gen.Maybe.andThen actionDataOrNothing actionData ) + , ( "path", page |> Elm.get "path" ) + , ( "url", maybePageUrl ) + , ( "submit" + , Elm.functionReduced + "fetcherArg" + (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) + ) + , ( "navigation", navigation ) + , ( "concurrentSubmissions" + , concurrentSubmissions + |> Gen.Dict.map + (\_ fetcherState -> + fetcherState + |> Gen.Pages.ConcurrentSubmission.map (\ad -> actionDataOrNothing ad) + ) + ) + , ( "pageFormState", pageFormState ) + ] + ] + ) + ] ) - [ Elm.record - [ ( "data", data ) - , ( "sharedData", globalData ) - , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) - , ( "action", Elm.nothing ) - , ( "path", page |> Elm.get "path" ) - , ( "url", Elm.nothing ) - , ( "submit", Elm.functionReduced "value" (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) ) - , ( "navigation", Elm.nothing ) - , ( "concurrentSubmissions", Gen.Dict.empty ) - , ( "pageFormState", Gen.Dict.empty ) - ] + , Elm.Case.branch Elm.Arg.ignore (\_ -> modelMismatchView.value) + ] + ) + ) + , ( "head" + , case phase of + Browser -> + Elm.list [] + + Cli -> + Elm.apply + (route + |> routeTemplateFunction "head" + ) + [ Elm.record + [ ( "data", data ) + , ( "sharedData", globalData ) + , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) + , ( "action", Elm.nothing ) + , ( "path", page |> Elm.get "path" ) + , ( "url", Elm.nothing ) + , ( "submit", Elm.functionReduced "value" (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) ) + , ( "navigation", Elm.nothing ) + , ( "concurrentSubmissions", Gen.Dict.empty ) + , ( "pageFormState", Gen.Dict.empty ) ] - ) - ] + ] + ) + ] + ) + |> Elm.Let.fn "actionDataOrNothing" + (Elm.Arg.var "thisActionData") + (\thisActionData -> + Elm.Case.custom thisActionData + Type.unit + (ignoreBranchIfNeeded + { primary = + Elm.Case.branch + (destructureRouteVariant ActionData "justActionData" route) + Elm.just + , otherwise = Elm.nothing + } + routes + ) ) - |> Elm.Let.fn "actionDataOrNothing" - ( "thisActionData", Nothing ) - (\thisActionData -> - Elm.Case.custom thisActionData - Type.unit - (ignoreBranchIfNeeded - { primary = - destructureRouteVariant ActionData "justActionData" route - |> Elm.Case.Branch.map - (\justActionData -> - Elm.just justActionData - ) - , otherwise = Elm.nothing - } - routes - ) - ) - |> Elm.Let.toExpression - ) + |> Elm.Let.toExpression + ) in Elm.Case.custom (Elm.tuple (page |> Elm.get "route") pageData) Type.unit - ((Elm.Case.Branch.tuple (Elm.Case.Branch.ignore ()) (Elm.Case.Branch.variant1 "DataErrorPage____" (Elm.Case.Branch.var "data") identity) - |> Elm.Case.Branch.map - (\( (), data ) -> - Elm.record - [ ( "view" - , Elm.fn ( "model", Nothing ) - (\model -> - Elm.Case.custom (model |> Elm.get "page") - Type.unit - [ Elm.Case.Branch.variant1 "ModelErrorPage____" (Elm.Case.Branch.var "subModel") <| - \subModel -> - Elm.apply - (Gen.Shared.values_.template - |> Elm.get "view" + (Elm.Case.branch + (Elm.Arg.tuple + Elm.Arg.ignore + (Elm.Arg.customType "DataErrorPage____" identity + |> Elm.Arg.item (Elm.Arg.var "data") + ) + ) + (\( _, data ) -> + Elm.record + [ ( "view" + , Elm.fn (Elm.Arg.var "model") + (\model -> + Elm.Case.custom (model |> Elm.get "page") + Type.unit + [ Elm.Case.branch + (Elm.Arg.customType "ModelErrorPage____" identity + |> Elm.Arg.item (Elm.Arg.var "subModel") + ) + (\subModel -> + Elm.apply + (Gen.Shared.values_.template + |> Elm.get "view" + ) + [ globalData + , page + , model |> Elm.get "global" + , Elm.fn (Elm.Arg.var "myMsg") + (\myMsg -> + Gen.PagesMsg.fromMsg + (Elm.apply (Elm.val "MsgGlobal") [ myMsg ]) ) - [ globalData - , page - , model |> Elm.get "global" - , Elm.fn ( "myMsg", Nothing ) + , Gen.View.call_.map + (Elm.functionReduced "myMsg" (\myMsg -> Gen.PagesMsg.fromMsg - (Elm.apply (Elm.val "MsgGlobal") [ myMsg ]) - ) - , Gen.View.call_.map - (Elm.functionReduced "myMsg" - (\myMsg -> - Gen.PagesMsg.fromMsg - (Elm.apply (Elm.val "MsgErrorPage____") [ myMsg ]) - ) - ) - (Gen.ErrorPage.call_.view - data - subModel + (Elm.apply (Elm.val "MsgErrorPage____") [ myMsg ]) ) - ] - , Elm.Case.Branch.ignore modelMismatchView.value - ] - ) - ) - , ( "head", Elm.list [] ) - ] - ) - ) + ) + (Gen.ErrorPage.call_.view + data + subModel + ) + ] + ) + , Elm.Case.branch Elm.Arg.ignore (\_ -> modelMismatchView.value) + ] + ) + ) + , ( "head", Elm.list [] ) + ] + ) :: (routes |> List.map routeToBranch ) - ++ [ Elm.Case.otherwise + ++ [ Elm.Case.branch + Elm.Arg.ignore (\_ -> Elm.record [ ( "view" - , Elm.fn ( "_", Nothing ) + , Elm.fn Elm.Arg.ignore (\_ -> Elm.record [ ( "title", Elm.string "Page not found" ) @@ -423,12 +421,12 @@ otherFile routes phaseString = |> Elm.withType (Type.record [ ( "view" - , Type.function [ Type.named [] "Model" ] + , Type.function [ modelType.annotation ] (Type.record [ ( "title", Type.string ) , ( "body" , Gen.Html.annotation_.html - (Gen.PagesMsg.annotation_.pagesMsg (Type.named [] "Msg")) + (Gen.PagesMsg.annotation_.pagesMsg msgType.annotation) |> Type.list ) ] @@ -442,11 +440,7 @@ otherFile routes phaseString = todo ) - modelMismatchView : - { declaration : Elm.Declaration - , value : Elm.Expression - , valueFrom : List String -> Elm.Expression - } + modelMismatchView : Elm.Declare.Value modelMismatchView = Elm.Declare.value "modelMismatchView" (Elm.record @@ -455,17 +449,12 @@ otherFile routes phaseString = ] ) - subscriptions : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + subscriptions : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) subscriptions = Elm.Declare.fn3 "subscriptions" - ( "route", Type.named [ "Route" ] "Route" |> Type.maybe |> Just ) - ( "path", pathType |> Just ) - ( "model", Type.named [] "Model" |> Just ) + (Elm.Arg.varWith "route" (Type.named [ "Route" ] "Route" |> Type.maybe)) + (Elm.Arg.varWith "path" pathType) + (Elm.Arg.varWith "model" modelType.annotation) (\route path model -> Gen.Platform.Sub.batch [ Elm.apply @@ -479,58 +468,47 @@ otherFile routes phaseString = |> Gen.Platform.Sub.call_.map (Elm.val "MsgGlobal") , templateSubscriptions.call route path model ] - |> Elm.withType (Gen.Platform.Sub.annotation_.sub (Type.named [] "Msg")) + |> Elm.withType (Gen.Platform.Sub.annotation_.sub msgType.annotation) ) - onActionData : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + onActionData : Elm.Declare.Function (Elm.Expression -> Elm.Expression) onActionData = Elm.Declare.fn "onActionData" - ( "actionData", Type.named [] "ActionData" |> Just ) + (Elm.Arg.varWith "actionData" actionDataType.annotation) (\actionData -> Elm.Case.custom actionData Type.unit (routes |> List.map (\route -> - route - |> destructureRouteVariant ActionData "thisActionData" - |> Elm.Case.Branch.map - (\thisActionData -> - (Elm.value - { annotation = Nothing - , importFrom = "Route" :: RoutePattern.toModuleName route - , name = "route" - } - |> Elm.get "onAction" - ) - |> Gen.Maybe.map - (\onAction -> - Elm.apply - (route |> routeVariantExpression Msg) - [ Elm.apply onAction [ thisActionData ] ] - ) + Elm.Case.branch + (destructureRouteVariant ActionData "thisActionData" route) + (\thisActionData -> + (Elm.value + { annotation = Nothing + , importFrom = "Route" :: RoutePattern.toModuleName route + , name = "route" + } + |> Elm.get "onAction" ) + |> Gen.Maybe.map + (\onAction -> + Elm.apply + (route |> routeVariantExpression Msg) + [ Elm.apply onAction [ thisActionData ] ] + ) + ) ) ) - |> Elm.withType (Type.maybe (Type.named [] "Msg")) + |> Elm.withType (Type.maybe msgType.annotation) ) - templateSubscriptions : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + templateSubscriptions : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) templateSubscriptions = Elm.Declare.fn3 "templateSubscriptions" - ( "route", Type.maybe (Type.named [ "Route" ] "Route") |> Just ) - ( "path", pathType |> Just ) - ( "model", Type.named [] "Model" |> Just ) + (Elm.Arg.varWith "route" (Type.maybe (Type.named [ "Route" ] "Route"))) + (Elm.Arg.varWith "path" pathType) + (Elm.Arg.varWith "model" modelType.annotation) (\maybeRoute path model -> Elm.Case.maybe maybeRoute { nothing = Gen.Platform.Sub.values_.none @@ -541,44 +519,38 @@ otherFile routes phaseString = (\route maybeRouteParams -> Elm.Case.custom (model |> Elm.get "page") Type.unit - [ route - |> destructureRouteVariant Model "templateModel" - |> Elm.Case.Branch.map - (\templateModel -> - Elm.apply - (Elm.value - { importFrom = "Route" :: RoutePattern.toModuleName route - , name = "route" - , annotation = Nothing - } - |> Elm.get "subscriptions" - ) - [ maybeRouteParams |> Maybe.withDefault (Elm.record []) - , path - , templateModel - , model |> Elm.get "global" - ] - |> Gen.Platform.Sub.call_.map (route |> routeVariantExpression Msg) - ) - , Elm.Case.otherwise (\_ -> Gen.Platform.Sub.values_.none) + [ Elm.Case.branch + (destructureRouteVariant Model "templateModel" route) + (\templateModel -> + Elm.apply + (Elm.value + { importFrom = "Route" :: RoutePattern.toModuleName route + , name = "route" + , annotation = Nothing + } + |> Elm.get "subscriptions" + ) + [ maybeRouteParams |> Maybe.withDefault (Elm.record []) + , path + , templateModel + , model |> Elm.get "global" + ] + |> Gen.Platform.Sub.call_.map (route |> routeVariantExpression Msg) + ) + , Elm.Case.branch Elm.Arg.ignore (\_ -> Gen.Platform.Sub.values_.none) ] ) ) } - |> Elm.withType (Gen.Platform.Sub.annotation_.sub (Type.named [] "Msg")) + |> Elm.withType (Gen.Platform.Sub.annotation_.sub msgType.annotation) ) - dataForRoute : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + dataForRoute : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression) dataForRoute = Elm.Declare.fn2 "dataForRoute" - ( "requestPayload", Just Gen.Server.Request.annotation_.request ) - ( "maybeRoute", Type.maybe (Type.named [ "Route" ] "Route") |> Just ) + (Elm.Arg.varWith "requestPayload" Gen.Server.Request.annotation_.request) + (Elm.Arg.varWith "maybeRoute" (Type.maybe (Type.named [ "Route" ] "Route"))) (\requestPayload maybeRoute -> Elm.Case.maybe maybeRoute { nothing = @@ -614,23 +586,18 @@ otherFile routes phaseString = (Gen.BackendTask.annotation_.backendTask (Type.named [ "FatalError" ] "FatalError") (Gen.Server.Response.annotation_.response - (Type.named [] "PageData") + pageDataType.annotation (Type.named [ "ErrorPage" ] "ErrorPage") ) ) ) - action : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + action : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression) action = Elm.Declare.fn2 "action" - ( "requestPayload", Just Gen.Server.Request.annotation_.request ) - ( "maybeRoute", Type.maybe (Type.named [ "Route" ] "Route") |> Just ) + (Elm.Arg.varWith "requestPayload" Gen.Server.Request.annotation_.request) + (Elm.Arg.varWith "maybeRoute" (Type.maybe (Type.named [ "Route" ] "Route"))) (\requestPayload maybeRoute -> Elm.Case.maybe maybeRoute { nothing = @@ -664,39 +631,34 @@ otherFile routes phaseString = (Gen.BackendTask.annotation_.backendTask (Type.named [ "FatalError" ] "FatalError") (Gen.Server.Response.annotation_.response - (Type.named [] "ActionData") + actionDataType.annotation (Type.named [ "ErrorPage" ] "ErrorPage") ) ) ) - init : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + init : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) init = Elm.Declare.fn6 "init" - ( "currentGlobalModel", Type.maybe (Type.named [ "Shared" ] "Model") |> Just ) - ( "userFlags", Type.named [ "Pages", "Flags" ] "Flags" |> Just ) - ( "sharedData", Type.named [ "Shared" ] "Data" |> Just ) - ( "pageData", Type.named [] "PageData" |> Just ) - ( "actionData", Type.named [] "ActionData" |> Type.maybe |> Just ) - ( "maybePagePath" - , Type.record - [ ( "path" - , Type.record - [ ( "path", pathType ) - , ( "query", Type.string |> Type.maybe ) - , ( "fragment", Type.string |> Type.maybe ) - ] - ) - , ( "metadata", Type.maybe (Type.named [ "Route" ] "Route") ) - , ( "pageUrl", Type.maybe (Type.named [ "Pages", "PageUrl" ] "PageUrl") ) - ] - |> Type.maybe - |> Just + (Elm.Arg.varWith "currentGlobalModel" (Type.maybe (Type.named [ "Shared" ] "Model"))) + (Elm.Arg.varWith "userFlags" (Type.named [ "Pages", "Flags" ] "Flags")) + (Elm.Arg.varWith "sharedData" (Type.named [ "Shared" ] "Data")) + (Elm.Arg.varWith "pageData" pageDataType.annotation) + (Elm.Arg.varWith "actionData" (actionDataType.annotation |> Type.maybe)) + (Elm.Arg.varWith "maybePagePath" + (Type.record + [ ( "path" + , Type.record + [ ( "path", pathType ) + , ( "query", Type.string |> Type.maybe ) + , ( "fragment", Type.string |> Type.maybe ) + ] + ) + , ( "metadata", Type.maybe (Type.named [ "Route" ] "Route") ) + , ( "pageUrl", Type.maybe (Type.named [ "Pages", "PageUrl" ] "PageUrl") ) + ] + |> Type.maybe + ) ) (\currentGlobalModel userFlags sharedData pageData actionData maybePagePath -> Elm.Let.letIn @@ -720,8 +682,11 @@ otherFile routes phaseString = ) ) ) - |> Elm.Let.tuple "templateModel" - "templateCmd" + |> Elm.Let.unpack + (Elm.Arg.tuple + (Elm.Arg.var "templateModel") + (Elm.Arg.var "templateCmd") + ) (Elm.Case.maybe (Gen.Maybe.map2 Gen.Tuple.pair (maybePagePath |> Gen.Maybe.andThen (Elm.get "metadata")) @@ -736,74 +701,72 @@ otherFile routes phaseString = ((routes |> List.map (\route -> - Elm.Case.Branch.tuple - (routeToSyntaxPattern route) - (route |> destructureRouteVariant Data "thisPageData") - |> Elm.Case.Branch.map - (\( maybeRouteParams, thisPageData ) -> - Elm.apply - (Elm.value - { name = "route" - , importFrom = "Route" :: RoutePattern.toModuleName route - , annotation = Nothing - } - |> Elm.get "init" - ) - [ sharedModel - , Elm.record - [ ( "data", thisPageData ) - , ( "sharedData", sharedData ) - , ( "action" - , actionData - |> Gen.Maybe.andThen - (\justActionData -> - Elm.Case.custom justActionData - Type.unit - (ignoreBranchIfNeeded - { primary = - route - |> destructureRouteVariant ActionData "thisActionData" - |> Elm.Case.Branch.map - (\thisActionData -> - Elm.just thisActionData - ) - , otherwise = Elm.nothing - } - routes - ) - ) - ) - , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) - , ( "path" - , justRouteAndPath - |> Gen.Tuple.second - |> Elm.get "path" - ) - , ( "url" - , Gen.Maybe.andThen (Elm.get "pageUrl") maybePagePath - ) - , ( "submit" - , Elm.apply - Gen.Pages.Fetcher.values_.submit - [ route |> decodeRouteType ActionData - ] - ) - , ( "navigation", Elm.nothing ) - , ( "concurrentSubmissions", Gen.Dict.empty ) - , ( "pageFormState", Gen.Dict.empty ) - ] - ] - |> Gen.Tuple.call_.mapBoth - (route |> routeVariantExpression Model) - (Elm.apply - Gen.Effect.values_.map - [ route |> routeVariantExpression Msg + Elm.Case.branch + (Elm.Arg.tuple + (routeToSyntaxPattern route) + (destructureRouteVariant Data "thisPageData" route) + ) + (\( maybeRouteParams, thisPageData ) -> + Elm.apply + (Elm.value + { name = "route" + , importFrom = "Route" :: RoutePattern.toModuleName route + , annotation = Nothing + } + |> Elm.get "init" + ) + [ sharedModel + , Elm.record + [ ( "data", thisPageData ) + , ( "sharedData", sharedData ) + , ( "action" + , actionData + |> Gen.Maybe.andThen + (\justActionData -> + Elm.Case.custom justActionData + Type.unit + (ignoreBranchIfNeeded + { primary = + Elm.Case.branch + (destructureRouteVariant ActionData "thisActionData" route) + Elm.just + , otherwise = Elm.nothing + } + routes + ) + ) + ) + , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) + , ( "path" + , justRouteAndPath + |> Gen.Tuple.second + |> Elm.get "path" + ) + , ( "url" + , Gen.Maybe.andThen (Elm.get "pageUrl") maybePagePath + ) + , ( "submit" + , Elm.apply + Gen.Pages.Fetcher.values_.submit + [ route |> decodeRouteType ActionData ] - ) - ) + ) + , ( "navigation", Elm.nothing ) + , ( "concurrentSubmissions", Gen.Dict.empty ) + , ( "pageFormState", Gen.Dict.empty ) + ] + ] + |> Gen.Tuple.call_.mapBoth + (route |> routeVariantExpression Model) + (Elm.apply + Gen.Effect.values_.map + [ route |> routeVariantExpression Msg + ] + ) + ) ) ) - ++ [ Elm.Case.Branch.ignore (initErrorPage.call pageData) + ++ [ Elm.Case.branch Elm.Arg.ignore (\_ -> initErrorPage.call pageData) ] ) ) @@ -811,8 +774,11 @@ otherFile routes phaseString = ) |> Elm.Let.toExpression ) - |> Elm.Let.tuple "sharedModel" - "globalCmd" + |> Elm.Let.unpack + (Elm.Arg.tuple + (Elm.Arg.var "sharedModel") + (Elm.Arg.var "globalCmd") + ) (currentGlobalModel |> Gen.Maybe.map (\m -> @@ -829,168 +795,171 @@ otherFile routes phaseString = |> Elm.Let.toExpression |> Elm.withType (Type.tuple - (Type.named [] "Model") - (Type.namedWith [ "Effect" ] "Effect" [ Type.named [] "Msg" ]) + modelType.annotation + (Type.namedWith [ "Effect" ] "Effect" [ msgType.annotation ]) ) ) - update : - { declaration : Elm.Declaration - , call : List Elm.Expression -> Elm.Expression - , callFrom : List String -> List Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + update : Elm.Declare.Function (List Elm.Expression -> Elm.Expression) update = Elm.Declare.function "update" [ ( "pageFormState", Type.named [ "Form" ] "Model" |> Just ) , ( "concurrentSubmissions" , Gen.Dict.annotation_.dict Type.string - (Gen.Pages.ConcurrentSubmission.annotation_.concurrentSubmission (Type.named [] "ActionData")) + (Gen.Pages.ConcurrentSubmission.annotation_.concurrentSubmission actionDataType.annotation) |> Just ) , ( "navigation", Type.named [ "Pages", "Navigation" ] "Navigation" |> Type.maybe |> Just ) , ( "sharedData", Type.named [ "Shared" ] "Data" |> Just ) - , ( "pageData", Type.named [] "PageData" |> Just ) + , ( "pageData", pageDataType.annotation |> Just ) , ( "navigationKey", Type.named [ "Browser", "Navigation" ] "Key" |> Type.maybe |> Just ) - , ( "msg", Type.named [] "Msg" |> Just ) - , ( "model", Type.named [] "Model" |> Just ) + , ( "msg", msgType.annotation |> Just ) + , ( "model", modelType.annotation |> Just ) ] (\args -> case args of [ pageFormState, concurrentSubmissions, navigation, sharedData, pageData, navigationKey, msg, model ] -> let routeToBranch route = - (route |> destructureRouteVariant Msg "msg_") - |> Elm.Case.Branch.map - (\msg_ -> - Elm.Case.custom - (Elm.triple - (model |> Elm.get "page") - pageData - (Gen.Maybe.call_.map3 - (toTriple.value []) - (model - |> Elm.get "current" - |> Gen.Maybe.andThen - (Elm.get "metadata") - ) - (model - |> Elm.get "current" - |> Gen.Maybe.andThen - (Elm.get "pageUrl") - ) - (model - |> Elm.get "current" - |> Gen.Maybe.map - (Elm.get "path") - ) + Elm.Case.branch + (route |> destructureRouteVariant Msg "msg_") + (\msg_ -> + Elm.Case.custom + (Elm.triple + (model |> Elm.get "page") + pageData + (Gen.Maybe.call_.map3 + toTriple.value + (model + |> Elm.get "current" + |> Gen.Maybe.andThen + (Elm.get "metadata") + ) + (model + |> Elm.get "current" + |> Gen.Maybe.andThen + (Elm.get "pageUrl") + ) + (model + |> Elm.get "current" + |> Gen.Maybe.map + (Elm.get "path") ) ) - Type.unit - [ Elm.Case.Branch.triple + ) + Type.unit + [ Elm.Case.branch + (Elm.Arg.triple (route |> destructureRouteVariant Model "pageModel") (route |> destructureRouteVariant Data "thisPageData") - (Elm.Case.Branch.variant1 - "Just" - (Elm.Case.Branch.triple - (routeToSyntaxPattern route) - (Elm.Case.Branch.var "pageUrl") - (Elm.Case.Branch.var "justPage") - ) - identity + (Elm.Arg.customType "Just" identity + |> Elm.Arg.item + (Elm.Arg.triple + (routeToSyntaxPattern route) + (Elm.Arg.var "pageUrl") + (Elm.Arg.var "justPage") + ) ) - |> Elm.Case.Branch.map - (\( pageModel, thisPageData, ( maybeRouteParams, pageUrl, justPage ) ) -> + ) + (\( pageModel, thisPageData, ( maybeRouteParams, pageUrl, justPage ) ) -> + Elm.Let.letIn + (\( updatedPageModel, pageCmd, newGLobalModelAndCmd ) -> Elm.Let.letIn - (\( updatedPageModel, pageCmd, newGLobalModelAndCmd ) -> - Elm.Let.letIn - (\( newGlobalModel, newGlobalCmd ) -> - Elm.tuple - (model - |> Elm.updateRecord - [ ( "page", updatedPageModel ) - , ( "global", newGlobalModel ) - ] - ) - (Gen.Effect.batch - [ pageCmd - , Gen.Effect.call_.map - (Elm.val "MsgGlobal") - newGlobalCmd - ] - ) - ) - |> Elm.Let.tuple "newGlobalModel" "newGlobalCmd" newGLobalModelAndCmd - |> Elm.Let.toExpression - ) - |> Elm.Let.triple - "updatedPageModel" - "pageCmd" - "globalModelAndCmd" - (fooFn.call - (route |> routeVariantExpression Model) - (route |> routeVariantExpression Msg) - model - (Elm.apply - (Elm.value - { annotation = Nothing - , importFrom = "Route" :: RoutePattern.toModuleName route - , name = "route" - } - |> Elm.get "update" - ) - [ Elm.record - [ ( "data", thisPageData ) - , ( "sharedData", sharedData ) - , ( "action", Elm.nothing ) - , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) - , ( "path", justPage |> Elm.get "path" ) - , ( "url", Elm.just pageUrl ) - , ( "submit", Elm.fn ( "options", Nothing ) (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) ) - , ( "navigation", navigation ) - , ( "concurrentSubmissions" - , concurrentSubmissions - |> Gen.Dict.map - (\_ fetcherState -> - fetcherState - |> Gen.Pages.ConcurrentSubmission.map - (\ad -> - Elm.Case.custom ad - Type.unit - (ignoreBranchIfNeeded - { primary = - route - |> destructureRouteVariant ActionData "justActionData" - |> Elm.Case.Branch.map - (\justActionData -> - Elm.just justActionData - ) - , otherwise = Elm.nothing - } - routes - ) - ) - ) - ) - , ( "pageFormState", pageFormState ) + (\( newGlobalModel, newGlobalCmd ) -> + Elm.tuple + (model + |> Elm.updateRecord + [ ( "page", updatedPageModel ) + , ( "global", newGlobalModel ) ] - , msg_ - , pageModel - , model |> Elm.get "global" + ) + (Gen.Effect.batch + [ pageCmd + , Gen.Effect.call_.map + (Elm.val "MsgGlobal") + newGlobalCmd ] ) + ) + |> Elm.Let.unpack + (Elm.Arg.tuple + (Elm.Arg.var "newGlobalModel") + (Elm.Arg.var "newGlobalCmd") ) + newGLobalModelAndCmd |> Elm.Let.toExpression ) - , Elm.Case.Branch.ignore - (Elm.tuple model Gen.Effect.values_.none) - ] - ) + |> Elm.Let.unpack + (Elm.Arg.triple + (Elm.Arg.var "updatedPageModel") + (Elm.Arg.var "pageCmd") + (Elm.Arg.var "globalModelAndCmd") + ) + (fooFn.call + (route |> routeVariantExpression Model) + (route |> routeVariantExpression Msg) + model + (Elm.apply + (Elm.value + { annotation = Nothing + , importFrom = "Route" :: RoutePattern.toModuleName route + , name = "route" + } + |> Elm.get "update" + ) + [ Elm.record + [ ( "data", thisPageData ) + , ( "sharedData", sharedData ) + , ( "action", Elm.nothing ) + , ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) ) + , ( "path", justPage |> Elm.get "path" ) + , ( "url", Elm.just pageUrl ) + , ( "submit", Elm.fn (Elm.Arg.var "options") (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) ) + , ( "navigation", navigation ) + , ( "concurrentSubmissions" + , concurrentSubmissions + |> Gen.Dict.map + (\_ fetcherState -> + fetcherState + |> Gen.Pages.ConcurrentSubmission.map + (\ad -> + Elm.Case.custom ad + Type.unit + (ignoreBranchIfNeeded + { primary = + Elm.Case.branch + (destructureRouteVariant ActionData "justActionData" route) + Elm.just + , otherwise = Elm.nothing + } + routes + ) + ) + ) + ) + , ( "pageFormState", pageFormState ) + ] + , msg_ + , pageModel + , model |> Elm.get "global" + ] + ) + ) + |> Elm.Let.toExpression + ) + , Elm.Case.branch Elm.Arg.ignore + (\_ -> Elm.tuple model Gen.Effect.values_.none) + ] + ) in Elm.Case.custom msg Type.unit - ([ Elm.Case.Branch.variant1 "MsgErrorPage____" (Elm.Case.Branch.var "msg_") <| + ([ Elm.Case.branch + (Elm.Arg.customType "MsgErrorPage____" identity + |> Elm.Arg.item (Elm.Arg.var "msg_") + ) + <| \msg_ -> Elm.Let.letIn (\( updatedPageModel, pageCmd ) -> @@ -1002,28 +971,39 @@ otherFile routes phaseString = ) pageCmd ) - |> Elm.Let.tuple - "updatedPageModel" - "pageCmd" + |> Elm.Let.unpack + (Elm.Arg.tuple + (Elm.Arg.var "updatedPageModel") + (Elm.Arg.var "pageCmd") + ) (Elm.Case.custom (Elm.tuple (model |> Elm.get "page") pageData) Type.unit - [ Elm.Case.Branch.tuple - (Elm.Case.Branch.variant1 "ModelErrorPage____" (Elm.Case.Branch.var "pageModel") identity) - (Elm.Case.Branch.variant1 "DataErrorPage____" (Elm.Case.Branch.var "thisPageData") identity) - |> Elm.Case.Branch.map - (\( pageModel, thisPageData ) -> - Gen.ErrorPage.update - thisPageData - msg_ - pageModel - |> Gen.Tuple.call_.mapBoth (Elm.val "ModelErrorPage____") - (Elm.apply Gen.Effect.values_.map [ Elm.val "MsgErrorPage____" ]) + [ Elm.Case.branch + (Elm.Arg.tuple + (Elm.Arg.customType "ModelErrorPage____" identity + |> Elm.Arg.item (Elm.Arg.var "pageModel") + ) + (Elm.Arg.customType "DataErrorPage____" identity + |> Elm.Arg.item (Elm.Arg.var "thisPageData") ) - , Elm.Case.Branch.ignore (Elm.tuple (model |> Elm.get "page") Gen.Effect.values_.none) + ) + (\( pageModel, thisPageData ) -> + Gen.ErrorPage.update + thisPageData + msg_ + pageModel + |> Gen.Tuple.call_.mapBoth (Elm.val "ModelErrorPage____") + (Elm.apply Gen.Effect.values_.map [ Elm.val "MsgErrorPage____" ]) + ) + , Elm.Case.branch Elm.Arg.ignore (\_ -> Elm.tuple (model |> Elm.get "page") Gen.Effect.values_.none) ] ) |> Elm.Let.toExpression - , Elm.Case.Branch.variant1 "MsgGlobal" (Elm.Case.Branch.var "msg_") <| + , Elm.Case.branch + (Elm.Arg.customType "MsgGlobal" identity + |> Elm.Arg.item (Elm.Arg.var "msg_") + ) + <| \msg_ -> Elm.Let.letIn (\( sharedModel, globalCmd ) -> @@ -1031,9 +1011,11 @@ otherFile routes phaseString = (Elm.updateRecord [ ( "global", sharedModel ) ] model) (Gen.Effect.call_.map (Elm.val "MsgGlobal") globalCmd) ) - |> Elm.Let.tuple - "sharedModel" - "globalCmd" + |> Elm.Let.unpack + (Elm.Arg.tuple + (Elm.Arg.var "sharedModel") + (Elm.Arg.var "globalCmd") + ) (Elm.apply (Gen.Shared.values_.template |> Elm.get "update" @@ -1041,7 +1023,11 @@ otherFile routes phaseString = [ msg_, model |> Elm.get "global" ] ) |> Elm.Let.toExpression - , Elm.Case.Branch.variant1 "OnPageChange" (Elm.Case.Branch.var "record") <| + , Elm.Case.branch + (Elm.Arg.customType "OnPageChange" identity + |> Elm.Arg.item (Elm.Arg.var "record") + ) + <| \record -> Elm.Let.letIn (\( updatedModel, cmd ) -> @@ -1062,9 +1048,11 @@ otherFile routes phaseString = ] ) ) - |> Elm.Let.tuple - "updatedGlobalModel" - "globalCmd" + |> Elm.Let.unpack + (Elm.Arg.tuple + (Elm.Arg.var "updatedGlobalModel") + (Elm.Arg.var "globalCmd") + ) (Elm.apply (Gen.Shared.values_.template |> Elm.get "update" @@ -1086,11 +1074,13 @@ otherFile routes phaseString = -- |> Elm.Let.destructure -- -- TODO there is a bug where the Browser.Navigation.Key type wasn't imported because the argument wasn't referenced. -- -- Remove this hack when that bug is fixed - -- Elm.Case.Branch.ignore + -- Elm.Case.branch Elm.Arg.ignore -- navigationKey - |> Elm.Let.tuple - "updatedModel" - "cmd" + |> Elm.Let.unpack + (Elm.Arg.tuple + (Elm.Arg.var "updatedModel") + (Elm.Arg.var "cmd") + ) (init.call (Elm.just (model |> Elm.get "global")) (Elm.value { importFrom = [ "Pages", "Flags" ], name = "PreRenderFlags", annotation = Nothing }) @@ -1130,127 +1120,112 @@ otherFile routes phaseString = ) |> Elm.withType (Type.tuple - (Type.named [] "Model") - (Type.namedWith [ "Effect" ] "Effect" [ Type.named [] "Msg" ]) + modelType.annotation + (Type.namedWith [ "Effect" ] "Effect" [ msgType.annotation ]) ) _ -> todo ) - fooFn : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + fooFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) fooFn = Elm.Declare.fn4 "fooFn" - ( "wrapModel" - , Type.function [ Type.var "a" ] - (Type.named [] "PageModel") - |> Just + (Elm.Arg.varWith "wrapModel" + (Type.function [ Type.var "a" ] + pageModelType.annotation + ) + ) + (Elm.Arg.varWith "wrapMsg" + (Type.function [ Type.var "b" ] + msgType.annotation + ) ) - ( "wrapMsg" - , Type.function [ Type.var "b" ] - (Type.named [] "Msg") - |> Just + (Elm.Arg.varWith "model" + modelType.annotation ) - ( "model", Type.named [] "Model" |> Just ) - ( "triple" - , Type.triple - (Type.var "a") - (Type.namedWith [ "Effect" ] "Effect" [ Type.var "b" ]) - (Type.maybe (Type.named [ "Shared" ] "Msg")) - |> Just + (Elm.Arg.varWith "triple" + (Type.triple + (Type.var "a") + (Type.namedWith [ "Effect" ] "Effect" [ Type.var "b" ]) + (Type.maybe (Type.named [ "Shared" ] "Msg")) + ) ) (\wrapModel wrapMsg model triple -> Elm.Case.custom triple Type.unit - [ Elm.Case.Branch.triple - (Elm.Case.Branch.var "a") - (Elm.Case.Branch.var "b") - (Elm.Case.Branch.var "c") - |> Elm.Case.Branch.map - (\( a, b, c ) -> - Elm.triple - (Elm.apply wrapModel [ a ]) - (Gen.Effect.call_.map wrapMsg b) - (Elm.Case.maybe c - { nothing = - Elm.tuple - (model |> Elm.get "global") - Gen.Effect.values_.none - , just = - ( "sharedMsg" - , \sharedMsg -> - Elm.apply - (Gen.Shared.values_.template - |> Elm.get "update" - ) - [ sharedMsg - , model |> Elm.get "global" - ] - ) - } - ) - ) + [ Elm.Case.branch + (Elm.Arg.triple + (Elm.Arg.var "a") + (Elm.Arg.var "b") + (Elm.Arg.var "c") + ) + (\( a, b, c ) -> + Elm.triple + (Elm.apply wrapModel [ a ]) + (Gen.Effect.call_.map wrapMsg b) + (Elm.Case.maybe c + { nothing = + Elm.tuple + (model |> Elm.get "global") + Gen.Effect.values_.none + , just = + ( "sharedMsg" + , \sharedMsg -> + Elm.apply + (Gen.Shared.values_.template + |> Elm.get "update" + ) + [ sharedMsg + , model |> Elm.get "global" + ] + ) + } + ) + ) ] |> Elm.withType (Type.triple - (Type.named [] "PageModel") - (Type.namedWith [ "Effect" ] "Effect" [ Type.named [] "Msg" ]) + pageModelType.annotation + (Type.namedWith [ "Effect" ] "Effect" [ msgType.annotation ]) (Type.tuple (Type.named [ "Shared" ] "Model") (Type.namedWith [ "Effect" ] "Effect" [ Type.named [ "Shared" ] "Msg" ]) ) ) ) - toTriple : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + toTriple : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) toTriple = Elm.Declare.fn3 "toTriple" - ( "a", Nothing ) - ( "b", Nothing ) - ( "c", Nothing ) + (Elm.Arg.var "a") + (Elm.Arg.var "b") + (Elm.Arg.var "c") (\a b c -> Elm.triple a b c) - initErrorPage : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + initErrorPage : Elm.Declare.Function (Elm.Expression -> Elm.Expression) initErrorPage = Elm.Declare.fn "initErrorPage" - ( "pageData", Type.named [] "PageData" |> Just ) + (Elm.Arg.varWith "pageData" pageDataType.annotation) (\pageData -> Gen.ErrorPage.init (Elm.Case.custom pageData Type.unit - [ Elm.Case.branch1 "DataErrorPage____" - ( "errorPage", Type.unit ) - (\errorPage -> errorPage) - , Elm.Case.otherwise (\_ -> Gen.ErrorPage.values_.notFound) + [ Elm.Case.branch + (Elm.Arg.customType "DataErrorPage____" identity + |> Elm.Arg.item (Elm.Arg.var "errorPage") + ) + identity + , Elm.Case.branch Elm.Arg.ignore (\_ -> Gen.ErrorPage.values_.notFound) ] ) |> Gen.Tuple.call_.mapBoth (Elm.val "ModelErrorPage____") (Elm.apply Gen.Effect.values_.map [ Elm.val "MsgErrorPage____" ]) - |> Elm.withType (Type.tuple (Type.named [] "PageModel") (Type.namedWith [ "Effect" ] "Effect" [ Type.named [] "Msg" ])) + |> Elm.withType (Type.tuple pageModelType.annotation (Type.namedWith [ "Effect" ] "Effect" [ msgType.annotation ])) ) - handleRoute : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + handleRoute : Elm.Declare.Function (Elm.Expression -> Elm.Expression) handleRoute = Elm.Declare.fn "handleRoute" - ( "maybeRoute", Type.maybe (Type.named [ "Route" ] "Route") |> Just ) + (Elm.Arg.varWith "maybeRoute" (Type.maybe (Type.named [ "Route" ] "Route"))) (\maybeRoute -> Elm.Case.maybe maybeRoute { nothing = Gen.BackendTask.succeed Elm.nothing @@ -1277,7 +1252,7 @@ otherFile routes phaseString = , routePatternToExpression route ) ] - , Elm.fn ( "param", Nothing ) + , Elm.fn (Elm.Arg.var "param") (\routeParam -> RoutePattern.toVariantName route |> .params @@ -1326,10 +1301,10 @@ otherFile routes phaseString = ) ) - maybeToString : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + maybeToString : Elm.Declare.Function (Elm.Expression -> Elm.Expression) maybeToString = Elm.Declare.fn "maybeToString" - ( "maybeString", Type.maybe Type.string |> Just ) + (Elm.Arg.varWith "maybeString" (Type.maybe Type.string)) (\maybeString -> Elm.Case.maybe maybeString { nothing = Elm.string "Nothing" @@ -1343,10 +1318,10 @@ otherFile routes phaseString = } ) - stringToString : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + stringToString : Elm.Declare.Function (Elm.Expression -> Elm.Expression) stringToString = Elm.Declare.fn "stringToString" - ( "string", Type.string |> Just ) + (Elm.Arg.varWith "string" Type.string) (\string -> Elm.Op.append (Elm.string "\"") @@ -1356,49 +1331,42 @@ otherFile routes phaseString = ) ) - nonEmptyToString : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + nonEmptyToString : Elm.Declare.Function (Elm.Expression -> Elm.Expression) nonEmptyToString = Elm.Declare.fn "nonEmptyToString" - ( "nonEmpty", Type.tuple Type.string (Type.list Type.string) |> Just ) + (Elm.Arg.varWith "nonEmpty" (Type.tuple Type.string (Type.list Type.string))) (\nonEmpty -> Elm.Case.custom nonEmpty Type.unit - [ Elm.Case.Branch.tuple (Elm.Case.Branch.var "first") (Elm.Case.Branch.var "rest") - |> Elm.Case.Branch.map - (\( first, rest ) -> - append - [ Elm.string "( " - , stringToString.call first - , Elm.string ", [ " - , rest - |> Gen.List.call_.map (stringToString.value []) - |> Gen.String.call_.join (Elm.string ", ") - , Elm.string " ] )" - ] - ) + [ Elm.Case.branch + (Elm.Arg.tuple + (Elm.Arg.var "first") + (Elm.Arg.var "rest") + ) + (\( first, rest ) -> + append + [ Elm.string "( " + , stringToString.call first + , Elm.string ", [ " + , rest + |> Gen.List.call_.map stringToString.value + |> Gen.String.call_.join (Elm.string ", ") + , Elm.string " ] )" + ] + ) ] ) - listToString : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + listToString : Elm.Declare.Function (Elm.Expression -> Elm.Expression) listToString = Elm.Declare.fn "listToString" - ( "strings", Type.list Type.string |> Just ) + (Elm.Arg.varWith "strings" (Type.list Type.string)) (\strings -> append [ Elm.string "[ " , strings - |> Gen.List.call_.map (stringToString.value []) + |> Gen.List.call_.map stringToString.value |> Gen.String.call_.join (Elm.string ", ") , Elm.string " ]" ] @@ -1416,62 +1384,51 @@ otherFile routes phaseString = moduleName = "Route." ++ (RoutePattern.toModuleName route |> String.join "__") in - if RoutePattern.hasRouteParams route then - Elm.Case.branch1 moduleName - ( "routeParams", Type.unit ) - (\routeParams -> - toInnerExpression route (Just routeParams) - ) + Elm.Case.branch + (if RoutePattern.hasRouteParams route then + Elm.Arg.customType moduleName Just + |> Elm.Arg.item (Elm.Arg.var "routeParams") - else - Elm.Case.branch0 moduleName - (toInnerExpression route Nothing) + else + Elm.Arg.customType moduleName Nothing + ) + (\routeParams -> toInnerExpression route routeParams) ) ) - encodeActionData : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + encodeActionData : Elm.Declare.Function (Elm.Expression -> Elm.Expression) encodeActionData = Elm.Declare.fn "encodeActionData" - ( "actionData", Type.named [] "ActionData" |> Just ) + (Elm.Arg.varWith "actionData" actionDataType.annotation) (\actionData -> Elm.Case.custom actionData Type.unit (routes |> List.map (\route -> - route - |> destructureRouteVariant ActionData "thisActionData" - |> Elm.Case.Branch.map - (\thisActionData -> - Elm.apply - (route |> encodeRouteType ActionData) - [ thisActionData ] - ) + Elm.Case.branch + (route |> destructureRouteVariant ActionData "thisActionData") + (\thisActionData -> + Elm.apply + (route |> encodeRouteType ActionData) + [ thisActionData ] + ) ) ) |> Elm.withType Gen.Bytes.Encode.annotation_.encoder ) - byteEncodePageData : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + byteEncodePageData : Elm.Declare.Function (Elm.Expression -> Elm.Expression) byteEncodePageData = Elm.Declare.fn "byteEncodePageData" - ( "pageData", Type.named [] "PageData" |> Just ) + (Elm.Arg.varWith "pageData" pageDataType.annotation) (\actionData -> Elm.Case.custom actionData Type.unit - ([ Elm.Case.branch1 - "DataErrorPage____" - ( "thisPageData", Type.unit ) + ([ Elm.Case.branch + (Elm.Arg.customType "DataErrorPage____" identity + |> Elm.Arg.item (Elm.Arg.var "thisPageData") + ) (\thisPageData -> Elm.apply (Elm.value @@ -1482,14 +1439,15 @@ otherFile routes phaseString = ) [ thisPageData ] ) - , Elm.Case.branch0 "Data404NotFoundPage____" (Gen.Bytes.Encode.unsignedInt8 0) + , Elm.Case.branch (Elm.Arg.customType "Data404NotFoundPage____" ()) (\_ -> Gen.Bytes.Encode.unsignedInt8 0) ] ++ (routes |> List.map (\route -> - Elm.Case.branch1 - ("Data" ++ (RoutePattern.toModuleName route |> String.join "__")) - ( "thisPageData", Type.unit ) + Elm.Case.branch + (Elm.Arg.customType ("Data" ++ (RoutePattern.toModuleName route |> String.join "__")) identity + |> Elm.Arg.item (Elm.Arg.var "thisPageData") + ) (\thisPageData -> Elm.apply (route |> encodeRouteType Data) @@ -1501,15 +1459,10 @@ otherFile routes phaseString = |> Elm.withType Gen.Bytes.Encode.annotation_.encoder ) - byteDecodePageData : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + byteDecodePageData : Elm.Declare.Function (Elm.Expression -> Elm.Expression) byteDecodePageData = Elm.Declare.fn "byteDecodePageData" - ( "route", Type.named [ "Route" ] "Route" |> Type.maybe |> Just ) + (Elm.Arg.varWith "maybeRoute" (Type.named [ "Route" ] "Route" |> Type.maybe)) (\maybeRoute -> Elm.Case.maybe maybeRoute { nothing = Gen.Bytes.Decode.values_.fail @@ -1532,43 +1485,38 @@ otherFile routes phaseString = routeVariant = "Route." ++ (RoutePattern.toModuleName route |> String.join "__") in - if RoutePattern.hasRouteParams route then - Elm.Case.branch1 - routeVariant - ( "_", Type.unit ) - (\_ -> - mappedDecoder - ) + Elm.Case.branch + (if RoutePattern.hasRouteParams route then + Elm.Arg.customType routeVariant Just + |> Elm.Arg.item Elm.Arg.ignore - else - Elm.Case.branch0 routeVariant mappedDecoder + else + Elm.Arg.customType routeVariant Nothing + ) + (\_ -> mappedDecoder) ) ) ) } - |> Elm.withType (Gen.Bytes.Decode.annotation_.decoder (Type.named [] "PageData")) + |> Elm.withType (Gen.Bytes.Decode.annotation_.decoder pageDataType.annotation) ) - pathsToGenerateHandler : - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } + pathsToGenerateHandler : Elm.Declare.Value pathsToGenerateHandler = - topLevelValue "pathsToGenerateHandler" + Elm.Declare.value "pathsToGenerateHandler" (Gen.ApiRoute.succeed (Gen.BackendTask.map2 (\pageRoutes apiRoutes -> Elm.Op.append pageRoutes (apiRoutes - |> Gen.List.call_.map (Elm.fn ( "api", Nothing ) (\api -> Elm.Op.append (Elm.string "/") api)) + |> Gen.List.call_.map (Elm.fn (Elm.Arg.var "api") (\api -> Elm.Op.append (Elm.string "/") api)) ) |> Gen.Json.Encode.call_.list Gen.Json.Encode.values_.string |> Gen.Json.Encode.encode 0 ) (Gen.BackendTask.map (Gen.List.call_.map - (Elm.fn ( "route", Nothing ) + (Elm.fn (Elm.Arg.var "route") (\route_ -> Elm.apply (Elm.value @@ -1582,12 +1530,12 @@ otherFile routes phaseString = ) ) ) - getStaticRoutes.reference + getStaticRoutes.value ) - (Elm.Op.cons routePatterns.reference - (Elm.Op.cons apiPatterns.reference + (Elm.Op.cons routePatterns.value + (Elm.Op.cons apiPatterns.value (Gen.Api.routes - getStaticRoutes.reference + getStaticRoutes.value (\_ _ -> Elm.string "") ) ) @@ -1600,18 +1548,14 @@ otherFile routes phaseString = |> Gen.ApiRoute.single ) - apiPatterns : - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } + apiPatterns : Elm.Declare.Value apiPatterns = - topLevelValue "apiPatterns" + Elm.Declare.value "apiPatterns" (Gen.ApiRoute.succeed (Gen.Json.Encode.call_.list Gen.Basics.values_.identity (Gen.Api.routes - getStaticRoutes.reference + getStaticRoutes.value (\_ _ -> Elm.string "") |> Gen.List.call_.map Gen.ApiRoute.values_.toJson ) @@ -1626,13 +1570,9 @@ otherFile routes phaseString = ) ) - routePatterns : - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } + routePatterns : Elm.Declare.Value routePatterns = - topLevelValue "routePatterns" + Elm.Declare.value "routePatterns" (Gen.ApiRoute.succeed (Gen.Json.Encode.list (\info -> @@ -1709,26 +1649,21 @@ otherFile routes phaseString = ) ) - globalHeadTags : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + globalHeadTags : Elm.Declare.Function (Elm.Expression -> Elm.Expression) globalHeadTags = Elm.Declare.fn "globalHeadTags" - ( "htmlToString" - , Type.function - [ Type.maybe - (Type.record - [ ( "indent", Type.int ) - , ( "newLines", Type.bool ) - ] - ) - , Gen.Html.annotation_.html Gen.Basics.annotation_.never - ] - Type.string - |> Just + (Elm.Arg.varWith "htmlToString" + (Type.function + [ Type.maybe + (Type.record + [ ( "indent", Type.int ) + , ( "newLines", Type.bool ) + ] + ) + , Gen.Html.annotation_.html Gen.Basics.annotation_.never + ] + Type.string + ) ) (\htmlToString -> Elm.Op.cons @@ -1736,7 +1671,7 @@ otherFile routes phaseString = |> Elm.get "head" ) (Gen.Api.call_.routes - getStaticRoutes.reference + getStaticRoutes.value htmlToString |> Gen.List.call_.filterMap Gen.ApiRoute.values_.getGlobalHeadTagsBackendTask ) @@ -1749,13 +1684,9 @@ otherFile routes phaseString = ) ) - encodeResponse : - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } + encodeResponse : Elm.Declare.Value encodeResponse = - topLevelValue "encodeResponse" + Elm.Declare.value "encodeResponse" (Elm.apply (Elm.value { annotation = Nothing @@ -1777,8 +1708,8 @@ otherFile routes phaseString = (Type.function [ Type.namedWith [ "Pages", "Internal", "ResponseSketch" ] "ResponseSketch" - [ Type.named [] "PageData" - , Type.named [] "ActionData" + [ pageDataType.annotation + , actionDataType.annotation , Type.named [ "Shared" ] "Data" ] ] @@ -1786,13 +1717,9 @@ otherFile routes phaseString = ) ) - decodeResponse : - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } + decodeResponse : Elm.Declare.Value decodeResponse = - topLevelValue "decodeResponse" + Elm.Declare.value "decodeResponse" (Elm.apply (Elm.value { annotation = Nothing @@ -1813,21 +1740,17 @@ otherFile routes phaseString = |> Elm.withType (Type.namedWith [ "Pages", "Internal", "ResponseSketch" ] "ResponseSketch" - [ Type.named [] "PageData" - , Type.named [] "ActionData" + [ pageDataType.annotation + , actionDataType.annotation , Type.named [ "Shared" ] "Data" ] |> Gen.Bytes.Decode.annotation_.decoder ) ) - getStaticRoutes : - { declaration : Elm.Declaration - , reference : Elm.Expression - , referenceFrom : List String -> Elm.Expression - } + getStaticRoutes : Elm.Declare.Value getStaticRoutes = - topLevelValue "getStaticRoutes" + Elm.Declare.value "getStaticRoutes" (Gen.BackendTask.combine (routes |> List.map @@ -1850,14 +1773,15 @@ otherFile routes phaseString = } else - fnIgnore - (Elm.value - { annotation = Nothing - , name = - (route |> RoutePattern.toModuleName) - |> String.join "__" - , importFrom = [ "Route" ] - } + Elm.fn Elm.Arg.ignore + (\_ -> + Elm.value + { annotation = Nothing + , name = + (route |> RoutePattern.toModuleName) + |> String.join "__" + , importFrom = [ "Route" ] + } ) ) ) @@ -1870,117 +1794,137 @@ otherFile routes phaseString = (Type.list (Type.named [ "Route" ] "Route")) ) ) - in - Elm.file [ "Main" ] - [ Elm.alias "Model" - (Type.record - [ ( "global", Type.named [ "Shared" ] "Model" ) - , ( "page", Type.named [] "PageModel" ) - , ( "current" - , Type.maybe - (Type.record - [ ( "path" - , Type.record - [ ( "path", Type.named [ "UrlPath" ] "UrlPath" ) - , ( "query", Type.string |> Type.maybe ) - , ( "fragment", Type.string |> Type.maybe ) - ] - ) - , ( "metadata", Type.maybe (Type.named [ "Route" ] "Route") ) - , ( "pageUrl", Type.maybe (Type.named [ "Pages", "PageUrl" ] "PageUrl") ) - ] - ) - ) - ] - ) - , Elm.customType "PageModel" - ((routes - |> List.map - (\route -> - Elm.variantWith - ("Model" - ++ (RoutePattern.toModuleName route |> String.join "__") + + modelType : Elm.Declare.Annotation + modelType = + Elm.Declare.alias "Model" + (Type.record + [ ( "global", Type.named [ "Shared" ] "Model" ) + , ( "page", pageModelType.annotation ) + , ( "current" + , Type.maybe + (Type.record + [ ( "path" + , Type.record + [ ( "path", Type.named [ "UrlPath" ] "UrlPath" ) + , ( "query", Type.string |> Type.maybe ) + , ( "fragment", Type.string |> Type.maybe ) + ] + ) + , ( "metadata", Type.maybe (Type.named [ "Route" ] "Route") ) + , ( "pageUrl", Type.maybe (Type.named [ "Pages", "PageUrl" ] "PageUrl") ) + ] ) - [ Type.named - ("Route" - :: RoutePattern.toModuleName route + ) + ] + ) + + pageModelType : Elm.Declare.Annotation + pageModelType = + Elm.Declare.customType "PageModel" + ((routes + |> List.map + (\route -> + Elm.variantWith + ("Model" + ++ (RoutePattern.toModuleName route |> String.join "__") ) - "Model" - ] - ) - ) - ++ [ Elm.variantWith "ModelErrorPage____" - [ Type.named [ "ErrorPage" ] "Model" ] - , Elm.variant "NotFound" - ] - ) - , Elm.customType "Msg" - ((routes - |> List.map - (\route -> - Elm.variantWith - ("Msg" - ++ (RoutePattern.toModuleName route |> String.join "__") - ) - [ Type.named - ("Route" - :: RoutePattern.toModuleName route + [ Type.named + ("Route" + :: RoutePattern.toModuleName route + ) + "Model" + ] + ) + ) + ++ [ Elm.variantWith "ModelErrorPage____" + [ Type.named [ "ErrorPage" ] "Model" ] + , Elm.variant "NotFound" + ] + ) + + msgType : Elm.Declare.Annotation + msgType = + Elm.Declare.customType "Msg" + ((routes + |> List.map + (\route -> + Elm.variantWith + ("Msg" + ++ (RoutePattern.toModuleName route |> String.join "__") ) - "Msg" - ] - ) - ) - ++ [ Elm.variantWith "MsgGlobal" [ Type.named [ "Shared" ] "Msg" ] - , Elm.variantWith "OnPageChange" - [ Type.record - [ ( "protocol", Gen.Url.annotation_.protocol ) - , ( "host", Type.string ) - , ( "port_", Type.maybe Type.int ) - , ( "path", pathType ) - , ( "query", Type.maybe Type.string ) - , ( "fragment", Type.maybe Type.string ) - , ( "metadata", Type.maybe (Type.named [ "Route" ] "Route") ) + [ Type.named + ("Route" + :: RoutePattern.toModuleName route + ) + "Msg" + ] + ) + ) + ++ [ Elm.variantWith "MsgGlobal" [ Type.named [ "Shared" ] "Msg" ] + , Elm.variantWith "OnPageChange" + [ Type.record + [ ( "protocol", Gen.Url.annotation_.protocol ) + , ( "host", Type.string ) + , ( "port_", Type.maybe Type.int ) + , ( "path", pathType ) + , ( "query", Type.maybe Type.string ) + , ( "fragment", Type.maybe Type.string ) + , ( "metadata", Type.maybe (Type.named [ "Route" ] "Route") ) + ] ] - ] - , Elm.variantWith "MsgErrorPage____" [ Type.named [ "ErrorPage" ] "Msg" ] - ] - ) - , Elm.customType "PageData" - ((routes - |> List.map - (\route -> - Elm.variantWith - ("Data" - ++ (RoutePattern.toModuleName route |> String.join "__") - ) - [ Type.named - ("Route" - :: RoutePattern.toModuleName route + , Elm.variantWith "MsgErrorPage____" [ Type.named [ "ErrorPage" ] "Msg" ] + ] + ) + + pageDataType : Elm.Declare.Annotation + pageDataType = + Elm.Declare.customType "PageData" + ((routes + |> List.map + (\route -> + Elm.variantWith + ("Data" + ++ (RoutePattern.toModuleName route |> String.join "__") ) - "Data" - ] - ) - ) - ++ [ Elm.variant "Data404NotFoundPage____" - , Elm.variantWith "DataErrorPage____" [ Type.named [ "ErrorPage" ] "ErrorPage" ] - ] - ) - , Elm.customType "ActionData" - (routes - |> List.map - (\route -> - Elm.variantWith - ("ActionData" - ++ (RoutePattern.toModuleName route |> String.join "__") - ) - [ Type.named - ("Route" - :: RoutePattern.toModuleName route + [ Type.named + ("Route" + :: RoutePattern.toModuleName route + ) + "Data" + ] + ) + ) + ++ [ Elm.variant "Data404NotFoundPage____" + , Elm.variantWith "DataErrorPage____" [ Type.named [ "ErrorPage" ] "ErrorPage" ] + ] + ) + + actionDataType : Elm.Declare.Annotation + actionDataType = + Elm.Declare.customType "ActionData" + (routes + |> List.map + (\route -> + Elm.variantWith + ("ActionData" + ++ (RoutePattern.toModuleName route |> String.join "__") ) - "ActionData" - ] - ) - ) + [ Type.named + ("Route" + :: RoutePattern.toModuleName route + ) + "ActionData" + ] + ) + ) + in + Elm.file [ "Main" ] + [ modelType.declaration + , pageModelType.declaration + , msgType.declaration + , pageDataType.declaration + , actionDataType.declaration , case phase of Browser -> Gen.Pages.Internal.Platform.application config @@ -1988,20 +1932,20 @@ otherFile routes phaseString = (Type.namedWith [ "Platform" ] "Program" [ Gen.Pages.Internal.Platform.annotation_.flags - , Gen.Pages.Internal.Platform.annotation_.model (Type.named [] "Model") - (Type.named [] "PageData") - (Type.named [] "ActionData") + , Gen.Pages.Internal.Platform.annotation_.model modelType.annotation + pageDataType.annotation + actionDataType.annotation (Type.named [ "Shared" ] "Data") , Gen.Pages.Internal.Platform.annotation_.msg - (Type.named [] "Msg") - (Type.named [] "PageData") - (Type.named [] "ActionData") + msgType.annotation + pageDataType.annotation + actionDataType.annotation (Type.named [ "Shared" ] "Data") (Type.named [ "ErrorPage" ] "ErrorPage") ] ) |> Elm.declaration "main" - |> expose + |> Elm.exposeConstructor Cli -> Gen.Pages.Internal.Platform.Cli.cliApplication config @@ -2010,7 +1954,7 @@ otherFile routes phaseString = (Type.named [ "Route" ] "Route" |> Type.maybe) ) |> Elm.declaration "main" - |> expose + |> Elm.exposeConstructor , dataForRoute.declaration , toTriple.declaration , action.declaration @@ -2056,7 +2000,7 @@ otherFile routes phaseString = ] -routeToSyntaxPattern : RoutePattern -> Elm.Case.Branch.Pattern (Maybe Elm.Expression) +routeToSyntaxPattern : RoutePattern -> Elm.Arg (Maybe Elm.Expression) routeToSyntaxPattern route = let moduleName : String @@ -2064,12 +2008,11 @@ routeToSyntaxPattern route = "Route." ++ (RoutePattern.toModuleName route |> String.join "__") in if RoutePattern.hasRouteParams route then - Elm.Case.Branch.variant1 moduleName - (Elm.Case.Branch.var "routeParams" |> Elm.Case.Branch.map Just) - identity + Elm.Arg.customType moduleName Just + |> Elm.Arg.item (Elm.Arg.var "routeParams") else - Elm.Case.Branch.variant0 moduleName Nothing + Elm.Arg.customType moduleName Nothing type RouteVariant @@ -2095,16 +2038,15 @@ routeVariantToString variant = "Msg" -destructureRouteVariant : RouteVariant -> String -> RoutePattern -> Elm.Case.Branch.Pattern Elm.Expression +destructureRouteVariant : RouteVariant -> String -> RoutePattern -> Elm.Arg Elm.Expression destructureRouteVariant variant varName route = let moduleName : String moduleName = routeVariantToString variant ++ (RoutePattern.toModuleName route |> String.join "__") in - Elm.Case.Branch.variant1 moduleName - (Elm.Case.Branch.var varName) - identity + Elm.Arg.customType moduleName identity + |> Elm.Arg.item (Elm.Arg.var varName) routeVariantExpression : RouteVariant -> RoutePattern -> Elm.Expression @@ -2214,7 +2156,7 @@ ignoreBranchIfNeeded : { primary : Elm.Case.Branch, otherwise : Elm.Expression } ignoreBranchIfNeeded info routes = [ info.primary |> Just , if List.length routes > 1 then - Elm.Case.Branch.ignore info.otherwise |> Just + Elm.Case.branch Elm.Arg.ignore (\_ -> info.otherwise) |> Just else Nothing diff --git a/codegen/elm.codegen.json b/codegen/elm.codegen.json index 7f8b0e9a4..88f45337c 100644 --- a/codegen/elm.codegen.json +++ b/codegen/elm.codegen.json @@ -1,5 +1,5 @@ { - "elm-codegen-version": "0.2.0", + "elm-codegen-version": "0.6.0", "codegen-helpers": { "packages": { "elm/core": "1.0.5", diff --git a/codegen/elm.json b/codegen/elm.json index 5bfb2338a..c7dd9dbf6 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -12,23 +12,22 @@ "elm/html": "1.0.0", "elm/json": "1.1.3", "elm/regex": "1.0.0", - "mdgriffith/elm-codegen": "4.2.1", + "mdgriffith/elm-codegen": "5.0.0", "rtfeldman/elm-hex": "1.0.0", - "stil4m/elm-syntax": "7.2.9", - "the-sett/elm-pretty-printer": "3.0.0", + "stil4m/elm-syntax": "7.3.4", + "the-sett/elm-pretty-printer": "3.1.0", "the-sett/elm-string-case": "1.0.2", - "the-sett/elm-syntax-dsl": "6.0.2" + "the-sett/elm-syntax-dsl": "6.0.3" }, "indirect": { "Chadtech/elm-bool-extra": "2.4.2", "elm/parser": "1.1.0", "elm/time": "1.0.0", "elm/url": "1.0.0", - "elm/virtual-dom": "1.0.2", + "elm/virtual-dom": "1.0.3", "elm-community/basics-extra": "4.1.0", - "elm-community/list-extra": "8.6.0", "elm-community/maybe-extra": "5.3.0", - "miniBill/elm-unicode": "1.0.2", + "miniBill/elm-unicode": "1.1.1", "stil4m/structured-writer": "1.0.3" } }, diff --git a/elm.json b/elm.json index e3196b120..734726f75 100644 --- a/elm.json +++ b/elm.json @@ -71,7 +71,7 @@ "elm-community/list-extra": "8.6.0 <= v < 9.0.0", "jluckyiv/elm-utc-date-strings": "1.0.0 <= v < 2.0.0", "justinmimbs/date": "4.0.1 <= v < 5.0.0", - "mdgriffith/elm-codegen": "4.0.0 <= v < 5.0.0", + "mdgriffith/elm-codegen": "5.0.0 <= v < 6.0.0", "miniBill/elm-codec": "2.0.0 <= v < 3.0.0", "noahzgordon/elm-color-extra": "1.0.2 <= v < 2.0.0", "robinheghan/fnv1a": "1.0.0 <= v < 2.0.0", diff --git a/examples/base-path/elm.json b/examples/base-path/elm.json index 807b006ae..1ac98bd48 100644 --- a/examples/base-path/elm.json +++ b/examples/base-path/elm.json @@ -34,7 +34,7 @@ "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", "matheus23/elm-default-tailwind-modules": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", diff --git a/examples/base-path/package-lock.json b/examples/base-path/package-lock.json index a69a9e2b3..388dab1a5 100644 --- a/examples/base-path/package-lock.json +++ b/examples/base-path/package-lock.json @@ -17,33 +17,33 @@ } }, "../..": { - "version": "3.0.14", + "version": "3.0.16", "dev": true, "license": "BSD-3-Clause", "dependencies": { "@sindresorhus/merge-streams": "^3.0.0", "busboy": "^1.6.0", - "chokidar": "^3.6.0", + "chokidar": "^3.5.3", "cli-cursor": "^4.0.0", - "commander": "^12.0.0", + "commander": "^11.1.0", "connect": "^3.7.0", "cookie-signature": "^1.2.1", "cross-spawn": "7.0.3", "devcert": "^1.2.2", "elm-doc-preview": "^5.0.5", "elm-hot": "^1.1.6", - "esbuild": "^0.20.2", + "esbuild": "^0.19.11", "fs-extra": "^11.2.0", - "globby": "14.0.1", + "globby": "14.0.0", "gray-matter": "^4.0.3", "jsesc": "^3.0.2", "kleur": "^4.1.5", "make-fetch-happen": "^13.0.0", - "memfs": "^4.9.1", + "memfs": "^4.6.0", "micromatch": "^4.0.5", "serve-static": "^1.15.0", - "terser": "^5.31.0", - "vite": "^5.2.10", + "terser": "^5.26.0", + "vite": "^5.0.11", "which": "^4.0.0" }, "bin": { @@ -53,20 +53,20 @@ "@types/cross-spawn": "^6.0.6", "@types/fs-extra": "^11.0.4", "@types/make-fetch-happen": "^10.0.4", - "@types/micromatch": "^4.0.7", - "@types/node": "^20.12.7", - "@types/serve-static": "^1.15.7", - "cypress": "^13.8.1", - "elm-codegen": "0.5.0", + "@types/micromatch": "^4.0.6", + "@types/node": "^20.10.7", + "@types/serve-static": "^1.15.5", + "cypress": "^13.6.2", + "elm-codegen": "^0.6.0", "elm-optimize-level-2": "^0.3.5", - "elm-review": "^2.11.1", + "elm-review": "^2.12.0", "elm-test": "^0.19.1-revision12", - "elm-tooling": "^1.15.1", - "elm-verify-examples": "^6.0.3", + "elm-tooling": "^1.15.0", + "elm-verify-examples": "^5.3.0", "lamdera": "^0.19.1-1.2.1-1", - "typescript": "^5.4.5", - "vite": "^5.2.10", - "vitest": "^1.5.2" + "typescript": "^5.3.3", + "vite": "^5.0.11", + "vitest": "^1.1.3" } }, "../../node_modules/@colors/colors": { diff --git a/examples/blog-engine/codegen/elm.codegen.json b/examples/blog-engine/codegen/elm.codegen.json index d6a7f20e7..22c971b57 100644 --- a/examples/blog-engine/codegen/elm.codegen.json +++ b/examples/blog-engine/codegen/elm.codegen.json @@ -1,5 +1,5 @@ { - "elm-codegen-version": "0.2.0", + "elm-codegen-version": "0.6.0", "codegen-helpers": { "packages": { "elm/core": "1.0.5", diff --git a/examples/blog-engine/codegen/elm.json b/examples/blog-engine/codegen/elm.json index 27f10b282..d6ce4c8d1 100644 --- a/examples/blog-engine/codegen/elm.json +++ b/examples/blog-engine/codegen/elm.json @@ -13,7 +13,7 @@ "elm/html": "1.0.0", "elm/json": "1.1.3", "elm/regex": "1.0.0", - "mdgriffith/elm-codegen": "2.0.0", + "mdgriffith/elm-codegen": "5.0.0", "the-sett/elm-syntax-dsl": "6.0.2" }, "indirect": { diff --git a/examples/blog-engine/elm.json b/examples/blog-engine/elm.json index 38777ab3b..e2b9a1ca5 100644 --- a/examples/blog-engine/elm.json +++ b/examples/blog-engine/elm.json @@ -40,7 +40,7 @@ "elm-community/list-extra": "8.7.0", "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "mgold/elm-nonempty-list": "4.2.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", diff --git a/examples/blog-engine/package-lock.json b/examples/blog-engine/package-lock.json index a6eafddf4..a1125a8c2 100644 --- a/examples/blog-engine/package-lock.json +++ b/examples/blog-engine/package-lock.json @@ -17,7 +17,7 @@ "@netlify/functions": "^0.7.2", "@tailwindcss/forms": "^0.3.4", "busboy": "^1.1.0", - "elm-codegen": "^0.3.0", + "elm-codegen": "^0.6.0", "elm-pages": "file:../..", "elm-review": "^2.7.0", "elm-tailwind-modules": "^0.3.2", @@ -28,55 +28,56 @@ } }, "../..": { - "name": "elm-pages", - "version": "3.0.0-beta.41", + "version": "3.0.16", "dev": true, "license": "BSD-3-Clause", "dependencies": { + "@sindresorhus/merge-streams": "^3.0.0", "busboy": "^1.6.0", "chokidar": "^3.5.3", - "commander": "^10.0.1", + "cli-cursor": "^4.0.0", + "commander": "^11.1.0", "connect": "^3.7.0", "cookie-signature": "^1.2.1", "cross-spawn": "7.0.3", "devcert": "^1.2.2", "elm-doc-preview": "^5.0.5", "elm-hot": "^1.1.6", - "esbuild": "^0.17.18", - "fs-extra": "^11.1.1", - "globby": "13.1.4", + "esbuild": "^0.19.11", + "fs-extra": "^11.2.0", + "globby": "14.0.0", "gray-matter": "^4.0.3", "jsesc": "^3.0.2", "kleur": "^4.1.5", - "make-fetch-happen": "^11.1.1", - "memfs": "^3.5.1", + "make-fetch-happen": "^13.0.0", + "memfs": "^4.6.0", "micromatch": "^4.0.5", "serve-static": "^1.15.0", - "terser": "^5.17.1", - "vite": "^4.3.5", - "which": "^3.0.1" + "terser": "^5.26.0", + "vite": "^5.0.11", + "which": "^4.0.0" }, "bin": { "elm-pages": "generator/src/cli.js" }, "devDependencies": { - "@types/cross-spawn": "^6.0.2", - "@types/fs-extra": "^11.0.1", - "@types/make-fetch-happen": "^10.0.1", - "@types/micromatch": "^4.0.2", - "@types/node": "^20.1.0", - "@types/serve-static": "^1.15.1", - "cypress": "^12.13.0", - "elm-codegen": "^0.3.0", + "@types/cross-spawn": "^6.0.6", + "@types/fs-extra": "^11.0.4", + "@types/make-fetch-happen": "^10.0.4", + "@types/micromatch": "^4.0.6", + "@types/node": "^20.10.7", + "@types/serve-static": "^1.15.5", + "cypress": "^13.6.2", + "elm-codegen": "^0.6.0", "elm-optimize-level-2": "^0.3.5", - "elm-review": "^2.10.2", + "elm-review": "^2.12.0", "elm-test": "^0.19.1-revision12", - "elm-tooling": "^1.14.0", - "elm-verify-examples": "^5.2.0", - "elmi-to-json": "^1.4.3", - "typescript": "^5.0.4", - "vite": "^4.3.5", - "vitest": "^0.31.0" + "elm-tooling": "^1.15.0", + "elm-verify-examples": "^5.3.0", + "lamdera": "^0.19.1-1.2.1-1", + "typescript": "^5.3.3", + "vite": "^5.0.11", + "vitest": "^1.1.3" } }, "../../node_modules/@colors/colors": { @@ -797,21 +798,6 @@ "node": ">=8" } }, - "../../node_modules/ajv": { - "version": "6.12.6", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, "../../node_modules/ansi-colors": { "version": "4.1.3", "dev": true, @@ -1010,15 +996,6 @@ "tweetnacl": "^0.14.3" } }, - "../../node_modules/binary": { - "version": "0.3.0", - "dev": true, - "license": "MIT", - "dependencies": { - "buffers": "~0.1.1", - "chainsaw": "~0.1.0" - } - }, "../../node_modules/binary-extensions": { "version": "2.2.0", "dev": true, @@ -1027,23 +1004,6 @@ "node": ">=8" } }, - "../../node_modules/binwrap": { - "version": "0.2.2", - "dev": true, - "license": "MIT", - "dependencies": { - "mustache": "^3.0.1", - "request": "^2.88.0", - "request-promise": "^4.2.4", - "tar": "^4.4.10", - "unzip-stream": "^0.3.0" - }, - "bin": { - "binwrap-install": "bin/binwrap-install", - "binwrap-prepare": "bin/binwrap-prepare", - "binwrap-test": "bin/binwrap-test" - } - }, "../../node_modules/bl": { "version": "4.1.0", "dev": true, @@ -1157,13 +1117,6 @@ "dev": true, "license": "MIT" }, - "../../node_modules/buffers": { - "version": "0.1.1", - "dev": true, - "engines": { - "node": ">=0.2.0" - } - }, "../../node_modules/busboy": { "version": "1.6.0", "dev": true, @@ -1427,14 +1380,6 @@ "node": ">=4" } }, - "../../node_modules/chainsaw": { - "version": "0.1.0", - "dev": true, - "license": "MIT/X11", - "dependencies": { - "traverse": ">=0.3.0 <0.4" - } - }, "../../node_modules/chalk": { "version": "4.1.2", "dev": true, @@ -1503,11 +1448,6 @@ "fsevents": "~2.3.2" } }, - "../../node_modules/chownr": { - "version": "1.1.4", - "dev": true, - "license": "ISC" - }, "../../node_modules/ci-info": { "version": "3.7.0", "dev": true, @@ -2668,18 +2608,6 @@ "node": ">= 8" } }, - "../../node_modules/elmi-to-json": { - "version": "1.4.3", - "dev": true, - "hasInstallScript": true, - "license": "BSD-3-Clause", - "dependencies": { - "binwrap": "0.2.2" - }, - "bin": { - "elmi-to-json": "bin/elmi-to-json" - } - }, "../../node_modules/emoji-regex": { "version": "8.0.0", "dev": true, @@ -3013,11 +2941,6 @@ ], "license": "MIT" }, - "../../node_modules/fast-deep-equal": { - "version": "3.1.3", - "dev": true, - "license": "MIT" - }, "../../node_modules/fast-glob": { "version": "3.2.12", "dev": true, @@ -3033,11 +2956,6 @@ "node": ">=8.6.0" } }, - "../../node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "dev": true, - "license": "MIT" - }, "../../node_modules/fast-levenshtein": { "version": "3.0.0", "dev": true, @@ -3253,14 +3171,6 @@ "node": ">=14.14" } }, - "../../node_modules/fs-minipass": { - "version": "1.2.7", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^2.6.0" - } - }, "../../node_modules/fs-monkey": { "version": "1.0.3", "dev": true, @@ -3471,26 +3381,6 @@ "node": ">=6.0" } }, - "../../node_modules/har-schema": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=4" - } - }, - "../../node_modules/har-validator": { - "version": "5.1.5", - "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, "../../node_modules/has": { "version": "1.0.3", "dev": true, @@ -3994,11 +3884,6 @@ "dev": true, "license": "(AFL-2.1 OR BSD-3-Clause)" }, - "../../node_modules/json-schema-traverse": { - "version": "0.4.1", - "dev": true, - "license": "MIT" - }, "../../node_modules/json-stringify-safe": { "version": "5.0.1", "dev": true, @@ -4392,15 +4277,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "../../node_modules/minipass": { - "version": "2.9.0", - "dev": true, - "license": "ISC", - "dependencies": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, "../../node_modules/minipass-collect": { "version": "1.0.2", "dev": true, @@ -4539,19 +4415,6 @@ "node": ">=8" } }, - "../../node_modules/minipass/node_modules/yallist": { - "version": "3.1.1", - "dev": true, - "license": "ISC" - }, - "../../node_modules/minizlib": { - "version": "1.3.3", - "dev": true, - "license": "MIT", - "dependencies": { - "minipass": "^2.9.0" - } - }, "../../node_modules/mkdirp": { "version": "0.5.6", "dev": true, @@ -4579,17 +4442,6 @@ "dev": true, "license": "MIT" }, - "../../node_modules/mustache": { - "version": "3.2.1", - "dev": true, - "license": "MIT", - "bin": { - "mustache": "bin/mustache" - }, - "engines": { - "npm": ">=1.4.0" - } - }, "../../node_modules/negotiator": { "version": "0.6.3", "dev": true, @@ -4708,14 +4560,6 @@ "node": ">=8" } }, - "../../node_modules/oauth-sign": { - "version": "0.9.0", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "*" - } - }, "../../node_modules/object-inspect": { "version": "1.12.2", "dev": true, @@ -5497,36 +5341,6 @@ "node": ">=8" } }, - "../../node_modules/request": { - "version": "2.88.2", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "engines": { - "node": ">= 6" - } - }, "../../node_modules/request-progress": { "version": "3.0.0", "dev": true, @@ -5535,73 +5349,6 @@ "throttleit": "^1.0.0" } }, - "../../node_modules/request-promise": { - "version": "4.2.6", - "dev": true, - "license": "ISC", - "dependencies": { - "bluebird": "^3.5.0", - "request-promise-core": "1.1.4", - "stealthy-require": "^1.1.1", - "tough-cookie": "^2.3.3" - }, - "engines": { - "node": ">=0.10.0" - }, - "peerDependencies": { - "request": "^2.34" - } - }, - "../../node_modules/request-promise-core": { - "version": "1.1.4", - "dev": true, - "license": "ISC", - "dependencies": { - "lodash": "^4.17.19" - }, - "engines": { - "node": ">=0.10.0" - }, - "peerDependencies": { - "request": "^2.34" - } - }, - "../../node_modules/request/node_modules/http-signature": { - "version": "1.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - }, - "engines": { - "node": ">=0.8", - "npm": ">=1.3.7" - } - }, - "../../node_modules/request/node_modules/jsprim": { - "version": "1.4.2", - "dev": true, - "license": "MIT", - "dependencies": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.4.0", - "verror": "1.10.0" - }, - "engines": { - "node": ">=0.6.0" - } - }, - "../../node_modules/request/node_modules/uuid": { - "version": "3.4.0", - "dev": true, - "license": "MIT", - "bin": { - "uuid": "bin/uuid" - } - }, "../../node_modules/require-directory": { "version": "2.1.1", "dev": true, @@ -6133,14 +5880,6 @@ "dev": true, "license": "MIT" }, - "../../node_modules/stealthy-require": { - "version": "1.1.1", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=0.10.0" - } - }, "../../node_modules/streamsearch": { "version": "1.1.0", "dev": true, @@ -6260,28 +5999,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "../../node_modules/tar": { - "version": "4.4.19", - "dev": true, - "license": "ISC", - "dependencies": { - "chownr": "^1.1.4", - "fs-minipass": "^1.2.7", - "minipass": "^2.9.0", - "minizlib": "^1.3.3", - "mkdirp": "^0.5.5", - "safe-buffer": "^5.2.1", - "yallist": "^3.1.1" - }, - "engines": { - "node": ">=4.5" - } - }, - "../../node_modules/tar/node_modules/yallist": { - "version": "3.1.1", - "dev": true, - "license": "ISC" - }, "../../node_modules/temp": { "version": "0.9.4", "dev": true, @@ -6437,11 +6154,6 @@ "node": ">=0.8" } }, - "../../node_modules/traverse": { - "version": "0.3.9", - "dev": true, - "license": "MIT/X11" - }, "../../node_modules/ts-union": { "version": "2.3.0", "dev": true, @@ -6562,23 +6274,6 @@ "node": ">=8" } }, - "../../node_modules/unzip-stream": { - "version": "0.3.1", - "dev": true, - "license": "MIT", - "dependencies": { - "binary": "^0.3.0", - "mkdirp": "^0.5.1" - } - }, - "../../node_modules/uri-js": { - "version": "4.4.1", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "punycode": "^2.1.0" - } - }, "../../node_modules/url-parse-lax": { "version": "3.0.0", "dev": true, @@ -8022,10 +7717,11 @@ "peer": true }, "node_modules/elm-codegen": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/elm-codegen/-/elm-codegen-0.3.0.tgz", - "integrity": "sha512-IsgEL7HkXA1vuTIoxEKVz04t64u5BAsLYtCwXFvCzo0KHE9xFaM1gOsSxJbO5E92Kp58QFR4C/Km+z4K+RBMMg==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/elm-codegen/-/elm-codegen-0.6.0.tgz", + "integrity": "sha512-zMe3KBsAwEyZSmMfnO+EBpEkEJzSEQZawTs5pob8LeLDmnl0VARl19VEENLvUI2v7x54mAmP20d1YIFO57CXkA==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "chalk": "^4.1.1", "chokidar": "^3.5.1", diff --git a/examples/blog-engine/package.json b/examples/blog-engine/package.json index 35d24ee7c..ad8973b93 100644 --- a/examples/blog-engine/package.json +++ b/examples/blog-engine/package.json @@ -17,7 +17,7 @@ "@netlify/functions": "^0.7.2", "@tailwindcss/forms": "^0.3.4", "busboy": "^1.1.0", - "elm-codegen": "^0.3.0", + "elm-codegen": "^0.6.0", "elm-pages": "file:../..", "elm-review": "^2.7.0", "elm-tailwind-modules": "^0.3.2", diff --git a/examples/blog-engine/script/elm.json b/examples/blog-engine/script/elm.json index 9fbb9c0f6..159c80ebb 100644 --- a/examples/blog-engine/script/elm.json +++ b/examples/blog-engine/script/elm.json @@ -30,9 +30,9 @@ "elm-community/dict-extra": "2.4.0", "elm-community/list-extra": "8.7.0", "jluckyiv/elm-utc-date-strings": "1.0.0", - "justinmimbs/date": "4.0.1", - "matheus23/elm-default-tailwind-modules": "2.0.3", - "mdgriffith/elm-codegen": "4.1.1", + "justinmimbs/date": "4.1.0", + "matheus23/elm-default-tailwind-modules": "4.0.1", + "mdgriffith/elm-codegen": "5.1.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", @@ -41,7 +41,7 @@ "rtfeldman/elm-css": "18.0.0", "rtfeldman/elm-iso8601-date-strings": "1.1.4", "the-sett/elm-pretty-printer": "3.1.0", - "the-sett/elm-syntax-dsl": "6.0.2", + "the-sett/elm-syntax-dsl": "6.0.3", "tripokey/elm-fuzzy": "5.2.1", "turboMaCk/non-empty-list-alias": "1.4.0", "vito/elm-ansi": "10.0.1", @@ -55,10 +55,11 @@ "elm-community/basics-extra": "4.1.0", "elm-community/maybe-extra": "5.3.0", "fredcy/elm-parseint": "2.0.1", + "matheus23/elm-tailwind-modules-base": "1.0.0", "mgold/elm-nonempty-list": "4.2.0", - "miniBill/elm-unicode": "1.0.3", + "miniBill/elm-unicode": "1.1.1", "rtfeldman/elm-hex": "1.0.0", - "stil4m/elm-syntax": "7.2.9", + "stil4m/elm-syntax": "7.3.6", "stil4m/structured-writer": "1.0.3" } }, diff --git a/examples/docs/elm.json b/examples/docs/elm.json index 5df5dd715..5c743f373 100644 --- a/examples/docs/elm.json +++ b/examples/docs/elm.json @@ -37,7 +37,7 @@ "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", "matheus23/elm-default-tailwind-modules": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", diff --git a/examples/end-to-end/codegen/elm.codegen.json b/examples/end-to-end/codegen/elm.codegen.json index 3567e4749..29ad39fab 100644 --- a/examples/end-to-end/codegen/elm.codegen.json +++ b/examples/end-to-end/codegen/elm.codegen.json @@ -1,5 +1,5 @@ { - "elm-codegen-version": "0.2.0", + "elm-codegen-version": "0.6.0", "codegen-helpers": { "packages": { "elm/core": "1.0.5", diff --git a/examples/end-to-end/codegen/elm.json b/examples/end-to-end/codegen/elm.json index 27f10b282..d6ce4c8d1 100644 --- a/examples/end-to-end/codegen/elm.json +++ b/examples/end-to-end/codegen/elm.json @@ -13,7 +13,7 @@ "elm/html": "1.0.0", "elm/json": "1.1.3", "elm/regex": "1.0.0", - "mdgriffith/elm-codegen": "2.0.0", + "mdgriffith/elm-codegen": "5.0.0", "the-sett/elm-syntax-dsl": "6.0.2" }, "indirect": { diff --git a/examples/end-to-end/elm.json b/examples/end-to-end/elm.json index ccb1de6ed..5f2ce71ba 100644 --- a/examples/end-to-end/elm.json +++ b/examples/end-to-end/elm.json @@ -38,7 +38,7 @@ "jgrenat/elm-html-test-runner": "1.0.3", "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "mgold/elm-nonempty-list": "4.2.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", diff --git a/examples/end-to-end/script/elm.json b/examples/end-to-end/script/elm.json index 33c8ad53a..584ece7be 100644 --- a/examples/end-to-end/script/elm.json +++ b/examples/end-to-end/script/elm.json @@ -30,7 +30,7 @@ "elm-explorations/test": "2.2.0", "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.1.0", - "mdgriffith/elm-codegen": "4.2.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "robinheghan/fnv1a": "1.0.0", diff --git a/examples/escaping/codegen/elm.codegen.json b/examples/escaping/codegen/elm.codegen.json index 9062e3383..c915fffb2 100644 --- a/examples/escaping/codegen/elm.codegen.json +++ b/examples/escaping/codegen/elm.codegen.json @@ -1,5 +1,5 @@ { - "elm-codegen-version": "0.2.0", + "elm-codegen-version": "0.6.0", "codegen-helpers": { "packages": { "elm/core": "1.0.5", diff --git a/examples/escaping/codegen/elm.json b/examples/escaping/codegen/elm.json index 2ac14c5c9..1ab96c64e 100644 --- a/examples/escaping/codegen/elm.json +++ b/examples/escaping/codegen/elm.json @@ -30,9 +30,9 @@ "elm-community/dict-extra": "2.4.0", "elm-community/list-extra": "8.7.0", "jluckyiv/elm-utc-date-strings": "1.0.0", - "justinmimbs/date": "4.0.1", - "matheus23/elm-default-tailwind-modules": "2.0.3", - "mdgriffith/elm-codegen": "4.1.1", + "justinmimbs/date": "4.1.0", + "matheus23/elm-default-tailwind-modules": "4.0.1", + "mdgriffith/elm-codegen": "5.1.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", @@ -41,7 +41,7 @@ "rtfeldman/elm-css": "18.0.0", "rtfeldman/elm-iso8601-date-strings": "1.1.4", "the-sett/elm-pretty-printer": "3.1.0", - "the-sett/elm-syntax-dsl": "6.0.2", + "the-sett/elm-syntax-dsl": "6.0.3", "tripokey/elm-fuzzy": "5.2.1", "turboMaCk/non-empty-list-alias": "1.4.0", "vito/elm-ansi": "10.0.1", @@ -55,10 +55,11 @@ "elm-community/basics-extra": "4.1.0", "elm-community/maybe-extra": "5.3.0", "fredcy/elm-parseint": "2.0.1", + "matheus23/elm-tailwind-modules-base": "1.0.0", "mgold/elm-nonempty-list": "4.2.0", - "miniBill/elm-unicode": "1.0.2", + "miniBill/elm-unicode": "1.1.1", "rtfeldman/elm-hex": "1.0.0", - "stil4m/elm-syntax": "7.2.9", + "stil4m/elm-syntax": "7.3.6", "stil4m/structured-writer": "1.0.3" } }, @@ -66,4 +67,4 @@ "direct": {}, "indirect": {} } -} \ No newline at end of file +} diff --git a/examples/escaping/elm.json b/examples/escaping/elm.json index 807b006ae..1ac98bd48 100644 --- a/examples/escaping/elm.json +++ b/examples/escaping/elm.json @@ -34,7 +34,7 @@ "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", "matheus23/elm-default-tailwind-modules": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", diff --git a/examples/escaping/package-lock.json b/examples/escaping/package-lock.json index 3a0ddc488..da0312ab4 100644 --- a/examples/escaping/package-lock.json +++ b/examples/escaping/package-lock.json @@ -17,33 +17,33 @@ } }, "../..": { - "version": "3.0.14", + "version": "3.0.16", "dev": true, "license": "BSD-3-Clause", "dependencies": { "@sindresorhus/merge-streams": "^3.0.0", "busboy": "^1.6.0", - "chokidar": "^3.6.0", + "chokidar": "^3.5.3", "cli-cursor": "^4.0.0", - "commander": "^12.0.0", + "commander": "^11.1.0", "connect": "^3.7.0", "cookie-signature": "^1.2.1", "cross-spawn": "7.0.3", "devcert": "^1.2.2", "elm-doc-preview": "^5.0.5", "elm-hot": "^1.1.6", - "esbuild": "^0.20.2", + "esbuild": "^0.19.11", "fs-extra": "^11.2.0", - "globby": "14.0.1", + "globby": "14.0.0", "gray-matter": "^4.0.3", "jsesc": "^3.0.2", "kleur": "^4.1.5", "make-fetch-happen": "^13.0.0", - "memfs": "^4.9.1", + "memfs": "^4.6.0", "micromatch": "^4.0.5", "serve-static": "^1.15.0", - "terser": "^5.31.0", - "vite": "^5.2.10", + "terser": "^5.26.0", + "vite": "^5.0.11", "which": "^4.0.0" }, "bin": { @@ -53,20 +53,20 @@ "@types/cross-spawn": "^6.0.6", "@types/fs-extra": "^11.0.4", "@types/make-fetch-happen": "^10.0.4", - "@types/micromatch": "^4.0.7", - "@types/node": "^20.12.7", - "@types/serve-static": "^1.15.7", - "cypress": "^13.8.1", - "elm-codegen": "0.5.0", + "@types/micromatch": "^4.0.6", + "@types/node": "^20.10.7", + "@types/serve-static": "^1.15.5", + "cypress": "^13.6.2", + "elm-codegen": "^0.6.0", "elm-optimize-level-2": "^0.3.5", - "elm-review": "^2.11.1", + "elm-review": "^2.12.0", "elm-test": "^0.19.1-revision12", - "elm-tooling": "^1.15.1", - "elm-verify-examples": "^6.0.3", + "elm-tooling": "^1.15.0", + "elm-verify-examples": "^5.3.0", "lamdera": "^0.19.1-1.2.1-1", - "typescript": "^5.4.5", - "vite": "^5.2.10", - "vitest": "^1.5.2" + "typescript": "^5.3.3", + "vite": "^5.0.11", + "vitest": "^1.1.3" } }, "../../node_modules/@colors/colors": { diff --git a/examples/escaping/script/elm.json b/examples/escaping/script/elm.json index 9b5f44c91..aa3ccaff2 100644 --- a/examples/escaping/script/elm.json +++ b/examples/escaping/script/elm.json @@ -32,7 +32,7 @@ "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", "matheus23/elm-default-tailwind-modules": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", diff --git a/examples/hackernews/elm.json b/examples/hackernews/elm.json index 50f07a253..b3a197d28 100644 --- a/examples/hackernews/elm.json +++ b/examples/hackernews/elm.json @@ -36,7 +36,7 @@ "elm-community/list-extra": "8.7.0", "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", - "mdgriffith/elm-codegen": "4.0.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.0.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", diff --git a/examples/hello/elm.json b/examples/hello/elm.json index c6f980527..0494d12f3 100644 --- a/examples/hello/elm.json +++ b/examples/hello/elm.json @@ -32,7 +32,7 @@ "elm-community/list-extra": "8.7.0", "elm-community/result-extra": "2.4.0", "jluckyiv/elm-utc-date-strings": "1.0.0", - "mdgriffith/elm-codegen": "2.1.0", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.0.0", "noahzgordon/elm-color-extra": "1.0.2", "robinheghan/fnv1a": "1.0.0", diff --git a/examples/pokedex/elm.json b/examples/pokedex/elm.json index 6a51789e3..7d349253e 100644 --- a/examples/pokedex/elm.json +++ b/examples/pokedex/elm.json @@ -38,7 +38,7 @@ "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", "matheus23/elm-default-tailwind-modules": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.5.0", diff --git a/examples/routing/elm.json b/examples/routing/elm.json index 8fc65cc17..a5dba9fe9 100644 --- a/examples/routing/elm.json +++ b/examples/routing/elm.json @@ -34,7 +34,7 @@ "lamdera/codecs": "1.0.0", "lamdera/core": "1.0.0", "matheus23/elm-default-tailwind-modules": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", "robinheghan/fnv1a": "1.0.0", diff --git a/examples/routing/package-lock.json b/examples/routing/package-lock.json index b00b31d18..75532e1d7 100644 --- a/examples/routing/package-lock.json +++ b/examples/routing/package-lock.json @@ -17,33 +17,33 @@ } }, "../..": { - "version": "3.0.14", + "version": "3.0.16", "dev": true, "license": "BSD-3-Clause", "dependencies": { "@sindresorhus/merge-streams": "^3.0.0", "busboy": "^1.6.0", - "chokidar": "^3.6.0", + "chokidar": "^3.5.3", "cli-cursor": "^4.0.0", - "commander": "^12.0.0", + "commander": "^11.1.0", "connect": "^3.7.0", "cookie-signature": "^1.2.1", "cross-spawn": "7.0.3", "devcert": "^1.2.2", "elm-doc-preview": "^5.0.5", "elm-hot": "^1.1.6", - "esbuild": "^0.20.2", + "esbuild": "^0.19.11", "fs-extra": "^11.2.0", - "globby": "14.0.1", + "globby": "14.0.0", "gray-matter": "^4.0.3", "jsesc": "^3.0.2", "kleur": "^4.1.5", "make-fetch-happen": "^13.0.0", - "memfs": "^4.9.1", + "memfs": "^4.6.0", "micromatch": "^4.0.5", "serve-static": "^1.15.0", - "terser": "^5.31.0", - "vite": "^5.2.10", + "terser": "^5.26.0", + "vite": "^5.0.11", "which": "^4.0.0" }, "bin": { @@ -53,20 +53,20 @@ "@types/cross-spawn": "^6.0.6", "@types/fs-extra": "^11.0.4", "@types/make-fetch-happen": "^10.0.4", - "@types/micromatch": "^4.0.7", - "@types/node": "^20.12.7", - "@types/serve-static": "^1.15.7", - "cypress": "^13.8.1", - "elm-codegen": "0.5.0", + "@types/micromatch": "^4.0.6", + "@types/node": "^20.10.7", + "@types/serve-static": "^1.15.5", + "cypress": "^13.6.2", + "elm-codegen": "^0.6.0", "elm-optimize-level-2": "^0.3.5", - "elm-review": "^2.11.1", + "elm-review": "^2.12.0", "elm-test": "^0.19.1-revision12", - "elm-tooling": "^1.15.1", - "elm-verify-examples": "^6.0.3", + "elm-tooling": "^1.15.0", + "elm-verify-examples": "^5.3.0", "lamdera": "^0.19.1-1.2.1-1", - "typescript": "^5.4.5", - "vite": "^5.2.10", - "vitest": "^1.5.2" + "typescript": "^5.3.3", + "vite": "^5.0.11", + "vitest": "^1.1.3" } }, "node_modules/@esbuild/aix-ppc64": { diff --git a/examples/smoothies/elm.json b/examples/smoothies/elm.json index fa6a705a7..7bcdfe09f 100644 --- a/examples/smoothies/elm.json +++ b/examples/smoothies/elm.json @@ -37,7 +37,7 @@ "elm-community/list-extra": "8.7.0", "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", - "mdgriffith/elm-codegen": "2.1.0", + "mdgriffith/elm-codegen": "5.0.0", "miniBill/elm-codec": "1.2.0", "noahzgordon/elm-color-extra": "1.0.2", "pablohirafuji/elm-syntax-highlight": "3.4.1", diff --git a/examples/todos/codegen/elm.codegen.json b/examples/todos/codegen/elm.codegen.json index 9062e3383..c915fffb2 100644 --- a/examples/todos/codegen/elm.codegen.json +++ b/examples/todos/codegen/elm.codegen.json @@ -1,5 +1,5 @@ { - "elm-codegen-version": "0.2.0", + "elm-codegen-version": "0.6.0", "codegen-helpers": { "packages": { "elm/core": "1.0.5", diff --git a/examples/todos/codegen/elm.json b/examples/todos/codegen/elm.json index 27f10b282..d6ce4c8d1 100644 --- a/examples/todos/codegen/elm.json +++ b/examples/todos/codegen/elm.json @@ -13,7 +13,7 @@ "elm/html": "1.0.0", "elm/json": "1.1.3", "elm/regex": "1.0.0", - "mdgriffith/elm-codegen": "2.0.0", + "mdgriffith/elm-codegen": "5.0.0", "the-sett/elm-syntax-dsl": "6.0.2" }, "indirect": { diff --git a/examples/todos/elm.json b/examples/todos/elm.json index fdc22b764..a4016e48a 100644 --- a/examples/todos/elm.json +++ b/examples/todos/elm.json @@ -38,7 +38,7 @@ "elm-community/list-extra": "8.7.0", "jluckyiv/elm-utc-date-strings": "1.0.0", "justinmimbs/date": "4.0.1", - "mdgriffith/elm-codegen": "4.1.1", + "mdgriffith/elm-codegen": "5.0.0", "mgold/elm-nonempty-list": "4.2.0", "miniBill/elm-codec": "2.1.0", "noahzgordon/elm-color-extra": "1.0.2", diff --git a/generator/review/elm.json b/generator/review/elm.json index d76d849a3..6b99abe70 100644 --- a/generator/review/elm.json +++ b/generator/review/elm.json @@ -12,7 +12,7 @@ "elm/json": "1.1.3", "elm/regex": "1.0.0", "jfmengels/elm-review": "2.14.0", - "mdgriffith/elm-codegen": "4.2.2", + "mdgriffith/elm-codegen": "5.0.0", "stil4m/elm-syntax": "7.3.2", "the-sett/elm-syntax-dsl": "6.0.3" }, diff --git a/generator/template/codegen/elm.codegen.json b/generator/template/codegen/elm.codegen.json index 565128f86..3ee1c1ce6 100644 --- a/generator/template/codegen/elm.codegen.json +++ b/generator/template/codegen/elm.codegen.json @@ -1,5 +1,5 @@ { - "elm-codegen-version": "0.5.1", + "elm-codegen-version": "0.6.0", "codegen-helpers": { "packages": { "elm/core": "1.0.5", diff --git a/package-lock.json b/package-lock.json index df33374d1..1e6ac5adb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "@types/node": "^20.10.7", "@types/serve-static": "^1.15.5", "cypress": "^13.6.2", - "elm-codegen": "^0.5.0", + "elm-codegen": "^0.6.0", "elm-optimize-level-2": "^0.3.5", "elm-review": "^2.12.0", "elm-test": "^0.19.1-revision12", @@ -2783,10 +2783,11 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/elm-codegen": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/elm-codegen/-/elm-codegen-0.5.0.tgz", - "integrity": "sha512-n4l/LnUZzTjGtWBTjVtVr0S2tCSm4DnB/0joeQyflqs8+AnyyDPUSMioAoPgGEXA1hc01Fwjt99M76YEo/Rvow==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/elm-codegen/-/elm-codegen-0.6.0.tgz", + "integrity": "sha512-zMe3KBsAwEyZSmMfnO+EBpEkEJzSEQZawTs5pob8LeLDmnl0VARl19VEENLvUI2v7x54mAmP20d1YIFO57CXkA==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "chalk": "^4.1.1", "chokidar": "^3.5.1", diff --git a/package.json b/package.json index 4c03365a5..e8a3e2ec5 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@types/node": "^20.10.7", "@types/serve-static": "^1.15.5", "cypress": "^13.6.2", - "elm-codegen": "^0.5.0", + "elm-codegen": "^0.6.0", "elm-optimize-level-2": "^0.3.5", "elm-review": "^2.12.0", "elm-test": "^0.19.1-revision12", diff --git a/src/Scaffold/Form.elm b/src/Scaffold/Form.elm index c09adb2cf..c91ddd5a2 100644 --- a/src/Scaffold/Form.elm +++ b/src/Scaffold/Form.elm @@ -28,6 +28,7 @@ with the wiring form a `Form`. import Cli.Option import Elm import Elm.Annotation as Type +import Elm.Arg import Elm.Declare import Elm.Op import List.Extra @@ -55,113 +56,111 @@ type alias Context = } -formWithFields : Bool -> List ( String, Kind ) -> ({ formState : { errors : Elm.Expression, submitting : Elm.Expression, submitAttempted : Elm.Expression, data : Elm.Expression, expression : Elm.Expression }, params : List { name : String, kind : Kind, param : Elm.Expression } } -> Elm.Expression) -> { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } +formWithFields : Bool -> List ( String, Kind ) -> ({ formState : { errors : Elm.Expression, submitting : Elm.Expression, submitAttempted : Elm.Expression, data : Elm.Expression, expression : Elm.Expression }, params : List { name : String, kind : Kind, param : Elm.Expression } } -> Elm.Expression) -> Elm.Declare.Value formWithFields elmCssView fields viewFn = - Elm.Declare.function "form" - [] - (\_ -> - fields - |> List.foldl - (\( fieldName, kind ) chain -> - chain - |> Elm.Op.pipe - (formField fieldName - (case kind of - FieldText -> - formFieldText - |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) - - FieldInt -> - formFieldInt { invalid = \_ -> Elm.string "" } - |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) - - FieldTextarea -> - formFieldText - |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) - |> Elm.Op.pipe - (formFieldTextarea - { rows = Elm.nothing - , cols = Elm.nothing - } - ) - - FieldFloat -> - formFieldFloat { invalid = \_ -> Elm.string "" } - |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) - - FieldTime -> - formFieldTime { invalid = \_ -> Elm.string "" } - |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) - - FieldDate -> - formFieldDate { invalid = \_ -> Elm.string "" } - |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) - - FieldCheckbox -> - formFieldCheckbox - ) - ) - ) - (Elm.function (List.map fieldToParam fields) - (\params -> - Elm.record - [ ( "combine" - , params - |> List.foldl - (\fieldExpression chain -> - chain - |> Elm.Op.pipe (validationAndMap fieldExpression) - ) - (Elm.val "ParsedForm" - |> Elm.Op.pipe validationSucceed - ) - ) - , ( "view" - , Elm.fn ( "formState", Nothing ) - (\formState -> - let - mappedParams : List { name : String, kind : Kind, param : Elm.Expression } - mappedParams = - params - |> List.Extra.zip fields - |> List.map - (\( ( name, kind ), param ) -> - { name = name - , kind = kind - , param = param - } - ) - in - viewFn - { formState = - { errors = formState |> Elm.get "errors" - , submitting = formState |> Elm.get "submitting" - , submitAttempted = formState |> Elm.get "submitAttempted" - , data = formState |> Elm.get "data" - , expression = formState + Elm.Declare.value "form" + (fields + |> List.foldl + (\( fieldName, kind ) chain -> + chain + |> Elm.Op.pipe + (formField fieldName + (case kind of + FieldText -> + formFieldText + |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) + + FieldInt -> + formFieldInt { invalid = \_ -> Elm.string "" } + |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) + + FieldTextarea -> + formFieldText + |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) + |> Elm.Op.pipe + (formFieldTextarea + { rows = Elm.nothing + , cols = Elm.nothing } - , params = mappedParams - } + ) + + FieldFloat -> + formFieldFloat { invalid = \_ -> Elm.string "" } + |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) + + FieldTime -> + formFieldTime { invalid = \_ -> Elm.string "" } + |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) + + FieldDate -> + formFieldDate { invalid = \_ -> Elm.string "" } + |> Elm.Op.pipe (formFieldRequired (Elm.string "Required")) + + FieldCheckbox -> + formFieldCheckbox + ) + ) + ) + (Elm.function (List.map fieldToParam fields) + (\params -> + Elm.record + [ ( "combine" + , params + |> List.foldl + (\fieldExpression chain -> + chain + |> Elm.Op.pipe (validationAndMap fieldExpression) ) - ) - ] - ) - |> Elm.Op.pipe formInit + (Elm.val "ParsedForm" + |> Elm.Op.pipe validationSucceed + ) + ) + , ( "view" + , Elm.fn (Elm.Arg.var "formState") + (\formState -> + let + mappedParams : List { name : String, kind : Kind, param : Elm.Expression } + mappedParams = + params + |> List.Extra.zip fields + |> List.map + (\( ( name, kind ), param ) -> + { name = name + , kind = kind + , param = param + } + ) + in + viewFn + { formState = + { errors = formState |> Elm.get "errors" + , submitting = formState |> Elm.get "submitting" + , submitAttempted = formState |> Elm.get "submitAttempted" + , data = formState |> Elm.get "data" + , expression = formState + } + , params = mappedParams + } + ) + ) + ] ) - |> Elm.withType - (Type.namedWith [ "Form" ] - (if elmCssView then - "StyledHtmlForm" + |> Elm.Op.pipe formInit + ) + |> Elm.withType + (Type.namedWith [ "Form" ] + (if elmCssView then + "StyledHtmlForm" - else - "HtmlForm" - ) - [ Type.string - , Type.named [] "ParsedForm" - , Type.var "input" - , Type.namedWith [ "PagesMsg" ] "PagesMsg" [ Type.named [] "Msg" ] - ] + else + "HtmlForm" ) + [ Type.string + , Type.named [] "ParsedForm" + , Type.var "input" + , Type.namedWith [ "PagesMsg" ] "PagesMsg" [ Type.named [] "Msg" ] + ] + ) ) @@ -246,29 +245,27 @@ provide { fields, view, elmCssView } = else let - form : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + form : Elm.Declare.Value form = formWithFields elmCssView fields view - formHandlersDeclaration : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + formHandlersDeclaration : Elm.Declare.Value formHandlersDeclaration = -- TODO customizable formHandlers name? - Elm.Declare.function "formHandlers" - [] - (\_ -> - initCombined (Elm.val "Action") (form.call []) - |> Elm.withType - (Type.namedWith [ "Form", "Handler" ] - "Handler" - [ Type.string - , Type.named [] "Action" - ] - ) + Elm.Declare.value "formHandlers" + (initCombined (Elm.val "Action") form.value + |> Elm.withType + (Type.namedWith [ "Form", "Handler" ] + "Handler" + [ Type.string + , Type.named [] "Action" + ] + ) ) in Just - { formHandlers = formHandlersDeclaration.call [] - , form = form.call [] + { formHandlers = formHandlersDeclaration.value + , form = form.value , declarations = [ formWithFields elmCssView fields view |> .declaration , Elm.customType "Action" diff --git a/src/Scaffold/Route.elm b/src/Scaffold/Route.elm index 0e7e6a747..0cee191e5 100644 --- a/src/Scaffold/Route.elm +++ b/src/Scaffold/Route.elm @@ -50,6 +50,7 @@ import Cli.Option as Option import Cli.Validate import Elm import Elm.Annotation +import Elm.Arg import Elm.Declare import Elm.Op import Pages.Internal.RoutePattern as RoutePattern @@ -541,21 +542,16 @@ userFunction : -> { path : String, body : String } userFunction moduleName definitions = let - viewFn : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + viewFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) viewFn = case definitions.localState of Just _ -> Elm.Declare.fn3 "view" - ( "app", Just appType ) - ( "shared" - , Just (Elm.Annotation.named [ "Shared" ] "Model") + (Elm.Arg.varWith "app" appType) + (Elm.Arg.varWith "shared" + (Elm.Annotation.named [ "Shared" ] "Model") ) - ( "model", Just (Elm.Annotation.named [] "Model") ) + (Elm.Arg.varWith "model" (Elm.Annotation.named [] "Model")) (\app shared model -> definitions.view app shared model |> Elm.withType @@ -571,17 +567,12 @@ userFunction moduleName definitions = Nothing -> let - viewDeclaration : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + viewDeclaration : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression) viewDeclaration = Elm.Declare.fn2 "view" - ( "app", Just appType ) - ( "shared" - , Just (Elm.Annotation.named [ "Shared" ] "Model") + (Elm.Arg.varWith "app" appType) + (Elm.Arg.varWith "shared" + (Elm.Annotation.named [ "Shared" ] "Model") ) (\app shared -> definitions.view app shared Elm.unit @@ -595,33 +586,30 @@ userFunction moduleName definitions = ] ) ) + + viewDeclarationExternal : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) + viewDeclarationExternal = + Elm.Declare.fn3 "view" + (Elm.Arg.varWith "app" appType) + (Elm.Arg.varWith "shared" + (Elm.Annotation.named [ "Shared" ] "Model") + ) + (Elm.Arg.varWith "model" (Elm.Annotation.named [] "Model")) + (\_ _ _ -> + Elm.unit + ) in { declaration = viewDeclaration.declaration , call = \app shared _ -> viewDeclaration.call app shared - , callFrom = \a _ c d -> viewDeclaration.callFrom a c d , value = viewDeclaration.value + , internal = viewDeclarationExternal.internal } localDefinitions : Maybe - { updateFn : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } - , initFn : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } - , subscriptionsFn : - { declaration : Elm.Declaration - , call : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression - , value : List String -> Elm.Expression - } + { updateFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) + , initFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression) + , subscriptionsFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression) , state : State } localDefinitions = @@ -630,10 +618,10 @@ userFunction moduleName definitions = (\localState -> { updateFn = Elm.Declare.fn4 "update" - ( "app", Just appType ) - ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") ) - ( "msg", Just (Elm.Annotation.named [] "Msg") ) - ( "model", Just (Elm.Annotation.named [] "Model") ) + (Elm.Arg.varWith "app" appType) + (Elm.Arg.varWith "shared" (Elm.Annotation.named [ "Shared" ] "Model")) + (Elm.Arg.varWith "msg" (Elm.Annotation.named [] "Msg")) + (Elm.Arg.varWith "model" (Elm.Annotation.named [] "Model")) (\app shared msg model -> localState.update app shared msg model |> Elm.withType @@ -644,8 +632,8 @@ userFunction moduleName definitions = ) , initFn = Elm.Declare.fn2 "init" - ( "app", Just appType ) - ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") ) + (Elm.Arg.varWith "app" appType) + (Elm.Arg.varWith "shared" (Elm.Annotation.named [ "Shared" ] "Model")) (\shared app -> localState.init app shared |> Elm.withType @@ -657,10 +645,10 @@ userFunction moduleName definitions = , subscriptionsFn = Elm.Declare.fn4 "subscriptions" - ( "routeParams", "RouteParams" |> Elm.Annotation.named [] |> Just ) - ( "path", Elm.Annotation.namedWith [ "UrlPath" ] "UrlPath" [] |> Just ) - ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") ) - ( "model", localType "Model" |> Just ) + (Elm.Arg.varWith "routeParams" (Elm.Annotation.named [] "RouteParams")) + (Elm.Arg.varWith "path" (Elm.Annotation.named [ "UrlPath" ] "UrlPath")) + (Elm.Arg.varWith "shared" (Elm.Annotation.named [ "Shared" ] "Model")) + (Elm.Arg.varWith "model" (localType "Model")) (\routeParams path shared model -> localState.subscriptions routeParams path shared model |> Elm.withType (Elm.Annotation.namedWith [] "Sub" [ localType "Msg" ]) @@ -669,7 +657,7 @@ userFunction moduleName definitions = } ) - dataFn : { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + dataFn : Elm.Declare.Function (List Elm.Expression -> Elm.Expression) dataFn = case definitions.action of Pages Nothing -> @@ -743,7 +731,7 @@ userFunction moduleName definitions = Elm.unit ) - actionFn : Maybe { declaration : Elm.Declaration, call : List Elm.Expression -> Elm.Expression, callFrom : List String -> List Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + actionFn : Maybe (Elm.Declare.Function (List Elm.Expression -> Elm.Expression)) actionFn = case definitions.action of Action action_ -> @@ -778,10 +766,10 @@ userFunction moduleName definitions = (\_ -> justPagesExpression) ) - headFn : { declaration : Elm.Declaration, call : Elm.Expression -> Elm.Expression, callFrom : List String -> Elm.Expression -> Elm.Expression, value : List String -> Elm.Expression } + headFn : Elm.Declare.Function (Elm.Expression -> Elm.Expression) headFn = Elm.Declare.fn "head" - ( "app", Just appType ) + (Elm.Arg.varWith "app" appType) (definitions.head >> Elm.withType (Elm.Annotation.list diff --git a/tests/Pages/RouteParamsTest.elm b/tests/Pages/RouteParamsTest.elm index 2a6363ef4..d9f9e4694 100644 --- a/tests/Pages/RouteParamsTest.elm +++ b/tests/Pages/RouteParamsTest.elm @@ -256,4 +256,5 @@ toString : Elm.Variant -> String toString variants = Elm.customType "Route" [ variants ] |> Elm.ToString.declaration - |> .body + |> List.map .body + |> String.join "\n\n"