Last active
May 31, 2017 08:58
-
-
Save back2dos/d863ab5e0e3310493e900f0f01d20327 to your computer and use it in GitHub Desktop.
TodoMVCoconut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>TodoMVCoconut</title> | |
<meta name="description" content="TodoMVC implementation based on MVCoconut" /> | |
<link rel="stylesheet" type="text/css" href="styles.css"> | |
<link rel="icon" href="https://avatars1.githubusercontent.com/u/25455337?v=3&s=200" type="image/png" /> | |
</head> | |
<body> | |
<script src="todomvc.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ol { | |
border-top: 2px solid #e4e4e4; | |
} | |
.todo-item { | |
display: flex; | |
align-items: center; | |
position: relative; | |
list-style: none; | |
border-bottom: 1px solid #e4e4e4; | |
} | |
.todo-item .description, | |
.todo-item input[name="description"] { | |
flex-grow: 1; | |
padding: 15px; | |
} | |
.todo-item input[name="description"] { | |
font: inherit; | |
border: none; | |
} | |
.todo-item[data-editing] input[name="completed"] { | |
visibility: hidden; | |
} | |
.todo-item[data-completed] .description { | |
text-decoration: line-through; | |
color: #ccc; | |
} | |
.todo-item input[name="completed"] { | |
margin-left: 4px; | |
left: 6px; | |
top: 2px; | |
position: relative; | |
-webkit-appearance: none; | |
-moz-appearance: none; | |
appearance: none; | |
} | |
.todo-item input[name="completed"]:focus { | |
outline: 0; | |
} | |
.todo-item input[name="completed"]:checked:after { | |
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#bddad5" stroke-width="3"/><path fill="#5dc2af" d="M72 25L42 71 27 56l-4 4 20 20 34-52z"/></svg>'); | |
} | |
.todo-item input[name="completed"]:after { | |
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#ededed" stroke-width="3"/></svg>'); | |
} | |
.todo-item:hover button.delete { | |
opacity: .5; | |
} | |
.todo-item:hover button.delete:hover { | |
opacity: 1; | |
} | |
.todo-item button.delete { | |
flex-basis: 60px; | |
align-self: stretch; | |
opacity: 0; | |
border: none; | |
background: none; | |
font-size: 0; | |
} | |
.todo-item button.delete:after { | |
content: "×"; | |
font-size: 30px; | |
color: #af5b5b; | |
} | |
html { | |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
background: #f5f5f5; | |
} | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
button, | |
input[type="checkbox"] { | |
cursor: pointer; | |
} | |
button, | |
input { | |
font: inherit; | |
} | |
.todo-list { | |
font-size: 24px; | |
margin: 200px auto 50px; | |
width: 550px; | |
position: relative; | |
background: white; | |
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1); | |
} | |
.todo-list h1 { | |
position: absolute; | |
top: -150px; | |
color: rgba(175, 91, 94, 0.25); | |
font-size: 100px; | |
font-weight: 100; | |
text-align: center; | |
width: 100%; | |
} | |
.todo-list button:focus { | |
outline: 0; | |
} | |
.todo-list:not([data-empty]):after { | |
content: ' '; | |
position: absolute; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
height: 50px; | |
overflow: hidden; | |
pointer-events: none; | |
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 0 -3px #f6f6f6, 0 9px 1px -3px rgba(0, 0, 0, 0.2), 0 16px 0 -6px #f6f6f6, 0 17px 2px -6px rgba(0, 0, 0, 0.2); | |
} | |
.todo-list footer { | |
font-size: 14px; | |
color: #777; | |
padding: 0 15px; | |
display: flex; | |
align-items: center; | |
height: 45px; | |
justify-content: space-between; | |
position: relative; | |
} | |
.todo-list footer button { | |
color: inherit; | |
font: inherit; | |
background: none; | |
border: none; | |
padding: 3px 7px; | |
} | |
.todo-list footer menu { | |
position: absolute; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
display: flex; | |
pointer-events: none; | |
justify-content: center; | |
align-items: center; | |
} | |
.todo-list footer menu button { | |
pointer-events: all; | |
margin: 0 3px; | |
border: 1px solid transparent; | |
border-radius: 2px; | |
} | |
.todo-list footer menu button:hover { | |
border-color: rgba(175, 91, 91, 0.2); | |
} | |
.todo-list footer menu button[data-active] { | |
border-color: rgba(175, 91, 91, 0.5); | |
} | |
.todo-list footer > button:hover { | |
text-decoration: underline; | |
} | |
.todo-list header { | |
position: relative; | |
} | |
.todo-list header input[type="text"] { | |
width: 100%; | |
padding: 19px; | |
padding-left: 60px; | |
border: none; | |
font: inherit; | |
} | |
.todo-list header input[type="text"]:focus { | |
outline: 0; | |
} | |
.todo-list header input[type="text"]::-webkit-input-placeholder { | |
font-style: italic; | |
font-weight: 300; | |
color: #e6e6e6; | |
} | |
.todo-list header input[type="text"]::-moz-placeholder { | |
font-style: italic; | |
font-weight: 300; | |
color: #e6e6e6; | |
} | |
.todo-list header input[type="text"]::input-placeholder { | |
font-style: italic; | |
font-weight: 300; | |
color: #e6e6e6; | |
} | |
.todo-list header button { | |
position: absolute; | |
background: none; | |
border: 0; | |
font-size: 0; | |
top: 0; | |
left: 0; | |
bottom: 0; | |
width: 62px; | |
} | |
.todo-list header button.mark-all:before { | |
opacity: .5; | |
} | |
.todo-list header button:before { | |
color: #737373; | |
margin: 0 auto; | |
font-size: 22px; | |
content: '❯'; | |
transform: rotate(90deg); | |
display: block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by Haxe 3.4.2 (git build master @ 890f8c7) | |
(function ($global) { "use strict"; | |
var $estr = function() { return js_Boot.__string_rec(this,''); }; | |
function $extend(from, fields) { | |
function Inherit() {} Inherit.prototype = from; var proto = new Inherit(); | |
for (var name in fields) proto[name] = fields[name]; | |
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; | |
return proto; | |
} | |
var HxOverrides = function() { }; | |
HxOverrides.__name__ = true; | |
HxOverrides.cca = function(s,index) { | |
var x = s.charCodeAt(index); | |
if(x != x) { | |
return undefined; | |
} | |
return x; | |
}; | |
HxOverrides.substr = function(s,pos,len) { | |
if(len == null) { | |
len = s.length; | |
} else if(len < 0) { | |
if(pos == 0) { | |
len = s.length + len; | |
} else { | |
return ""; | |
} | |
} | |
return s.substr(pos,len); | |
}; | |
HxOverrides.remove = function(a,obj) { | |
var i = a.indexOf(obj); | |
if(i == -1) { | |
return false; | |
} | |
a.splice(i,1); | |
return true; | |
}; | |
HxOverrides.iter = function(a) { | |
return { cur : 0, arr : a, hasNext : function() { | |
return this.cur < this.arr.length; | |
}, next : function() { | |
return this.arr[this.cur++]; | |
}}; | |
}; | |
var List = function() { | |
this.length = 0; | |
}; | |
List.__name__ = true; | |
List.prototype = { | |
push: function(item) { | |
var x = new _$List_ListNode(item,this.h); | |
this.h = x; | |
if(this.q == null) { | |
this.q = x; | |
} | |
this.length++; | |
} | |
,first: function() { | |
if(this.h == null) { | |
return null; | |
} else { | |
return this.h.item; | |
} | |
} | |
,pop: function() { | |
if(this.h == null) { | |
return null; | |
} | |
var x = this.h.item; | |
this.h = this.h.next; | |
if(this.h == null) { | |
this.q = null; | |
} | |
this.length--; | |
return x; | |
} | |
,__class__: List | |
}; | |
var _$List_ListNode = function(item,next) { | |
this.item = item; | |
this.next = next; | |
}; | |
_$List_ListNode.__name__ = true; | |
_$List_ListNode.prototype = { | |
__class__: _$List_ListNode | |
}; | |
Math.__name__ = true; | |
var Reflect = function() { }; | |
Reflect.__name__ = true; | |
Reflect.field = function(o,field) { | |
try { | |
return o[field]; | |
} catch( e ) { | |
return null; | |
} | |
}; | |
Reflect.fields = function(o) { | |
var a = []; | |
if(o != null) { | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
for( var f in o ) { | |
if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) { | |
a.push(f); | |
} | |
} | |
} | |
return a; | |
}; | |
Reflect.isFunction = function(f) { | |
if(typeof(f) == "function") { | |
return !(f.__name__ || f.__ename__); | |
} else { | |
return false; | |
} | |
}; | |
var StringTools = function() { }; | |
StringTools.__name__ = true; | |
StringTools.isSpace = function(s,pos) { | |
var c = HxOverrides.cca(s,pos); | |
if(!(c > 8 && c < 14)) { | |
return c == 32; | |
} else { | |
return true; | |
} | |
}; | |
StringTools.ltrim = function(s) { | |
var l = s.length; | |
var r = 0; | |
while(r < l && StringTools.isSpace(s,r)) ++r; | |
if(r > 0) { | |
return HxOverrides.substr(s,r,l - r); | |
} else { | |
return s; | |
} | |
}; | |
StringTools.rtrim = function(s) { | |
var l = s.length; | |
var r = 0; | |
while(r < l && StringTools.isSpace(s,l - r - 1)) ++r; | |
if(r > 0) { | |
return HxOverrides.substr(s,0,l - r); | |
} else { | |
return s; | |
} | |
}; | |
StringTools.trim = function(s) { | |
return StringTools.ltrim(StringTools.rtrim(s)); | |
}; | |
var TodoMvc = function() { }; | |
TodoMvc.__name__ = true; | |
TodoMvc.main = function() { | |
window.document.body.appendChild(new todomvc_ui_TodoListView(tink_state__$Observable_Observable_$Impl_$.auto(tink_state__$Observable_Computation_$Impl_$.plain(function() { | |
return { filter : new todomvc_data_TodoFilter(), todos : new todomvc_data_TodoList()}; | |
}))).toElement()); | |
}; | |
var Type = function() { }; | |
Type.__name__ = true; | |
Type.enumEq = function(a,b) { | |
if(a == b) { | |
return true; | |
} | |
try { | |
if(a[0] != b[0]) { | |
return false; | |
} | |
var _g1 = 2; | |
var _g = a.length; | |
while(_g1 < _g) { | |
var i = _g1++; | |
if(!Type.enumEq(a[i],b[i])) { | |
return false; | |
} | |
} | |
var e = a.__enum__; | |
if(e != b.__enum__ || e == null) { | |
return false; | |
} | |
} catch( e1 ) { | |
return false; | |
} | |
return true; | |
}; | |
var coconut_data_Model = function() { }; | |
coconut_data_Model.__name__ = true; | |
var vdom_Widget = function() { | |
this.type = "Widget"; | |
}; | |
vdom_Widget.__name__ = true; | |
vdom_Widget.prototype = { | |
init: function() { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,update: function(prev,elt) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,destroy: function() { | |
} | |
,__class__: vdom_Widget | |
}; | |
var coconut_vdom_Renderable = function(rendered,key) { | |
vdom_Widget.call(this); | |
this.__rendered = rendered; | |
if(key == null) { | |
key = vdom__$Attr_Key_$Impl_$.ofObj(this.__rendered); | |
} | |
this.key = key; | |
}; | |
coconut_vdom_Renderable.__name__ = true; | |
coconut_vdom_Renderable.__super__ = vdom_Widget; | |
coconut_vdom_Renderable.prototype = $extend(vdom_Widget.prototype,{ | |
init: function() { | |
this.__lastRender = tink_state__$Observable_Observable_$Impl_$.get_value(this.__rendered); | |
this.beforeInit(); | |
this.__dom = vdom_VDom.create(this.__lastRender); | |
this.afterInit(this.__dom); | |
this.__setupBinding(); | |
return this.__dom; | |
} | |
,__setupBinding: function() { | |
var _gthis = this; | |
this.__binding = tink_state__$Observable_Observable_$Impl_$.bind(this.__rendered,null,function(next) { | |
if(next != _gthis.__lastRender) { | |
_gthis.__apply(next); | |
} | |
}); | |
} | |
,__apply: function(next) { | |
var changes = vdom_VDom.diff(this.__lastRender,next); | |
this.beforePatching(this.__dom); | |
this.__dom = vdom_VDom.patch(this.__dom,changes); | |
this.__lastRender = next; | |
this.afterPatching(this.__dom); | |
} | |
,toElement: function() { | |
var _g = this.__dom; | |
if(_g == null) { | |
return this.init(); | |
} else { | |
var v = _g; | |
return v; | |
} | |
} | |
,beforeInit: function() { | |
} | |
,afterInit: function(element) { | |
} | |
,beforePatching: function(element) { | |
} | |
,afterPatching: function(element) { | |
} | |
,update: function(x,y) { | |
var _g = (x instanceof coconut_vdom_Renderable) ? x : null; | |
if(_g != null) { | |
var v = _g; | |
this.__reuseRender(v); | |
} | |
return this.toElement(); | |
} | |
,__reuseRender: function(that) { | |
this.__dom = that.__dom; | |
this.__lastRender = that.__lastRender; | |
this.__apply(tink_state__$Observable_Observable_$Impl_$.get_value(this.__rendered)); | |
this.__setupBinding(); | |
that.destroy(); | |
} | |
,destroy: function() { | |
var this1 = this.__binding; | |
if(this1 != null) { | |
this1.dissolve(); | |
} | |
vdom_Widget.prototype.destroy.call(this); | |
} | |
,__class__: coconut_vdom_Renderable | |
}); | |
var coconut_ui_BaseView = function(data,render) { | |
this.__coco__cache = new coconut_ui_tools_ViewCache(); | |
var _gthis = this; | |
coconut_vdom_Renderable.call(this,tink_state__$Observable_Observable_$Impl_$.auto(tink_state__$Observable_Computation_$Impl_$.plain(function() { | |
var f = render; | |
var a1 = data; | |
var tmp = function() { | |
return f(a1); | |
}; | |
return _gthis.__coco__cache.cached(tmp); | |
}))); | |
}; | |
coconut_ui_BaseView.__name__ = true; | |
coconut_ui_BaseView.__super__ = coconut_vdom_Renderable; | |
coconut_ui_BaseView.prototype = $extend(coconut_vdom_Renderable.prototype,{ | |
__class__: coconut_ui_BaseView | |
}); | |
var coconut_ui_View = function(data,render) { | |
coconut_ui_BaseView.call(this,data,render); | |
}; | |
coconut_ui_View.__name__ = true; | |
coconut_ui_View.__super__ = coconut_ui_BaseView; | |
coconut_ui_View.prototype = $extend(coconut_ui_BaseView.prototype,{ | |
__class__: coconut_ui_View | |
}); | |
var tink_core_Noise = { __ename__ : true, __constructs__ : ["Noise"] }; | |
tink_core_Noise.Noise = ["Noise",0]; | |
tink_core_Noise.Noise.toString = $estr; | |
tink_core_Noise.Noise.__enum__ = tink_core_Noise; | |
var tink_core__$Lazy_LazyObject = function() { }; | |
tink_core__$Lazy_LazyObject.__name__ = true; | |
tink_core__$Lazy_LazyObject.prototype = { | |
__class__: tink_core__$Lazy_LazyObject | |
}; | |
var tink_core__$Lazy_LazyConst = function(value) { | |
this.value = value; | |
}; | |
tink_core__$Lazy_LazyConst.__name__ = true; | |
tink_core__$Lazy_LazyConst.__interfaces__ = [tink_core__$Lazy_LazyObject]; | |
tink_core__$Lazy_LazyConst.prototype = { | |
get: function() { | |
return this.value; | |
} | |
,map: function(f) { | |
return new tink_core__$Lazy_LazyConst(f(this.value)); | |
} | |
,__class__: tink_core__$Lazy_LazyConst | |
}; | |
var tink_core__$Future_FutureObject = function() { }; | |
tink_core__$Future_FutureObject.__name__ = true; | |
tink_core__$Future_FutureObject.prototype = { | |
__class__: tink_core__$Future_FutureObject | |
}; | |
var tink_core__$Future_SyncFuture = function(value) { | |
this.value = value; | |
}; | |
tink_core__$Future_SyncFuture.__name__ = true; | |
tink_core__$Future_SyncFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_SyncFuture.prototype = { | |
flatMap: function(f) { | |
var l = this.value.map(f); | |
return new tink_core__$Future_SimpleFuture(function(cb) { | |
return l.get().handle(cb); | |
}); | |
} | |
,handle: function(cb) { | |
cb(this.value.get()); | |
return null; | |
} | |
,gather: function() { | |
return this; | |
} | |
,__class__: tink_core__$Future_SyncFuture | |
}; | |
var coconut_ui_tools_Compare = function() { }; | |
coconut_ui_tools_Compare.__name__ = true; | |
coconut_ui_tools_Compare.stabilize = function(o,comparator) { | |
if(comparator == null) { | |
comparator = Type.enumEq; | |
} | |
return tink_state__$Observable_Observable_$Impl_$.create(function() { | |
var m = tink_state__$Observable_Observable_$Impl_$.measure(o); | |
var check = null; | |
check = function(f) { | |
var ret = f.flatMap(function(_) { | |
var next = tink_state__$Observable_Observable_$Impl_$.measure(o); | |
if(comparator(m.a,next.a)) { | |
return check(next.b); | |
} else { | |
return coconut_ui_tools_Compare.END; | |
} | |
}); | |
return ret.gather(); | |
}; | |
var check1 = check; | |
var this1; | |
var this2 = new tink_core_MPair(m.a,check1(m.b)); | |
this1 = this2; | |
return this1; | |
},{ fileName : "Compare.hx", lineNumber : 16, className : "coconut.ui.tools.Compare", methodName : "stabilize"}); | |
}; | |
coconut_ui_tools_Compare.shallow = function(skipFunctions,old,nu) { | |
if(nu == old) { | |
return true; | |
} | |
var _g = 0; | |
var _g1 = Reflect.fields(nu); | |
while(_g < _g1.length) { | |
var f = _g1[_g]; | |
++_g; | |
var nu1 = Reflect.field(nu,f); | |
var old1 = Reflect.field(old,f); | |
if(skipFunctions && Reflect.isFunction(old1)) { | |
continue; | |
} | |
if(old1 != nu1) { | |
var _g2 = (nu1 instanceof tink_state_ConstObservable) ? nu1 : null; | |
var _g3 = (old1 instanceof tink_state_ConstObservable) ? old1 : null; | |
if(_g3 == null) { | |
return false; | |
} else if(_g2 == null) { | |
return false; | |
} else { | |
var a = _g3; | |
var b = _g2; | |
if(a.m.a != b.m.a) { | |
return false; | |
} | |
} | |
} | |
} | |
return true; | |
}; | |
var coconut_ui_tools__$ViewCache_Stack = function(create) { | |
this.stored = []; | |
this.counter = 0; | |
this.create = create; | |
}; | |
coconut_ui_tools__$ViewCache_Stack.__name__ = true; | |
coconut_ui_tools__$ViewCache_Stack.prototype = { | |
purge: function() { | |
this.stored.splice(this.counter,this.stored.length); | |
this.counter = 0; | |
} | |
,poll: function() { | |
var _g = this.stored[this.counter++]; | |
if(_g == null) { | |
var ret = this.create(); | |
this.stored.push(ret); | |
return ret; | |
} else { | |
var v = _g; | |
return v; | |
} | |
} | |
,__class__: coconut_ui_tools__$ViewCache_Stack | |
}; | |
var coconut_ui_tools__$ViewCache_Factory = function(render) { | |
this.dataByKey = new haxe_ds_ObjectMap(); | |
this.stackByData = new haxe_ds_ObjectMap(); | |
this.render = render; | |
}; | |
coconut_ui_tools__$ViewCache_Factory.__name__ = true; | |
coconut_ui_tools__$ViewCache_Factory.prototype = { | |
forKey: function(key,f) { | |
var _g = this.dataByKey.get(key); | |
if(_g == null) { | |
var this1 = this.dataByKey; | |
var v = f(); | |
this1.set(key,v); | |
return v; | |
} else { | |
var v1 = _g; | |
return v1; | |
} | |
} | |
,purge: function() { | |
var s = this.stackByData.iterator(); | |
while(s.hasNext()) { | |
var s1 = s.next(); | |
s1.purge(); | |
} | |
} | |
,make: function(data) { | |
var stack; | |
var _g = this.stackByData.get(data); | |
if(_g == null) { | |
var this1 = this.stackByData; | |
var f = this.render; | |
var a1 = data; | |
var v = new coconut_ui_tools__$ViewCache_Stack(function() { | |
return f(a1); | |
}); | |
this1.set(data,v); | |
stack = v; | |
} else { | |
var v1 = _g; | |
stack = v1; | |
} | |
return stack.poll(); | |
} | |
,__class__: coconut_ui_tools__$ViewCache_Factory | |
}; | |
var coconut_ui_tools_ViewCache = function() { | |
this.__cache = new haxe_ds_StringMap(); | |
}; | |
coconut_ui_tools_ViewCache.__name__ = true; | |
coconut_ui_tools_ViewCache.prototype = { | |
cached: function(f) { | |
var o = { cache : this}; | |
coconut_ui_tools_ViewCache.stack.push(o); | |
var ret = f(); | |
HxOverrides.remove(coconut_ui_tools_ViewCache.stack,o); | |
this.purge(); | |
return ret; | |
} | |
,purge: function() { | |
var _this = this.__cache; | |
var f = new haxe_ds__$StringMap_StringMapIterator(_this,_this.arrayKeys()); | |
while(f.hasNext()) { | |
var f1 = f.next(); | |
f1.purge(); | |
} | |
} | |
,getFactory: function(cls,make) { | |
var _g = this.__cache.get(cls); | |
var tmp; | |
if(_g == null) { | |
var this1 = this.__cache; | |
var v = new coconut_ui_tools__$ViewCache_Factory(make); | |
this1.set(cls,v); | |
tmp = v; | |
} else { | |
var v1 = _g; | |
tmp = v1; | |
} | |
return tmp; | |
} | |
,__class__: coconut_ui_tools_ViewCache | |
}; | |
var haxe_StackItem = { __ename__ : true, __constructs__ : ["CFunction","Module","FilePos","Method","LocalFunction"] }; | |
haxe_StackItem.CFunction = ["CFunction",0]; | |
haxe_StackItem.CFunction.toString = $estr; | |
haxe_StackItem.CFunction.__enum__ = haxe_StackItem; | |
haxe_StackItem.Module = function(m) { var $x = ["Module",1,m]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; }; | |
haxe_StackItem.FilePos = function(s,file,line) { var $x = ["FilePos",2,s,file,line]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; }; | |
haxe_StackItem.Method = function(classname,method) { var $x = ["Method",3,classname,method]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; }; | |
haxe_StackItem.LocalFunction = function(v) { var $x = ["LocalFunction",4,v]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; }; | |
var haxe_IMap = function() { }; | |
haxe_IMap.__name__ = true; | |
haxe_IMap.prototype = { | |
__class__: haxe_IMap | |
}; | |
var haxe_Timer = function(time_ms) { | |
var me = this; | |
this.id = setInterval(function() { | |
me.run(); | |
},time_ms); | |
}; | |
haxe_Timer.__name__ = true; | |
haxe_Timer.delay = function(f,time_ms) { | |
var t = new haxe_Timer(time_ms); | |
t.run = function() { | |
t.stop(); | |
f(); | |
}; | |
return t; | |
}; | |
haxe_Timer.prototype = { | |
stop: function() { | |
if(this.id == null) { | |
return; | |
} | |
clearInterval(this.id); | |
this.id = null; | |
} | |
,run: function() { | |
} | |
,__class__: haxe_Timer | |
}; | |
var haxe_ds_ObjectMap = function() { | |
this.h = { __keys__ : { }}; | |
}; | |
haxe_ds_ObjectMap.__name__ = true; | |
haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap]; | |
haxe_ds_ObjectMap.prototype = { | |
set: function(key,value) { | |
var id = key.__id__ || (key.__id__ = ++haxe_ds_ObjectMap.count); | |
this.h[id] = value; | |
this.h.__keys__[id] = key; | |
} | |
,get: function(key) { | |
return this.h[key.__id__]; | |
} | |
,keys: function() { | |
var a = []; | |
for( var key in this.h.__keys__ ) { | |
if(this.h.hasOwnProperty(key)) { | |
a.push(this.h.__keys__[key]); | |
} | |
} | |
return HxOverrides.iter(a); | |
} | |
,iterator: function() { | |
return { ref : this.h, it : this.keys(), hasNext : function() { | |
return this.it.hasNext(); | |
}, next : function() { | |
var i = this.it.next(); | |
return this.ref[i.__id__]; | |
}}; | |
} | |
,__class__: haxe_ds_ObjectMap | |
}; | |
var haxe_ds__$StringMap_StringMapIterator = function(map,keys) { | |
this.map = map; | |
this.keys = keys; | |
this.index = 0; | |
this.count = keys.length; | |
}; | |
haxe_ds__$StringMap_StringMapIterator.__name__ = true; | |
haxe_ds__$StringMap_StringMapIterator.prototype = { | |
hasNext: function() { | |
return this.index < this.count; | |
} | |
,next: function() { | |
var _this = this.map; | |
var key = this.keys[this.index++]; | |
if(__map_reserved[key] != null) { | |
return _this.getReserved(key); | |
} else { | |
return _this.h[key]; | |
} | |
} | |
,__class__: haxe_ds__$StringMap_StringMapIterator | |
}; | |
var haxe_ds_StringMap = function() { | |
this.h = { }; | |
}; | |
haxe_ds_StringMap.__name__ = true; | |
haxe_ds_StringMap.__interfaces__ = [haxe_IMap]; | |
haxe_ds_StringMap.prototype = { | |
set: function(key,value) { | |
if(__map_reserved[key] != null) { | |
this.setReserved(key,value); | |
} else { | |
this.h[key] = value; | |
} | |
} | |
,get: function(key) { | |
if(__map_reserved[key] != null) { | |
return this.getReserved(key); | |
} | |
return this.h[key]; | |
} | |
,setReserved: function(key,value) { | |
if(this.rh == null) { | |
this.rh = { }; | |
} | |
this.rh["$" + key] = value; | |
} | |
,getReserved: function(key) { | |
if(this.rh == null) { | |
return null; | |
} else { | |
return this.rh["$" + key]; | |
} | |
} | |
,arrayKeys: function() { | |
var out = []; | |
for( var key in this.h ) { | |
if(this.h.hasOwnProperty(key)) { | |
out.push(key); | |
} | |
} | |
if(this.rh != null) { | |
for( var key in this.rh ) { | |
if(key.charCodeAt(0) == 36) { | |
out.push(key.substr(1)); | |
} | |
} | |
} | |
return out; | |
} | |
,__class__: haxe_ds_StringMap | |
}; | |
var js__$Boot_HaxeError = function(val) { | |
Error.call(this); | |
this.val = val; | |
this.message = String(val); | |
if(Error.captureStackTrace) { | |
Error.captureStackTrace(this,js__$Boot_HaxeError); | |
} | |
}; | |
js__$Boot_HaxeError.__name__ = true; | |
js__$Boot_HaxeError.wrap = function(val) { | |
if((val instanceof Error)) { | |
return val; | |
} else { | |
return new js__$Boot_HaxeError(val); | |
} | |
}; | |
js__$Boot_HaxeError.__super__ = Error; | |
js__$Boot_HaxeError.prototype = $extend(Error.prototype,{ | |
__class__: js__$Boot_HaxeError | |
}); | |
var js_Boot = function() { }; | |
js_Boot.__name__ = true; | |
js_Boot.getClass = function(o) { | |
if((o instanceof Array) && o.__enum__ == null) { | |
return Array; | |
} else { | |
var cl = o.__class__; | |
if(cl != null) { | |
return cl; | |
} | |
var name = js_Boot.__nativeClassName(o); | |
if(name != null) { | |
return js_Boot.__resolveNativeClass(name); | |
} | |
return null; | |
} | |
}; | |
js_Boot.__interfLoop = function(cc,cl) { | |
if(cc == null) { | |
return false; | |
} | |
if(cc == cl) { | |
return true; | |
} | |
var intf = cc.__interfaces__; | |
if(intf != null) { | |
var _g1 = 0; | |
var _g = intf.length; | |
while(_g1 < _g) { | |
var i = _g1++; | |
var i1 = intf[i]; | |
if(i1 == cl || js_Boot.__interfLoop(i1,cl)) { | |
return true; | |
} | |
} | |
} | |
return js_Boot.__interfLoop(cc.__super__,cl); | |
}; | |
js_Boot.__instanceof = function(o,cl) { | |
if(cl == null) { | |
return false; | |
} | |
switch(cl) { | |
case Array: | |
if((o instanceof Array)) { | |
return o.__enum__ == null; | |
} else { | |
return false; | |
} | |
break; | |
case Bool: | |
return typeof(o) == "boolean"; | |
case Dynamic: | |
return true; | |
case Float: | |
return typeof(o) == "number"; | |
case Int: | |
if(typeof(o) == "number") { | |
return (o|0) === o; | |
} else { | |
return false; | |
} | |
break; | |
case String: | |
return typeof(o) == "string"; | |
default: | |
if(o != null) { | |
if(typeof(cl) == "function") { | |
if(o instanceof cl) { | |
return true; | |
} | |
if(js_Boot.__interfLoop(js_Boot.getClass(o),cl)) { | |
return true; | |
} | |
} else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) { | |
if(o instanceof cl) { | |
return true; | |
} | |
} | |
} else { | |
return false; | |
} | |
if(cl == Class ? o.__name__ != null : false) { | |
return true; | |
} | |
if(cl == Enum ? o.__ename__ != null : false) { | |
return true; | |
} | |
return o.__enum__ == cl; | |
} | |
}; | |
js_Boot.__nativeClassName = function(o) { | |
var name = js_Boot.__toStr.call(o).slice(8,-1); | |
if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") { | |
return null; | |
} | |
return name; | |
}; | |
js_Boot.__isNativeObj = function(o) { | |
return js_Boot.__nativeClassName(o) != null; | |
}; | |
js_Boot.__resolveNativeClass = function(name) { | |
return $global[name]; | |
}; | |
var tink_core__$Callback_Callback_$Impl_$ = {}; | |
tink_core__$Callback_Callback_$Impl_$.__name__ = true; | |
tink_core__$Callback_Callback_$Impl_$.fromNiladic = function(f) { | |
var this1 = function(r) { | |
f(); | |
}; | |
return this1; | |
}; | |
tink_core__$Callback_Callback_$Impl_$.defer = function(f) { | |
haxe_Timer.delay(f,0); | |
}; | |
var tink_core__$Callback_LinkObject = function() { }; | |
tink_core__$Callback_LinkObject.__name__ = true; | |
tink_core__$Callback_LinkObject.prototype = { | |
__class__: tink_core__$Callback_LinkObject | |
}; | |
var tink_core__$Callback_SimpleLink = function(f) { | |
this.f = f; | |
}; | |
tink_core__$Callback_SimpleLink.__name__ = true; | |
tink_core__$Callback_SimpleLink.__interfaces__ = [tink_core__$Callback_LinkObject]; | |
tink_core__$Callback_SimpleLink.prototype = { | |
dissolve: function() { | |
if(this.f != null) { | |
this.f(); | |
} | |
} | |
,__class__: tink_core__$Callback_SimpleLink | |
}; | |
var tink_core__$Callback_ListCell = function(cb,list) { | |
if(cb == null) { | |
throw new js__$Boot_HaxeError("callback expected but null received"); | |
} | |
this.cb = cb; | |
this.list = list; | |
}; | |
tink_core__$Callback_ListCell.__name__ = true; | |
tink_core__$Callback_ListCell.__interfaces__ = [tink_core__$Callback_LinkObject]; | |
tink_core__$Callback_ListCell.prototype = { | |
clear: function() { | |
this.list = null; | |
this.cb = null; | |
} | |
,dissolve: function() { | |
var _g = this.list; | |
if(_g != null) { | |
var v = _g; | |
this.clear(); | |
HxOverrides.remove(v,this); | |
} | |
} | |
,__class__: tink_core__$Callback_ListCell | |
}; | |
var tink_core__$Callback_CallbackList_$Impl_$ = {}; | |
tink_core__$Callback_CallbackList_$Impl_$.__name__ = true; | |
tink_core__$Callback_CallbackList_$Impl_$.add = function(this1,cb) { | |
var node = new tink_core__$Callback_ListCell(cb,this1); | |
this1.push(node); | |
return node; | |
}; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke = function(this1,data) { | |
var _g = 0; | |
var _g1 = this1.slice(); | |
while(_g < _g1.length) { | |
var cell = _g1[_g]; | |
++_g; | |
if(cell.cb != null) { | |
cell.cb(data); | |
} | |
} | |
}; | |
tink_core__$Callback_CallbackList_$Impl_$.clear = function(this1) { | |
var _g = 0; | |
var _g1 = this1.splice(0,this1.length); | |
while(_g < _g1.length) { | |
var cell = _g1[_g]; | |
++_g; | |
cell.clear(); | |
} | |
}; | |
var tink_core_TypedError = function(code,message,pos) { | |
if(code == null) { | |
code = 500; | |
} | |
this.code = code; | |
this.message = message; | |
this.pos = pos; | |
this.exceptionStack = []; | |
this.callStack = []; | |
}; | |
tink_core_TypedError.__name__ = true; | |
tink_core_TypedError.withData = function(code,message,data,pos) { | |
return tink_core_TypedError.typed(code,message,data,pos); | |
}; | |
tink_core_TypedError.typed = function(code,message,data,pos) { | |
var ret = new tink_core_TypedError(code,message,pos); | |
ret.data = data; | |
return ret; | |
}; | |
tink_core_TypedError.catchExceptions = function(f,report,pos) { | |
try { | |
return tink_core_Outcome.Success(f()); | |
} catch( $e0 ) { | |
if ($e0 instanceof js__$Boot_HaxeError) $e0 = $e0.val; | |
if( js_Boot.__instanceof($e0,tink_core_TypedError) ) { | |
var e = $e0; | |
return tink_core_Outcome.Failure(e); | |
} else { | |
var e1 = $e0; | |
return tink_core_Outcome.Failure(report == null ? tink_core_TypedError.withData(null,"Unexpected Error",e1,pos) : report(e1)); | |
} | |
} | |
}; | |
tink_core_TypedError.reporter = function(code,message,pos) { | |
return function(e) { | |
return tink_core_TypedError.withData(code,message,e,pos); | |
}; | |
}; | |
tink_core_TypedError.rethrow = function(any) { | |
throw js__$Boot_HaxeError.wrap(any); | |
}; | |
tink_core_TypedError.prototype = { | |
printPos: function() { | |
return this.pos.className + "." + this.pos.methodName + ":" + this.pos.lineNumber; | |
} | |
,toString: function() { | |
var ret = "Error#" + this.code + ": " + this.message; | |
if(this.pos != null) { | |
ret += " @ " + this.printPos(); | |
} | |
return ret; | |
} | |
,throwSelf: function() { | |
throw new js__$Boot_HaxeError(this); | |
} | |
,__class__: tink_core_TypedError | |
}; | |
var tink_core__$Future_Future_$Impl_$ = {}; | |
tink_core__$Future_Future_$Impl_$.__name__ = true; | |
tink_core__$Future_Future_$Impl_$.flatten = function(f) { | |
return new tink_core__$Future_NestedFuture(f); | |
}; | |
var tink_core__$Future_SimpleFuture = function(f) { | |
this.f = f; | |
}; | |
tink_core__$Future_SimpleFuture.__name__ = true; | |
tink_core__$Future_SimpleFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_SimpleFuture.prototype = { | |
handle: function(callback) { | |
return this.f(callback); | |
} | |
,flatMap: function(f) { | |
var f1 = f; | |
var _gthis = this; | |
return tink_core__$Future_Future_$Impl_$.flatten(new tink_core__$Future_SimpleFuture(function(cb) { | |
return _gthis.f(function(v) { | |
var data = f1(v); | |
cb(data); | |
}); | |
})); | |
} | |
,gather: function() { | |
return tink_core_FutureTrigger.gatherFuture(this); | |
} | |
,__class__: tink_core__$Future_SimpleFuture | |
}; | |
var tink_core__$Future_NestedFuture = function(outer) { | |
this.outer = outer; | |
}; | |
tink_core__$Future_NestedFuture.__name__ = true; | |
tink_core__$Future_NestedFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_NestedFuture.prototype = { | |
flatMap: function(f) { | |
var ret = this.outer.flatMap(function(inner) { | |
var ret1 = inner.flatMap(f); | |
return ret1.gather(); | |
}); | |
return ret.gather(); | |
} | |
,gather: function() { | |
return tink_core_FutureTrigger.gatherFuture(this); | |
} | |
,handle: function(cb) { | |
var ret = null; | |
ret = this.outer.handle(function(inner) { | |
ret = inner.handle(function(result) { | |
cb(result); | |
}); | |
}); | |
return ret; | |
} | |
,__class__: tink_core__$Future_NestedFuture | |
}; | |
var tink_core_FutureTrigger = function() { | |
var this1 = []; | |
this.list = this1; | |
}; | |
tink_core_FutureTrigger.__name__ = true; | |
tink_core_FutureTrigger.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core_FutureTrigger.gatherFuture = function(f) { | |
var op = null; | |
var this1 = new tink_core__$Future_SimpleFuture(function(cb) { | |
if(op == null) { | |
op = new tink_core_FutureTrigger(); | |
f.handle($bind(op,op.trigger)); | |
f = null; | |
} | |
return op.handle(cb); | |
}); | |
return this1; | |
}; | |
tink_core_FutureTrigger.prototype = { | |
handle: function(callback) { | |
var _g = this.list; | |
if(_g == null) { | |
callback(this.result); | |
return null; | |
} else { | |
var v = _g; | |
return tink_core__$Callback_CallbackList_$Impl_$.add(v,callback); | |
} | |
} | |
,flatMap: function(f) { | |
var _g = this.list; | |
if(_g == null) { | |
return f(this.result); | |
} else { | |
var v = _g; | |
var ret = new tink_core_FutureTrigger(); | |
tink_core__$Callback_CallbackList_$Impl_$.add(this.list,function(v1) { | |
f(v1).handle($bind(ret,ret.trigger)); | |
}); | |
return ret; | |
} | |
} | |
,gather: function() { | |
return this; | |
} | |
,trigger: function(result) { | |
if(this.list == null) { | |
return false; | |
} else { | |
var list = this.list; | |
this.list = null; | |
this.result = result; | |
if(tink_core_FutureTrigger.depth >= 1000) { | |
tink_core__$Callback_Callback_$Impl_$.defer(function() { | |
tink_core_FutureTrigger.depth++; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(list,result); | |
tink_core__$Callback_CallbackList_$Impl_$.clear(list); | |
tink_core_FutureTrigger.depth--; | |
}); | |
} else { | |
tink_core_FutureTrigger.depth++; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(list,result); | |
tink_core__$Callback_CallbackList_$Impl_$.clear(list); | |
tink_core_FutureTrigger.depth--; | |
} | |
return true; | |
} | |
} | |
,__class__: tink_core_FutureTrigger | |
}; | |
var tink_core_NamedWith = function(name,value) { | |
this.name = name; | |
this.value = value; | |
}; | |
tink_core_NamedWith.__name__ = true; | |
tink_core_NamedWith.prototype = { | |
__class__: tink_core_NamedWith | |
}; | |
var tink_core_Outcome = { __ename__ : true, __constructs__ : ["Success","Failure"] }; | |
tink_core_Outcome.Success = function(data) { var $x = ["Success",0,data]; $x.__enum__ = tink_core_Outcome; $x.toString = $estr; return $x; }; | |
tink_core_Outcome.Failure = function(failure) { var $x = ["Failure",1,failure]; $x.__enum__ = tink_core_Outcome; $x.toString = $estr; return $x; }; | |
var tink_core_MPair = function(a,b) { | |
this.a = a; | |
this.b = b; | |
}; | |
tink_core_MPair.__name__ = true; | |
tink_core_MPair.prototype = { | |
__class__: tink_core_MPair | |
}; | |
var tink_core__$Promise_Promise_$Impl_$ = {}; | |
tink_core__$Promise_Promise_$Impl_$.__name__ = true; | |
tink_core__$Promise_Promise_$Impl_$.ofOutcome = function(o) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(o)); | |
}; | |
var tink_pure__$List_List_$Impl_$ = {}; | |
tink_pure__$List_List_$Impl_$.__name__ = true; | |
tink_pure__$List_List_$Impl_$.prepend = function(this1,value) { | |
if(this1 == null) { | |
return new tink_pure__$List_Node(1,value); | |
} else { | |
return new tink_pure__$List_Node(this1.length + 1,value,[this1]); | |
} | |
}; | |
tink_pure__$List_List_$Impl_$.filter = function(this1,f) { | |
if(this1 == null) { | |
return null; | |
} else { | |
return this1.filter(f); | |
} | |
}; | |
tink_pure__$List_List_$Impl_$.fromArray = function(i) { | |
var ret = null; | |
var len = 0; | |
var pos = i.length; | |
while(pos-- > 0) ret = new tink_pure__$List_Node(++len,i[pos],ret == null ? tink_pure__$List_Node.EMPTY : [ret]); | |
return ret; | |
}; | |
var tink_pure__$List_Node = function(length,value,tails) { | |
this.value = value; | |
this.length = length; | |
this.tails = tails == null ? tink_pure__$List_Node.EMPTY : tails; | |
var _g = 0; | |
var _g1 = this.tails; | |
while(_g < _g1.length) { | |
var x = _g1[_g]; | |
++_g; | |
if(x == null) { | |
throw new js__$Boot_HaxeError("whaaaaa?"); | |
} | |
} | |
}; | |
tink_pure__$List_Node.__name__ = true; | |
tink_pure__$List_Node.prototype = { | |
filter: function(f) { | |
var iter = new tink_pure_NodeIterator(this); | |
var ret = []; | |
while(iter.list.length > 0) { | |
var next = iter.list.pop(); | |
var _g = -next.tails.length; | |
while(_g < 0) { | |
var i = _g++; | |
iter.list.push(next.tails[-i - 1]); | |
} | |
var value = next.value; | |
var res = f(value); | |
if(res > 0) { | |
ret.push(value); | |
} | |
if((res & 3) == 3) { | |
break; | |
} | |
} | |
return tink_pure__$List_List_$Impl_$.fromArray(ret); | |
} | |
,__class__: tink_pure__$List_Node | |
}; | |
var tink_pure_NodeIterator = function(node) { | |
this.list = []; | |
if(node != null) { | |
this.list.push(node); | |
} | |
}; | |
tink_pure_NodeIterator.__name__ = true; | |
tink_pure_NodeIterator.prototype = { | |
hasNext: function() { | |
return this.list.length > 0; | |
} | |
,next: function() { | |
var next = this.list.pop(); | |
var _g = -next.tails.length; | |
while(_g < 0) { | |
var i = _g++; | |
this.list.push(next.tails[-i - 1]); | |
} | |
return next.value; | |
} | |
,__class__: tink_pure_NodeIterator | |
}; | |
var tink_state__$Observable_Observable_$Impl_$ = {}; | |
tink_state__$Observable_Observable_$Impl_$.__name__ = true; | |
tink_state__$Observable_Observable_$Impl_$.get_value = function(this1) { | |
return tink_state__$Observable_Observable_$Impl_$.measure(this1).a; | |
}; | |
tink_state__$Observable_Observable_$Impl_$.measure = function(this1) { | |
var before = tink_state__$Observable_Observable_$Impl_$.stack.first(); | |
tink_state__$Observable_Observable_$Impl_$.stack.push(this1); | |
var p = this1.poll(); | |
var _g = (before instanceof tink_state__$Observable_AutoObservable) ? before : null; | |
if(_g != null) { | |
var v = _g; | |
p.b.handle(tink_core__$Callback_Callback_$Impl_$.fromNiladic($bind(v,v.invalidate))); | |
} | |
tink_state__$Observable_Observable_$Impl_$.stack.pop(); | |
return p; | |
}; | |
tink_state__$Observable_Observable_$Impl_$.bind = function(this1,options,cb) { | |
if(options == null) { | |
var scheduled = false; | |
var active = true; | |
var updated = null; | |
var link = null; | |
var update = function() { | |
if(active) { | |
var next = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
cb(next.a); | |
scheduled = false; | |
link = next.b.handle(updated); | |
} | |
}; | |
var doSchedule = function() { | |
if(scheduled) { | |
return; | |
} | |
scheduled = true; | |
tink_state__$Observable_Observable_$Impl_$.schedule(update); | |
}; | |
updated = tink_core__$Callback_Callback_$Impl_$.fromNiladic(doSchedule); | |
doSchedule(); | |
var this2 = new tink_core__$Callback_SimpleLink(function() { | |
if(active) { | |
active = false; | |
if(link != null) { | |
link.dissolve(); | |
} | |
} | |
}); | |
return this2; | |
} else if(options.direct == null) { | |
var scheduled1 = false; | |
var active1 = true; | |
var updated1 = null; | |
var link1 = null; | |
var update1 = function() { | |
if(active1) { | |
var next1 = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
cb(next1.a); | |
scheduled1 = false; | |
link1 = next1.b.handle(updated1); | |
} | |
}; | |
var doSchedule1 = function() { | |
if(scheduled1) { | |
return; | |
} | |
scheduled1 = true; | |
tink_state__$Observable_Observable_$Impl_$.schedule(update1); | |
}; | |
updated1 = tink_core__$Callback_Callback_$Impl_$.fromNiladic(doSchedule1); | |
doSchedule1(); | |
var this3 = new tink_core__$Callback_SimpleLink(function() { | |
if(active1) { | |
active1 = false; | |
if(link1 != null) { | |
link1.dissolve(); | |
} | |
} | |
}); | |
return this3; | |
} else if(options.direct == false) { | |
var scheduled2 = false; | |
var active2 = true; | |
var updated2 = null; | |
var link2 = null; | |
var update2 = function() { | |
if(active2) { | |
var next2 = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
cb(next2.a); | |
scheduled2 = false; | |
link2 = next2.b.handle(updated2); | |
} | |
}; | |
var doSchedule2 = function() { | |
if(scheduled2) { | |
return; | |
} | |
scheduled2 = true; | |
tink_state__$Observable_Observable_$Impl_$.schedule(update2); | |
}; | |
updated2 = tink_core__$Callback_Callback_$Impl_$.fromNiladic(doSchedule2); | |
doSchedule2(); | |
var this4 = new tink_core__$Callback_SimpleLink(function() { | |
if(active2) { | |
active2 = false; | |
if(link2 != null) { | |
link2.dissolve(); | |
} | |
} | |
}); | |
return this4; | |
} else { | |
var link3 = null; | |
var update3 = null; | |
update3 = function(_) { | |
var next3 = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
cb(next3.a); | |
link3 = next3.b.handle(update3); | |
}; | |
var update4 = update3; | |
update4(tink_core_Noise.Noise); | |
var this5 = new tink_core__$Callback_SimpleLink(function() { | |
if(link3 != null) { | |
link3.dissolve(); | |
} | |
}); | |
return this5; | |
} | |
}; | |
tink_state__$Observable_Observable_$Impl_$.schedule = function(f) { | |
var _g = tink_state__$Observable_Observable_$Impl_$.scheduled; | |
if(_g == null) { | |
f(); | |
} else if(_g.length == 0) { | |
tink_state__$Observable_Observable_$Impl_$.scheduled.push(f); | |
if(tink_state__$Observable_Observable_$Impl_$.hasRAF) { | |
window.requestAnimationFrame(function(_) { | |
tink_state__$Observable_Observable_$Impl_$.updateAll(); | |
}); | |
} else { | |
tink_core__$Callback_Callback_$Impl_$.defer(f); | |
} | |
} else { | |
var v = _g; | |
v.push(f); | |
} | |
}; | |
tink_state__$Observable_Observable_$Impl_$.updateAll = function() { | |
if(tink_state__$Observable_Observable_$Impl_$.scheduled == null) { | |
return; | |
} | |
var old = tink_state__$Observable_Observable_$Impl_$.scheduled; | |
tink_state__$Observable_Observable_$Impl_$.scheduled = null; | |
var _g = 0; | |
while(_g < old.length) { | |
var o = old[_g]; | |
++_g; | |
o(); | |
} | |
tink_state__$Observable_Observable_$Impl_$.scheduled = []; | |
}; | |
tink_state__$Observable_Observable_$Impl_$.create = function(f,pos) { | |
return new tink_state__$Observable_SimpleObservable(f,pos); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.auto = function(f) { | |
return new tink_state__$Observable_AutoObservable(f); | |
}; | |
tink_state__$Observable_Observable_$Impl_$["const"] = function(value) { | |
return new tink_state_ConstObservable(value); | |
}; | |
var tink_state__$Observable_Computation_$Impl_$ = {}; | |
tink_state__$Observable_Computation_$Impl_$.__name__ = true; | |
tink_state__$Observable_Computation_$Impl_$.plain = function(f) { | |
var this1 = { f : f}; | |
return this1; | |
}; | |
var tink_state_ObservableObject = function() { }; | |
tink_state_ObservableObject.__name__ = true; | |
tink_state_ObservableObject.prototype = { | |
__class__: tink_state_ObservableObject | |
}; | |
var tink_state__$Observable_SimpleObservable = function(f,pos) { | |
this._poll = f; | |
this.pos = pos; | |
}; | |
tink_state__$Observable_SimpleObservable.__name__ = true; | |
tink_state__$Observable_SimpleObservable.__interfaces__ = [tink_state_ObservableObject]; | |
tink_state__$Observable_SimpleObservable.prototype = { | |
resetCache: function(_) { | |
this.cache = null; | |
} | |
,poll: function() { | |
var count = 0; | |
var last = null; | |
while(this.cache == null) { | |
var cache = this.cache = this._poll(); | |
if(last == cache) { | |
throw new js__$Boot_HaxeError("Polling loops on the same value"); | |
} | |
last = cache; | |
cache.b.handle($bind(this,this.resetCache)); | |
if(count++ >= 100) { | |
throw new js__$Boot_HaxeError("Polling not concluded after 100 iterations"); | |
} | |
} | |
return this.cache; | |
} | |
,__class__: tink_state__$Observable_SimpleObservable | |
}; | |
var tink_state_ConstObservable = function(value) { | |
var this1; | |
var this2 = new tink_core_MPair(value,tink_state_ConstObservable.NEVER); | |
this1 = this2; | |
this.m = this1; | |
}; | |
tink_state_ConstObservable.__name__ = true; | |
tink_state_ConstObservable.__interfaces__ = [tink_state_ObservableObject]; | |
tink_state_ConstObservable.prototype = { | |
poll: function() { | |
return this.m; | |
} | |
,__class__: tink_state_ConstObservable | |
}; | |
var tink_state__$Observable_AutoObservable = function(comp) { | |
var _gthis = this; | |
tink_state__$Observable_SimpleObservable.call(this,function() { | |
_gthis.trigger = new tink_core_FutureTrigger(); | |
var this1; | |
var this2 = new tink_core_MPair(comp.f(),_gthis.trigger); | |
this1 = this2; | |
return this1; | |
},{ fileName : "Observable.hx", lineNumber : 331, className : "tink.state._Observable.AutoObservable", methodName : "new"}); | |
}; | |
tink_state__$Observable_AutoObservable.__name__ = true; | |
tink_state__$Observable_AutoObservable.__super__ = tink_state__$Observable_SimpleObservable; | |
tink_state__$Observable_AutoObservable.prototype = $extend(tink_state__$Observable_SimpleObservable.prototype,{ | |
invalidate: function() { | |
this.trigger.trigger(tink_core_Noise.Noise); | |
} | |
,__class__: tink_state__$Observable_AutoObservable | |
}); | |
var tink_state__$State_State_$Impl_$ = {}; | |
tink_state__$State_State_$Impl_$.__name__ = true; | |
tink_state__$State_State_$Impl_$.get_value = function(this1) { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(tink_state__$State_State_$Impl_$.observe(this1)); | |
}; | |
tink_state__$State_State_$Impl_$.observe = function(this1) { | |
return this1; | |
}; | |
tink_state__$State_State_$Impl_$.ofConstant = function(value) { | |
var this1 = new tink_state__$State_StateObject(value); | |
return this1; | |
}; | |
var tink_state__$State_StateObject = function(value) { | |
this.value = value; | |
this.arm(); | |
}; | |
tink_state__$State_StateObject.__name__ = true; | |
tink_state__$State_StateObject.__interfaces__ = [tink_state_ObservableObject]; | |
tink_state__$State_StateObject.prototype = { | |
poll: function() { | |
return this.next; | |
} | |
,arm: function() { | |
this.trigger = new tink_core_FutureTrigger(); | |
var this1; | |
var this2 = new tink_core_MPair(this.value,this.trigger); | |
this1 = this2; | |
this.next = this1; | |
} | |
,set: function(value) { | |
if(value != this.value) { | |
this.value = value; | |
var last = this.trigger; | |
this.arm(); | |
last.trigger(tink_core_Noise.Noise); | |
} | |
} | |
,__class__: tink_state__$State_StateObject | |
}; | |
var todomvc_data_TodoFilter = function(initial) { | |
if(initial == null) { | |
initial = { }; | |
} | |
this.options = tink_pure__$List_List_$Impl_$.fromArray([new tink_core_NamedWith("All",function(_) { | |
return true; | |
}),new tink_core_NamedWith("Active",todomvc_data_TodoItem.isActive),new tink_core_NamedWith("Completed",todomvc_data_TodoItem.isCompleted)]); | |
var _this = new tink_pure_NodeIterator(this.get_options()); | |
var next = _this.list.pop(); | |
var _g = -next.tails.length; | |
while(_g < 0) { | |
var i = _g++; | |
_this.list.push(next.tails[-i - 1]); | |
} | |
this.__coco_currentFilter = tink_state__$State_State_$Impl_$.ofConstant(next.value.value); | |
this.observables = { options : tink_state__$Observable_Observable_$Impl_$["const"](this.get_options()), currentFilter : this.__coco_currentFilter}; | |
}; | |
todomvc_data_TodoFilter.__name__ = true; | |
todomvc_data_TodoFilter.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoFilter.prototype = { | |
matches: function(item) { | |
return (this.get_currentFilter())(item); | |
} | |
,toggle: function(filter) { | |
var _gthis = this; | |
var ret = (function() { | |
var _g = new tink_pure_NodeIterator(_gthis.get_options()); | |
while(_g.list.length > 0) { | |
var next = _g.list.pop(); | |
var _g1 = -next.tails.length; | |
while(_g1 < 0) { | |
var i = _g1++; | |
_g.list.push(next.tails[-i - 1]); | |
} | |
var o = next.value; | |
if(o.value == filter) { | |
return tink_core__$Promise_Promise_$Impl_$.ofOutcome(tink_core_Outcome.Success({ currentFilter : filter})); | |
} | |
} | |
return tink_core__$Promise_Promise_$Impl_$.ofOutcome(tink_core_Outcome.Success({ })); | |
})(); | |
ret.handle(function(o1) { | |
if(o1[1] == 0) { | |
var v = o1[2]; | |
_gthis.__cocoupdate(v); | |
} | |
}); | |
return ret; | |
} | |
,isActive: function(filter) { | |
return filter == this.get_currentFilter(); | |
} | |
,get_options: function() { | |
return this.options; | |
} | |
,get_currentFilter: function() { | |
return tink_state__$State_State_$Impl_$.get_value(this.__coco_currentFilter); | |
} | |
,__cocoupdate: function(delta) { | |
var this1 = { }; | |
var sparse = this1; | |
var delta1 = delta; | |
var _g = 0; | |
var _g1 = Reflect.fields(delta1); | |
while(_g < _g1.length) { | |
var k = _g1[_g]; | |
++_g; | |
var this2; | |
var this3 = new Array(1); | |
this2 = this3; | |
var ret = this2; | |
ret[0] = delta1[k]; | |
sparse[k] = ret; | |
} | |
var delta2 = sparse; | |
if(delta2.currentFilter != null) { | |
this.__coco_currentFilter.set(delta2.currentFilter[0]); | |
} | |
} | |
,__class__: todomvc_data_TodoFilter | |
}; | |
var todomvc_data_TodoItem = function(initial) { | |
var _g = initial.completed; | |
var tmp; | |
if(_g == null) { | |
tmp = tink_state__$State_State_$Impl_$.ofConstant(false); | |
} else { | |
var v = _g; | |
tmp = tink_state__$State_State_$Impl_$.ofConstant(v); | |
} | |
this.__coco_completed = tmp; | |
this.__coco_description = tink_state__$State_State_$Impl_$.ofConstant(initial.description); | |
var _g1 = initial.created; | |
var tmp1; | |
if(_g1 == null) { | |
tmp1 = new Date(); | |
} else { | |
var v1 = _g1; | |
tmp1 = v1; | |
} | |
this.created = tmp1; | |
this.observables = { completed : this.__coco_completed, description : this.__coco_description, created : tink_state__$Observable_Observable_$Impl_$["const"](this.get_created())}; | |
}; | |
todomvc_data_TodoItem.__name__ = true; | |
todomvc_data_TodoItem.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoItem.create = function(description) { | |
return new todomvc_data_TodoItem({ description : description}); | |
}; | |
todomvc_data_TodoItem.isActive = function(item) { | |
return !item.get_completed(); | |
}; | |
todomvc_data_TodoItem.isCompleted = function(item) { | |
return item.get_completed(); | |
}; | |
todomvc_data_TodoItem.prototype = { | |
get_completed: function() { | |
return tink_state__$State_State_$Impl_$.get_value(this.__coco_completed); | |
} | |
,set_completed: function(param) { | |
this.__coco_completed.set(param); | |
return param; | |
} | |
,get_description: function() { | |
return tink_state__$State_State_$Impl_$.get_value(this.__coco_description); | |
} | |
,set_description: function(param) { | |
this.__coco_description.set(param); | |
return param; | |
} | |
,get_created: function() { | |
return this.created; | |
} | |
,__class__: todomvc_data_TodoItem | |
}; | |
var todomvc_data_TodoList = function(initial) { | |
if(initial == null) { | |
initial = { }; | |
} | |
var _g = initial.items; | |
var tmp; | |
if(_g == null) { | |
tmp = tink_state__$State_State_$Impl_$.ofConstant(null); | |
} else { | |
var v = _g; | |
tmp = tink_state__$State_State_$Impl_$.ofConstant(v); | |
} | |
this.__coco_items = tmp; | |
this.observables = { items : this.__coco_items}; | |
}; | |
todomvc_data_TodoList.__name__ = true; | |
todomvc_data_TodoList.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoList.prototype = { | |
add: function(description) { | |
var _gthis = this; | |
var ret = tink_core__$Promise_Promise_$Impl_$.ofOutcome(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.prepend(_gthis.get_items(),todomvc_data_TodoItem.create(description))})); | |
ret.handle(function(o) { | |
if(o[1] == 0) { | |
var v = o[2]; | |
_gthis.__cocoupdate(v); | |
} | |
}); | |
return ret; | |
} | |
,'delete': function(item) { | |
var _gthis = this; | |
var ret = tink_core__$Promise_Promise_$Impl_$.ofOutcome(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.filter(_gthis.get_items(),function(i) { | |
if(i != item) { | |
return 1; | |
} else { | |
return 0; | |
} | |
})})); | |
ret.handle(function(o) { | |
if(o[1] == 0) { | |
var v = o[2]; | |
_gthis.__cocoupdate(v); | |
} | |
}); | |
return ret; | |
} | |
,clearCompleted: function() { | |
var _gthis = this; | |
var ret = tink_core__$Promise_Promise_$Impl_$.ofOutcome(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.filter(_gthis.get_items(),function(i) { | |
if(!i.get_completed()) { | |
return 1; | |
} else { | |
return 0; | |
} | |
})})); | |
ret.handle(function(o) { | |
if(o[1] == 0) { | |
var v = o[2]; | |
_gthis.__cocoupdate(v); | |
} | |
}); | |
return ret; | |
} | |
,get_items: function() { | |
return tink_state__$State_State_$Impl_$.get_value(this.__coco_items); | |
} | |
,__cocoupdate: function(delta) { | |
var this1 = { }; | |
var sparse = this1; | |
var delta1 = delta; | |
var _g = 0; | |
var _g1 = Reflect.fields(delta1); | |
while(_g < _g1.length) { | |
var k = _g1[_g]; | |
++_g; | |
var this2; | |
var this3 = new Array(1); | |
this2 = this3; | |
var ret = this2; | |
ret[0] = delta1[k]; | |
sparse[k] = ret; | |
} | |
var delta2 = sparse; | |
if(delta2.items != null) { | |
this.__coco_items.set(delta2.items[0]); | |
} | |
} | |
,__class__: todomvc_data_TodoList | |
}; | |
var todomvc_ui_TodoItemView = function(data) { | |
var _gthis = this; | |
coconut_ui_View.call(this,data,function(data1) { | |
var tmp = tink_state__$Observable_Observable_$Impl_$.get_value(data1); | |
return _gthis.render(tmp); | |
}); | |
var this1 = new tink_state__$State_StateObject(false); | |
this.__coco_isEditing__ = this1; | |
}; | |
todomvc_ui_TodoItemView.__name__ = true; | |
todomvc_ui_TodoItemView.__super__ = coconut_ui_View; | |
todomvc_ui_TodoItemView.prototype = $extend(coconut_ui_View.prototype,{ | |
render: function(__data__) { | |
var _gthis = this; | |
var ondeleted = $bind(__data__,__data__.ondeleted); | |
var item = __data__.item; | |
var edit = function(entered) { | |
var _g = StringTools.rtrim(entered); | |
if(_g == "") { | |
ondeleted(item); | |
} else { | |
var v = _g; | |
item.set_description(v); | |
} | |
}; | |
var attr = vdom__$Attr_ClassName_$Impl_$.ofString("todo-item"); | |
var attr1 = item.get_completed() ? "" : undefined; | |
var attr2 = tink_state__$State_State_$Impl_$.get_value(this.__coco_isEditing__) ? "" : undefined; | |
var children = vdom_VDom.h("input",{ name : "completed", type : "checkbox", checked : item.get_completed(), onchange : function(event) { | |
item.set_completed(event.target.checked); | |
}}); | |
var children1 = tink_state__$State_State_$Impl_$.get_value(this.__coco_isEditing__) ? vdom__$VNode_VNode_$Impl_$.flatten([vdom_VDom.h("input",{ name : "description", type : "text", value : item.get_description(), onchange : function(event1) { | |
edit(event1.target.value); | |
}, onblur : function(event2) { | |
_gthis.__coco_isEditing__.set(false); | |
}})]) : vdom__$VNode_VNode_$Impl_$.flatten([vdom_VDom.h("span",{ className : vdom__$Attr_ClassName_$Impl_$.ofString("description"), ondblclick : function(event3) { | |
_gthis.__coco_isEditing__.set(true); | |
}},[item.get_description()]),vdom_VDom.h("button",{ className : vdom__$Attr_ClassName_$Impl_$.ofString("delete"), onclick : function(event4) { | |
ondeleted(item); | |
}},["Delete"])]); | |
return vdom_VDom.h("li",{ className : attr, attributes : { 'data-completed' : attr1, 'data-editing' : attr2}},[children,children1]); | |
} | |
,afterPatching: function(_) { | |
if(tink_state__$State_State_$Impl_$.get_value(this.__coco_isEditing__)) { | |
this.__dom.querySelector("input[type=\"text\"]").focus(); | |
} | |
} | |
,__class__: todomvc_ui_TodoItemView | |
}); | |
var todomvc_ui_TodoListView = function(data) { | |
var _gthis = this; | |
coconut_ui_View.call(this,data,function(data1) { | |
var tmp = tink_state__$Observable_Observable_$Impl_$.get_value(data1); | |
return _gthis.render(tmp); | |
}); | |
}; | |
todomvc_ui_TodoListView.__name__ = true; | |
todomvc_ui_TodoListView.__super__ = coconut_ui_View; | |
todomvc_ui_TodoListView.prototype = $extend(coconut_ui_View.prototype,{ | |
render: function(__data__) { | |
var todos = __data__.todos; | |
var filter = __data__.filter; | |
var attr = vdom__$Attr_ClassName_$Impl_$.ofString("todo-list"); | |
var this1 = todos.get_items(); | |
var attr1 = { className : attr, attributes : { 'data-empty' : (this1 == null ? 0 : this1.length) == 0 ? "" : undefined}}; | |
var children = vdom_VDom.h("h1",{ },["todos"]); | |
var children1 = vdom_VDom.h("input",{ type : "text", placeholder : "What needs to be done?", onkeypress : function(e) { | |
if(e.keyCode == 13) { | |
todos.add(e.target.value); | |
e.target.value = ""; | |
} | |
return; | |
}}); | |
var children2; | |
var this11 = todos.get_items(); | |
if((this11 == null ? 0 : this11.length) > 0) { | |
var children3; | |
var predicate = todomvc_data_TodoItem.isActive; | |
var ret = false; | |
var _g = new tink_pure_NodeIterator(todos.get_items()); | |
while(_g.list.length > 0) { | |
var next = _g.list.pop(); | |
var _g1 = -next.tails.length; | |
while(_g1 < 0) { | |
var i = _g1++; | |
_g.list.push(next.tails[-i - 1]); | |
} | |
var x = next.value; | |
if(predicate(x)) { | |
ret = true; | |
break; | |
} | |
} | |
if(ret) { | |
children3 = vdom__$VNode_VNode_$Impl_$.flatten([vdom_VDom.h("button",{ className : vdom__$Attr_ClassName_$Impl_$.ofString("mark-all"), onclick : tink_core__$Callback_Callback_$Impl_$.fromNiladic(function() { | |
var _g2 = new tink_pure_NodeIterator(todos.get_items()); | |
while(_g2.list.length > 0) { | |
var next1 = _g2.list.pop(); | |
var _g3 = -next1.tails.length; | |
while(_g3 < 0) { | |
var i1 = _g3++; | |
_g2.list.push(next1.tails[-i1 - 1]); | |
} | |
var i2 = next1.value; | |
i2.set_completed(true); | |
} | |
return; | |
})},["Mark all as completed"])]); | |
} else { | |
children3 = vdom__$VNode_VNode_$Impl_$.flatten([vdom_VDom.h("button",{ className : vdom__$Attr_ClassName_$Impl_$.ofString("unmark-all"), onclick : tink_core__$Callback_Callback_$Impl_$.fromNiladic(function() { | |
var _g4 = new tink_pure_NodeIterator(todos.get_items()); | |
while(_g4.list.length > 0) { | |
var next2 = _g4.list.pop(); | |
var _g5 = -next2.tails.length; | |
while(_g5 < 0) { | |
var i3 = _g5++; | |
_g4.list.push(next2.tails[-i3 - 1]); | |
} | |
var i4 = next2.value; | |
i4.set_completed(false); | |
} | |
return; | |
})},["Unmark all as completed"])]); | |
} | |
children2 = vdom__$VNode_VNode_$Impl_$.flatten([children3]); | |
} else { | |
children2 = vdom__$VNode_VNode_$Impl_$.flatten([]); | |
} | |
var children4 = vdom_VDom.h("header",{ },[children1,children2]); | |
var children5; | |
var this12 = todos.get_items(); | |
if((this12 == null ? 0 : this12.length) > 0) { | |
var _g6 = []; | |
var _g11 = new tink_pure_NodeIterator(todos.get_items()); | |
while(_g11.list.length > 0) { | |
var next3 = _g11.list.pop(); | |
var _g7 = -next3.tails.length; | |
while(_g7 < 0) { | |
var i5 = _g7++; | |
_g11.list.push(next3.tails[-i5 - 1]); | |
} | |
var item = [next3.value]; | |
var children6; | |
if(filter.matches(item[0])) { | |
var __f = this.__coco__cache.getFactory("TodoItemView",(function() { | |
return function(data) { | |
return new todomvc_ui_TodoItemView(data); | |
}; | |
})()); | |
var __s = __f.forKey(item[0],(function() { | |
return function() { | |
var this13 = new tink_state__$State_StateObject(null); | |
var s = this13; | |
var o = coconut_ui_tools_Compare.stabilize(tink_state__$Observable_Observable_$Impl_$.auto(tink_state__$Observable_Computation_$Impl_$.plain((function() { | |
return function() { | |
return (tink_state__$State_State_$Impl_$.get_value(s))(); | |
}; | |
})())),(function() { | |
return function(a2,nu) { | |
return coconut_ui_tools_Compare.shallow(false,a2,nu); | |
}; | |
})()); | |
var this14 = new tink_core_MPair(s,o); | |
return this14; | |
}; | |
})()); | |
tink_state__$Observable_Observable_$Impl_$.stack.push(__s.a); | |
__s.a.set((function(item1) { | |
return function() { | |
var children7 = (function(item2) { | |
return function(event) { | |
todos["delete"](item2[0]); | |
}; | |
})(item1); | |
return { item : item1[0], ondeleted : children7}; | |
}; | |
})(item)); | |
tink_state__$Observable_Observable_$Impl_$.stack.pop(); | |
children6 = vdom__$VNode_VNode_$Impl_$.flatten([__f.make(__s.b)]); | |
} else { | |
children6 = vdom__$VNode_VNode_$Impl_$.flatten([]); | |
} | |
_g6.push(vdom__$VNode_VNode_$Impl_$.flatten([children6])); | |
} | |
var children8 = [vdom__$VNode_VNode_$Impl_$.flatten(_g6)]; | |
var children9 = vdom_VDom.h("ol",{ },children8); | |
var predicate1 = todomvc_data_TodoItem.isActive; | |
var ret1 = 0; | |
var _g8 = new tink_pure_NodeIterator(todos.get_items()); | |
while(_g8.list.length > 0) { | |
var next4 = _g8.list.pop(); | |
var _g12 = -next4.tails.length; | |
while(_g12 < 0) { | |
var i6 = _g12++; | |
_g8.list.push(next4.tails[-i6 - 1]); | |
} | |
var x1 = next4.value; | |
if(predicate1(x1)) { | |
++ret1; | |
} | |
} | |
var _g13 = ret1; | |
var children10; | |
if(_g13 == 1) { | |
children10 = vdom__$VNode_VNode_$Impl_$.flatten(["1 item"]); | |
} else { | |
var v = _g13; | |
children10 = vdom__$VNode_VNode_$Impl_$.flatten([v == null ? "null" : "" + v," items"]); | |
} | |
var children11 = vdom_VDom.h("span",{ },[children10," left"]); | |
var _g21 = []; | |
var _g31 = new tink_pure_NodeIterator(filter.get_options()); | |
while(_g31.list.length > 0) { | |
var next5 = _g31.list.pop(); | |
var _g9 = -next5.tails.length; | |
while(_g9 < 0) { | |
var i7 = _g9++; | |
_g31.list.push(next5.tails[-i7 - 1]); | |
} | |
var f = [next5.value]; | |
_g21.push(vdom__$VNode_VNode_$Impl_$.flatten([vdom_VDom.h("button",{ onclick : (function(f1) { | |
return function(event1) { | |
filter.toggle(f1[0].value); | |
}; | |
})(f), attributes : { 'data-active' : filter.isActive(f[0].value) ? "" : undefined}},[f[0].name])])); | |
} | |
var children12 = [vdom__$VNode_VNode_$Impl_$.flatten(_g21)]; | |
var children13 = vdom_VDom.h("menu",{ },children12); | |
var children14; | |
var predicate2 = todomvc_data_TodoItem.isCompleted; | |
var ret2 = false; | |
var _g10 = new tink_pure_NodeIterator(todos.get_items()); | |
while(_g10.list.length > 0) { | |
var next6 = _g10.list.pop(); | |
var _g14 = -next6.tails.length; | |
while(_g14 < 0) { | |
var i8 = _g14++; | |
_g10.list.push(next6.tails[-i8 - 1]); | |
} | |
var x2 = next6.value; | |
if(predicate2(x2)) { | |
ret2 = true; | |
break; | |
} | |
} | |
if(ret2) { | |
children14 = vdom__$VNode_VNode_$Impl_$.flatten([vdom_VDom.h("button",{ onclick : tink_core__$Callback_Callback_$Impl_$.fromNiladic($bind(todos,todos.clearCompleted))},["Clear Completed"])]); | |
} else { | |
children14 = vdom__$VNode_VNode_$Impl_$.flatten([]); | |
} | |
children5 = vdom__$VNode_VNode_$Impl_$.flatten([children9,vdom_VDom.h("footer",{ },[children11,children13,children14])]); | |
} else { | |
children5 = vdom__$VNode_VNode_$Impl_$.flatten([]); | |
} | |
return vdom_VDom.h("div",attr1,[children,children4,children5]); | |
} | |
,afterInit: function(_) { | |
var _gthis = this; | |
var this1 = new tink_core__$Callback_SimpleLink(($_=haxe_Timer.delay(function() { | |
_gthis.__dom.querySelector("header input").focus(); | |
},10),$bind($_,$_.stop))); | |
} | |
,__class__: todomvc_ui_TodoListView | |
}); | |
var vdom__$Attr_ClassName_$Impl_$ = {}; | |
vdom__$Attr_ClassName_$Impl_$.__name__ = true; | |
vdom__$Attr_ClassName_$Impl_$.ofString = function(s) { | |
var this1 = StringTools.trim(s); | |
return this1; | |
}; | |
var vdom__$Attr_Key_$Impl_$ = {}; | |
vdom__$Attr_Key_$Impl_$.__name__ = true; | |
vdom__$Attr_Key_$Impl_$.ofObj = function(v) { | |
if(v == null) { | |
return null; | |
} | |
var o = v; | |
if(o.__vdomKey__ == null) { | |
o.__vdomKey__ = vdom__$Attr_Key_$Impl_$.keygen++; | |
} | |
return o.__vdomKey__; | |
}; | |
var vdom__$VNode_VNode_$Impl_$ = {}; | |
vdom__$VNode_VNode_$Impl_$.__name__ = true; | |
vdom__$VNode_VNode_$Impl_$.flatten = function(c) { | |
return c; | |
}; | |
var $_, $fid = 0; | |
function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.hx__closures__[m.__id__] = f; } return f; } | |
String.prototype.__class__ = String; | |
String.__name__ = true; | |
Array.__name__ = true; | |
Date.prototype.__class__ = Date; | |
Date.__name__ = ["Date"]; | |
var Int = { __name__ : ["Int"]}; | |
var Dynamic = { __name__ : ["Dynamic"]}; | |
var Float = Number; | |
Float.__name__ = ["Float"]; | |
var Bool = Boolean; | |
Bool.__ename__ = ["Bool"]; | |
var Class = { __name__ : ["Class"]}; | |
var Enum = { }; | |
var __map_reserved = {} | |
var vdom_VDom = function(e){return e()}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | |
var createElement = require("./vdom/create-element.js") | |
module.exports = createElement | |
},{"./vdom/create-element.js":15}],2:[function(require,module,exports){ | |
var diff = require("./vtree/diff.js") | |
module.exports = diff | |
},{"./vtree/diff.js":35}],3:[function(require,module,exports){ | |
var h = require("./virtual-hyperscript/index.js") | |
module.exports = h | |
},{"./virtual-hyperscript/index.js":22}],4:[function(require,module,exports){ | |
var diff = require("./diff.js") | |
var patch = require("./patch.js") | |
var h = require("./h.js") | |
var create = require("./create-element.js") | |
var VNode = require('./vnode/vnode.js') | |
var VText = require('./vnode/vtext.js') | |
module.exports = { | |
diff: diff, | |
patch: patch, | |
h: h, | |
create: create, | |
VNode: VNode, | |
VText: VText | |
} | |
//for (var name in module.exports) | |
//window[name] = module.exports[name]; | |
},{"./create-element.js":1,"./diff.js":2,"./h.js":3,"./patch.js":13,"./vnode/vnode.js":31,"./vnode/vtext.js":33}],5:[function(require,module,exports){ | |
/*! | |
* Cross-Browser Split 1.1.1 | |
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com> | |
* Available under the MIT License | |
* ECMAScript compliant, uniform cross-browser split method | |
*/ | |
/** | |
* Splits a string into an array of strings using a regex or string separator. Matches of the | |
* separator are not included in the result array. However, if `separator` is a regex that contains | |
* capturing groups, backreferences are spliced into the result each time `separator` is matched. | |
* Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably | |
* cross-browser. | |
* @param {String} str String to split. | |
* @param {RegExp|String} separator Regex or string to use for separating the string. | |
* @param {Number} [limit] Maximum number of items to include in the result array. | |
* @returns {Array} Array of substrings. | |
* @example | |
* | |
* // Basic use | |
* split('a b c d', ' '); | |
* // -> ['a', 'b', 'c', 'd'] | |
* | |
* // With limit | |
* split('a b c d', ' ', 2); | |
* // -> ['a', 'b'] | |
* | |
* // Backreferences in result array | |
* split('..word1 word2..', /([a-z]+)(\d+)/i); | |
* // -> ['..', 'word', '1', ' ', 'word', '2', '..'] | |
*/ | |
module.exports = (function split(undef) { | |
var nativeSplit = String.prototype.split, | |
compliantExecNpcg = /()??/.exec("")[1] === undef, | |
// NPCG: nonparticipating capturing group | |
self; | |
self = function(str, separator, limit) { | |
// If `separator` is not a regex, use `nativeSplit` | |
if (Object.prototype.toString.call(separator) !== "[object RegExp]") { | |
return nativeSplit.call(str, separator, limit); | |
} | |
var output = [], | |
flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6 | |
(separator.sticky ? "y" : ""), | |
// Firefox 3+ | |
lastLastIndex = 0, | |
// Make `global` and avoid `lastIndex` issues by working with a copy | |
separator = new RegExp(separator.source, flags + "g"), | |
separator2, match, lastIndex, lastLength; | |
str += ""; // Type-convert | |
if (!compliantExecNpcg) { | |
// Doesn't need flags gy, but they don't hurt | |
separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags); | |
} | |
/* Values for `limit`, per the spec: | |
* If undefined: 4294967295 // Math.pow(2, 32) - 1 | |
* If 0, Infinity, or NaN: 0 | |
* If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296; | |
* If negative number: 4294967296 - Math.floor(Math.abs(limit)) | |
* If other: Type-convert, then use the above rules | |
*/ | |
limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1 | |
limit >>> 0; // ToUint32(limit) | |
while (match = separator.exec(str)) { | |
// `separator.lastIndex` is not reliable cross-browser | |
lastIndex = match.index + match[0].length; | |
if (lastIndex > lastLastIndex) { | |
output.push(str.slice(lastLastIndex, match.index)); | |
// Fix browsers whose `exec` methods don't consistently return `undefined` for | |
// nonparticipating capturing groups | |
if (!compliantExecNpcg && match.length > 1) { | |
match[0].replace(separator2, function() { | |
for (var i = 1; i < arguments.length - 2; i++) { | |
if (arguments[i] === undef) { | |
match[i] = undef; | |
} | |
} | |
}); | |
} | |
if (match.length > 1 && match.index < str.length) { | |
Array.prototype.push.apply(output, match.slice(1)); | |
} | |
lastLength = match[0].length; | |
lastLastIndex = lastIndex; | |
if (output.length >= limit) { | |
break; | |
} | |
} | |
if (separator.lastIndex === match.index) { | |
separator.lastIndex++; // Avoid an infinite loop | |
} | |
} | |
if (lastLastIndex === str.length) { | |
if (lastLength || !separator.test("")) { | |
output.push(""); | |
} | |
} else { | |
output.push(str.slice(lastLastIndex)); | |
} | |
return output.length > limit ? output.slice(0, limit) : output; | |
}; | |
return self; | |
})(); | |
},{}],6:[function(require,module,exports){ | |
},{}],7:[function(require,module,exports){ | |
'use strict'; | |
var OneVersionConstraint = require('individual/one-version'); | |
var MY_VERSION = '7'; | |
OneVersionConstraint('ev-store', MY_VERSION); | |
var hashKey = '__EV_STORE_KEY@' + MY_VERSION; | |
module.exports = EvStore; | |
function EvStore(elem) { | |
var hash = elem[hashKey]; | |
if (!hash) { | |
hash = elem[hashKey] = {}; | |
} | |
return hash; | |
} | |
},{"individual/one-version":9}],8:[function(require,module,exports){ | |
(function (global){ | |
'use strict'; | |
/*global window, global*/ | |
var root = typeof window !== 'undefined' ? | |
window : typeof global !== 'undefined' ? | |
global : {}; | |
module.exports = Individual; | |
function Individual(key, value) { | |
if (key in root) { | |
return root[key]; | |
} | |
root[key] = value; | |
return value; | |
} | |
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | |
},{}],9:[function(require,module,exports){ | |
'use strict'; | |
var Individual = require('./index.js'); | |
module.exports = OneVersion; | |
function OneVersion(moduleName, version, defaultValue) { | |
var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName; | |
var enforceKey = key + '_ENFORCE_SINGLETON'; | |
var versionValue = Individual(enforceKey, version); | |
if (versionValue !== version) { | |
throw new Error('Can only have one copy of ' + | |
moduleName + '.\n' + | |
'You already have version ' + versionValue + | |
' installed.\n' + | |
'This means you cannot install version ' + version); | |
} | |
return Individual(key, defaultValue); | |
} | |
},{"./index.js":8}],10:[function(require,module,exports){ | |
(function (global){ | |
var topLevel = typeof global !== 'undefined' ? global : | |
typeof window !== 'undefined' ? window : {} | |
var minDoc = require('min-document'); | |
if (typeof document !== 'undefined') { | |
module.exports = document; | |
} else { | |
var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4']; | |
if (!doccy) { | |
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc; | |
} | |
module.exports = doccy; | |
} | |
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | |
},{"min-document":6}],11:[function(require,module,exports){ | |
"use strict"; | |
module.exports = function isObject(x) { | |
return typeof x === "object" && x !== null; | |
}; | |
},{}],12:[function(require,module,exports){ | |
var nativeIsArray = Array.isArray | |
var toString = Object.prototype.toString | |
module.exports = nativeIsArray || isArray | |
function isArray(obj) { | |
return toString.call(obj) === "[object Array]" | |
} | |
},{}],13:[function(require,module,exports){ | |
var patch = require("./vdom/patch.js") | |
module.exports = patch | |
},{"./vdom/patch.js":18}],14:[function(require,module,exports){ | |
var isObject = require("is-object") | |
var isHook = require("../vnode/is-vhook.js") | |
module.exports = applyProperties | |
function applyProperties(node, props, previous) { | |
for (var propName in props) { | |
var propValue = props[propName] | |
if (propValue === undefined) { | |
removeProperty(node, propName, propValue, previous); | |
} else if (isHook(propValue)) { | |
removeProperty(node, propName, propValue, previous) | |
if (propValue.hook) { | |
propValue.hook(node, | |
propName, | |
previous ? previous[propName] : undefined) | |
} | |
} else { | |
if (isObject(propValue)) { | |
patchObject(node, props, previous, propName, propValue); | |
} else { | |
node[propName] = propValue | |
} | |
} | |
} | |
} | |
function removeProperty(node, propName, propValue, previous) { | |
if (previous) { | |
var previousValue = previous[propName] | |
if (!isHook(previousValue)) { | |
if (propName === "attributes") { | |
for (var attrName in previousValue) { | |
node.removeAttribute(attrName) | |
} | |
} else if (propName === "style") { | |
for (var i in previousValue) { | |
node.style[i] = "" | |
} | |
} else if (typeof previousValue === "string") { | |
node[propName] = "" | |
} else { | |
node[propName] = null | |
} | |
} else if (previousValue.unhook) { | |
previousValue.unhook(node, propName, propValue) | |
} | |
} | |
} | |
function patchObject(node, props, previous, propName, propValue) { | |
var previousValue = previous ? previous[propName] : undefined | |
// Set attributes | |
if (propName === "attributes") { | |
for (var attrName in propValue) { | |
var attrValue = propValue[attrName] | |
if (attrValue === undefined) { | |
node.removeAttribute(attrName) | |
} else { | |
node.setAttribute(attrName, attrValue) | |
} | |
} | |
return | |
} | |
if(previousValue && isObject(previousValue) && | |
getPrototype(previousValue) !== getPrototype(propValue)) { | |
node[propName] = propValue | |
return | |
} | |
if (!isObject(node[propName])) { | |
node[propName] = {} | |
} | |
var replacer = propName === "style" ? "" : undefined | |
for (var k in propValue) { | |
var value = propValue[k] | |
node[propName][k] = (value === undefined) ? replacer : value | |
} | |
} | |
function getPrototype(value) { | |
if (Object.getPrototypeOf) { | |
return Object.getPrototypeOf(value) | |
} else if (value.__proto__) { | |
return value.__proto__ | |
} else if (value.constructor) { | |
return value.constructor.prototype | |
} | |
} | |
},{"../vnode/is-vhook.js":26,"is-object":11}],15:[function(require,module,exports){ | |
var document = require("global/document") | |
var applyProperties = require("./apply-properties") | |
var isVNode = require("../vnode/is-vnode.js") | |
var isVText = require("../vnode/is-vtext.js") | |
var isWidget = require("../vnode/is-widget.js") | |
var handleThunk = require("../vnode/handle-thunk.js") | |
module.exports = createElement | |
function createElement(vnode, opts) { | |
var doc = opts ? opts.document || document : document | |
var warn = opts ? opts.warn : null | |
vnode = handleThunk(vnode).a | |
if (isWidget(vnode)) { | |
return vnode.init() | |
} else if (isVText(vnode)) { | |
return doc.createTextNode(vnode.text) | |
} else if (!isVNode(vnode)) { | |
if (warn) { | |
warn("Item is not a valid virtual dom node", vnode) | |
} | |
return null | |
} | |
var node = (vnode.namespace === null) ? | |
doc.createElement(vnode.tagName) : | |
doc.createElementNS(vnode.namespace, vnode.tagName) | |
var props = vnode.properties | |
applyProperties(node, props) | |
var children = vnode.children | |
for (var i = 0; i < children.length; i++) { | |
var childNode = createElement(children[i], opts) | |
if (childNode) { | |
node.appendChild(childNode) | |
} | |
} | |
return node | |
} | |
},{"../vnode/handle-thunk.js":24,"../vnode/is-vnode.js":27,"../vnode/is-vtext.js":28,"../vnode/is-widget.js":29,"./apply-properties":14,"global/document":10}],16:[function(require,module,exports){ | |
// Maps a virtual DOM tree onto a real DOM tree in an efficient manner. | |
// We don't want to read all of the DOM nodes in the tree so we use | |
// the in-order tree indexing to eliminate recursion down certain branches. | |
// We only recurse into a DOM node if we know that it contains a child of | |
// interest. | |
var noChild = {} | |
module.exports = domIndex | |
function domIndex(rootNode, tree, indices, nodes) { | |
if (!indices || indices.length === 0) { | |
return {} | |
} else { | |
indices.sort(ascending) | |
return recurse(rootNode, tree, indices, nodes, 0) | |
} | |
} | |
function recurse(rootNode, tree, indices, nodes, rootIndex) { | |
nodes = nodes || {} | |
if (rootNode) { | |
if (indexInRange(indices, rootIndex, rootIndex)) { | |
nodes[rootIndex] = rootNode | |
} | |
var vChildren = tree.children | |
if (vChildren) { | |
var childNodes = rootNode.childNodes | |
for (var i = 0; i < tree.children.length; i++) { | |
rootIndex += 1 | |
var vChild = vChildren[i] || noChild | |
var nextIndex = rootIndex + (vChild.count || 0) | |
// skip recursion down the tree if there are no nodes down here | |
if (indexInRange(indices, rootIndex, nextIndex)) { | |
recurse(childNodes[i], vChild, indices, nodes, rootIndex) | |
} | |
rootIndex = nextIndex | |
} | |
} | |
} | |
return nodes | |
} | |
// Binary search for an index in the interval [left, right] | |
function indexInRange(indices, left, right) { | |
if (indices.length === 0) { | |
return false | |
} | |
var minIndex = 0 | |
var maxIndex = indices.length - 1 | |
var currentIndex | |
var currentItem | |
while (minIndex <= maxIndex) { | |
currentIndex = ((maxIndex + minIndex) / 2) >> 0 | |
currentItem = indices[currentIndex] | |
if (minIndex === maxIndex) { | |
return currentItem >= left && currentItem <= right | |
} else if (currentItem < left) { | |
minIndex = currentIndex + 1 | |
} else if (currentItem > right) { | |
maxIndex = currentIndex - 1 | |
} else { | |
return true | |
} | |
} | |
return false; | |
} | |
function ascending(a, b) { | |
return a > b ? 1 : -1 | |
} | |
},{}],17:[function(require,module,exports){ | |
var applyProperties = require("./apply-properties") | |
var isWidget = require("../vnode/is-widget.js") | |
var VPatch = require("../vnode/vpatch.js") | |
var updateWidget = require("./update-widget") | |
module.exports = applyPatch | |
function applyPatch(vpatch, domNode, renderOptions) { | |
var type = vpatch.type | |
var vNode = vpatch.vNode | |
var patch = vpatch.patch | |
switch (type) { | |
case VPatch.REMOVE: | |
return removeNode(domNode, vNode) | |
case VPatch.INSERT: | |
return insertNode(domNode, patch, renderOptions) | |
case VPatch.VTEXT: | |
return stringPatch(domNode, vNode, patch, renderOptions) | |
case VPatch.WIDGET: | |
return widgetPatch(domNode, vNode, patch, renderOptions) | |
case VPatch.VNODE: | |
return vNodePatch(domNode, vNode, patch, renderOptions) | |
case VPatch.ORDER: | |
reorderChildren(domNode, patch) | |
return domNode | |
case VPatch.PROPS: | |
applyProperties(domNode, patch, vNode.properties) | |
return domNode | |
case VPatch.THUNK: | |
return replaceRoot(domNode, | |
renderOptions.patch(domNode, patch, renderOptions)) | |
default: | |
return domNode | |
} | |
} | |
function removeNode(domNode, vNode) { | |
var parentNode = domNode.parentNode | |
if (parentNode) { | |
parentNode.removeChild(domNode) | |
} | |
destroyWidget(domNode, vNode); | |
return null | |
} | |
function insertNode(parentNode, vNode, renderOptions) { | |
var newNode = renderOptions.render(vNode, renderOptions) | |
if (parentNode) { | |
parentNode.appendChild(newNode) | |
} | |
return parentNode | |
} | |
function stringPatch(domNode, leftVNode, vText, renderOptions) { | |
var newNode | |
if (domNode.nodeType === 3) { | |
domNode.replaceData(0, domNode.length, vText.text) | |
newNode = domNode | |
} else { | |
var parentNode = domNode.parentNode | |
newNode = renderOptions.render(vText, renderOptions) | |
if (parentNode && newNode !== domNode) { | |
parentNode.replaceChild(newNode, domNode) | |
} | |
} | |
return newNode | |
} | |
function widgetPatch(domNode, leftVNode, widget, renderOptions) { | |
var updating = updateWidget(leftVNode, widget) | |
var newNode | |
if (updating) { | |
newNode = widget.update(leftVNode, domNode) || domNode | |
} else { | |
newNode = renderOptions.render(widget, renderOptions) | |
} | |
var parentNode = domNode.parentNode | |
if (parentNode && newNode !== domNode) { | |
parentNode.replaceChild(newNode, domNode) | |
} | |
if (!updating) { | |
destroyWidget(domNode, leftVNode) | |
} | |
return newNode | |
} | |
function vNodePatch(domNode, leftVNode, vNode, renderOptions) { | |
var parentNode = domNode.parentNode | |
var newNode = renderOptions.render(vNode, renderOptions) | |
if (parentNode && newNode !== domNode) { | |
parentNode.replaceChild(newNode, domNode) | |
} | |
return newNode | |
} | |
function destroyWidget(domNode, w) { | |
if (typeof w.destroy === "function" && isWidget(w)) { | |
w.destroy(domNode) | |
} | |
} | |
function reorderChildren(domNode, moves) { | |
var childNodes = domNode.childNodes | |
var keyMap = {} | |
var node | |
var remove | |
var insert | |
for (var i = 0; i < moves.removes.length; i++) { | |
remove = moves.removes[i] | |
node = childNodes[remove.from] | |
if (remove.key) { | |
keyMap[remove.key] = node | |
} | |
domNode.removeChild(node) | |
} | |
var length = childNodes.length | |
for (var j = 0; j < moves.inserts.length; j++) { | |
insert = moves.inserts[j] | |
node = keyMap[insert.key] | |
// this is the weirdest bug i've ever seen in webkit | |
domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to]) | |
} | |
} | |
function replaceRoot(oldRoot, newRoot) { | |
if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) { | |
oldRoot.parentNode.replaceChild(newRoot, oldRoot) | |
} | |
return newRoot; | |
} | |
},{"../vnode/is-widget.js":29,"../vnode/vpatch.js":32,"./apply-properties":14,"./update-widget":19}],18:[function(require,module,exports){ | |
var document = require("global/document") | |
var isArray = require("x-is-array") | |
var render = require("./create-element") | |
var domIndex = require("./dom-index") | |
var patchOp = require("./patch-op") | |
module.exports = patch | |
function patch(rootNode, patches, renderOptions) { | |
renderOptions = renderOptions || {} | |
renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch | |
? renderOptions.patch | |
: patchRecursive | |
renderOptions.render = renderOptions.render || render | |
return renderOptions.patch(rootNode, patches, renderOptions) | |
} | |
function patchRecursive(rootNode, patches, renderOptions) { | |
var indices = patchIndices(patches) | |
if (indices.length === 0) { | |
return rootNode | |
} | |
var index = domIndex(rootNode, patches.a, indices) | |
var ownerDocument = rootNode.ownerDocument | |
if (!renderOptions.document && ownerDocument !== document) { | |
renderOptions.document = ownerDocument | |
} | |
for (var i = 0; i < indices.length; i++) { | |
var nodeIndex = indices[i] | |
rootNode = applyPatch(rootNode, | |
index[nodeIndex], | |
patches[nodeIndex], | |
renderOptions) | |
} | |
return rootNode | |
} | |
function applyPatch(rootNode, domNode, patchList, renderOptions) { | |
if (!domNode) { | |
return rootNode | |
} | |
var newNode | |
if (isArray(patchList)) { | |
for (var i = 0; i < patchList.length; i++) { | |
newNode = patchOp(patchList[i], domNode, renderOptions) | |
if (domNode === rootNode) { | |
rootNode = newNode | |
} | |
} | |
} else { | |
newNode = patchOp(patchList, domNode, renderOptions) | |
if (domNode === rootNode) { | |
rootNode = newNode | |
} | |
} | |
return rootNode | |
} | |
function patchIndices(patches) { | |
var indices = [] | |
for (var key in patches) { | |
if (key !== "a") { | |
indices.push(Number(key)) | |
} | |
} | |
return indices | |
} | |
},{"./create-element":15,"./dom-index":16,"./patch-op":17,"global/document":10,"x-is-array":12}],19:[function(require,module,exports){ | |
var isWidget = require("../vnode/is-widget.js") | |
module.exports = updateWidget | |
function updateWidget(a, b) { | |
if (isWidget(a) && isWidget(b)) { | |
if ("name" in a && "name" in b) { | |
return a.id === b.id | |
} else { | |
return a.init === b.init | |
} | |
} | |
return false | |
} | |
},{"../vnode/is-widget.js":29}],20:[function(require,module,exports){ | |
'use strict'; | |
var EvStore = require('ev-store'); | |
module.exports = EvHook; | |
function EvHook(value) { | |
if (!(this instanceof EvHook)) { | |
return new EvHook(value); | |
} | |
this.value = value; | |
} | |
EvHook.prototype.hook = function (node, propertyName) { | |
var es = EvStore(node); | |
var propName = propertyName.substr(3); | |
es[propName] = this.value; | |
}; | |
EvHook.prototype.unhook = function(node, propertyName) { | |
var es = EvStore(node); | |
var propName = propertyName.substr(3); | |
es[propName] = undefined; | |
}; | |
},{"ev-store":7}],21:[function(require,module,exports){ | |
'use strict'; | |
module.exports = SoftSetHook; | |
function SoftSetHook(value) { | |
if (!(this instanceof SoftSetHook)) { | |
return new SoftSetHook(value); | |
} | |
this.value = value; | |
} | |
SoftSetHook.prototype.hook = function (node, propertyName) { | |
if (node[propertyName] !== this.value) { | |
node[propertyName] = this.value; | |
} | |
}; | |
},{}],22:[function(require,module,exports){ | |
'use strict'; | |
var isArray = require('x-is-array'); | |
var VNode = require('../vnode/vnode.js'); | |
var VText = require('../vnode/vtext.js'); | |
var isVNode = require('../vnode/is-vnode'); | |
var isVText = require('../vnode/is-vtext'); | |
var isWidget = require('../vnode/is-widget'); | |
var isHook = require('../vnode/is-vhook'); | |
var isVThunk = require('../vnode/is-thunk'); | |
var parseTag = require('./parse-tag.js'); | |
var softSetHook = require('./hooks/soft-set-hook.js'); | |
var evHook = require('./hooks/ev-hook.js'); | |
module.exports = h; | |
function h(tagName, properties, children) { | |
var childNodes = []; | |
var tag, props, key, namespace; | |
if (!children && isChildren(properties)) { | |
children = properties; | |
props = {}; | |
} | |
props = props || properties || {}; | |
tag = parseTag(tagName, props); | |
// support keys | |
if (props.hasOwnProperty('key')) { | |
key = props.key; | |
props.key = undefined; | |
} | |
// support namespace | |
if (props.hasOwnProperty('namespace')) { | |
namespace = props.namespace; | |
props.namespace = undefined; | |
} | |
// fix cursor bug | |
if (tag === 'INPUT' && | |
!namespace && | |
props.hasOwnProperty('value') && | |
props.value !== undefined && | |
!isHook(props.value) | |
) { | |
props.value = softSetHook(props.value); | |
} | |
transformProperties(props); | |
if (children !== undefined && children !== null) { | |
addChild(children, childNodes, tag, props); | |
} | |
return new VNode(tag, props, childNodes, key, namespace); | |
} | |
function addChild(c, childNodes, tag, props) { | |
if (typeof c === 'string') { | |
childNodes.push(new VText(c)); | |
} else if (typeof c === 'number') { | |
childNodes.push(new VText(String(c))); | |
} else if (isChild(c)) { | |
childNodes.push(c); | |
} else if (isArray(c)) { | |
for (var i = 0; i < c.length; i++) { | |
addChild(c[i], childNodes, tag, props); | |
} | |
} else if (c === null || c === undefined) { | |
return; | |
} else { | |
throw UnexpectedVirtualElement({ | |
foreignObject: c, | |
parentVnode: { | |
tagName: tag, | |
properties: props | |
} | |
}); | |
} | |
} | |
function transformProperties(props) { | |
for (var propName in props) { | |
if (props.hasOwnProperty(propName)) { | |
var value = props[propName]; | |
if (isHook(value)) { | |
continue; | |
} | |
if (propName.substr(0, 3) === 'ev-') { | |
// add ev-foo support | |
props[propName] = evHook(value); | |
} | |
} | |
} | |
} | |
function isChild(x) { | |
return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x); | |
} | |
function isChildren(x) { | |
return typeof x === 'string' || isArray(x) || isChild(x); | |
} | |
function UnexpectedVirtualElement(data) { | |
var err = new Error(); | |
err.type = 'virtual-hyperscript.unexpected.virtual-element'; | |
err.message = 'Unexpected virtual child passed to h().\n' + | |
'Expected a VNode / Vthunk / VWidget / string but:\n' + | |
'got:\n' + | |
errorString(data.foreignObject) + | |
'.\n' + | |
'The parent vnode is:\n' + | |
errorString(data.parentVnode) | |
'\n' + | |
'Suggested fix: change your `h(..., [ ... ])` callsite.'; | |
err.foreignObject = data.foreignObject; | |
err.parentVnode = data.parentVnode; | |
return err; | |
} | |
function errorString(obj) { | |
try { | |
return JSON.stringify(obj, null, ' '); | |
} catch (e) { | |
return String(obj); | |
} | |
} | |
},{"../vnode/is-thunk":25,"../vnode/is-vhook":26,"../vnode/is-vnode":27,"../vnode/is-vtext":28,"../vnode/is-widget":29,"../vnode/vnode.js":31,"../vnode/vtext.js":33,"./hooks/ev-hook.js":20,"./hooks/soft-set-hook.js":21,"./parse-tag.js":23,"x-is-array":12}],23:[function(require,module,exports){ | |
'use strict'; | |
var split = require('browser-split'); | |
var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/; | |
var notClassId = /^\.|#/; | |
module.exports = parseTag; | |
function parseTag(tag, props) { | |
if (!tag) { | |
return 'DIV'; | |
} | |
var noId = !(props.hasOwnProperty('id')); | |
var tagParts = split(tag, classIdSplit); | |
var tagName = null; | |
if (notClassId.test(tagParts[1])) { | |
tagName = 'DIV'; | |
} | |
var classes, part, type, i; | |
for (i = 0; i < tagParts.length; i++) { | |
part = tagParts[i]; | |
if (!part) { | |
continue; | |
} | |
type = part.charAt(0); | |
if (!tagName) { | |
tagName = part; | |
} else if (type === '.') { | |
classes = classes || []; | |
classes.push(part.substring(1, part.length)); | |
} else if (type === '#' && noId) { | |
props.id = part.substring(1, part.length); | |
} | |
} | |
if (classes) { | |
if (props.className) { | |
classes.push(props.className); | |
} | |
props.className = classes.join(' '); | |
} | |
return props.namespace ? tagName : tagName.toUpperCase(); | |
} | |
},{"browser-split":5}],24:[function(require,module,exports){ | |
var isVNode = require("./is-vnode") | |
var isVText = require("./is-vtext") | |
var isWidget = require("./is-widget") | |
var isThunk = require("./is-thunk") | |
module.exports = handleThunk | |
function handleThunk(a, b) { | |
var renderedA = a | |
var renderedB = b | |
if (isThunk(b)) { | |
renderedB = renderThunk(b, a) | |
} | |
if (isThunk(a)) { | |
renderedA = renderThunk(a, null) | |
} | |
return { | |
a: renderedA, | |
b: renderedB | |
} | |
} | |
function renderThunk(thunk, previous) { | |
var renderedThunk = thunk.vnode | |
if (!renderedThunk) { | |
renderedThunk = thunk.vnode = thunk.render(previous) | |
} | |
if (!(isVNode(renderedThunk) || | |
isVText(renderedThunk) || | |
isWidget(renderedThunk))) { | |
throw new Error("thunk did not return a valid node"); | |
} | |
return renderedThunk | |
} | |
},{"./is-thunk":25,"./is-vnode":27,"./is-vtext":28,"./is-widget":29}],25:[function(require,module,exports){ | |
module.exports = isThunk | |
function isThunk(t) { | |
return t && t.type === "Thunk" | |
} | |
},{}],26:[function(require,module,exports){ | |
module.exports = isHook | |
function isHook(hook) { | |
return hook && | |
(typeof hook.hook === "function" && !hook.hasOwnProperty("hook") || | |
typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook")) | |
} | |
},{}],27:[function(require,module,exports){ | |
var version = require("./version") | |
module.exports = isVirtualNode | |
function isVirtualNode(x) { | |
return x && x.type === "VirtualNode" && x.version === version | |
} | |
},{"./version":30}],28:[function(require,module,exports){ | |
var version = require("./version") | |
module.exports = isVirtualText | |
function isVirtualText(x) { | |
return x && x.type === "VirtualText" && x.version === version | |
} | |
},{"./version":30}],29:[function(require,module,exports){ | |
module.exports = isWidget | |
function isWidget(w) { | |
return w && w.type === "Widget" | |
} | |
},{}],30:[function(require,module,exports){ | |
module.exports = "2" | |
},{}],31:[function(require,module,exports){ | |
var version = require("./version") | |
var isVNode = require("./is-vnode") | |
var isWidget = require("./is-widget") | |
var isThunk = require("./is-thunk") | |
var isVHook = require("./is-vhook") | |
module.exports = VirtualNode | |
var noProperties = {} | |
var noChildren = [] | |
function VirtualNode(tagName, properties, children, key, namespace) { | |
this.tagName = tagName | |
this.properties = properties || noProperties | |
this.children = children || noChildren | |
this.key = key != null ? String(key) : undefined | |
this.namespace = (typeof namespace === "string") ? namespace : null | |
var count = (children && children.length) || 0 | |
var descendants = 0 | |
var hasWidgets = false | |
var hasThunks = false | |
var descendantHooks = false | |
var hooks | |
for (var propName in properties) { | |
if (properties.hasOwnProperty(propName)) { | |
var property = properties[propName] | |
if (isVHook(property) && property.unhook) { | |
if (!hooks) { | |
hooks = {} | |
} | |
hooks[propName] = property | |
} | |
} | |
} | |
for (var i = 0; i < count; i++) { | |
var child = children[i] | |
if (isVNode(child)) { | |
descendants += child.count || 0 | |
if (!hasWidgets && child.hasWidgets) { | |
hasWidgets = true | |
} | |
if (!hasThunks && child.hasThunks) { | |
hasThunks = true | |
} | |
if (!descendantHooks && (child.hooks || child.descendantHooks)) { | |
descendantHooks = true | |
} | |
} else if (!hasWidgets && isWidget(child)) { | |
if (typeof child.destroy === "function") { | |
hasWidgets = true | |
} | |
} else if (!hasThunks && isThunk(child)) { | |
hasThunks = true; | |
} | |
} | |
this.count = count + descendants | |
this.hasWidgets = hasWidgets | |
this.hasThunks = hasThunks | |
this.hooks = hooks | |
this.descendantHooks = descendantHooks | |
} | |
VirtualNode.prototype.version = version | |
VirtualNode.prototype.type = "VirtualNode" | |
},{"./is-thunk":25,"./is-vhook":26,"./is-vnode":27,"./is-widget":29,"./version":30}],32:[function(require,module,exports){ | |
var version = require("./version") | |
VirtualPatch.NONE = 0 | |
VirtualPatch.VTEXT = 1 | |
VirtualPatch.VNODE = 2 | |
VirtualPatch.WIDGET = 3 | |
VirtualPatch.PROPS = 4 | |
VirtualPatch.ORDER = 5 | |
VirtualPatch.INSERT = 6 | |
VirtualPatch.REMOVE = 7 | |
VirtualPatch.THUNK = 8 | |
module.exports = VirtualPatch | |
function VirtualPatch(type, vNode, patch) { | |
this.type = Number(type) | |
this.vNode = vNode | |
this.patch = patch | |
} | |
VirtualPatch.prototype.version = version | |
VirtualPatch.prototype.type = "VirtualPatch" | |
},{"./version":30}],33:[function(require,module,exports){ | |
var version = require("./version") | |
module.exports = VirtualText | |
function VirtualText(text) { | |
this.text = String(text) | |
} | |
VirtualText.prototype.version = version | |
VirtualText.prototype.type = "VirtualText" | |
},{"./version":30}],34:[function(require,module,exports){ | |
var isObject = require("is-object") | |
var isHook = require("../vnode/is-vhook") | |
module.exports = diffProps | |
function diffProps(a, b) { | |
var diff | |
for (var aKey in a) { | |
if (!(aKey in b)) { | |
diff = diff || {} | |
diff[aKey] = undefined | |
} | |
var aValue = a[aKey] | |
var bValue = b[aKey] | |
if (aValue === bValue) { | |
continue | |
} else if (isObject(aValue) && isObject(bValue)) { | |
if (getPrototype(bValue) !== getPrototype(aValue)) { | |
diff = diff || {} | |
diff[aKey] = bValue | |
} else if (isHook(bValue)) { | |
diff = diff || {} | |
diff[aKey] = bValue | |
} else { | |
var objectDiff = diffProps(aValue, bValue) | |
if (objectDiff) { | |
diff = diff || {} | |
diff[aKey] = objectDiff | |
} | |
} | |
} else { | |
diff = diff || {} | |
diff[aKey] = bValue | |
} | |
} | |
for (var bKey in b) { | |
if (!(bKey in a)) { | |
diff = diff || {} | |
diff[bKey] = b[bKey] | |
} | |
} | |
return diff | |
} | |
function getPrototype(value) { | |
if (Object.getPrototypeOf) { | |
return Object.getPrototypeOf(value) | |
} else if (value.__proto__) { | |
return value.__proto__ | |
} else if (value.constructor) { | |
return value.constructor.prototype | |
} | |
} | |
},{"../vnode/is-vhook":26,"is-object":11}],35:[function(require,module,exports){ | |
var isArray = require("x-is-array") | |
var VPatch = require("../vnode/vpatch") | |
var isVNode = require("../vnode/is-vnode") | |
var isVText = require("../vnode/is-vtext") | |
var isWidget = require("../vnode/is-widget") | |
var isThunk = require("../vnode/is-thunk") | |
var handleThunk = require("../vnode/handle-thunk") | |
var diffProps = require("./diff-props") | |
module.exports = diff | |
function diff(a, b) { | |
var patch = { a: a } | |
walk(a, b, patch, 0) | |
return patch | |
} | |
function walk(a, b, patch, index) { | |
if (a === b) { | |
return | |
} | |
var apply = patch[index] | |
var applyClear = false | |
if (isThunk(a) || isThunk(b)) { | |
thunks(a, b, patch, index) | |
} else if (b == null) { | |
// If a is a widget we will add a remove patch for it | |
// Otherwise any child widgets/hooks must be destroyed. | |
// This prevents adding two remove patches for a widget. | |
if (!isWidget(a)) { | |
clearState(a, patch, index) | |
apply = patch[index] | |
} | |
apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b)) | |
} else if (isVNode(b)) { | |
if (isVNode(a)) { | |
if (a.tagName === b.tagName && | |
a.namespace === b.namespace && | |
a.key === b.key) { | |
var propsPatch = diffProps(a.properties, b.properties) | |
if (propsPatch) { | |
apply = appendPatch(apply, | |
new VPatch(VPatch.PROPS, a, propsPatch)) | |
} | |
apply = diffChildren(a, b, patch, apply, index) | |
} else { | |
apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b)) | |
applyClear = true | |
} | |
} else { | |
apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b)) | |
applyClear = true | |
} | |
} else if (isVText(b)) { | |
if (!isVText(a)) { | |
apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b)) | |
applyClear = true | |
} else if (a.text !== b.text) { | |
apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b)) | |
} | |
} else if (isWidget(b)) { | |
if (!isWidget(a)) { | |
applyClear = true | |
} | |
apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b)) | |
} | |
if (apply) { | |
patch[index] = apply | |
} | |
if (applyClear) { | |
clearState(a, patch, index) | |
} | |
} | |
function diffChildren(a, b, patch, apply, index) { | |
var aChildren = a.children | |
var orderedSet = reorder(aChildren, b.children) | |
var bChildren = orderedSet.children | |
var aLen = aChildren.length | |
var bLen = bChildren.length | |
var len = aLen > bLen ? aLen : bLen | |
for (var i = 0; i < len; i++) { | |
var leftNode = aChildren[i] | |
var rightNode = bChildren[i] | |
index += 1 | |
if (!leftNode) { | |
if (rightNode) { | |
// Excess nodes in b need to be added | |
apply = appendPatch(apply, | |
new VPatch(VPatch.INSERT, null, rightNode)) | |
} | |
} else { | |
walk(leftNode, rightNode, patch, index) | |
} | |
if (isVNode(leftNode) && leftNode.count) { | |
index += leftNode.count | |
} | |
} | |
if (orderedSet.moves) { | |
// Reorder nodes last | |
apply = appendPatch(apply, new VPatch( | |
VPatch.ORDER, | |
a, | |
orderedSet.moves | |
)) | |
} | |
return apply | |
} | |
function clearState(vNode, patch, index) { | |
// TODO: Make this a single walk, not two | |
unhook(vNode, patch, index) | |
destroyWidgets(vNode, patch, index) | |
} | |
// Patch records for all destroyed widgets must be added because we need | |
// a DOM node reference for the destroy function | |
function destroyWidgets(vNode, patch, index) { | |
if (isWidget(vNode)) { | |
if (typeof vNode.destroy === "function") { | |
patch[index] = appendPatch( | |
patch[index], | |
new VPatch(VPatch.REMOVE, vNode, null) | |
) | |
} | |
} else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) { | |
var children = vNode.children | |
var len = children.length | |
for (var i = 0; i < len; i++) { | |
var child = children[i] | |
index += 1 | |
destroyWidgets(child, patch, index) | |
if (isVNode(child) && child.count) { | |
index += child.count | |
} | |
} | |
} else if (isThunk(vNode)) { | |
thunks(vNode, null, patch, index) | |
} | |
} | |
// Create a sub-patch for thunks | |
function thunks(a, b, patch, index) { | |
var nodes = handleThunk(a, b) | |
var thunkPatch = diff(nodes.a, nodes.b) | |
if (hasPatches(thunkPatch)) { | |
patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch) | |
} | |
} | |
function hasPatches(patch) { | |
for (var index in patch) { | |
if (index !== "a") { | |
return true | |
} | |
} | |
return false | |
} | |
// Execute hooks when two nodes are identical | |
function unhook(vNode, patch, index) { | |
if (isVNode(vNode)) { | |
if (vNode.hooks) { | |
patch[index] = appendPatch( | |
patch[index], | |
new VPatch( | |
VPatch.PROPS, | |
vNode, | |
undefinedKeys(vNode.hooks) | |
) | |
) | |
} | |
if (vNode.descendantHooks || vNode.hasThunks) { | |
var children = vNode.children | |
var len = children.length | |
for (var i = 0; i < len; i++) { | |
var child = children[i] | |
index += 1 | |
unhook(child, patch, index) | |
if (isVNode(child) && child.count) { | |
index += child.count | |
} | |
} | |
} | |
} else if (isThunk(vNode)) { | |
thunks(vNode, null, patch, index) | |
} | |
} | |
function undefinedKeys(obj) { | |
var result = {} | |
for (var key in obj) { | |
result[key] = undefined | |
} | |
return result | |
} | |
// List diff, naive left to right reordering | |
function reorder(aChildren, bChildren) { | |
// O(M) time, O(M) memory | |
var bChildIndex = keyIndex(bChildren) | |
var bKeys = bChildIndex.keys | |
var bFree = bChildIndex.free | |
if (bFree.length === bChildren.length) { | |
return { | |
children: bChildren, | |
moves: null | |
} | |
} | |
// O(N) time, O(N) memory | |
var aChildIndex = keyIndex(aChildren) | |
var aKeys = aChildIndex.keys | |
var aFree = aChildIndex.free | |
if (aFree.length === aChildren.length) { | |
return { | |
children: bChildren, | |
moves: null | |
} | |
} | |
// O(MAX(N, M)) memory | |
var newChildren = [] | |
var freeIndex = 0 | |
var freeCount = bFree.length | |
var deletedItems = 0 | |
// Iterate through a and match a node in b | |
// O(N) time, | |
for (var i = 0 ; i < aChildren.length; i++) { | |
var aItem = aChildren[i] | |
var itemIndex | |
if (aItem.key) { | |
if (bKeys.hasOwnProperty(aItem.key)) { | |
// Match up the old keys | |
itemIndex = bKeys[aItem.key] | |
newChildren.push(bChildren[itemIndex]) | |
} else { | |
// Remove old keyed items | |
itemIndex = i - deletedItems++ | |
newChildren.push(null) | |
} | |
} else { | |
// Match the item in a with the next free item in b | |
if (freeIndex < freeCount) { | |
itemIndex = bFree[freeIndex++] | |
newChildren.push(bChildren[itemIndex]) | |
} else { | |
// There are no free items in b to match with | |
// the free items in a, so the extra free nodes | |
// are deleted. | |
itemIndex = i - deletedItems++ | |
newChildren.push(null) | |
} | |
} | |
} | |
var lastFreeIndex = freeIndex >= bFree.length ? | |
bChildren.length : | |
bFree[freeIndex] | |
// Iterate through b and append any new keys | |
// O(M) time | |
for (var j = 0; j < bChildren.length; j++) { | |
var newItem = bChildren[j] | |
if (newItem.key) { | |
if (!aKeys.hasOwnProperty(newItem.key)) { | |
// Add any new keyed items | |
// We are adding new items to the end and then sorting them | |
// in place. In future we should insert new items in place. | |
newChildren.push(newItem) | |
} | |
} else if (j >= lastFreeIndex) { | |
// Add any leftover non-keyed items | |
newChildren.push(newItem) | |
} | |
} | |
var simulate = newChildren.slice() | |
var simulateIndex = 0 | |
var removes = [] | |
var inserts = [] | |
var simulateItem | |
for (var k = 0; k < bChildren.length;) { | |
var wantedItem = bChildren[k] | |
simulateItem = simulate[simulateIndex] | |
// remove items | |
while (simulateItem === null && simulate.length) { | |
removes.push(remove(simulate, simulateIndex, null)) | |
simulateItem = simulate[simulateIndex] | |
} | |
if (!simulateItem || simulateItem.key !== wantedItem.key) { | |
// if we need a key in this position... | |
if (wantedItem.key) { | |
if (simulateItem && simulateItem.key) { | |
// if an insert doesn't put this key in place, it needs to move | |
if (bKeys[simulateItem.key] !== k + 1) { | |
removes.push(remove(simulate, simulateIndex, simulateItem.key)) | |
simulateItem = simulate[simulateIndex] | |
// if the remove didn't put the wanted item in place, we need to insert it | |
if (!simulateItem || simulateItem.key !== wantedItem.key) { | |
inserts.push({key: wantedItem.key, to: k}) | |
} | |
// items are matching, so skip ahead | |
else { | |
simulateIndex++ | |
} | |
} | |
else { | |
inserts.push({key: wantedItem.key, to: k}) | |
} | |
} | |
else { | |
inserts.push({key: wantedItem.key, to: k}) | |
} | |
k++ | |
} | |
// a key in simulate has no matching wanted key, remove it | |
else if (simulateItem && simulateItem.key) { | |
removes.push(remove(simulate, simulateIndex, simulateItem.key)) | |
} | |
} | |
else { | |
simulateIndex++ | |
k++ | |
} | |
} | |
// remove all the remaining nodes from simulate | |
while(simulateIndex < simulate.length) { | |
simulateItem = simulate[simulateIndex] | |
removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key)) | |
} | |
// If the only moves we have are deletes then we can just | |
// let the delete patch remove these items. | |
if (removes.length === deletedItems && !inserts.length) { | |
return { | |
children: newChildren, | |
moves: null | |
} | |
} | |
return { | |
children: newChildren, | |
moves: { | |
removes: removes, | |
inserts: inserts | |
} | |
} | |
} | |
function remove(arr, index, key) { | |
arr.splice(index, 1) | |
return { | |
from: index, | |
key: key | |
} | |
} | |
function keyIndex(children) { | |
var keys = {} | |
var free = [] | |
var length = children.length | |
for (var i = 0; i < length; i++) { | |
var child = children[i] | |
if (child.key) { | |
keys[child.key] = i | |
} else { | |
free.push(i) | |
} | |
} | |
return { | |
keys: keys, // A hash of key name to index | |
free: free // An array of unkeyed item indices | |
} | |
} | |
function appendPatch(apply, patch) { | |
if (apply) { | |
if (isArray(apply)) { | |
apply.push(patch) | |
} else { | |
apply = [apply, patch] | |
} | |
return apply | |
} else { | |
return patch | |
} | |
} | |
},{"../vnode/handle-thunk":24,"../vnode/is-thunk":25,"../vnode/is-vnode":27,"../vnode/is-vtext":28,"../vnode/is-widget":29,"../vnode/vpatch":32,"./diff-props":34,"x-is-array":12}]},{},[4])(4) | |
}); | |
coconut_ui_tools_Compare.END = new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Noise.Noise)); | |
coconut_ui_tools_ViewCache.stack = []; | |
haxe_ds_ObjectMap.count = 0; | |
js_Boot.__toStr = ({ }).toString; | |
tink_core_FutureTrigger.depth = 0; | |
tink_pure__$List_Node.EMPTY = []; | |
tink_state__$Observable_Observable_$Impl_$.stack = new List(); | |
tink_state__$Observable_Observable_$Impl_$.scheduled = []; | |
tink_state__$Observable_Observable_$Impl_$.hasRAF = typeof window != 'undefined' && 'requestAnimationFrame' in window; | |
tink_state_ConstObservable.NEVER = (function($this) { | |
var $r; | |
var this1 = new tink_core__$Future_SimpleFuture(function(_) { | |
return null; | |
}); | |
$r = this1; | |
return $r; | |
}(this)); | |
vdom__$Attr_Key_$Impl_$.keygen = 0; | |
TodoMvc.main(); | |
})(typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment