Merge branch 'next' into strict-mode

This commit is contained in:
Isiah Meadows 2017-03-09 11:54:32 -05:00 committed by GitHub
commit 934e0ac55e
19 changed files with 316 additions and 537 deletions

1
.gitattributes vendored
View file

@ -1,3 +1,4 @@
* text=auto
/mithril.js binary
/mithril.min.js binary
/stream/stream.js binary

View file

@ -10,10 +10,10 @@ cache:
directories:
- node_modules
# Custom install step so the travis scripts don't need to be in package.json
# Custom install step so the travis-only stuff doesn't need to be in package.json
install:
- npm install
- npm install @alrra/travis-scripts@^3.0.1
- npm install @alrra/travis-scripts@^3.0.1 gh-pages@^0.12.0
# Bundle before running tests so the bundle is always up-to-date
before_script: npm run build
@ -21,37 +21,43 @@ before_script: npm run build
# This is the default, but leaving so it is obvious
# script: npm test
# After a successful build create bundles & commit back to the repo
# After a successful build commit changes back to repo
after_success:
- |
# Only want to commit when building a push on whatever $BRANCH is
if [ "$TRAVIS_EVENT_TYPE" == "push" ] && \
[ "$TRAVIS_BRANCH" == "$BRANCH" ] && \
[ "$TRAVIS_REPO_SLUG" == "$REPO" ]
then
# Set up SSH environment
$(npm bin)/set-up-ssh \
--key "$encrypted_8b86e0359d64_key" \
--iv "$encrypted_8b86e0359d64_iv" \
--path-encrypted-key "./.deploy.enc"
# Commit changes (if there were any) from running build earlier
# Commit bundle changes generated in before_script step
# --commands is a weird no-op but required for commit-changes to run
# --branch arg is to ensure this only runs against the `next` branch
$(npm bin)/commit-changes \
--commands "echo committing" \
--commit-message "Bundled output for commit $TRAVIS_COMMIT [skip ci]" \
--branch "$BRANCH"
--branch "next"
# Only want to commit docs when building pushes on master &
# this doesn't have the built-in branch protection likt commit-changes
if [ "$TRAVIS_EVENT_TYPE" == "push" ] && \
[ "$TRAVIS_BRANCH" == "master" ] && \
[ "$TRAVIS_REPO_SLUG" == "lhorie/mithril.js" ]
then
# Generate docs
$(npm-bin) run gendocs
# Commit docs to gh-pages branch
# Using --add to ensure that archived versions aren't lost
# Using --repo to force it to go over SSH so the saved keys are used (tschaub/gh-pages#160)
$(npm bin)/gh-pages --dist ./dist --add --repo "git@github.com:lhorie/mithril.js.git"
else
echo "Not submitting build artifacts"
echo "Not submitting documentation updates"
fi
# Environment configuration
env:
global:
# Restrict the branch this will activate on
- BRANCH=next
- REPO=lhorie/mithril.js
# Set up GH_USER_EMAIL & GH_USER_NAME env variables used by travis-scripts package
- secure: Xvqvm3+PvJu/rs3jl/NNn0RWLkkLkIoPHiL0GCfVRaywgjCYVN02g54NVvIDaOfybqPmu9E6PJFVs92vhF34NMFQHf4EWskynusIGV271R2BV0i+OJBfLMuLgiwm6zRn7/Zw4JvWIUGEwcnlz0qxbqdHsS0SOR3fIkFzePickW0=
- secure: Rf/ldEO9d4vItJhe6EmqWpFAyCARzoCb422nHnjr1hYJknnwIXpgyZ1C/7On/9o7rWPPf+8WcHC/rgjK2rthKCldzdG5I60LfWSNzap9lk3Aa4TpSCoDBuEp7JVvDr5tc3rKnBXVT71hOay7RSx1StWzXiJs9mjaeVMJzYzRT78=

View file

