Comparing version 6.0.3--beta to 6.0.4--beta
{ | ||
"name": "elm-spa", | ||
"version": "6.0.3--beta", | ||
"version": "6.0.4--beta", | ||
"description": "single page apps made easy", | ||
@@ -5,0 +5,0 @@ "bin": "dist/src/index.js", |
@@ -9,2 +9,3 @@ "use strict"; | ||
homepage: 'Home_', | ||
redirecting: 'Redirecting_', | ||
notFound: 'NotFound' | ||
@@ -41,2 +42,3 @@ }; | ||
defaults: [ | ||
['Effect.elm'], | ||
['Main.elm'], | ||
@@ -43,0 +45,0 @@ ['Shared.elm'], |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const config_1 = __importDefault(require("../config")); | ||
const utils_1 = require("./utils"); | ||
@@ -11,4 +15,4 @@ exports.default = (pages, options) => ` | ||
${utils_1.pagesModelDefinition(pages, options)} | ||
${utils_1.pagesModelDefinition([[config_1.default.reserved.redirecting]].concat(pages), options)} | ||
`.trimLeft(); |
@@ -8,3 +8,4 @@ "use strict"; | ||
import Browser.Navigation exposing (Key) | ||
import Request exposing (Request) | ||
import Effect exposing (Effect) | ||
import ElmSpa.Internals.Page | ||
${utils_1.paramsImports(pages)} | ||
@@ -16,2 +17,3 @@ import Gen.Model as Model | ||
${utils_1.pagesImports(pages)} | ||
import Request exposing (Request) | ||
import Shared | ||
@@ -31,3 +33,3 @@ import Task | ||
init : Route -> Shared.Model -> Url -> Key -> ( Model, Cmd Msg, Cmd Shared.Msg ) | ||
init : Route -> Shared.Model -> Url -> Key -> ( Model, Effect Msg ) | ||
init route = | ||
@@ -37,3 +39,3 @@ ${utils_1.pagesInitBody(pages)} | ||
update : Msg -> Model -> Shared.Model -> Url -> Key -> ( Model, Cmd Msg, Cmd Shared.Msg ) | ||
update : Msg -> Model -> Shared.Model -> Url -> Key -> ( Model, Effect Msg ) | ||
update msg_ model_ = | ||
@@ -65,45 +67,20 @@ ${utils_1.pagesUpdateBody(pages.filter(page => options.isStatic(page) === false), options)} | ||
type alias Bundle params model msg = | ||
{ init : params -> Shared.Model -> Url -> Key -> ( Model, Cmd Msg, Cmd Shared.Msg ) | ||
, update : params -> msg -> model -> Shared.Model -> Url -> Key -> ( Model, Cmd Msg, Cmd Shared.Msg ) | ||
, view : params -> model -> Shared.Model -> Url -> Key -> View Msg | ||
, subscriptions : params -> model -> Shared.Model -> Url -> Key -> Sub Msg | ||
} | ||
ElmSpa.Internals.Page.Bundle params model msg Shared.Model (Effect Msg) Model Msg (View Msg) | ||
bundle : | ||
(Shared.Model -> Request params -> Page model msg) | ||
-> (params -> model -> Model) | ||
-> (msg -> Msg) | ||
-> Bundle params model msg | ||
bundle page toModel toMsg = | ||
let | ||
mapTriple : | ||
params | ||
-> ( model, Cmd msg, List Shared.Msg ) | ||
-> ( Model, Cmd Msg, Cmd Shared.Msg ) | ||
mapTriple params ( model, cmd, sharedMsgList ) = | ||
( toModel params model | ||
, Cmd.map toMsg cmd | ||
, sharedMsgList | ||
|> List.map (Task.succeed >> Task.perform identity) | ||
|> Cmd.batch | ||
) | ||
in | ||
{ init = | ||
\\params shared url key -> | ||
(page shared (Request.create params url key)).init () | ||
|> mapTriple params | ||
, update = | ||
\\params msg model shared url key -> | ||
(page shared (Request.create params url key)).update msg model | ||
|> mapTriple params | ||
, view = | ||
\\params model shared url key -> | ||
(page shared (Request.create params url key)).view model | ||
|> View.map toMsg | ||
, subscriptions = | ||
\\params model shared url key -> | ||
(page shared (Request.create params url key)).subscriptions model | ||
|> Sub.map toMsg | ||
} | ||
ElmSpa.Internals.Page.bundle | ||
{ redirecting = | ||
{ model = Model.Redirecting_ | ||
, view = View.none | ||
} | ||
, toRoute = Route.fromUrl | ||
, toUrl = Route.toHref | ||
, fromCmd = Effect.fromCmd | ||
, mapEffect = Effect.map toMsg | ||
, mapView = View.map toMsg | ||
, toModel = toModel | ||
, toMsg = toMsg | ||
, page = page | ||
} | ||
@@ -117,4 +94,4 @@ | ||
static view_ toModel = | ||
{ init = \\params _ _ _ -> ( toModel params, Cmd.none, Cmd.none ) | ||
, update = \\params _ _ _ _ _ -> ( toModel params, Cmd.none, Cmd.none ) | ||
{ init = \\params _ _ _ -> ( toModel params, Effect.none ) | ||
, update = \\params _ _ _ _ _ -> ( toModel params, Effect.none ) | ||
, view = \\_ _ _ _ _ -> View.map never view_ | ||
@@ -121,0 +98,0 @@ , subscriptions = \\_ _ _ _ _ -> Sub.none |
@@ -115,5 +115,7 @@ "use strict"; | ||
const pageModuleName = (path) => `Pages.${path.join('.')}`; | ||
exports.pagesModelDefinition = (paths, options) => exports.customType('Model', paths.map(path => options.isStatic(path) | ||
? `${modelVariant(path)} ${params(path)}` | ||
: `${modelVariant(path)} ${params(path)} ${model(path)}`)); | ||
exports.pagesModelDefinition = (paths, options) => exports.customType('Model', paths.map(path => path[0] === config_1.default.reserved.redirecting | ||
? config_1.default.reserved.redirecting | ||
: options.isStatic(path) | ||
? `${modelVariant(path)} ${params(path)}` | ||
: `${modelVariant(path)} ${params(path)} ${model(path)}`)); | ||
exports.pagesMsgDefinition = (paths) => (paths.length === 0) | ||
@@ -153,4 +155,4 @@ ? `type Msg = None` | ||
_ -> | ||
\\_ _ _ -> ( model_, Cmd.none, Cmd.none )`; | ||
exports.pagesViewBody = (paths, options) => exports.indent(caseExpression(paths, { | ||
\\_ _ _ -> ( model_, Effect.none )`; | ||
exports.pagesViewBody = (paths, options) => exports.indent(caseExpressionWithRedirectingModel(`\\_ _ _ -> View.none`, paths, { | ||
variable: 'model_', | ||
@@ -160,3 +162,3 @@ condition: path => `${destructuredModel(path, options)}`, | ||
})); | ||
exports.pagesSubscriptionsBody = (paths, options) => exports.indent(caseExpression(paths, { | ||
exports.pagesSubscriptionsBody = (paths, options) => exports.indent(caseExpressionWithRedirectingModel(`\\_ _ _ -> Sub.none`, paths, { | ||
variable: 'model_', | ||
@@ -166,2 +168,11 @@ condition: path => `${destructuredModel(path, options)}`, | ||
})); | ||
const caseExpressionWithRedirectingModel = (fallback, items, options) => caseExpression([[config_1.default.reserved.redirecting]].concat(items), { | ||
variable: options.variable, | ||
condition: (item) => item[0] === config_1.default.reserved.redirecting | ||
? `Model.${config_1.default.reserved.redirecting}` | ||
: options.condition(item), | ||
result: (item) => item[0] === config_1.default.reserved.redirecting | ||
? fallback | ||
: options.result(item) | ||
}); | ||
const caseExpression = (items, options) => `case ${options.variable} of | ||
@@ -168,0 +179,0 @@ ${items.map(item => ` ${options.condition(item)} ->\n ${options.result(item)}`).join('\n\n')}`; |
{ | ||
"name": "elm-spa", | ||
"version": "6.0.3--beta", | ||
"version": "6.0.4--beta", | ||
"description": "single page apps made easy", | ||
@@ -5,0 +5,0 @@ "bin": "dist/src/index.js", |
@@ -16,3 +16,3 @@ { | ||
"elm/url": "1.0.0", | ||
"ryannhg/elm-spa": "5.0.0" | ||
"ryannhg/elm-spa": "5.1.0" | ||
}, | ||
@@ -19,0 +19,0 @@ "indirect": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64689
41
1014