You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I fixed some bugs of this libraray, but i losted the souce code.
compiled code is below.
/*! *****************************************************************************Copyright (c) Microsoft Corporation.Permission to use, copy, modify, and/or distribute this software for anypurpose with or without fee is hereby granted.THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITHREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITYAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROMLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OROTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ORPERFORMANCE OF THIS SOFTWARE.***************************************************************************** */function__spreadArrays(){for(vars=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;for(varr=Array(s),k=0,i=0;i<il;i++)for(vara=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];returnr;}varisNotEmpty=function(str){returnstr!=="";};varisBoolean=function(boolean){returntypeofboolean==="boolean";};varremoveQuotes=function(str){if(str===void0){str="";}returnstr.replace(/"/g,"");};varmakeMap=function(string,expectLowerCase){varmap=Object.create(null);varlist=string.split(",");list.map(function(item){return(map[item]=true);});returnexpectLowerCase
? function(val){returnmap[val.toLowerCase()];}
: function(val){returnmap[val];};};varisUnaryTag=makeMap("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,"+"link,meta,param,source,track,wbr");varDIRECTIVES;(function(DIRECTIVES){DIRECTIVES["text"]="v-text";DIRECTIVES["html"]="v-html";DIRECTIVES["show"]="v-show";DIRECTIVES["if"]="v-if";DIRECTIVES["else"]="v-else";DIRECTIVES["elseif"]="v-else-if";DIRECTIVES["for"]="v-for";DIRECTIVES["on"]="v-on";DIRECTIVES["bind"]="v-bind";DIRECTIVES["model"]="v-model";DIRECTIVES["slot"]="v-slot";DIRECTIVES["pre"]="v-pre";DIRECTIVES["cloak"]="v-cloak";DIRECTIVES["once"]="v-once";})(DIRECTIVES||(DIRECTIVES={}));varDIRECTIVES$1=DIRECTIVES;varTYPE;(function(TYPE){TYPE[(TYPE["ELEMENT"]=1)]="ELEMENT";TYPE[(TYPE["TEXT"]=2)]="TEXT";TYPE[(TYPE["STATIC_TEXT"]=3)]="STATIC_TEXT";})(TYPE||(TYPE={}));varonReg=/^@|^v-on:/;varpreserveBindingReg=/(^:|^v-bind:)(style|class|type|key)/;varcustomPropertyReg=/(^:|^v-bind:)([\s\S]+)/;varemptyBaseNodeAttr={name: "",value: "",};varTemplateGenertor=(function(){functionTemplateGenertor(options){if(options===void0){options={};}this.options=options;}TemplateGenertor.prototype.generate=function(ast){varres={code: "",};if(!ast){returnres;}this.ast=ast;res.code=this.genElement(this.ast);returnres;};TemplateGenertor.prototype.genElement=function(node){if(!node){return"";}elseif(node.ifConditions&&!node.ifConditionsHasGenerated){returnthis.genIfConditions(node);}elseif(node.type===TYPE.ELEMENT){returnthis.genNode(node);}elseif(node.type===TYPE.TEXT){returnthis.genText(node);}elseif(node.type===TYPE.STATIC_TEXT){returnthis.genText(node);}else{return"";}};TemplateGenertor.prototype.genIfConditions=function(node){var_this=this;node.ifConditionsHasGenerated=true;if(!node.ifConditions){return"";}returnnode.ifConditions.map(function(item){varblock=item.block;return_this.genElement(block);}).filter(isNotEmpty).join("");};TemplateGenertor.prototype.genNode=function(node){vartag=this.genTag(node);varisUnary=isUnaryTag(tag);varchildrenNodes=this.genChildren(node);letattrs=Object.keys(node.attrsMap).map((k)=>{constv=node.attrsMap[k];if(v===""){returnk;}return`${k}="${v}"`;}).join(" ");if(attrs.length>1){attrs=" "+attrs;}conststartTag=`<${tag}${attrs}${isUnary ? "/>" : ">"}`;constendTag=isUnary ? "" : `</${tag}>`;return[startTag,childrenNodes,endTag].join("");};TemplateGenertor.prototype.genChildren=function(node){var_this=this;constchildren=[
...(node.children||[]),
...Object.values(node.scopedSlots||{}),];if(children.length===0){return"";}returnchildren.map(function(child){return_this.genElement(child);}).filter(isNotEmpty).join("");};TemplateGenertor.prototype.genTag=function(node){returnnode.tag;};TemplateGenertor.prototype.genText=function(node){var_a=node.text,text=_a===void0 ? "" : _a;returntext;};TemplateGenertor.prototype.genVIf=function(node){if(node.if){returnDIRECTIVES$1.if+'="'+node.if+'"';}elseif(node.elseif){returnDIRECTIVES$1.elseif+'="'+node.elseif+'"';}elseif(node.else){return""+DIRECTIVES$1.else;}return"";};TemplateGenertor.prototype.genVFor=function(node){returnthis.getDirectiveFromAttrsMap(node,"for",true);};TemplateGenertor.prototype.genKey=function(node){returnthis.getPropFromAttrsMap(node,"key",true);};TemplateGenertor.prototype.genEvents=function(node){var_a=node.attrsMap,attrsMap=_a===void0 ? {} : _a;returnObject.keys(attrsMap).map(function(attr){if(onReg.test(attr)){returnattr+'="'+attrsMap[attr]+'"';}return"";}).filter(isNotEmpty).join(" ");};TemplateGenertor.prototype.genVShow=function(node){returnthis.getDirectiveFromAttrsMap(node,"show",true);};TemplateGenertor.prototype.genVModel=function(node){returnthis.getDirectiveFromAttrsMap(node,"model",true);};TemplateGenertor.prototype.genVBind=function(node){var_a=node.attrsMap,attrsMap=_a===void0 ? {} : _a;returnObject.keys(attrsMap).map(function(attr){varisPreservedProperty=preserveBindingReg.test(attr);if(isPreservedProperty){return"";}varmatched=attr.match(customPropertyReg);if(matched){returnmatched[0]+'="'+attrsMap[attr]+'"';}return"";}).filter(isNotEmpty).join(" ");};TemplateGenertor.prototype.genAttrs=function(node){var_a=node.attrs,attrs=_a===void0 ? [] : _a,_b=node.attrsMap,attrsMap=_b===void0 ? {} : _b;if(!attrs.length){return"";}varattrsMapKeys=Object.keys(attrsMap);returnattrs.map(function(attr){varname=attr.name,value=attr.value;returnattrsMapKeys.find(function(attr){return":"+name===attr||"v-bind:"+name===attr;})
? ""
: value==='""'
? ""+name
: name+'="'+removeQuotes(value)+'"';}).filter(isNotEmpty).join(" ");};TemplateGenertor.prototype.genIs=function(node){returnthis.getPropFromAttrsMap(node,"is",true);};TemplateGenertor.prototype.genStyle=function(node){varbindStyle=this.getPropFromAttrsMap(node,"style",true);varstaticStyle=this.getDomAttrFromAttrsMap(node,"style",true);returnbindStyle+" "+staticStyle;};TemplateGenertor.prototype.genClass=function(node){varbindClass=this.getPropFromAttrsMap(node,"class",true);varstaticClass=this.getDomAttrFromAttrsMap(node,"class",true);returnbindClass+" "+staticClass;};TemplateGenertor.prototype.genVOnce=function(node){returnthis.getDirectiveFromAttrsMap(node,"once",true);};TemplateGenertor.prototype.genVPre=function(node){returnthis.getDirectiveFromAttrsMap(node,"pre",true);};TemplateGenertor.prototype.genVCloak=function(node){returnthis.getDirectiveFromAttrsMap(node,"cloak",true);};TemplateGenertor.prototype.genVHtml=function(node){returnthis.getDirectiveFromAttrsMap(node,"html",true);};TemplateGenertor.prototype.genVText=function(node){returnthis.getDirectiveFromAttrsMap(node,"text",true);};TemplateGenertor.prototype.genRef=function(node){returnthis.getDomAttrFromAttrsMap(node,"ref",true);};TemplateGenertor.prototype.genSlot=function(node){if(node.tag==="slot"){returnthis.getDomAttrFromAttrsMap(node,"name",true);}return"";};TemplateGenertor.prototype.getDirectiveFromAttrsMap=function(node,name,alias,needNormalize){if(isBoolean(alias)){needNormalize=alias;}varres;vardirective=DIRECTIVES$1[name]||DIRECTIVES$1[alias];varemptyMap=Object.assign({},emptyBaseNodeAttr);var_a=node.attrsMap,attrsMap=_a===void0 ? {} : _a;if(!directive){res=emptyMap;}else{vardirReg_1=newRegExp(directive);varrealDir=Object.keys(attrsMap).find(function(attr){returndirReg_1.test(attr);});res=realDir
? attrsMap[realDir]
? {name: realDir,value: '"'+attrsMap[realDir]+'"',}
: Object.assign(emptyMap,{noMap: true,})
: emptyMap;}returnneedNormalize ? this.normalizeMap(res) : res;};TemplateGenertor.prototype.getPropFromAttrsMap=function(node,name,needNormalize){var_a=node.attrsMap,attrsMap=_a===void0 ? {} : _a;varemptyMap=Object.assign({},emptyBaseNodeAttr);varvalue=attrsMap[":"+name]||attrsMap[DIRECTIVES$1.bind+":"+name];varres=!value
? emptyMap
: {name: ":"+name,value: '"'+value+'"'};returnneedNormalize ? this.normalizeMap(res) : res;};TemplateGenertor.prototype.getDomAttrFromAttrsMap=function(node,name,needNormalize){var_a=node.attrsMap,attrsMap=_a===void0 ? {} : _a;varemptyMap=Object.assign({},emptyBaseNodeAttr);varres;if(attrsMap.hasOwnProperty(name)){res=attrsMap[name]
? {name: name,value: '"'+attrsMap[name]+'"'}
: emptyMap;}else{res=emptyMap;}returnneedNormalize ? this.normalizeMap(res) : res;};TemplateGenertor.prototype.normalizeMap=function(res){varname=res.name,value=res.value,noMap=res.noMap;if(noMap&&name){returnname;}elseif(name&&value){returnname+"="+value;}else{return"";}};returnTemplateGenertor;})();module.exports=TemplateGenertor;
The text was updated successfully, but these errors were encountered:
I fixed some bugs of this libraray, but i losted the souce code.
compiled code is below.
The text was updated successfully, but these errors were encountered: