bungee
Version:
Bungee is a declarative language engine to run inside a browser. The node module contains the offline compiler.
2 lines • 103 kB
JavaScript
(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){(function(){"use strict";var Bungee=require("./index.js");window.Bungee=Bungee})()},{"./index.js":2}],3:[function(require,module,exports){},{}],2:[function(require,module,exports){"use strict";var fs=require("fs");module.exports=function(){var ret={};ret.Tokenizer=require("./src/tokenizer.js");ret.Compiler=require("./src/compiler.js");ret.Engine=require("./src/engine.js");ret.Elements=require("./src/dom.js");ret.Animation=require("./src/animation.js");function mixin(obj){for(var e in obj){if(obj.hasOwnProperty(e)){ret[e]=obj[e]}}}mixin(ret.Engine);mixin(ret.Elements);mixin(ret.Animation);ret.compileFile=function(file,options,callback){fs.readFile(file,"utf8",function(error,data){if(error){callback(error)}else{ret.compile(data,options,callback)}})};ret.compile=function(source,options,callback){var tokens=ret.Tokenizer.parse(source);ret.Compiler.compileAndRender(tokens,options,function(error,result){callback(error,result)})};ret.debug=false;ret.verbose=false;function ensureEngine(engine){if(!engine){console.log("[Bungee] Using default engine with DOM renderer.");engine=new ret.Engine(new ret.RendererDOM)}return engine}ret.jump=function(engine){engine=ensureEngine(engine);ret.useQueryFlags();ret.compileScriptTags(engine);engine.start()};ret.useQueryFlags=function(){ret.verbose=window.location.href.indexOf("verbose")>=0;ret.debug=window.location.href.indexOf("debug")>=0};ret.compileScriptTagElement=function(engine,script){engine=ensureEngine(engine);var tokens=ret.Tokenizer.parse(script.text);var moduleName=script.attributes.module&&script.attributes.module.textContent;var o,n;ret.Compiler.compileAndRender(tokens,{module:moduleName},function(error,result){if(error){console.error("Bungee compile error: "+error.line+": "+error.message);console.error(" -- "+error.context)}else{if(ret.verbose||ret.debug){console.log("----------------------");console.log(result);console.log("----------------------");console.log("eval...");o=new Date}if(result.indexOf("module.exports = ")===0){if(!ret.Modules){ret.Modules={}}result=result.replace("module.exports = ","Bungee.Modules."+moduleName+" = ");eval(result)}else{var tmp=eval(result);tmp(Bungee,engine)}if(ret.verbose||ret.debug){n=new Date;console.log("done, eval took time: ",n-o,"ms")}}})};ret.compileScriptTags=function(engine,dom){engine=ensureEngine(engine);for(var i=0;i<window.document.scripts.length;++i){var script=window.document.scripts[i];if(script.type==="text/jmp"||script.type==="text/jump"){ret.compileScriptTagElement(engine,script)}}};return ret}()},{"./src/animation.js":8,"./src/compiler.js":5,"./src/dom.js":7,"./src/engine.js":6,"./src/tokenizer.js":4,fs:3}],5:[function(require,module,exports){(function(){"use strict";if(!Bungee){var Bungee={}}var compiler=function(){var compiler={};var ELEM_PREFIX="e";var ELEM_NS="Bungee.";var ENGINE_VAR="BungeeEngine";var output;var index;var errorCodes={GENERIC:0,UNKNOWN_ELEMENT:1,NO_PROPERTY:2,NO_ELEMENTTYPE:3,NO_TYPENAME:4,NO_EXPRESSION:5,NO_COLON:6,INVALID_PROPERTY_NAME:7,UNEXPECTED_END:8};compiler.errorCodes=errorCodes;var errorMessages=[];errorMessages[errorCodes.GENERIC]="generic error";errorMessages[errorCodes.UNKNOWN_ELEMENT]="Cannot create element.";errorMessages[errorCodes.NO_PROPERTY]="No property to assing expression.";errorMessages[errorCodes.NO_ELEMENTTYPE]="No type to create an element.";errorMessages[errorCodes.NO_TYPENAME]="No typename for the new type definition.";errorMessages[errorCodes.NO_COLON]="Property must be followed by a ':'.";errorMessages[errorCodes.NO_EXPRESSION]="No right-hand-side expression or element found.";errorMessages[errorCodes.INVALID_PROPERTY_NAME]="Invalid property name found.";errorMessages[errorCodes.UNEXPECTED_END]="Unexpected end of input.";function error(code,token){var ret={};ret.code=code;ret.context=token?token.CONTEXT:undefined;ret.message=errorMessages[code];ret.line=token?token.LINE:-1;return ret}function log(msg){if(Bungee.verbose){console.log(msg)}}function isNumeric(c){return c>="0"&&c<="9"}function addIndentation(additional){var indentLevel=index+(additional?additional:0);var i;for(i=indentLevel;i;--i){output+=" "}}function renderBegin(options){if(options.module){output+="module.exports = function (Bungee, "+ENGINE_VAR+") {\n"}else{output+="(function () { return function (Bungee, "+ENGINE_VAR+") {\n"}addIndentation();output+="'use strict';\n\n";if(Bungee.debug){addIndentation(1);output+="debugger;\n"}addIndentation();output+="var "+ELEM_PREFIX+" = { \n";addIndentation(1);output+="children: [],\n";addIndentation(1);output+="addChild: function(child) {\n";addIndentation(2);output+="this[child.id] = child;\n";addIndentation(2);output+="for (var i in this.children) {\n";addIndentation(2);output+=" if (this.children.hasOwnProperty(i)) {\n";addIndentation(2);output+=" this.children[i][child.id] = child;\n";addIndentation(2);output+=" child[this.children[i].id] = this.children[i];\n";addIndentation(2);output+=" }\n";addIndentation(2);output+="}\n";addIndentation(2);output+=ELEM_PREFIX+".children.push(child);\n";addIndentation(2);output+=ENGINE_VAR+".addElement(child);\n";addIndentation(2);output+="return child;\n";addIndentation(1);output+="},\n";addIndentation(1);output+="initializeBindings: function() {\n";addIndentation(2);output+="for (var i = 0; i < "+ELEM_PREFIX+".children.length; ++i) { "+ELEM_PREFIX+".children[i].initializeBindings(); }\n";addIndentation(1);output+="},\n";addIndentation(1);output+="render: function() {\n";addIndentation(2);output+="for (var i = 0; i < "+ELEM_PREFIX+".children.length; ++i) { "+ELEM_PREFIX+".children[i].render(); }\n";addIndentation(1);output+="}\n";addIndentation();output+="};\n\n"}function renderEnd(options){addIndentation();output+=ELEM_PREFIX+".initializeBindings();\n";addIndentation();output+=ELEM_PREFIX+".render();\n";if(options.module){addIndentation();output+="return "+ELEM_PREFIX+";\n";output+="};\n"}else{addIndentation();output+="};\n";output+="})();\n"}}function renderBeginElement(type,id){addIndentation();output+=ELEM_PREFIX+".addChild((function() {\n";++index;addIndentation();output+="var "+ELEM_PREFIX+" = new "+ELEM_NS+type+"(";output+=ENGINE_VAR;output+=id?', "'+id+'"':"";output+=");\n"}function renderEndElement(){addIndentation();output+="return "+ELEM_PREFIX+";\n";--index;addIndentation();output+="})());\n"}function renderBeginType(type,inheritedType){addIndentation();output+=ELEM_NS+type+" = function (engine, id, parent) {\n";++index;addIndentation();output+="var "+ELEM_PREFIX+" = new "+ELEM_NS+inheritedType+"(engine, id, parent);\n"}function renderEndType(){addIndentation();output+="return "+ELEM_PREFIX+";\n";--index;addIndentation();output+="};\n"}function renderEventHandler(property,value){addIndentation();output+=ELEM_PREFIX+'.addEventHandler("'+property+'", ';output+="function () {\n";addIndentation();output+=value+"\n";addIndentation();output+="});\n"}function renderFunction(property,value){var name=property.slice(property.indexOf(" ")+1,property.indexOf("("));var args=property.slice(property.indexOf("(")+1,-1);addIndentation();output+=ELEM_PREFIX+'.addFunction("'+name+'", ';output+="function ("+args+") {\n";addIndentation();output+=value+"\n";addIndentation();output+="});\n"}function renderProperty(property,value){if(property==="id"){return}if(property.indexOf("on")===0){renderEventHandler(property,value);return}if(property.indexOf("(")!==-1){renderFunction(property,value);return}addIndentation();output+=ELEM_PREFIX+'.addProperty("'+property+'", ';output+="function () {";if(String(value).indexOf("return")!==-1){output+=value+" "}else{output+="return "+value+";"}output+="});\n"}function renderDelegate(property,value){addIndentation();output+=ELEM_PREFIX+".create"+property+" = function () {\n";addIndentation(1);output+="return new "+ELEM_NS+value+"("+ENGINE_VAR+");\n";addIndentation();output+="}\n"}function renderTreeObject(tree){var i;if(tree.typeDefinition){renderBeginType(tree.typeDefinition,tree.type)}else{renderBeginElement(tree.type,tree.id)}for(i=0;i<tree.properties.length;++i){renderProperty(tree.properties[i].name,tree.properties[i].value)}for(i=0;i<tree.delegates.length;++i){renderDelegate(tree.delegates[i].name,tree.delegates[i].value)}for(i=0;i<tree.types.length;++i){renderTreeObject(tree.types[i])}for(i=0;i<tree.elements.length;++i){renderTreeObject(tree.elements[i])}if(tree.typeDefinition){renderEndType()}else{renderEndElement()}}compiler.renderTree=function(tree,options,callback){var i;index=1;output="";renderBegin(options);for(i=0;i<tree.types.length;++i){renderTreeObject(tree.types[i])}for(i=0;i<tree.elements.length;++i){renderTreeObject(tree.elements[i])}renderEnd(options);callback(null,output)};function dumpObjectTree(tree,indent){var i;if(indent===undefined){indent=0}function niceLog(msg){var j;var out="";for(j=0;j<indent;++j){out+=" "}console.log(out+msg)}niceLog("+ Element:");niceLog("|- type: "+tree.type);niceLog("|- type definition: "+tree.typeDefinition);niceLog("|+ Properties:");for(i=0;i<tree.properties.length;++i){niceLog("|--> "+tree.properties[i].name)}niceLog("|+ Delegates:");for(i=0;i<tree.delegates.length;++i){niceLog("|--> "+tree.delegates[i].name+" : "+tree.delegates[i].value)}if(tree.types.length){niceLog("|+ Types:");for(i=0;i<tree.types.length;++i){dumpObjectTree(tree.types[i],indent+2)}}if(tree.elements.length){niceLog("|+ Elements: ");for(i=0;i<tree.elements.length;++i){dumpObjectTree(tree.elements[i],indent+2)}}}compiler.createObjectTree=function(tok,options,callback){var property;var tokens=tok;var token_length=tokens.length;var elementType;var elementTypeDefinition;var i,j;var TreeObject=function(parent){this.id=undefined;this.type=undefined;this.typeDefinition=undefined;this.parent=parent;this.types=[];this.elements=[];this.properties=[];this.delegates=[]};var objectTreeRoot=new TreeObject;objectTreeRoot.type="RootObject";var objectTree=objectTreeRoot;for(i=0;i<token_length;i+=1){var token=tokens[i];if(token.TOKEN==="IS_A"){if(elementType){elementTypeDefinition=elementType;elementType=undefined}else{callback(error(errorCodes.NO_TYPENAME,token),null);return}}if(token.TOKEN==="ELEMENT"){elementType=token.DATA}if(token.TOKEN==="SCOPE_START"){log("start element description");if(elementType){var tmp=new TreeObject(objectTree);tmp.type=elementType;if(elementTypeDefinition){tmp.typeDefinition=elementTypeDefinition;objectTree.types.push(tmp)}else{objectTree.elements.push(tmp)}objectTree=tmp;elementType=undefined;elementTypeDefinition=undefined}else{callback(error(errorCodes.NO_ELEMENTTYPE,token),null)}}if(token.TOKEN==="SCOPE_END"){log("end element description");objectTree=objectTree.parent}if(token.TOKEN==="EXPRESSION"){var next_token=i+1<token_length?tokens[i+1]:undefined;if(next_token&&next_token.TOKEN==="COLON"){property=token.DATA;log("property found '"+property+"'");if(isNumeric(property[0])){log("property name '"+property+"' is invalid.");callback(error(errorCodes.INVALID_PROPERTY_NAME,token),null);return}i+=1;next_token=undefined}else{callback(error(errorCodes.NO_COLON,token),null);return}next_token=i+1<token_length?tokens[i+1]:undefined;if(next_token&&next_token.TOKEN==="EXPRESSION"){log("right-hand-side expression found for property '"+property+"' '"+next_token.DATA+"'");if(property==="id"){objectTree.id=next_token.DATA}else{objectTree.properties.push({name:property,value:next_token.DATA})}i+=1;property=undefined}else if(next_token&&next_token.TOKEN==="ELEMENT"){log("right-hand-side element found for property",property,next_token.DATA);objectTree.delegates.push({name:property,value:next_token.DATA});i+=1;property=undefined}else{callback(error(errorCodes.NO_EXPRESSION,next_token),null);return}}}if(objectTree!==objectTreeRoot){callback(error(errorCodes.UNEXPECTED_END,null),null);return}callback(null,objectTreeRoot)};compiler.compileAndRender=function(tok,options,callback){compiler.createObjectTree(tok,options,function(error,result){if(error){callback(error,null);return}if(options.dump){dumpObjectTree(result)}compiler.renderTree(result,options,callback)})};return compiler}();module.exports=compiler})()},{}],6:[function(require,module,exports){"use strict";var ret={};function Engine(renderer){this.getterCalled={};this._dirtyElements={};this.renderer=renderer;this.verbose=false;this._elementIndex=0;this.createElement=renderer.createElement;this.addElement=renderer.addElement;this.addElements=renderer.addElements;this.renderElement=renderer.renderElement;this.removeElement=renderer.removeElement;this.maybeReportGetterCalled=function(){};this.renderInterval=undefined;this.fps={};this.fps.d=Date.now();this.fps.l=0}Engine.prototype.log=function(msg,error){if(this.verbose||error){console.log("[Bungee.Engine] "+msg)}};Engine.prototype.enterMagicBindingState=function(){var that=this;this.log("enterMagicBindingState");this.getterCalled={};this.maybeReportGetterCalled=function(silent,name){if(!silent){that.addCalledGetter(this,name)}}};Engine.prototype.exitMagicBindingState=function(){this.log("exitMagicBindingState\n\n");this.maybeReportGetterCalled=function(){};return this.getterCalled};Engine.prototype.start=function(){var that=this;this.renderInterval=window.setInterval(function(){that.advance()},1e3/60)};Engine.prototype.stop=function(){window.clearInterval(this.renderInterval)};Engine.prototype.dirty=function(element,property){if(property[0]==="_"){return}element._dirtyProperties[property]=true;if(!this._dirtyElements[element._internalIndex]){this._dirtyElements[element._internalIndex]=element}};Engine.prototype.addCalledGetter=function(element,property){this.getterCalled[element.id+"."+property]={element:element,property:property}};Engine.prototype.advance=function(){var keys=Object.keys(this._dirtyElements);var keys_length=keys.length;for(var i=0;i<keys_length;++i){this._dirtyElements[keys[i]].render()}this._dirtyElements={};if(this.verbose){var fps=this.fps;if(Date.now()-fps.d>=2e3){console.log("FPS: "+fps.l/2);fps.d=Date.now();fps.l=0}else{++fps.l}}};function Element(engine,id,parent,typeHint){console.assert(engine instanceof Engine);this.engine=engine;this.id=id;this.typeHint=typeHint;this.parent=parent;if(typeHint!=="object"){this.element=this.engine.createElement(typeHint,this)}else{this.element=null}this._internalIndex=this.engine._elementIndex++;this._dirtyProperties={};this._properties={};this._connections={};this._children={};this._bound={};this._isInitialized=false;this._initializeBindingsStep=false;if(this.parent){this.parent.addChild(this)}}Element.prototype.children=function(){this.engine.maybeReportGetterCalled.call(this,false,"children");return this._children};Element.prototype.removeChild=function(child){this.engine.removeElement(child,this);delete this._children[child._internalIndex];this.emit("children")};Element.prototype.removeChildren=function(){for(var i in this._children){if(this._children.hasOwnProperty(i)){this.engine.removeElement(this._children[i],this)}}this._children={};this.emit("children")};Element.prototype.addChild=function(child){if(child.id)this[child.id]=child;if(this.id)child[this.id]=this;for(var i in this._children){if(this._children.hasOwnProperty(i)){if(child.id)this._children[i][child.id]=child;if(this._children[i].id)child[this._children[i].id]=this._children[i]}}this._children[child._internalIndex]=child;child.parent=this;this.engine.addElement(child,this);this.emit("children");return child};Element.prototype.render=function(){this.engine.renderElement(this)};Element.prototype.addChanged=function(signal,callback){if(!this._connections[signal]){this._connections[signal]=[]}this._connections[signal].push(callback)};Element.prototype.removeChanged=function(obj,signal){var signalConnections=this._connections[signal];if(!signalConnections){return}};Element.prototype.addBinding=function(name,value,property){var that=this;var hasBinding=false;var val,getters;var bindingFunction;this.engine.enterMagicBindingState();if(typeof value==="function"){val=value.apply(this);bindingFunction=function(){that[name]=value.apply(that)}}else if(typeof value==="object"&&typeof property!=="undefined"){val=value[property];bindingFunction=function(){that[name]=value[property]}}else{val=value}getters=this.engine.exitMagicBindingState();this.breakBindings(name);for(var getter in getters){if(getters.hasOwnProperty(getter)){var tmp=getters[getter];this._bound[name][this._bound[name].length]={element:tmp.element,property:tmp.property};tmp.element.addChanged(tmp.property,bindingFunction);hasBinding=true}}return{hasBindings:hasBinding,value:val}};Element.prototype.addEventHandler=function(event,handler){var that=this;var signal=event;if(signal===""||typeof handler!=="function"){return}if(signal.indexOf("on")===0){signal=signal.slice(2)}this.addChanged(signal,function(){if(!that._initializeBindingsStep)handler.apply(that)})};Element.prototype.breakBindings=function(name){if(this._bound[name]){for(var i=0;i<this._bound[name].length;++i){this._bound[name][i].element.removeChanged(this,name)}}this._bound[name]=[]};Element.prototype.setSilent=function(name,value){var setter=this.__lookupSetter__(name);if(typeof setter==="function"){setter.call(this,value,true)}};Element.prototype.getSilent=function(name){var getter=this.__lookupGetter__(name);if(typeof getter==="function"){return getter.call(this,true)}};Element.prototype.set=function(name,value){this.breakBindings(name);if(typeof value==="function"){var ret=this.addBinding(name,value);if(ret.hasBindings){this[name]=value}else{this[name]=ret.value}}else{this[name]=value}};Element.prototype.addFunction=function(name,value){this[name]=value};var defPropCount=0;var notdefPropCount=0;Element.prototype.addProperty=function(name,value){var that=this;var valueStore;this._properties[name]=value;if(!this.hasOwnProperty(name)){Object.defineProperty(this,name,{get:function(silent){this.engine.maybeReportGetterCalled.call(that,silent,name);if(typeof valueStore==="function")return valueStore.apply(that);return valueStore},set:function(val,silent){if(valueStore===val)return;valueStore=val;if(!silent){that.emit(name);that.emit("changed")}this.engine.dirty(that,name)}})}};Element.prototype.initializeBindings=function(options){var name,i;if(this._isInitialized){return}this._isInitialized=true;this._initializeBindingsStep=true;for(name in this._properties){if(this._properties.hasOwnProperty(name)){var value=this._properties[name];if(typeof value==="function"){var ret=this.addBinding(name,value);if(ret.hasBindings){this[name]=value}else{this[name]=ret.value}}else{this[name]=value}}}if(!options||!options.deferRender){this.render()}for(i in this._children){if(this._children.hasOwnProperty(i)){this._children[i].initializeBindings(options)}}this._initializeBindingsStep=false;this.emit("load")};Element.prototype.emit=function(signal){if(signal in this._connections){var slots=this._connections[signal];for(var i=0;i<slots.length;++i){slots[i].apply()}}};function Collection(engine,id,parent){var elem=new Element(engine,id,parent,"object");return elem}module.exports={Engine:Engine,Element:Element,Collection:Collection}},{}],7:[function(require,module,exports){(function(){"use strict";var Bungee=require("./engine.js");Bungee.Item=function(engine,id,parent,typeHint){var elem=new Bungee.Element(engine,id,parent,typeHint?typeHint:"item");elem.addProperty("className","");elem.addProperty("width",100);elem.addProperty("height",100);elem.addProperty("top",0);elem.addProperty("left",0);elem.addProperty("childrenWidth",function(){var left=0;var right=0;var kids=this.children();for(var i in kids){if(kids.hasOwnProperty(i)){var c=kids[i];if(c.left<left){left=c.left}if(c.left+c.width>right){right=c.left+c.width}}}return right-left});elem.addProperty("childrenHeight",function(){var top=0;var bottom=0;var kids=this.children();for(var i in kids){if(kids.hasOwnProperty(i)){var c=kids[i];if(c.top<top){top=c.top}if(c.top+c.height>bottom){bottom=c.top+c.height}}}return bottom-top});return elem};Bungee.InputItem=function(engine,id,parent){var elem=new Bungee.Item(engine,id,parent,"InputItem");elem.addProperty("width",function(){return this.parent?this.parent.width:100});elem.addProperty("height",function(){return this.parent?this.parent.height:100});elem.addProperty("mouseAbsX",0);elem.addProperty("mouseAbsY",0);elem.addProperty("mouseRelX",0);elem.addProperty("mouseRelY",0);elem.addProperty("mouseRelStartX",0);elem.addProperty("mouseRelStartY",0);elem.addProperty("mousePressed",false);elem.addProperty("containsMouse",false);elem.addProperty("scrollTop",0);elem.addProperty("scrollLeft",0);elem.addProperty("srollWidth",0);elem.addProperty("scrollHeight",0);return elem};var tmpTextElement;Bungee.Text=function(engine,id,parent){var elem=new Bungee.Item(engine,id,parent);elem.addProperty("mouseEnabled",false);elem.addProperty("textWidth",0);elem.addProperty("textHeight",0);elem.addProperty("fontSize","");elem.addProperty("fontFamily","");elem.addProperty("text","");elem.addProperty("-text",function(){return this.text});elem.addProperty("width",function(){return this.textWidth});elem.addProperty("height",function(){return this.textHeight});if(!tmpTextElement){tmpTextElement=window.document.createElement("div");tmpTextElement.style.position="absolute";tmpTextElement.style.visibility="hidden";tmpTextElement.style.width="auto";tmpTextElement.style.height="auto";tmpTextElement.style.left=-1e4;window.document.body.appendChild(tmpTextElement)}function relayout(){var tmpProperty=elem.text;var width=0;var height=0;tmpTextElement.style.fontSize=elem.fontSize;tmpTextElement.style.fontFamily=elem.fontFamily;if(tmpTextElement.innerHTML===tmpProperty){width=tmpTextElement.clientWidth+1;height=tmpTextElement.clientHeight+1}else if(tmpProperty!==""){tmpTextElement.innerHTML=tmpProperty;width=tmpTextElement.clientWidth+1;height=tmpTextElement.clientHeight+1}elem.textWidth=width;elem.textHeight=height}elem.addChanged("text",relayout);return elem};Bungee.Window=function(engine,id,parent){var elem=new Bungee.Element(engine,id,parent);elem.addProperty("innerWidth",window.innerWidth);elem.addProperty("innerHeight",window.innerHeight);elem.addProperty("width",function(){return this.innerWidth});elem.addProperty("height",function(){return this.innerHeight});elem.addEventHandler("load",function(){var that=this;window.addEventListener("resize",function(event){that.innerWidth=event.srcElement.innerWidth;that.innerHeight=event.srcElement.innerHeight})});return elem};Bungee.Rectangle=function(engine,id,parent){var elem=new Bungee.Item(engine,id,parent);elem.addProperty("backgroundColor","white");elem.addProperty("borderColor","black");elem.addProperty("borderStyle","solid");elem.addProperty("borderWidth",1);elem.addProperty("borderRadius",0);return elem};Bungee.BackgroundImage=function(engine,id,parent){var elem=new Bungee.Item(engine,id,parent);elem.addProperty("src","");elem.addProperty("backgroundImage",function(){if(!this.src){return""}if(this.src.indexOf("url('")===0){return this.src}return"url('"+this.src+"')"});elem.addProperty("backgroundPosition","center");elem.addProperty("backgroundRepeat","no-repeat");return elem};Bungee.Image=function(engine,id,parent){var elem=new Bungee.Item(engine,id,parent,"image");elem.addProperty("src","");elem.addProperty("-image-src",function(){return this.src});return elem};Bungee.Input=function(engine,id,parent){var elem=new Bungee.Item(engine,id,parent,"input");elem.addProperty("-webkit-user-select","auto");elem.addProperty("userSelect","auto");elem.addProperty("text",function(){return this.element.value});elem.addProperty("placeholder","");return elem};Bungee.RendererDOM=function(){this.currentMouseElement=undefined};Bungee.RendererDOM.prototype.createElement=function(typeHint,object){var elem;var that=this;if(typeHint==="input"){elem=document.createElement("input")}else if(typeHint==="image"){elem=document.createElement("img")}else{elem=document.createElement("div")}elem.style.position="absolute";if(object.id){elem.id=object.id}function handleTouchStartEvents(event){that.currentMouseElement=this;if(that.currentScrollElement){that.currentScrollElementTopStart=that.currentScrollElement.scrollTop;that.currentScrollElementLeftStart=that.currentScrollElement.scrollLeft}object.mousePressed=true;object.emit("mousedown")}function handleTouchEndEvents(event){object.mousePressed=false;object.mouseRelStartX=0;object.mouseRelStartY=0;object.emit("mouseup");if(that.currentMouseElement===this){object.emit("activated")}that.currentMouseElement=undefined}function handleTouchMoveEvents(event){object.mouseAbsX=event.clientX||event.targetTouches[0].clientX;object.mouseAbsY=event.clientY||event.targetTouches[0].clientY;object.mouseRelX=event.layerX||event.targetTouches[0].layerX;object.mouseRelY=event.layerY||event.targetTouches[0].layerY;object.emit("mousemove")}function handleMouseDownEvents(event){if(!event.used){that.currentMouseElement=this;event.used=true}object.mousePressed=true;object.mouseRelStartX=event.layerX;object.mouseRelStartY=event.layerY;object.emit("mousedown")}function handleMouseUpEvents(event){object.mousePressed=false;object.mouseRelStartX=0;object.mouseRelStartY=0;object.emit("mouseup");if(that.currentMouseElement===this){object.emit("activated")}that.currentMouseElement=undefined}function handleMouseMoveEvents(event){object.mouseAbsX=event.clientX;object.mouseAbsY=event.clientY;object.mouseRelX=event.layerX;object.mouseRelY=event.layerY;object.emit("mousemove")}function handleMouseOverEvents(event){object.containsMouse=true;object.emit("mouseover")}function handleMouseOutEvents(event){object.containsMouse=false;object.emit("mouseout")}function handleScrollEvents(event){if(that.currentScrollElement!==object){that.currentScrollElement=object;that.currentScrollElementTopStart=event.target.scrollTop;that.currentScrollElementLeftStart=event.target.scrollLeft}if(Math.abs(that.currentScrollElementTopStart-event.target.scrollTop)>20||Math.abs(that.currentScrollElementLeftStart-event.target.scrollLeft)>20){that.currentMouseElement=undefined}object.scrollTop=event.target.scrollTop;object.scrollLeft=event.target.scrollLeft;object.srollWidth=event.target.scrollWidth;object.scrollHeight=event.target.scrollHeight}elem.addEventListener("scroll",handleScrollEvents,false);if(typeHint==="InputItem"){if("ontouchstart"in document.documentElement){if(window.navigator.msPointerEnabled){elem.addEventListener("MSPointerDown",handleTouchStartEvents,false);elem.addEventListener("MSPointerMove",handleTouchMoveEvents,false);elem.addEventListener("MSPointerUp",handleTouchEndEvents,false)}else{elem.addEventListener("touchstart",handleTouchStartEvents,false);elem.addEventListener("touchmove",handleTouchMoveEvents,false);elem.addEventListener("touchend",handleTouchEndEvents,false)}}else{elem.addEventListener("mousedown",handleMouseDownEvents,false);elem.addEventListener("mouseup",handleMouseUpEvents,false);elem.addEventListener("mousemove",handleMouseMoveEvents,false);elem.addEventListener("mouseover",handleMouseOverEvents,false);elem.addEventListener("mouseout",handleMouseOutEvents,false)}}return elem};Bungee.RendererDOM.prototype.addElement=function(element,parent){if(!element.element){return}if(parent&&parent.element){parent.element.appendChild(element.element)}else{document.body.appendChild(element.element)}};Bungee.RendererDOM.prototype.removeElement=function(element,parent){if(!element.element){return}if(parent&&parent.element){parent.element.removeChild(element.element)}else{document.body.removeChild(element.element)}};Bungee.RendererDOM.prototype.addElements=function(elements,parent){var fragment=document.createDocumentFragment();for(var i=0;i<elements.length;++i){if(!elements[i].element){continue}fragment.appendChild(elements[i].element)}if(parent&&parent.element){parent.element.appendChild(fragment)}else{document.body.appendChild(fragment)}};Bungee.RendererDOM.prototype.renderElement=function(element){var name;if(!element.element){return}for(name in element._dirtyProperties){if(name==="className"&&element[name]!==""){element.element.className=element[name]}else if(name==="scale"){var s=element.scale.toFixed(10);var tmp="scale("+s+", "+s+")";element.element.style["-webkit-transform"]=tmp;element.element.style["transform"]=tmp}else if(name==="-text"){element.element.innerHTML=element[name]}else if(name==="-image-src"){element.element.src=element[name]}else if(name==="placeholder"){element.element.placeholder=element[name]}else{element.element.style[name]=element[name]}}element._dirtyProperties={}};module.exports=Bungee})()},{"./engine.js":6}],8:[function(require,module,exports){"use strict";var Bungee=require("./engine.js");Bungee._animationIndex=0;Bungee._debugAnimation=false;Bungee.Step=function(engine,id,parent){var elem=new Bungee.Element(engine,id,parent,"object");elem.addProperty("percentage",0);return elem};Bungee.Animation=function(engine,id,parent){var elem=new Bungee.Element(engine,id,parent,"object");var index=Bungee._animationIndex++;var dirty=true;var hasRules=false;var animationName="bungeeAnimation"+index;var keyFramesName="bungeeAnimationKeyFrames"+index;elem.addProperty("target",function(){return this.parent});elem.addProperty("duration",250);elem.addProperty("delay",0);elem.addProperty("loops",1);elem.addProperty("reverse",false);elem.addProperty("easing","ease");function animationStart(event){Bungee._debugAnimation&&console.log("start",event);elem.emit("started")}function animationIteration(event){Bungee._debugAnimation&&console.log("iteration",event)}function animationEnd(event){Bungee._debugAnimation&&console.log("end",event);elem.stop();elem.emit("finished")}function updateRules(){var rule1="";var rule2="";var rule3="";var rule4="";if(!Bungee._style){Bungee._style=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(Bungee._style)}if(hasRules){var tmpName="."+animationName;var i;for(i=0;i<Bungee._style.sheet.cssRules.length;++i){if(Bungee._style.sheet.cssRules[i].name===keyFramesName){Bungee._style.sheet.deleteRule(i);break}}for(i=0;i<Bungee._style.sheet.cssRules.length;++i){if(Bungee._style.sheet.cssRules[i].selectorText===tmpName){Bungee._style.sheet.deleteRule(i);break}}}rule1+="."+animationName+" {\n";rule1+=" animation: ";rule1+=keyFramesName+" ";rule1+=elem.duration+"ms ";rule1+=elem.easing+" ";rule1+=elem.delay+" ";rule1+=elem.loops+" ";rule1+=(elem.reverse?"alternate":"normal")+";\n";rule1+=" -webkit-animation: ";rule1+=keyFramesName+" ";rule1+=elem.duration+"ms ";rule1+=elem.easing+" ";rule1+=elem.delay+" ";rule1+=elem.loops+" ";rule1+=(elem.reverse?"alternate":"normal")+";\n";rule1+="}\n";rule2+="@keyframes "+keyFramesName+" { \n";rule3+="@-webkit-keyframes "+keyFramesName+" { \n";for(var j in elem.children()){var child=elem.children()[j];if(typeof child.percentage==="undefined"){continue}rule2+=" "+child.percentage+"% {\n";rule3+=" "+child.percentage+"% {\n";for(var property in child._properties){if(child.hasOwnProperty(property)&&property!=="percentage"){rule2+=" "+property+": "+child[property]+";\n";rule3+=" "+property+": "+child[property]+";\n"}}rule2+=" }\n";rule3+=" }\n"}rule2+="}\n";rule3+="}\n";Bungee._debugAnimation&&console.log("Bungee Animation rules:\n",rule2,rule3,rule1);try{Bungee._style.sheet.insertRule(rule3,Bungee._style.sheet.rules.length)}catch(e){Bungee._debugAnimation&&console.error("Bungee Animation rule",rule3,"could not be inserted.",e)}try{Bungee._style.sheet.insertRule(rule2,Bungee._style.sheet.rules.length)}catch(e){Bungee._debugAnimation&&console.error("Bungee Animation rule",rule2,"could not be inserted.",e)
}try{Bungee._style.sheet.insertRule(rule1,Bungee._style.sheet.rules.length)}catch(e){Bungee._debugAnimation&&console.error("Bungee Animation rule",rule1,"could not be inserted.",e)}hasRules=true}function addEventListeners(){elem._element=elem.target;if(elem._element&&elem._element.element){elem._element.element.addEventListener("webkitAnimationStart",animationStart,false);elem._element.element.addEventListener("webkitAnimationIteration",animationIteration,false);elem._element.element.addEventListener("webkitAnimationEnd",animationEnd,false)}}function markDirty(){dirty=true}elem.addChanged("target",addEventListeners);elem.addChanged("changed",markDirty);elem.start=function(){if(dirty){updateRules();dirty=false}if(elem._element)elem._element.className=animationName};elem.stop=function(){elem._element.className=""};elem.restart=function(){elem.stop();elem.start()};return elem};Bungee.Behavior=function(engine,id,parent){var elem=new Bungee.Element(engine,id,parent,"object");var index=Bungee._animationIndex++;var hasRules=false;var animationName="bungeeAnimation"+index;elem.addProperty("target",function(){return this.parent});function animationStart(event){Bungee._debugAnimation&&console.log("start",event);elem.emit("started")}function animationIteration(event){Bungee._debugAnimation&&console.log("iteration",event)}function animationEnd(event){Bungee._debugAnimation&&console.log("end",event);elem.stop();elem.emit("finished")}function updateRules(){var rule="";var rulepart="";var gotProperties=false;if(!Bungee._style){Bungee._style=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(Bungee._style)}if(hasRules){var tmpName="."+animationName;var i;for(i=0;i<Bungee._style.sheet.cssRules.length;++i){if(Bungee._style.sheet.cssRules[i].selectorText===tmpName){Bungee._style.sheet.deleteRule(i);break}}}if(elem._properties.length===0){return}for(var property in elem._properties){if(elem.hasOwnProperty(property)&&property!=="target"){if(gotProperties){rulepart+=", "}else{gotProperties=true}rulepart+=property+" "+elem[property]}}rule+="."+animationName+" {\n";rule+=" -webkit-transition: "+rulepart+";\n";rule+=" transition: "+rulepart+";\n";rule+="}\n";if(gotProperties&&rule.indexOf("undefined")===-1){Bungee._debugAnimation&&console.log("Bungee Behavior rule",rule);try{Bungee._style.sheet.insertRule(rule,Bungee._style.sheet.rules.length)}catch(e){Bungee._debugAnimation&&console.error("Bungee Animation rule",rule,"could not be inserted.",e)}hasRules=true}}function addEventListeners(){elem._element=elem.target;if(elem._element&&elem._element.element){elem._element.element.addEventListener("webkitAnimationStart",animationStart,false);elem._element.element.addEventListener("webkitAnimationIteration",animationIteration,false);elem._element.element.addEventListener("webkitAnimationEnd",animationEnd,false);elem._element.className=animationName}}elem.addChanged("target",addEventListeners);elem.addChanged("changed",updateRules);return elem}},{"./engine.js":6}],4:[function(require,module,exports){"use strict";var esprima=require("esprima");if(!Bungee){var Bungee={}}var tokenizer=function(){var c,i,line,tokens,bindings,exp,colonOnLine,comment,lineContext;var ret={};function log(msg){if(Bungee.verbose){console.log(msg)}}function addToken(type,data){tokens.push({TOKEN:type,DATA:data,LINE:line,CONTEXT:lineContext})}function parseElementName(){var token="";while(c){if(c==="\n"){i-=1;break}if(c>="A"&&c<="Z"||c>="a"&&c<="z"||c>="0"&&c<="9"||c==="_"||c==="-")token+=c;else break;advance()}if(token[token.length-1]===";"){token=token.substring(0,token.length-1)}return token}function parseExpression(){var expression="";while(c){if(c==="\n"){i-=1;break}if(!colonOnLine&&c===":"){i-=1;break}expression+=c;advance()}if(expression[expression.length-1]===";"){expression=expression.substring(0,expression.length-1)}return expression}function parseInlineBlock(){var block="";var script;while(c){block+=c;if(c==="}"){try{script=esprima.parse(block,{tolerant:true});break}catch(e){var tmp="var a = "+block;try{script=esprima.parse(tmp,{tolerant:true});break}catch(e){}}}if(c==="\n"){++line}advance()}if(script&&script.body&&script.body[0]&&script.body[0].type==="BlockStatement"){block=block.trim();if(block[0]==="{"){block=block.slice(1)}if(block[block.length-1]==="}"){block=block.slice(0,block.length-1)}}return block}function advance(){c=exp[++i];return c}ret.parse=function(input){exp=input;i=-1;line=1;lineContext="";tokens=[];c=undefined;bindings=[];colonOnLine=false;comment=false;while(advance()){if(comment&&c!=="\n")continue;if(c==="/"&&exp[i+1]==="/"){comment=true;continue}if(c==="\n"){comment=false;colonOnLine=false;++line;lineContext="";var j=i;var tmpChar=exp[++j];while(tmpChar){if(tmpChar==="\n"){break}lineContext+=tmpChar;tmpChar=exp[++j]}continue}if(c>="A"&&c<="Z"){addToken("ELEMENT",parseElementName());continue}if(c>="a"&&c<="z"||c>="0"&&c<="9"||c==='"'||c==="'"||c==="("||c==="-"||c==="_"||c==="["){addToken("EXPRESSION",parseExpression());continue}if(c==="{"&&tokens[tokens.length-1].TOKEN==="ELEMENT"){addToken("SCOPE_START");continue}if(c==="{"){addToken("EXPRESSION",parseInlineBlock());continue}if(c==="}"){addToken("SCOPE_END");continue}if(c===":"){colonOnLine=true;addToken("COLON");continue}if(c==="@"){addToken("IS_A");continue}if(c===";"){colonOnLine=false;addToken("SEMICOLON");continue}}if(Bungee.verbose){ret.dumpTokens()}return tokens};ret.dumpTokens=function(){for(var i=0;i<tokens.length;++i)console.log("TOKEN: "+tokens[i].TOKEN+" "+(tokens[i].DATA?tokens[i].DATA:""))};return ret}();module.exports=tokenizer},{esprima:9}],9:[function(require,module,exports){(function(){(function(root,factory){"use strict";if(typeof define==="function"&&define.amd){define(["exports"],factory)}else if(typeof exports!=="undefined"){factory(exports)}else{factory(root.esprima={})}})(this,function(exports){"use strict";var Token,TokenName,Syntax,PropertyKind,Messages,Regex,source,strict,index,lineNumber,lineStart,length,buffer,state,extra;Token={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8};TokenName={};TokenName[Token.BooleanLiteral]="Boolean";TokenName[Token.EOF]="<end>";TokenName[Token.Identifier]="Identifier";TokenName[Token.Keyword]="Keyword";TokenName[Token.NullLiteral]="Null";TokenName[Token.NumericLiteral]="Numeric";TokenName[Token.Punctuator]="Punctuator";TokenName[Token.StringLiteral]="String";Syntax={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"};PropertyKind={Data:1,Get:2,Set:4};Messages={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"};Regex={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")};function assert(condition,message){if(!condition){throw new Error("ASSERT: "+message)}}function sliceSource(from,to){return source.slice(from,to)}if(typeof"esprima"[0]==="undefined"){sliceSource=function sliceArraySource(from,to){return source.slice(from,to).join("")}}function isDecimalDigit(ch){return"0123456789".indexOf(ch)>=0}function isHexDigit(ch){return"0123456789abcdefABCDEF".indexOf(ch)>=0}function isOctalDigit(ch){return"01234567".indexOf(ch)>=0}function isWhiteSpace(ch){return ch===" "||ch===" "||ch===""||ch==="\f"||ch===" "||ch.charCodeAt(0)>=5760&&" ".indexOf(ch)>=0}function isLineTerminator(ch){return ch==="\n"||ch==="\r"||ch==="\u2028"||ch==="\u2029"}function isIdentifierStart(ch){return ch==="$"||ch==="_"||ch==="\\"||ch>="a"&&ch<="z"||ch>="A"&&ch<="Z"||ch.charCodeAt(0)>=128&&Regex.NonAsciiIdentifierStart.test(ch)}function isIdentifierPart(ch){return ch==="$"||ch==="_"||ch==="\\"||ch>="a"&&ch<="z"||ch>="A"&&ch<="Z"||ch>="0"&&ch<="9"||ch.charCodeAt(0)>=128&&Regex.NonAsciiIdentifierPart.test(ch)}function isFutureReservedWord(id){switch(id){case"class":case"enum":case"export":case"extends":case"import":case"super":return true}return false}function isStrictModeReservedWord(id){switch(id){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return true}return false}function isRestrictedWord(id){return id==="eval"||id==="arguments"}function isKeyword(id){var keyword=false;switch(id.length){case 2:keyword=id==="if"||id==="in"||id==="do";break;case 3:keyword=id==="var"||id==="for"||id==="new"||id==="try";break;case 4:keyword=id==="this"||id==="else"||id==="case"||id==="void"||id==="with";break;case 5:keyword=id==="while"||id==="break"||id==="catch"||id==="throw";break;case 6:keyword=id==="return"||id==="typeof"||id==="delete"||id==="switch";break;case 7:keyword=id==="default"||id==="finally";break;case 8:keyword=id==="function"||id==="continue"||id==="debugger";break;case 10:keyword=id==="instanceof";break}if(keyword){return true}switch(id){case"const":return true;case"yield":case"let":return true}if(strict&&isStrictModeReservedWord(id)){return true}return isFutureReservedWord(id)}function skipComment(){var ch,blockComment,lineComment;blockComment=false;lineComment=false;while(index<length){ch=source[index];if(lineComment){ch=source[index++];if(isLineTerminator(ch)){lineComment=false;if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index}}else if(blockComment){if(isLineTerminator(ch)){if(ch==="\r"&&source[index+1]==="\n"){++index}++lineNumber;++index;lineStart=index;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{ch=source[index++];if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}if(ch==="*"){ch=source[index];if(ch==="/"){++index;blockComment=false}}}}else if(ch==="/"){ch=source[index+1];if(ch==="/"){index+=2;lineComment=true}else if(ch==="*"){index+=2;blockComment=true;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{break}}else if(isWhiteSpace(ch)){++index}else if(isLineTerminator(ch)){++index;if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index}else{break}}}function scanHexEscape(prefix){var i,len,ch,code=0;len=prefix==="u"?4:2;for(i=0;i<len;++i){if(index<length&&isHexDigit(source[index])){ch=source[index++];code=code*16+"0123456789abcdef".indexOf(ch.toLowerCase())}else{return""}}return String.fromCharCode(code)}function scanIdentifier(){var ch,start,id,restore;ch=source[index];if(!isIdentifierStart(ch)){return}start=index;if(ch==="\\"){++index;if(source[index]!=="u"){return}++index;restore=index;ch=scanHexEscape("u");if(ch){if(ch==="\\"||!isIdentifierStart(ch)){return}id=ch}else{index=restore;id="u"}}else{id=source[index++]}while(index<length){ch=source[index];if(!isIdentifierPart(ch)){break}if(ch==="\\"){++index;if(source[index]!=="u"){return}++index;restore=index;ch=scanHexEscape("u");if(ch){if(ch==="\\"||!isIdentifierPart(ch)){return}id+=ch}else{index=restore;id+="u"}}else{id+=source[index++]}}if(id.length===1){return{type:Token.Identifier,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(isKeyword(id)){return{type:Token.Keyword,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(id==="null"){return{type:Token.NullLiteral,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(id==="true"||id==="false"){return{type:Token.BooleanLiteral,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}return{type:Token.Identifier,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanPunctuator(){var start=index,ch1=source[index],ch2,ch3,ch4;if(ch1===";"||ch1==="{"||ch1==="}"){++index;return{type:Token.Punctuator,value:ch1,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1===","||ch1==="("||ch1===")"){++index;return{type:Token.Punctuator,value:ch1,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}ch2=source[index+1];if(ch1==="."&&!isDecimalDigit(ch2)){return{type:Token.Punctuator,value:source[index++],lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}ch3=source[index+2];ch4=source[index+3];if(ch1===">"&&ch2===">"&&ch3===">"){if(ch4==="="){index+=4;return{type:Token.Punctuator,value:">>>=",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}}if(ch1==="="&&ch2==="="&&ch3==="="){index+=3;return{type:Token.Punctuator,value:"===",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="!"&&ch2==="="&&ch3==="="){index+=3;return{type:Token.Punctuator,value:"!==",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1===">"&&ch2===">"&&ch3===">"){index+=3;return{type:Token.Punctuator,value:">>>",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="<"&&ch2==="<"&&ch3==="="){index+=3;return{type:Token.Punctuator,value:"<<=",lineNumber:lineN