Skip to content

Commit

Permalink
ADD mikado-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
ts-thomas committed Oct 31, 2019
1 parent b4df679 commit 177776a
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frameworks/keyed/mikado-proxy/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Mikado-"keyed"</title>
<link rel="preload" href="dist/main.js" as="script">
<link href="/css/currentStyle.css" rel="stylesheet"/>
</head>
<body>
<div id="main"></div>
<script src="dist/main.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions frameworks/keyed/mikado-proxy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"private": true,
"name": "js-framework-benchmark-mikado-proxy",
"homepage": "https://github.com/nextapps-de/mikado/",
"author": "Nextapps GmbH",
"license": "Apache-2.0",
"js-framework-benchmark": {
"frameworkVersionFromPackage": "mikado"
},
"preferGlobal": false,
"repository": {
"type": "git",
"url": "https://github.com/krausest/js-framework-benchmark.git"
},
"scripts": {
"compile": "mikado-compile src/template/app.html && mikado-compile src/template/item.html && echo Compile Complete. && exit 0",
"build": "npm run compile && node task/build RELEASE=custom DEBUG=false USE_POLYFILL=false SUPPORT_CACHE=false SUPPORT_EVENTS=true SUPPORT_STORAGE=true SUPPORT_HELPERS=false SUPPORT_ASYNC=false SUPPORT_TRANSPORT=false SUPPORT_TEMPLATE_EXTENSION=false SUPPORT_REACTIVE=true SUPPORT_CACHE_HELPERS=false SUPPORT_POOLS=false SUPPORT_CALLBACKS=false SUPPORT_COMPILE=false && exit 0",
"build-prod": "npm run build"
},
"dependencies": {
"mikado": "^0.7.46"
},
"devDependencies": {
"google-closure-compiler": "^20191030.0.0-nightly",
"mikado-compile": "0.6.5"
}
}
40 changes: 40 additions & 0 deletions frameworks/keyed/mikado-proxy/src/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const ADJECTIVES = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
const COLOURS = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
const NOUNS = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];

const len_ADJECTIVES = ADJECTIVES.length;
const len_COLOURS = COLOURS.length;
const len_NOUNS = NOUNS.length;

let _nextId = 1;

export function buildData(count){

// if(count === 1){
//
// return {
//
// id: _nextId++,
// label: ADJECTIVES[_random(len_ADJECTIVES)] + " " + COLOURS[_random(len_COLOURS)] + " " + NOUNS[_random(len_NOUNS)]
// }
// }

const data = new Array(count);

for(let i = 0; i < count; i++){

data[i] = {

"id": _nextId++,
"label": ADJECTIVES[_random(len_ADJECTIVES)] + " " + COLOURS[_random(len_COLOURS)] + " " + NOUNS[_random(len_NOUNS)],
"selected": ""
};
}

return data;
}

function _random(max){

return (Math.random() * max) | 0;
}
32 changes: 32 additions & 0 deletions frameworks/keyed/mikado-proxy/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Mikado from "../node_modules/mikado/src/mikado.js";
import Array from "../node_modules/mikado/src/array.js";
import app from "./template/app.es6.js";
import item from "./template/item.es6.js";
import { buildData } from "./data.js";

Mikado.once(document.getElementById("main"), app);

