diff --git a/docs/lifecycle.md b/docs/lifecycle.md index c9b566a..f669be3 100755 --- a/docs/lifecycle.md +++ b/docs/lifecycle.md @@ -8,6 +8,9 @@ | **beforeFirstRender** | Before component rendered to the DOM at the first time | | **afterFirstRender** | After component rendered to the DOM at the first time | ||| +| **beforeRender** | Before every render | +| **afterRender** | After every render | +||| | **beforeRerender** | Before component rerendered/updated on the DOM | | **afterRerender** | After component rerendered/updated on the DOM | ||| @@ -16,6 +19,8 @@ ||| | **disconnected** | Triggered when the component is removed from the DOM | +!> DOM and state variables is not available in "construct". You can only reach them in "render" events, especially if you are using routers. + ## Usage Example \ No newline at end of file diff --git a/examples/app-router/web-app.html b/examples/app-router/web-app.html index c509f98..7cf5379 100755 --- a/examples/app-router/web-app.html +++ b/examples/app-router/web-app.html @@ -1,5 +1,5 @@ - + web app {state.name} diff --git a/simply.js b/simply.js index 4a17786..1e90ee0 100755 --- a/simply.js +++ b/simply.js @@ -193,14 +193,16 @@ simply = { subject = m.groups.of; } - iiii = "s" + Math.random().toString(2).slice(-7); + var iiii = "s" + Math.random().toString(16).slice(2); + if (Array.isArray(subject)) { key = m.groups.key ? "let " + m.groups.key + " = " + iiii + ";" : ""; - let index = m.groups.key ? "let " + m.groups.index + " = " + iiii + ";" : ""; + index = m.groups.index ? "let " + m.groups.index + " = " + iiii + ";" : ""; logic = "for (" + iiii + " = 0; " + iiii + " < " + m.groups.of + ".length; " + iiii + "++) { \ - " + key + "; \ - " + index + "; \ + if (!"+ m.groups.of + "["+iiii+"]) { continue; }\ + " + key + " \ + " + index + " \ let " + m.groups.as + "=" + m.groups.of + "[" + iiii + "];"; } else { @@ -237,10 +239,13 @@ simply = { let of = ofMatch ? ofMatch[1] : undefined; let as = asMatch ? asMatch[1] : undefined; - let key = keyMatch ? keyMatch[1] : undefined; - let index = indexMatch ? indexMatch[1] : undefined; - - return { of, as, key, index }; + + // Create the result object and conditionally add key and index if they exist + let result = { of, as }; + if (keyMatch) result.key = keyMatch[1]; + if (indexMatch) result.index = indexMatch[1]; + + return result; } if (flag === true) { @@ -829,7 +834,7 @@ simply = { this.dom = dom; this.lifecycle = lifecycle; - this.props = props; + this.propsToObserve = props; this.dataToObserve = data; this.data; @@ -841,6 +846,8 @@ simply = { this.open = open; this.cb = cb; + var self = this; + // console.log(name, open); var geval = eval; @@ -865,7 +872,7 @@ simply = { var attrib = this.attributes[i]; // console.log("yaz balam ay balam", simply.parseProp(attrib.value)); if (attrib.name !== "cb") { - props[attrib.name] = simply.parseProp(attrib.value).value; + self.propsToObserve[attrib.name] = simply.parseProp(attrib.value).value; } } @@ -937,85 +944,20 @@ simply = { cb.data = newValue; }; - this.setProps = function (newValue) { - props = newValue; - }; - this.setCbProps = function (newValue) { - cb.props = newValue; - }; - this.setState = function (newValue) { state = newValue; }; this.setCbState = function (newValue) { cb.state = newValue; - }; - - // after construct event - if (typeof this.lifecycle !== "undefined") { - if (typeof this.lifecycle.afterConstruct !== "undefined") { - setTimeout(() => { - this.lifecycle.afterConstruct(); - }, 0); - } - } - } - // invoked each time the custom element is appended - // into a document-connected element - observeAttrChange(el, callback) { - var self = this; - var observer = new MutationObserver(function (mutations) { - mutations.forEach(function (mutation) { - if (mutation.type === 'attributes') { - var newVal = mutation.target.getAttribute(mutation.attributeName); - console.log(mutation.attributeName, "attribute changed to", newVal); - callback(mutation.attributeName, newVal); - - } - }); - }); - observer.observe(el, { - attributes: true, - childList: false, - characterData: false, - subtree: false, - attributeOldValue: true, - characterDataOldValue: false - }); - return observer; - } - onBeforeEnter(location, commands, router) { - //console.log("on before",location, commands, router); - //return commands.prevent(); - } - connectedCallback() { - this.observeAttrChange(this, function (name, newValue) { - console.log("hee"); - // value öncekiyle aynı değilse - // console.log(name, newValue, self.props[name], newValue == simply.prepareAttr(self.props[name])); - if (self.props[name]) { - if (newValue !== simply.prepareAttr(self.props[name])) { - try { - newValue = simply.parseProp(newValue).value; - } catch (e) { - // getattribute parse edemezse - newValue = newValue; - } - - self.props[name] = newValue; - if (typeof self.lifecycle !== "undefined") { - if (typeof self.lifecycle.whenPropChange !== "undefined") { - console.log("propchange"); - self.lifecycle.whenPropChange(name, self.props[name], newValue); - } - } - } + }; - } - }); + this.setProps = function (newValue) { + props = newValue; + }; + this.setCbProps = function (newValue) { + cb.props = newValue; + }; - var self = this; - var templateName = name; this.react = function (property, newValue, previousValue, prop = false) { // console.log("react to ", property, previousValue, newValue, templateName); @@ -1058,10 +1000,13 @@ simply = { self.render(); } - } + } + + + if (this.dataToObserve) { - this.data = ObservableSlim.create(this.dataToObserve, true, function (changes) { + this.data = ObservableSlim.create(this.dataToObserve, false, function (changes) { for (const [key, cb] of Object.entries(self.cb.data)) { if (cb) { changes.forEach(function (change, key) { @@ -1079,76 +1024,117 @@ simply = { } } - if (this.props) { - let handler = { - get: function (obj, prop) { - // props can contain only key: value not key: object - // so no need to proxify child nodes + if (this.propsToObserve) { + this.props = ObservableSlim.create(this.propsToObserve, false, function (changes) { + for (const [key, cb] of Object.entries(self.cb.props)) { + if (cb) { + changes.forEach(function (change, key) { + cb(change.property, change.newValue, change.previousValue); + }) + } + } + }); - /* - if (isObjectWithoutTriggeringGetter(obj, prop) ) { - console.log(proxies, obj[prop], r); - if (proxies.has(obj[prop])) { - // console.log("uyy proxy daaa", obj[prop]); - return proxies.get(obj[prop]); - } - else { - // console.log("obje proxy'e dönüştürüldü", obj, prop); - let proxy = new Proxy(obj[prop], handler); - //proxies.add(proxy); - proxies.set(obj[prop], proxy); - return proxy; - } + if (template.indexOf("props.") > -1 || script.indexOf("props.") > -1) { + this.cb.props = {} + this.cb.props[this.uid] = function (property, newValue, previousValue) { self.react(property, newValue, previousValue) }; + } + } - } - else { - //console.log("normal get", obj, prop); - return obj[prop]; - } - */ - return obj[prop]; - }, - set: function (target, prop, value, receiver) { - if (target[prop] !== value) { - Reflect.set(...arguments); - for (const [key, cb] of Object.entries(self.cb.props)) { - if (cb) { - cb(prop, value); - } + // after construct event + if (typeof this.lifecycle !== "undefined") { + if (typeof this.lifecycle.afterConstruct !== "undefined") { + this.lifecycle.afterConstruct(); + } + } + } + // invoked each time the custom element is appended + // into a document-connected element + observeAttrChange(el, callback) { + var self = this; + var observer = new MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + if (mutation.type === 'attributes') { + var newVal = mutation.target.getAttribute(mutation.attributeName); + console.log(mutation.attributeName, "attribute changed to", newVal); + callback(mutation.attributeName, newVal); - //console.log(`${key}: ${value}`); - } + } + }); + }); + observer.observe(el, { + attributes: true, + childList: false, + characterData: false, + subtree: false, + attributeOldValue: true, + characterDataOldValue: false + }); + return observer; + } + onBeforeEnter(location, commands, router) { + //console.log("on before",location, commands, router); + //return commands.prevent(); + } + connectedCallback() { + this.observeAttrChange(this, function (name, newValue) { + console.log("hee"); + // value öncekiyle aynı değilse + // console.log(name, newValue, self.props[name], newValue == simply.prepareAttr(self.props[name])); + if (self.props[name]) { + if (newValue !== simply.prepareAttr(self.props[name])) { + try { + newValue = simply.parseProp(newValue).value; + } catch (e) { + // getattribute parse edemezse + newValue = newValue; } - return true; // Pass through the operation - }, - deleteProperty: function (target, prop) { - if (prop in target) { - delete target[prop]; - //console.log(`property removed: ${prop}`); - // Expected output: "property removed: texture" + + self.props[name] = newValue; + if (typeof self.lifecycle !== "undefined") { + if (typeof self.lifecycle.whenPropChange !== "undefined") { + console.log("propchange"); + self.lifecycle.whenPropChange(name, self.props[name], newValue); + } } - for (const [key, cb] of Object.entries(self.cb.props)) { - cb(prop, null); - //console.log(`${key}: ${value}`); + } + + } + }); + + var self = this; + var templateName = name; + + // parent değişkenleri değişince + // velet de tepki versin diye + + /* + if (this.parent) { + console.log(this.parent); + if (this.parent.data) { + if (this.parent.cb) { + if (this.parent.cb.data) { + + this.parent.cb.data[this.uid] = function (prop, value) { self.react(prop, value) }; + this.parent.setData = this.parent.data; } } - }; - if (template.indexOf("props.") > -1 || script.indexOf("props.") > -1) { - this.cb.props = {} - this.cb.props[this.uid] = function (prop, value) { self.react(prop, value, true) }; - this.props = new Proxy(this.props, handler); - this.setProps(this.props); - this.setCbProps(this.cb.props); } - + + if (this.parent.props) { + this.parent.cb.props[this.uid] = function (prop, value) { self.react(prop, value) }; + this.parent.setprops = this.parent.props; + } + } + */ if (this.stateToObserve) { if (!this.stateToObserve.__isProxy) { - this.state = ObservableSlim.create(this.stateToObserve, true, function (changes) { + this.state = ObservableSlim.create(this.stateToObserve, false, function (changes) { // console.log(changes, templateName); if (self.cb.state) { for (const [key, cb] of Object.entries(self.cb.state)) { @@ -1163,7 +1149,7 @@ simply = { }); this.cb.state = {} this.cb.state[this.uid] = function (property, newValue, previousValue) { self.react(property, newValue, previousValue) }; - this.setCbState(this.cb.state); + //this.setCbState(this.cb.state); //console.log("bu bi kere çalışır"); // this.state = new Proxy(this.state, handler); @@ -1181,9 +1167,10 @@ simply = { - this.setState(this.state); + - } + } + function findElementWithCB(element) { let current = element; @@ -1205,31 +1192,7 @@ simply = { } return null; // No element with `cb` found - } - // parent değişkenleri değişince - // velet de tepki versin diye - - /* - if (this.parent) { - console.log(this.parent); - if (this.parent.data) { - if (this.parent.cb) { - if (this.parent.cb.data) { - - this.parent.cb.data[this.uid] = function (prop, value) { self.react(prop, value) }; - this.parent.setData = this.parent.data; - } - } - - } - - if (this.parent.props) { - this.parent.cb.props[this.uid] = function (prop, value) { self.react(prop, value) }; - this.parent.setprops = this.parent.props; - } - - } - */ + } this.render(); } @@ -1322,13 +1285,23 @@ simply = { } + if (!this.rendered) { + this.rendered = true; var self = this; let parsedTemplate = simply.parseTemplate(parsingArgs); var parsedStyle = simply.parseStyle(parsingArgs); parsedTemplate = parsedTemplate + "" + ""; + + if (typeof this.lifecycle !== "undefined") { + if (typeof this.lifecycle.beforeRender !== "undefined") { + if (typeof this.lifecycle.beforeRender(parsedTemplate) !== "undefined") { + parsedTemplate = this.lifecycle.beforeRender(parsedTemplate); + } + } + } if (typeof this.lifecycle !== "undefined") { if (typeof this.lifecycle.beforeFirstRender !== "undefined") { if (typeof this.lifecycle.beforeFirstRender(parsedTemplate) !== "undefined") { @@ -1336,6 +1309,9 @@ simply = { } } } + + + this.dom.innerHTML = parsedTemplate; simply.setupInlineComps(this.dom, docStr, template); if (window.unoConfig) { @@ -1403,11 +1379,10 @@ simply = { if (typeof this.lifecycle !== "undefined") { if (typeof this.lifecycle.afterFirstRender !== "undefined") { - setTimeout(() => { this.lifecycle.afterFirstRender(); - }, 0); } } + } else { if (typeof this.lifecycle !== "undefined") { @@ -1416,11 +1391,28 @@ simply = { } } + + // var ddd = this.data; + // parsingArgs.data = JSON.parse(JSON.stringify(ddd)); const t0 = performance.now(); + /* + try { + console.log(parsingArgs.data.browser.length); + } + catch(e) { + + } + */ let parsedTemplate = simply.parseTemplate(parsingArgs); const t1 = performance.now(); // console.log(`parseTemplate took ${t1 - t0} milliseconds.`); - + /* + if (parsedTemplate.indexOf('level="1"') == -1 && name == "browser-comp") { + console.log("yakalarım hatayı"); + console.log(JSON.stringify(this.data.browser)); + console.log(parsedTemplate); + } + */ parsedTemplate = parsedTemplate.replace("", "").replace("", ""); var parsedStyle = simply.parseStyle(parsingArgs); var newDom = parsedTemplate + "" + ""; @@ -1439,7 +1431,7 @@ simply = { function morphIt(dom) { - // console.log("morphing"); + //console.log("morphing"); simply.morphdom(dom, newDomAsString, { @@ -1535,13 +1527,17 @@ simply = { if (typeof this.lifecycle !== "undefined") { if (typeof this.lifecycle.afterRerender !== "undefined") { - setTimeout(() => { this.lifecycle.afterRerender(); - }, 0); } } } - this.rendered = true; + if (typeof this.lifecycle !== "undefined") { + if (typeof this.lifecycle.afterRender !== "undefined") { + this.lifecycle.afterRender(); + + } + } + } disconnectedCallback() { // console.log("disconnector", this.uid); diff --git a/simply.min.js b/simply.min.js index 07979c1..8de12a7 100644 --- a/simply.min.js +++ b/simply.min.js @@ -1,4 +1,4 @@ -simply={components:{},parseTemplate:function(parsingArgs){var{template:template,data:data,style:style,state:state,parent:parent,methods:methods,props:props,component:component,dom:dom,methods:methods,lifecycle:lifecycle,watch:watch}=parsingArgs;let simplyTemplate=/\]*)simply([^<>]*)>$/,ifStart=/\$)/,elsifStart=/\$)/,ifEnd=/\<\/if\>$/,elsifEnd=/\<\/elsif\>$/,elseStart=/\$/,elseEnd=/\<\/else\>$/,eachEnd=/\<\/each\>$/;const MAX_LENGTH=150;let eachStart=/\[^"]*)\"\s+as\=\"(?[^"]*)\"(\s+key\=\"(?[^"]*)\")?(\s+index\=\"(?[^"]*)\")?\>$/gm,inTagVar=/:="(?[^"]*)"$/,ifCount=0,eachCount=0,m,bucket="";var processedLetters="",capturedLogics=[],staticLetters="",flag=!1,curlyCount=0,curlyFlag=!1,varBucket="",scriptCount=0,styleCount=0,templateCount=0,simplyTemplateCount=0,ignoreFlag=!1;template.includes("${")&&(template=template.replace(/\$\{/g,"minyeli{"));for(var i=0;i")?simplyTemplateCount+=1:bucket.endsWith("<\/script>")?scriptCount-=1:bucket.endsWith("")?styleCount-=1:bucket.endsWith("")&&(simplyTemplateCount-=1),0==simplyTemplateCount&&0==styleCount&&0==scriptCount){if((bucket.endsWith('="function')||bucket.endsWith('="(function'))&&(ignoreFlag=!0),"\\"!==template[i-1]&&"{"==template[i]&&(curlyCount+=1),curlyCount>0&&!1===ignoreFlag&&(varBucket+=template[i]),"\\"!==template[i-1]&&"}"==template[i]&&(curlyCount-=1,0==curlyCount&&!0===ignoreFlag&&(ignoreFlag=!1)),0==curlyCount&&""!==varBucket){varBucket=varBucket.trim();let variable=varBucket.trim().substring(1,varBucket.length-1);function isObjectString(str){return/^\{(?:[^{}]|(?:\{(?:[^{}]|(?:\{[^{}]*\}))+\}))*\}$/.exec(str)}isObjectString(variable)&&(variable='"'+varBucket.trim()+'"'),logic="ht+="+variable+";",flag=!0}else null!==(m=inTagVar.exec(recentBucket))&&(logic="ht+="+m.groups.l+";",flag=!0);if(recentBucket.endsWith(">"))if(recentBucket.includes("]*\>$/),m.groups=parseEachTag(m[0]),eachCount+=1;try{subject=eval(m.groups.of)}catch(error){subject=m.groups.of}if(iiii="s"+Math.random().toString(2).slice(-7),Array.isArray(subject)){key=m.groups.key?"let "+m.groups.key+" = "+iiii+";":"";let index=m.groups.key?"let "+m.groups.index+" = "+iiii+";":"";logic="for ("+iiii+" = 0; "+iiii+" < "+m.groups.of+".length; "+iiii+"++) { \t\t\t\t\t\t\t\t\t\t\t\t\t\t"+key+"; \t\t\t\t\t\t\t\t\t\t\t\t\t\t"+index+"; \t\t\t\t\t\t\t\t\t\t\t\t\t\tlet "+m.groups.as+"="+m.groups.of+"["+iiii+"];"}else key=m.groups.index?"let "+m.groups.index+" = ":"",logic="\t\t\t\t\t\t\t\t\t\t\t\tfor (var ii in "+m.groups.of+") { \t\t\t\t\t\t\t\t\t\t\t\t\tif (typeof "+m.groups.of+"[ii] == 'function') { continue; }\t\t\t\t\t\t\t\t\t\t\t\t\t"+key+"Object.keys("+m.groups.of+").indexOf(ii); \t\t\t\t\t\t\t\t\t\t\t\t\tlet "+m.groups.key+"= ii; \t\t\t\t\t\t\t\t\t\t\t\t\tlet "+m.groups.as+"="+m.groups.of+"[ii];";flag=!0,lastM=m.groups.of,lasti=iiii}else null!==(m=eachEnd.exec(recentBucket2))&&(eachCount-=1,logic="};",flag=!0)}function parseEachTag(eachTag){let ofMatch=eachTag.match(/of="([^"]+)"/),asMatch=eachTag.match(/as="([^"]+)"/),keyMatch=eachTag.match(/key="([^"]+)"/),indexMatch=eachTag.match(/index="([^"]+)"/),of,as,key,index;return{of:ofMatch?ofMatch[1]:void 0,as:asMatch?asMatch[1]:void 0,key:keyMatch?keyMatch[1]:void 0,index:indexMatch?indexMatch[1]:void 0}}if(!0===flag){try{capturedLogics.push(m[0])}catch(error){capturedLogics.push(varBucket),varBucket=""}let logicLine=capturedLogics[capturedLogics.length-1];staticText=processedLetters.substring(0,processedLetters.lastIndexOf(logicLine))+"";let replaceThis=staticText+logicLine;var withThis="ht+=`"+staticText.replace(/\n/g,"")+"`;"+logic;if(""==staticText.trim())var withThis=logic;else var withThis="ht+=`"+staticText.replace(/\n/g,"")+"`;"+logic;bucket=bucket.replace(replaceThis,withThis),flag=!1,processedLetters=""}}""!==processedLetters.trimEnd()&&(processedLettersRegex=processedLetters.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),bucket=bucket.replace(new RegExp(processedLettersRegex+"$"),"ht+=`"+processedLetters.trimEnd()+"`;"));var ht="";return bucket=bucket.replace(/minyeli/g,"$"),eval(bucket),ht},parseStyle:function(parsingArgs){var{template:template,style:style,data:data,state:state,parent:parent,methods:methods,props:props,component:component,dom:dom,methods:methods,lifecycle:lifecycle,watch:watch}=parsingArgs;let variable=/(\"|\')(\{)([^{}\n]*)\}(\"|\')/;for(var vars={};null!==(m=variable.exec(style));){m.index===variable.lastIndex&&variable.lastIndex++;var variableName="--"+m[3].replace(/\./g,"-"),variableValue=eval(m[3]);vars[variableName]=variableValue,style=style.split(m[0]).join("var("+variableName+")")}return{style:style,vars:vars}},getBetweenTag:function(obj){let{string:string,tag:tag,prop:prop}=obj,open,anyOpen=new RegExp("<"+tag+"([^<>]*)>$","i"),close=new RegExp("$","i"),captureFlag=!1,bucket,capture="",count=0;open=prop?new RegExp("<"+tag+"([^<>]*)"+prop+"([^<>]*)>$","i"):anyOpen;for(var i=0;i]*)simply([^<>]*)>/;return capture=capture.trim(),capture=capture.replace(simplyTemplate,""),capture=capture.replace(close,""),capture=capture.trim(),capture}}else captureFlag&&(capture+=string[i])},getObject:function(string,name){var open=/uno(\s+)?\=(\s+)?{$/,bucket="",capture="",captureFlag=!1;count=0;for(var i=0;i]*)simply([^<>]*)>$/,ifStart=/\$)/,elsifStart=/\$)/,ifEnd=/\<\/if\>$/,elsifEnd=/\<\/elsif\>$/,elseStart=/\$/,elseEnd=/\<\/else\>$/,eachEnd=/\<\/each\>$/;const MAX_LENGTH=150;let eachStart=/\[^"]*)\"\s+as\=\"(?[^"]*)\"(\s+key\=\"(?[^"]*)\")?(\s+index\=\"(?[^"]*)\")?\>$/gm,inTagVar=/:="(?[^"]*)"$/,ifCount=0,eachCount=0,m,bucket="";var processedLetters="",capturedLogics=[],staticLetters="",flag=!1,curlyCount=0,curlyFlag=!1,varBucket="",scriptCount=0,styleCount=0,templateCount=0,simplyTemplateCount=0,ignoreFlag=!1;template.includes("${")&&(template=template.replace(/\$\{/g,"minyeli{"));for(var i=0;i")?simplyTemplateCount+=1:bucket.endsWith("<\/script>")?scriptCount-=1:bucket.endsWith("")?styleCount-=1:bucket.endsWith("")&&(simplyTemplateCount-=1),0==simplyTemplateCount&&0==styleCount&&0==scriptCount){if((bucket.endsWith('="function')||bucket.endsWith('="(function'))&&(ignoreFlag=!0),"\\"!==template[i-1]&&"{"==template[i]&&(curlyCount+=1),curlyCount>0&&!1===ignoreFlag&&(varBucket+=template[i]),"\\"!==template[i-1]&&"}"==template[i]&&(curlyCount-=1,0==curlyCount&&!0===ignoreFlag&&(ignoreFlag=!1)),0==curlyCount&&""!==varBucket){varBucket=varBucket.trim();let variable=varBucket.trim().substring(1,varBucket.length-1);function isObjectString(str){return/^\{(?:[^{}]|(?:\{(?:[^{}]|(?:\{[^{}]*\}))+\}))*\}$/.exec(str)}isObjectString(variable)&&(variable='"'+varBucket.trim()+'"'),logic="ht+="+variable+";",flag=!0}else null!==(m=inTagVar.exec(recentBucket))&&(logic="ht+="+m.groups.l+";",flag=!0);if(recentBucket.endsWith(">"))if(recentBucket.includes("]*\>$/),m.groups=parseEachTag(m[0]),eachCount+=1;try{subject=eval(m.groups.of)}catch(error){subject=m.groups.of}var iiii="s"+Math.random().toString(16).slice(2);Array.isArray(subject)?(key=m.groups.key?"let "+m.groups.key+" = "+iiii+";":"",index=m.groups.index?"let "+m.groups.index+" = "+iiii+";":"",logic="for ("+iiii+" = 0; "+iiii+" < "+m.groups.of+".length; "+iiii+"++) { \t\t\t\t\t\t\t\tif (!"+m.groups.of+"["+iiii+"]) { continue; }\t\t\t\t\t\t\t\t\t\t\t\t\t\t"+key+" \t\t\t\t\t\t\t\t\t\t\t\t\t\t"+index+" \t\t\t\t\t\t\t\t\t\t\t\t\t\tlet "+m.groups.as+"="+m.groups.of+"["+iiii+"];"):(key=m.groups.index?"let "+m.groups.index+" = ":"",logic="\t\t\t\t\t\t\t\t\t\t\t\tfor (var ii in "+m.groups.of+") { \t\t\t\t\t\t\t\t\t\t\t\t\tif (typeof "+m.groups.of+"[ii] == 'function') { continue; }\t\t\t\t\t\t\t\t\t\t\t\t\t"+key+"Object.keys("+m.groups.of+").indexOf(ii); \t\t\t\t\t\t\t\t\t\t\t\t\tlet "+m.groups.key+"= ii; \t\t\t\t\t\t\t\t\t\t\t\t\tlet "+m.groups.as+"="+m.groups.of+"[ii];"),flag=!0,lastM=m.groups.of,lasti=iiii}else null!==(m=eachEnd.exec(recentBucket2))&&(eachCount-=1,logic="};",flag=!0)}function parseEachTag(eachTag){let ofMatch=eachTag.match(/of="([^"]+)"/),asMatch=eachTag.match(/as="([^"]+)"/),keyMatch=eachTag.match(/key="([^"]+)"/),indexMatch=eachTag.match(/index="([^"]+)"/),of,as,result={of:ofMatch?ofMatch[1]:void 0,as:asMatch?asMatch[1]:void 0};return keyMatch&&(result.key=keyMatch[1]),indexMatch&&(result.index=indexMatch[1]),result}if(!0===flag){try{capturedLogics.push(m[0])}catch(error){capturedLogics.push(varBucket),varBucket=""}let logicLine=capturedLogics[capturedLogics.length-1];staticText=processedLetters.substring(0,processedLetters.lastIndexOf(logicLine))+"";let replaceThis=staticText+logicLine;var withThis="ht+=`"+staticText.replace(/\n/g,"")+"`;"+logic;if(""==staticText.trim())var withThis=logic;else var withThis="ht+=`"+staticText.replace(/\n/g,"")+"`;"+logic;bucket=bucket.replace(replaceThis,withThis),flag=!1,processedLetters=""}}""!==processedLetters.trimEnd()&&(processedLettersRegex=processedLetters.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),bucket=bucket.replace(new RegExp(processedLettersRegex+"$"),"ht+=`"+processedLetters.trimEnd()+"`;"));var ht="";return bucket=bucket.replace(/minyeli/g,"$"),eval(bucket),ht},parseStyle:function(parsingArgs){var{template:template,style:style,data:data,state:state,parent:parent,methods:methods,props:props,component:component,dom:dom,methods:methods,lifecycle:lifecycle,watch:watch}=parsingArgs;let variable=/(\"|\')(\{)([^{}\n]*)\}(\"|\')/;for(var vars={};null!==(m=variable.exec(style));){m.index===variable.lastIndex&&variable.lastIndex++;var variableName="--"+m[3].replace(/\./g,"-"),variableValue=eval(m[3]);vars[variableName]=variableValue,style=style.split(m[0]).join("var("+variableName+")")}return{style:style,vars:vars}},getBetweenTag:function(obj){let{string:string,tag:tag,prop:prop}=obj,open,anyOpen=new RegExp("<"+tag+"([^<>]*)>$","i"),close=new RegExp("$","i"),captureFlag=!1,bucket,capture="",count=0;open=prop?new RegExp("<"+tag+"([^<>]*)"+prop+"([^<>]*)>$","i"):anyOpen;for(var i=0;i]*)simply([^<>]*)>/;return capture=capture.trim(),capture=capture.replace(simplyTemplate,""),capture=capture.replace(close,""),capture=capture.trim(),capture}}else captureFlag&&(capture+=string[i])},getObject:function(string,name){var open=/uno(\s+)?\=(\s+)?{$/,bucket="",capture="",captureFlag=!1;count=0;for(var i=0;i0)if(window[waitBeforeCb])cb();else var tryAmount=10,tryCount=0,a=setInterval(()=>{!window[waitBeforeCb]&&tryCount<10?tryCount+=1:(cb(),clearInterval(a))},50);else{var tmp,ref=window.document.getElementsByTagName("script")[0],script=window.document.createElement("script");script.src=src,script.async=!0,ref.parentNode.insertBefore(script,ref),cb&&"function"==typeof cb&&(script.onload=cb)}return script},get:function(path,name){if(simply.gets=simply.gets?simply.gets:[],Array.isArray(path))for(let i=0;i-1)var ext=name.split(".").pop(),name=name.replace("."+ext,"");else var ext="html";if("js"==ext);else if("html"==ext&&void 0===simply.components[name]){simply.components[name]={};var request=new XMLHttpRequest;request.open("GET",path,!0),request.onload=function(){if(this.status>=200&&this.status<400){let docStr=this.response,parsed=simply.splitComponent(this.response);simply.components[name]=parsed,callback({name:name,template:parsed.template,styles:parsed.styles,script:parsed.script,docStr:docStr})}},request.onerror=function(){},request.send()}},request:function(url,callback,async=!1){var request=new XMLHttpRequest;request.open("GET",url,async),request.onload=function(){if(this.status>=200&&this.status<400){try{response=JSON.parse(this.responseText)}catch(err){response=this.responseText}callback&&callback(response)}},request.send()},splitComponent:function(string){var txt=document.createElement("textarea"),parser,dom=(new DOMParser).parseFromString(string,"text/html"),template,styles={};dom.querySelector("style")&&dom.querySelectorAll("style").forEach(styleEl=>{txt.innerHTML=styleEl.innerHTML,style=txt.value,string=string.replace(txt.value,""),null!==styleEl.getAttribute("global")?styles.global=style:styles.local=style,styleEl.remove()});var script="";if(dom.querySelector("script")){var script=dom.querySelector("script");txt.innerHTML=script.innerHTML,script=txt.value,dom.querySelector("script").remove(),string=string.replace(txt.value,"")}return{template:template=string.replace("","").replace("","").replace("