aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-01-31 00:10:58 +0100
committerRobert Jaros <rjaros@finn.pl>2018-01-31 00:10:58 +0100
commitfacf7991ed52cb21852dd6175a3817e94598c2dc (patch)
treeaa4364769bbe0c3d637af8061761ef32c2234c37
parenta3514f0ea18313d37b9701e055f97f7ad81f76c4 (diff)
downloadkvision-facf7991ed52cb21852dd6175a3817e94598c2dc.tar.gz
kvision-facf7991ed52cb21852dd6175a3817e94598c2dc.tar.bz2
kvision-facf7991ed52cb21852dd6175a3817e94598c2dc.zip
TodoMVC example
-rw-r--r--examples/todomvc/.gitignore4
-rw-r--r--examples/todomvc/build.gradle94
-rw-r--r--examples/todomvc/detekt.yml292
-rw-r--r--examples/todomvc/gradle.properties2
-rw-r--r--examples/todomvc/gradle/wrapper/gradle-wrapper.jarbin0 -> 54712 bytes
-rw-r--r--examples/todomvc/gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xexamples/todomvc/gradlew172
-rw-r--r--examples/todomvc/gradlew.bat84
-rw-r--r--examples/todomvc/package.json.d/project.info3
-rwxr-xr-xexamples/todomvc/refresh.sh26
-rw-r--r--examples/todomvc/settings.gradle1
-rw-r--r--examples/todomvc/src/main/kotlin/com/example/Main.kt40
-rw-r--r--examples/todomvc/src/main/kotlin/com/example/Todomvc.kt242
-rw-r--r--examples/todomvc/src/main/web/index.html22
-rw-r--r--examples/todomvc/src/main/web/node_modules/todomvc-app-css/index.css376
-rw-r--r--examples/todomvc/src/main/web/node_modules/todomvc-app-css/package.json58
-rw-r--r--examples/todomvc/src/main/web/node_modules/todomvc-app-css/readme.md28
-rw-r--r--examples/todomvc/src/main/web/node_modules/todomvc-common/base.css141
-rw-r--r--examples/todomvc/src/main/web/node_modules/todomvc-common/base.js249
-rw-r--r--examples/todomvc/src/main/web/node_modules/todomvc-common/package.json54
-rw-r--r--examples/todomvc/src/main/web/node_modules/todomvc-common/readme.md15
-rw-r--r--examples/todomvc/src/main/web/package-lock.json16
-rw-r--r--examples/todomvc/src/main/web/package.json7
-rw-r--r--examples/todomvc/src/test/kotlin/test/com/example/TestUtil.kt32
-rw-r--r--examples/todomvc/webpack.config.d/bootstrap.js4
-rw-r--r--examples/todomvc/webpack.config.d/css.js2
-rw-r--r--examples/todomvc/webpack.config.d/dce.js2
-rw-r--r--examples/todomvc/webpack.config.d/file.js6
-rw-r--r--examples/todomvc/webpack.config.d/jquery.js4
-rw-r--r--examples/todomvc/webpack.config.d/minify.js4
30 files changed, 1986 insertions, 0 deletions
diff --git a/examples/todomvc/.gitignore b/examples/todomvc/.gitignore
new file mode 100644
index 00000000..4d615936
--- /dev/null
+++ b/examples/todomvc/.gitignore
@@ -0,0 +1,4 @@
+.*/
+build/
+out/
+*.iml \ No newline at end of file
diff --git a/examples/todomvc/build.gradle b/examples/todomvc/build.gradle
new file mode 100644
index 00000000..3087c146
--- /dev/null
+++ b/examples/todomvc/build.gradle
@@ -0,0 +1,94 @@
+buildscript {
+ ext.kotlin_version = '1.2.21'
+ ext.production = (findProperty('prod') ?: 'false') == 'true'
+ ext.npmdeps = new URL("file:///home/rjaros/git/kvision/npm.dependencies").getText()
+
+ repositories {
+ jcenter()
+ maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
+ maven { url "https://plugins.gradle.org/m2/" }
+ }
+
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.26"
+ classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0.RC6-2"
+ }
+}
+
+apply plugin: 'kotlin2js'
+apply plugin: 'org.jetbrains.kotlin.frontend'
+apply plugin: "io.gitlab.arturbosch.detekt"
+
+repositories {
+ jcenter()
+ maven { url = 'https://dl.bintray.com/gbaldeck/kotlin' }
+ maven { url = 'https://dl.bintray.com/rjaros/kotlin' }
+ maven {
+ url "file:///home/rjaros/kotlin/mvn/"
+ }
+}
+
+dependencies {
+ compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
+ compile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" // for now only compile configuration is supported
+ compile "pl.treksoft:kvision:0.0.1"
+}
+
+kotlinFrontend {
+ npm {
+ npmdeps.eachLine { line ->
+ def (name, version) = line.tokenize(" ")
+ dependency(name, version)
+ }
+ dependency("todomvc-app-css", "^2.0.0")
+ dependency("todomvc-common", "^1.0.0")
+ devDependency("karma")
+ }
+
+ webpackBundle {
+ bundleName = "main"
+ contentPath = file('src/main/web')
+ }
+
+ define "PRODUCTION", production
+
+}
+
+detekt {
+ version = "1.0.0.RC6-2"
+ profile("main") {
+ input = "$projectDir/src/main/kotlin"
+ config = "$projectDir/detekt.yml"
+ filters = ".*test.*,.*/resources/.*,.*/tmp/.*"
+ }
+}
+
+compileKotlin2Js {
+ kotlinOptions.metaInfo = true
+ kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}.js"
+ kotlinOptions.sourceMap = !production
+ kotlinOptions.moduleKind = 'commonjs'
+}
+
+compileTestKotlin2Js {
+ kotlinOptions.metaInfo = true
+ kotlinOptions.outputFile = "$project.buildDir.path/js-tests/${project.name}-tests.js"
+ kotlinOptions.sourceMap = !production
+ kotlinOptions.moduleKind = 'commonjs'
+}
+
+task copyResources(type: Copy) {
+ from "src/main/resources"
+ into file(buildDir.path + "/js")
+}
+
+task copyResourcesForTests(type: Copy) {
+ from "src/main/resources"
+ into file(buildDir.path + "/js-tests/")
+}
+
+afterEvaluate {
+ tasks.getByName("webpack-bundle") { dependsOn(copyResources) }
+ tasks.getByName("webpack-run") { dependsOn(copyResources, copyResourcesForTests) }
+}
diff --git a/examples/todomvc/detekt.yml b/examples/todomvc/detekt.yml
new file mode 100644
index 00000000..a6fdea75
--- /dev/null
+++ b/examples/todomvc/detekt.yml
@@ -0,0 +1,292 @@
+autoCorrect: true
+failFast: false
+
+build:
+ warningThreshold: 5
+ failThreshold: 10
+ weights:
+ complexity: 2
+ formatting: 1
+ LongParameterList: 1
+ comments: 1
+
+processors:
+ active: true
+ exclude:
+ # - 'FunctionCountProcessor'
+ # - 'PropertyCountProcessor'
+ # - 'ClassCountProcessor'
+ # - 'PackageCountProcessor'
+ # - 'KtFileCountProcessor'
+
+console-reports:
+ active: true
+ exclude:
+ # - 'ProjectStatisticsReport'
+ # - 'ComplexityReport'
+ # - 'NotificationReport'
+ # - 'FindingsReport'
+ # - 'BuildFailureReport'
+
+output-reports:
+ active: true
+ exclude:
+ # - 'PlainOutputReport'
+ # - 'XmlOutputReport'
+
+potential-bugs:
+ active: true
+ DuplicateCaseInWhenExpression:
+ active: true
+ EqualsAlwaysReturnsTrueOrFalse:
+ active: false
+ EqualsWithHashCodeExist:
+ active: true
+ WrongEqualsTypeParameter:
+ active: false
+ ExplicitGarbageCollectionCall:
+ active: true
+ UnreachableCode:
+ active: true
+ LateinitUsage:
+ active: false
+ UnsafeCallOnNullableType:
+ active: false
+ UnsafeCast:
+ active: false
+ UselessPostfixExpression:
+ active: false
+
+performance:
+ active: true
+ ForEachOnRange:
+ active: true
+ SpreadOperator:
+ active: true
+ UnnecessaryTemporaryInstantiation:
+ active: true
+
+exceptions:
+ active: true
+ TooGenericExceptionCatched:
+ active: true
+ exceptions:
+ - ArrayIndexOutOfBoundsException
+ - Error
+ - Exception
+ - IllegalMonitorStateException
+ - IndexOutOfBoundsException
+ - NullPointerException
+ - RuntimeException
+ TooGenericExceptionThrown:
+ active: true
+ exceptions:
+ - Throwable
+ - ThrowError
+ - ThrowException
+ - ThrowNullPointerException
+ - ThrowRuntimeException
+ - ThrowThrowable
+
+empty-blocks:
+ active: true
+ EmptyCatchBlock:
+ active: true
+ EmptyClassBlock:
+ active: true
+ EmptyDefaultConstructor:
+ active: true
+ EmptyDoWhileBlock:
+ active: true
+ EmptyElseBlock:
+ active: true
+ EmptyFinallyBlock:
+ active: true
+ EmptyForBlock:
+ active: true
+ EmptyFunctionBlock:
+ active: true
+ EmptyIfBlock:
+ active: true
+ EmptyInitBlock:
+ active: true
+ EmptySecondaryConstructor:
+ active: true
+ EmptyWhenBlock:
+ active: true
+ EmptyWhileBlock:
+ active: true
+
+complexity:
+ active: true
+ LongMethod:
+ threshold: 20
+ LongParameterList:
+ threshold: 5
+ LargeClass:
+ threshold: 150
+ ComplexMethod:
+ threshold: 10
+ TooManyFunctions:
+ threshold: 10
+ ComplexCondition:
+ threshold: 3
+ LabeledExpression:
+ active: false
+ StringLiteralDuplication:
+ active: false
+ threshold: 2
+ ignoreAnnotation: true
+ excludeStringsWithLessThan5Characters: true
+ ignoreStringsRegex: '$^'
+
+code-smell:
+ active: true
+ FeatureEnvy:
+ threshold: 0.5
+ weight: 0.45
+ base: 0.5
+
+formatting:
+ active: true
+ useTabs: true
+ Indentation:
+ active: false
+ indentSize: 4
+ ConsecutiveBlankLines:
+ active: true
+ autoCorrect: true
+ MultipleSpaces:
+ active: true
+ autoCorrect: true
+ SpacingAfterComma:
+ active: true
+ autoCorrect: true
+ SpacingAfterKeyword:
+ active: true
+ autoCorrect: true
+ SpacingAroundColon:
+ active: true
+ autoCorrect: true
+ SpacingAroundCurlyBraces:
+ active: true
+ autoCorrect: true
+ SpacingAroundOperator:
+ active: true
+ autoCorrect: true
+ TrailingSpaces:
+ active: true
+ autoCorrect: true
+ UnusedImports:
+ active: true
+ autoCorrect: true
+ OptionalSemicolon:
+ active: true
+ autoCorrect: true
+ OptionalUnit:
+ active: true
+ autoCorrect: true
+ ExpressionBodySyntax:
+ active: false
+ autoCorrect: false
+ ExpressionBodySyntaxLineBreaks:
+ active: false
+ autoCorrect: false
+ OptionalReturnKeyword:
+ active: true
+ autoCorrect: false
+
+style:
+ active: true
+ ReturnCount:
+ active: true
+ max: 2
+ NewLineAtEndOfFile:
+ active: true
+ OptionalAbstractKeyword:
+ active: true
+ OptionalWhenBraces:
+ active: false
+ EqualsNullCall:
+ active: false
+ ForbiddenComment:
+ active: true
+ values: 'TODO:,FIXME:,STOPSHIP:'
+ ForbiddenImport:
+ active: false
+ imports: ''
+ ModifierOrder:
+ active: true
+ MagicNumber:
+ active: true
+ ignoreNumbers: '-1,0,1,2'
+ ignoreHashCodeFunction: false
+ ignorePropertyDeclaration: false
+ ignoreAnnotation: false
+ WildcardImport:
+ active: true
+ SafeCast:
+ active: true
+ MaxLineLength:
+ active: true
+ maxLineLength: 120
+ excludePackageStatements: false
+ excludeImportStatements: false
+ PackageNaming:
+ active: true
+ packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$'
+ ClassNaming:
+ active: true
+ classPattern: '[A-Z$][a-zA-Z$]*'
+ EnumNaming:
+ active: true
+ enumEntryPattern: '^[A-Z$][a-zA-Z_$]*$'
+ FunctionNaming :
+ active: true
+ functionPattern: '^[a-z$][a-zA-Z$0-9]*$'
+ FunctionMaxLength:
+ active: false
+ maximumFunctionNameLength: 30
+ FunctionMinLength:
+ active: false
+ minimumFunctionNameLength: 3
+ VariableNaming :
+ active: true
+ variablePattern: '^(_)?[a-z$][a-zA-Z$0-9]*$'
+ ConstantNaming :
+ active: true
+ constantPattern: '^([A-Z_]*|serialVersionUID)$'
+ VariableMaxLength:
+ active: false
+ maximumVariableNameLength: 30
+ VariableMinLength:
+ active: false
+ minimumVariableNameLength: 3
+ ProtectedMemberInFinalClass:
+ active: false
+ UnnecessaryParentheses:
+ active: false
+
+comments:
+ active: true
+ CommentOverPrivateMethod:
+ active: true
+ CommentOverPrivateProperty:
+ active: true
+ UndocumentedPublicClass:
+ active: false
+ searchInNestedClass: true
+ searchInInnerClass: true
+ searchInInnerObject: true
+ searchInInnerInterface: true
+ UndocumentedPublicFunction:
+ active: false
+
+# *experimental feature*
+# Migration rules can be defined in the same config file or a new one
+migration:
+ active: true
+ imports:
+ # your.package.Class: new.package.or.Class
+ # for example:
+ # io.gitlab.arturbosch.detekt.api.Rule: io.gitlab.arturbosch.detekt.rule.Rule
diff --git a/examples/todomvc/gradle.properties b/examples/todomvc/gradle.properties
new file mode 100644
index 00000000..4ac81290
--- /dev/null
+++ b/examples/todomvc/gradle.properties
@@ -0,0 +1,2 @@
+#org.gradle.jvmargs=-XX:+UnlockCommercialFeatures -XX:+FlightRecorder
+#org.gradle.debug=true
diff --git a/examples/todomvc/gradle/wrapper/gradle-wrapper.jar b/examples/todomvc/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..09f1fecb
--- /dev/null
+++ b/examples/todomvc/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/examples/todomvc/gradle/wrapper/gradle-wrapper.properties b/examples/todomvc/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..9f53b3e5
--- /dev/null
+++ b/examples/todomvc/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Jan 22 09:38:31 CET 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
diff --git a/examples/todomvc/gradlew b/examples/todomvc/gradlew
new file mode 100755
index 00000000..cccdd3d5
--- /dev/null
+++ b/examples/todomvc/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/examples/todomvc/gradlew.bat b/examples/todomvc/gradlew.bat
new file mode 100644
index 00000000..f9553162
--- /dev/null
+++ b/examples/todomvc/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/examples/todomvc/package.json.d/project.info b/examples/todomvc/package.json.d/project.info
new file mode 100644
index 00000000..3c4d58fe
--- /dev/null
+++ b/examples/todomvc/package.json.d/project.info
@@ -0,0 +1,3 @@
+{
+ "description": "KVision TodoMVC"
+}
diff --git a/examples/todomvc/refresh.sh b/examples/todomvc/refresh.sh
new file mode 100755
index 00000000..2568701d
--- /dev/null
+++ b/examples/todomvc/refresh.sh
@@ -0,0 +1,26 @@
+./gradlew stop
+rm -rf build/bundle
+rm -rf build/js
+rm -rf build/js-tests
+rm -rf build/reports
+rm -rf build/resources
+rm -rf build/tmp
+rm -rf build/logs
+rm -rf build/package.json
+rm -rf build/package-lock.json
+rm -rf build/.modules.with.kotlin.txt
+rm -rf build/.modules.with.types.txt
+rm -rf build/.npmrc
+rm -rf build/.unpack.txt
+rm -rf build/kotlin
+rm -rf build/kotlin-build
+rm -rf build/*.js
+rm -rf build/node_modules/kotlin
+rm -rf build/node_modules/kotlin-test
+rm -rf build/node_modules/kvision
+rm -rf build/node_modules/navigo-kotlin
+rm -rf build/node_modules/jquery-kotlin
+rm -rf build/node_modules/snabbdom-kotlin
+rm -rf build/node_modules/kotlin-observable-js
+rm -rf build/node_modules_imported
+./gradlew -t run
diff --git a/examples/todomvc/settings.gradle b/examples/todomvc/settings.gradle
new file mode 100644
index 00000000..00861ee1
--- /dev/null
+++ b/examples/todomvc/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'todomvc'
diff --git a/examples/todomvc/src/main/kotlin/com/example/Main.kt b/examples/todomvc/src/main/kotlin/com/example/Main.kt
new file mode 100644
index 00000000..d8894a4c
--- /dev/null
+++ b/examples/todomvc/src/main/kotlin/com/example/Main.kt
@@ -0,0 +1,40 @@
+package com.example
+
+import pl.treksoft.kvision.ApplicationBase
+import pl.treksoft.kvision.core.KVManager
+import pl.treksoft.kvision.module
+import kotlin.browser.document
+
+fun main(args: Array<String>) {
+ var application: ApplicationBase? = null
+
+ val state: dynamic = module.hot?.let { hot ->
+ hot.accept()
+
+ hot.dispose { data ->
+ data.appState = application?.dispose()
+ KVManager.shutdown()
+ application = null
+ }
+
+ hot.data
+ }
+
+ if (document.body != null) {
+ KVManager.start()
+ application = start(state)
+ } else {
+ KVManager.init()
+ application = null
+ document.addEventListener("DOMContentLoaded", { application = start(state) })
+ }
+}
+
+fun start(state: dynamic): ApplicationBase? {
+ if (document.getElementById("todomvc") == null) return null
+ val application = Todomvc()
+ @Suppress("UnsafeCastFromDynamic")
+ application.start(state?.appState ?: emptyMap())
+ return application
+}
+
diff --git a/examples/todomvc/src/main/kotlin/com/example/Todomvc.kt b/examples/todomvc/src/main/kotlin/com/example/Todomvc.kt
new file mode 100644
index 00000000..76d90716
--- /dev/null
+++ b/examples/todomvc/src/main/kotlin/com/example/Todomvc.kt
@@ -0,0 +1,242 @@
+package com.example
+
+import com.lightningkite.kotlin.observable.list.observableListOf
+import org.w3c.dom.get
+import org.w3c.dom.set
+import pl.treksoft.kvision.ApplicationBase
+import pl.treksoft.kvision.core.Root
+import pl.treksoft.kvision.data.DataComponent
+import pl.treksoft.kvision.data.DataContainer
+import pl.treksoft.kvision.form.FieldLabel
+import pl.treksoft.kvision.form.check.CHECKINPUTTYPE
+import pl.treksoft.kvision.form.check.CheckInput
+import pl.treksoft.kvision.form.text.TextInput
+import pl.treksoft.kvision.html.Button
+import pl.treksoft.kvision.html.LIST
+import pl.treksoft.kvision.html.Link
+import pl.treksoft.kvision.html.ListTag
+import pl.treksoft.kvision.html.TAG
+import pl.treksoft.kvision.html.Tag
+import pl.treksoft.kvision.routing.routing
+import kotlin.browser.localStorage
+
+const val ENTER_KEY = 13
+const val ESCAPE_KEY = 27
+
+class Todo(completed: Boolean, title: String, hidden: Boolean) : DataComponent() {
+ var completed: Boolean by obs(completed)
+ var title: String by obs(title)
+ var hidden: Boolean by obs(hidden)
+}
+
+enum class LISTMODE {
+ ALL,
+ ACTIVE,
+ COMPLETED
+}
+
+class Todomvc : ApplicationBase() {
+
+ private val model = observableListOf<Todo>()
+
+ private val checkAllInput = CheckInput(classes = setOf("toggle-all")).apply {
+ id = "toggle-all"
+ onClick {
+ val value = this.value
+ model.forEach { it.completed = value }
+ }
+ }
+ private val allLink = Link("All", "#!/", classes = setOf("selected"))
+ private val activeLink = Link("Active", "#!/active")
+ private val completedLink = Link("Completed", "#!/completed")
+ private val clearCompletedButton = Button("Clear completed", classes = setOf("clear-completed")).onClick {
+ model.filter { it.completed }.forEach { model.remove(it) }
+ }
+
+ private val countTag = Tag(TAG.STRONG, "0")
+ private val itemsLeftTag = Tag(TAG.SPAN, " items left", classes = setOf("todo-count")).apply {
+ add(countTag)
+ }
+ private var mode: LISTMODE = LISTMODE.ALL
+
+ private val header = genHeader()
+ private val main = genMain()
+ private val footer = genFooter()
+
+ override fun start(state: Map<String, Any>) {
+ val root = Root("todomvc")
+ val section = Tag(TAG.SECTION, classes = setOf("todoapp"))
+ section.add(this.header)
+ section.add(this.main)
+ section.add(this.footer)
+ root.add(section)
+ loadModel()
+ checkModel()
+ routing.on("/", { _ -> all() })
+ .on("/active", { _ -> active() })
+ .on("/completed", { _ -> completed() })
+ .resolve()
+ }
+
+ private fun loadModel() {
+ localStorage.get("todos-kvision")?.let {
+ JSON.parse<Array<dynamic>>(it).map { Todo(it.completed, it.title, false) }.forEach {
+ model.add(it)
+ }
+ }
+ }
+
+ private fun saveModel() {
+ val jsonString = model.map {
+ val array = listOf("title" to it.title, "completed" to it.completed).toTypedArray()
+ JSON.stringify(kotlin.js.json(*array))
+ }.toString()
+ localStorage.set("todos-kvision", jsonString)
+ }
+
+ private fun checkModel() {
+ val countActive = model.filter { !it.completed }.size
+ val countCompleted = model.filter { it.completed }.size
+ this.main.visible = model.isNot