From 1184929eb8ff67c6f5220edec2f6789d79229ac5 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Sun, 27 Oct 2019 19:12:13 +0100 Subject: [PATCH] Replace swap built-in with reconcile --- frameworks/keyed/mikado/package.json | 6 +++--- frameworks/keyed/mikado/src/data.js | 16 ++++++++-------- frameworks/keyed/mikado/src/main.js | 18 ++++++++++++------ frameworks/keyed/mikado/src/template/item.html | 2 +- frameworks/keyed/mikado/task/build.js | 4 ++-- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/frameworks/keyed/mikado/package.json b/frameworks/keyed/mikado/package.json index 810665616..bb0679c35 100644 --- a/frameworks/keyed/mikado/package.json +++ b/frameworks/keyed/mikado/package.json @@ -14,14 +14,14 @@ }, "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='swap' SUPPORT_ASYNC=false SUPPORT_TRANSPORT=false SUPPORT_TEMPLATE_EXTENSION=false SUPPORT_REACTIVE=false SUPPORT_CACHE_HELPERS=false SUPPORT_POOLS=false SUPPORT_COMPILE=false && exit 0", + "build": "npm run compile && node task/build RELEASE=custom DEBUG=false USE_POLYFILL=false SUPPORT_CACHE=false SUPPORT_EVENTS=true SUPPORT_STORAGE=false SUPPORT_HELPERS=false SUPPORT_ASYNC=false SUPPORT_TRANSPORT=false SUPPORT_TEMPLATE_EXTENSION=false SUPPORT_REACTIVE=false SUPPORT_CACHE_HELPERS=false SUPPORT_POOLS=false SUPPORT_CALLBACKS=false SUPPORT_COMPILE=false && exit 0", "build-prod": "npm run build" }, "dependencies": { - "mikado": "^0.6.53" + "mikado": "0.7.35" }, "devDependencies": { - "google-closure-compiler": "20191012.0.0-nightly", + "google-closure-compiler": "20191027.0.0-nightly", "mikado-compile": "0.6.5" } } diff --git a/frameworks/keyed/mikado/src/data.js b/frameworks/keyed/mikado/src/data.js index 7a0a2f369..83ececf2b 100644 --- a/frameworks/keyed/mikado/src/data.js +++ b/frameworks/keyed/mikado/src/data.js @@ -10,14 +10,14 @@ 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)] - } - } + // if(count === 1){ + // + // return { + // + // id: _nextId++, + // label: ADJECTIVES[_random(len_ADJECTIVES)] + " " + COLOURS[_random(len_COLOURS)] + " " + NOUNS[_random(len_NOUNS)] + // } + // } const data = new Array(count); diff --git a/frameworks/keyed/mikado/src/main.js b/frameworks/keyed/mikado/src/main.js index b21328ac2..d324d768b 100644 --- a/frameworks/keyed/mikado/src/main.js +++ b/frameworks/keyed/mikado/src/main.js @@ -5,22 +5,28 @@ import { buildData } from "./data.js"; Mikado.once(document.getElementById("main"), app); +let data; const state = { "selected": {} }; const root = document.getElementById("tbody"); -const mikado = Mikado.new(root, item, { +const mikado = new Mikado(root, item, { "reuse": false, "state": state }) -.route("run", () => { mikado.render(buildData(1000)) }) -.route("runlots", () => { mikado.render(buildData(10000)) }) +.route("run", () => { mikado.clear().append(data = buildData(1000)) }) +.route("runlots", () => { mikado.clear().append(buildData(10000)) }) .route("add", () => { mikado.append(buildData(1000)) }) .route("update", () => { for(let i = 0, len = mikado.length; i < len; i += 10){ - mikado.data(i).label += " !!!"; - mikado.refresh(i); + data[i].label += " !!!"; + mikado.apply(mikado.node(i), data[i]); } }) .route("clear", () => { mikado.clear() }) -.route("swaprows", () => { mikado.swap(1, 998) }) +.route("swaprows", () => { + const tmp = data[998] + data[998] = data[1]; + data[1] = tmp; + mikado.reconcile(data); +}) .route("remove", target => { mikado.remove(target) }) .route("select", target => { state["selected"].className = ""; diff --git a/frameworks/keyed/mikado/src/template/item.html b/frameworks/keyed/mikado/src/template/item.html index 3991e98bf..1c3d11256 100644 --- a/frameworks/keyed/mikado/src/template/item.html +++ b/frameworks/keyed/mikado/src/template/item.html @@ -1,4 +1,4 @@ - + {{data.id}} {{data.label}} diff --git a/frameworks/keyed/mikado/task/build.js b/frameworks/keyed/mikado/task/build.js index 6e5f10db0..929d26370 100644 --- a/frameworks/keyed/mikado/task/build.js +++ b/frameworks/keyed/mikado/task/build.js @@ -58,7 +58,7 @@ const parameter = (function(opt){ generate_exports: true, export_local_property_definitions: true, language_in: "ECMASCRIPT6_STRICT", - language_out: "ECMASCRIPT5_STRICT", + language_out: "ECMASCRIPT6_STRICT", process_closure_primitives: true, summary_detail_level: 3, warning_level: "VERBOSE", @@ -88,7 +88,7 @@ const parameter = (function(opt){ //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' --js='!src/*config.js'" + flag_str + " --js_output_file='dist/main.js' && exit 0", function(){ +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."); });