@lmjs/cli 2.5.3 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/fcs.js +1 -1
- package/dist/lib/files/libs/lm.js +1 -1
- package/dist/lib/hst.js +1 -0
- package/package.json +2 -2
package/dist/lib/fcs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const fetch=require("node-fetch");const path=require("path");const fs=require("fs");const nodemon=require("nodemon");var _acorn=require("acorn");var acorn=require("acorn-loose");function parseScriptJs(source){let ast;try{ast=_acorn.parse(source,{ecmaVersion:"latest",sourceType:"script"})}catch(e){ast=acorn.parse(source,{ecmaVersion:"latest"})}return stripAstPositions(ast)}function precompileViewScripts(groups){let failed=0;function visit(nodes,vars,inSection,file){if(!Array.isArray(nodes))return;for(const n of nodes){if(!n||n.type==="text")continue;const sectioned=inSection||n.type==="section"||n.type==="sections";const nm=String(n.name||"").toLowerCase();if((nm==="script"||nm==="js")&&Array.isArray(n.children)&&n.children[0]&&n.children[0].type==="text"){const t=n.children[0];if(t.content||t.jst){try{const ast=t.jst||_acorn.parse(t.content,{ecmaVersion:"latest",sourceType:"script"});const code=_walk.getWatcher(ast,{name:file},sectioned?void 0:(vars||[]).slice(),["__LMROOT__"]).code;new Function(code);t.pre=code;delete t.content;delete t.jst}catch(e){failed++;console.warn("\x1B[33mLumenJS: could not precompile a <script> in "+file+": "+(e&&e.message)+" (it will be compiled in the browser)\x1B[0m")}}}visit(n.children,vars,sectioned,file)}}for(const group of groups){const isTpl=group.kind==="tpls";for(const key in group.files){const entry=group.files[key];if(!entry||!Array.isArray(entry.hst))continue;const file=Buffer.from(key,"base64").toString().split(/[\\/]/).slice(-2).join("/");visit(entry.hst,entry.reactiveVars,isTpl,file)}}return failed}exports.precompileViewScripts=precompileViewScripts;function stripDevOnlyRuntime(src){const a=src.indexOf("var __lmDevOnlyStart__ = 1;");const b=src.indexOf("var __lmDevOnlyEnd__ = 1;");if(a<0||b<a)return src;return src.slice(0,a)+src.slice(b+"var __lmDevOnlyEnd__ = 1;".length)}exports.stripDevOnlyRuntime=stripDevOnlyRuntime;const _HST_EMPTY_OBJ={attrs:1,ax:1,evs:1,ex:1};function compactHstReplacer(key,value){if(_HST_EMPTY_OBJ[key]===1&&value&&typeof value==="object"&&!Array.isArray(value)&&Object.keys(value).length===0)return void 0;if(key==="isV"&&value===false)return void 0;if((key==="mss"||key==="children")&&Array.isArray(value)&&value.length===0)return void 0;return value}exports.compactHstReplacer=compactHstReplacer;function scriptPayload(source){try{_acorn.parse(source,{ecmaVersion:"latest",sourceType:"script"});return{content:source}}catch(e){return{jst:parseScriptJs(source)}}}exports.scriptPayload=scriptPayload;function stripAstPositions(node){if(Array.isArray(node)){for(let i=0;i<node.length;i++)stripAstPositions(node[i]);return node}if(!node||typeof node!=="object")return node;delete node.start;delete node.end;delete node.loc;delete node.range;for(const k in node){const v=node[k];if(v&&typeof v==="object")stripAstPositions(v)}return node}exports.stripAstPositions=stripAstPositions;var _min=require("html-minifier").minify;var he=require("he");const _FD=require("ftp-deploy");const _fD=new _FD;global.astring=global.astring||require("astring");const _corePackageDir=path.dirname(require.resolve("@lmjs/core/package.json"));const _walk=require(path.join(_corePackageDir,"src","walk.js"));const _npmBundle=require(path.join(__dirname,"npm-bundle.js"));exports.hasOwnDependencies=_npmBundle.hasOwnDependencies;exports.buildEntryWithImports=_npmBundle.buildEntryWithImports;const _pluginsBundle=require(path.join(__dirname,"plugins-esbuild-plugin.js"));const _vault=require(path.join(__dirname,"vault.js"));exports.login=_vault.login;exports.apiSet=_vault.apiSet;exports.apiUpdate=_vault.apiUpdate;exports.apiGet=_vault.apiGet;exports.apiList=_vault.apiList;exports.apiRemove=_vault.apiRemove;function selectedProjectPlugins(projectRoot){try{let deps={};const pkgPath=path.join(projectRoot,"package.json");if(fs.existsSync(pkgPath)){const pkg=JSON.parse(fs.readFileSync(pkgPath,"utf8"));Object.assign(deps,pkg.dependencies||{})}for(const key of detectUsedPlugins(projectRoot))if(!deps.hasOwnProperty(key))deps[key]="*";if(!Object.keys(deps).length)return[];return _pluginsBundle.selectedRegistryEntries(deps)}catch(e){return[]}}exports.selectedProjectPlugins=selectedProjectPlugins;const PLUGIN_SIGNATURES={"select2":[/\.select2\s*\(/,/<[a-z][^>]*\s(?:sl|slct)(?=[\s>=\/])/i],"flickity":[/\.flickity\s*\(/,/\bFlickity\b/,/<[a-z][^>]*\scrslf(?=[\s>=\/])/i],"bootstrap-colorpicker":[/\.colorpicker\s*\(/,/<input[^>]*\scolor(?=[\s>=\/])/i],"bootstrap-datetimepicker":[/\.datetimepicker\s*\(/,/<input[^>]*\s(?:date|time|datetime)(?=[\s>=\/])/i],"jquery-ui-dist":[/\.(?:sortable|draggable|droppable|resizable|datepicker|autocomplete|slider|accordion)\s*\(/,/<[a-z][^>]*\s(?:sort|drag|drop)(?=[\s>=\/])/i],"jquery.easing":[/\beas(?:e|ing)(?:In|Out)[A-Z]\w*/],"nestedSortable":[/\.nestedSortable\s*\(/],"jquery.numeric":[/\.numeric\s*\(/,/<input[^>]*\s(?:numeric|integer|decimal)(?=[\s>=\/])/i],"timeago":[/\.timeago\s*\(/,/\$\.timeago\b/],"slick-carousel":[/\.(?:crsl|slick)\s*\(/,/<[a-z][^>]*\scrsl(?=[\s>=\/])/i],"@iconify/iconify":[/class=["'][^"']*\biconify\b/,/\bIconify\./],"rellax":[/\bRellax\b/],"headroom.js":[/\bHeadroom\b/,/<[a-z][^>]*\spinnable(?=[\s>=\/])/i],"in-view":[/\binView\b/],"gsap":[/\bgsap\b/,/\bTween(?:Max|Lite)\b/,/\bTimeline(?:Max|Lite)\b/],"jquery.caret":[/\.caret\s*\(/],"jquery-tageditor":[/\.tagEditor\s*\(/,/<[a-z][^>]*\stags(?=[\s>=\/])/i],"jquery-lazy":[/\.lazy\s*\(/,/<img[^>]*\slazy(?=[\s>=\/])/i]};function detectUsedPlugins(projectRoot){const src=path.join(projectRoot,"src");if(!fs.existsSync(src))return[];let indexHtml="";try{indexHtml=fs.readFileSync(path.join(src,"index.html"),"utf8")}catch(e){}const texts=[];(function walk(dir){let entries;try{entries=fs.readdirSync(dir,{withFileTypes:true})}catch(e){return}for(const e of entries){const p=path.join(dir,e.name);if(e.isDirectory()){if(e.name==="node_modules"||e.name==="js"||e.name==="css"||e.name==="images")continue;walk(p)}else if(/\.(view|tpl|layout)$/.test(e.name)){try{texts.push(fs.readFileSync(p,"utf8"))}catch(x){}}}})(src);try{texts.push(fs.readFileSync(path.join(src,"index.js"),"utf8"))}catch(e){}for(const s of detectLocalProjectScripts(indexHtml)){try{texts.push(fs.readFileSync(path.join(src,s.replace(/^\//,"")),"utf8"))}catch(e){}}const all=texts.join("\n");const loadedByPage=key=>new RegExp(`<script[^>]+src=["'][^"']*`+key.replace(/^@[^/]+\//,"").replace(/\.js$/,"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i").test(indexHtml);const found=[];for(const key in PLUGIN_SIGNATURES){if(loadedByPage(key))continue;if(PLUGIN_SIGNATURES[key].some(re=>re.test(all)))found.push(key)}return found}exports.detectUsedPlugins=detectUsedPlugins;function compileProjectScript(source,name){let ast=_acorn.parse(source,{ecmaVersion:"latest",sourceType:"script"});let topLevelNames=[];for(const stmt of ast.body){if(stmt.type==="VariableDeclaration"){for(const d of stmt.declarations){if(d.id&&d.id.type==="Identifier")topLevelNames.push(d.id.name)}}}return _walk.getWatcher(ast,{name:name||"script"},topLevelNames,"Global").code}exports.compileProjectScript=compileProjectScript;function placePluginsCss(html,cssTag){html=String(html);let at=html.search(/<link\b[^>]*href=["']\/css\//i);return at>=0?html.slice(0,at)+cssTag+"\n "+html.slice(at):html.split("</head>").join(" "+cssTag+"\n</head>")}exports.placePluginsCss=placePluginsCss;function detectLocalProjectScripts(indexHtmlSource){let found=[];let re=/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi;let m;indexHtmlSource=String(indexHtmlSource).replace(/<!--[\s\S]*?-->/g,"");while(m=re.exec(indexHtmlSource)){let src=m[1];if(src.indexOf("/")!==0)continue;if(src==="/js/lm.js"||src==="/index.js")continue;if(/^\/js\/bea\.js(\?|$)/.test(src))continue;found.push(src)}return found}exports.detectLocalProjectScripts=detectLocalProjectScripts;const CORE_Libs={BEACSS:"https://s.beacdn.com/beacss/latest",COREJS:"https://lmjs.beacdn.com/latest"};const HST_FORMAT_VERSION=3;exports.HST_FORMAT_VERSION=HST_FORMAT_VERSION;function checkProjectRuntime(projectPath){try{let lm=fs.readFileSync(path.join(projectPath,"src","js","lm.js"),"utf8");let m=/EXPECTED_HST_FORMAT_VERSION\s*=\s*(\d+)/.exec(lm);let accepts=/_HST_FORMATS_ACCEPTED\s*=\s*\[([\d,\s]+)\]/.exec(lm);let ok=accepts?accepts[1].split(",").map(Number).indexOf(HST_FORMAT_VERSION)>-1:m&&Number(m[1])===HST_FORMAT_VERSION;if(m&&!ok){console.warn("\n\x1B[33mLumenJS: src/js/lm.js is older than this CLI (it expects HST v"+m[1]+", this CLI emits v"+HST_FORMAT_VERSION+"). Run `lm update-core` to update the project's runtime.\x1B[0m\n");return false}}catch(e){}return true}exports.checkProjectRuntime=checkProjectRuntime;exports.getAllFiles=getAllFiles;exports.ucwords=ucwords;exports.fetch=fetch;exports.getConfig=getConfig;function getConfig(){config={version:"1.0.0.1",server:{host:"127.0.0.1",port:"3000",ssl:{enabled:false,key:"/key.pem",cert:"/certificate.cer"}},apis:[{baseURL:"https://www.beaapis.com/1",headers:{"X-BEA-Application-ID":"YOUR_APPLICATION_ID","X-BEA-Authorization":"YOUR_REST_API_KEY"}}],ftp:{host:"ftp_host",username:"ftp_username",password:"ftp_password",remotePath:"/",concurrency:4,protocol:"ftp",port:21,ignore:[],syncOption:{delete:false,ignoreExisting:false,skipCreate:false,update:true},connectTimeout:3e4}};let configPath=process.cwd()+path.sep+`config.json`;if(fs.existsSync(configPath)){config=JSON.parse(fs.readFileSync(configPath,{encoding:"utf8"}))}return config}var config=getConfig();function ucwords(str){return(str+"").replace(/^([a-z])|\s+([a-z])/g,function($1){return $1.toUpperCase()})}function lw(s){return s.toString().toLowerCase()}exports.lw=lw;function cd(d){if(!fs.existsSync(d))fs.mkdirSync(d)}exports.cd=cd;function rd(d){if(fs.existsSync(d))fs.rmSync(d,{recursive:true,force:true})}exports.rd=rd;function create(conf){let t=conf.type=="v"||conf.type=="s"||conf.type=="t"?conf.type:"p";let n=conf.type=="v"||conf.type=="s"||conf.type=="t"?lw(conf.name[0]):conf.name.join(" ");if(t=="p"){var libsPath=`${__dirname}`+path.sep+`files`+path.sep+`libs`;var getLibs=false;var _beacssMissing=false;var _lmMissing=false;require("dns").resolve("www.google.com",function(err){if(!err){var _mobiuscssPath=libsPath+path.sep+"mobius.css";_beacssMissing=!fs.existsSync(_mobiuscssPath)||fs.statSync(_mobiuscssPath).size===0;_lmMissing=!fs.existsSync(libsPath+path.sep+"lm.js");if(_lmMissing||_beacssMissing)getLibs=true}if(getLibs){API.get(CORE_Libs.COREJS,{}).then(corejs=>{API.get(CORE_Libs.BEACSS,{}).then(mobiuscss=>{var libsPath2=`${__dirname}`+path.sep+`files`+path.sep+`libs`;cd(libsPath2);if(_lmMissing){fs.writeFileSync(libsPath2+path.sep+"lm.js",String(corejs))}if(_beacssMissing){fs.writeFileSync(libsPath2+path.sep+"mobius.css",String(mobiuscss))}var filePath3=`${process.cwd()}`+path.sep;copyDir(`${__dirname}`+path.sep+`files`+path.sep+`project`,filePath3,n);cd(filePath3+path.sep+"src");cd(filePath3+path.sep+"src"+path.sep+"css");cd(filePath3+path.sep+"src"+path.sep+"images");cd(filePath3+path.sep+"src"+path.sep+"js");let stylesFile=filePath3+path.sep+"src"+path.sep+"css"+path.sep+`styles.css`;let faviconFile=filePath3+path.sep+"src"+path.sep+`favicon.ico`;if(!fs.existsSync(stylesFile))fs.writeFileSync(stylesFile,String(""));if(!fs.existsSync(faviconFile))fs.writeFileSync(faviconFile,String(""));fs.writeFileSync(filePath3+path.sep+"src"+path.sep+"js"+path.sep+"lm.js",String(corejs));fs.writeFileSync(filePath3+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css",String(mobiuscss))})}).catch(err2=>{})}else{var filePath2=`${process.cwd()}`+path.sep;copyDir(`${__dirname}`+path.sep+`files`+path.sep+`project`,filePath2,n);cd(filePath2+path.sep+"src");cd(filePath2+path.sep+"src"+path.sep+"css");cd(filePath2+path.sep+"src"+path.sep+"images");cd(filePath2+path.sep+"src"+path.sep+"js");let stylesFile=filePath2+path.sep+"src"+path.sep+"css"+path.sep+`styles.css`;let faviconFile=filePath2+path.sep+"src"+path.sep+`favicon.ico`;if(!fs.existsSync(stylesFile))fs.writeFileSync(stylesFile,String(""));if(!fs.existsSync(faviconFile))fs.writeFileSync(faviconFile,String(""));let corejs=Buffer.from(fs.readFileSync(libsPath+path.sep+"lm.js").toString());let mobiuscss=Buffer.from(fs.readFileSync(libsPath+path.sep+"mobius.css").toString());fs.writeFileSync(filePath2+path.sep+"src"+path.sep+"js"+path.sep+"lm.js",String(corejs));fs.writeFileSync(filePath2+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css",String(mobiuscss))}})}else{let file=t=="s"?"sub_view.view":t=="t"?"layout.layout":"view.view";let ident=t=="s"?"SubView":t=="t"?"Template":"View";let dir=t=="t"?"layouts":"views";let ext=t=="t"?"layout":"view";let html5=Buffer.from(fs.readFileSync(`${__dirname}`+path.sep+`files`+path.sep+file).toString().split("["+ident+"Name]").join(ucwords(n)));var filePath=`${process.cwd()}`+path.sep+`src`+path.sep+dir+path.sep+`${n}.${ext}`;if(fs.existsSync(filePath)){console.log(ident+" already exists:",filePath)}else{fs.writeFileSync(filePath,html5)}}}function getAllFiles(dirPath,arrayOfFiles={},mini=false,hst2=true){files=fs.readdirSync(dirPath);files.forEach(function(file){if(fs.statSync(dirPath+path.sep+file).isDirectory()){arrayOfFiles=getAllFiles(dirPath+path.sep+file,arrayOfFiles,mini,hst2)}else{let filePath=path.join(dirPath,path.sep,file);let fileKey=Buffer.from(filePath.split(`${process.cwd()}`+path.sep).join("").split("\\").join("/")).toString("base64");if(mini){var result=_min(fs.readFileSync(filePath,{encoding:"utf8"}),{removeAttributeQuotes:false,caseSensitive:true,collapseWhitespace:true,collapseInlineTagWhitespace:true,conservativeCollapse:true,removeComments:true,minifyJS:false,minifyCSS:false,processConditionalComments:true,collapseBooleanAttributes:false,decodeEntities:false,html5:true,includeAutoGeneratedTags:true,keepClosingSlash:true,maxLineLength:null,minifyURLs:false,preserveLineBreaks:false,preventAttributesEscaping:false,processScripts:["text/html"],quoteCharacter:"",removeEmptyAttributes:true,removeEmptyElements:false,removeOptionalTags:true,removeRedundantAttributes:true,removeScriptTypeAttributes:false,removeStyleLinkTypeAttributes:true,removeTagWhitespace:false,sortAttributes:false,sortClassName:false,trimCustomFragments:true,useShortDoctype:true,continueOnParseError:true})}else if(hst2){var result=_hst(fs.readFileSync(filePath,{encoding:"utf8"}))}else{var result=fs.readFileSync(filePath,{encoding:"utf8"})}arrayOfFiles[fileKey]=result}});return arrayOfFiles}const RESERVED_BARE_ATTRS=new Set(["body","view","scoped","tpl","sl","color","time","date","datetime","up","stop","confirm","econfirm","acl","rcl","hidden","disabled","readonly","required","checked","selected","autofocus","multiple","async","defer"]);function _collectWidgetRegions(nodes,found){if(!Array.isArray(nodes))return;for(const node of nodes){if(node&&node.type==="tag"&&node.attrs){for(const attrName in node.attrs){if(Object.prototype.hasOwnProperty.call(node.attrs,attrName)&&node.attrs[attrName]===""&&!RESERVED_BARE_ATTRS.has(attrName)&&!found.includes(attrName)){found.push(attrName)}}}if(node&&Array.isArray(node.children)){_collectWidgetRegions(node.children,found)}}}function annotateLayoutRegions(layoutsObj){for(const key in layoutsObj){if(!Object.prototype.hasOwnProperty.call(layoutsObj,key))continue;let entry=layoutsObj[key];if(!entry||!entry.hst)continue;let found=[];_collectWidgetRegions(entry.hst,found);entry.regions=found}return layoutsObj}exports.annotateLayoutRegions=annotateLayoutRegions;function v1CompatIndexHtml(html){return String(html).replace(/(<script\b[^>]*\bsrc=["'])\/?js\/bea\.js(?:\?[^"']*)?(["'])/gi,"$1/js/lm.js$2").replace(/<script\b[^>]*\bsrc=["']\/?index\.js(?:\?[^"']*)?["'][^>]*>\s*<\/script>\s*/gi,"").replace(/<script\b[^>]*\bsrc=["'](?:https?:)?\/\/(?:s\.|www\.)?beacdn\.com\/beajs\/[^"']*["'][^>]*>\s*<\/script>\s*/gi,"").replace(/<script\b[^>]*\bsrc=["'](?:https?:)?\/\/lmjs\.beacdn\.com\/[^"']*["'][^>]*>\s*<\/script>\s*/gi,"")}exports.v1CompatIndexHtml=v1CompatIndexHtml;function readTemplates(root){let out={};for(const folder of["tpls","comps"]){let dir=root+path.sep+"src"+path.sep+folder+path.sep;if(fs.existsSync(dir))Object.assign(out,getAllFiles(dir,{},false,true))}return out}exports.readTemplates=readTemplates;function linkTemplateReactiveVars(files2,templates){function templateFor(attrs){let name=String(attrs.tpl).replace(/^\/+/,"");for(const f of["tpls","comps"]){let key=Buffer.from("src/"+f+"/"+name+".tpl").toString("base64");if(templates[key])return templates[key]}return null}function scan(nodes,add){if(!Array.isArray(nodes))return;for(const node of nodes){if(!node)continue;let a=node.attrs;if(a&&node.type==="sections"&&a.hasOwnProperty("tpl")){let t=templateFor(a);if(t)(t.reactiveVars||[]).forEach(add)}if(a&&a.hasOwnProperty("view")){let sv=viewFor(a.view);if(sv)(sv.reactiveVars||[]).forEach(add)}if(node.children)scan(node.children,add);if(Array.isArray(node.content))scan(node.content,add)}}let viewByPath={};for(const key in files2){let p=Buffer.from(key,"base64").toString().replace(/\\/g,"/");let m=p.match(/(?:^|\/)views\/(.+)\.view$/);if(m)viewByPath[m[1]]=files2[key]}function viewFor(v){let p=String(v).trim().replace(/^\/+/,"").replace(/\.view$/,"");if(!p||/\{\{/.test(p))return null;return viewByPath[p]||null}for(let pass=0;pass<10;pass++){let grew=false;for(const key in files2){let entry=files2[key];if(!entry||!Array.isArray(entry.hst))continue;if(!Array.isArray(entry.reactiveVars))entry.reactiveVars=[];scan(entry.hst,function(n){if(entry.reactiveVars.indexOf(n)===-1){entry.reactiveVars.push(n);grew=true}})}if(!grew)break}for(const key in files2){let entry=files2[key];if(!entry||!Array.isArray(entry.hst))continue;if(!Array.isArray(entry.reactiveVars))entry.reactiveVars=[];scan(entry.hst,function(n){if(entry.reactiveVars.indexOf(n)===-1)entry.reactiveVars.push(n)})}return files2}exports.linkTemplateReactiveVars=linkTemplateReactiveVars;function hst_markSvg(nodes,inSvg){if(!Array.isArray(nodes))return;for(const n of nodes){if(!n||n.type==="text")continue;let name=String(n.name||"").toLowerCase();let here=inSvg||name==="svg";if(here)n.svg=true;let kidsInSvg=here&&name!=="foreignobject";hst_markSvg(n.children,kidsInSvg);if(Array.isArray(n.content))hst_markSvg(n.content,kidsInSvg)}}function hst_orderIfFor(res){if(!res||!res.attrs||!res.forX||!Object.prototype.hasOwnProperty.call(res.attrs,":if"))return;let keys=Object.keys(res.attrs);let cond=String(res.attrs[":if"]);if(keys.indexOf(":if")<keys.indexOf(":for")){res.forX.js="("+cond+") ? ("+res.forX.js+") : []"}else{let prev=res.attrs[":for-if"];res.attrs[":for-if"]=prev?"("+prev+") && ("+cond+")":cond}res.type="sections";delete res.cond;delete res.attrs[":if"];if(res.ax)delete res.ax[":if"]}exports.hst_orderIfFor=hst_orderIfFor;class hst{htmlVoidElements=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","isindex","keygen","link","menuitem","meta","nextid","param","source","track","wbr"];moustachePattern=/\{\s*\{\s*([\s\S]*?)\s*\}\s*\}/g;attrRE=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[\s\S]*?"|'[\s\S]*?')/g;tagRE=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;whitespaceRE=/^\s*$/;empty=Object.create(null);reactiveVariables=[];constructor(html){let hst2=this.parse(html);hst_markSvg(hst2,false);this.reactiveVariables=this.reactiveVariables.filter((value,index,self)=>{return self.indexOf(value)===index});return{hst:hst2,"reactiveVars":this.reactiveVariables}}keepOneSpace(_t){_t=_t.replace(/\s\s/gm," ");if(/\s\s/gm.test(_t))return this.keepOneSpace(_t);return _t}_clean(_t){_t=_t.replace(/(\r?\n|\r)/gm,"");_t=_t.replace(/(\t)/gm,"");_t=this.keepOneSpace(_t);return _t.replace(/^(?:\s*\t*\r*\n*\{*)+|(?:\s*\t*\r*\n*\})+$/g,"").trim()}processAttr(n,v,res){}processForXAttr(val){let forX={"js":"","as":{"k":"","v":""},"dx":""};var val=val.trim();if(val.indexOf(";")>-1){let zxx=val.split(";");forX["dx"]=zxx[1].trim();val=zxx[0].trim()}if(val.indexOf(" as ")>-1){let arr2=val.split(" as ");let kv=[];let arr3=arr2[1].split(" ").join("").split(",");if(arr3.length>1){kv=[arr3[0],arr3[1]]}else{kv=[arr3[0]]}if(kv.length){forX["as"]["k"]=kv[0].trim();if(kv.length>1){forX["as"]["v"]=kv[1].trim()}}val=arr2[0].trim()}forX["js"]=val.trim();return forX}parseTag(tag){var res={type:"tag",name:"",isV:false,attrs:{},ax:{},evs:{},ex:{},children:[]};var tagMatch=tag.match(/<\/?([^\s]+?)[/\s>]/);if(tagMatch){res.name=tagMatch[1];res.isV=this.htmlVoidElements.includes(tagMatch[1])||tag.charAt(tag.length-2)==="/"}var reg=new RegExp(this.attrRE);var result=null;for(;;){result=reg.exec(tag);if(result===null){break}if(!result[0].trim()){continue}if(result[1]){var attr=result[1].trim();var arr=[attr,""];if(arr[0]==":else"){res.type="section";res.cond=""}if(attr.indexOf("=")>-1){arr=attr.split("=")}if(arr[0].substring(0,1)=="@"){}else{if(res.name.toLowerCase()=="icon"&&arr[0].indexOf(":")>-1&&arr[0].substr(0,1)!=":"){res.icon=arr[0]}else res.attrs[arr[0]]=arr[1]}reg.lastIndex--}else if(result[2]){let sl=result[3].trim().substring(1,result[3].length-1);sl=he.decode(sl);if(result[2]==":if"||result[2]==":else-if"||result[2]==":else"){res.type="section";res.cond=sl;if(sl){try{let condAST=acorn.parse(sl,{ecmaVersion:"latest"});let condVars=this.collectVariableUsageFromAST(condAST,{excludeBuiltins:true,extraBuiltins:[]});for(let X=0;X<condVars.length;X++){this.reactiveVariables.push(condVars[X])}}catch(e){}}}else if(result[2]==":for"){res.type="sections";res.content=sl;res.forX=this.processForXAttr(sl);if(res.forX.js){try{let forAST=acorn.parse(res.forX.js,{ecmaVersion:"latest"});let forVars=this.collectVariableUsageFromAST(forAST,{excludeBuiltins:true,extraBuiltins:[]});for(let X=0;X<forVars.length;X++){this.reactiveVariables.push(forVars[X])}}catch(e){}}}if(result[2].substring(0,1)=="@"){let max=this._getMs2(sl);res.evs[result[2]]=max[1];max[0].length?res.ex[result[2]]=max[0]:null}else{let max=this._getMs2(sl.replace(/`(\{\s*\{[\s\S]*?\}\s*\})`/g,"$1"));if(res.name.toLowerCase()=="icon"&&result[2].indexOf(":")>-1&&result[2].substr(0,1)!=":"){res.icon=result[2]}else res.attrs[result[2]]=max[1];max[0].length?res.ax[result[2]]=max[0]:null}}}hst_orderIfFor(res);return res}removeComments(str){str=str.replace(/<!--[\s\S]*?(?:-->)/g,"");return str}cleanExpression(expression){let cleaned="";let inSingle=false,inDouble=false,inTemplate=false;let inRegex=false,escapeNext=false;let inBlockComment=false,inLineComment=false;for(let i=0;i<expression.length;i++){let char=expression[i];let next=expression[i+1];if(escapeNext){cleaned+=char;escapeNext=false;continue}if(inBlockComment){if(char==="*"&&next==="/"){inBlockComment=false;i++}continue}if(inLineComment){if(char==="\n"){inLineComment=false}continue}if(!inSingle&&!inDouble&&!inTemplate&&!inRegex){if(char==="/"&&next==="*"){inBlockComment=true;i++;continue}if(char==="/"&&next==="/"){inLineComment=true;i++;continue}}if(!inDouble&&!inTemplate&&!inRegex&&char==="'"&&!inSingle){inSingle=true;cleaned+=char;continue}else if(inSingle&&char==="'"){inSingle=false;cleaned+=char;continue}if(!inSingle&&!inTemplate&&!inRegex&&char==='"'&&!inDouble){inDouble=true;cleaned+=char;continue}else if(inDouble&&char==='"'){inDouble=false;cleaned+=char;continue}if(!inSingle&&!inDouble&&!inRegex&&char==="`"&&!inTemplate){inTemplate=true;cleaned+=char;continue}else if(inTemplate&&char==="`"){inTemplate=false;cleaned+=char;continue}if(!inSingle&&!inDouble&&!inTemplate&&char==="/"&&!inRegex){let prevNonSpace=cleaned.match(/\S$/);if(!prevNonSpace||/[=({[,;:?!+\-*/%&|^~<>]/.test(prevNonSpace[0])){inRegex=true}cleaned+=char;continue}else if(inRegex&&char==="/"&&expression[i-1]!=="\\"){inRegex=false;cleaned+=char;continue}if(char==="\\"&&(inSingle||inDouble||inTemplate||inRegex)){escapeNext=true;cleaned+=char;continue}if(!inSingle&&!inDouble&&!inTemplate&&!inRegex){if(/\s/.test(char)){if(cleaned[cleaned.length-1]!==" "){cleaned+=" "}continue}}cleaned+=char}return cleaned.trim()}_getMs(_t,wbt){let result="";let lastIndex=0;let _m;var _ms=[];let hasError=false;while((_m=this.moustachePattern.exec(_t))!=null){try{let AST=acorn.parse(_m[0],{ecmaVersion:"latest"});hasError=false;let mux=this._clean(_m[0]);if(wbt){if(_t.substring(_m.index-1,1)=="`"){_ms.push(mux);result+=_t.substring(lastIndex,_m.index);result+="{{"+mux+"}}";lastIndex=_m.index+_m[0].length}}else{if(_t.substring(_m.index-1,1)!="`"){_ms.push(mux);result+=_t.substring(lastIndex,_m.index);result+="{{"+mux+"}}";lastIndex=_m.index+_m[0].length}}}catch(e){hasError=true;result+=_t.substring(lastIndex,_m.index);result+="{{ /*Invalid Javascript Code*/ }}";console.log("Invalid JS",_m[0])}}if(!hasError)result+=_t.substring(lastIndex);return[_ms,result]}_getMs2(_t,wbt){let content="";let lastIndex=0;let _m;var _muxes=[];let hasError=false;while((_m=this.moustachePattern.exec(_t))!=null){try{hasError=false;let mux=this._clean(_m[0]);let JST=acorn.parse(mux,{ecmaVersion:"latest"});let rvs=[];let vss=this.collectVariableUsageFromAST(JST,{excludeBuiltins:true,extraBuiltins:[]});for(let X=0;X<vss.length;X++){rvs.push(vss[X]);this.reactiveVariables.push(vss[X])}rvs=rvs.filter((value,index,self)=>{return self.indexOf(value)===index});_muxes.push({"mus":mux,"rvs":rvs});content+=_t.substring(lastIndex,_m.index);content+="{{"+mux+"}}";lastIndex=_m.index+_m[0].length}catch(e){hasError=true;content+=_t.substring(lastIndex,_m.index);content+="{{ /*Invalid Javascript Code*/ }}";console.log("Invalid JS",_m[0])}}if(!hasError)content+=_t.substring(lastIndex);_muxes=this.setMuxesIndexes(content,_muxes);return[_muxes,content]}setMuxesIndexes(content,_muxes){let muxes=[];let lastIndex=0;let i=0;let _m;while((_m=this.moustachePattern.exec(content))!=null){muxes.push({..._muxes[i],"start":_m.index,"end":_m.index+_m[0].length});lastIndex=_m.index+_m[0].length;i++}return muxes}parse(html,options){if(options===void 0){options={}}options||(options={});options.components||(options.components=this.empty);html=this.removeComments(html);var result=[];var arr=[];var current;var level=-1;var inComponent=false;var inRawText=false;var par=this;if(html.indexOf("<")!==0){var end=html.indexOf("<");let zl=end===-1?html:html.substring(0,end);let mssx=this._getMs2(zl);let textObj={type:"text",content:mssx[1],mss:mssx[0]};result.push(textObj)}html.replace(this.tagRE,async function(tag,index){if(inComponent||inRawText){if(tag!=="</"+current.name+">"){return""}else{inComponent=false;inRawText=false}}var isOpen=tag.charAt(1)!=="/";var start=index+tag.length;var nextChar=html.charAt(start);var parent;if(isOpen){level++;current=par.parseTag(tag);if(current.type==="tag"&&(current.name==="script"||current.name==="style")){inRawText=true}if(current.type==="tag"&¤t.name&&options.components&&options.components[current.name]){current.type="component";inComponent=true}if(!current.isV&&!inComponent&&nextChar&&nextChar!=="<"&&Array.isArray(current.children)){let end2;if(current.name==="script"||current.name==="style"){let closeRe=new RegExp("</\\s*"+current.name+"\\s*>","i");let m=closeRe.exec(html.slice(start));end2=m?start+m.index:html.length}else{end2=html.indexOf("<",start);while(html.charAt(end2+1)==" "){end2=html.indexOf("<",start+(end2+1-start))}}let hl=html.slice(start,end2);let mssx=null;if(current.name!="script")mssx=par._getMs2(hl);let textObj={type:"text",content:current.name=="script"?"":mssx[1],...current.name=="script"?scriptPayload(hl):{mss:mssx[0]},tag:current.name};current.children.push(textObj)}if(level===0){result.push(current)}parent=arr[level-1];if(parent&&parent.children){parent.children.push(current)}arr[level]=current}if(!isOpen||current.isV){if(level>-1&&(current.isV||current.name===tag.slice(2,-1))){level--;current=level===-1?result:arr[level]}if(!inComponent&&nextChar!=="<"&&nextChar){parent=level===-1?result:arr[level].children;var _end=html.indexOf("<",start);var content=html.slice(start,_end===-1?void 0:_end);let wsOnly=par.whitespaceRE.test(content);if(wsOnly?_end>-1&&parent&&Array.isArray(parent):true){if(parent&&Array.isArray(parent)){if(wsOnly){parent.push({type:"text",content,mss:[]})}else{let mssx=par._getMs2(content);let textObj={type:"text",content:mssx[1],mss:mssx[0]};parent.push(textObj)}}}}}});return result}collectVariableUsageFromAST(ast,options={}){const{excludeBuiltins=true,extraBuiltins=[]}=options;const DEFAULT_BUILTINS=new Set(["undefined","NaN","Infinity","null","true","false","Object","Function","Boolean","Symbol","Error","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","Number","BigInt","Math","Date","String","RegExp","Array","Map","Set","WeakMap","WeakSet","Promise","Reflect","Proxy","Intl","JSON","Atomics","SharedArrayBuffer","ArrayBuffer","DataView","WeakRef","FinalizationRegistry","console","window","document","navigator","location","localStorage","sessionStorage","fetch","XMLHttpRequest","setTimeout","clearTimeout","setInterval","clearInterval","requestAnimationFrame","cancelAnimationFrame","process","global","globalThis","require","module","exports","Buffer","parseInt","parseFloat","isFinite","isNaN","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","escape","unescape"]);const builtinSet=new Set([...DEFAULT_BUILTINS,...extraBuiltins]);function createScope(parent=null,isFunction=false){return{parent,isFunction:!!isFunction,names:new Set}}const scopeForNode=new WeakMap;const bindingIdNodes=new WeakSet;const allDeclaredNames=new Set;function markPatternBindings(pattern,scope,kind="var"){if(!pattern)return;switch(pattern.type){case"Identifier":bindingIdNodes.add(pattern);declareInScope(pattern.name,kind,scope);allDeclaredNames.add(pattern.name);break;case"ArrayPattern":for(const el of pattern.elements)if(el)markPatternBindings(el,scope,kind);break;case"ObjectPattern":for(const p of pattern.properties){if(p.type==="Property")markPatternBindings(p.value,scope,kind);else if(p.type==="RestElement")markPatternBindings(p.argument,scope,kind)}break;case"RestElement":markPatternBindings(pattern.argument,scope,kind);break;case"AssignmentPattern":markPatternBindings(pattern.left,scope,kind);break;default:break}}function declareInScope(name,kind,currentScope){if(!name||!currentScope)return;if(kind==="var"||kind==="function"){let s=currentScope;while(s&&!s.isFunction&&s.parent)s=s.parent;s.names.add(name)}else{currentScope.names.add(name)}}function buildScopes(node,currentScope){if(!node||typeof node!=="object")return;switch(node.type){case"Program":{scopeForNode.set(node,currentScope);for(const stmt of node.body)buildScopes(stmt,currentScope);return}case"FunctionDeclaration":{if(node.id){bindingIdNodes.add(node.id);declareInScope(node.id.name,"function",currentScope);allDeclaredNames.add(node.id.name)}const fnScope=createScope(currentScope,true);scopeForNode.set(node,fnScope);for(const p of node.params)markPatternBindings(p,fnScope,"param");buildScopes(node.body,fnScope);return}case"FunctionExpression":{const fnScope=createScope(currentScope,true);scopeForNode.set(node,fnScope);if(node.id){bindingIdNodes.add(node.id);declareInScope(node.id.name,"let",fnScope);allDeclaredNames.add(node.id.name)}for(const p of node.params)markPatternBindings(p,fnScope,"param");buildScopes(node.body,fnScope);return}case"ArrowFunctionExpression":{const fnScope=createScope(currentScope,true);scopeForNode.set(node,fnScope);for(const p of node.params)markPatternBindings(p,fnScope,"param");buildScopes(node.body,fnScope);return}case"BlockStatement":case"StaticBlock":case"SwitchStatement":{const blockScope=createScope(currentScope,false);scopeForNode.set(node,blockScope);if(node.type==="SwitchStatement"){for(const c of node.cases)buildScopes(c,blockScope)}else{for(const s of node.body)buildScopes(s,blockScope)}return}case"CatchClause":{const catchScope=createScope(currentScope,false);scopeForNode.set(node,catchScope);if(node.param)markPatternBindings(node.param,catchScope,"let");buildScopes(node.body,catchScope);return}case"ForStatement":case"ForInStatement":case"ForOfStatement":{const forScope=createScope(currentScope,false);scopeForNode.set(node,forScope);if(node.init)buildScopes(node.init,forScope);if(node.left)buildScopes(node.left,forScope);if(node.test)buildScopes(node.test,forScope);if(node.update)buildScopes(node.update,forScope);buildScopes(node.body,forScope);return}case"VariableDeclaration":{for(const decl of node.declarations||[]){markPatternBindings(decl.id,currentScope,node.kind||"var");if(decl.init)buildScopes(decl.init,currentScope)}return}case"ClassDeclaration":{if(node.id){bindingIdNodes.add(node.id);declareInScope(node.id.name,"let",currentScope);allDeclaredNames.add(node.id.name)}if(node.body)buildScopes(node.body,currentScope);return}case"ImportDeclaration":{for(const spec of node.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declareInScope(spec.local.name,"const",currentScope);allDeclaredNames.add(spec.local.name)}}return}case"ExportNamedDeclaration":case"ExportDefaultDeclaration":case"ExportAllDeclaration":{if(node.declaration)buildScopes(node.declaration,currentScope);return}default:break}for(const key of Object.keys(node)){if(key==="loc"||key==="range")continue;const child=node[key];if(Array.isArray(child)){for(const c of child)if(c&&typeof c==="object")buildScopes(c,currentScope)}else if(child&&typeof child==="object"){buildScopes(child,currentScope)}}}const rootScope=createScope(null,true);scopeForNode.set(ast,rootScope);buildScopes(ast,rootScope);const usageSet=new Set;function isVariableUsageIdentifier(node,parent,propName){if(!parent)return true;if(bindingIdNodes.has(node))return false;if(parent.type==="LabeledStatement"&&propName==="label"||(parent.type==="BreakStatement"||parent.type==="ContinueStatement")&&propName==="label"){return false}if(parent.type==="MemberExpression"&&propName==="property"&&parent.computed===false){return false}if(parent.type==="Property"&&propName==="key"&&parent.computed===false&&!parent.shorthand){return false}if((parent.type==="MethodDefinition"||parent.type==="PropertyDefinition")&&propName==="key"&&parent.computed===false){return false}if(parent.type&&(parent.type.startsWith("Import")||parent.type.startsWith("Export")||parent.type==="MetaProperty")){return false}if((parent.type==="FunctionDeclaration"||parent.type==="FunctionExpression"||parent.type==="ClassDeclaration")&&propName==="id"){return false}if(parent.type==="VariableDeclarator"&&propName==="id"||parent.type==="CatchClause"&&propName==="param"){return false}if((parent.type==="CallExpression"||parent.type==="OptionalCallExpression")&&propName==="callee"){return false}if(parent.type==="NewExpression"&&propName==="callee"){return false}return true}const scopeStack=[rootScope];function collect(node,parent,propName,index){if(!node||typeof node!=="object")return;const nodeScope=scopeForNode.get(node);if(nodeScope)scopeStack.push(nodeScope);if(node.type==="Identifier"){if(isVariableUsageIdentifier(node,parent,propName)){const name=node.name;if(!(excludeBuiltins&&builtinSet.has(name))){usageSet.add(name)}}}for(const key of Object.keys(node)){if(key==="loc"||key==="range")continue;const child=node[key];if(Array.isArray(child)){for(let i=0;i<child.length;i++){const c=child[i];if(c&&typeof c==="object")collect(c,node,key,i)}}else if(child&&typeof child==="object"){collect(child,node,key,null)}}if(nodeScope)scopeStack.pop()}collect(ast,null,null,null);const self=this;(function findTpl(node){if(!node||typeof node!=="object")return;if(node.type==="TemplateLiteral"&&node.expressions.length===0&&node.quasis.length===1){const inner=node.quasis[0].value.cooked;if(inner&&inner.trim()){try{const innerAst=_acorn.parse(inner,{ecmaVersion:"latest",sourceType:"script"});for(const n of self.collectVariableUsageFromAST(innerAst,options))usageSet.add(n)}catch(e){}}return}for(const key of Object.keys(node)){if(key==="loc"||key==="range")continue;const child=node[key];if(Array.isArray(child))child.forEach(findTpl);else if(child&&typeof child==="object")findTpl(child)}})(ast);return Array.from(usageSet).sort()}}function _hst(html){return new hst(html)}function copyDir(src,dest,projectName){try{const entries=fs.readdirSync(src,{encoding:"utf8",withFileTypes:true});cd(dest);for(let entry of entries){const srcPath=path.join(src.toString(),entry.name.toString());const destPath=path.join(dest.toString(),entry.name.toString());if(entry.isDirectory()){if(projectName=="_beajsBuild"){if(entry.name!="layouts"&&entry.name!="views"&&entry.name!="css"&&entry.name!="js")copyDir(srcPath,destPath,projectName)}else copyDir(srcPath,destPath,projectName)}else{if(projectName=="_beajsBuild"){if(projectName=="_beajsBuild"&&entry.name!="index.js"&&entry.name!="index.html")fs.copyFileSync(srcPath,destPath)}else{if(!fs.existsSync(destPath)){if(projectName){if(entry.name=="index.html"){let html5=Buffer.from(fs.readFileSync(srcPath).toString().split("[ProjectName]").join(ucwords(projectName)));fs.writeFileSync(destPath,html5)}else if(entry.name=="package.json"){let slug=lw(projectName).replace(/[^a-z0-9._-]+/g,"-").replace(/^[-.]+|[-.]+$/g,"")||"lumenjs-project";let pkgJson=Buffer.from(fs.readFileSync(srcPath).toString().split("[ProjectName]").join(slug));fs.writeFileSync(destPath,pkgJson)}else fs.copyFileSync(srcPath,destPath)}else fs.copyFileSync(srcPath,destPath)}else{console.log("File already exists:",destPath)}}}}}catch(e){console.log(e)}}exports.copyDir=copyDir;function validURL(string){let url;try{url=new URL(string)}catch(_){return false}return url.protocol==="http:"||url.protocol==="https:"}exports.validURL=validURL;let getPairs=(obj,keys=[])=>Object.entries(obj).reduce((pairs,[key,value])=>{if(typeof value==="object")pairs.push(...getPairs(value,[...keys,key]));else pairs.push([[...keys,key],value]);return pairs},[]);function pairIt(obj){return getPairs(obj).map(([[key0,...keysRest],value])=>`${key0}${keysRest.map(a=>`[${a}]`).join("")}=${value}`).join("&")}var API={get:async function(u,d,h,a){return await this.req(u,d,h,"GET",a)},put:async function(u,d,h,a){return await this.req(u,d,h,"PUT",a)},post:async function(u,d,h,a){return await this.req(u,d,h,"POST",a)},delete:async function(u,d,h,a){return await this.req(u,d,h,"DELETE",a)},patch:async function(u,d,h,a){return await this.req(u,d,h,"PATCH",a)},req:async function(u,d,h,m,a,f){var urled=validURL(u)?u:config.apis[a??0].baseURL+u;if(m.toString().toLowerCase()=="get"){if(urled.indexOf("?")>-1)urled=urled+"&"+pairIt(d??{});else urled=urled+"?"+pairIt(d??{})}let resa=await fetch(urled,{method:m.toString().toLowerCase(),body:m.toString().toLowerCase()=="get"?null:JSON.stringify(d??{}),headers:h??config.apis[a??0].headers});if(f)return resa;let res=await resa.text();try{return JSON.parse(res)}catch(e){return res}}};exports.API=API;function updateCore(){var libsPath=`${__dirname}`+path.sep+`files`+path.sep+`libs`;var projectJsPath=process.cwd()+path.sep+"src"+path.sep+"js"+path.sep+"lm.js";var projectCssPath=process.cwd()+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css";if(!fs.existsSync(process.cwd()+path.sep+"config.json")||!fs.existsSync(process.cwd()+path.sep+"src")){console.log("This doesn't look like a LumenJS project (no config.json/src here) \u2014 run this from your project's root.");return}if(!fs.existsSync(libsPath+path.sep+"lm.js")){console.log("This CLI install has no bundled runtime to copy from \u2014 reinstall @lmjs/cli.");return}addAgentFiles(process.cwd());var oldSize=fs.existsSync(projectJsPath)?fs.statSync(projectJsPath).size:null;var newJs=fs.readFileSync(libsPath+path.sep+"lm.js");var newSize=newJs.length;if(oldSize===newSize){console.log("Already up to date \u2014 this project's src/js/lm.js already matches the installed @lmjs/cli's runtime ("+newSize+" bytes). Nothing to do.");return}fs.writeFileSync(projectJsPath,newJs);if(fs.existsSync(libsPath+path.sep+"mobius.css")){fs.writeFileSync(projectCssPath,fs.readFileSync(libsPath+path.sep+"mobius.css"))}console.log("Updated src/js/lm.js"+(oldSize!==null?" (was "+oldSize+" bytes, now "+newSize+" bytes)":" (was missing, now "+newSize+" bytes)")+" \u2014 matches the currently installed @lmjs/cli.")}exports.updateCore=updateCore;function addAgentFiles(projectPath){var tplDir=path.join(__dirname,"files","project");var added=[];["AGENTS.md","CLAUDE.md"].forEach(function(f){var dest=path.join(projectPath,f);if(!fs.existsSync(dest)&&fs.existsSync(path.join(tplDir,f))){fs.copyFileSync(path.join(tplDir,f),dest);added.push(f)}});if(added.length)console.log("Added "+added.join(" + ")+" (points AI coding agents at the LumenJS reference).");return added}exports.addAgentFiles=addAgentFiles;exports.processCommand=processCommands;exports.startServer=startServer;exports.create=create;function processCommands(cmd){var command=cmd?cmd:process.argv[2];if(command=="run"||command=="serve"){startServer()}else if(command=="create"||command=="update"){let c=process.argv.slice(3,process.argv.length);let t=lw(c[0]);create({type:t[0]=="-"?t.split("-").join(""):t,name:t[0]=="-"?c.slice(1,c.length):c})}else if(command=="update-core"){updateCore()}else if(command=="purge"){console.log("(lm purge now does the same thing as `lm update-core` \u2014 prefer that name going forward.)");updateCore()}else if(command=="build"){let cmds=process.argv;_bp(cmds)}else if(command=="login"){_vault.login()}else if(command=="api"){let sub=process.argv[3];let name=process.argv[4];if(sub=="set")_vault.apiSet(name);else if(sub=="update")_vault.apiUpdate(name);else if(sub=="get")_vault.apiGet(name);else if(sub=="list")_vault.apiList();else if(sub=="remove")_vault.apiRemove(name);else console.log("Usage: lm api <set|get|update|list|remove> [name]")}else if(command=="-v"||command=="-version"){let _pkgJsonPath=fs.existsSync(path.join(__dirname,"..","..","package.json"))?path.join(__dirname,"..","..","package.json"):path.join(__dirname,"..","package.json");console.log("LumenJS version "+require(_pkgJsonPath).version)}else{console.log("LumenJS CLI's command not found!")}}async function _bp(cmds){import("ora").then(async({default:ora,oraPromise})=>{const spinner=ora({color:"green"});spinner.succeed("Started Building Project For Production").start("Gathering Required Resources..");var projectPath=`${process.cwd()}`;if(!checkProjectRuntime(projectPath)){spinner.fail("Build stopped: run `lm update-core` first, then build again.");process.exit(1)}var dest=projectPath+path.sep+"dist";let _views=getAllFiles(`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep,{},false,true);let _layoutsDir=`${process.cwd()}`+path.sep+`src`+path.sep+`layouts`+path.sep;let _layouts=fs.existsSync(_layoutsDir)?annotateLayoutRegions(getAllFiles(_layoutsDir,{},false,true)):{};let _tpls=readTemplates(`${process.cwd()}`);linkTemplateReactiveVars(_views,_tpls);linkTemplateReactiveVars(_layouts,_tpls);var indexCode=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"index.html","utf8");let _cssDir=projectPath+path.sep+`src`+path.sep+"css"+path.sep;let _mainCssName=["mobius.css","bea.css"].find(f=>fs.existsSync(_cssDir+f))||null;var beaCSSCode=_mainCssName?fs.readFileSync(_cssDir+_mainCssName,"utf8"):"";var indexJs=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"index.js","utf8");let _hasOwnDeps=_npmBundle.hasOwnDependencies(projectPath);let _localScriptSrcs=detectLocalProjectScripts(String(indexCode));let _compiledScripts="";for(const src of _localScriptSrcs){let scriptPath=projectPath+path.sep+"src"+path.sep+src.split("/").join(path.sep).replace(/^\\|^\//,"");try{let raw=_hasOwnDeps?_npmBundle.buildEntryWithImports(scriptPath,projectPath):fs.readFileSync(scriptPath,"utf8");_compiledScripts+="\n"+compileProjectScript(raw,src);indexCode=indexCode.split(new RegExp(`<script\\b[^>]*\\bsrc\\s*=\\s*["']`+src.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+`["'][^>]*>\\s*<\\/script>`,"i")).join("")}catch(e){}}let _uncompiledScripts=precompileViewScripts([{kind:"views",files:_views},{kind:"layouts",files:_layouts},{kind:"tpls",files:_tpls}]);let vt=`
|
|
1
|
+
const fetch=require("node-fetch");const path=require("path");const fs=require("fs");const nodemon=require("nodemon");var _acorn=require("acorn");var acorn=require("acorn-loose");const _hstLib=require("./hst.js");const{parseScriptJs,scriptPayload,stripAstPositions,annotateLayoutRegions,hst_markSvg,hst_orderIfFor,_hst}=_hstLib;exports.scriptPayload=scriptPayload;exports.stripAstPositions=stripAstPositions;exports.annotateLayoutRegions=annotateLayoutRegions;exports.hst_orderIfFor=hst_orderIfFor;function precompileViewScripts(groups){let failed=0;function visit(nodes,vars,inSection,file){if(!Array.isArray(nodes))return;for(const n of nodes){if(!n||n.type==="text")continue;const sectioned=inSection||n.type==="section"||n.type==="sections";const nm=String(n.name||"").toLowerCase();if((nm==="script"||nm==="js")&&Array.isArray(n.children)&&n.children[0]&&n.children[0].type==="text"){const t=n.children[0];if(t.content||t.jst){try{const ast=t.jst||_acorn.parse(t.content,{ecmaVersion:"latest",sourceType:"script"});const code=_walk.getWatcher(ast,{name:file},sectioned?void 0:(vars||[]).slice(),["__LMROOT__"]).code;new Function(code);t.pre=code;delete t.content;delete t.jst}catch(e){failed++;console.warn("\x1B[33mLumenJS: could not precompile a <script> in "+file+": "+(e&&e.message)+" (it will be compiled in the browser)\x1B[0m")}}}visit(n.children,vars,sectioned,file)}}for(const group of groups){const isTpl=group.kind==="tpls";for(const key in group.files){const entry=group.files[key];if(!entry||!Array.isArray(entry.hst))continue;const file=Buffer.from(key,"base64").toString().split(/[\\/]/).slice(-2).join("/");visit(entry.hst,entry.reactiveVars,isTpl,file)}}return failed}exports.precompileViewScripts=precompileViewScripts;function stripDevOnlyRuntime(src){const a=src.indexOf("var __lmDevOnlyStart__ = 1;");const b=src.indexOf("var __lmDevOnlyEnd__ = 1;");if(a<0||b<a)return src;return src.slice(0,a)+src.slice(b+"var __lmDevOnlyEnd__ = 1;".length)}exports.stripDevOnlyRuntime=stripDevOnlyRuntime;const _HST_EMPTY_OBJ={attrs:1,ax:1,evs:1,ex:1};function compactHstReplacer(key,value){if(_HST_EMPTY_OBJ[key]===1&&value&&typeof value==="object"&&!Array.isArray(value)&&Object.keys(value).length===0)return void 0;if(key==="isV"&&value===false)return void 0;if((key==="mss"||key==="children")&&Array.isArray(value)&&value.length===0)return void 0;return value}exports.compactHstReplacer=compactHstReplacer;var _min=require("html-minifier").minify;var he=require("he");const _FD=require("ftp-deploy");const _fD=new _FD;global.astring=global.astring||require("astring");const _corePackageDir=path.dirname(require.resolve("@lmjs/core/package.json"));const _walk=require(path.join(_corePackageDir,"src","walk.js"));const _npmBundle=require(path.join(__dirname,"npm-bundle.js"));exports.hasOwnDependencies=_npmBundle.hasOwnDependencies;exports.buildEntryWithImports=_npmBundle.buildEntryWithImports;const _pluginsBundle=require(path.join(__dirname,"plugins-esbuild-plugin.js"));const _vault=require(path.join(__dirname,"vault.js"));exports.login=_vault.login;exports.apiSet=_vault.apiSet;exports.apiUpdate=_vault.apiUpdate;exports.apiGet=_vault.apiGet;exports.apiList=_vault.apiList;exports.apiRemove=_vault.apiRemove;function selectedProjectPlugins(projectRoot){try{let deps={};const pkgPath=path.join(projectRoot,"package.json");if(fs.existsSync(pkgPath)){const pkg=JSON.parse(fs.readFileSync(pkgPath,"utf8"));Object.assign(deps,pkg.dependencies||{})}for(const key of detectUsedPlugins(projectRoot))if(!deps.hasOwnProperty(key))deps[key]="*";if(!Object.keys(deps).length)return[];return _pluginsBundle.selectedRegistryEntries(deps)}catch(e){return[]}}exports.selectedProjectPlugins=selectedProjectPlugins;const PLUGIN_SIGNATURES={"select2":[/\.select2\s*\(/,/<[a-z][^>]*\s(?:sl|slct)(?=[\s>=\/])/i],"flickity":[/\.flickity\s*\(/,/\bFlickity\b/,/<[a-z][^>]*\scrslf(?=[\s>=\/])/i],"bootstrap-colorpicker":[/\.colorpicker\s*\(/,/<input[^>]*\scolor(?=[\s>=\/])/i],"bootstrap-datetimepicker":[/\.datetimepicker\s*\(/,/<input[^>]*\s(?:date|time|datetime)(?=[\s>=\/])/i],"jquery-ui-dist":[/\.(?:sortable|draggable|droppable|resizable|datepicker|autocomplete|slider|accordion)\s*\(/,/<[a-z][^>]*\s(?:sort|drag|drop)(?=[\s>=\/])/i],"jquery.easing":[/\beas(?:e|ing)(?:In|Out)[A-Z]\w*/],"nestedSortable":[/\.nestedSortable\s*\(/],"jquery.numeric":[/\.numeric\s*\(/,/<input[^>]*\s(?:numeric|integer|decimal)(?=[\s>=\/])/i],"timeago":[/\.timeago\s*\(/,/\$\.timeago\b/],"slick-carousel":[/\.(?:crsl|slick)\s*\(/,/<[a-z][^>]*\scrsl(?=[\s>=\/])/i],"@iconify/iconify":[/class=["'][^"']*\biconify\b/,/\bIconify\./],"rellax":[/\bRellax\b/],"headroom.js":[/\bHeadroom\b/,/<[a-z][^>]*\spinnable(?=[\s>=\/])/i],"in-view":[/\binView\b/],"gsap":[/\bgsap\b/,/\bTween(?:Max|Lite)\b/,/\bTimeline(?:Max|Lite)\b/],"jquery.caret":[/\.caret\s*\(/],"jquery-tageditor":[/\.tagEditor\s*\(/,/<[a-z][^>]*\stags(?=[\s>=\/])/i],"jquery-lazy":[/\.lazy\s*\(/,/<img[^>]*\slazy(?=[\s>=\/])/i]};function detectUsedPlugins(projectRoot){const src=path.join(projectRoot,"src");if(!fs.existsSync(src))return[];let indexHtml="";try{indexHtml=fs.readFileSync(path.join(src,"index.html"),"utf8")}catch(e){}const texts=[];(function walk(dir){let entries;try{entries=fs.readdirSync(dir,{withFileTypes:true})}catch(e){return}for(const e of entries){const p=path.join(dir,e.name);if(e.isDirectory()){if(e.name==="node_modules"||e.name==="js"||e.name==="css"||e.name==="images")continue;walk(p)}else if(/\.(view|tpl|layout)$/.test(e.name)){try{texts.push(fs.readFileSync(p,"utf8"))}catch(x){}}}})(src);try{texts.push(fs.readFileSync(path.join(src,"index.js"),"utf8"))}catch(e){}for(const s of detectLocalProjectScripts(indexHtml)){try{texts.push(fs.readFileSync(path.join(src,s.replace(/^\//,"")),"utf8"))}catch(e){}}const all=texts.join("\n");const loadedByPage=key=>new RegExp(`<script[^>]+src=["'][^"']*`+key.replace(/^@[^/]+\//,"").replace(/\.js$/,"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i").test(indexHtml);const found=[];for(const key in PLUGIN_SIGNATURES){if(loadedByPage(key))continue;if(PLUGIN_SIGNATURES[key].some(re=>re.test(all)))found.push(key)}return found}exports.detectUsedPlugins=detectUsedPlugins;function compileProjectScript(source,name){let ast=_acorn.parse(source,{ecmaVersion:"latest",sourceType:"script"});let topLevelNames=[];for(const stmt of ast.body){if(stmt.type==="VariableDeclaration"){for(const d of stmt.declarations){if(d.id&&d.id.type==="Identifier")topLevelNames.push(d.id.name)}}}return _walk.getWatcher(ast,{name:name||"script"},topLevelNames,"Global").code}exports.compileProjectScript=compileProjectScript;function placePluginsCss(html,cssTag){html=String(html);let at=html.search(/<link\b[^>]*href=["']\/css\//i);return at>=0?html.slice(0,at)+cssTag+"\n "+html.slice(at):html.split("</head>").join(" "+cssTag+"\n</head>")}exports.placePluginsCss=placePluginsCss;function detectLocalProjectScripts(indexHtmlSource){let found=[];let re=/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi;let m;indexHtmlSource=String(indexHtmlSource).replace(/<!--[\s\S]*?-->/g,"");while(m=re.exec(indexHtmlSource)){let src=m[1];if(src.indexOf("/")!==0)continue;if(src==="/js/lm.js"||src==="/index.js")continue;if(/^\/js\/bea\.js(\?|$)/.test(src))continue;found.push(src)}return found}exports.detectLocalProjectScripts=detectLocalProjectScripts;const CORE_Libs={BEACSS:"https://s.beacdn.com/beacss/latest",COREJS:"https://lmjs.beacdn.com/latest"};const HST_FORMAT_VERSION=3;exports.HST_FORMAT_VERSION=HST_FORMAT_VERSION;function checkProjectRuntime(projectPath){try{let lm=fs.readFileSync(path.join(projectPath,"src","js","lm.js"),"utf8");let m=/EXPECTED_HST_FORMAT_VERSION\s*=\s*(\d+)/.exec(lm);let accepts=/_HST_FORMATS_ACCEPTED\s*=\s*\[([\d,\s]+)\]/.exec(lm);let ok=accepts?accepts[1].split(",").map(Number).indexOf(HST_FORMAT_VERSION)>-1:m&&Number(m[1])===HST_FORMAT_VERSION;if(m&&!ok){console.warn("\n\x1B[33mLumenJS: src/js/lm.js is older than this CLI (it expects HST v"+m[1]+", this CLI emits v"+HST_FORMAT_VERSION+"). Run `lm update-core` to update the project's runtime.\x1B[0m\n");return false}}catch(e){}return true}exports.checkProjectRuntime=checkProjectRuntime;exports.getAllFiles=getAllFiles;exports.ucwords=ucwords;exports.fetch=fetch;exports.getConfig=getConfig;function getConfig(){config={version:"1.0.0.1",server:{host:"127.0.0.1",port:"3000",ssl:{enabled:false,key:"/key.pem",cert:"/certificate.cer"}},apis:[{baseURL:"https://www.beaapis.com/1",headers:{"X-BEA-Application-ID":"YOUR_APPLICATION_ID","X-BEA-Authorization":"YOUR_REST_API_KEY"}}],ftp:{host:"ftp_host",username:"ftp_username",password:"ftp_password",remotePath:"/",concurrency:4,protocol:"ftp",port:21,ignore:[],syncOption:{delete:false,ignoreExisting:false,skipCreate:false,update:true},connectTimeout:3e4}};let configPath=process.cwd()+path.sep+`config.json`;if(fs.existsSync(configPath)){config=JSON.parse(fs.readFileSync(configPath,{encoding:"utf8"}))}return config}var config=getConfig();function ucwords(str){return(str+"").replace(/^([a-z])|\s+([a-z])/g,function($1){return $1.toUpperCase()})}function lw(s){return s.toString().toLowerCase()}exports.lw=lw;function cd(d){if(!fs.existsSync(d))fs.mkdirSync(d)}exports.cd=cd;function rd(d){if(fs.existsSync(d))fs.rmSync(d,{recursive:true,force:true})}exports.rd=rd;function create(conf){let t=conf.type=="v"||conf.type=="s"||conf.type=="t"?conf.type:"p";let n=conf.type=="v"||conf.type=="s"||conf.type=="t"?lw(conf.name[0]):conf.name.join(" ");if(t=="p"){var libsPath=`${__dirname}`+path.sep+`files`+path.sep+`libs`;var getLibs=false;var _beacssMissing=false;var _lmMissing=false;require("dns").resolve("www.google.com",function(err){if(!err){var _mobiuscssPath=libsPath+path.sep+"mobius.css";_beacssMissing=!fs.existsSync(_mobiuscssPath)||fs.statSync(_mobiuscssPath).size===0;_lmMissing=!fs.existsSync(libsPath+path.sep+"lm.js");if(_lmMissing||_beacssMissing)getLibs=true}if(getLibs){API.get(CORE_Libs.COREJS,{}).then(corejs=>{API.get(CORE_Libs.BEACSS,{}).then(mobiuscss=>{var libsPath2=`${__dirname}`+path.sep+`files`+path.sep+`libs`;cd(libsPath2);if(_lmMissing){fs.writeFileSync(libsPath2+path.sep+"lm.js",String(corejs))}if(_beacssMissing){fs.writeFileSync(libsPath2+path.sep+"mobius.css",String(mobiuscss))}var filePath3=`${process.cwd()}`+path.sep;copyDir(`${__dirname}`+path.sep+`files`+path.sep+`project`,filePath3,n);cd(filePath3+path.sep+"src");cd(filePath3+path.sep+"src"+path.sep+"css");cd(filePath3+path.sep+"src"+path.sep+"images");cd(filePath3+path.sep+"src"+path.sep+"js");let stylesFile=filePath3+path.sep+"src"+path.sep+"css"+path.sep+`styles.css`;let faviconFile=filePath3+path.sep+"src"+path.sep+`favicon.ico`;if(!fs.existsSync(stylesFile))fs.writeFileSync(stylesFile,String(""));if(!fs.existsSync(faviconFile))fs.writeFileSync(faviconFile,String(""));fs.writeFileSync(filePath3+path.sep+"src"+path.sep+"js"+path.sep+"lm.js",String(corejs));fs.writeFileSync(filePath3+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css",String(mobiuscss))})}).catch(err2=>{})}else{var filePath2=`${process.cwd()}`+path.sep;copyDir(`${__dirname}`+path.sep+`files`+path.sep+`project`,filePath2,n);cd(filePath2+path.sep+"src");cd(filePath2+path.sep+"src"+path.sep+"css");cd(filePath2+path.sep+"src"+path.sep+"images");cd(filePath2+path.sep+"src"+path.sep+"js");let stylesFile=filePath2+path.sep+"src"+path.sep+"css"+path.sep+`styles.css`;let faviconFile=filePath2+path.sep+"src"+path.sep+`favicon.ico`;if(!fs.existsSync(stylesFile))fs.writeFileSync(stylesFile,String(""));if(!fs.existsSync(faviconFile))fs.writeFileSync(faviconFile,String(""));let corejs=Buffer.from(fs.readFileSync(libsPath+path.sep+"lm.js").toString());let mobiuscss=Buffer.from(fs.readFileSync(libsPath+path.sep+"mobius.css").toString());fs.writeFileSync(filePath2+path.sep+"src"+path.sep+"js"+path.sep+"lm.js",String(corejs));fs.writeFileSync(filePath2+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css",String(mobiuscss))}})}else{let file=t=="s"?"sub_view.view":t=="t"?"layout.layout":"view.view";let ident=t=="s"?"SubView":t=="t"?"Template":"View";let dir=t=="t"?"layouts":"views";let ext=t=="t"?"layout":"view";let html5=Buffer.from(fs.readFileSync(`${__dirname}`+path.sep+`files`+path.sep+file).toString().split("["+ident+"Name]").join(ucwords(n)));var filePath=`${process.cwd()}`+path.sep+`src`+path.sep+dir+path.sep+`${n}.${ext}`;if(fs.existsSync(filePath)){console.log(ident+" already exists:",filePath)}else{fs.writeFileSync(filePath,html5)}}}function getAllFiles(dirPath,arrayOfFiles={},mini=false,hst=true){files=fs.readdirSync(dirPath);files.forEach(function(file){if(fs.statSync(dirPath+path.sep+file).isDirectory()){arrayOfFiles=getAllFiles(dirPath+path.sep+file,arrayOfFiles,mini,hst)}else{let filePath=path.join(dirPath,path.sep,file);let fileKey=Buffer.from(filePath.split(`${process.cwd()}`+path.sep).join("").split("\\").join("/")).toString("base64");if(mini){var result=_min(fs.readFileSync(filePath,{encoding:"utf8"}),{removeAttributeQuotes:false,caseSensitive:true,collapseWhitespace:true,collapseInlineTagWhitespace:true,conservativeCollapse:true,removeComments:true,minifyJS:false,minifyCSS:false,processConditionalComments:true,collapseBooleanAttributes:false,decodeEntities:false,html5:true,includeAutoGeneratedTags:true,keepClosingSlash:true,maxLineLength:null,minifyURLs:false,preserveLineBreaks:false,preventAttributesEscaping:false,processScripts:["text/html"],quoteCharacter:"",removeEmptyAttributes:true,removeEmptyElements:false,removeOptionalTags:true,removeRedundantAttributes:true,removeScriptTypeAttributes:false,removeStyleLinkTypeAttributes:true,removeTagWhitespace:false,sortAttributes:false,sortClassName:false,trimCustomFragments:true,useShortDoctype:true,continueOnParseError:true})}else if(hst){var result=_hst(fs.readFileSync(filePath,{encoding:"utf8"}))}else{var result=fs.readFileSync(filePath,{encoding:"utf8"})}arrayOfFiles[fileKey]=result}});return arrayOfFiles}function v1CompatIndexHtml(html){return String(html).replace(/(<script\b[^>]*\bsrc=["'])\/?js\/bea\.js(?:\?[^"']*)?(["'])/gi,"$1/js/lm.js$2").replace(/<script\b[^>]*\bsrc=["']\/?index\.js(?:\?[^"']*)?["'][^>]*>\s*<\/script>\s*/gi,"").replace(/<script\b[^>]*\bsrc=["'](?:https?:)?\/\/(?:s\.|www\.)?beacdn\.com\/beajs\/[^"']*["'][^>]*>\s*<\/script>\s*/gi,"").replace(/<script\b[^>]*\bsrc=["'](?:https?:)?\/\/lmjs\.beacdn\.com\/[^"']*["'][^>]*>\s*<\/script>\s*/gi,"")}exports.v1CompatIndexHtml=v1CompatIndexHtml;function readTemplates(root){let out={};for(const folder of["tpls","comps"]){let dir=root+path.sep+"src"+path.sep+folder+path.sep;if(fs.existsSync(dir))Object.assign(out,getAllFiles(dir,{},false,true))}return out}exports.readTemplates=readTemplates;function linkTemplateReactiveVars(files2,templates){function templateFor(attrs){let name=String(attrs.tpl).replace(/^\/+/,"");for(const f of["tpls","comps"]){let key=Buffer.from("src/"+f+"/"+name+".tpl").toString("base64");if(templates[key])return templates[key]}return null}function scan(nodes,add){if(!Array.isArray(nodes))return;for(const node of nodes){if(!node)continue;let a=node.attrs;if(a&&node.type==="sections"&&a.hasOwnProperty("tpl")){let t=templateFor(a);if(t)(t.reactiveVars||[]).forEach(add)}if(a&&a.hasOwnProperty("view")){let sv=viewFor(a.view);if(sv)(sv.reactiveVars||[]).forEach(add)}if(node.children)scan(node.children,add);if(Array.isArray(node.content))scan(node.content,add)}}let viewByPath={};for(const key in files2){let p=Buffer.from(key,"base64").toString().replace(/\\/g,"/");let m=p.match(/(?:^|\/)views\/(.+)\.view$/);if(m)viewByPath[m[1]]=files2[key]}function viewFor(v){let p=String(v).trim().replace(/^\/+/,"").replace(/\.view$/,"");if(!p||/\{\{/.test(p))return null;return viewByPath[p]||null}for(let pass=0;pass<10;pass++){let grew=false;for(const key in files2){let entry=files2[key];if(!entry||!Array.isArray(entry.hst))continue;if(!Array.isArray(entry.reactiveVars))entry.reactiveVars=[];scan(entry.hst,function(n){if(entry.reactiveVars.indexOf(n)===-1){entry.reactiveVars.push(n);grew=true}})}if(!grew)break}for(const key in files2){let entry=files2[key];if(!entry||!Array.isArray(entry.hst))continue;if(!Array.isArray(entry.reactiveVars))entry.reactiveVars=[];scan(entry.hst,function(n){if(entry.reactiveVars.indexOf(n)===-1)entry.reactiveVars.push(n)})}return files2}exports.linkTemplateReactiveVars=linkTemplateReactiveVars;function copyDir(src,dest,projectName){try{const entries=fs.readdirSync(src,{encoding:"utf8",withFileTypes:true});cd(dest);for(let entry of entries){const srcPath=path.join(src.toString(),entry.name.toString());const destPath=path.join(dest.toString(),entry.name.toString());if(entry.isDirectory()){if(projectName=="_beajsBuild"){if(entry.name!="layouts"&&entry.name!="views"&&entry.name!="css"&&entry.name!="js")copyDir(srcPath,destPath,projectName)}else copyDir(srcPath,destPath,projectName)}else{if(projectName=="_beajsBuild"){if(projectName=="_beajsBuild"&&entry.name!="index.js"&&entry.name!="index.html")fs.copyFileSync(srcPath,destPath)}else{if(!fs.existsSync(destPath)){if(projectName){if(entry.name=="index.html"){let html5=Buffer.from(fs.readFileSync(srcPath).toString().split("[ProjectName]").join(ucwords(projectName)));fs.writeFileSync(destPath,html5)}else if(entry.name=="package.json"){let slug=lw(projectName).replace(/[^a-z0-9._-]+/g,"-").replace(/^[-.]+|[-.]+$/g,"")||"lumenjs-project";let pkgJson=Buffer.from(fs.readFileSync(srcPath).toString().split("[ProjectName]").join(slug));fs.writeFileSync(destPath,pkgJson)}else fs.copyFileSync(srcPath,destPath)}else fs.copyFileSync(srcPath,destPath)}else{console.log("File already exists:",destPath)}}}}}catch(e){console.log(e)}}exports.copyDir=copyDir;function validURL(string){let url;try{url=new URL(string)}catch(_){return false}return url.protocol==="http:"||url.protocol==="https:"}exports.validURL=validURL;let getPairs=(obj,keys=[])=>Object.entries(obj).reduce((pairs,[key,value])=>{if(typeof value==="object")pairs.push(...getPairs(value,[...keys,key]));else pairs.push([[...keys,key],value]);return pairs},[]);function pairIt(obj){return getPairs(obj).map(([[key0,...keysRest],value])=>`${key0}${keysRest.map(a=>`[${a}]`).join("")}=${value}`).join("&")}var API={get:async function(u,d,h,a){return await this.req(u,d,h,"GET",a)},put:async function(u,d,h,a){return await this.req(u,d,h,"PUT",a)},post:async function(u,d,h,a){return await this.req(u,d,h,"POST",a)},delete:async function(u,d,h,a){return await this.req(u,d,h,"DELETE",a)},patch:async function(u,d,h,a){return await this.req(u,d,h,"PATCH",a)},req:async function(u,d,h,m,a,f){var urled=validURL(u)?u:config.apis[a??0].baseURL+u;if(m.toString().toLowerCase()=="get"){if(urled.indexOf("?")>-1)urled=urled+"&"+pairIt(d??{});else urled=urled+"?"+pairIt(d??{})}let resa=await fetch(urled,{method:m.toString().toLowerCase(),body:m.toString().toLowerCase()=="get"?null:JSON.stringify(d??{}),headers:h??config.apis[a??0].headers});if(f)return resa;let res=await resa.text();try{return JSON.parse(res)}catch(e){return res}}};exports.API=API;function updateCore(){var libsPath=`${__dirname}`+path.sep+`files`+path.sep+`libs`;var projectJsPath=process.cwd()+path.sep+"src"+path.sep+"js"+path.sep+"lm.js";var projectCssPath=process.cwd()+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css";if(!fs.existsSync(process.cwd()+path.sep+"config.json")||!fs.existsSync(process.cwd()+path.sep+"src")){console.log("This doesn't look like a LumenJS project (no config.json/src here) \u2014 run this from your project's root.");return}if(!fs.existsSync(libsPath+path.sep+"lm.js")){console.log("This CLI install has no bundled runtime to copy from \u2014 reinstall @lmjs/cli.");return}addAgentFiles(process.cwd());var oldSize=fs.existsSync(projectJsPath)?fs.statSync(projectJsPath).size:null;var newJs=fs.readFileSync(libsPath+path.sep+"lm.js");var newSize=newJs.length;if(oldSize===newSize){console.log("Already up to date \u2014 this project's src/js/lm.js already matches the installed @lmjs/cli's runtime ("+newSize+" bytes). Nothing to do.");return}fs.writeFileSync(projectJsPath,newJs);if(fs.existsSync(libsPath+path.sep+"mobius.css")){fs.writeFileSync(projectCssPath,fs.readFileSync(libsPath+path.sep+"mobius.css"))}console.log("Updated src/js/lm.js"+(oldSize!==null?" (was "+oldSize+" bytes, now "+newSize+" bytes)":" (was missing, now "+newSize+" bytes)")+" \u2014 matches the currently installed @lmjs/cli.")}exports.updateCore=updateCore;function addAgentFiles(projectPath){var tplDir=path.join(__dirname,"files","project");var added=[];["AGENTS.md","CLAUDE.md"].forEach(function(f){var dest=path.join(projectPath,f);if(!fs.existsSync(dest)&&fs.existsSync(path.join(tplDir,f))){fs.copyFileSync(path.join(tplDir,f),dest);added.push(f)}});if(added.length)console.log("Added "+added.join(" + ")+" (points AI coding agents at the LumenJS reference).");return added}exports.addAgentFiles=addAgentFiles;exports.processCommand=processCommands;exports.startServer=startServer;exports.create=create;function processCommands(cmd){var command=cmd?cmd:process.argv[2];if(command=="run"||command=="serve"){startServer()}else if(command=="create"||command=="update"){let c=process.argv.slice(3,process.argv.length);let t=lw(c[0]);create({type:t[0]=="-"?t.split("-").join(""):t,name:t[0]=="-"?c.slice(1,c.length):c})}else if(command=="update-core"){updateCore()}else if(command=="purge"){console.log("(lm purge now does the same thing as `lm update-core` \u2014 prefer that name going forward.)");updateCore()}else if(command=="build"){let cmds=process.argv;_bp(cmds)}else if(command=="login"){_vault.login()}else if(command=="api"){let sub=process.argv[3];let name=process.argv[4];if(sub=="set")_vault.apiSet(name);else if(sub=="update")_vault.apiUpdate(name);else if(sub=="get")_vault.apiGet(name);else if(sub=="list")_vault.apiList();else if(sub=="remove")_vault.apiRemove(name);else console.log("Usage: lm api <set|get|update|list|remove> [name]")}else if(command=="-v"||command=="-version"){let _pkgJsonPath=fs.existsSync(path.join(__dirname,"..","..","package.json"))?path.join(__dirname,"..","..","package.json"):path.join(__dirname,"..","package.json");console.log("LumenJS version "+require(_pkgJsonPath).version)}else{console.log("LumenJS CLI's command not found!")}}async function _bp(cmds){import("ora").then(async({default:ora,oraPromise})=>{const spinner=ora({color:"green"});spinner.succeed("Started Building Project For Production").start("Gathering Required Resources..");var projectPath=`${process.cwd()}`;if(!checkProjectRuntime(projectPath)){spinner.fail("Build stopped: run `lm update-core` first, then build again.");process.exit(1)}var dest=projectPath+path.sep+"dist";let _views=getAllFiles(`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep,{},false,true);let _layoutsDir=`${process.cwd()}`+path.sep+`src`+path.sep+`layouts`+path.sep;let _layouts=fs.existsSync(_layoutsDir)?annotateLayoutRegions(getAllFiles(_layoutsDir,{},false,true)):{};let _tpls=readTemplates(`${process.cwd()}`);linkTemplateReactiveVars(_views,_tpls);linkTemplateReactiveVars(_layouts,_tpls);var indexCode=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"index.html","utf8");let _cssDir=projectPath+path.sep+`src`+path.sep+"css"+path.sep;let _mainCssName=["mobius.css","bea.css"].find(f=>fs.existsSync(_cssDir+f))||null;var beaCSSCode=_mainCssName?fs.readFileSync(_cssDir+_mainCssName,"utf8"):"";var indexJs=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"index.js","utf8");let _hasOwnDeps=_npmBundle.hasOwnDependencies(projectPath);let _localScriptSrcs=detectLocalProjectScripts(String(indexCode));let _compiledScripts="";for(const src of _localScriptSrcs){let scriptPath=projectPath+path.sep+"src"+path.sep+src.split("/").join(path.sep).replace(/^\\|^\//,"");try{let raw=_hasOwnDeps?_npmBundle.buildEntryWithImports(scriptPath,projectPath):fs.readFileSync(scriptPath,"utf8");_compiledScripts+="\n"+compileProjectScript(raw,src);indexCode=indexCode.split(new RegExp(`<script\\b[^>]*\\bsrc\\s*=\\s*["']`+src.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+`["'][^>]*>\\s*<\\/script>`,"i")).join("")}catch(e){}}let _uncompiledScripts=precompileViewScripts([{kind:"views",files:_views},{kind:"layouts",files:_layouts},{kind:"tpls",files:_tpls}]);let vt=`
|
|
2
2
|
var _vcData = {
|
|
3
3
|
"hstFormatVersion": `+HST_FORMAT_VERSION+`,
|
|
4
4
|
"views": `+JSON.stringify(_views,compactHstReplacer)+`,
|
|
@@ -23,7 +23,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
|
|
|
23
23
|
class WalkerBase{constructor(){this.should_skip=false;this.should_remove=false;this.replacement=null;this.context={skip:()=>this.should_skip=true,remove:()=>this.should_remove=true,replace:node=>this.replacement=node}}replace(parent,prop,index,node){if(parent&&prop){if(index!=null){parent[prop][index]=node}else{parent[prop]=node}}}remove(parent,prop,index){if(parent&&prop){if(index!==null&&index!==void 0){parent[prop].splice(index,1)}else{delete parent[prop]}}}}class SyncWalker extends WalkerBase{constructor(enter,leave){super();this.should_skip=false;this.should_remove=false;this.replacement=null;this.context={skip:()=>this.should_skip=true,remove:()=>this.should_remove=true,replace:node=>this.replacement=node};this.enter=enter;this.leave=leave}visit(node,parent,prop,index){if(node){if(this.enter){const _should_skip=this.should_skip;const _should_remove=this.should_remove;const _replacement=this.replacement;this.should_skip=false;this.should_remove=false;this.replacement=null;this.enter.call(this.context,node,parent,prop,index);if(this.replacement){if(Array.isArray(this.replacement)){var expressions=[];for(let rp=0;rp<this.replacement.length;rp++){expressions.push(this.replacement[rp])}if(this.replacement.length>1){node={"type":"VariableDeclaration","start":node.start,"kind":"let","declarations":expressions,"level":node.level,"scope":node.scope}}else{node={"type":"ExpressionStatement","expression":{"type":"SequenceExpression","expressions":expressions,"level":node.level,"scope":node.scope},"level":node.level,"scope":node.scope}}this.replace(parent,prop,index,node)}else{node=this.replacement;this.replace(parent,prop,index,node)}}if(this.should_remove){this.remove(parent,prop,index)}const skipped=this.should_skip;const removed=this.should_remove;this.should_skip=_should_skip;this.should_remove=_should_remove;this.replacement=_replacement;if(skipped)return node;if(removed)return null}let key;for(key in node){const value=node[key];if(value&&typeof value==="object"){if(Array.isArray(value)){const nodes=value;for(let i=0;i<nodes.length;i+=1){const item=nodes[i];if(isNode(item)){if(!this.visit(item,node,key,i)){i--}}}}else if(isNode(value)){this.visit(value,node,key,null)}}}if(this.leave){const _replacement=this.replacement;const _should_remove=this.should_remove;this.replacement=null;this.should_remove=false;this.leave.call(this.context,node,parent,prop,index);if(this.replacement){if(Array.isArray(this.replacement)){for(let rp=0;rp<this.replacement.length;rp++){node=this.replacement[rp];this.replace(parent,prop,index,node)}}else{node=this.replacement;this.replace(parent,prop,index,node)}}if(this.should_remove){this.remove(parent,prop,index)}const removed=this.should_remove;this.replacement=_replacement;this.should_remove=_should_remove;if(removed)return null}}return node}}function isNode(value){return value!==null&&typeof value==="object"&&"type"in value&&typeof value.type==="string"}function walk(ast,{enter,leave}){const instance=new SyncWalker(enter,leave);return instance.visit(ast,null)}function getProgramBody(node){if(node.type=="Program"){return node.body}return node}function parseNode(node){}function checkNodeL1(node,varz,vazzz){try{if(node&&typeof node==="object"){if(Array.isArray(node)){for(let i=0;i<node.length;i++){const nd=node[i];if(isNode(nd)){if(nd.type==="VariableDeclaration"){let declarators=nd.declarations;for(let x=0;x<declarators.length;x++){let dec=declarators[x].id;if(vazzz.includes(dec.name)){varz.push({name:dec.name,node:dec});dec.marked=true}}}else if(nd.type=="Identifier"){}parseNode(nd)}}}else if(isNode(node)){}}}catch(e){}}function getL1Vs(AST,view,vazzz){var level=0,block=[{start:0}];var varz=view?.varz??[];let nodes=getProgramBody(AST);checkNodeL1(nodes,varz,vazzz);return{"varz":varz,"AST":AST}}function getWatcher(AST,view,vazzz,targetKey="View"){AST=JSON.parse(JSON.stringify(AST));let Vars=getL1Vs(AST,view,vazzz);AST=Vars["AST"];let varz=Vars["varz"];validateBeforeRewrite(AST,view);AST=changeReactiveVarsOccurences(AST,vazzz,targetKey);AST=transformTopLevelDeclarations(AST,vazzz,targetKey);return{"code":astring.generate(AST),"varz":varz}}function validateBeforeRewrite(AST,view){try{new Function(astring.generate(AST))}catch(e){if(typeof reportLumenError==="function"){reportLumenError({stage:"validate",view:view?.name,error:e,hint:"This is a real JavaScript error in your <script> block (for example, a variable declared twice with let/const) \u2014 fix it in the .view file; it will not surface again once rewritten."})}}}function buildTargetRootExpr(targetKey){const segments=Array.isArray(targetKey)?targetKey:[targetKey];let expr={type:"Identifier",name:"_vt"};for(const seg of segments){if(typeof seg==="number"){expr={type:"MemberExpression",object:expr,property:{type:"Literal",value:seg,raw:String(seg)},computed:true}}else{expr={type:"MemberExpression",object:expr,property:{type:"Identifier",name:seg},computed:false}}}return expr}function changeReactiveVarsOccurences(AST,reactiveVariables,targetKey="View"){const reactive=new Set(reactiveVariables||[]);const scopeStack=[];const bindingIdNodes=new WeakSet;const pushScope=isFunction=>scopeStack.push({isFunction:!!isFunction,names:new Set});const popScope=()=>scopeStack.pop();const currentScope=()=>scopeStack[scopeStack.length-1];function declare(name,kind){if(!name)return;if(kind==="var"||kind==="function"){for(let i=scopeStack.length-1;i>=0;i--){if(scopeStack[i].isFunction||i===0){scopeStack[i].names.add(name);return}}}else{currentScope().names.add(name)}}function rootHas(name){return scopeStack.length>0&&scopeStack[0].names.has(name)}function isShadowedFromRoot(name){for(let i=scopeStack.length-1;i>=1;i--){if(scopeStack[i].names.has(name))return true}return false}function visitPattern(node,onId){if(!node)return;switch(node.type){case"Identifier":onId(node);break;case"RestElement":visitPattern(node.argument,onId);break;case"AssignmentPattern":visitPattern(node.left,onId);break;case"ArrayPattern":for(const el of node.elements)if(el)visitPattern(el,onId);break;case"ObjectPattern":for(const p of node.properties){if(p.type==="Property")visitPattern(p.value,onId);else if(p.type==="RestElement")visitPattern(p.argument,onId)}break;default:break}}function markPatternBindings(pattern,kind="var"){if(!pattern)return;visitPattern(pattern,idNode=>{bindingIdNodes.add(idNode);declare(idNode.name,kind)})}function predeclareProgram(programNode){if(!programNode||!Array.isArray(programNode.body))return;for(const stmt of programNode.body){if(stmt.type==="VariableDeclaration"){for(const d of stmt.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);declare(id.name,stmt.kind)})}}else if(stmt.type==="FunctionDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);declare(stmt.id.name,"function")}else if(stmt.type==="ClassDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);declare(stmt.id.name,"let")}else if(stmt.type==="ImportDeclaration"){for(const spec of stmt.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declare(spec.local.name,"const")}}}}}function predeclareBlockLexicals(blockNode){if(!blockNode||!Array.isArray(blockNode.body))return;for(const stmt of blockNode.body){if(stmt.type==="VariableDeclaration"&&stmt.kind!=="var"){for(const d of stmt.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);currentScope().names.add(id.name)})}}else if(stmt.type==="FunctionDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);currentScope().names.add(stmt.id.name)}else if(stmt.type==="ClassDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);currentScope().names.add(stmt.id.name)}}}function predeclareForHeader(node){const header=node.type==="ForStatement"?node.init:node.left;if(header&&header.type==="VariableDeclaration"&&header.kind!=="var"){for(const d of header.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);currentScope().names.add(id.name)})}}}function shouldSkipIdentifier(node,parent,prop){if(!parent)return false;if(parent.type==="LabeledStatement"&&prop==="label"||(parent.type==="BreakStatement"||parent.type==="ContinueStatement")&&prop==="label")return true;if(parent.type==="MemberExpression"){if(prop==="property"&&parent.computed===false)return true}if(parent.type==="Property"){if(prop==="key"&&parent.computed===false)return true}if((parent.type==="MethodDefinition"||parent.type==="ClassProperty"||parent.type==="PropertyDefinition")&&prop==="key"&&parent.computed===false)return true;if(parent.type==="ImportSpecifier"||parent.type==="ImportDefaultSpecifier"||parent.type==="ImportNamespaceSpecifier"||parent.type==="ExportSpecifier")return true;return false}function walk2(node,parent,prop,index){if(!node||typeof node!=="object")return;switch(node.type){case"Program":pushScope(true);predeclareProgram(node);break;case"BlockStatement":case"StaticBlock":pushScope(false);predeclareBlockLexicals(node);break;case"FunctionDeclaration":if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"function")}pushScope(true);for(const p of node.params)markPatternBindings(p,"param");break;case"FunctionExpression":pushScope(true);if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"let")}for(const p of node.params)markPatternBindings(p,"param");break;case"ArrowFunctionExpression":pushScope(true);for(const p of node.params)markPatternBindings(p,"param");break;case"CatchClause":pushScope(false);if(node.param)markPatternBindings(node.param,"let");break;case"ForStatement":case"ForInStatement":case"ForOfStatement":pushScope(false);predeclareForHeader(node);break;case"VariableDeclaration":for(const decl of node.declarations){markPatternBindings(decl.id,node.kind||"var")}break;case"ClassDeclaration":if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"let")}break;case"ImportDeclaration":for(const spec of node.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declare(spec.local.name,"const")}}break}for(const key in node){if(key==="parent")continue;const child=node[key];if(Array.isArray(child)){for(let i=0;i<child.length;i++){if(child[i]&&typeof child[i]==="object"){walk2(child[i],node,key,i)}}}else if(child&&typeof child==="object"){walk2(child,node,key,null)}}if(node.type==="Identifier"){const name=node.name;if(!reactive.has(name)||bindingIdNodes.has(node)){}else if(!rootHas(name)){}else if(isShadowedFromRoot(name)){}else if(shouldSkipIdentifier(node,parent,prop)){}else{if(parent&&parent.type==="Property"&&parent.shorthand&&prop==="value"){parent.shorthand=false}const replacement={type:"MemberExpression",object:{type:"MemberExpression",object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"vars"},computed:false},property:{type:"Literal",value:name,raw:JSON.stringify(name)},computed:true};if(parent){if(index!==null&&Array.isArray(parent[prop])){parent[prop][index]=replacement}else{parent[prop]=replacement}}else{Object.keys(node).forEach(k=>delete node[k]);Object.assign(node,replacement)}}}switch(node.type){case"Program":case"BlockStatement":case"StaticBlock":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"ForStatement":case"ForInStatement":case"ForOfStatement":popScope();break;default:break}}walk2(AST,null,null,null);return AST}function _reactiveAssignStatement(name,init,targetKey="View"){return{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:true,object:{type:"MemberExpression",computed:false,object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"vars"}},property:{type:"Literal",value:name}},right:init||{type:"Identifier",name:"undefined"}}}}function _fnRegisterStatement(name,targetKey){return{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:true,object:{type:"MemberExpression",computed:false,object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"fns"}},property:{type:"Literal",value:name}},right:{type:"Identifier",name}}}}function _windowExportStatement(name){return{type:"IfStatement",test:{type:"BinaryExpression",operator:"!==",left:{type:"UnaryExpression",operator:"typeof",prefix:true,argument:{type:"Identifier",name:"window"}},right:{type:"Literal",value:"undefined"}},consequent:{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:true,object:{type:"Identifier",name:"window"},property:{type:"Literal",value:name}},right:{type:"Identifier",name}}},alternate:null}}function transformTopLevelDeclarations(AST,reactiveVariables,targetKey="View"){const reactive=new Set(reactiveVariables||[]);const newBody=[];for(const stmt of AST.body){if(stmt.type==="FunctionDeclaration"&&stmt.id){newBody.push(stmt);newBody.push(_fnRegisterStatement(stmt.id.name,targetKey));if(stmt.async||stmt.generator)newBody.push(_windowExportStatement(stmt.id.name));continue}if(stmt.type!=="VariableDeclaration"){newBody.push(stmt);continue}const reactiveDecls=stmt.declarations.filter(d=>reactive.has(d.id.name));const nonReactiveDecls=stmt.declarations.filter(d=>!reactive.has(d.id.name));if(reactiveDecls.length===0){newBody.push(stmt);continue}for(const decl of reactiveDecls){newBody.push(_reactiveAssignStatement(decl.id.name,decl.init,targetKey))}if(nonReactiveDecls.length>0){newBody.push({type:"VariableDeclaration",kind:stmt.kind,declarations:nonReactiveDecls})}}AST.body=newBody;return AST}if(typeof module!=="undefined"&&module.exports){module.exports={getWatcher,changeReactiveVarsOccurences,transformTopLevelDeclarations,validateBeforeRewrite}}
|
|
24
24
|
|
|
25
25
|
var __lmDevOnlyEnd__ = 1;
|
|
26
|
-
var cl=console.log;var LumenJS_HTML_SNIFF_RE=/([&][a-zA-Z]*[;]+)|<\/?[a-z][\s\S]*>/im;class _v{static name;static type;static vars;static fns;static rvs;static _pv;static mx;static views;static hst;static settings;constructor(obj){this.name=obj.name??"home";this.type=obj.type??"main";this.hst=obj.hst??[];this.views=obj.views??[];this.vars=obj.vars??{};this.fns=obj.fns??{};this.rvs=obj.rvs??{};this._pv=obj._pv??null;this.mx=obj.mx??[];this.settings=obj.settings??{layout:"default",requireAuth:false}}}const consoleLogOriginal=console.log;console.log=function(){for(let i=0;i<arguments.length;i++){const arg=arguments[i];if(arg&&arg.hasOwnProperty("__isProxy")||arg?.target){arguments[i]=arguments[i].target}}consoleLogOriginal.apply(console,arguments)};var _lumenDevMode=true;var _lumenErrorLog=[];var _lumenLoggedExprs={};var _mountedSubviewEngines=[];var EXPECTED_HST_FORMAT_VERSION=3;var _HST_FORMATS_ACCEPTED=[1,2,3];function _numericPathToBrackets(expr2){if(typeof expr2!=="string"||!/\.\d/.test(expr2)||!/^\s*[A-Za-z_$][\w$]*(?:\.[\w$]+)+\s*$/.test(expr2))return expr2;return expr2.replace(/\.(\d[\w$]*)/g,"['$1']")}var _entityDecodeEl;function decodeHtmlEntities(str){if(!str||str.indexOf("&")===-1)return str;if(!_entityDecodeEl)_entityDecodeEl=document.createElement("textarea");_entityDecodeEl.innerHTML=str;return _entityDecodeEl.value}function _translateLumenError(message){if(!message)return message;return message.replace(/_vt\.View\.vars\[["'`]([^"'`\]]+)["'`]\]/g,"$1")}function reportLumenError(info){info=info||{};var rawMessage=info.message||info.error&&info.error.message||"Unknown error";var entry={time:new Date().toISOString(),stage:info.stage||"runtime",view:info.view||(typeof _vt!=="undefined"&&_vt.View?_vt.View.name:void 0),expr:info.expr,message:_translateLumenError(rawMessage),hint:info.hint};_lumenErrorLog.push(entry);if(_lumenDevMode&&entry.stage==="expression"){var dedupeKey=(entry.view||"")+"|"+(entry.expr||"")+"|"+rawMessage;if(_lumenLoggedExprs[dedupeKey])return entry;_lumenLoggedExprs[dedupeKey]=true;if(/ is not defined$/.test(rawMessage)){console.warn('[LumenJS] "'+(entry.view||"unknown")+'" \u2014 {{'+entry.expr+"}}: "+entry.message+" anywhere in scope, so it is shown as literal text.");return entry}if(/Cannot read propert(y|ies) of (undefined|null)/.test(rawMessage)){console.warn('[LumenJS] "'+(entry.view||"unknown")+'" \u2014 '+entry.expr+" is empty for now ("+entry.message+"). Fine if its data is still loading.");return entry}}if(_lumenDevMode){console.error("[LumenJS] "+entry.stage+' error in "'+(entry.view||"unknown")+'"'+(entry.expr?" \u2014 "+entry.expr:"")+": "+entry.message+(entry.hint?"\n "+entry.hint:""))}return entry}function _x(_x2){const _ARRAY_MUTATORS={push:1,pop:1,shift:1,unshift:1,splice:1,sort:1,reverse:1,fill:1,copyWithin:1};function _dispatchVarsUpdate(key,currPath){let varsIdx=currPath.indexOf("vars");if(varsIdx===-1)return;let varName=varsIdx<currPath.length-1?currPath[varsIdx+1]:key;let rootPath=currPath.slice(0,varsIdx);try{if(typeof watch!=="undefined"&&watch&&Object.prototype.hasOwnProperty.call(watch,varName)&&typeof watch[varName]==="function"){watch[varName]()}}catch(e){cl(e)}if(rootPath[0]==="Global"){try{if(typeof window!=="undefined")window[varName]=_x2.Global.vars[varName]}catch(e){}if(_vt.View._re)_vt.View._re.update(varName);for(const regionName in _vt.Widgets){if(_vt.Widgets[regionName]&&_vt.Widgets[regionName]._re){_vt.Widgets[regionName]._re.update(varName)}}for(let msi=_mountedSubviewEngines.length-1;msi>=0;msi--){let sve=_mountedSubviewEngines[msi];let sveNode=sve._RealDOM&&sve._RealDOM[0];if(sveNode&&!sveNode.isConnected){_mountedSubviewEngines.splice(msi,1);continue}sve.update(varName)}_updateReactiveEngines(varName);return}let owner=_x2;for(let i=0;i<rootPath.length&&owner;i++){owner=owner[rootPath[i]]}if(owner&&owner._re)owner._re.update(varName);for(let msi=_mountedSubviewEngines.length-1;msi>=0;msi--){const sve=_mountedSubviewEngines[msi];if(!sve||sve===(owner&&owner._re))continue;const sveNode=sve._RealDOM&&sve._RealDOM[0];if(sveNode&&!sveNode.isConnected){_mountedSubviewEngines.splice(msi,1);continue}const sp=sve.view&&sve.view.scopePath;if(!sp||sp.length<=rootPath.length)continue;let under=true;for(let i=0;i<rootPath.length;i++)if(String(sp[i])!==String(rootPath[i])){under=false;break}if(under)sve.update(varName)}_updateReactiveEngines(varName)}function _isWrappable(v){if(Array.isArray(v))return true;try{for(let p=Object.getPrototypeOf(v);p&&p!==Object.prototype;p=Object.getPrototypeOf(p)){const c=Object.prototype.hasOwnProperty.call(p,"constructor")?p.constructor:null;if(typeof c!=="function")continue;if(c.name==="Object")return true;if(/\[native code\]/.test(Function.prototype.toString.call(c)))return false}}catch(e){return false}return true}let _batch=0;function makeHandler(path){const childProxies=new WeakMap;return{get(target,key,receiver){if(key=="__isProxy")return true;if(typeof key==="symbol")return target[key];if(_ARRAY_MUTATORS[key]===1&&Array.isArray(target)&&typeof target[key]==="function"){return function(){let res;_batch++;try{res=Array.prototype[key].apply(target,arguments)}finally{_batch--}if(!_batch){try{_dispatchVarsUpdate(key,path)}catch(e){cl(e)}}return res===target?receiver:res}}const v=target[key];if(typeof v==="object"&&v!==null&&key!="_re"){const hit=childProxies.get(v);if(hit&&hit.key===key)return hit.proxy;if(!_isWrappable(v)&&v.isSub!==true)return v;const proxy=new Proxy(v,makeHandler(path.concat(key)));childProxies.set(v,{key,proxy});return proxy}return v??(key=="target"?target:void 0)??void 0},set(target,key,value){target[key]=value;if(!_batch){try{_dispatchVarsUpdate(key,path)}catch(e){cl(e)}}return true},deleteProperty(target,key){if(!(key in target)){return false}delete target[key];if(!_batch){try{_dispatchVarsUpdate(key,path)}catch(e){cl(e)}}return true},ownKeys(target){return Reflect.ownKeys(target)},has(target,key){return key in target},defineProperty(target,key,descriptor){if(descriptor&&"value"in descriptor){target[key]=descriptor.value}return target},getOwnPropertyDescriptor(target,key){const real=Reflect.getOwnPropertyDescriptor(target,key);if(real&&!real.configurable)return real;const value=target[key];return key in target?{value,enumerable:true,configurable:true}:void 0}}}const handler=makeHandler([]);var x=new Proxy(_x2,handler);return x}let _vt=_x({"View":new _v({}),"Global":{"vars":{},"fns":{}},"Widgets":{}});function touch(name){if(_vt.Global.vars.hasOwnProperty(name)){_vt.Global.vars[name]=_vt.Global.vars[name]}}var _deepReactiveCache=typeof WeakMap!=="undefined"?new WeakMap:null;function _deepReactive(obj,onChange){if(obj===null||typeof obj!=="object")return obj;if(_deepReactiveCache&&_deepReactiveCache.has(obj))return _deepReactiveCache.get(obj);var proxy=new Proxy(obj,{get(target,key){var v=target[key];if(v!==null&&typeof v==="object"&&typeof key!=="symbol"){return _deepReactive(v,onChange)}return v},set(target,key,value){target[key]=value;onChange();return true},deleteProperty(target,key){if(key in target)delete target[key];onChange();return true}});if(_deepReactiveCache)_deepReactiveCache.set(obj,proxy);return proxy}function _lookupInWidgets(name){for(const wname in _vt.Widgets){if(_vt.Widgets[wname].vars.hasOwnProperty(name))return _vt.Widgets[wname].vars[name]}return void 0}function _resolveScopePathTarget(scopePath){let target=_vt;for(let i=0;i<scopePath.length;i++)target=target[scopePath[i]];return target}function _evalEventScopedExpr(ownerRe,expr,locals){locals=locals||{};let hasOwner=!!(ownerRe&&ownerRe.view);let levels=[];for(let e=hasOwner?ownerRe:null,n=0;e&&e.view&&n<50;e=e.view._pv,n++){let live=null;if(e.view.scopePath){try{let _sv=_resolveScopePathTarget(e.view.scopePath);if(_sv&&_sv._re===e)live=_sv.vars}catch(err){live=null}}levels.push({re:e,vars:e.view.vars||{},live})}function levelOf(key){for(let i=0;i<levels.length;i++)if(Object.prototype.hasOwnProperty.call(levels[i].vars,key))return levels[i];return null}let widgetsVars=hasOwner?_mergedWidgetsVars():{};function ownFn(key){for(let i=0;i<levels.length;i++){const fns=levels[i].re.view.fns;if(fns&&Object.prototype.hasOwnProperty.call(fns,key)&&typeof fns[key]==="function")return fns[key]}return void 0}let scopeProxy=new Proxy({},{has(target,key){if(typeof key==="symbol")return false;if(locals.hasOwnProperty(key))return true;if(!hasOwner)return false;if(ownFn(key))return true;return!!levelOf(key)||widgetsVars.hasOwnProperty(key)||_vt.Global.vars.hasOwnProperty(key)},get(target,key){if(locals.hasOwnProperty(key))return locals[key];const f=ownFn(key);if(f)return f;const lv=levelOf(key);if(lv)return lv.live?lv.live[key]:lv.vars[key];if(widgetsVars.hasOwnProperty(key)){for(const wname in _vt.Widgets)if(_vt.Widgets[wname].vars.hasOwnProperty(key))return _vt.Widgets[wname].vars[key]}return _vt.Global.vars[key]},set(target,key,value){if(locals.hasOwnProperty(key)){locals[key]=value;return true}try{const lv=levelOf(key);if(lv){if(lv.live)lv.live[key]=value;else{lv.vars[key]=value;try{lv.re.update(key)}catch(e2){cl(e2)}}}else if(widgetsVars.hasOwnProperty(key)){for(const wname in _vt.Widgets){if(_vt.Widgets[wname].vars.hasOwnProperty(key)){_vt.Widgets[wname].vars[key]=value;break}}}else{_vt.Global.vars[key]=value}}catch(e){cl(e)}return true}});function _runWithScope(expr){with(scopeProxy){return eval(expr)}}return _runWithScope(expr)}var _scopedEvalFns=new Map;var _SVG_NS="http://www.w3.org/2000/svg";function _lmSetAttr(el2,name,val){if(el2&&el2.namespaceURI===_SVG_NS){if(name.indexOf("xlink:")===0)return el2.setAttributeNS("http://www.w3.org/1999/xlink",name,val);if(name==="xmlns"||name.indexOf("xmlns:")===0)return el2.setAttributeNS("http://www.w3.org/2000/xmlns/",name,val)}el2.setAttribute(name,val)}var _CONST_EFFECT="\0const";function _mergedWidgetsVars(){let out={};let widgets=_vt.Widgets;let names=Object.keys(widgets);for(let i=names.length-1;i>=0;i--){Object.assign(out,widgets[names[i]].vars)}return out}class _lm{_RealDOM=[];_effects={};_cc={};_jj={};_ready=false;view=void 0;sbscrbs=[];reactiveVariables=[];vrs={};_CXR=[];_LXR=[];constructor(view){this.view=view;this.view._re=this;this.reactiveVariables=view?.rvs??{};this.init();if(this.view.type=="main")_vt.View=this.view;if(this.view._pv){this.view._pv.subscribe(this.view)}return this}init(){var par2=this;this.view.hst.forEach(function(doc2){par2.walk(doc2,null)})}subscribe(view){this.sbscrbs.push(view)}scopedEval(context,expr2,kk){let ctx=this.concatVarsAtLevel(context,this);expr2=_numericPathToBrackets(expr2);if(kk){if(!ctx.hasOwnProperty(kk))return void 0;delete ctx[kk]}try{const ctxKeys=Object.keys(ctx);const evalKey=ctxKeys.join("");let evaluator=_scopedEvalFns.get(evalKey);if(!evaluator){evaluator=Function.apply(null,[...ctxKeys,"expr","return eval(expr)"]);if(_scopedEvalFns.size>=500)_scopedEvalFns.clear();_scopedEvalFns.set(evalKey,evaluator)}return evaluator.apply(null,[...Object.values(ctx),expr2])}catch(e){if(e instanceof TypeError&&!kk){let hadUndefined=false;let strippedCtx={};for(const k2 in ctx){if(ctx[k2]===void 0||ctx[k2]===null){hadUndefined=true;continue}strippedCtx[k2]=ctx[k2]}if(hadUndefined){try{const evaluator2=Function.apply(null,[...Object.keys(strippedCtx),"expr","return eval(expr)"]);return evaluator2.apply(null,[...Object.values(strippedCtx),expr2])}catch(e2){const m2=e2 instanceof ReferenceError&&/^([\w$]+) is not defined$/.exec(e2.message);if(m2&&Object.prototype.hasOwnProperty.call(ctx,m2[1])){reportLumenError({stage:"expression",expr:expr2,error:e});return void 0}if(e2 instanceof ReferenceError)this._lastUnresolved=true;reportLumenError({stage:"expression",expr:expr2,error:e2});return void 0}}}if(e instanceof ReferenceError)this._lastUnresolved=true;reportLumenError({stage:"expression",expr:expr2,error:e});return void 0}}_inForRow(){for(let r=this,n=0;r&&n<50;r=r.view&&r.view._pv,n++){if(r._blankUnresolved)return true;if(r.vrs&&Object.keys(r.vrs).length)return true;let v=r.view;if(v&&v.type==="section"&&v.vars&&Object.keys(v.vars).length)return true}return false}_textMustache(content){this._lastUnresolved=false;let v=this.getVal(content);let unresolved=this._lastUnresolved&&(v===void 0||v===null||v==="");this._lastUnresolved=false;if(!unresolved)return v;if(this._inForRow())return v;let raw=String(content);return/^\s*\{\{[\s\S]*\}\}\s*$/.test(raw)?raw:"{{"+raw+"}}"}getVals(effect){let val="";if(effect.type=="text"){if(!effect.isSplit){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this._textMustache(split.content)}else{val+=split.content}}}else{val=this._textMustache(effect.content)}}else if(effect.type=="attr"||effect.type=="event"){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}return val}renderAll(){if(this._ready)return;this._ready=true;for(const rv in this._effects){if(Object.prototype.hasOwnProperty.call(this._effects,rv)){const effects=this._effects[rv];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){this.applyTextEffect(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{_lmSetAttr(effect.nd,effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}}this.updateCXRs();this.updateLXRs();this.updateVXRs();if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}chainConnected(cx){for(let i=cx.chain.length-1;i>=0;i--){const cxs=cx.chain[i];if(cxs.ref.isPreConnected){return true}}return false}async updateVXRs(k){let subsNames=[];for(let i=0;i<this.view.views.length;i++){const _view=this.view.views[i];if(!subsNames.includes(_view.subPath))subsNames.push(_view.subPath)}if(!subsNames.length)return;if(this._RealDOM&&this._RealDOM.length&&!this._RealDOM.some(function(nd){return nd&&nd.isConnected})){this._vxrWaits=(this._vxrWaits||0)+1;if(this._vxrWaits<=200)setTimeout(()=>this.updateVXRs(k),10);return}this._vxrWaits=0;for(let i=0;i<subsNames.length;i++){const n=subsNames[i];renderView(n,true,{},"views",this.view.views,this.view.scopePath||["View"])}}_evalCondition(expr2){if(typeof expr2==="string"&&expr2.charAt(0)==="!"){return!this.evalExp(expr2.substring(1),this.reactiveVariables)}return this.evalExp(expr2,this.reactiveVariables)}async updateCXRs(k){for(let i=0;i<this._CXR.length;i++){const cx=this._CXR[i];if(cx.name=="if"){let isTrue=this._evalCondition(cx.content);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else if(cx.name=="else-if"){if(!this.chainConnected(cx)){let isTrue=this._evalCondition(cx.content);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else{await this.hideSectionCX(cx)}}else if(cx.name=="else"){if(!this.chainConnected(cx)){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}}}async showSectionCX(cx,k){let wasConnected=cx.ref.node.isConnected;cx.ref.isPreConnected=true;await renderSection(cx.ref,cx.doc,this,k);if(!wasConnected)await fireRenderHook(cx,"after-render",cx.ref.node,{visible:true})}async hideSectionCX(cx){if(cx.ref.node.isConnected)await fireRenderHook(cx,"before-render",cx.ref.node,{visible:false});cx.ref.isPreConnected=false;cx.ref.node.replaceWith(cx.ref)}render(effect){let x="";try{if(effect.type=="text"||effect.type=="attr"||effect.type=="event"){x=this.getVals(effect)}}catch(e){cl(e)}return x}applyTextEffect(effect){let val=this.render(effect);let nd=effect.nd;let clone2=effect._htmlClone||nd._lmHtmlClone||null;if(LumenJS_HTML_SNIFF_RE.test(val)){nd.textContent="";if(!clone2){clone2=document.createElement("span");nd.before(clone2)}effect._htmlClone=nd._lmHtmlClone=clone2;clone2.innerHTML=val}else{if(clone2){clone2.remove();effect._htmlClone=nd._lmHtmlClone=null}nd.textContent=val}}update(k){if(!this._ready)return;if(this._effects.hasOwnProperty(k)){const effects=this._effects[k];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){this.applyTextEffect(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{_lmSetAttr(effect.nd,effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}this.updateCXRs(k);this.updateLXRs(k);for(let sbscsi=0;sbscsi<this.sbscrbs.length;sbscsi++){const sbscr=this.sbscrbs[sbscsi];sbscr._re.update(k)}if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}_forReads(cx,k){const js=cx.forX["js"];if(js===k)return true;const cache=cx._reads||(cx._reads={});if(k in cache)return cache[k];let hit=false;if(typeof k==="string"&&k!==""){const src=[js,cx.limit,cx.offset,cx.cond].filter(s=>typeof s==="string").join("\n");hit=new RegExp("(^|[^\\w$.])"+k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?![\\w$])").test(src)}return cache[k]=hit}_forNum(raw){if(typeof raw!=="string"||raw.indexOf("{")===-1)return raw;const self=this;return raw.replace(/\{\s*\{\s*([\s\S]*?)\s*\}\s*\}/g,function(_,expr2){let v;try{v=self.getVal(expr2,"")}catch(e){v=""}return v===void 0||v===null?"":String(v)}).trim()}async updateLXRs(k){for(let i=0;i<this._LXR.length;i++){var cx=this._LXR[i];var forX=cx.forX;if(k&&!this._forReads(cx,k))continue;if(cx._updating){cx._dirty=true;continue}cx._updating=true;try{var val=this.getVal(forX["js"],"");var tempVal=[];if(this.typeStr(val)=="number"){for(let i2=0;i2<val;i2++){tempVal.push(i2)}val=tempVal}let vals=[];let isObj=false;if(this.typeStr(val)=="object"){isObj=true;for(const oKey in val){if(Object.hasOwnProperty.call(val,oKey)){const item=val[oKey];let objj={key:oKey,value:item};vals.push(objj)}}}else vals=clone(val);if(this.typeStr(vals)!="array")vals=[];{let forIf=cx.cond;let limit=vals.length;let offset=0;const cxLimit=this._forNum(cx.limit);const cxOffset=this._forNum(cx.offset);if(cxLimit)limit=(isNaN(cxLimit)?cxLimit:limit)>vals.length?vals.length:cxLimit*1;if(cxOffset)offset=(isNaN(cxOffset)?cxOffset:offset)<0?0:cxOffset*1;let marray=[];if(forIf){marray=vals.slice(offset*1,vals.length)}else{marray=vals.slice(offset*1,limit*1+offset*1)}let myLimit=0;let arrayToRender=[];let arrayToRenderVXs=[];for(var index=0;index<marray.length;index++){if(myLimit==limit*1)break;try{let vx={};vx["index"]=myLimit;if(forX["dx"]!="")vx[forX["dx"]]=myLimit;if(isObj){if(forX["as"]["v"]!=""){if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]["key"];if(forX["as"]["v"])vx[forX["as"]["v"]]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]}vx["key"]=marray[index]["key"];vx["value"]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index];if(marray[index]&&typeof marray[index]==="object"&&!Array.isArray(marray[index])){for(const k2 in marray[index]){if(Object.prototype.hasOwnProperty.call(marray[index],k2)){vx[k2]=marray[index][k2]}}}}if(forIf){let _prevVrs=this.vrs;this.vrs=vx;let isTrue;try{isTrue=this.evalExp(forIf,[])}finally{this.vrs=_prevVrs}if(!isTrue)continue}let miIndexx=offset*1+index*1;arrayToRender.push(marray[index]);arrayToRenderVXs.push(vx);myLimit++}catch(e){cl(e)}}let oldATR=cx.atr;cx.atr=clone(arrayToRender);const actions=this.compareArrays(oldATR,arrayToRender);if(actions.length)await fireRenderHook(cx,"before-render",cx.ref.parentElement,{items:arrayToRender,actions});let addActions=[];let otherActions=[];for(let ai=0;ai<actions.length;ai++){(actions[ai].action=="add"?addActions:otherActions).push(actions[ai])}if(addActions.length){let createdSections=await Promise.all(addActions.map(actn=>{let vx=arrayToRenderVXs[actn.index];return this.createSection(cx,vx,isObj,forX)}));for(let ci=0;ci<createdSections.length;ci++){let cln=createdSections[ci];cx.ref.before(cln);cln.replaceWith(cln.node)}}for(let ai=0;ai<otherActions.length;ai++){const actn=otherActions[ai];if(actn.action=="remove"){var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];if(tx2){tx2.remove();tx2.node.remove();delete cx.ref.nodes[keyed]}}else{var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];let vx=arrayToRenderVXs[actn.index];if(tx2){tx2._re.vrs=vx;let _rowVars=tx2._re.view&&tx2._re.view.vars;if(_rowVars&&_rowVars!==vx){for(const _rk in _rowVars)if(!(_rk in vx))delete _rowVars[_rk];Object.assign(_rowVars,vx)}if(tx2.isObj){if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);if(tx2.forX.as["v"]!="")tx2._re.update(tx2.forX.as["v"]);for(let actnsi=0;actnsi<actn.updates.length;actnsi++){const actnu=actn.updates[actnsi];tx2._re.update(actnu.property)}}else{if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);for(const ik in vx){if(Object.prototype.hasOwnProperty.call(vx,ik)&&ik!==tx2.forX.js&&ik!==tx2.forX.as["k"])tx2._re.update(ik)}}}}}if(actions.length)await fireRenderHook(cx,"after-render",cx.ref.parentElement,{items:arrayToRender,actions})}}finally{cx._updating=false;if(cx._dirty){cx._dirty=false;Promise.resolve().then(()=>this.updateLXRs(k))}}}}compareLogic(array1,array2){if(array1.length===array2.length){return 1}else{if(array1.length>array2.length){return 2}else{return 3}}}compareArrays(array1,array2){const actions=[];const maxLength=Math.max(array1.length,array2.length);for(let i=0;i<maxLength;i++){const element1=array1[i];const element2=array2[i];if(element2===void 0){actions.push({action:"remove",index:i})}else if(element1===void 0){actions.push({action:"add",index:i,element:element2})}else if(!this.deepCompare(element1,element2)){actions.push({action:"update",index:i,updates:this.getUpdates(element1,element2)})}}return actions}findDeletedIndexes(array1,array2){const deletedIndexes=[];let par2=this;array1.forEach((item,index)=>{const foundIndex=array2.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){deletedIndexes.push(index)}});return deletedIndexes}findAddedIndexes(array1,array2){const addedIndexes=[];let par2=this;array2.forEach((item,index)=>{const foundIndex=array1.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){addedIndexes.push(index)}});return addedIndexes}deepCompare(obj1,obj2){return JSON.stringify(obj1)===JSON.stringify(obj2)}getUpdates(oldObj,newObj){const updates=[];for(const key in newObj){if(newObj.hasOwnProperty(key)&&newObj[key]!==oldObj[key]){updates.push({property:key,value:newObj[key]})}}return updates}getVal(mo,indexName){let vars={};try{for(let i=0;i<this.reactiveVariables.length;i++){let __name=this.reactiveVariables[i];if(_vt.View.vars.hasOwnProperty(__name)){vars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);let _gv=_wv!==void 0?_wv:_vt.Global.vars[__name];if(_gv!==void 0)vars[__name]=_gv}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){vars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){vars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}mo=mo.trim();if(mo.slice(0,2)=="{{"){mo=mo.slice(2,-2)}let value="";let _mo=mo;if(mo.indexOf("`")>-1){var matchesVal=_mo.match(/\.`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("."+this.getVal(matchesVal[y].substr(1).slice(1,-1),indexName))}var matchesVal=_mo.match(/`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("'"+this.getVal(matchesVal[y].slice(1,-1),indexName)+"'")}return this.getVal(_mo,indexName)}if(mo.indexOf(";")>-1){let zxx=mo.split(";");mo=$.trim(zxx[0])}if(mo.indexOf(" as ")>-1){mo=mo.split(" as ");return this.getVal(mo[0],indexName)}if(indexName){indexName=indexName.toString();if(mo.indexOf(indexName)>-1&&mo!=indexName&&vars.hasOwnProperty(indexName)&&mo!="index"){mo=mo.split(indexName).join(vars[indexName]);return this.getVal(mo,indexName)}}var Ondex=mo.match(/\bindex\b/g);if(Ondex&&mo!="index"&&vars.hasOwnProperty("index")){_mo=mo.replace(/\bindex\b/g,vars["index"]);return this.getVal(_mo,indexName)}value=this.lookup(mo,vars);return value??""}concatVarsAtLevel(levelVars,parent2){if(!parent2.view._pv){var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={..._vt.Global.vars,..._mergedWidgetsVars(),...parent2.view.vars,...concatenatedVars}}return concatenatedVars}var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={...parent2.view.vars,...concatenatedVars}}return this.concatVarsAtLevel(concatenatedVars,parent2.view._pv)}lookup(name,vaz){let vars=this.concatVarsAtLevel(vaz,this);try{var value;var names,index,lookupHit=false;if(this.hasProperty(vars,name)){value=vars[name]}else if(name.indexOf(".")>-1&&name.indexOf("[")==-1){var value=this.scopedEval(vars,name);if(!(value||value==0)){value=vars;names=name.split(".");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=this.hasProperty(value,names[index]);value=value[names[index++]]}}}else{var value=this.scopedEval(vars,name);if(!(value||value==0)){if(name.indexOf(".")==-1&&name.indexOf("[")>-1){let _name=name;var matchesVal=_name.match(/\[[\s\S]*?\]/g);for(var y=0;y<matchesVal.length;y++){if(matchesVal[y].indexOf("'")==-1&&matchesVal[y].indexOf('"')==-1)_name=_name.split(matchesVal[y]).join("['"+matchesVal[y].slice(1,-1)+"']")}var value=this.scopedEval(vars,_name)}}}if(this.isFunction(value))value=value.call(value)}catch(e){reportLumenError({stage:"lookup",expr:name,error:e});return""}return value}objectToString=Object.prototype.toString;isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};isFunction(object){return typeof object==="function"}typeStr(obj){return this.isArray(obj)?"array":typeof obj}hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}createEl(tag,attrs,children,events,doc2){const _el2=doc2&&doc2.svg?document.createElementNS(_SVG_NS,tag):document.createElement(tag);Object.defineProperty(_el2,"_ownerRe",{value:this,enumerable:false,configurable:true,writable:true});_el2.isSub=false;if(attrs.hasOwnProperty("view")){_el2.isSub=true;_el2.subPath=attrs["view"];_el2.vars={};_el2.views=[];_el2.fns={};if(doc2&&doc2.evs&&doc2.evs.hasOwnProperty("@init")){let _initAttr=doc2.evs["@init"];if(_initAttr){let _rowScope=Object.assign({},this.view&&this.view.type==="section"&&this.view.vars||{},this.vrs||{});let _initResult=evalEvAttr(_initAttr,{cType:"init"},$(_el2),"init",_rowScope);if(_initResult&&typeof _initResult==="object"&&typeof _initResult.then!=="function"){Object.assign(_el2.vars,_initResult)}}}this.view.views.push(_el2)}_el2.events={};for(const prop in attrs){if(prop=="view"||prop==":data"||prop==":if"||prop==":else-if"||prop==":else"||prop==":for"||prop==":for-limit"||prop==":for-offset"||prop==":for-if")continue;try{let val=doc2&&doc2.ax.hasOwnProperty(prop)?"":attrs[prop];if(prop=="value"&&!(doc2&&doc2.svg)){_el2.value=val}else _lmSetAttr(_el2,prop,val)}catch(e){cl(e)}}for(const prop in events){try{_el2.events[prop]=events[prop];if(typeof _lmIndexAtEl==="function")_lmIndexAtEl(_el2,prop)}catch(e){cl(e)}}if(children.length)_el2.append(...children);if(events&&events["@after-render"]&&!(attrs&&(attrs.hasOwnProperty(":for")||attrs.hasOwnProperty(":if")||attrs.hasOwnProperty(":else-if")||attrs.hasOwnProperty(":else")))){fireRenderHook({doc:doc2},"after-render",_el2,{})}autoInitPlugins(_el2,attrs);return _el2}evalExp(expr2,vars){let rvars={};try{for(let i=0;i<vars.length;i++){let __name=vars[i];if(_vt.View.vars.hasOwnProperty(__name)){rvars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);rvars[__name]=_wv!==void 0?_wv:_vt.Global.vars[__name]}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){rvars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){rvars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}try{var value=this.scopedEval(rvars,expr2);if(value&&value!=0)return true}catch(e){reportLumenError({stage:"condition",expr:expr2,error:e});return false}return false}splitTextWithMustaches(text,mustaches){mustaches.sort((a,b)=>a.start-b.start);const elements=[];let currentIndex=0;for(const mustache of mustaches){if(currentIndex<mustache.start){elements.push({type:"static",content:text.substring(currentIndex,mustache.start)})}elements.push({type:"mustache",jst:mustache.jst,rvs:mustache.rvs,content:text.substring(mustache.start,mustache.end)});currentIndex=mustache.end}if(currentIndex<text.length){elements.push({type:"static",content:text.substring(currentIndex)})}return elements}walk(doc,parent){var par=this;var tx,el;switch(doc.type){case"text":if(doc.mss.length){let splitIt=true;if(doc.tag=="textarea"){splitIt=false}if(splitIt){let splits=this.splitTextWithMustaches(doc.content,doc.mss);for(let si=0;si<splits.length;si++){const split=splits[si];if(split.type=="static"){let txnd=document.createTextNode(decodeHtmlEntities(split.content));if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}else{let txnd=document.createTextNode("");const _keys=split.rvs.length?split.rvs:[_CONST_EFFECT];for(let ri=0;ri<_keys.length;ri++){const element=_keys[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":split.content,"jst":split.jst,"rvs":split.rvs,"isSplit":true,"nd":txnd,"tag":doc.tag})}if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}}return tx}else{tx=document.createTextNode("");const _anyRv=doc.mss.some(m=>m.rvs.length);for(let mui=0;mui<doc.mss.length;mui++){const mus=doc.mss[mui];const _keys=mus.rvs.length?mus.rvs:!_anyRv&&mui===0?[_CONST_EFFECT]:[];for(let ri=0;ri<_keys.length;ri++){const element=_keys[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":doc.content,"splits":this.splitTextWithMustaches(doc.content,doc.mss),"jst":mus.jst,"rvs":mus.rvs,"isSplit":false,"nd":tx,"tag":doc.tag})}}if(!parent)par._RealDOM.push(tx);return tx}}else{tx=document.createTextNode(decodeHtmlEntities(doc.content));if(!parent)par._RealDOM.push(tx);return tx}break;case"sections":case"section":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());tx=document.createTextNode("");var typeN=null;if(doc.attrs.hasOwnProperty(":else"))typeN="else";else if(doc.attrs.hasOwnProperty(":else-if"))typeN="else-if";else if(doc.attrs.hasOwnProperty(":if"))typeN="if";else typeN="for";if(doc.type=="section"){var chain=[];if(typeN=="else-if"||typeN=="else"){try{let lastInChain=this._CXR.at(-1);if(lastInChain){_dd=lastInChain.key;chain.push(...lastInChain.chain,lastInChain)}}catch(e){}}el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);tx.node=el;this._CXR.push({"type":"section","name":typeN,"content":doc.cond,"doc":doc,"key":_dd,"chain":chain,"ref":tx});this.setEffects(doc,el)}else if(doc.type=="sections"){tx.key=_dd;tx.node=null;tx.nodes={};let docRaw=doc;this._LXR.push({"type":"sections","name":typeN,"cond":doc.attrs.hasOwnProperty(":for-if")?doc.attrs[":for-if"]:null,"limit":doc.attrs.hasOwnProperty(":for-limit")?doc.attrs[":for-limit"]:0,"offset":doc.attrs.hasOwnProperty(":for-offset")?doc.attrs[":for-offset"]:0,"content":doc.content,"forX":doc.forX,"doc":docRaw,"key":_dd,"atr":[],"ref":tx})}if(!parent)par._RealDOM.push(tx);return tx;break;case"tag":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());if(doc.name.toLowerCase()=="settings"){if(par.view.type=="main"){var defaultSettings={layout:"default",requireAuth:false};try{let settingsC=doc.children[0].content;let settings={};eval("settings = "+settingsC+";");if(settings){if(settings.layout==null)settings.layout="default";if(settings.requireAuth==null)settings.requireAuth=false;par.view.settings=settings}else{par.view.settings=defaultSettings}}catch(e){setError(e,"Error in your settings tag inside the '"+par.view.name.toLowerCase()+"' main view!");par.view.settings=defaultSettings}}}else if(doc.name.toLowerCase()=="script"||doc.name.toLowerCase()=="js"){let child=doc.children[0]||{};let js=child.content;let jst=child.jst;let isScoped=false;if(doc.attrs.hasOwnProperty("scoped")){delete doc.attrs["scoped"];isScoped=true}el=par.createEl("script",doc.attrs,[],doc.evs,doc);el._sc=isScoped;el._dd=_dd;el._jst=jst;el._js=js;el._pre=child.pre;(par._jj[_dd]??(par._jj[_dd]=[])).push({"nd":el})}else if(doc.name.toLowerCase()=="style"){let css=doc.children[0].content;let isScoped=false;el=par.createEl("style",{},[],doc.evs,doc);if(doc.attrs.hasOwnProperty("scoped")){if(!parent){if(par.view._dd)_dd=par.view._dd;else{par.view._dd=_dd;if(par.view.type=="main")$("[body]")[0].setAttribute("vuid",_dd)}}else{if(parent._dd)_dd=parent._dd;else{parent._dd=_dd;parent.setAttribute("vuid",_dd)}}delete doc.attrs["scoped"];isScoped=true;el._sc=isScoped;el._dd=_dd;el._css=css;(par._cc[_dd]??(par._cc[_dd]=[])).push({"nd":el,"_css":css})}else{el._sc=isScoped;el._dd=_dd;el.textContent=css}for(const prop in doc.attrs){try{_el.setAttribute(prop,doc.attrs[prop])}catch(e){cl(e)}}}else if(doc.name.toLowerCase()=="icon"){let child=par.createEl("span",{"class":"iconify","data-icon":doc?.icon??"mdi:home"},[],{},null);el=par.createEl("span",doc.attrs,[child],doc.evs,doc)}else if(doc.name.toLowerCase()=="slot"){let slotName=doc.attrs&&doc.attrs.name;if(slotName){let tempWrapper=document.createElement("div");let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,tempWrapper);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}(par.view._slots??(par.view._slots={}))[slotName]=childs}}else if(doc.attrs&&(doc.attrs.hasOwnProperty("tpl")||doc.attrs.hasOwnProperty("comp"))){let _elAttrs=Object.assign({},doc.attrs);delete _elAttrs["tpl"];delete _elAttrs["comp"];delete _elAttrs[":data"];el=par.createEl(doc.name,_elAttrs,[],doc.evs,doc);_reportTplMisuse(doc,par)}else{el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);if(!doc.isV&&!el.isSub){let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,el);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}childs.length?el.append(...childs):null}}this.setEffects(doc,el);if(el){if(!parent)par._RealDOM.push(el)}return el;break;case"comment":break;default:break}}setEffects(doc2,el2){let rvs=[];if(Object.keys(doc2.ax).length){for(const attrName in doc2.ax){if(Object.hasOwnProperty.call(doc2.ax,attrName)){const attrMustaches=doc2.ax[attrName];const _anyRv=attrMustaches.some(m=>m.rvs.length);for(let i=0;i<attrMustaches.length;i++){const mus=attrMustaches[i];const _keys=mus.rvs.length?mus.rvs:!_anyRv&&i===0?[_CONST_EFFECT]:[];for(let ri=0;ri<_keys.length;ri++){const element=_keys[ri];if(element!==_CONST_EFFECT)rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"attr","name":attrName,"content":doc2.attrs[attrName],"splits":this.splitTextWithMustaches(doc2.attrs[attrName],doc2.ax[attrName]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}if(Object.keys(doc2.ex).length){for(const ky in doc2.ex){if(Object.hasOwnProperty.call(doc2.ex,ky)){const mss=doc2.ex[ky];for(let i=0;i<mss.length;i++){const mus=mss[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"event","name":ky,"content":doc2.evs[ky],"splits":this.splitTextWithMustaches(doc2.evs[ky],doc2.ex[ky]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}return rvs.filter((value,index,self)=>{return self.indexOf(value)===index})}async createSection(cx,vx,isObj,forX){var keyed=cx.key+"_"+vx.index;var tx2=document.createTextNode("");var typeN2=null;if(cx.doc.attrs.hasOwnProperty(":else"))typeN2="else";else if(cx.doc.attrs.hasOwnProperty(":else-if"))typeN2="else-if";else if(cx.doc.attrs.hasOwnProperty(":if"))typeN2="if";else typeN2="for";let _ownerVrs=this.vrs;this.vrs=Object.assign({},_ownerVrs||{},vx||{});let el2;try{el2=this.createEl(cx.doc.name,cx.doc.attrs,[],cx.doc.evs,cx.doc)}finally{this.vrs=_ownerVrs}tx2.node=el2;tx2.key=cx.key;tx2.keyed=keyed;tx2.isObj=isObj;tx2.forX=forX;tx2.vx=vx;let scsc=await renderSection(tx2,cx.doc,this,cx.key);if(el2&&scsc)Object.defineProperty(el2,"_ownerRe",{value:scsc,enumerable:false,configurable:true,writable:true});scsc._re=scsc;cx.ref.nodes[keyed]=tx2;return tx2}attrString(attrs){var buff=[];for(var key in attrs){buff.push(key+'="'+attrs[key]+'"')}if(!buff.length)return"";return" "+buff.join(" ")}_stringify(buff,doc2){var par2=this;switch(doc2.type){case"text":return buff+doc2.content;case"tag":buff+="<"+doc2.name+(doc2.attrs?par2.attrString(doc2.attrs):"")+(doc2.isV?"/>":">");if(doc2.isV)return buff;for(let i=0;i<doc2.children.length;i++){const dc=doc2.children[i];buff=buff+par2._stringify("",dc)}return buff+"</"+doc2.name+">";case"comment":return buff;default:return""}}stringify(doc2){var par2=this;return doc2.reduce(function(token,rootEl){return token+par2._stringify("",rootEl)},"")}}async function renderHST(hst,n,type="main",tx2,_pv=null,scopePath=["View"],ownVars,ownFns,ownViews){var reactiveVariables=hst.reactiveVars;hst=hst.hst;let _re=new _lm(new _v({"name":n,"type":type,"hst":hst,"vars":ownVars??tx2?.vx,"fns":ownFns,"views":ownViews,"rvs":reactiveVariables,"_pv":_pv}));_re.view.scopePath=scopePath;if(Object.keys(_re._cc).length){for(const ky in _re._cc){if(Object.hasOwnProperty.call(_re._cc,ky)){const csses=_re._cc[ky];for(let inde=0;inde<csses.length;inde++){let prom=new defer;const css=csses[inde];_csswrk.trigger("css-ready",{"csses":[css._css],"pre":"[vuid='"+ky+"']","key":ky});_vuid[ky]=prom;let _csses=await prom;css.nd.textContent=_csses[0]}}}}if(Object.keys(_re._jj).length){for(const ky in _re._jj){if(Object.hasOwnProperty.call(_re._jj,ky)){const jses=_re._jj[ky];for(let inde=0;inde<jses.length;inde++){const nd=jses[inde].nd;let code=_lmScriptCode(nd,_re.view,reactiveVariables,scopePath);if(code===null)continue;code=`try { _lmSetViewVar(document.currentScript); `+code+` } catch (e) { reportLumenError({ stage: 'script', error: e }); }`;code=code+`
|
|
26
|
+
var cl=console.log;var LumenJS_HTML_SNIFF_RE=/([&][a-zA-Z]*[;]+)|<\/?[a-z][\s\S]*>/im;class _v{static name;static type;static vars;static fns;static rvs;static _pv;static mx;static views;static hst;static settings;constructor(obj){this.name=obj.name??"home";this.type=obj.type??"main";this.hst=obj.hst??[];this.views=obj.views??[];this.vars=obj.vars??{};this.fns=obj.fns??{};this.rvs=obj.rvs??{};this._pv=obj._pv??null;this.mx=obj.mx??[];this.settings=obj.settings??{layout:"default",requireAuth:false}}}const consoleLogOriginal=console.log;console.log=function(){for(let i=0;i<arguments.length;i++){const arg=arguments[i];if(arg&&arg.hasOwnProperty("__isProxy")||arg?.target){arguments[i]=arguments[i].target}}consoleLogOriginal.apply(console,arguments)};var _lumenDevMode=true;var _lumenErrorLog=[];var _lumenLoggedExprs={};var _mountedSubviewEngines=[];var EXPECTED_HST_FORMAT_VERSION=3;var _HST_FORMATS_ACCEPTED=[1,2,3];function _numericPathToBrackets(expr2){if(typeof expr2!=="string"||!/\.\d/.test(expr2)||!/^\s*[A-Za-z_$][\w$]*(?:\.[\w$]+)+\s*$/.test(expr2))return expr2;return expr2.replace(/\.(\d[\w$]*)/g,"['$1']")}var _entityDecodeEl;function decodeHtmlEntities(str){if(!str||str.indexOf("&")===-1)return str;if(!_entityDecodeEl)_entityDecodeEl=document.createElement("textarea");_entityDecodeEl.innerHTML=str;return _entityDecodeEl.value}function _translateLumenError(message){if(!message)return message;return message.replace(/_vt\.View\.vars\[["'`]([^"'`\]]+)["'`]\]/g,"$1")}function reportLumenError(info){info=info||{};var rawMessage=info.message||info.error&&info.error.message||"Unknown error";var entry={time:new Date().toISOString(),stage:info.stage||"runtime",view:info.view||(typeof _vt!=="undefined"&&_vt.View?_vt.View.name:void 0),expr:info.expr,message:_translateLumenError(rawMessage),hint:info.hint};_lumenErrorLog.push(entry);if(_lumenDevMode&&entry.stage==="expression"){var dedupeKey=(entry.view||"")+"|"+(entry.expr||"")+"|"+rawMessage;if(_lumenLoggedExprs[dedupeKey])return entry;_lumenLoggedExprs[dedupeKey]=true;if(/ is not defined$/.test(rawMessage)){console.warn('[LumenJS] "'+(entry.view||"unknown")+'" \u2014 {{'+entry.expr+"}}: "+entry.message+" anywhere in scope, so it is shown as literal text.");return entry}if(/Cannot read propert(y|ies) of (undefined|null)/.test(rawMessage)){console.warn('[LumenJS] "'+(entry.view||"unknown")+'" \u2014 '+entry.expr+" is empty for now ("+entry.message+"). Fine if its data is still loading.");return entry}}if(_lumenDevMode){console.error("[LumenJS] "+entry.stage+' error in "'+(entry.view||"unknown")+'"'+(entry.expr?" \u2014 "+entry.expr:"")+": "+entry.message+(entry.hint?"\n "+entry.hint:""))}return entry}function _x(_x2){const _ARRAY_MUTATORS={push:1,pop:1,shift:1,unshift:1,splice:1,sort:1,reverse:1,fill:1,copyWithin:1};function _dispatchVarsUpdate(key,currPath){let varsIdx=currPath.indexOf("vars");if(varsIdx===-1)return;let varName=varsIdx<currPath.length-1?currPath[varsIdx+1]:key;let rootPath=currPath.slice(0,varsIdx);try{if(typeof watch!=="undefined"&&watch&&Object.prototype.hasOwnProperty.call(watch,varName)&&typeof watch[varName]==="function"){watch[varName]()}}catch(e){cl(e)}if(rootPath[0]==="Global"){try{if(typeof window!=="undefined")window[varName]=_x2.Global.vars[varName]}catch(e){}if(_vt.View._re)_vt.View._re.update(varName);for(const regionName in _vt.Widgets){if(_vt.Widgets[regionName]&&_vt.Widgets[regionName]._re){_vt.Widgets[regionName]._re.update(varName)}}for(let msi=_mountedSubviewEngines.length-1;msi>=0;msi--){let sve=_mountedSubviewEngines[msi];let sveNode=sve._RealDOM&&sve._RealDOM[0];if(sveNode&&!sveNode.isConnected){_mountedSubviewEngines.splice(msi,1);continue}sve.update(varName)}_updateReactiveEngines(varName);return}let owner=_x2;for(let i=0;i<rootPath.length&&owner;i++){owner=owner[rootPath[i]]}if(owner&&owner._re)owner._re.update(varName);for(let msi=_mountedSubviewEngines.length-1;msi>=0;msi--){const sve=_mountedSubviewEngines[msi];if(!sve||sve===(owner&&owner._re))continue;const sveNode=sve._RealDOM&&sve._RealDOM[0];if(sveNode&&!sveNode.isConnected){_mountedSubviewEngines.splice(msi,1);continue}const sp=sve.view&&sve.view.scopePath;if(!sp||sp.length<=rootPath.length)continue;let under=true;for(let i=0;i<rootPath.length;i++)if(String(sp[i])!==String(rootPath[i])){under=false;break}if(under)sve.update(varName)}_updateReactiveEngines(varName)}function _isWrappable(v){if(Array.isArray(v))return true;try{for(let p=Object.getPrototypeOf(v);p&&p!==Object.prototype;p=Object.getPrototypeOf(p)){const c=Object.prototype.hasOwnProperty.call(p,"constructor")?p.constructor:null;if(typeof c!=="function")continue;if(c.name==="Object")return true;if(/\[native code\]/.test(Function.prototype.toString.call(c)))return false}}catch(e){return false}return true}let _batch=0;function makeHandler(path){const childProxies=new WeakMap;return{get(target,key,receiver){if(key=="__isProxy")return true;if(typeof key==="symbol")return target[key];if(_ARRAY_MUTATORS[key]===1&&Array.isArray(target)&&typeof target[key]==="function"){return function(){let res;_batch++;try{res=Array.prototype[key].apply(target,arguments)}finally{_batch--}if(!_batch){try{_dispatchVarsUpdate(key,path)}catch(e){cl(e)}}return res===target?receiver:res}}const v=target[key];if(typeof v==="object"&&v!==null&&key!="_re"){const hit=childProxies.get(v);if(hit&&hit.key===key)return hit.proxy;if(!_isWrappable(v)&&v.isSub!==true)return v;const proxy=new Proxy(v,makeHandler(path.concat(key)));childProxies.set(v,{key,proxy});return proxy}return v??(key=="target"?target:void 0)??void 0},set(target,key,value){target[key]=value;if(!_batch){try{_dispatchVarsUpdate(key,path)}catch(e){cl(e)}}return true},deleteProperty(target,key){if(!(key in target)){return false}delete target[key];if(!_batch){try{_dispatchVarsUpdate(key,path)}catch(e){cl(e)}}return true},ownKeys(target){return Reflect.ownKeys(target)},has(target,key){return key in target},defineProperty(target,key,descriptor){if(descriptor&&"value"in descriptor){target[key]=descriptor.value}return target},getOwnPropertyDescriptor(target,key){const real=Reflect.getOwnPropertyDescriptor(target,key);if(real&&!real.configurable)return real;const value=target[key];return key in target?{value,enumerable:true,configurable:true}:void 0}}}const handler=makeHandler([]);var x=new Proxy(_x2,handler);return x}let _vt=_x({"View":new _v({}),"Global":{"vars":{},"fns":{}},"Widgets":{}});function touch(name){if(_vt.Global.vars.hasOwnProperty(name)){_vt.Global.vars[name]=_vt.Global.vars[name]}}var _deepReactiveCache=typeof WeakMap!=="undefined"?new WeakMap:null;function _deepReactive(obj,onChange){if(obj===null||typeof obj!=="object")return obj;if(_deepReactiveCache&&_deepReactiveCache.has(obj))return _deepReactiveCache.get(obj);var proxy=new Proxy(obj,{get(target,key){var v=target[key];if(v!==null&&typeof v==="object"&&typeof key!=="symbol"){return _deepReactive(v,onChange)}return v},set(target,key,value){target[key]=value;onChange();return true},deleteProperty(target,key){if(key in target)delete target[key];onChange();return true}});if(_deepReactiveCache)_deepReactiveCache.set(obj,proxy);return proxy}function _lookupInWidgets(name){for(const wname in _vt.Widgets){if(_vt.Widgets[wname].vars.hasOwnProperty(name))return _vt.Widgets[wname].vars[name]}return void 0}function _resolveScopePathTarget(scopePath){let target=_vt;for(let i=0;i<scopePath.length;i++)target=target[scopePath[i]];return target}function _evalEventScopedExpr(ownerRe,expr,locals){locals=locals||{};let hasOwner=!!(ownerRe&&ownerRe.view);let levels=[];for(let e=hasOwner?ownerRe:null,n=0;e&&e.view&&n<50;e=e.view._pv,n++){let live=null;if(e.view.scopePath){try{let _sv=_resolveScopePathTarget(e.view.scopePath);if(_sv&&_sv._re===e)live=_sv.vars}catch(err){live=null}}levels.push({re:e,vars:e.view.vars||{},live})}function levelOf(key){for(let i=0;i<levels.length;i++)if(Object.prototype.hasOwnProperty.call(levels[i].vars,key))return levels[i];return null}let widgetsVars=hasOwner?_mergedWidgetsVars():{};function ownFn(key){for(let i=0;i<levels.length;i++){const fns=levels[i].re.view.fns;if(fns&&Object.prototype.hasOwnProperty.call(fns,key)&&typeof fns[key]==="function")return fns[key]}return void 0}let scopeProxy=new Proxy({},{has(target,key){if(typeof key==="symbol")return false;if(locals.hasOwnProperty(key))return true;if(!hasOwner)return false;if(ownFn(key))return true;return!!levelOf(key)||widgetsVars.hasOwnProperty(key)||_vt.Global.vars.hasOwnProperty(key)},get(target,key){if(locals.hasOwnProperty(key))return locals[key];const f=ownFn(key);if(f)return f;const lv=levelOf(key);if(lv)return lv.live?lv.live[key]:lv.vars[key];if(widgetsVars.hasOwnProperty(key)){for(const wname in _vt.Widgets)if(_vt.Widgets[wname].vars.hasOwnProperty(key))return _vt.Widgets[wname].vars[key]}return _vt.Global.vars[key]},set(target,key,value){if(locals.hasOwnProperty(key)){locals[key]=value;return true}try{const lv=levelOf(key);if(lv){if(lv.live)lv.live[key]=value;else{lv.vars[key]=value;try{lv.re.update(key)}catch(e2){cl(e2)}}}else if(widgetsVars.hasOwnProperty(key)){for(const wname in _vt.Widgets){if(_vt.Widgets[wname].vars.hasOwnProperty(key)){_vt.Widgets[wname].vars[key]=value;break}}}else{_vt.Global.vars[key]=value}}catch(e){cl(e)}return true}});function _runWithScope(expr){with(scopeProxy){return eval(expr)}}return _runWithScope(expr)}var _scopedEvalFns=new Map;var _SVG_NS="http://www.w3.org/2000/svg";function _lmSetAttr(el2,name,val){if(el2&&el2.namespaceURI===_SVG_NS){if(name.indexOf("xlink:")===0)return el2.setAttributeNS("http://www.w3.org/1999/xlink",name,val);if(name==="xmlns"||name.indexOf("xmlns:")===0)return el2.setAttributeNS("http://www.w3.org/2000/xmlns/",name,val)}el2.setAttribute(name,val)}var _CONST_EFFECT="\0const";function _mergedWidgetsVars(){let out={};let widgets=_vt.Widgets;let names=Object.keys(widgets);for(let i=names.length-1;i>=0;i--){Object.assign(out,widgets[names[i]].vars)}return out}class _lm{_RealDOM=[];_effects={};_cc={};_jj={};_ready=false;view=void 0;sbscrbs=[];reactiveVariables=[];vrs={};_CXR=[];_LXR=[];constructor(view){this.view=view;this.view._re=this;this.reactiveVariables=view?.rvs??{};this.init();if(this.view.type=="main")_vt.View=this.view;if(this.view._pv){this.view._pv.subscribe(this.view)}return this}init(){var par2=this;this.view.hst.forEach(function(doc2){par2.walk(doc2,null)})}subscribe(view){this.sbscrbs.push(view)}scopedEval(context,expr2,kk){let ctx=this.concatVarsAtLevel(context,this);expr2=_numericPathToBrackets(expr2);if(kk){if(!ctx.hasOwnProperty(kk))return void 0;delete ctx[kk]}try{const ctxKeys=Object.keys(ctx);const evalKey=ctxKeys.join("");let evaluator=_scopedEvalFns.get(evalKey);if(!evaluator){evaluator=Function.apply(null,[...ctxKeys,"expr","return eval(expr)"]);if(_scopedEvalFns.size>=500)_scopedEvalFns.clear();_scopedEvalFns.set(evalKey,evaluator)}return evaluator.apply(null,[...Object.values(ctx),expr2])}catch(e){if(e instanceof TypeError&&!kk){let hadUndefined=false;let strippedCtx={};for(const k2 in ctx){if(ctx[k2]===void 0||ctx[k2]===null){hadUndefined=true;continue}strippedCtx[k2]=ctx[k2]}if(hadUndefined){try{const evaluator2=Function.apply(null,[...Object.keys(strippedCtx),"expr","return eval(expr)"]);return evaluator2.apply(null,[...Object.values(strippedCtx),expr2])}catch(e2){const m2=e2 instanceof ReferenceError&&/^([\w$]+) is not defined$/.exec(e2.message);if(m2&&Object.prototype.hasOwnProperty.call(ctx,m2[1])){reportLumenError({stage:"expression",expr:expr2,error:e});return void 0}if(e2 instanceof ReferenceError)this._lastUnresolved=true;reportLumenError({stage:"expression",expr:expr2,error:e2});return void 0}}}if(e instanceof ReferenceError)this._lastUnresolved=true;reportLumenError({stage:"expression",expr:expr2,error:e});return void 0}}_inForRow(){for(let r=this,n=0;r&&n<50;r=r.view&&r.view._pv,n++){if(r._blankUnresolved)return true;if(r.vrs&&Object.keys(r.vrs).length)return true;let v=r.view;if(v&&v.type==="section"&&v.vars&&Object.keys(v.vars).length)return true}return false}_textMustache(content){this._lastUnresolved=false;let v=this.getVal(content);let unresolved=this._lastUnresolved&&(v===void 0||v===null||v==="");this._lastUnresolved=false;if(!unresolved)return v;if(this._inForRow())return v;let raw=String(content);return/^\s*\{\{[\s\S]*\}\}\s*$/.test(raw)?raw:"{{"+raw+"}}"}getVals(effect){let val="";if(effect.type=="text"){if(!effect.isSplit){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this._textMustache(split.content)}else{val+=split.content}}}else{val=this._textMustache(effect.content)}}else if(effect.type=="attr"||effect.type=="event"){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}return val}renderAll(){if(this._ready)return;this._ready=true;for(const rv in this._effects){if(Object.prototype.hasOwnProperty.call(this._effects,rv)){const effects=this._effects[rv];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){this.applyTextEffect(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{_lmSetAttr(effect.nd,effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}}this.updateCXRs();this.updateLXRs();this.updateVXRs();if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}chainConnected(cx){for(let i=cx.chain.length-1;i>=0;i--){const cxs=cx.chain[i];if(cxs.ref.isPreConnected){return true}}return false}async updateVXRs(k){let subsNames=[];for(let i=0;i<this.view.views.length;i++){const _view=this.view.views[i];if(!subsNames.includes(_view.subPath))subsNames.push(_view.subPath)}if(!subsNames.length)return;if(this._RealDOM&&this._RealDOM.length&&!this._RealDOM.some(function(nd){return nd&&nd.isConnected})){this._vxrWaits=(this._vxrWaits||0)+1;if(this._vxrWaits<=200)setTimeout(()=>this.updateVXRs(k),10);return}this._vxrWaits=0;for(let i=0;i<subsNames.length;i++){const n=subsNames[i];renderView(n,true,{},"views",this.view.views,this.view.scopePath||["View"])}}_evalCondition(expr2){if(typeof expr2==="string"&&expr2.charAt(0)==="!"){return!this.evalExp(expr2.substring(1),this.reactiveVariables)}return this.evalExp(expr2,this.reactiveVariables)}async updateCXRs(k){for(let i=0;i<this._CXR.length;i++){const cx=this._CXR[i];if(cx.name=="if"){let isTrue=this._evalCondition(cx.content);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else if(cx.name=="else-if"){if(!this.chainConnected(cx)){let isTrue=this._evalCondition(cx.content);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else{await this.hideSectionCX(cx)}}else if(cx.name=="else"){if(!this.chainConnected(cx)){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}}}async showSectionCX(cx,k){let wasConnected=cx.ref.node.isConnected;cx.ref.isPreConnected=true;await renderSection(cx.ref,cx.doc,this,k);if(!wasConnected)await fireRenderHook(cx,"after-render",cx.ref.node,{visible:true})}async hideSectionCX(cx){if(cx.ref.node.isConnected)await fireRenderHook(cx,"before-render",cx.ref.node,{visible:false});cx.ref.isPreConnected=false;cx.ref.node.replaceWith(cx.ref)}render(effect){let x="";try{if(effect.type=="text"||effect.type=="attr"||effect.type=="event"){x=this.getVals(effect)}}catch(e){cl(e)}return x}applyTextEffect(effect){let val=this.render(effect);let nd=effect.nd;let clone2=effect._htmlClone||nd._lmHtmlClone||null;if(LumenJS_HTML_SNIFF_RE.test(val)){nd.textContent="";if(!clone2){clone2=document.createElement("span");nd.before(clone2)}effect._htmlClone=nd._lmHtmlClone=clone2;clone2.innerHTML=val}else{if(clone2){clone2.remove();effect._htmlClone=nd._lmHtmlClone=null}nd.textContent=val}}update(k){if(!this._ready)return;if(this._effects.hasOwnProperty(k)){const effects=this._effects[k];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){this.applyTextEffect(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{_lmSetAttr(effect.nd,effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}this.updateCXRs(k);this.updateLXRs(k);for(let sbscsi=0;sbscsi<this.sbscrbs.length;sbscsi++){const sbscr=this.sbscrbs[sbscsi];sbscr._re.update(k)}if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}_forReads(cx,k){const js=cx.forX["js"];if(js===k)return true;const cache=cx._reads||(cx._reads={});if(k in cache)return cache[k];let hit=false;if(typeof k==="string"&&k!==""){const src=[js,cx.limit,cx.offset,cx.cond].filter(s=>typeof s==="string").join("\n");hit=new RegExp("(^|[^\\w$.])"+k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?![\\w$])").test(src)}return cache[k]=hit}_forNum(raw){if(typeof raw!=="string"||raw.indexOf("{")===-1)return raw;const self=this;return raw.replace(/\{\s*\{\s*([\s\S]*?)\s*\}\s*\}/g,function(_,expr2){let v;try{v=self.getVal(expr2,"")}catch(e){v=""}return v===void 0||v===null?"":String(v)}).trim()}async updateLXRs(k){for(let i=0;i<this._LXR.length;i++){var cx=this._LXR[i];var forX=cx.forX;if(k&&!this._forReads(cx,k))continue;if(cx._updating){cx._dirty=true;continue}cx._updating=true;try{var val=this.getVal(forX["js"],"");var tempVal=[];if(this.typeStr(val)=="number"){for(let i2=0;i2<val;i2++){tempVal.push(i2)}val=tempVal}let vals=[];let isObj=false;if(this.typeStr(val)=="object"){isObj=true;for(const oKey in val){if(Object.hasOwnProperty.call(val,oKey)){const item=val[oKey];let objj={key:oKey,value:item};vals.push(objj)}}}else vals=clone(val);if(this.typeStr(vals)!="array")vals=[];{let forIf=cx.cond;let limit=vals.length;let offset=0;const cxLimit=this._forNum(cx.limit);const cxOffset=this._forNum(cx.offset);if(cxLimit)limit=(isNaN(cxLimit)?cxLimit:limit)>vals.length?vals.length:cxLimit*1;if(cxOffset)offset=(isNaN(cxOffset)?cxOffset:offset)<0?0:cxOffset*1;let marray=[];if(forIf){marray=vals.slice(offset*1,vals.length)}else{marray=vals.slice(offset*1,limit*1+offset*1)}let myLimit=0;let arrayToRender=[];let arrayToRenderVXs=[];for(var index=0;index<marray.length;index++){if(myLimit==limit*1)break;try{let vx={};vx["index"]=offset*1+index*1;if(forX["dx"]!="")vx[forX["dx"]]=offset*1+index*1;if(isObj){if(forX["as"]["v"]!=""){if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]["key"];if(forX["as"]["v"])vx[forX["as"]["v"]]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]}vx["key"]=marray[index]["key"];vx["value"]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index];if(marray[index]&&typeof marray[index]==="object"&&!Array.isArray(marray[index])){for(const k2 in marray[index]){if(Object.prototype.hasOwnProperty.call(marray[index],k2)){vx[k2]=marray[index][k2]}}}}if(forIf){let _prevVrs=this.vrs;this.vrs=vx;let isTrue;try{isTrue=this.evalExp(forIf,[])}finally{this.vrs=_prevVrs}if(!isTrue)continue}let miIndexx=offset*1+index*1;arrayToRender.push(marray[index]);arrayToRenderVXs.push(vx);myLimit++}catch(e){cl(e)}}let oldATR=cx.atr;cx.atr=clone(arrayToRender);const actions=this.compareArrays(oldATR,arrayToRender);if(actions.length)await fireRenderHook(cx,"before-render",cx.ref.parentElement,{items:arrayToRender,actions});let addActions=[];let otherActions=[];for(let ai=0;ai<actions.length;ai++){(actions[ai].action=="add"?addActions:otherActions).push(actions[ai])}if(addActions.length){let createdSections=await Promise.all(addActions.map(actn=>{let vx=arrayToRenderVXs[actn.index];return this.createSection(cx,vx,isObj,forX,actn.index)}));for(let ci=0;ci<createdSections.length;ci++){let cln=createdSections[ci];cx.ref.before(cln);cln.replaceWith(cln.node)}}for(let ai=0;ai<otherActions.length;ai++){const actn=otherActions[ai];if(actn.action=="remove"){var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];if(tx2){tx2.remove();tx2.node.remove();delete cx.ref.nodes[keyed]}}else{var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];let vx=arrayToRenderVXs[actn.index];if(tx2){tx2._re.vrs=vx;let _rowVars=tx2._re.view&&tx2._re.view.vars;if(_rowVars&&_rowVars!==vx){for(const _rk in _rowVars)if(!(_rk in vx))delete _rowVars[_rk];Object.assign(_rowVars,vx)}if(tx2.isObj){if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);if(tx2.forX.as["v"]!="")tx2._re.update(tx2.forX.as["v"]);for(let actnsi=0;actnsi<actn.updates.length;actnsi++){const actnu=actn.updates[actnsi];tx2._re.update(actnu.property)}}else{if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);for(const ik in vx){if(Object.prototype.hasOwnProperty.call(vx,ik)&&ik!==tx2.forX.js&&ik!==tx2.forX.as["k"])tx2._re.update(ik)}}}}}if(actions.length)await fireRenderHook(cx,"after-render",cx.ref.parentElement,{items:arrayToRender,actions})}}finally{cx._updating=false;if(cx._dirty){cx._dirty=false;Promise.resolve().then(()=>this.updateLXRs(k))}}}}compareLogic(array1,array2){if(array1.length===array2.length){return 1}else{if(array1.length>array2.length){return 2}else{return 3}}}compareArrays(array1,array2){const actions=[];const maxLength=Math.max(array1.length,array2.length);for(let i=0;i<maxLength;i++){const element1=array1[i];const element2=array2[i];if(element2===void 0){actions.push({action:"remove",index:i})}else if(element1===void 0){actions.push({action:"add",index:i,element:element2})}else if(!this.deepCompare(element1,element2)){actions.push({action:"update",index:i,updates:this.getUpdates(element1,element2)})}}return actions}findDeletedIndexes(array1,array2){const deletedIndexes=[];let par2=this;array1.forEach((item,index)=>{const foundIndex=array2.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){deletedIndexes.push(index)}});return deletedIndexes}findAddedIndexes(array1,array2){const addedIndexes=[];let par2=this;array2.forEach((item,index)=>{const foundIndex=array1.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){addedIndexes.push(index)}});return addedIndexes}deepCompare(obj1,obj2){return JSON.stringify(obj1)===JSON.stringify(obj2)}getUpdates(oldObj,newObj){const updates=[];for(const key in newObj){if(newObj.hasOwnProperty(key)&&newObj[key]!==oldObj[key]){updates.push({property:key,value:newObj[key]})}}return updates}getVal(mo,indexName){let vars={};try{for(let i=0;i<this.reactiveVariables.length;i++){let __name=this.reactiveVariables[i];if(_vt.View.vars.hasOwnProperty(__name)){vars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);let _gv=_wv!==void 0?_wv:_vt.Global.vars[__name];if(_gv!==void 0)vars[__name]=_gv}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){vars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){vars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}mo=mo.trim();if(mo.slice(0,2)=="{{"){mo=mo.slice(2,-2)}let value="";let _mo=mo;if(mo.indexOf("`")>-1){var matchesVal=_mo.match(/\.`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("."+this.getVal(matchesVal[y].substr(1).slice(1,-1),indexName))}var matchesVal=_mo.match(/`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("'"+this.getVal(matchesVal[y].slice(1,-1),indexName)+"'")}return this.getVal(_mo,indexName)}if(mo.indexOf(";")>-1){let zxx=mo.split(";");mo=$.trim(zxx[0])}if(mo.indexOf(" as ")>-1){mo=mo.split(" as ");return this.getVal(mo[0],indexName)}if(indexName){indexName=indexName.toString();if(mo.indexOf(indexName)>-1&&mo!=indexName&&vars.hasOwnProperty(indexName)&&mo!="index"){mo=mo.split(indexName).join(vars[indexName]);return this.getVal(mo,indexName)}}var Ondex=mo.match(/\bindex\b/g);if(Ondex&&mo!="index"&&vars.hasOwnProperty("index")){_mo=mo.replace(/\bindex\b/g,vars["index"]);return this.getVal(_mo,indexName)}value=this.lookup(mo,vars);return value??""}concatVarsAtLevel(levelVars,parent2){if(!parent2.view._pv){var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={..._vt.Global.vars,..._mergedWidgetsVars(),...parent2.view.vars,...concatenatedVars}}return concatenatedVars}var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={...parent2.view.vars,...concatenatedVars}}return this.concatVarsAtLevel(concatenatedVars,parent2.view._pv)}lookup(name,vaz){let vars=this.concatVarsAtLevel(vaz,this);try{var value;var names,index,lookupHit=false;if(this.hasProperty(vars,name)){value=vars[name]}else if(name.indexOf(".")>-1&&name.indexOf("[")==-1){var value=this.scopedEval(vars,name);if(!(value||value==0)){value=vars;names=name.split(".");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=this.hasProperty(value,names[index]);value=value[names[index++]]}}}else{var value=this.scopedEval(vars,name);if(!(value||value==0)){if(name.indexOf(".")==-1&&name.indexOf("[")>-1){let _name=name;var matchesVal=_name.match(/\[[\s\S]*?\]/g);for(var y=0;y<matchesVal.length;y++){if(matchesVal[y].indexOf("'")==-1&&matchesVal[y].indexOf('"')==-1)_name=_name.split(matchesVal[y]).join("['"+matchesVal[y].slice(1,-1)+"']")}var value=this.scopedEval(vars,_name)}}}if(this.isFunction(value))value=value.call(value)}catch(e){reportLumenError({stage:"lookup",expr:name,error:e});return""}return value}objectToString=Object.prototype.toString;isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};isFunction(object){return typeof object==="function"}typeStr(obj){return this.isArray(obj)?"array":typeof obj}hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}createEl(tag,attrs,children,events,doc2){const _el2=doc2&&doc2.svg?document.createElementNS(_SVG_NS,tag):document.createElement(tag);Object.defineProperty(_el2,"_ownerRe",{value:this,enumerable:false,configurable:true,writable:true});_el2.isSub=false;if(attrs.hasOwnProperty("view")){_el2.isSub=true;_el2.subPath=attrs["view"];_el2.vars={};_el2.views=[];_el2.fns={};if(doc2&&doc2.evs&&doc2.evs.hasOwnProperty("@init")){let _initAttr=doc2.evs["@init"];if(_initAttr){let _rowScope=Object.assign({},this.view&&this.view.type==="section"&&this.view.vars||{},this.vrs||{});let _initResult=evalEvAttr(_initAttr,{cType:"init"},$(_el2),"init",_rowScope);if(_initResult&&typeof _initResult==="object"&&typeof _initResult.then!=="function"){Object.assign(_el2.vars,_initResult)}}}this.view.views.push(_el2)}_el2.events={};for(const prop in attrs){if(prop=="view"||prop==":data"||prop==":if"||prop==":else-if"||prop==":else"||prop==":for"||prop==":for-limit"||prop==":for-offset"||prop==":for-if")continue;try{let val=doc2&&doc2.ax.hasOwnProperty(prop)?"":attrs[prop];if(prop=="value"&&!(doc2&&doc2.svg)){_el2.value=val}else _lmSetAttr(_el2,prop,val)}catch(e){cl(e)}}for(const prop in events){try{_el2.events[prop]=events[prop];if(typeof _lmIndexAtEl==="function")_lmIndexAtEl(_el2,prop)}catch(e){cl(e)}}if(children.length)_el2.append(...children);if(events&&events["@after-render"]&&!(attrs&&(attrs.hasOwnProperty(":for")||attrs.hasOwnProperty(":if")||attrs.hasOwnProperty(":else-if")||attrs.hasOwnProperty(":else")))){fireRenderHook({doc:doc2},"after-render",_el2,{})}autoInitPlugins(_el2,attrs);return _el2}evalExp(expr2,vars){let rvars={};try{for(let i=0;i<vars.length;i++){let __name=vars[i];if(_vt.View.vars.hasOwnProperty(__name)){rvars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);rvars[__name]=_wv!==void 0?_wv:_vt.Global.vars[__name]}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){rvars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){rvars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}try{var value=this.scopedEval(rvars,expr2);if(value&&value!=0)return true}catch(e){reportLumenError({stage:"condition",expr:expr2,error:e});return false}return false}splitTextWithMustaches(text,mustaches){mustaches.sort((a,b)=>a.start-b.start);const elements=[];let currentIndex=0;for(const mustache of mustaches){if(currentIndex<mustache.start){elements.push({type:"static",content:text.substring(currentIndex,mustache.start)})}elements.push({type:"mustache",jst:mustache.jst,rvs:mustache.rvs,content:text.substring(mustache.start,mustache.end)});currentIndex=mustache.end}if(currentIndex<text.length){elements.push({type:"static",content:text.substring(currentIndex)})}return elements}walk(doc,parent){var par=this;var tx,el;switch(doc.type){case"text":if(doc.mss.length){let splitIt=true;if(doc.tag=="textarea"){splitIt=false}if(splitIt){let splits=this.splitTextWithMustaches(doc.content,doc.mss);for(let si=0;si<splits.length;si++){const split=splits[si];if(split.type=="static"){let txnd=document.createTextNode(decodeHtmlEntities(split.content));if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}else{let txnd=document.createTextNode("");const _keys=split.rvs.length?split.rvs:[_CONST_EFFECT];for(let ri=0;ri<_keys.length;ri++){const element=_keys[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":split.content,"jst":split.jst,"rvs":split.rvs,"isSplit":true,"nd":txnd,"tag":doc.tag})}if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}}return tx}else{tx=document.createTextNode("");const _anyRv=doc.mss.some(m=>m.rvs.length);for(let mui=0;mui<doc.mss.length;mui++){const mus=doc.mss[mui];const _keys=mus.rvs.length?mus.rvs:!_anyRv&&mui===0?[_CONST_EFFECT]:[];for(let ri=0;ri<_keys.length;ri++){const element=_keys[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":doc.content,"splits":this.splitTextWithMustaches(doc.content,doc.mss),"jst":mus.jst,"rvs":mus.rvs,"isSplit":false,"nd":tx,"tag":doc.tag})}}if(!parent)par._RealDOM.push(tx);return tx}}else{tx=document.createTextNode(decodeHtmlEntities(doc.content));if(!parent)par._RealDOM.push(tx);return tx}break;case"sections":case"section":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());tx=document.createTextNode("");var typeN=null;if(doc.attrs.hasOwnProperty(":else"))typeN="else";else if(doc.attrs.hasOwnProperty(":else-if"))typeN="else-if";else if(doc.attrs.hasOwnProperty(":if"))typeN="if";else typeN="for";if(doc.type=="section"){var chain=[];if(typeN=="else-if"||typeN=="else"){try{let lastInChain=this._CXR.at(-1);if(lastInChain){_dd=lastInChain.key;chain.push(...lastInChain.chain,lastInChain)}}catch(e){}}el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);tx.node=el;this._CXR.push({"type":"section","name":typeN,"content":doc.cond,"doc":doc,"key":_dd,"chain":chain,"ref":tx});this.setEffects(doc,el)}else if(doc.type=="sections"){tx.key=_dd;tx.node=null;tx.nodes={};let docRaw=doc;this._LXR.push({"type":"sections","name":typeN,"cond":doc.attrs.hasOwnProperty(":for-if")?doc.attrs[":for-if"]:null,"limit":doc.attrs.hasOwnProperty(":for-limit")?doc.attrs[":for-limit"]:0,"offset":doc.attrs.hasOwnProperty(":for-offset")?doc.attrs[":for-offset"]:0,"content":doc.content,"forX":doc.forX,"doc":docRaw,"key":_dd,"atr":[],"ref":tx})}if(!parent)par._RealDOM.push(tx);return tx;break;case"tag":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());if(doc.name.toLowerCase()=="settings"){if(par.view.type=="main"){var defaultSettings={layout:"default",requireAuth:false};try{let settingsC=doc.children[0].content;let settings={};eval("settings = "+settingsC+";");if(settings){if(settings.layout==null)settings.layout="default";if(settings.requireAuth==null)settings.requireAuth=false;par.view.settings=settings}else{par.view.settings=defaultSettings}}catch(e){setError(e,"Error in your settings tag inside the '"+par.view.name.toLowerCase()+"' main view!");par.view.settings=defaultSettings}}}else if(doc.name.toLowerCase()=="script"||doc.name.toLowerCase()=="js"){let child=doc.children[0]||{};let js=child.content;let jst=child.jst;let isScoped=false;if(doc.attrs.hasOwnProperty("scoped")){delete doc.attrs["scoped"];isScoped=true}el=par.createEl("script",doc.attrs,[],doc.evs,doc);el._sc=isScoped;el._dd=_dd;el._jst=jst;el._js=js;el._pre=child.pre;(par._jj[_dd]??(par._jj[_dd]=[])).push({"nd":el})}else if(doc.name.toLowerCase()=="style"){let css=doc.children[0].content;let isScoped=false;el=par.createEl("style",{},[],doc.evs,doc);if(doc.attrs.hasOwnProperty("scoped")){if(!parent){if(par.view._dd)_dd=par.view._dd;else{par.view._dd=_dd;if(par.view.type=="main")$("[body]")[0].setAttribute("vuid",_dd)}}else{if(parent._dd)_dd=parent._dd;else{parent._dd=_dd;parent.setAttribute("vuid",_dd)}}delete doc.attrs["scoped"];isScoped=true;el._sc=isScoped;el._dd=_dd;el._css=css;(par._cc[_dd]??(par._cc[_dd]=[])).push({"nd":el,"_css":css})}else{el._sc=isScoped;el._dd=_dd;el.textContent=css}for(const prop in doc.attrs){try{_el.setAttribute(prop,doc.attrs[prop])}catch(e){cl(e)}}}else if(doc.name.toLowerCase()=="icon"){let child=par.createEl("span",{"class":"iconify","data-icon":doc?.icon??"mdi:home"},[],{},null);el=par.createEl("span",doc.attrs,[child],doc.evs,doc)}else if(doc.name.toLowerCase()=="slot"){let slotName=doc.attrs&&doc.attrs.name;if(slotName){let tempWrapper=document.createElement("div");let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,tempWrapper);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}(par.view._slots??(par.view._slots={}))[slotName]=childs}}else if(doc.attrs&&(doc.attrs.hasOwnProperty("tpl")||doc.attrs.hasOwnProperty("comp"))){let _elAttrs=Object.assign({},doc.attrs);delete _elAttrs["tpl"];delete _elAttrs["comp"];delete _elAttrs[":data"];el=par.createEl(doc.name,_elAttrs,[],doc.evs,doc);_reportTplMisuse(doc,par)}else{el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);if(!doc.isV&&!el.isSub){let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,el);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}childs.length?el.append(...childs):null}}this.setEffects(doc,el);if(el){if(!parent)par._RealDOM.push(el)}return el;break;case"comment":break;default:break}}setEffects(doc2,el2){let rvs=[];if(Object.keys(doc2.ax).length){for(const attrName in doc2.ax){if(Object.hasOwnProperty.call(doc2.ax,attrName)){const attrMustaches=doc2.ax[attrName];const _anyRv=attrMustaches.some(m=>m.rvs.length);for(let i=0;i<attrMustaches.length;i++){const mus=attrMustaches[i];const _keys=mus.rvs.length?mus.rvs:!_anyRv&&i===0?[_CONST_EFFECT]:[];for(let ri=0;ri<_keys.length;ri++){const element=_keys[ri];if(element!==_CONST_EFFECT)rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"attr","name":attrName,"content":doc2.attrs[attrName],"splits":this.splitTextWithMustaches(doc2.attrs[attrName],doc2.ax[attrName]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}if(Object.keys(doc2.ex).length){for(const ky in doc2.ex){if(Object.hasOwnProperty.call(doc2.ex,ky)){const mss=doc2.ex[ky];for(let i=0;i<mss.length;i++){const mus=mss[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"event","name":ky,"content":doc2.evs[ky],"splits":this.splitTextWithMustaches(doc2.evs[ky],doc2.ex[ky]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}return rvs.filter((value,index,self)=>{return self.indexOf(value)===index})}async createSection(cx,vx,isObj,forX,pos){var keyed=cx.key+"_"+(pos!==void 0?pos:vx.index);var tx2=document.createTextNode("");var typeN2=null;if(cx.doc.attrs.hasOwnProperty(":else"))typeN2="else";else if(cx.doc.attrs.hasOwnProperty(":else-if"))typeN2="else-if";else if(cx.doc.attrs.hasOwnProperty(":if"))typeN2="if";else typeN2="for";let _ownerVrs=this.vrs;this.vrs=Object.assign({},_ownerVrs||{},vx||{});let el2;try{el2=this.createEl(cx.doc.name,cx.doc.attrs,[],cx.doc.evs,cx.doc)}finally{this.vrs=_ownerVrs}tx2.node=el2;tx2.key=cx.key;tx2.keyed=keyed;tx2.isObj=isObj;tx2.forX=forX;tx2.vx=vx;let scsc=await renderSection(tx2,cx.doc,this,cx.key);if(el2&&scsc)Object.defineProperty(el2,"_ownerRe",{value:scsc,enumerable:false,configurable:true,writable:true});scsc._re=scsc;cx.ref.nodes[keyed]=tx2;return tx2}attrString(attrs){var buff=[];for(var key in attrs){buff.push(key+'="'+attrs[key]+'"')}if(!buff.length)return"";return" "+buff.join(" ")}_stringify(buff,doc2){var par2=this;switch(doc2.type){case"text":return buff+doc2.content;case"tag":buff+="<"+doc2.name+(doc2.attrs?par2.attrString(doc2.attrs):"")+(doc2.isV?"/>":">");if(doc2.isV)return buff;for(let i=0;i<doc2.children.length;i++){const dc=doc2.children[i];buff=buff+par2._stringify("",dc)}return buff+"</"+doc2.name+">";case"comment":return buff;default:return""}}stringify(doc2){var par2=this;return doc2.reduce(function(token,rootEl){return token+par2._stringify("",rootEl)},"")}}async function renderHST(hst,n,type="main",tx2,_pv=null,scopePath=["View"],ownVars,ownFns,ownViews){var reactiveVariables=hst.reactiveVars;hst=hst.hst;let _re=new _lm(new _v({"name":n,"type":type,"hst":hst,"vars":ownVars??tx2?.vx,"fns":ownFns,"views":ownViews,"rvs":reactiveVariables,"_pv":_pv}));_re.view.scopePath=scopePath;if(Object.keys(_re._cc).length){for(const ky in _re._cc){if(Object.hasOwnProperty.call(_re._cc,ky)){const csses=_re._cc[ky];for(let inde=0;inde<csses.length;inde++){let prom=new defer;const css=csses[inde];_csswrk.trigger("css-ready",{"csses":[css._css],"pre":"[vuid='"+ky+"']","key":ky});_vuid[ky]=prom;let _csses=await prom;css.nd.textContent=_csses[0]}}}}if(Object.keys(_re._jj).length){for(const ky in _re._jj){if(Object.hasOwnProperty.call(_re._jj,ky)){const jses=_re._jj[ky];for(let inde=0;inde<jses.length;inde++){const nd=jses[inde].nd;let code=_lmScriptCode(nd,_re.view,reactiveVariables,scopePath);if(code===null)continue;code=`try { _lmSetViewVar(document.currentScript); `+code+` } catch (e) { reportLumenError({ stage: 'script', error: e }); }`;code=code+`
|
|
27
27
|
//# sourceURL=`+(_re.view?.name||"view")+`.view.generated.js`;nd.textContent=code}}}}return _re}async function fireRenderHook(cx,n,containerEl,extra){if(!containerEl)return;let attrKey="@"+n;if(!cx.doc||!cx.doc.evs||!cx.doc.evs.hasOwnProperty(attrKey))return;let attrVal=cx.doc.evs[attrKey];if(!attrVal)return;let ev=Object.assign({cType:n},extra||{});let result=evalEvAttr(attrVal,ev,$(containerEl),n);if(result&&typeof result.then==="function"){try{return await result}catch(e){return void 0}}return result}var _pendingPluginEls=[];var _pluginFlushTimer=null;function _flushPendingPlugins(tries){_pluginFlushTimer=null;var waiting=[];for(var i=0;i<_pendingPluginEls.length;i++){var p=_pendingPluginEls[i];if(p[0].isConnected)autoInitPlugins(p[0],p[1]);else waiting.push(p)}_pendingPluginEls=waiting;if(waiting.length&&tries<40){_pluginFlushTimer=setTimeout(function(){_flushPendingPlugins(tries+1)},50)}else{_pendingPluginEls=[]}}function _queuePluginInit(el2,attrs){_pendingPluginEls.push([el2,attrs]);if(_pluginFlushTimer===null){_pluginFlushTimer=setTimeout(function(){_flushPendingPlugins(0)},0)}}function autoInitPlugins(el2,attrs){if(!attrs)return;if(el2&&el2.isConnected===false&&(attrs.hasOwnProperty("sl")||attrs.hasOwnProperty("color")||attrs.hasOwnProperty("time")||attrs.hasOwnProperty("date")||attrs.hasOwnProperty("datetime"))){_queuePluginInit(el2,attrs);return}try{if(attrs.hasOwnProperty("sl")&&typeof $.fn.select2==="function"){initSl($(el2))}if(attrs.hasOwnProperty("color")&&typeof $.fn.colorpicker==="function"){$(el2).removeAttr("color").colorpicker({format:"rgba"})}if(typeof $.fn.datetimepicker==="function"){if(attrs.hasOwnProperty("time"))dtp($(el2),"time");if(attrs.hasOwnProperty("date"))dtp($(el2),"date");if(attrs.hasOwnProperty("datetime"))dtp($(el2),"datetime")}}catch(e){cl(e)}}function initSl(t){if(t.hasClass("select2-hidden-accessible"))return;try{var plchldr=t.attr("placeholder")?t.attr("placeholder"):"";var dir=$("body").hasClass("rtl")?"rtl":"ltr";var nr=t.attr("sl-nrmsg")?t.attr("sl-nrmsg"):"No results found";var minResultsForSearch=t.attr("sl-mins")?t.attr("sl-mins"):10;var allowNewTags=t.attr("sl-ntgs")?true:false;var dropdownParent=t.attr("sl-prt")?t.attr("sl-prt"):"body";if(dropdownParent=="self")dropdownParent=t.parent();else dropdownParent=$(dropdownParent);var query=t.attr("sl-query")?t.attr("sl-query"):null;var uniquer=Date.now();if(typeof window[query]==="function"){t.select2.amd.define("adapt_"+uniquer,["select2/data/array","select2/utils"],function(ArrayAdapter,Utils){function CustomDataAdapter($element,options){CustomDataAdapter.__super__.constructor.call(this,$element,options)}Utils.Extend(CustomDataAdapter,ArrayAdapter);CustomDataAdapter.prototype.query=function(params,callback){clearTimeout(_dbcrs[uniquer]);let _t=t;_dbcrs[uniquer]=setTimeout(function(){window[query](params,callback,_t)},!_dbcrs.hasOwnProperty(uniquer)?0:_dbcrsTime)};return CustomDataAdapter});t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}},...t.select2.amd.require("adapt_"+uniquer)?{ajax:{},dataAdapter:t.select2.amd.require("adapt_"+uniquer)}:{}})}else{t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}}})}if(t.attr("sl-nosrch"))t.on("select2:opening select2:closing",function(event){$(this).parent().find(".select2-search__field").prop("disabled",true)});if(t.attr("sl-class")){t.on("select2:opening",function(event){dropdownParent.addClass(t.attr("sl-class"))});t.on("select2:closing",function(event){dropdownParent.removeClass(t.attr("sl-class"))})}if(t.attr("sl-id")||t.attr("sl-text")){let text=t.attr("sl-text");let id=t.attr("sl-id");if(!text)text=id;if(!id)id=text;let newOption=new Option(text,id,true,true);t.append(newOption).trigger("select")}else{t.select2("val","")}if(t.attr("sl-value"))t.val(t.attr("sl-value")).trigger("change")}catch(e){cl(e)}}var _dbcrs={};var _dbcrsTime=250;function dtp(el2,t){el2.removeAttr(t);let opts={format:t=="date"?"yyyy-mm-dd":t=="time"?"hh:ii":"yyyy-mm-dd hh:ii",weekStart:el2.attr("date-week-start")??1,startView:t=="time"?1:el2.attr("startview")?el2.attr("startview"):2,minView:el2.attr("minview")?el2.attr("minview"):t=="time"?0:t=="datetime"?0:2,maxView:el2.attr("maxview")?el2.attr("maxview"):t=="time"?1:4,todayBtn:t=="time"?0:el2.attr("date-today")=="false"?0:1,todayHighlight:t=="time"?0:el2.attr("date-today")=="false"?0:1,language:el2.attr("date-lang")??"en",minuteStep:el2.attr("date-minute-step")??5,pickerPosition:el2.attr("date-position")??"top-right",autoclose:1,showMeridian:false};if(el2.attr("date-start"))opts["startDate"]=el2.attr("date-start");if(el2.attr("date-end"))opts["endDate"]=el2.attr("date-end");if(el2.attr("date-value"))opts["date"]=el2.attr("date-value");el2.datetimepicker(opts);if(t=="time"){el2.on("show",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: hidden; font-size:0px !important; overflow: hidden; height: 0px;")}).on("hide",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: visible;")})}if(el2.attr("date-link-start")){el2.on("change",function(e){let dp1=el2.data("datetimepicker");let dp2=$(el2.attr("date-link-start")).data("datetimepicker");dp2.setStartDate(dp1.getFormattedDate());if(dp2.getFormattedDate()<dp1.getFormattedDate()||dp2.getFormattedDate()=="")$(el2.attr("date-link-start")).val(dp1.getFormattedDate())})}else if(el2.attr("date-link-end")){el2.on("change",function(e){let dp1=$(el2.attr("date-link-end")).data("datetimepicker");let dp2=el2.data("datetimepicker");dp1.setEndDate(dp2.getFormattedDate())});opts["useCurrent"]=false}}const _V1_DEFAULT_LAYOUT={hst:["nav","header","body","footer"].map(function(r){let attrs={};attrs[r]="";return{type:"tag",name:"div",isV:false,attrs,ax:{},evs:{},ex:{},children:[]}}),reactiveVars:[],regions:["nav","header","footer"]};function _resolveTemplateEntry(attrs){let _payload=typeof _vcD!=="undefined"&&_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);let name=String(attrs["tpl"]).replace(/^\/+/,"");let bucket=_payload&&_payload.tpls;for(const f of["tpls","comps"]){let entry=bucket&&bucket[btoa("src/"+f+"/"+name+".tpl")];if(entry)return entry}reportLumenError({stage:"tpl",error:new Error('tpl="'+name+'" \u2014 no such file at src/tpls/'+name+".tpl")});return null}function _reportTplMisuse(doc2,par2){if(doc2._tplReported)return;try{Object.defineProperty(doc2,"_tplReported",{value:true,enumerable:false})}catch(e){}let view=par2&&par2.view&&par2.view.name?' in "'+par2.view.name+'"':"";let msg;if(doc2.attrs.hasOwnProperty("comp")){msg='comp="'+doc2.attrs["comp"]+'"'+view+" is no longer supported. Put the :for on the element and use tpl=, e.g. <"+doc2.name+' :for="items as item" tpl="'+String(doc2.attrs["comp"]).replace(/^\/+/,"")+`">, and move the template's own :for out of the .tpl file.`}else{msg='tpl="'+doc2.attrs["tpl"]+'"'+view+" only works on a :for loop element, e.g. <"+doc2.name+' :for="items as item" tpl="'+String(doc2.attrs["tpl"]).replace(/^\/+/,"")+'">. It was ignored on this <'+doc2.name+">; move the template's :for onto this element."}reportLumenError({stage:"tpl",error:new Error(msg)})}async function renderSection(tx2,doc2,par2,k,sectionsData){if(tx2.node.isConnected){if(k){tx2._re.update(k)}return tx2._re}var hst=doc2.children;if(doc2.attrs&&(doc2.attrs.hasOwnProperty("tpl")||doc2.attrs.hasOwnProperty("comp"))){if(doc2.type==="sections"&&doc2.attrs.hasOwnProperty("tpl")&&!doc2.attrs.hasOwnProperty("comp")){let _tplEntry=_resolveTemplateEntry(doc2.attrs);if(_tplEntry)hst=_tplEntry.hst}else{_reportTplMisuse(doc2,par2)}}let _re=await renderHST({hst,mxes:[]},tx2.key,"section",tx2,par2,par2?.view?.scopePath||["View"],void 0,void 0,par2?.view?.views);tx2._re=_re;if(tx2.node){tx2.replaceWith(tx2.node);tx2.node.innerHTML="";tx2.node.append(..._re._RealDOM);_re.setEffects(doc2,tx2.node);_re.renderAll("section")}return _re}function _lmHstDefaults(payload){function fix(n){if(!n||typeof n!=="object")return;if(Array.isArray(n)){for(let i=0;i<n.length;i++)fix(n[i]);return}if(n.type==="text"){if(!n.mss)n.mss=[];return}if(n.type==="tag"||n.type==="section"||n.type==="sections"){if(!n.attrs)n.attrs={};if(!n.ax)n.ax={};if(!n.evs)n.evs={};if(!n.ex)n.ex={};if(n.isV===void 0)n.isV=false;if(!n.children)n.children=[];fix(n.children)}}for(const sec of["views","layouts","tpls"]){const group=payload[sec];if(!group)continue;for(const k in group)if(group[k]&&group[k].hst)fix(group[k].hst)}}var _lmScriptCodeBySrc=new Map;var _lmScriptCodeByAst=new WeakMap;function _lmScopeExpr(scopePath){let segs=Array.isArray(scopePath)?scopePath:[scopePath];let e="_vt";for(let i=0;i<segs.length;i++)e+=typeof segs[i]==="number"?"["+segs[i]+"]":"."+segs[i];return e}function _lmScriptCode(nd,view,reactiveVariables,scopePath){if(typeof nd._pre==="string")return nd._pre.split("_vt.__LMROOT__").join(_lmScopeExpr(scopePath));if(typeof getWatcher!=="function"||typeof acorn==="undefined"){reportLumenError({stage:"script",error:new Error("this view script was not precompiled by lm build and this production runtime cannot compile scripts \u2014 rebuild with a matching @lmjs/cli")});return null}let rv=Array.isArray(reactiveVariables)?reactiveVariables.join(","):Object.keys(reactiveVariables||{}).join(",");let subKey=rv+""+(Array.isArray(scopePath)?scopePath.join(""):String(scopePath));let bucket;if(nd._jst!==void 0){if(!nd._jst||typeof nd._jst!=="object")return null;bucket=_lmScriptCodeByAst.get(nd._jst);if(!bucket){bucket=new Map;_lmScriptCodeByAst.set(nd._jst,bucket)}if(bucket.has(subKey))return bucket.get(subKey);let code2=getWatcher(nd._jst,view,reactiveVariables,scopePath).code;bucket.set(subKey,code2);return code2}if(!nd._js||!String(nd._js).trim())return null;let key=nd._js+"\0"+subKey;if(_lmScriptCodeBySrc.has(key))return _lmScriptCodeBySrc.get(key);let ast;try{ast=acorn.parse(nd._js,{ecmaVersion:"latest",sourceType:"script"})}catch(e){reportLumenError({stage:"script",error:e});return null}let code=getWatcher(ast,view,reactiveVariables,scopePath).code;if(_lmScriptCodeBySrc.size>=1e3)_lmScriptCodeBySrc.clear();_lmScriptCodeBySrc.set(key,code);return code}function _lmSetViewVar(script){for(let n=script&&script.parentNode;n;n=n.parentNode){if(n.isSub===true){window.view=$(n);return}}}function mountModalView(el2,name){if(!el2||!name)return Promise.resolve();el2.isSub=true;el2.subPath=prepareNode(name).split("?")[0];el2.vars={};el2.views=[];el2.fns={};_vt.View.views.push(el2);return renderView(name,true,{})}async function renderView(n,isSub,d,type="views",viewsArr,scopeBase=["View"],force=false){let filePath="src/views/"+n+".view";if(type=="layouts")filePath="src/layouts/"+n+".layout";let fileKey=btoa(filePath);if(!isSub){View.props=d??{};var _queryParams=window.location.href.split("?");var nn=_queryParams.shift();View.params=paraToObj(_queryParams)??{}}n=prepareNode(n);var _queryParams=n.split("?");n=_queryParams.shift();let _payload=_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);if(_payload&&!_payload.__hstVersionChecked){_payload.__hstVersionChecked=true;_lmHstDefaults(_payload);if(_payload.hstFormatVersion!==void 0&&_HST_FORMATS_ACCEPTED.indexOf(_payload.hstFormatVersion)===-1){reportLumenError({stage:"hst-version-mismatch",error:new Error("This project was compiled for HST format v"+_payload.hstFormatVersion+", but this LumenJS runtime expects v"+EXPECTED_HST_FORMAT_VERSION+". @lmjs/cli and @lmjs/core are out of sync \u2014 reinstall/upgrade both together.")});return}}if(_payload&&_payload[type].hasOwnProperty(fileKey)&&_csswrk.isStarted()){if(isSub)cl("Rendering",n,fileKey);var hst=_payload[type][fileKey];if(isSub){let searchArr=viewsArr||_vt.View.views;let els=[];for(let i=0;i<searchArr.length;i++){let _el2=searchArr[i];if(_el2.__isProxy)_el2=_el2.target;if(_el2.subPath==n)els.push({el:_el2,viewsIndex:i})}if(els.length){for(let i=0;i<els.length;i++){const{el:el2,viewsIndex}=els[i];if(!force&&el2._mountedSubPath===n&&el2._re&&el2._re._RealDOM&&el2._re._RealDOM.some(nd=>nd.isConnected)){continue}if(!force&&el2._mountedSubPath!==void 0&&!el2.isConnected){continue}el2.vars=el2.vars||{};el2.views=el2.views||[];el2.fns=el2.fns||{};let _re=await renderHST(hst,n,"sub",void 0,null,scopeBase.concat(["views",viewsIndex]),el2.vars,el2.fns,el2.views);el2._re=_re;el2._mountedSubPath=n;_mountedSubviewEngines.push(_re);el2.innerHTML="";el2.append(..._re._RealDOM);_re.renderAll();if(typeof globalWatch==="function"){try{globalWatch()}catch(e){cl(e)}}}}}else{if(type=="layouts"){let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);if(appContainer.length){let _rel=await renderHST(hst,n,"layout");appContainer.data("layout",n).html(_rel._RealDOM);_rel.renderAll();goToNode()}}else{let _re=await renderHST(hst,n,"main");if(_re.view.settings&&_re.view.settings.requireAuth){let authFunc=appSettings.auth&&typeof appSettings.auth==="function"?appSettings.auth:typeof Auth==="function"?Auth:null;if(typeof authFunc!=="function"){setError(null,"No Reactor.auth() function detected! Please add one");return}if(!authFunc()){let fallback=(appSettings.authView||appSettings.defaultView||"home").toLowerCase();if(fallback==n.toLowerCase()){setError(null,"The auth view '"+n+"' itself has requireAuth: true \u2014 it can never render");return}return renderView(fallback,null,{redirect:n.toLowerCase(),data:clone(View.props)})}}let layout=_re.view.settings.layout;let filePathL="src/layouts/"+layout+".layout";let fileKeyL=btoa(filePathL);let hstL=_payload["layouts"]&&_payload["layouts"][fileKeyL];if(!hstL){if(layout&&layout!=="default"){reportLumenError({stage:"layout",error:new Error('layout "'+layout+'" not found at '+filePathL+" \u2014 using the built-in default layout")})}hstL=JSON.parse(JSON.stringify(_V1_DEFAULT_LAYOUT))}let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);let layoutJustSwapped=false;if(appContainer.length){let currentLayout=$(appSelector).data("layout");if(currentLayout!=layout){let _rel=await renderHST(hstL,layout,"layout");appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll();layoutJustSwapped=true}else{}}else{$("body").prepend("<div "+appSelector+"></div>");let _rel=await renderHST(hstL,layout,"layout");appContainer=$(appSelector);appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll();layoutJustSwapped=true}let declaredRegions=hstL&&hstL.regions||[];for(const regionName of declaredRegions){let settingsKey="has"+regionName[0].toUpperCase()+regionName.slice(1);let want=_re.view.settings.hasOwnProperty(settingsKey)?_re.view.settings[settingsKey]:true;let resolvedFile=want===false?null:want===true?regionName:want;let w=_vt.Widgets[regionName]||(_vt.Widgets[regionName]={vars:{},fns:{},views:[],_re:null,_resolvedFile:void 0});if(resolvedFile!==w._resolvedFile){if(resolvedFile===null){$("["+regionName+"]").html("");w._re=null;w._resolvedFile=resolvedFile}else{let wFilePath="src/views/widgets/"+resolvedFile+".view";let wHst=_payload["views"][btoa(wFilePath)];if(wHst){let _rew=await renderHST(wHst,resolvedFile,"widget",void 0,null,["Widgets",regionName],w.vars,w.fns,w.views);w._re=_rew;$("["+regionName+"]").html(_rew._RealDOM);_rew.renderAll();w._resolvedFile=resolvedFile}}}else if(layoutJustSwapped&&w._re){$("["+regionName+"]").html(w._re._RealDOM)}}$("[body]").html(_re._RealDOM);if(_re.view._slots){for(const slotName in _re.view._slots){if(Object.prototype.hasOwnProperty.call(_re.view._slots,slotName)){$('[slot="'+slotName+'"]').html(_re.view._slots[slotName])}}}_re.renderAll();if(typeof globalWatch==="function"){try{globalWatch()}catch(e){cl(e)}}if(typeof View!=="undefined"&&View&&typeof View.onAfterMount==="function"){try{View.onAfterMount()}catch(e){cl(e)}}}}}else{setTimeout(()=>{renderView(n,isSub,d)},10)}}
|
|
28
28
|
|
|
29
29
|
var _reactiveEngines=[];var _rxMoustache=/\{\s*\{\s*([\s\S]*?)\s*\}\s*\}/g;var _rxVoid={area:1,base:1,basefont:1,bgsound:1,br:1,col:1,command:1,embed:1,frame:1,hr:1,image:1,img:1,input:1,isindex:1,keygen:1,link:1,menuitem:1,meta:1,nextid:1,param:1,source:1,track:1,wbr:1};var _rxSkip={};"break case catch class const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield await async of static get set null true false undefined NaN Infinity Object Function Boolean Symbol Error Number BigInt Math Date String RegExp Array Map Set WeakMap WeakSet Promise Reflect Proxy Intl JSON console window document navigator location localStorage sessionStorage fetch setTimeout clearTimeout setInterval clearInterval parseInt parseFloat isFinite isNaN encodeURI decodeURI encodeURIComponent decodeURIComponent escape unescape globalThis".split(" ").forEach(function(w){_rxSkip[w]=1});var _rxExprCache=new Map;function _rxKeepOneSpace(t){t=t.replace(/\s\s/gm," ");if(/\s\s/gm.test(t))return _rxKeepOneSpace(t);return t}function _rxClean(t){t=t.replace(/(\r?\n|\r)/gm,"");t=t.replace(/(\t)/gm,"");t=_rxKeepOneSpace(t);return t.replace(/^(?:\s*\t*\r*\n*\{*)+|(?:\s*\t*\r*\n*\})+$/g,"").trim()}function _rxIdents(src,out){var i=0,n=src.length,prev="";function skipTemplate(){i++;while(i<n){var c=src[i];if(c==="\\"){i+=2;continue}if(c==="`"){i++;return}if(c==="$"&&src[i+1]==="{"){i+=2;var depth=1,start=i;while(i<n&&depth){var d=src[i];if(d==="`"){var s=i;skipTemplate();continue}if(d==="{")depth++;else if(d==="}"){depth--;if(!depth)break}else if(d==="'"||d==='"'){var q=d;i++;while(i<n&&src[i]!==q){if(src[i]==="\\")i++;i++}}i++}_rxIdents(src.slice(start,i),out);i++;continue}i++}}while(i<n){var ch=src[i];if(ch==="'"||ch==='"'){i++;while(i<n&&src[i]!==ch){if(src[i]==="\\")i++;i++}i++;prev="s";continue}if(ch==="`"){skipTemplate();prev="s";continue}if(ch==="/"&&src[i+1]==="/"){while(i<n&&src[i]!=="\n")i++;continue}if(ch==="/"&&src[i+1]==="*"){var e=src.indexOf("*/",i+2);i=e<0?n:e+2;continue}if(/\s/.test(ch)){i++;continue}if(/[0-9]/.test(ch)){while(i<n&&/[\w.]/.test(src[i]))i++;prev="n";continue}if(/[A-Za-z_$]/.test(ch)){var st=i;while(i<n&&/[\w$]/.test(src[i]))i++;var id=src.slice(st,i);var j=i;while(j<n&&/\s/.test(src[j]))j++;var isKey=src[j]===":"&&(prev==="{"||prev===",");if(prev!=="."&&!isKey&&!_rxSkip[id]&&out.indexOf(id)===-1)out.push(id);prev="i";continue}prev=ch;i++}return out}function _rxExpr(mux){var hit=_rxExprCache.get(mux);if(hit)return hit;var rv=null;try{new Function(mux);rv=_rxIdents(mux,[])}catch(e){rv=null}if(_rxExprCache.size>2e3)_rxExprCache.clear();_rxExprCache.set(mux,rv);return rv}function _rxEscape(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _rxMustaches(text,escapeStatic,rvSet){var found=[],m,last=0;_rxMoustache.lastIndex=0;while((m=_rxMoustache.exec(text))!=null){var mux=_rxClean(m[0]);var rvs=_rxExpr(mux);if(rvs)found.push({index:m.index,len:m[0].length,mux,rvs})}if(!found.length)return{content:escapeStatic?_rxEscape(text):text,mss:[]};var esc=escapeStatic?_rxEscape:function(s){return s};var content="",mss=[];for(var k=0;k<found.length;k++){var f=found[k];content+=esc(text.substring(last,f.index));var start=content.length;content+="{{"+f.mux+"}}";mss.push({mus:f.mux,jst:null,rvs:f.rvs.slice(),start,end:content.length});for(var r=0;r<f.rvs.length;r++)rvSet[f.rvs[r]]=1;last=f.index+f.len}content+=esc(text.substring(last));return{content,mss}}function _rxForX(val){var forX={js:"",as:{k:"",v:""},dx:""};val=val.trim();if(val.indexOf(";")>-1){var zxx=val.split(";");forX.dx=zxx[1].trim();val=zxx[0].trim()}if(val.indexOf(" as ")>-1){var arr2=val.split(" as ");var arr3=arr2[1].split(" ").join("").split(",");forX.as.k=arr3[0].trim();if(arr3.length>1)forX.as.v=arr3[1].trim();val=arr2[0].trim()}forX.js=val.trim();return forX}function _rxCompileNode(n,ptag,rvSet){if(n.nodeType===3){var t=n.nodeValue;var mm=_rxMustaches(t,ptag!=="style",rvSet);if(ptag==="textarea"&&mm.mss.length)mm=_rxMustaches(t,false,rvSet);return{type:"text",content:mm.content,mss:mm.mss,tag:ptag}}if(n.nodeType!==1)return null;var name=n.localName;if(name==="script")return null;var res={type:"tag",name,isV:!!_rxVoid[name],attrs:{},ax:{},evs:{},ex:{},children:[]};if(n.namespaceURI==="http://www.w3.org/2000/svg")res.svg=true;var attrs=n.attributes;for(var a=0;a<attrs.length;a++){var an=attrs[a].name,av=attrs[a].value;if(an===":else"){res.type="section";res.cond=""}else if(an===":if"||an===":else-if"){res.type="section";res.cond=av;_rxIdents(av,[]).forEach(function(id){rvSet[id]=1})}else if(an===":for"){res.type="sections";res.content=av;res.forX=_rxForX(av);if(res.forX.js)_rxIdents(res.forX.js,[]).forEach(function(id){rvSet[id]=1})}var ms=_rxMustaches(an.charAt(0)==="@"?av:av.replace(/`(\{\s*\{[\s\S]*?\}\s*\})`/g,"$1"),false,rvSet);if(an.charAt(0)==="@"){res.evs[an]=ms.content;if(ms.mss.length)res.ex[an]=ms.mss}else{res.attrs[an]=ms.content;if(ms.mss.length)res.ax[an]=ms.mss}}_rxOrderIfFor(res);if(!res.isV){var kids=n.childNodes;for(var c=0;c<kids.length;c++){var ch=_rxCompileNode(kids[c],name,rvSet);if(ch)res.children.push(ch)}if(name==="style"&&!res.children.length)res.children.push({type:"text",content:"",mss:[],tag:"style"})}return res}function _rxOrderIfFor(res){if(!res||!res.attrs||!res.forX||!Object.prototype.hasOwnProperty.call(res.attrs,":if"))return;var keys=Object.keys(res.attrs);var cond=String(res.attrs[":if"]);if(keys.indexOf(":if")<keys.indexOf(":for"))res.forX.js="("+cond+") ? ("+res.forX.js+") : []";else res.attrs[":for-if"]=res.attrs[":for-if"]?"("+res.attrs[":for-if"]+") && ("+cond+")":cond;res.type="sections";delete res.cond;delete res.attrs[":if"];if(res.ax)delete res.ax[":if"]}function _rxCompileHost(host){var rvSet={},hst=[],kids=host.childNodes;for(var i=0;i<kids.length;i++){var c=_rxCompileNode(kids[i],host.localName,rvSet);if(c)hst.push(c)}return{hst,reactiveVars:Object.keys(rvSet)}}async function _rxRender(host){host.classList.add("binded");var compiled=_rxCompileHost(host);var sub=null;for(var p=host.parentNode;p;p=p.parentNode){if(p.isSub===true){sub=p;break}}var _re=await renderHST(compiled,"reactive","section",void 0,null,["View"],sub?sub.vars:void 0,sub?sub.fns:void 0);_re._blankUnresolved=true;var bindEl=host.closest("[bind]");if(bindEl){String(bindEl.getAttribute("bind")||"").split(",").forEach(function(v){var parts=v.trim().split(" as ");if(parts.length===2&&parts[0].trim()&&parts[1].trim()){try{_re.vrs[parts[1].trim()]=_re.scopedEval(_re.reactiveVariables,parts[0].trim())}catch(e){}}})}host.textContent="";host.append.apply(host,_re._RealDOM);_re._rxHost=host;_reactiveEngines.push(_re);_re.renderAll("section")}function _updateReactiveEngines(varName){for(var i=_reactiveEngines.length-1;i>=0;i--){var re=_reactiveEngines[i];if(!re._rxHost||!re._rxHost.isConnected){_reactiveEngines.splice(i,1);continue}try{re.update(varName)}catch(e){cl(e)}}}(function(){if(typeof MutationObserver==="undefined"||typeof document==="undefined"||!document.documentElement)return;var pending=[],running=false;function consider(node){if(!node||node.nodeType!==1||node._ownerRe)return;if(node.hasAttribute("reactive"))pending.push(node);if(node.firstElementChild){var found=node.querySelectorAll("[reactive]");for(var i=0;i<found.length;i++)pending.push(found[i])}}async function drain(){if(running)return;running=true;var rendered=0;try{while(pending.length){var h=pending.shift();if(!h.isConnected||h._ownerRe||h.classList.contains("binded"))continue;try{await _rxRender(h);rendered++}catch(e){reportLumenError({stage:"reactive",error:e})}}}finally{running=false}if(rendered&&typeof globalWatch==="function"){try{globalWatch()}catch(e){reportLumenError({stage:"reactive",error:e})}}}new MutationObserver(function(records){for(var r=0;r<records.length;r++){var added=records[r].addedNodes;for(var k=0;k<added.length;k++)consider(added[k])}if(pending.length)drain()}).observe(document.documentElement,{childList:true,subtree:true});function scan(){consider(document.documentElement);if(pending.length)drain()}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",scan);else setTimeout(scan,0)})();
|
package/dist/lib/hst.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _acorn=require("acorn");var acorn=require("acorn-loose");var he=require("he");function parseScriptJs(source){let ast;try{ast=_acorn.parse(source,{ecmaVersion:"latest",sourceType:"script"})}catch(e){ast=acorn.parse(source,{ecmaVersion:"latest"})}return stripAstPositions(ast)}function scriptPayload(source){try{_acorn.parse(source,{ecmaVersion:"latest",sourceType:"script"});return{content:source}}catch(e){return{jst:parseScriptJs(source)}}}exports.scriptPayload=scriptPayload;function stripAstPositions(node){if(Array.isArray(node)){for(let i=0;i<node.length;i++)stripAstPositions(node[i]);return node}if(!node||typeof node!=="object")return node;delete node.start;delete node.end;delete node.loc;delete node.range;for(const k in node){const v=node[k];if(v&&typeof v==="object")stripAstPositions(v)}return node}exports.stripAstPositions=stripAstPositions;const RESERVED_BARE_ATTRS=new Set(["body","view","scoped","tpl","sl","color","time","date","datetime","up","stop","confirm","econfirm","acl","rcl","hidden","disabled","readonly","required","checked","selected","autofocus","multiple","async","defer"]);function _collectWidgetRegions(nodes,found){if(!Array.isArray(nodes))return;for(const node of nodes){if(node&&node.type==="tag"&&node.attrs){for(const attrName in node.attrs){if(Object.prototype.hasOwnProperty.call(node.attrs,attrName)&&node.attrs[attrName]===""&&!RESERVED_BARE_ATTRS.has(attrName)&&!found.includes(attrName)){found.push(attrName)}}}if(node&&Array.isArray(node.children)){_collectWidgetRegions(node.children,found)}}}function annotateLayoutRegions(layoutsObj){for(const key in layoutsObj){if(!Object.prototype.hasOwnProperty.call(layoutsObj,key))continue;let entry=layoutsObj[key];if(!entry||!entry.hst)continue;let found=[];_collectWidgetRegions(entry.hst,found);entry.regions=found}return layoutsObj}exports.annotateLayoutRegions=annotateLayoutRegions;function hst_markSvg(nodes,inSvg){if(!Array.isArray(nodes))return;for(const n of nodes){if(!n||n.type==="text")continue;let name=String(n.name||"").toLowerCase();let here=inSvg||name==="svg";if(here)n.svg=true;let kidsInSvg=here&&name!=="foreignobject";hst_markSvg(n.children,kidsInSvg);if(Array.isArray(n.content))hst_markSvg(n.content,kidsInSvg)}}function hst_orderIfFor(res){if(!res||!res.attrs||!res.forX||!Object.prototype.hasOwnProperty.call(res.attrs,":if"))return;let keys=Object.keys(res.attrs);let cond=String(res.attrs[":if"]);if(keys.indexOf(":if")<keys.indexOf(":for")){res.forX.js="("+cond+") ? ("+res.forX.js+") : []"}else{let prev=res.attrs[":for-if"];res.attrs[":for-if"]=prev?"("+prev+") && ("+cond+")":cond}res.type="sections";delete res.cond;delete res.attrs[":if"];if(res.ax)delete res.ax[":if"]}exports.hst_orderIfFor=hst_orderIfFor;class hst{htmlVoidElements=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","isindex","keygen","link","menuitem","meta","nextid","param","source","track","wbr"];moustachePattern=/\{\s*\{\s*([\s\S]*?)\s*\}\s*\}/g;attrRE=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[\s\S]*?"|'[\s\S]*?')/g;tagRE=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;whitespaceRE=/^\s*$/;empty=Object.create(null);reactiveVariables=[];constructor(html){let hst2=this.parse(html);hst_markSvg(hst2,false);this.reactiveVariables=this.reactiveVariables.filter((value,index,self)=>{return self.indexOf(value)===index});return{hst:hst2,"reactiveVars":this.reactiveVariables}}keepOneSpace(_t){_t=_t.replace(/\s\s/gm," ");if(/\s\s/gm.test(_t))return this.keepOneSpace(_t);return _t}_clean(_t){_t=_t.replace(/(\r?\n|\r)/gm,"");_t=_t.replace(/(\t)/gm,"");_t=this.keepOneSpace(_t);return _t.replace(/^(?:\s*\t*\r*\n*\{*)+|(?:\s*\t*\r*\n*\})+$/g,"").trim()}processAttr(n,v,res){}processForXAttr(val){let forX={"js":"","as":{"k":"","v":""},"dx":""};var val=val.trim();if(val.indexOf(";")>-1){let zxx=val.split(";");forX["dx"]=zxx[1].trim();val=zxx[0].trim()}if(val.indexOf(" as ")>-1){let arr2=val.split(" as ");let kv=[];let arr3=arr2[1].split(" ").join("").split(",");if(arr3.length>1){kv=[arr3[0],arr3[1]]}else{kv=[arr3[0]]}if(kv.length){forX["as"]["k"]=kv[0].trim();if(kv.length>1){forX["as"]["v"]=kv[1].trim()}}val=arr2[0].trim()}forX["js"]=val.trim();return forX}parseTag(tag){var res={type:"tag",name:"",isV:false,attrs:{},ax:{},evs:{},ex:{},children:[]};var tagMatch=tag.match(/<\/?([^\s]+?)[/\s>]/);if(tagMatch){res.name=tagMatch[1];res.isV=this.htmlVoidElements.includes(tagMatch[1])||tag.charAt(tag.length-2)==="/"}var reg=new RegExp(this.attrRE);var result=null;for(;;){result=reg.exec(tag);if(result===null){break}if(!result[0].trim()){continue}if(result[1]){var attr=result[1].trim();var arr=[attr,""];if(arr[0]==":else"){res.type="section";res.cond=""}if(attr.indexOf("=")>-1){arr=attr.split("=")}if(arr[0].substring(0,1)=="@"){}else{if(res.name.toLowerCase()=="icon"&&arr[0].indexOf(":")>-1&&arr[0].substr(0,1)!=":"){res.icon=arr[0]}else res.attrs[arr[0]]=arr[1]}reg.lastIndex--}else if(result[2]){let sl=result[3].trim().substring(1,result[3].length-1);sl=he.decode(sl);if(result[2]==":if"||result[2]==":else-if"||result[2]==":else"){res.type="section";res.cond=sl;if(sl){try{let condAST=acorn.parse(sl,{ecmaVersion:"latest"});let condVars=this.collectVariableUsageFromAST(condAST,{excludeBuiltins:true,extraBuiltins:[]});for(let X=0;X<condVars.length;X++){this.reactiveVariables.push(condVars[X])}}catch(e){}}}else if(result[2]==":for"){res.type="sections";res.content=sl;res.forX=this.processForXAttr(sl);if(res.forX.js){try{let forAST=acorn.parse(res.forX.js,{ecmaVersion:"latest"});let forVars=this.collectVariableUsageFromAST(forAST,{excludeBuiltins:true,extraBuiltins:[]});for(let X=0;X<forVars.length;X++){this.reactiveVariables.push(forVars[X])}}catch(e){}}}if(result[2].substring(0,1)=="@"){let max=this._getMs2(sl);res.evs[result[2]]=max[1];max[0].length?res.ex[result[2]]=max[0]:null}else{let max=this._getMs2(sl.replace(/`(\{\s*\{[\s\S]*?\}\s*\})`/g,"$1"));if(res.name.toLowerCase()=="icon"&&result[2].indexOf(":")>-1&&result[2].substr(0,1)!=":"){res.icon=result[2]}else res.attrs[result[2]]=max[1];max[0].length?res.ax[result[2]]=max[0]:null}}}hst_orderIfFor(res);return res}removeComments(str){str=str.replace(/<!--[\s\S]*?(?:-->)/g,"");return str}cleanExpression(expression){let cleaned="";let inSingle=false,inDouble=false,inTemplate=false;let inRegex=false,escapeNext=false;let inBlockComment=false,inLineComment=false;for(let i=0;i<expression.length;i++){let char=expression[i];let next=expression[i+1];if(escapeNext){cleaned+=char;escapeNext=false;continue}if(inBlockComment){if(char==="*"&&next==="/"){inBlockComment=false;i++}continue}if(inLineComment){if(char==="\n"){inLineComment=false}continue}if(!inSingle&&!inDouble&&!inTemplate&&!inRegex){if(char==="/"&&next==="*"){inBlockComment=true;i++;continue}if(char==="/"&&next==="/"){inLineComment=true;i++;continue}}if(!inDouble&&!inTemplate&&!inRegex&&char==="'"&&!inSingle){inSingle=true;cleaned+=char;continue}else if(inSingle&&char==="'"){inSingle=false;cleaned+=char;continue}if(!inSingle&&!inTemplate&&!inRegex&&char==='"'&&!inDouble){inDouble=true;cleaned+=char;continue}else if(inDouble&&char==='"'){inDouble=false;cleaned+=char;continue}if(!inSingle&&!inDouble&&!inRegex&&char==="`"&&!inTemplate){inTemplate=true;cleaned+=char;continue}else if(inTemplate&&char==="`"){inTemplate=false;cleaned+=char;continue}if(!inSingle&&!inDouble&&!inTemplate&&char==="/"&&!inRegex){let prevNonSpace=cleaned.match(/\S$/);if(!prevNonSpace||/[=({[,;:?!+\-*/%&|^~<>]/.test(prevNonSpace[0])){inRegex=true}cleaned+=char;continue}else if(inRegex&&char==="/"&&expression[i-1]!=="\\"){inRegex=false;cleaned+=char;continue}if(char==="\\"&&(inSingle||inDouble||inTemplate||inRegex)){escapeNext=true;cleaned+=char;continue}if(!inSingle&&!inDouble&&!inTemplate&&!inRegex){if(/\s/.test(char)){if(cleaned[cleaned.length-1]!==" "){cleaned+=" "}continue}}cleaned+=char}return cleaned.trim()}_getMs(_t,wbt){let result="";let lastIndex=0;let _m;var _ms=[];let hasError=false;while((_m=this.moustachePattern.exec(_t))!=null){try{let AST=acorn.parse(_m[0],{ecmaVersion:"latest"});hasError=false;let mux=this._clean(_m[0]);if(wbt){if(_t.substring(_m.index-1,1)=="`"){_ms.push(mux);result+=_t.substring(lastIndex,_m.index);result+="{{"+mux+"}}";lastIndex=_m.index+_m[0].length}}else{if(_t.substring(_m.index-1,1)!="`"){_ms.push(mux);result+=_t.substring(lastIndex,_m.index);result+="{{"+mux+"}}";lastIndex=_m.index+_m[0].length}}}catch(e){hasError=true;result+=_t.substring(lastIndex,_m.index);result+="{{ /*Invalid Javascript Code*/ }}";console.log("Invalid JS",_m[0])}}if(!hasError)result+=_t.substring(lastIndex);return[_ms,result]}_getMs2(_t,wbt){let content="";let lastIndex=0;let _m;var _muxes=[];let hasError=false;while((_m=this.moustachePattern.exec(_t))!=null){try{hasError=false;let mux=this._clean(_m[0]);let JST=acorn.parse(mux,{ecmaVersion:"latest"});let rvs=[];let vss=this.collectVariableUsageFromAST(JST,{excludeBuiltins:true,extraBuiltins:[]});for(let X=0;X<vss.length;X++){rvs.push(vss[X]);this.reactiveVariables.push(vss[X])}rvs=rvs.filter((value,index,self)=>{return self.indexOf(value)===index});_muxes.push({"mus":mux,"rvs":rvs});content+=_t.substring(lastIndex,_m.index);content+="{{"+mux+"}}";lastIndex=_m.index+_m[0].length}catch(e){hasError=true;content+=_t.substring(lastIndex,_m.index);content+="{{ /*Invalid Javascript Code*/ }}";console.log("Invalid JS",_m[0])}}if(!hasError)content+=_t.substring(lastIndex);_muxes=this.setMuxesIndexes(content,_muxes);return[_muxes,content]}setMuxesIndexes(content,_muxes){let muxes=[];let lastIndex=0;let i=0;let _m;while((_m=this.moustachePattern.exec(content))!=null){muxes.push({..._muxes[i],"start":_m.index,"end":_m.index+_m[0].length});lastIndex=_m.index+_m[0].length;i++}return muxes}parse(html,options){if(options===void 0){options={}}options||(options={});options.components||(options.components=this.empty);html=this.removeComments(html);var result=[];var arr=[];var current;var level=-1;var inComponent=false;var inRawText=false;var par=this;if(html.indexOf("<")!==0){var end=html.indexOf("<");let zl=end===-1?html:html.substring(0,end);let mssx=this._getMs2(zl);let textObj={type:"text",content:mssx[1],mss:mssx[0]};result.push(textObj)}html.replace(this.tagRE,async function(tag,index){if(inComponent||inRawText){if(tag!=="</"+current.name+">"){return""}else{inComponent=false;inRawText=false}}var isOpen=tag.charAt(1)!=="/";var start=index+tag.length;var nextChar=html.charAt(start);var parent;if(isOpen){level++;current=par.parseTag(tag);if(current.type==="tag"&&(current.name==="script"||current.name==="style")){inRawText=true}if(current.type==="tag"&¤t.name&&options.components&&options.components[current.name]){current.type="component";inComponent=true}if(!current.isV&&!inComponent&&nextChar&&nextChar!=="<"&&Array.isArray(current.children)){let end2;if(current.name==="script"||current.name==="style"){let closeRe=new RegExp("</\\s*"+current.name+"\\s*>","i");let m=closeRe.exec(html.slice(start));end2=m?start+m.index:html.length}else{end2=html.indexOf("<",start);while(html.charAt(end2+1)==" "){end2=html.indexOf("<",start+(end2+1-start))}}let hl=html.slice(start,end2);let mssx=null;if(current.name!="script")mssx=par._getMs2(hl);let textObj={type:"text",content:current.name=="script"?"":mssx[1],...current.name=="script"?scriptPayload(hl):{mss:mssx[0]},tag:current.name};current.children.push(textObj)}if(level===0){result.push(current)}parent=arr[level-1];if(parent&&parent.children){parent.children.push(current)}arr[level]=current}if(!isOpen||current.isV){if(level>-1&&(current.isV||current.name===tag.slice(2,-1))){level--;current=level===-1?result:arr[level]}if(!inComponent&&nextChar!=="<"&&nextChar){parent=level===-1?result:arr[level].children;var _end=html.indexOf("<",start);var content=html.slice(start,_end===-1?void 0:_end);let wsOnly=par.whitespaceRE.test(content);if(wsOnly?_end>-1&&parent&&Array.isArray(parent):true){if(parent&&Array.isArray(parent)){if(wsOnly){parent.push({type:"text",content,mss:[]})}else{let mssx=par._getMs2(content);let textObj={type:"text",content:mssx[1],mss:mssx[0]};parent.push(textObj)}}}}}});return result}collectVariableUsageFromAST(ast,options={}){const{excludeBuiltins=true,extraBuiltins=[]}=options;const DEFAULT_BUILTINS=new Set(["undefined","NaN","Infinity","null","true","false","Object","Function","Boolean","Symbol","Error","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","Number","BigInt","Math","Date","String","RegExp","Array","Map","Set","WeakMap","WeakSet","Promise","Reflect","Proxy","Intl","JSON","Atomics","SharedArrayBuffer","ArrayBuffer","DataView","WeakRef","FinalizationRegistry","console","window","document","navigator","location","localStorage","sessionStorage","fetch","XMLHttpRequest","setTimeout","clearTimeout","setInterval","clearInterval","requestAnimationFrame","cancelAnimationFrame","process","global","globalThis","require","module","exports","Buffer","parseInt","parseFloat","isFinite","isNaN","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","escape","unescape"]);const builtinSet=new Set([...DEFAULT_BUILTINS,...extraBuiltins]);function createScope(parent=null,isFunction=false){return{parent,isFunction:!!isFunction,names:new Set}}const scopeForNode=new WeakMap;const bindingIdNodes=new WeakSet;const allDeclaredNames=new Set;function markPatternBindings(pattern,scope,kind="var"){if(!pattern)return;switch(pattern.type){case"Identifier":bindingIdNodes.add(pattern);declareInScope(pattern.name,kind,scope);allDeclaredNames.add(pattern.name);break;case"ArrayPattern":for(const el of pattern.elements)if(el)markPatternBindings(el,scope,kind);break;case"ObjectPattern":for(const p of pattern.properties){if(p.type==="Property")markPatternBindings(p.value,scope,kind);else if(p.type==="RestElement")markPatternBindings(p.argument,scope,kind)}break;case"RestElement":markPatternBindings(pattern.argument,scope,kind);break;case"AssignmentPattern":markPatternBindings(pattern.left,scope,kind);break;default:break}}function declareInScope(name,kind,currentScope){if(!name||!currentScope)return;if(kind==="var"||kind==="function"){let s=currentScope;while(s&&!s.isFunction&&s.parent)s=s.parent;s.names.add(name)}else{currentScope.names.add(name)}}function buildScopes(node,currentScope){if(!node||typeof node!=="object")return;switch(node.type){case"Program":{scopeForNode.set(node,currentScope);for(const stmt of node.body)buildScopes(stmt,currentScope);return}case"FunctionDeclaration":{if(node.id){bindingIdNodes.add(node.id);declareInScope(node.id.name,"function",currentScope);allDeclaredNames.add(node.id.name)}const fnScope=createScope(currentScope,true);scopeForNode.set(node,fnScope);for(const p of node.params)markPatternBindings(p,fnScope,"param");buildScopes(node.body,fnScope);return}case"FunctionExpression":{const fnScope=createScope(currentScope,true);scopeForNode.set(node,fnScope);if(node.id){bindingIdNodes.add(node.id);declareInScope(node.id.name,"let",fnScope);allDeclaredNames.add(node.id.name)}for(const p of node.params)markPatternBindings(p,fnScope,"param");buildScopes(node.body,fnScope);return}case"ArrowFunctionExpression":{const fnScope=createScope(currentScope,true);scopeForNode.set(node,fnScope);for(const p of node.params)markPatternBindings(p,fnScope,"param");buildScopes(node.body,fnScope);return}case"BlockStatement":case"StaticBlock":case"SwitchStatement":{const blockScope=createScope(currentScope,false);scopeForNode.set(node,blockScope);if(node.type==="SwitchStatement"){for(const c of node.cases)buildScopes(c,blockScope)}else{for(const s of node.body)buildScopes(s,blockScope)}return}case"CatchClause":{const catchScope=createScope(currentScope,false);scopeForNode.set(node,catchScope);if(node.param)markPatternBindings(node.param,catchScope,"let");buildScopes(node.body,catchScope);return}case"ForStatement":case"ForInStatement":case"ForOfStatement":{const forScope=createScope(currentScope,false);scopeForNode.set(node,forScope);if(node.init)buildScopes(node.init,forScope);if(node.left)buildScopes(node.left,forScope);if(node.test)buildScopes(node.test,forScope);if(node.update)buildScopes(node.update,forScope);buildScopes(node.body,forScope);return}case"VariableDeclaration":{for(const decl of node.declarations||[]){markPatternBindings(decl.id,currentScope,node.kind||"var");if(decl.init)buildScopes(decl.init,currentScope)}return}case"ClassDeclaration":{if(node.id){bindingIdNodes.add(node.id);declareInScope(node.id.name,"let",currentScope);allDeclaredNames.add(node.id.name)}if(node.body)buildScopes(node.body,currentScope);return}case"ImportDeclaration":{for(const spec of node.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declareInScope(spec.local.name,"const",currentScope);allDeclaredNames.add(spec.local.name)}}return}case"ExportNamedDeclaration":case"ExportDefaultDeclaration":case"ExportAllDeclaration":{if(node.declaration)buildScopes(node.declaration,currentScope);return}default:break}for(const key of Object.keys(node)){if(key==="loc"||key==="range")continue;const child=node[key];if(Array.isArray(child)){for(const c of child)if(c&&typeof c==="object")buildScopes(c,currentScope)}else if(child&&typeof child==="object"){buildScopes(child,currentScope)}}}const rootScope=createScope(null,true);scopeForNode.set(ast,rootScope);buildScopes(ast,rootScope);const usageSet=new Set;function isVariableUsageIdentifier(node,parent,propName){if(!parent)return true;if(bindingIdNodes.has(node))return false;if(parent.type==="LabeledStatement"&&propName==="label"||(parent.type==="BreakStatement"||parent.type==="ContinueStatement")&&propName==="label"){return false}if(parent.type==="MemberExpression"&&propName==="property"&&parent.computed===false){return false}if(parent.type==="Property"&&propName==="key"&&parent.computed===false&&!parent.shorthand){return false}if((parent.type==="MethodDefinition"||parent.type==="PropertyDefinition")&&propName==="key"&&parent.computed===false){return false}if(parent.type&&(parent.type.startsWith("Import")||parent.type.startsWith("Export")||parent.type==="MetaProperty")){return false}if((parent.type==="FunctionDeclaration"||parent.type==="FunctionExpression"||parent.type==="ClassDeclaration")&&propName==="id"){return false}if(parent.type==="VariableDeclarator"&&propName==="id"||parent.type==="CatchClause"&&propName==="param"){return false}if((parent.type==="CallExpression"||parent.type==="OptionalCallExpression")&&propName==="callee"){return false}if(parent.type==="NewExpression"&&propName==="callee"){return false}return true}const scopeStack=[rootScope];function collect(node,parent,propName,index){if(!node||typeof node!=="object")return;const nodeScope=scopeForNode.get(node);if(nodeScope)scopeStack.push(nodeScope);if(node.type==="Identifier"){if(isVariableUsageIdentifier(node,parent,propName)){const name=node.name;if(!(excludeBuiltins&&builtinSet.has(name))){usageSet.add(name)}}}for(const key of Object.keys(node)){if(key==="loc"||key==="range")continue;const child=node[key];if(Array.isArray(child)){for(let i=0;i<child.length;i++){const c=child[i];if(c&&typeof c==="object")collect(c,node,key,i)}}else if(child&&typeof child==="object"){collect(child,node,key,null)}}if(nodeScope)scopeStack.pop()}collect(ast,null,null,null);const self=this;(function findTpl(node){if(!node||typeof node!=="object")return;if(node.type==="TemplateLiteral"&&node.expressions.length===0&&node.quasis.length===1){const inner=node.quasis[0].value.cooked;if(inner&&inner.trim()){try{const innerAst=_acorn.parse(inner,{ecmaVersion:"latest",sourceType:"script"});for(const n of self.collectVariableUsageFromAST(innerAst,options))usageSet.add(n)}catch(e){}}return}for(const key of Object.keys(node)){if(key==="loc"||key==="range")continue;const child=node[key];if(Array.isArray(child))child.forEach(findTpl);else if(child&&typeof child==="object")findTpl(child)}})(ast);return Array.from(usageSet).sort()}}function _hst(html){return new hst(html)}exports.parseScriptJs=parseScriptJs;exports.hst_markSvg=hst_markSvg;exports.hst=hst;exports._hst=_hst;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmjs/cli",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "Command line interface for LumenJS — scaffold, develop, and build LumenJS applications. LumenJS is a tiny, fast reactive JavaScript framework for building web applications and interfaces with standard HTML, CSS, and JavaScript.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lm": "./dist/bin/commands.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"ora": "^6.1.2",
|
|
53
53
|
"semver": "^7.3.7",
|
|
54
54
|
"ws": "^8.8.1",
|
|
55
|
-
"@lmjs/core": "2.5.
|
|
55
|
+
"@lmjs/core": "2.5.4"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=18.0.0"
|