let selected = 0;
const store = new Array();
const view = new Mikado(document.getElementById("tbody"), item, {
"reuse": false, "store": store
})
.route("run", () => store.set(buildData(1000)))
.route("runlots", () => store.set(buildData(10000)))
.route("add", () => store.concat(buildData(1000)))
.route("update", () => {
for(let i = 0, len = store.length; i < len; i += 10)
store[i].label += " !!!"
})
.route("clear", () => store.splice())
.route("swaprows", () => {
const tmp = store[998];
store[998] = store[1];
store[1] = tmp;
})
.route("remove", target => store.splice(view.index(target), 1))
.route("select", target => {
store[selected]["selected"] = "";
store[selected = view.index(target)]["selected"] = "danger";
})
.listen("click");
35 changes: 35 additions & 0 deletions frameworks/keyed/mikado-proxy/src/template/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="container">
<div class="jumbotron">
<div class="row">
<div class="col-md-6">
<h1>Mikado-"keyed"</h1>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-sm-6 smallpad">
<button type="button" class="btn btn-primary btn-block" id="run" click="run">Create 1,000 rows</button>
</div>
<div class="col-sm-6 smallpad">
<button type="button" class="btn btn-primary btn-block" id="runlots" click="runlots">Create 10,000 rows</button>
</div>
<div class="col-sm-6 smallpad">
<button type="button" class="btn btn-primary btn-block" id="add" click="add">Append 1,000 rows</button>
</div>
<div class="col-sm-6 smallpad">
<button type="button" class="btn btn-primary btn-block" id="update" click="update">Update every 10th row</button>
</div>
<div class="col-sm-6 smallpad">
<button type="button" class="btn btn-primary btn-block" id="clear" click="clear">Clear</button>
</div>
<div class="col-sm-6 smallpad">
<button type="button" class="btn btn-primary btn-block" id="swaprows" click="swaprows">Swap Rows</button>
</div>
</div>
</div>
</div>
</div>
<table class="table table-hover table-striped test-data">
<tbody id="tbody"></tbody>
</table>
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
</div>
12 changes: 12 additions & 0 deletions frameworks/keyed/mikado-proxy/src/template/item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<tr class="{{=data.selected}}" root>
<td class="col-md-1">{{=data.id}}</td>
<td class="col-md-4">
<a class="lbl" click="select:root">{{=data.label}}</a>
</td>
<td class="col-md-1">
<a class="remove" click="remove:root">
<span class="remove glyphicon glyphicon-remove" aria-hidden="true"></span>
</a>
</td>
<td class="col-md-6"></td>
</tr>
115 changes: 115 additions & 0 deletions frameworks/keyed/mikado-proxy/task/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
const child_process = require('child_process');
const fs = require('fs');

console.log("Start build .....");
console.log();

fs.existsSync("log") || fs.mkdirSync("log");

let flag_str = "";

var options = (function(argv){

const arr = {};
let count = 0;

argv.forEach(function(val, index) {

if(++count > 2){

index = val.split('=');
val = index[1];
index = index[0].toUpperCase();

flag_str += " --define='" + index + "=" + val + "'";
arr[index] = val;

if(count > 3) console.log(index + ': ' + val);
}
});

console.log('RELEASE: ' + (arr['RELEASE'] || 'custom'));

return arr;

})(process.argv);

const parameter = (function(opt){

let parameter = '';

for(let index in opt){

if(opt.hasOwnProperty(index)){

parameter += ' --' + index + '=' + opt[index];
}
}

return parameter;
})({

compilation_level: "ADVANCED_OPTIMIZATIONS", //"WHITESPACE"
use_types_for_optimization: true,
//new_type_inf: true,
jscomp_warning: "newCheckTypes",
//jscomp_error: "strictCheckTypes",
jscomp_error: "newCheckTypesExtraChecks",
generate_exports: true,
export_local_property_definitions: true,
language_in: "ECMASCRIPT6_STRICT",
language_out: "ECMASCRIPT6_STRICT",
process_closure_primitives: true,
summary_detail_level: 3,
warning_level: "VERBOSE",
emit_use_strict: true,

output_manifest: "log/manifest.log",
output_module_dependencies: "log/module_dependencies.log",
property_renaming_report: "log/property_renaming.log",
create_source_map: "log/source_map.log",
variable_renaming_report: "log/variable_renaming.log",
strict_mode_input: true,
assume_function_wrapper: true,

transform_amd_modules: true,
process_common_js_modules: true,
module_resolution: "BROWSER",
//dependency_mode: "SORT_ONLY",
//js_module_root: "./",
entry_point: "./src/main.js",
//manage_closure_dependencies: true,
dependency_mode: "PRUNE_LEGACY",
rewrite_polyfills: false,

isolation_mode: "IIFE"
//output_wrapper: "(function(){%output%}());"

//formatting: "PRETTY_PRINT"
});

exec("java -jar node_modules/google-closure-compiler-java/compiler.jar" + parameter + " --js='src/*.js' --js='src/template/*.es6.js' --js='node_modules/mikado/src/*.js'" + flag_str + " --js_output_file='dist/main.js' && exit 0", function(){

console.log("Build Complete.");
});

function exec(prompt, callback){

const child = child_process.exec(prompt, function(err, stdout, stderr){

if(err){

console.error(err);
}
else{

if(callback){

callback();
}
}
});

child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
}

0 comments on commit 177776a

Please sign in to comment.