@ -114,7 +114,7 @@ function run(input, output) {
.replace(/(\r|\n)+/g, "\n").replace(/(\r|\n)$/, "") // remove multiline breaks
.replace(versionTag, isFile(packageFile) ? parse(packageFile).version : versionTag) // set version
code = "new function() {\n" + code + "\n}"
code = ";(function() {\n" + code + "\n}());"
if (!isFile(output) || code !== read(output)) {
//try {new Function(code); console.log("build completed at " + new Date())} catch (e) {}

View file

@ -24,7 +24,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b = 1\n}")
o(read("out.js")).equals(";(function() {\nvar b = 1\n}());")
remove("a.js")
remove("b.js")
@ -35,7 +35,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1;")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b = 1;\n}")
o(read("out.js")).equals(";(function() {\nvar b = 1;\n}());")
remove("a.js")
remove("b.js")
@ -46,7 +46,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nlet b = 1\n}")
o(read("out.js")).equals(";(function() {\nlet b = 1\n}());")
remove("a.js")
remove("b.js")
@ -57,7 +57,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nconst b = 1\n}")
o(read("out.js")).equals(";(function() {\nconst b = 1\n}());")
remove("a.js")
remove("b.js")
@ -68,7 +68,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar a = {}\na.b = 1\n}")
o(read("out.js")).equals(";(function() {\nvar a = {}\na.b = 1\n}());")
remove("a.js")
remove("b.js")
@ -79,7 +79,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b = {}\nb = 1\n}")
o(read("out.js")).equals(";(function() {\nvar b = {}\nb = 1\n}());")
remove("a.js")
remove("b.js")
@ -90,7 +90,7 @@ o.spec("bundler", function() {
write("b.js", '"use strict"\nmodule.exports = 1')
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals('new function() {\n"use strict"\nvar b = 1\n}')
o(read("out.js")).equals(";(function() {\n"use strict"\nvar b = 1\n}());")
remove("a.js")
remove("b.js")
@ -101,7 +101,7 @@ o.spec("bundler", function() {
write("b.js", "'use strict'\nmodule.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\n'use strict'\nvar b = 1\n}")
o(read("out.js")).equals(";(function() {\n'use strict'\nvar b = 1\n}());")
remove("a.js")
remove("b.js")
@ -112,7 +112,7 @@ o.spec("bundler", function() {
write("b.js", "'use strict'\nmodule.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals('new function() {\n"use strict"\nvar b = 1\n}')
o(read("out.js")).equals(";(function() {\n"use strict"\nvar b = 1\n}());")
remove("a.js")
remove("b.js")
@ -123,7 +123,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = function() {return a}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nwindow.a = 1\nvar b = function() {return a}\n}")
o(read("out.js")).equals(";(function() {\nwindow.a = 1\nvar b = function() {return a}\n}());")
remove("a.js")
remove("b.js")
@ -134,7 +134,7 @@ o.spec("bundler", function() {
write("b.js", "1 + 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\n1 + 1\n}")
o(read("out.js")).equals(";(function() {\n1 + 1\n}());")
remove("a.js")
remove("b.js")
@ -145,7 +145,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = []")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar _0 = []\nvar b = _0.toString()\n}")
o(read("out.js")).equals(";(function() {\nvar _0 = []\nvar b = _0.toString()\n}());")
remove("a.js")
remove("b.js")
@ -156,7 +156,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = []")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar _0 = []\nvar b = _0\n\t.toString()\n}")
o(read("out.js")).equals(";(function() {\nvar _0 = []\nvar b = _0\n\t.toString()\n}());")
remove("a.js")
remove("b.js")
@ -167,7 +167,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = function() {}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar _0 = function() {}\nvar b = _0()\n}")
o(read("out.js")).equals(";(function() {\nvar _0 = function() {}\nvar b = _0()\n}());")
remove("a.js")
remove("b.js")
@ -178,7 +178,7 @@ o.spec("bundler", function() {
write("b.js", "module.exports = function() {}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar _0 = function() {}\nvar b = _0\n()\n}")
o(read("out.js")).equals(";(function() {\nvar _0 = function() {}\nvar b = _0\n()\n}());")
remove("a.js")
remove("b.js")
@ -190,7 +190,7 @@ o.spec("bundler", function() {
write("c.js", 'var b = require("./b")\nmodule.exports = function() {return b}')
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar _0 = []\nvar b = _0.toString()\nvar b0 = _0\nvar c = function() {return b0}\n}")
o(read("out.js")).equals(";(function() {\nvar _0 = []\nvar b = _0.toString()\nvar b0 = _0\nvar c = function() {return b0}\n}());")
remove("a.js")
remove("b.js")
@ -203,7 +203,7 @@ o.spec("bundler", function() {
write("c.js", "var x\nmodule.exports = 2")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b = 1\nvar x\nvar c = 2\n}")
o(read("out.js")).equals(";(function() {\nvar b = 1\nvar x\nvar c = 2\n}());")
remove("a.js")
remove("b.js")
@ -216,7 +216,7 @@ o.spec("bundler", function() {
write("c.js", "var cc = 2\nmodule.exports = cc")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar x = {}\nvar bb = 1\nx.b = bb\nvar cc = 2\nx.c = cc\n}")
o(read("out.js")).equals(";(function() {\nvar x = {}\nvar bb = 1\nx.b = bb\nvar cc = 2\nx.c = cc\n}());")
remove("a.js")
remove("b.js")
@ -229,7 +229,7 @@ o.spec("bundler", function() {
write("c.js", "var cc = 2\nmodule.exports = cc")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals('new function() {\nvar x = {}\nvar bb = 1\nx["b"] = bb\nvar cc = 2\nx["c"] = cc\n}')
o(read("out.js")).equals(";(function() {\nvar x = {}\nvar bb = 1\nx["b"] = bb\nvar cc = 2\nx["c"] = cc\n}());")
remove("a.js")
remove("b.js")
@ -241,7 +241,7 @@ o.spec("bundler", function() {
write("b.js", "var b = 1\nmodule.exports = 2")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b0 = 1\nvar b = 2\n}")
o(read("out.js")).equals(";(function() {\nvar b0 = 1\nvar b = 2\n}());")
remove("a.js")
remove("b.js")
@ -253,7 +253,7 @@ o.spec("bundler", function() {
write("c.js", "var b = {}\nmodule.exports = b")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b = {}\nb.x = 1\n}")
o(read("out.js")).equals(";(function() {\nvar b = {}\nb.x = 1\n}());")
remove("a.js")
remove("b.js")
@ -267,7 +267,7 @@ o.spec("bundler", function() {
write("d.js", "var a = 3\nmodule.exports = a")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar a = 1\nvar b = a\nvar a0 = 2\nvar c = a0\nvar a1 = 3\nvar d = a1\n}")
o(read("out.js")).equals(";(function() {\nvar a = 1\nvar b = a\nvar a0 = 2\nvar c = a0\nvar a1 = 3\nvar d = a1\n}());")
remove("a.js")
remove("b.js")
@ -281,7 +281,7 @@ o.spec("bundler", function() {
write("c.js", 'var a = require("./a").toString()\nvar b = require("./b")')
bundle(ns + "c.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar _0 = 123\nvar a = _0.toString()\nvar a0 = _0.toString()\nvar b = a0\n}")
o(read("out.js")).equals(";(function() {\nvar _0 = 123\nvar a = _0.toString()\nvar a0 = _0.toString()\nvar b = a0\n}());")
remove("a.js")
remove("b.js")
@ -293,7 +293,7 @@ o.spec("bundler", function() {
write("c.js", 'var b = require("./b")\nvar a = require("./a").toString()')
bundle(ns + "c.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar _0 = 123\nvar a0 = _0.toString()\nvar b = a0\nvar a = _0.toString()\n}")
o(read("out.js")).equals(";(function() {\nvar _0 = 123\nvar a0 = _0.toString()\nvar b = a0\nvar a = _0.toString()\n}());")
remove("a.js")
remove("b.js")
@ -306,7 +306,7 @@ o.spec("bundler", function() {
write("d.js", "module.exports = 1")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar d = 1\nvar b = function() {return d + 1}\nvar c = function() {return d + 2}\n}")
o(read("out.js")).equals(";(function() {\nvar d = 1\nvar b = function() {return d + 1}\nvar c = function() {return d + 2}\n}());")
remove("a.js")
remove("b.js")
@ -319,7 +319,7 @@ o.spec("bundler", function() {
write("b.js", "var b = 1\nmodule.exports = function() {return b}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b0 = 1\nvar b = function() {return b0}\n}")
o(read("out.js")).equals(";(function() {\nvar b0 = 1\nvar b = function() {return b0}\n}());")
remove("a.js")
remove("b.js")
@ -330,7 +330,7 @@ o.spec("bundler", function() {
write("b.js", "var a = 2\nmodule.exports = function() {return a}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar a = 1\nvar a0 = 2\nvar b = function() {return a0}\n}")
o(read("out.js")).equals(";(function() {\nvar a = 1\nvar a0 = 2\nvar b = function() {return a0}\n}());")
remove("a.js")
remove("b.js")
@ -341,7 +341,7 @@ o.spec("bundler", function() {
write("b.js", "var a = 2\nmodule.exports = function() {return a}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nfunction a() {}\nvar a0 = 2\nvar b = function() {return a0}\n}")
o(read("out.js")).equals(";(function() {\nfunction a() {}\nvar a0 = 2\nvar b = function() {return a0}\n}());")
remove("a.js")
remove("b.js")
@ -353,7 +353,7 @@ o.spec("bundler", function() {
write("c.js", "var a = 2\nmodule.exports = function() {return a}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar a = 1\nvar b = function() {return a}\nvar a0 = 2\nvar c = function() {return a0}\n}")
o(read("out.js")).equals(";(function() {\nvar a = 1\nvar b = function() {return a}\nvar a0 = 2\nvar c = function() {return a0}\n}());")
remove("a.js")
remove("b.js")
@ -365,7 +365,7 @@ o.spec("bundler", function() {
write("b.js", 'var b = "b b b \\" b"\nmodule.exports = function() {return b}')
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals('new function() {\nvar b0 = "b b b \\" b"\nvar b = function() {return b0}\n}')
o(read("out.js")).equals(';(function() {\nvar b0 = "b b b \\\" b"\nvar b = function() {return b0}\n}());')
remove("a.js")
remove("b.js")
@ -376,7 +376,7 @@ o.spec("bundler", function() {
write("b.js", "var b = {b: 1}\nmodule.exports = function() {return b.b}")
bundle(ns + "a.js", ns + "out.js")
o(read("out.js")).equals("new function() {\nvar b0 = {b: 1}\nvar b = function() {return b0.b}\n}")
o(read("out.js")).equals(";(function() {\nvar b0 = {b: 1}\nvar b = function() {return b0.b}\n}());")
remove("a.js")
remove("b.js")

1
docs/CNAME Normal file
View file

@ -0,0 +1 @@
mithril.js.org

View file

@ -5,13 +5,13 @@ var path = require("path")
var marked = require("marked")
var layout = fs.readFileSync("./docs/layout.html", "utf-8")
var version = JSON.parse(fs.readFileSync("./package.json", "utf-8")).version
try {fs.mkdirSync("../mithril")} catch (e) {/* ignore */}
try {fs.mkdirSync("../mithril/archive")} catch (e) {/* ignore */}
try {fs.mkdirSync("../mithril/archive/v" + version)} catch (e) {/* ignore */}
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib")} catch (e) {/* ignore */}
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib/prism")} catch (e) {/* ignore */}
try {fs.mkdirSync("../mithril/lib")} catch (e) {/* ignore */}
try {fs.mkdirSync("../mithril/lib/prism")} catch (e) {/* ignore */}
try {fs.mkdirSync("./dist")} catch (e) {/* ignore */}
try {fs.mkdirSync("./dist/archive")} catch (e) {/* ignore */}
try {fs.mkdirSync("./dist/archive/v" + version)} catch (e) {/* ignore */}
try {fs.mkdirSync("./dist/archive/v" + version + "/lib")} catch (e) {/* ignore */}
try {fs.mkdirSync("./dist/archive/v" + version + "/lib/prism")} catch (e) {/* ignore */}
try {fs.mkdirSync("./dist/lib")} catch (e) {/* ignore */}
try {fs.mkdirSync("./dist/lib/prism")} catch (e) {/* ignore */}
var guides = fs.readFileSync("docs/guides.md", "utf-8")
var methods = fs.readFileSync("docs/methods.md", "utf-8")
@ -57,12 +57,12 @@ function generate(pathname) {
.replace(/<h(.) id="([^"]+?)">(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
return "<h" + n + ' id="' + text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/<a.*?>.+?<\/a>/g, "").replace(/\.|\[|\]|&quot;|\/|\(|\)/g, "").replace(/\s/g, "-") + '">' + text + "</h" + n + ">"
})
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
fs.writeFileSync("./dist/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
fs.writeFileSync("./dist/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
}
else if (!pathname.match(/lint|generate/)) {
fs.writeFileSync("../mithril/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
fs.writeFileSync("../mithril/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
fs.writeFileSync("./dist/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
fs.writeFileSync("./dist/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
}
}
}

View file

@ -257,8 +257,6 @@ In the example above, we defined a route `/edit/:id`. This creates a dynamic rou
It's possible to have multiple arguments in a route, for example `/edit/:projectID/:userID` would yield the properties `projectID` and `userID` on the component's vnode attributes object.
In addition to routing parameters, the `attrs` object also includes a `path` property that contains the current route path, and a `route` property that contains the matched routed.
#### Key parameter
When a user navigates from a parameterized route to the same route with a different parameter (e.g. going from `/page/1` to `/page/2` given a route `/page/:id`, the component would not be recreated from scratch since both routes resolve to the same component, and thus result in a virtual dom in-place diff. This has the side-effect of triggering the `onupdate` hook, rather than `oninit`/`oncreate`. However, it's relatively common for a developer to want to synchronize the recreation of the component to the route change event.

View file

@ -40,6 +40,14 @@ Streams are NOT bundled with Mithril's core distribution. To include the Streams
var Stream = require("mithril/stream")
```
You can also download the module directly if your environment does not support a bundling toolchain:
```markup
<script src="https://unpkg.com/mithril-stream"></script>
```
When loaded directly with a `<script>` tag (rather than required), the stream library will be exposed as `window.m.stream`. If `window.m` is already defined (e.g. because you also use the main Mithril script), it will attach itself to the existing object. Otherwise it creates a new `window.m`. If you want to use streams in conjunction with Mithril as raw script tags, you should include Mithril in your page before `mithril-stream`, because `mithril` will otherwise overwrite the `window.m` object defined by `mithril-stream`. This is not a concern when the libraries are consumed as CommonJS modules (using `require(...)`).
---
### Signature

View file

@ -73,9 +73,11 @@ Property | Type | Description
`text` | `(String|Number|Boolean)?` | This is used instead of `children` if a vnode contains a text node as its only child. This is done for performance reasons. Component vnodes never use the `text` property even if they have a text node as their only child.
`dom` | `Element?` | Points to the element that corresponds to the vnode. This property is `undefined` in the `oninit` lifecycle method. In fragments and trusted HTML vnodes, `dom` points to the first element in the range.
`domSize` | `Number?` | This is only set in fragment and trusted HTML vnodes, and it's `undefined` in all other vnode types. It defines the number of DOM elements that the vnode represents (starting from the element referenced by the `dom` property).
`state` | `Object` | An object that is persisted between redraws. In component vnodes, `state` is a shallow clone of the component object.
`state` | `Object`? | An object that is persisted between redraws. It is provided by the core engine when needed. In component vnodes, the `state` inherits prototypically from the component object/class.
`events` | `Object?` | An object that is persisted between redraws and that stores event handlers so that they can be removed using the DOM API. The `events` property is `undefined` if there are no event handlers defined. This property is only used internally by Mithril, do not use it.
---
### Vnode types

View file

@ -38,7 +38,7 @@ var state = {
update: function(title) {
if (state.editing != null) {
state.editing.title = title.trim()
if (state.editing.title === "") destroy(state.editing)
if (state.editing.title === "") state.destroy(state.editing)
state.editing = null
}
},
@ -104,7 +104,7 @@ var Todos = {
m("label", {ondblclick: function() {state.dispatch("edit", [todo])}}, todo.title),
m("button.destroy", {onclick: function() {state.dispatch("destroy", [todo])}}),
]),
m("input.edit", {onupdate: function(vnode) {ui.focus(vnode, todo)}, onkeypress: ui.save, onblur: ui.save})
m("input.edit", {onupdate: function(vnode) {ui.focus(vnode, todo)}, onkeyup: ui.save, onblur: ui.save})
])
}),
]),

308
mithril.d.ts vendored
View file

@ -1,308 +0,0 @@
// Type definitions for mithril.js 1.0
// Project: https://github.com/lhorie/mithril.js
// Definitions by: Mike Linkovich <https://github.com/spacejack>
declare namespace Mithril {
interface Lifecycle<A,S> {
/** The oninit hook is called before a vnode is touched by the virtual DOM engine. */
oninit?: (this: S, vnode: Vnode<A,S>) => void;
/** The oncreate hook is called after a DOM element is created and attached to the document. */
oncreate?: (this: S, vnode: VnodeDOM<A,S>) => void;
/** The onbeforeupdate hook is called before a vnode is diffed in a update. */
onbeforeupdate?: (this: S, vnode: Vnode<A,S>, old: Vnode<A,S>) => boolean;
/** The onupdate hook is called after a DOM element is updated, while attached to the document. */
onupdate?: (this: S, vnode: VnodeDOM<A,S>) => void;
/** The onbeforeremove hook is called before a DOM element is detached from the document. If a Promise is returned, Mithril only detaches the DOM element after the promise completes. */
onbeforeremove?: (this: S, vnode: VnodeDOM<A,S>) => Promise<any> | void;
/** The onremove hook is called before a DOM element is removed from the document. */
onremove?: (this: S, vnode: VnodeDOM<A,S>) => void;
}
interface Hyperscript {
/** Creates a virtual element (Vnode). */
(selector: string, ...children: any[]): Vnode<any,any>;
/** Creates a virtual element (Vnode). */
<A,S>(component: Component<A,S> | {new(vnode: CVnode<A>): ClassComponent<A>} | FactoryComponent<A,S>, a?: (A & Lifecycle<A,S>) | Children, ...children: Children[]): Vnode<A,S>;
/** Creates a fragment virtual element (Vnode). */
fragment(attrs: any, children: Children[]): Vnode<any,any>;
/** Turns an HTML string into a virtual element (Vnode). Do not use trust on unsanitized user input. */
trust(html: string): Vnode<any,any>;
}
interface RouteResolver {
/** The onmatch hook is called when the router needs to find a component to render. */
onmatch?: (args: any, requestedPath: string) => Mithril.Component<any,any> | {new(vnode: CVnode<any>): ClassComponent<any>} | FactoryComponent<any,any> | Promise<Mithril.Component<any,any> | {new(): Component<any,any>} | FactoryComponent<any,any>> | void;
/** The render method is called on every redraw for a matching route. */
render?: (vnode: Mithril.Vnode<any,any>) => Children;
}
interface RouteDefs {
[url: string]: Component<any,any> | {new(vnode: CVnode<any>): ClassComponent<any>} | FactoryComponent<any,any> | RouteResolver;
}
interface RouteOptions {
replace?: boolean;
state?: any;
title?: string;
}
interface Route {
/** Creates application routes and mounts Components and/or RouteResolvers to a DOM element. */
(element: HTMLElement, defaultRoute: string, routes: RouteDefs): void;
/** Returns the last fully resolved routing path, without the prefix. */
get(): string;
/** Redirects to a matching route or to the default route if no matching routes can be found. */
set(route: string, data?: any, options?: RouteOptions): void;
/** Defines a router prefix which is a fragment of the URL that dictates the underlying strategy used by the router. */
prefix(urlFragment: string): void;
/** This method is meant to be used in conjunction with an <a> Vnode's oncreate hook. */
link(vnode: Vnode<any,any>): (e: Event) => void;
/** Returns the named parameter value from the current route. */
param(name?: string): any;
}
interface Mount {
/** Mounts a component to a DOM element, enabling it to autoredraw on user events. */
(element: Element, component: Component<any,any> | {new(vnode: CVnode<any>): ClassComponent<any>} | FactoryComponent<any,any> | null): void;
}
interface WithAttr {
/** Creates an event handler which takes the value of the specified DOM element property and calls a function with it as the argument. */
(name: string, callback: (value: any) => void, thisArg?: any): (e: {currentTarget: any, [p: string]: any}) => boolean;
}
interface ParseQueryString {
/** Returns an object with key/value pairs parsed from a string of the form: ?a=1&b=2 */
(queryString: string): any;
}
interface BuildQueryString {
/** Turns the key/value pairs of an object into a string of the form: a=1&b=2 */
(values: {[p: string]: any}): string;
}
interface RequestOptions<T> {
method?: string;
data?: any;
async?: boolean;
user?: string;
password?: string;
withCredentials?: boolean;
config?: (xhr: XMLHttpRequest) => void;
headers?: any;
type?: any;
serialize?: (data: any) => string;
deserialize?: (str: string) => T;
extract?: (xhr: XMLHttpRequest, options: RequestOptions<T>) => string;
useBody?: boolean;
background?: boolean;
}
interface RequestOptionsAll<T> extends RequestOptions<T> {
url: string;
}
interface Request {
/** Makes an XHR request and returns a promise. */
<T>(options: RequestOptionsAll<T>): Promise<T>;
/** Makes an XHR request and returns a promise. */
<T>(url: string, options?: RequestOptions<T>): Promise<T>;
}
interface JsonpOptions {
data?: any;
type?: any;
callbackName?: string;
callbackKey?: string;
background?: boolean;
}
interface JsonpOptionsAll extends JsonpOptions {
url: string;
}
interface Jsonp {
/** Makes a JSON-P request and returns a promise. */
<T>(options: JsonpOptionsAll): Promise<T>;
/** Makes a JSON-P request and returns a promise. */
<T>(url: string, options?: JsonpOptions): Promise<T>;
}
interface RequestService {
request: Request;
jsonp: Jsonp;
}
interface Render {
/** Renders a vnode structure into a DOM element. */
(el: Element, vnodes: Children): void;
}
interface RenderService {
render: Render
}
interface Redraw {
/** Manually triggers a redraw of mounted components. */
(): void;
}
interface RedrawService {
redraw: Redraw
render: Render
}
interface Static extends Hyperscript {
route: Route;
mount: Mount;
withAttr: WithAttr;
render: Render;
redraw: Redraw;
request: Request;
jsonp: Jsonp;
parseQueryString: ParseQueryString;
buildQueryString: BuildQueryString;
version: string;
}
// Vnode children types
type Child = Vnode<any,any> | string | number | boolean | null | undefined;
interface ChildArray extends Array<Children> {}
type Children = Child | ChildArray;
interface Vnode<A, S extends Lifecycle<A,S>> {
tag: string | Component<A,S>;
attrs: A;
state: S;
key?: string;
children?: Vnode<any,any>[];
events?: any;
}
// In some lifecycle methods, Vnode will have a dom property
// and possibly a domSize property.
interface VnodeDOM<A,S> extends Vnode<A,S> {
dom: Element;
domSize?: number;
}
interface CVnode<A> extends Vnode<A, ClassComponent<A>> {}
interface CVnodeDOM<A> extends VnodeDOM<A, ClassComponent<A>> {}
interface Component<A, S extends Lifecycle<A,S>> extends Lifecycle<A,S> {
view (this: S, vnode: Vnode<A,S>): Vnode<any,any> | null | void | (Vnode<any,any> | null | void)[];
}
interface ClassComponent<A> extends Lifecycle<A,ClassComponent<A>> {
view (this: ClassComponent<A>, vnode: CVnode<A>): Vnode<any,any> | null | void | (Vnode<any,any> | null | void)[];
}
// Factory component
type FactoryComponent<A,S> = (vnode: Vnode<A,S>) => Component<A,S>
type Unary<T,U> = (input: T) => U;
interface Functor<T> {
map<U>(f: Unary<T,U>): Functor<U>;
ap?(f: Functor<T>): Functor<T>;
}
interface Stream<T> {
/** Returns the value of the stream. */
(): T;
/** Sets the value of the stream. */
(value: T): this;
/** Creates a dependent stream whose value is set to the result of the callback function. */
map(f: (current: T) => Stream<T> | T | void): Stream<T>;
/** Creates a dependent stream whose value is set to the result of the callback function. */
map<U>(f: (current: T) => Stream<U> | U): Stream<U>;
/** This method is functionally identical to stream. It exists to conform to Fantasy Land's Applicative specification. */
of(val?: T): Stream<T>;
/** Apply. */
ap<U>(f: Stream<(value: T) => U>): Stream<U>;
/** A co-dependent stream that unregisters dependent streams when set to true. */
end: Stream<boolean>;
}
type StreamCombiner<T> = (...streams: any[]) => T
interface StreamFactory {
/** Creates a stream. */
<T>(val?: T): Stream<T>;
/** Creates a computed stream that reactively updates if any of its upstreams are updated. */
combine<T>(combiner: StreamCombiner<T>, streams: Stream<any>[]): Stream<T>;
/** Creates a stream whose value is the array of values from an array of streams. */
merge(streams: Stream<any>[]): Stream<any[]>;
/** A special value that can be returned to stream callbacks to halt execution of downstreams. */
HALT: any;
}
interface StreamScan {
/** Creates a new stream with the results of calling the function on every incoming stream with and accumulator and the incoming value. */
<T,U>(fn: (acc: U, value: T) => U, acc: U, stream: Stream<T>): Stream<U>;
}
interface StreamScanMerge {
/** Takes an array of pairs of streams and scan functions and merges all those streams using the given functions into a single stream. */
<T,U>(pairs: [Stream<T>, (acc: U, value: T) => U][], acc: U): Stream<U>;
/** Takes an array of pairs of streams and scan functions and merges all those streams using the given functions into a single stream. */
<U>(pairs: [Stream<any>, (acc: U, value: any) => U][], acc: U): Stream<U>;
}
}
declare module 'mithril' {
const m: Mithril.Static;
export = m;
}
declare module 'mithril/hyperscript' {
const h: Mithril.Hyperscript;
export = h;
}
declare module 'mithril/mount' {
const m: Mithril.Mount;
export = m;
}
declare module 'mithril/route' {
const r: Mithril.Route;
export = r;
}
declare module 'mithril/request' {
const r: Mithril.RequestService;
export = r;
}
declare module 'mithril/render' {
const r: Mithril.RenderService;
export = r;
}
declare module 'mithril/redraw' {
const r: Mithril.RedrawService;
export = r;
}
declare module 'mithril/util/withAttr' {
const withAttr: Mithril.WithAttr;
export = withAttr;
}
declare module 'mithril/stream' {
const s: Mithril.StreamFactory;
export = s;
}
declare module 'mithril/stream/scan' {
const s: Mithril.StreamScan;
export = s;
}
declare module 'mithril/stream/scanMerge' {
const sm: Mithril.StreamScanMerge;
export = sm;
}

View file

@ -1,7 +1,7 @@
new function() {
;(function() {
function Vnode(tag, key, attrs0, children, text, dom) {
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: {}, events: undefined, instance: undefined, skip: false}
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined, skip: false}
}
Vnode.normalize = function(node) {
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
@ -16,62 +16,82 @@ Vnode.normalizeChildren = function normalizeChildren(children) {
}
var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g
var selectorCache = {}
function hyperscript(selector) {
if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") {
throw Error("The selector must be either a string or a component.");
}
if (typeof selector === "string" && selectorCache[selector] === undefined) {
var match, tag, classes = [], attributes = {}
var hasOwn = {}.hasOwnProperty
function compileSelector(selector) {
var match, tag = "div", classes = [], attrs = {}
while (match = selectorParser.exec(selector)) {
var type = match[1], value = match[2]
if (type === "" && value !== "") tag = value
else if (type === "#") attributes.id = value
else if (type === "#") attrs.id = value
else if (type === ".") classes.push(value)
else if (match[3][0] === "[") {
var attrValue = match[6]
if (attrValue) attrValue = attrValue.replace(/\\(["'])/g, "$1").replace(/\\\\/g, "\\")
if (match[4] === "class") classes.push(attrValue)
else attributes[match[4]] = attrValue || true
else attrs[match[4]] = attrValue || true
}
}
if (classes.length > 0) attributes.className = classes.join(" ")
selectorCache[selector] = function(attrs, children) {
if (classes.length > 0) attrs.className = classes.join(" ")
return selectorCache[selector] = {tag: tag, attrs: attrs}
}
function execSelector(state, attrs, children) {
var hasAttrs = false, childList, text
var className = attrs.className || attrs.class
for (var key in attributes) attrs[key] = attributes[key]
if (className !== undefined) {
if (attrs.class !== undefined) {
for (var key in state.attrs) {
if (hasOwn.call(state.attrs, key)) {
attrs[key] = state.attrs[key]
}
}
if (className != null) {
if (attrs.class != null) {
attrs.class = undefined
attrs.className = className
}
if (attributes.className !== undefined) attrs.className = attributes.className + " " + className
if (state.attrs.className != null) {
attrs.className = state.attrs.className + " " + className
}
}
for (var key in attrs) {
if (key !== "key") {
if (hasOwn.call(attrs, key) && key !== "key") {
hasAttrs = true
break
}
}
if (Array.isArray(children) && children.length == 1 && children[0] != null && children[0].tag === "#") text = children[0].children
else childList = children
return Vnode(tag || "div", attrs.key, hasAttrs ? attrs : undefined, childList, text, undefined)
if (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === "#") {
text = children[0].children
} else {
childList = children
}
return Vnode(state.tag, attrs.key, hasAttrs ? attrs : undefined, childList, text)
}
var attrs, children, childrenIndex
if (arguments[1] == null || typeof arguments[1] === "object" && arguments[1].tag === undefined && !Array.isArray(arguments[1])) {
attrs = arguments[1]
childrenIndex = 2
function hyperscript(selector) {
// Because sloppy mode sucks
var attrs = arguments[1], start = 2, children
if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") {
throw Error("The selector must be either a string or a component.");
}
else childrenIndex = 1
if (arguments.length === childrenIndex + 1) {
children = Array.isArray(arguments[childrenIndex]) ? arguments[childrenIndex] : [arguments[childrenIndex]]
if (typeof selector === "string") {
var cached = selectorCache[selector] || compileSelector(selector)
}
else {
if (!attrs) {
attrs = {}
} else if (typeof attrs !== "object" || attrs.tag != null || Array.isArray(attrs)) {
attrs = {}
start = 1
}
if (arguments.length === start + 1) {
children = arguments[start]
if (!Array.isArray(children)) children = [children]
} else {
children = []
for (var i = childrenIndex; i < arguments.length; i++) children.push(arguments[i])
while (start < arguments.length) children.push(arguments[start++])
}
var normalized = Vnode.normalizeChildren(children)
if (typeof selector === "string") {
return execSelector(cached, attrs, normalized)
} else {
return Vnode(selector, attrs.key, attrs, normalized)
}
if (typeof selector === "string") return selectorCache[selector](attrs || {}, Vnode.normalizeChildren(children))
return Vnode(selector, attrs && attrs.key, attrs || {}, Vnode.normalizeChildren(children), undefined, undefined)
}
hyperscript.trust = function(html) {
if (html == null) html = ""
@ -369,6 +389,7 @@ var coreRenderer = function($window) {
function createNode(parent, vnode, hooks, ns, nextSibling) {
var tag = vnode.tag
if (typeof tag === "string") {
vnode.state = {}
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)
switch (tag) {
case "#": return createText(parent, vnode, nextSibling)
@ -577,7 +598,10 @@ var coreRenderer = function($window) {
if (!recycling && shouldNotUpdate(vnode, old)) return
if (typeof oldTag === "string") {
if (vnode.attrs != null) {
if (recycling) initLifecycle(vnode.attrs, vnode, hooks)
if (recycling) {
vnode.state = {}
initLifecycle(vnode.attrs, vnode, hooks)
}
else updateLifecycle(vnode.attrs, vnode, hooks)
}
switch (oldTag) {
@ -1198,4 +1222,4 @@ m.version = "1.0.1"
m.vnode = Vnode
if (typeof module !== "undefined") module["exports"] = m
else window.m = m
}
}());

86
mithril.min.js vendored
View file

@ -1,43 +1,43 @@
new function(){function x(b,d,l,e,g,k){return{tag:b,key:d,attrs:l,children:e,text:g,dom:k,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function B(b){if(null==b||"string"!==typeof b&&"function"!==typeof b&&"function"!==typeof b.view)throw Error("The selector must be either a string or a component.");if("string"===typeof b&&void 0===I[b]){for(var d,l,e=[],g={};d=O.exec(b);){var k=d[1],h=d[2];""===k&&""!==h?l=h:"#"===k?g.id=h:"."===k?e.push(h):"["===d[3][0]&&((k=d[6])&&(k=k.replace(/\\(["'])/g,
"$1").replace(/\\\\/g,"\\")),"class"===d[4]?e.push(k):g[d[4]]=k||!0)}0<e.length&&(g.className=e.join(" "));I[b]=function(b,d){var e=!1,a,k,n=b.className||b["class"],y;for(y in g)b[y]=g[y];void 0!==n&&(void 0!==b["class"]&&(b["class"]=void 0,b.className=n),void 0!==g.className&&(b.className=g.className+" "+n));for(y in b)if("key"!==y){e=!0;break}Array.isArray(d)&&1==d.length&&null!=d[0]&&"#"===d[0].tag?k=d[0].children:a=d;return x(l||"div",b.key,e?b:void 0,a,k,void 0)}}var r;null==arguments[1]||"object"===
typeof arguments[1]&&void 0===arguments[1].tag&&!Array.isArray(arguments[1])?(r=arguments[1],e=2):e=1;if(arguments.length===e+1)d=Array.isArray(arguments[e])?arguments[e]:[arguments[e]];else for(d=[];e<arguments.length;e++)d.push(arguments[e]);return"string"===typeof b?I[b](r||{},x.normalizeChildren(d)):x(b,r&&r.key,r||{},x.normalizeChildren(d),void 0,void 0)}function P(b){var d=0,l=null,e="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var g=Date.now();
0===d||16<=g-d?(d=g,b()):null===l&&(l=e(function(){l=null;b();d=Date.now()},16-(g-d)))}}x.normalize=function(b){return Array.isArray(b)?x("[",void 0,void 0,x.normalizeChildren(b),void 0,void 0):null!=b&&"object"!==typeof b?x("#",void 0,void 0,!1===b?"":b,void 0,void 0):b};x.normalizeChildren=function(b){for(var d=0;d<b.length;d++)b[d]=x.normalize(b[d]);return b};var O=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,I={};B.trust=function(b){null==b&&(b="");return x("<",
void 0,void 0,b,void 0,void 0)};B.fragment=function(b,d){return x("[",b.key,b,x.normalizeChildren(d),void 0,void 0)};var A=function(b){function d(b,a){return function t(d){var h;try{if(!a||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(h=d.then))m(function(){a||0!==b.length||console.error("Possible unhandled promise rejection:",d);for(var e=0;e<b.length;e++)b[e](d);g.length=0;k.length=0;n.state=a;n.retry=function(){t(d)}});else{if(d===e)throw new TypeError("Promise can't be resolved w/ itself");
l(h.bind(d))}}catch(Q){r(Q)}}}function l(b){function a(a){return function(b){0<d++||a(b)}}var d=0,e=a(r);try{b(a(h),e)}catch(y){e(y)}}if(!(this instanceof A))throw Error("Promise must be called with `new`");if("function"!==typeof b)throw new TypeError("executor must be a function");var e=this,g=[],k=[],h=d(g,!0),r=d(k,!1),n=e._instance={resolvers:g,rejectors:k},m="function"===typeof setImmediate?setImmediate:setTimeout;l(b)};A.prototype.then=function(b,d){function l(b,d,l,h){d.push(function(a){if("function"!==
typeof b)l(a);else try{g(b(a))}catch(w){k&&k(w)}});"function"===typeof e.retry&&h===e.state&&e.retry()}var e=this._instance,g,k,h=new A(function(b,d){g=b;k=d});l(b,e.resolvers,g,!0);l(d,e.rejectors,k,!1);return h};A.prototype["catch"]=function(b){return this.then(null,b)};A.resolve=function(b){return b instanceof A?b:new A(function(d){d(b)})};A.reject=function(b){return new A(function(d,l){l(b)})};A.all=function(b){return new A(function(d,l){var e=b.length,g=0,k=[];if(0===b.length)d([]);else for(var h=
0;h<b.length;h++)(function(h){function n(b){g++;k[h]=b;g===e&&d(k)}null==b[h]||"object"!==typeof b[h]&&"function"!==typeof b[h]||"function"!==typeof b[h].then?n(b[h]):b[h].then(n,l)})(h)})};A.race=function(b){return new A(function(d,l){for(var e=0;e<b.length;e++)b[e].then(d,l)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=A),A=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise&&(global.Promise=A),A=global.Promise);var F=function(b){function d(b,
e){if(Array.isArray(e))for(var g=0;g<e.length;g++)d(b+"["+g+"]",e[g]);else if("[object Object]"===Object.prototype.toString.call(e))for(g in e)d(b+"["+g+"]",e[g]);else l.push(encodeURIComponent(b)+(null!=e&&""!==e?"="+encodeURIComponent(e):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var l=[],e;for(e in b)d(e,b[e]);return l.join("&")},R=/^file:\/\//i,L=function(b,d){function l(){function a(){0===--b&&"function"===typeof v&&v()}var b=0;return function y(d){var e=d.then;d.then=
function(){b++;var g=e.apply(d,arguments);g.then(a,function(d){a();if(0===b)throw d;});return y(g)};return d}}function e(a,b){if("string"===typeof a){var d=a;a=b||{};null==a.url&&(a.url=d)}return a}function g(a,b){if(null==b)return a;for(var d=a.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var g=d[e].slice(1);null!=b[g]&&(a=a.replace(d[e],b[g]))}return a}function k(a,b){var d=F(b);if(""!==d){var e=0>a.indexOf("?")?"?":"&";a+=e+d}return a}function h(a){try{return""!==a?JSON.parse(a):null}catch(w){throw Error(a);
}}function r(a){return a.responseText}function n(a,b){if("function"===typeof a)if(Array.isArray(b))for(var d=0;d<b.length;d++)b[d]=new a(b[d]);else return new a(b);return b}var m=0,v;return{request:function(a,m){var v=l();a=e(a,m);var y=new d(function(d,e){null==a.method&&(a.method="GET");a.method=a.method.toUpperCase();var l="GET"===a.method||"TRACE"===a.method?!1:"boolean"===typeof a.useBody?a.useBody:!0;"function"!==typeof a.serialize&&(a.serialize="undefined"!==typeof FormData&&a.data instanceof
FormData?function(f){return f}:JSON.stringify);"function"!==typeof a.deserialize&&(a.deserialize=h);"function"!==typeof a.extract&&(a.extract=r);a.url=g(a.url,a.data);l?a.data=a.serialize(a.data):a.url=k(a.url,a.data);var m=new b.XMLHttpRequest,v=!1,y=m.abort;m.abort=function(){v=!0;y.call(m)};m.open(a.method,a.url,"boolean"===typeof a.async?a.async:!0,"string"===typeof a.user?a.user:void 0,"string"===typeof a.password?a.password:void 0);a.serialize===JSON.stringify&&l&&m.setRequestHeader("Content-Type",
"application/json; charset=utf-8");a.deserialize===h&&m.setRequestHeader("Accept","application/json, text/*");a.withCredentials&&(m.withCredentials=a.withCredentials);for(var w in a.headers)({}).hasOwnProperty.call(a.headers,w)&&m.setRequestHeader(w,a.headers[w]);"function"===typeof a.config&&(m=a.config(m,a)||m);m.onreadystatechange=function(){if(!v&&4===m.readyState)try{var f=a.extract!==r?a.extract(m,a):a.deserialize(a.extract(m,a));if(200<=m.status&&300>m.status||304===m.status||R.test(a.url))d(n(a.type,
f));else{var c=Error(m.responseText),q;for(q in f)c[q]=f[q];e(c)}}catch(p){e(p)}};l&&null!=a.data?m.send(a.data):m.send()});return!0===a.background?y:v(y)},jsonp:function(a,h){var v=l();a=e(a,h);var r=new d(function(d,e){var l=a.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,h=b.document.createElement("script");b[l]=function(e){h.parentNode.removeChild(h);d(n(a.type,e));delete b[l]};h.onerror=function(){h.parentNode.removeChild(h);e(Error("JSONP request failed"));delete b[l]};null==
a.data&&(a.data={});a.url=g(a.url,a.data);a.data[a.callbackKey||"callback"]=l;h.src=k(a.url,a.data);b.document.documentElement.appendChild(h)});return!0===a.background?r:v(r)},setCompletionCallback:function(b){v=b}}}(window,A),N=function(b){function d(f,c,q,b,a,d,e){for(;q<b;q++){var p=c[q];null!=p&&l(f,p,a,e,d)}}function l(f,c,q,b,a){var p=c.tag;if("string"===typeof p)switch(null!=c.attrs&&B(c.attrs,c,q),p){case "#":return c.dom=C.createTextNode(c.children),m(f,c.dom,a),c.dom;case "<":return e(f,
c,a);case "[":var h=C.createDocumentFragment();null!=c.children&&(p=c.children,d(h,p,0,p.length,q,null,b));c.dom=h.firstChild;c.domSize=h.childNodes.length;m(f,h,a);return h;default:var n=c.tag;switch(c.tag){case "svg":b="http://www.w3.org/2000/svg";break;case "math":b="http://www.w3.org/1998/Math/MathML"}var k=(p=c.attrs)&&p.is,n=b?k?C.createElementNS(b,n,{is:k}):C.createElementNS(b,n):k?C.createElement(n,{is:k}):C.createElement(n);c.dom=n;if(null!=p)for(h in k=b,p)y(c,h,null,p[h],k);m(f,n,a);null!=
c.attrs&&null!=c.attrs.contenteditable?v(c):(null!=c.text&&(""!==c.text?n.textContent=c.text:c.children=[x("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(f=c.children,d(n,f,0,f.length,q,null,b),f=c.attrs,"select"===c.tag&&null!=f&&("value"in f&&y(c,"value",null,f.value,void 0),"selectedIndex"in f&&y(c,"selectedIndex",null,f.selectedIndex,void 0))));return n}else{g(c,q);if(null!=c.instance){if(c.instance===c)throw Error("A view cannot return the vnode it received as arguments");q=l(f,
c.instance,q,b,a);c.dom=c.instance.dom;c.domSize=null!=c.dom?c.instance.domSize:0;m(f,q,a);c=q}else c.domSize=0,c=K;return c}}function e(f,c,b){var q={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(c.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div",q=C.createElement(q);q.innerHTML=c.children;c.dom=q.firstChild;c.domSize=q.childNodes.length;c=C.createDocumentFragment();for(var a;a=q.firstChild;)c.appendChild(a);m(f,c,b);return c}
function g(f,c){var b;if("function"===typeof f.tag){f.state=null;b=f.tag;if(null!=b.$$reentrantLock$$)return K;b.$$reentrantLock$$=!0;f.state=null!=f.tag.prototype&&"function"===typeof f.tag.prototype.view?new f.tag(f):f.tag(f)}else{f.state=Object.create(f.tag);b=f.state.view;if(null!=b.$$reentrantLock$$)return K;b.$$reentrantLock$$=!0}null!=f.attrs&&B(f.attrs,f,c);B(f.state,f,c);f.instance=x.normalize(f.state.view(f));b.$$reentrantLock$$=null}function k(f,c,b,e,g,k,v){if(c!==b&&(null!=c||null!=b))if(null==
c)d(f,b,0,b.length,g,k,void 0);else if(null==b)a(c,0,c.length,b);else{if(c.length===b.length){for(var q=!1,p=0;p<b.length;p++)if(null!=b[p]&&null!=c[p]){q=null==b[p].key&&null==c[p].key;break}if(q){for(p=0;p<c.length;p++)c[p]!==b[p]&&(null==c[p]&&null!=b[p]?l(f,b[p],g,v,n(c,p+1,k)):null==b[p]?a(c,p,p+1,b):h(f,c[p],b[p],g,n(c,p+1,k),e,v));return}}if(!e)a:{if(null!=c.pool&&Math.abs(c.pool.length-b.length)<=Math.abs(c.length-b.length)&&(e=b[0]&&b[0].children&&b[0].children.length||0,Math.abs((c.pool[0]&&
c.pool[0].children&&c.pool[0].children.length||0)-e)<=Math.abs((c[0]&&c[0].children&&c[0].children.length||0)-e))){e=!0;break a}e=!1}if(e){var D=c.pool;c=c.concat(c.pool)}for(var p=q=0,w=c.length-1,y=b.length-1,G;w>=q&&y>=p;){var z=c[q],t=b[p];if(z!==t||e)if(null==z)q++;else if(null==t)p++;else if(z.key===t.key){var u=null!=D&&q>=c.length-D.length||null==D&&e;q++;p++;h(f,z,t,g,n(c,q,k),u,v);e&&z.tag===t.tag&&m(f,r(z),k)}else if(z=c[w],z!==t||e)if(null==z)w--;else if(null==t)p++;else if(z.key===t.key)u=
null!=D&&w>=c.length-D.length||null==D&&e,h(f,z,t,g,n(c,w+1,k),u,v),(e||p<y)&&m(f,r(z),n(c,q,k)),w--,p++;else break;else w--,p++;else q++,p++}for(;w>=q&&y>=p;){z=c[w];t=b[y];if(z!==t||e)if(null==z)w--;else{if(null!=t)if(z.key===t.key)u=null!=D&&w>=c.length-D.length||null==D&&e,h(f,z,t,g,n(c,w+1,k),u,v),e&&z.tag===t.tag&&m(f,r(z),k),null!=z.dom&&(k=z.dom),w--;else{if(!G){G=c;var z=w,u={},x;for(x=0;x<z;x++){var E=G[x];null!=E&&(E=E.key,null!=E&&(u[E]=x))}G=u}null!=t&&(z=G[t.key],null!=z?(u=c[z],h(f,
u,t,g,n(c,w+1,k),e,v),m(f,r(u),k),c[z].skip=!0,null!=u.dom&&(k=u.dom)):k=l(f,t,g,void 0,k))}y--}else w--,y--;if(y<p)break}d(f,b,p,y+1,g,k,v);a(c,q,w+1,b)}}function h(b,c,a,d,n,m,t){var f=c.tag;if(f===a.tag){a.state=c.state;a.events=c.events;var p;if(p=!m){var q,D;null!=a.attrs&&"function"===typeof a.attrs.onbeforeupdate&&(q=a.attrs.onbeforeupdate.call(a.state,a,c));"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeupdate&&(D=a.state.onbeforeupdate(a,c));void 0===q&&void 0===D||q||D?p=!1:
(a.dom=c.dom,a.domSize=c.domSize,a.instance=c.instance,p=!0)}if(!p)if("string"===typeof f)switch(null!=a.attrs&&(m?B(a.attrs,a,d):J(a.attrs,a,d)),f){case "#":c.children.toString()!==a.children.toString()&&(c.dom.nodeValue=a.children);a.dom=c.dom;break;case "<":c.children!==a.children?(r(c),e(b,a,n)):(a.dom=c.dom,a.domSize=c.domSize);break;case "[":k(b,c.children,a.children,m,d,n,t);c=0;d=a.children;a.dom=null;if(null!=d){for(m=0;m<d.length;m++){var u=d[m];null!=u&&null!=u.dom&&(null==a.dom&&(a.dom=
u.dom),c+=u.domSize||1)}1!==c&&(a.domSize=c)}break;default:b=t;n=a.dom=c.dom;switch(a.tag){case "svg":b="http://www.w3.org/2000/svg";break;case "math":b="http://www.w3.org/1998/Math/MathML"}"textarea"===a.tag&&(null==a.attrs&&(a.attrs={}),null!=a.text&&(a.attrs.value=a.text,a.text=void 0));t=c.attrs;f=a.attrs;p=b;if(null!=f)for(u in f)y(a,u,t&&t[u],f[u],p);if(null!=t)for(u in t)null!=f&&u in f||("className"===u&&(u="class"),"o"!==u[0]||"n"!==u[1]||E(u)?"key"!==u&&a.dom.removeAttribute(u):A(a,u,void 0));
null!=a.attrs&&null!=a.attrs.contenteditable?v(a):null!=c.text&&null!=a.text&&""!==a.text?c.text.toString()!==a.text.toString()&&(c.dom.firstChild.nodeValue=a.text):(null!=c.text&&(c.children=[x("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=a.text&&(a.children=[x("#",void 0,void 0,a.text,void 0,void 0)]),k(n,c.children,a.children,m,d,null,b))}else m?g(a,d):(a.instance=x.normalize(a.state.view(a)),null!=a.attrs&&J(a.attrs,a,d),J(a.state,a,d)),null!=a.instance?(null==c.instance?l(b,a.instance,
d,t,n):h(b,c.instance,a.instance,d,n,m,t),a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=c.instance?(w(c.instance,null),a.dom=void 0,a.domSize=0):(a.dom=c.dom,a.domSize=c.domSize)}else w(c,null),l(b,a,d,t,n)}function r(a){var c=a.domSize;if(null!=c||null==a.dom){var b=C.createDocumentFragment();if(0<c){for(a=a.dom;--c;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function n(a,c,b){for(;c<a.length;c++)if(null!=a[c]&&null!=a[c].dom)return a[c].dom;return b}
function m(a,c,b){b&&b.parentNode?a.insertBefore(c,b):a.appendChild(c)}function v(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function a(a,c,b,d){for(;c<b;c++){var f=a[c];null!=f&&(f.skip?f.skip=!1:w(f,d))}}function w(a,b){function c(){if(++d===f&&(t(a),a.dom)){var c=a.domSize||1;if(1<c)for(var e=a.dom;--c;){var p=e.nextSibling,
g=p.parentNode;null!=g&&g.removeChild(p)}c=a.dom;e=c.parentNode;null!=e&&e.removeChild(c);if(c=null!=b&&null==a.domSize)c=a.attrs,c=!(null!=c&&(c.oncreate||c.onupdate||c.onbeforeremove||c.onremove));c&&"string"===typeof a.tag&&(b.pool?b.pool.push(a):b.pool=[a])}}var f=1,d=0;if(a.attrs&&a.attrs.onbeforeremove){var e=a.attrs.onbeforeremove.call(a.state,a);null!=e&&"function"===typeof e.then&&(f++,e.then(c,c))}"string"!==typeof a.tag&&a.state.onbeforeremove&&(e=a.state.onbeforeremove(a),null!=e&&"function"===
typeof e.then&&(f++,e.then(c,c)));c()}function t(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,a);if("string"!==typeof a.tag&&a.state.onremove)a.state.onremove(a);if(null!=a.instance)t(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&t(b)}}function y(a,c,b,d,e){var f=a.dom;if("key"!==c&&"is"!==c&&(b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===C.activeElement||"object"===typeof d)&&"undefined"!==typeof d&&
!E(c)){var g=c.indexOf(":");if(-1<g&&"xlink"===c.substr(0,g))f.setAttributeNS("http://www.w3.org/1999/xlink",c.slice(g+1),d);else if("o"===c[0]&&"n"===c[1]&&"function"===typeof d)A(a,c,d);else if("style"===c)if(a=b,a===d&&(f.style.cssText="",a=null),null==d)f.style.cssText="";else if("string"===typeof d)f.style.cssText=d;else{"string"===typeof a&&(f.style.cssText="");for(var n in d)f.style[n]=d[n];if(null!=a&&"string"!==typeof a)for(n in a)n in d||(f.style[n]="")}else c in f&&"href"!==c&&"list"!==
c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))?"input"===a.tag&&"value"===c&&a.dom.value==d&&a.dom===C.activeElement||"select"===a.tag&&"value"===c&&a.dom.value==d&&a.dom===C.activeElement||"option"===a.tag&&"value"===c&&a.dom.value==d||("input"===a.tag&&"type"===c?f.setAttribute(c,d):f[c]=d):"boolean"===typeof d?d?f.setAttribute(c,""):f.removeAttribute(c):f.setAttribute("className"===c?"class":c,d)}}function E(a){return"oninit"===a||"oncreate"===a||"onupdate"===
a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function A(a,c,b){var d=a.dom,e="function"!==typeof F?b:function(a){var c=b.call(d,a);F.call(d,a);return c};if(c in d)d[c]="function"===typeof b?e:null;else{var f=c.slice(2);void 0===a.events&&(a.events={});a.events[c]!==e&&(null!=a.events[c]&&d.removeEventListener(f,a.events[c],!1),"function"===typeof b&&(a.events[c]=e,d.addEventListener(f,a.events[c],!1)))}}function B(a,c,b){"function"===typeof a.oninit&&a.oninit.call(c.state,c);"function"===
typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function J(a,b,d){"function"===typeof a.onupdate&&d.push(a.onupdate.bind(b.state,b))}var C=b.document,K=C.createDocumentFragment(),F;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=C.activeElement;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);k(a,a.vnodes,x.normalizeChildren(b),!1,c,null,void 0);a.vnodes=b;for(var e=0;e<c.length;e++)c[e]();
C.activeElement!==d&&d.focus()},setEventCallback:function(a){return F=a}}},H=function(b){function d(b){b=e.indexOf(b);-1<b&&e.splice(b,2)}function l(){for(var b=1;b<e.length;b+=2)e[b]()}b=N(b);b.setEventCallback(function(b){!1!==b.redraw&&l()});var e=[];return{subscribe:function(b,k){d(b);e.push(b,P(k))},unsubscribe:d,redraw:l,render:b.render}}(window);L.setCompletionCallback(H.redraw);B.mount=function(b){return function(d,l){if(null===l)b.render(d,[]),b.unsubscribe(d);else{if(null==l.view&&"function"!==
typeof l)throw Error("m.mount(element, component) expects a component, not a vnode");b.subscribe(d,function(){b.render(d,x(l))});b.redraw()}}}(H);var S=A,M=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},l={},e=0;e<b.length;e++){var g=b[e].split("="),k=decodeURIComponent(g[0]),g=2===g.length?decodeURIComponent(g[1]):"";"true"===g?g=!0:"false"===g&&(g=!1);var h=k.split(/\]\[?|\[/),r=d;-1<k.indexOf("[")&&h.pop();for(var n=0;n<h.length;n++){var k=
h[n],m=h[n+1],m=""==m||!isNaN(parseInt(m,10)),v=n===h.length-1;""===k&&(k=h.slice(0,n).join(),null==l[k]&&(l[k]=0),k=l[k]++);null==r[k]&&(r[k]=v?g:m?[]:{});r=r[k]}}return d},T=function(b){function d(d){var e=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function l(b){return function(){null==h&&(h=k(function(){h=null;b()}))}}function e(b,d,e){var a=b.indexOf("?"),g=b.indexOf("#"),k=-1<a?a:-1<g?g:b.length;if(-1<a){var a=M(b.slice(a+
1,-1<g?g:b.length)),h;for(h in a)d[h]=a[h]}if(-1<g)for(h in d=M(b.slice(g+1)),d)e[h]=d[h];return b.slice(0,k)}var g="function"===typeof b.history.pushState,k="function"===typeof setImmediate?setImmediate:setTimeout,h,r={prefix:"#!",getPath:function(){switch(r.prefix.charAt(0)){case "#":return d("hash").slice(r.prefix.length);case "?":return d("search").slice(r.prefix.length)+d("hash");default:return d("pathname").slice(r.prefix.length)+d("search")+d("hash")}},setPath:function(d,h,k){var a={},l={};
d=e(d,a,l);if(null!=h){for(var m in h)a[m]=h[m];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return h[d]})}(m=F(a))&&(d+="?"+m);(l=F(l))&&(d+="#"+l);g?(l=k?k.state:null,m=k?k.title:null,b.onpopstate(),k&&k.replace?b.history.replaceState(l,m,r.prefix+d):b.history.pushState(l,m,r.prefix+d)):b.location.href=r.prefix+d},defineRoutes:function(d,k,h){function a(){var a=r.getPath(),g={},l=e(a,g,g),m=b.history.state;if(null!=m)for(var n in m)g[n]=m[n];for(var v in d)if(m=new RegExp("^"+v.replace(/:[^\/]+?\.{3}/g,
"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),m.test(l)){l.replace(m,function(){for(var b=v.match(/:[^\/]+/g)||[],e=[].slice.call(arguments,1,-2),h=0;h<b.length;h++)g[b[h].replace(/:|\./g,"")]=decodeURIComponent(e[h]);k(d[v],g,a,v)});return}h(a,g)}g?b.onpopstate=l(a):"#"===r.prefix.charAt(0)&&(b.onhashchange=a);a()}};return r};B.route=function(b,d){var l=T(b),e=function(b){return b},g,k,h,r,n,m=function(b,a,m){if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");
var v=function(){null!=g&&d.render(b,g(x(k,h.key,h)))},w=function(b){if(b!==a)l.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+a);};l.defineRoutes(m,function(a,b,d){var l=n=function(a,m){l===n&&(k=null==m||"function"!==typeof m.view&&"function"!==typeof m?"div":m,h=b,r=d,n=null,g=(a.render||e).bind(a),v())};a.view||"function"===typeof a?l({},a):a.onmatch?S.resolve(a.onmatch(b,d)).then(function(b){l(a,b)},w):l(a,"div")},w);d.subscribe(b,v)};m.set=function(b,a,d){null!=
n&&(d={replace:!0});n=null;l.setPath(b,a,d)};m.get=function(){return r};m.prefix=function(b){l.prefix=b};m.link=function(b){b.dom.setAttribute("href",l.prefix+b.attrs.href);b.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(l.prefix)&&(a=a.slice(l.prefix.length)),m.set(a,void 0,void 0))}};m.param=function(b){return"undefined"!==typeof h&&"undefined"!==typeof b?h[b]:h};return m}(window,H);B.withAttr=function(b,
d,l){return function(e){d.call(l||this,b in e.currentTarget?e.currentTarget[b]:e.currentTarget.getAttribute(b))}};var U=N(window);B.render=U.render;B.redraw=H.redraw;B.request=L.request;B.jsonp=L.jsonp;B.parseQueryString=M;B.buildQueryString=F;B.version="1.0.1";B.vnode=x;"undefined"!==typeof module?module.exports=B:window.m=B};
(function(){function B(a,d,f,g,e,p){return{tag:a,key:d,attrs:f,children:g,text:e,dom:p,domSize:void 0,state:void 0,events:void 0,instance:void 0,skip:!1}}function C(a){var d=arguments[1],f=2,g;if(null==a||"string"!==typeof a&&"function"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a){var e;if(!(e=M[a])){g="div";for(var p=[],k={};e=P.exec(a);){var q=e[1],n=e[2];""===q&&""!==n?g=n:"#"===q?k.id=n:"."===q?p.push(n):"["===
e[3][0]&&((q=e[6])&&(q=q.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===e[4]?p.push(q):k[e[4]]=q||!0)}0<p.length&&(k.className=p.join(" "));e=M[a]={tag:g,attrs:k}}}if(!d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},f=1;if(arguments.length===f+1)g=arguments[f],Array.isArray(g)||(g=[g]);else for(g=[];f<arguments.length;)g.push(arguments[f++]);f=B.normalizeChildren(g);if("string"===typeof a){g=!1;var l,u,p=d.className||d["class"],b;for(b in e.attrs)N.call(e.attrs,
b)&&(d[b]=e.attrs[b]);null!=p&&(null!=d["class"]&&(d["class"]=void 0,d.className=p),null!=e.attrs.className&&(d.className=e.attrs.className+" "+p));for(b in d)if(N.call(d,b)&&"key"!==b){g=!0;break}Array.isArray(f)&&1===f.length&&null!=f[0]&&"#"===f[0].tag?u=f[0].children:l=f;return B(e.tag,d.key,g?d:void 0,l,u)}return B(a,d.key,d,f)}function Q(a){var d=0,f=null,g="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var e=Date.now();0===d||16<=e-d?(d=e,a()):
null===f&&(f=g(function(){f=null;a();d=Date.now()},16-(e-d)))}}B.normalize=function(a){return Array.isArray(a)?B("[",void 0,void 0,B.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?B("#",void 0,void 0,!1===a?"":a,void 0,void 0):a};B.normalizeChildren=function(a){for(var d=0;d<a.length;d++)a[d]=B.normalize(a[d]);return a};var P=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,M={},N={}.hasOwnProperty;C.trust=function(a){null==a&&(a="");return B("<",void 0,
void 0,a,void 0,void 0)};C.fragment=function(a,d){return B("[",a.key,a,B.normalizeChildren(d),void 0,void 0)};var x=function(a){function d(a,b){return function r(d){var k;try{if(!b||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(k=d.then))l(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",d);for(var f=0;f<a.length;f++)a[f](d);e.length=0;p.length=0;n.state=b;n.retry=function(){r(d)}});else{if(d===g)throw new TypeError("Promise can't be resolved w/ itself");
f(k.bind(d))}}catch(R){q(R)}}}function f(a){function b(b){return function(a){0<d++||b(a)}}var d=0,e=b(q);try{a(b(k),e)}catch(A){e(A)}}if(!(this instanceof x))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var g=this,e=[],p=[],k=d(e,!0),q=d(p,!1),n=g._instance={resolvers:e,rejectors:p},l="function"===typeof setImmediate?setImmediate:setTimeout;f(a)};x.prototype.then=function(a,d){function f(a,d,f,k){d.push(function(b){if("function"!==
typeof a)f(b);else try{e(a(b))}catch(w){p&&p(w)}});"function"===typeof g.retry&&k===g.state&&g.retry()}var g=this._instance,e,p,k=new x(function(a,d){e=a;p=d});f(a,g.resolvers,e,!0);f(d,g.rejectors,p,!1);return k};x.prototype["catch"]=function(a){return this.then(null,a)};x.resolve=function(a){return a instanceof x?a:new x(function(d){d(a)})};x.reject=function(a){return new x(function(d,f){f(a)})};x.all=function(a){return new x(function(d,f){var g=a.length,e=0,p=[];if(0===a.length)d([]);else for(var k=
0;k<a.length;k++)(function(k){function n(a){e++;p[k]=a;e===g&&d(p)}null==a[k]||"object"!==typeof a[k]&&"function"!==typeof a[k]||"function"!==typeof a[k].then?n(a[k]):a[k].then(n,f)})(k)})};x.race=function(a){return new x(function(d,f){for(var g=0;g<a.length;g++)a[g].then(d,f)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=x),x=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise&&(global.Promise=x),x=global.Promise);var F=function(a){function d(a,
g){if(Array.isArray(g))for(var e=0;e<g.length;e++)d(a+"["+e+"]",g[e]);else if("[object Object]"===Object.prototype.toString.call(g))for(e in g)d(a+"["+e+"]",g[e]);else f.push(encodeURIComponent(a)+(null!=g&&""!==g?"="+encodeURIComponent(g):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var f=[],g;for(g in a)d(g,a[g]);return f.join("&")},S=/^file:\/\//i,K=function(a,d){function f(){function b(){0===--a&&"function"===typeof u&&u()}var a=0;return function A(d){var e=d.then;d.then=
function(){a++;var f=e.apply(d,arguments);f.then(b,function(d){b();if(0===a)throw d;});return A(f)};return d}}function g(b,a){if("string"===typeof b){var d=b;b=a||{};null==b.url&&(b.url=d)}return b}function e(b,a){if(null==a)return b;for(var d=b.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var f=d[e].slice(1);null!=a[f]&&(b=b.replace(d[e],a[f]))}return b}function p(b,a){var d=F(a);if(""!==d){var e=0>b.indexOf("?")?"?":"&";b+=e+d}return b}function k(b){try{return""!==b?JSON.parse(b):null}catch(w){throw Error(b);
}}function q(b){return b.responseText}function n(b,a){if("function"===typeof b)if(Array.isArray(a))for(var d=0;d<a.length;d++)a[d]=new b(a[d]);else return new b(a);return a}var l=0,u;return{request:function(b,l){var u=f();b=g(b,l);var w=new d(function(d,f){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var g="GET"===b.method||"TRACE"===b.method?!1:"boolean"===typeof b.useBody?b.useBody:!0;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof
FormData?function(h){return h}:JSON.stringify);"function"!==typeof b.deserialize&&(b.deserialize=k);"function"!==typeof b.extract&&(b.extract=q);b.url=e(b.url,b.data);g?b.data=b.serialize(b.data):b.url=p(b.url,b.data);var l=new a.XMLHttpRequest,u=!1,w=l.abort;l.abort=function(){u=!0;w.call(l)};l.open(b.method,b.url,"boolean"===typeof b.async?b.async:!0,"string"===typeof b.user?b.user:void 0,"string"===typeof b.password?b.password:void 0);b.serialize===JSON.stringify&&g&&l.setRequestHeader("Content-Type",
"application/json; charset=utf-8");b.deserialize===k&&l.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(l.withCredentials=b.withCredentials);for(var r in b.headers)({}).hasOwnProperty.call(b.headers,r)&&l.setRequestHeader(r,b.headers[r]);"function"===typeof b.config&&(l=b.config(l,b)||l);l.onreadystatechange=function(){if(!u&&4===l.readyState)try{var h=b.extract!==q?b.extract(l,b):b.deserialize(b.extract(l,b));if(200<=l.status&&300>l.status||304===l.status||S.test(b.url))d(n(b.type,
h));else{var c=Error(l.responseText),m;for(m in h)c[m]=h[m];f(c)}}catch(v){f(v)}};g&&null!=b.data?l.send(b.data):l.send()});return!0===b.background?w:u(w)},jsonp:function(b,k){var u=f();b=g(b,k);var q=new d(function(d,f){var g=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+l++,k=a.document.createElement("script");a[g]=function(e){k.parentNode.removeChild(k);d(n(b.type,e));delete a[g]};k.onerror=function(){k.parentNode.removeChild(k);f(Error("JSONP request failed"));delete a[g]};null==
b.data&&(b.data={});b.url=e(b.url,b.data);b.data[b.callbackKey||"callback"]=g;k.src=p(b.url,b.data);a.document.documentElement.appendChild(k)});return!0===b.background?q:u(q)},setCompletionCallback:function(b){u=b}}}(window,x),O=function(a){function d(h,c,m,b,a,d,e){for(;m<b;m++){var v=c[m];null!=v&&f(h,v,a,e,d)}}function f(h,c,m,b,a){var v=c.tag;if("string"===typeof v)switch(c.state={},null!=c.attrs&&C(c.attrs,c,m),v){case "#":return c.dom=D.createTextNode(c.children),l(h,c.dom,a),c.dom;case "<":return g(h,
c,a);case "[":var k=D.createDocumentFragment();null!=c.children&&(v=c.children,d(k,v,0,v.length,m,null,b));c.dom=k.firstChild;c.domSize=k.childNodes.length;l(h,k,a);return k;default:var n=c.tag;switch(c.tag){case "svg":b="http://www.w3.org/2000/svg";break;case "math":b="http://www.w3.org/1998/Math/MathML"}var t=(v=c.attrs)&&v.is,n=b?t?D.createElementNS(b,n,{is:t}):D.createElementNS(b,n):t?D.createElement(n,{is:t}):D.createElement(n);c.dom=n;if(null!=v)for(k in t=b,v)A(c,k,null,v[k],t);l(h,n,a);null!=
c.attrs&&null!=c.attrs.contenteditable?u(c):(null!=c.text&&(""!==c.text?n.textContent=c.text:c.children=[B("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(h=c.children,d(n,h,0,h.length,m,null,b),h=c.attrs,"select"===c.tag&&null!=h&&("value"in h&&A(c,"value",null,h.value,void 0),"selectedIndex"in h&&A(c,"selectedIndex",null,h.selectedIndex,void 0))));return n}else{e(c,m);if(null!=c.instance){if(c.instance===c)throw Error("A view cannot return the vnode it received as arguments");m=f(h,
c.instance,m,b,a);c.dom=c.instance.dom;c.domSize=null!=c.dom?c.instance.domSize:0;l(h,m,a);c=m}else c.domSize=0,c=J;return c}}function g(h,c,b){var m={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(c.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div",m=D.createElement(m);m.innerHTML=c.children;c.dom=m.firstChild;c.domSize=m.childNodes.length;c=D.createDocumentFragment();for(var a;a=m.firstChild;)c.appendChild(a);l(h,c,b);return c}
function e(h,c){var m;if("function"===typeof h.tag){h.state=null;m=h.tag;if(null!=m.$$reentrantLock$$)return J;m.$$reentrantLock$$=!0;h.state=null!=h.tag.prototype&&"function"===typeof h.tag.prototype.view?new h.tag(h):h.tag(h)}else{h.state=Object.create(h.tag);m=h.state.view;if(null!=m.$$reentrantLock$$)return J;m.$$reentrantLock$$=!0}null!=h.attrs&&C(h.attrs,h,c);C(h.state,h,c);h.instance=B.normalize(h.state.view(h));m.$$reentrantLock$$=null}function p(h,c,m,a,e,g,p){if(c!==m&&(null!=c||null!=m))if(null==
c)d(h,m,0,m.length,e,g,void 0);else if(null==m)b(c,0,c.length,m);else{if(c.length===m.length){for(var v=!1,t=0;t<m.length;t++)if(null!=m[t]&&null!=c[t]){v=null==m[t].key&&null==c[t].key;break}if(v){for(t=0;t<c.length;t++)c[t]!==m[t]&&(null==c[t]&&null!=m[t]?f(h,m[t],e,p,n(c,t+1,g)):null==m[t]?b(c,t,t+1,m):k(h,c[t],m[t],e,n(c,t+1,g),a,p));return}}if(!a)a:{if(null!=c.pool&&Math.abs(c.pool.length-m.length)<=Math.abs(c.length-m.length)&&(a=m[0]&&m[0].children&&m[0].children.length||0,Math.abs((c.pool[0]&&
c.pool[0].children&&c.pool[0].children.length||0)-a)<=Math.abs((c[0]&&c[0].children&&c[0].children.length||0)-a))){a=!0;break a}a=!1}if(a){var u=c.pool;c=c.concat(c.pool)}for(var t=v=0,w=c.length-1,y=m.length-1,G;w>=v&&y>=t;){var r=c[v],z=m[t];if(r!==z||a)if(null==r)v++;else if(null==z)t++;else if(r.key===z.key){var A=null!=u&&v>=c.length-u.length||null==u&&a;v++;t++;k(h,r,z,e,n(c,v,g),A,p);a&&r.tag===z.tag&&l(h,q(r),g)}else if(r=c[w],r!==z||a)if(null==r)w--;else if(null==z)t++;else if(r.key===z.key)A=
null!=u&&w>=c.length-u.length||null==u&&a,k(h,r,z,e,n(c,w+1,g),A,p),(a||t<y)&&l(h,q(r),n(c,v,g)),w--,t++;else break;else w--,t++;else v++,t++}for(;w>=v&&y>=t;){r=c[w];z=m[y];if(r!==z||a)if(null==r)w--;else{if(null!=z)if(r.key===z.key)A=null!=u&&w>=c.length-u.length||null==u&&a,k(h,r,z,e,n(c,w+1,g),A,p),a&&r.tag===z.tag&&l(h,q(r),g),null!=r.dom&&(g=r.dom),w--;else{if(!G){G=c;var r=w,A={},E;for(E=0;E<r;E++){var x=G[E];null!=x&&(x=x.key,null!=x&&(A[x]=E))}G=A}null!=z&&(r=G[z.key],null!=r?(A=c[r],k(h,
A,z,e,n(c,w+1,g),a,p),l(h,q(A),g),c[r].skip=!0,null!=A.dom&&(g=A.dom)):g=f(h,z,e,void 0,g))}y--}else w--,y--;if(y<t)break}d(h,m,t,y+1,e,g,p);b(c,v,w+1,m)}}function k(h,c,a,b,d,n,l){var m=c.tag;if(m===a.tag){a.state=c.state;a.events=c.events;var v;if(v=!n){var r,z;null!=a.attrs&&"function"===typeof a.attrs.onbeforeupdate&&(r=a.attrs.onbeforeupdate.call(a.state,a,c));"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeupdate&&(z=a.state.onbeforeupdate(a,c));void 0===r&&void 0===z||r||z?v=!1:
(a.dom=c.dom,a.domSize=c.domSize,a.instance=c.instance,v=!0)}if(!v)if("string"===typeof m)switch(null!=a.attrs&&(n?(a.state={},C(a.attrs,a,b)):I(a.attrs,a,b)),m){case "#":c.children.toString()!==a.children.toString()&&(c.dom.nodeValue=a.children);a.dom=c.dom;break;case "<":c.children!==a.children?(q(c),g(h,a,d)):(a.dom=c.dom,a.domSize=c.domSize);break;case "[":p(h,c.children,a.children,n,b,d,l);c=0;b=a.children;a.dom=null;if(null!=b){for(n=0;n<b.length;n++){var y=b[n];null!=y&&null!=y.dom&&(null==
a.dom&&(a.dom=y.dom),c+=y.domSize||1)}1!==c&&(a.domSize=c)}break;default:h=l;d=a.dom=c.dom;switch(a.tag){case "svg":h="http://www.w3.org/2000/svg";break;case "math":h="http://www.w3.org/1998/Math/MathML"}"textarea"===a.tag&&(null==a.attrs&&(a.attrs={}),null!=a.text&&(a.attrs.value=a.text,a.text=void 0));l=c.attrs;m=a.attrs;v=h;if(null!=m)for(y in m)A(a,y,l&&l[y],m[y],v);if(null!=l)for(y in l)null!=m&&y in m||("className"===y&&(y="class"),"o"!==y[0]||"n"!==y[1]||E(y)?"key"!==y&&a.dom.removeAttribute(y):
x(a,y,void 0));null!=a.attrs&&null!=a.attrs.contenteditable?u(a):null!=c.text&&null!=a.text&&""!==a.text?c.text.toString()!==a.text.toString()&&(c.dom.firstChild.nodeValue=a.text):(null!=c.text&&(c.children=[B("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=a.text&&(a.children=[B("#",void 0,void 0,a.text,void 0,void 0)]),p(d,c.children,a.children,n,b,null,h))}else n?e(a,b):(a.instance=B.normalize(a.state.view(a)),null!=a.attrs&&I(a.attrs,a,b),I(a.state,a,b)),null!=a.instance?(null==c.instance?
f(h,a.instance,b,l,d):k(h,c.instance,a.instance,b,d,n,l),a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=c.instance?(w(c.instance,null),a.dom=void 0,a.domSize=0):(a.dom=c.dom,a.domSize=c.domSize)}else w(c,null),f(h,a,b,l,d)}function q(a){var c=a.domSize;if(null!=c||null==a.dom){var b=D.createDocumentFragment();if(0<c){for(a=a.dom;--c;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function n(a,c,b){for(;c<a.length;c++)if(null!=a[c]&&null!=a[c].dom)return a[c].dom;
return b}function l(a,c,b){b&&b.parentNode?a.insertBefore(c,b):a.appendChild(c)}function u(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function b(a,c,b,d){for(;c<b;c++){var h=a[c];null!=h&&(h.skip?h.skip=!1:w(h,d))}}function w(a,c){function b(){if(++d===h&&(r(a),a.dom)){var b=a.domSize||1;if(1<b)for(var e=a.dom;--b;){var g=
e.nextSibling,m=g.parentNode;null!=m&&m.removeChild(g)}b=a.dom;e=b.parentNode;null!=e&&e.removeChild(b);if(b=null!=c&&null==a.domSize)b=a.attrs,b=!(null!=b&&(b.oncreate||b.onupdate||b.onbeforeremove||b.onremove));b&&"string"===typeof a.tag&&(c.pool?c.pool.push(a):c.pool=[a])}}var h=1,d=0;if(a.attrs&&a.attrs.onbeforeremove){var e=a.attrs.onbeforeremove.call(a.state,a);null!=e&&"function"===typeof e.then&&(h++,e.then(b,b))}"string"!==typeof a.tag&&a.state.onbeforeremove&&(e=a.state.onbeforeremove(a),
null!=e&&"function"===typeof e.then&&(h++,e.then(b,b)));b()}function r(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,a);if("string"!==typeof a.tag&&a.state.onremove)a.state.onremove(a);if(null!=a.instance)r(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&r(b)}}function A(a,c,b,d,e){var h=a.dom;if("key"!==c&&"is"!==c&&(b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===D.activeElement||"object"===typeof d)&&
"undefined"!==typeof d&&!E(c)){var g=c.indexOf(":");if(-1<g&&"xlink"===c.substr(0,g))h.setAttributeNS("http://www.w3.org/1999/xlink",c.slice(g+1),d);else if("o"===c[0]&&"n"===c[1]&&"function"===typeof d)x(a,c,d);else if("style"===c)if(a=b,a===d&&(h.style.cssText="",a=null),null==d)h.style.cssText="";else if("string"===typeof d)h.style.cssText=d;else{"string"===typeof a&&(h.style.cssText="");for(var f in d)h.style[f]=d[f];if(null!=a&&"string"!==typeof a)for(f in a)f in d||(h.style[f]="")}else c in
h&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))?"input"===a.tag&&"value"===c&&a.dom.value==d&&a.dom===D.activeElement||"select"===a.tag&&"value"===c&&a.dom.value==d&&a.dom===D.activeElement||"option"===a.tag&&"value"===c&&a.dom.value==d||("input"===a.tag&&"type"===c?h.setAttribute(c,d):h[c]=d):"boolean"===typeof d?d?h.setAttribute(c,""):h.removeAttribute(c):h.setAttribute("className"===c?"class":c,d)}}function E(a){return"oninit"===
a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function x(a,c,b){var d=a.dom,e="function"!==typeof F?b:function(a){var c=b.call(d,a);F.call(d,a);return c};if(c in d)d[c]="function"===typeof b?e:null;else{var h=c.slice(2);void 0===a.events&&(a.events={});a.events[c]!==e&&(null!=a.events[c]&&d.removeEventListener(h,a.events[c],!1),"function"===typeof b&&(a.events[c]=e,d.addEventListener(h,a.events[c],!1)))}}function C(a,c,b){"function"===typeof a.oninit&&
a.oninit.call(c.state,c);"function"===typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function I(a,c,b){"function"===typeof a.onupdate&&b.push(a.onupdate.bind(c.state,c))}var D=a.document,J=D.createDocumentFragment(),F;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=D.activeElement;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);p(a,a.vnodes,B.normalizeChildren(b),!1,c,null,void 0);a.vnodes=
b;for(var e=0;e<c.length;e++)c[e]();D.activeElement!==d&&d.focus()},setEventCallback:function(a){return F=a}}},H=function(a){function d(a){a=g.indexOf(a);-1<a&&g.splice(a,2)}function f(){for(var a=1;a<g.length;a+=2)g[a]()}a=O(a);a.setEventCallback(function(a){!1!==a.redraw&&f()});var g=[];return{subscribe:function(a,f){d(a);g.push(a,Q(f))},unsubscribe:d,redraw:f,render:a.render}}(window);K.setCompletionCallback(H.redraw);C.mount=function(a){return function(d,f){if(null===f)a.render(d,[]),a.unsubscribe(d);
else{if(null==f.view&&"function"!==typeof f)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(d,function(){a.render(d,B(f))});a.redraw()}}}(H);var T=x,L=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},f={},g=0;g<a.length;g++){var e=a[g].split("="),p=decodeURIComponent(e[0]),e=2===e.length?decodeURIComponent(e[1]):"";"true"===e?e=!0:"false"===e&&(e=!1);var k=p.split(/\]\[?|\[/),q=d;-1<p.indexOf("[")&&k.pop();
for(var n=0;n<k.length;n++){var p=k[n],l=k[n+1],l=""==l||!isNaN(parseInt(l,10)),u=n===k.length-1;""===p&&(p=k.slice(0,n).join(),null==f[p]&&(f[p]=0),p=f[p]++);null==q[p]&&(q[p]=u?e:l?[]:{});q=q[p]}}return d},U=function(a){function d(d){var e=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function f(a){return function(){null==k&&(k=p(function(){k=null;a()}))}}function g(a,d,e){var b=a.indexOf("?"),g=a.indexOf("#"),f=-1<b?b:-1<g?g:
a.length;if(-1<b){var b=L(a.slice(b+1,-1<g?g:a.length)),k;for(k in b)d[k]=b[k]}if(-1<g)for(k in d=L(a.slice(g+1)),d)e[k]=d[k];return a.slice(0,f)}var e="function"===typeof a.history.pushState,p="function"===typeof setImmediate?setImmediate:setTimeout,k,q={prefix:"#!",getPath:function(){switch(q.prefix.charAt(0)){case "#":return d("hash").slice(q.prefix.length);case "?":return d("search").slice(q.prefix.length)+d("hash");default:return d("pathname").slice(q.prefix.length)+d("search")+d("hash")}},setPath:function(d,
f,k){var b={},l={};d=g(d,b,l);if(null!=f){for(var n in f)b[n]=f[n];d=d.replace(/:([^\/]+)/g,function(a,d){delete b[d];return f[d]})}(n=F(b))&&(d+="?"+n);(l=F(l))&&(d+="#"+l);e?(l=k?k.state:null,n=k?k.title:null,a.onpopstate(),k&&k.replace?a.history.replaceState(l,n,q.prefix+d):a.history.pushState(l,n,q.prefix+d)):a.location.href=q.prefix+d},defineRoutes:function(d,k,p){function b(){var b=q.getPath(),e={},f=g(b,e,e),l=a.history.state;if(null!=l)for(var n in l)e[n]=l[n];for(var u in d)if(l=new RegExp("^"+
u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),l.test(f)){f.replace(l,function(){for(var a=u.match(/:[^\/]+/g)||[],g=[].slice.call(arguments,1,-2),f=0;f<a.length;f++)e[a[f].replace(/:|\./g,"")]=decodeURIComponent(g[f]);k(d[u],e,b,u)});return}p(b,e)}e?a.onpopstate=f(b):"#"===q.prefix.charAt(0)&&(a.onhashchange=b);b()}};return q};C.route=function(a,d){var f=U(a),g=function(a){return a},e,p,k,q,n,l=function(a,b,l){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");
var u=function(){null!=e&&d.render(a,e(B(p,k.key,k)))},w=function(a){if(a!==b)f.setPath(b,null,{replace:!0});else throw Error("Could not resolve default route "+b);};f.defineRoutes(l,function(a,b,d){var f=n=function(a,l){f===n&&(p=null==l||"function"!==typeof l.view&&"function"!==typeof l?"div":l,k=b,q=d,n=null,e=(a.render||g).bind(a),u())};a.view||"function"===typeof a?f({},a):a.onmatch?T.resolve(a.onmatch(b,d)).then(function(b){f(a,b)},w):f(a,"div")},w);d.subscribe(a,u)};l.set=function(a,b,d){null!=
n&&(d={replace:!0});n=null;f.setPath(a,b,d)};l.get=function(){return q};l.prefix=function(a){f.prefix=a};l.link=function(a){a.dom.setAttribute("href",f.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(f.prefix)&&(a=a.slice(f.prefix.length)),l.set(a,void 0,void 0))}};l.param=function(a){return"undefined"!==typeof k&&"undefined"!==typeof a?k[a]:k};return l}(window,H);C.withAttr=function(a,
d,f){return function(g){d.call(f||this,a in g.currentTarget?g.currentTarget[a]:g.currentTarget.getAttribute(a))}};var V=O(window);C.render=V.render;C.redraw=H.redraw;C.request=K.request;C.jsonp=K.jsonp;C.parseQueryString=L;C.buildQueryString=F;C.version="1.0.1";C.vnode=B;"undefined"!==typeof module?module.exports=C:window.m=C})();

View file

@ -278,12 +278,20 @@ ospec will automatically evaluate all `*.js` files in any folder named `/tests`.
$ npm test
```
#### Installing ospec globally
#### Direct use from the command line
While it's recommended to install ospec locally to maintain reproducible environments, sometimes it may be deemed appropriate to install it globally. To do so, run this command:
Ospec doesn't work when installed globally. Using global scripts is generally a bad idea since you can end up with different, incompatible versions of the same package installed locally and globally.
To work around this limitation, you can use [`npm-run`](https://www.npmjs.com/package/npm-run) which enables one to run the binaries of locally installed packages.
```
npm install ospec -g
npm install npm-run -g
```
Then, from a project that has ospec installed as a (dev) dependency:
```
npm-run ospec
```
---

View file

@ -5,7 +5,6 @@
"author": "Leo Horie",
"license": "MIT",
"main": "mithril.js",
"types": "mithril.d.ts",
"repository": "lhorie/mithril.js",
"scripts": {
"dev": "node bundler/cli browser.js -o mithril.js -w",

View file

@ -4,66 +4,97 @@ var Vnode = require("../render/vnode")
var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g
var selectorCache = {}
function hyperscript(selector) {
if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") {
throw Error("The selector must be either a string or a component.");
}
var hasOwn = {}.hasOwnProperty
if (typeof selector === "string" && selectorCache[selector] === undefined) {
var match, tag, classes = [], attributes = {}
function compileSelector(selector) {
var match, tag = "div", classes = [], attrs = {}
while (match = selectorParser.exec(selector)) {
var type = match[1], value = match[2]
if (type === "" && value !== "") tag = value
else if (type === "#") attributes.id = value
else if (type === "#") attrs.id = value
else if (type === ".") classes.push(value)
else if (match[3][0] === "[") {
var attrValue = match[6]
if (attrValue) attrValue = attrValue.replace(/\\(["'])/g, "$1").replace(/\\\\/g, "\\")
if (match[4] === "class") classes.push(attrValue)
else attributes[match[4]] = attrValue || true
else attrs[match[4]] = attrValue || true
}
}
if (classes.length > 0) attributes.className = classes.join(" ")
selectorCache[selector] = function(attrs, children) {
if (classes.length > 0) attrs.className = classes.join(" ")
return selectorCache[selector] = {tag: tag, attrs: attrs}
}
function execSelector(state, attrs, children) {
var hasAttrs = false, childList, text
var className = attrs.className || attrs.class
for (var key in attributes) attrs[key] = attributes[key]
if (className !== undefined) {
if (attrs.class !== undefined) {
for (var key in state.attrs) {
if (hasOwn.call(state.attrs, key)) {
attrs[key] = state.attrs[key]
}
}
if (className != null) {
if (attrs.class != null) {
attrs.class = undefined
attrs.className = className
}
if (attributes.className !== undefined) attrs.className = attributes.className + " " + className
if (state.attrs.className != null) {
attrs.className = state.attrs.className + " " + className
}
}
for (var key in attrs) {
if (key !== "key") {
if (hasOwn.call(attrs, key) && key !== "key") {
hasAttrs = true
break
}
}
if (Array.isArray(children) && children.length == 1 && children[0] != null && children[0].tag === "#") text = children[0].children
else childList = children
return Vnode(tag || "div", attrs.key, hasAttrs ? attrs : undefined, childList, text, undefined)
if (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === "#") {
text = children[0].children
} else {
childList = children
}
return Vnode(state.tag, attrs.key, hasAttrs ? attrs : undefined, childList, text)
}
var attrs, children, childrenIndex
if (arguments[1] == null || typeof arguments[1] === "object" && arguments[1].tag === undefined && !Array.isArray(arguments[1])) {
attrs = arguments[1]
childrenIndex = 2
function hyperscript(selector) {
// Because sloppy mode sucks
var attrs = arguments[1], start = 2, children
if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") {
throw Error("The selector must be either a string or a component.");
}
else childrenIndex = 1
if (arguments.length === childrenIndex + 1) {
children = Array.isArray(arguments[childrenIndex]) ? arguments[childrenIndex] : [arguments[childrenIndex]]
if (typeof selector === "string") {
var cached = selectorCache[selector] || compileSelector(selector)
}
else {
if (!attrs) {
attrs = {}
} else if (typeof attrs !== "object" || attrs.tag != null || Array.isArray(attrs)) {
attrs = {}
start = 1
}
if (arguments.length === start + 1) {
children = arguments[start]
if (!Array.isArray(children)) children = [children]
} else {
children = []
for (var i = childrenIndex; i < arguments.length; i++) children.push(arguments[i])
while (start < arguments.length) children.push(arguments[start++])
}
if (typeof selector === "string") return selectorCache[selector](attrs || {}, Vnode.normalizeChildren(children))
var normalized = Vnode.normalizeChildren(children)
return Vnode(selector, attrs && attrs.key, attrs || {}, Vnode.normalizeChildren(children), undefined, undefined)
if (typeof selector === "string") {
return execSelector(cached, attrs, normalized)
} else {
return Vnode(selector, attrs.key, attrs, normalized)
}
}
module.exports = hyperscript

View file

@ -21,6 +21,7 @@ module.exports = function($window) {
function createNode(parent, vnode, hooks, ns, nextSibling) {
var tag = vnode.tag
if (typeof tag === "string") {
vnode.state = {}
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)
switch (tag) {
case "#": return createText(parent, vnode, nextSibling)
@ -238,7 +239,10 @@ module.exports = function($window) {
if (!recycling && shouldNotUpdate(vnode, old)) return
if (typeof oldTag === "string") {
if (vnode.attrs != null) {
if (recycling) initLifecycle(vnode.attrs, vnode, hooks)
if (recycling) {
vnode.state = {}
initLifecycle(vnode.attrs, vnode, hooks)
}
else updateLifecycle(vnode.attrs, vnode, hooks)
}
switch (oldTag) {

View file

@ -1,7 +1,7 @@
"use strict"
function Vnode(tag, key, attrs, children, text, dom) {
return {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: {}, events: undefined, instance: undefined, skip: false}
return {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined, skip: false}
}
Vnode.normalize = function(node) {
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)

View file

@ -1,5 +1,7 @@
"use strict"
;(function() {
var guid = 0, HALT = {}
function createStream() {
function stream() {
@ -113,4 +115,7 @@ createStream.combine = combine
createStream.HALT = HALT
if (typeof module !== "undefined") module["exports"] = createStream
else window.stream = createStream
else if (typeof window.m === "function" && !("stream" in window.m)) window.m.stream = createStream
else window.m = {stream : createStream}
}());