@lmjs/cli 2.6.0 → 2.6.2
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/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");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"){require(path.join(__dirname,"copilot","auth.js")).loginCommand(process.argv.slice(3))}else if(command=="logout"){require(path.join(__dirname,"copilot","auth.js")).logout()}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);if(!c.length||String(c[0])[0]=="-"&&c.length<2){console.log("Usage: lm create <project name> (or lm create -v|-s|-t <name> for a view, sub-view or layout)");return}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"){require(path.join(__dirname,"copilot","auth.js")).loginCommand(process.argv.slice(3))}else if(command=="logout"){require(path.join(__dirname,"copilot","auth.js")).logout()}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)+`,
|
|
@@ -28,7 +28,7 @@ var cl=console.log;var LumenJS_HTML_SNIFF_RE=/([&][a-zA-Z]*[;]+)|<\/?[a-z][\s\S]
|
|
|
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)})();
|
|
30
30
|
|
|
31
|
-
var LM_BUILD=(function(){try{var m=/\/js\/app\.(\d+)\.js/.exec(document.currentScript&&document.currentScript.src||(function(){var s=document.querySelectorAll('script[src*="/js/app."]');return s.length?s[s.length-1].src:""})());return m?parseInt(m[1],10):0}catch(e){return 0}})();var LM_VERSION=(function(){if(!LM_BUILD)return"dev";var d=new Date(LM_BUILD);var p=function(n){return(n<10?"0":"")+n};return d.getUTCFullYear()+"."+p(d.getUTCMonth()+1)+"."+p(d.getUTCDate())+"."+p(d.getUTCHours())+p(d.getUTCMinutes())})();var _lmUpdateShown=false;function _lmUpdateOpts(){var o=typeof appSettings!=="undefined"&&appSettings?appSettings.updateCheck:void 0;if(o===false)return null;return o&&typeof o==="object"?o:{}}function _lmShowUpdateBar(opts,latest){if(_lmUpdateShown)return;_lmUpdateShown=true;var reload=function(){location.reload()};if(typeof opts.onUpdate==="function"){try{opts.onUpdate({current:LM_BUILD,latest,reload})}catch(e){cl(e)}return}if(!document.getElementById("lm-update-style")){var st=document.createElement("style");st.id="lm-update-style";st.textContent=".lm-update-bar{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);z-index:100001;display:flex;align-items:center;gap:14px;max-width:calc(100vw - 32px);padding:10px 12px 10px 18px;background:var(--color-card-background,#1c1c1e);border:1px solid var(--color-border--dark,#333);border-radius:12px;box-shadow:0 16px 40px -10px rgba(0,0,0,.55);color:var(--color-text,#e8e8e8);font-size:13px;font-family:inherit}.lm-update-go{background:#e5484d;color:#fff;border:0;border-radius:8px;padding:6px 14px;font-weight:700;cursor:pointer;font-size:13px}.lm-update-x{background:none;border:0;color:#8a8a8a;font-size:18px;line-height:1;cursor:pointer;padding:2px 4px}.lm-update-x:hover{color:var(--color-text,#e8e8e8)}";document.head.appendChild(st)}var bar=document.createElement("div");bar.className="lm-update-bar";bar.setAttribute("role","status");var msg=document.createElement("span");msg.textContent=opts.message||"A new version is available.";var go=document.createElement("button");go.type="button";go.className="lm-update-go";go.textContent=opts.buttonText||"Reload";go.onclick=reload;var x=document.createElement("button");x.type="button";x.className="lm-update-x";x.setAttribute("aria-label","Dismiss");x.textContent="\xD7";x.onclick=function(){if(bar.parentNode)bar.parentNode.removeChild(bar)};bar.appendChild(msg);bar.appendChild(go);bar.appendChild(x);document.body.appendChild(bar)}function lmCheckForUpdate(){var opts=_lmUpdateOpts();if(!opts||!LM_BUILD||_lmUpdateShown||typeof fetch!=="function")return Promise.resolve(false);var url=opts.url||"/";return fetch(url+(url.indexOf("?")>-1?"&":"?")+"_v="+Date.now(),{cache:"no-store",credentials:"same-origin"}).then(function(r){return r.ok?r.text():""}).then(function(html){var m=/\/js\/app\.(\d+)\.js/.exec(html
|
|
31
|
+
var LM_BUILD=(function(){try{var m=/\/js\/app\.(\d+)\.js/.exec(document.currentScript&&document.currentScript.src||(function(){var s=document.querySelectorAll('script[src*="/js/app."]');return s.length?s[s.length-1].src:""})());return m?parseInt(m[1],10):0}catch(e){return 0}})();var LM_VERSION=(function(){if(!LM_BUILD)return"dev";var d=new Date(LM_BUILD);var p=function(n){return(n<10?"0":"")+n};return d.getUTCFullYear()+"."+p(d.getUTCMonth()+1)+"."+p(d.getUTCDate())+"."+p(d.getUTCHours())+p(d.getUTCMinutes())})();var _lmUpdateShown=false;function _lmUpdateOpts(){var o=typeof appSettings!=="undefined"&&appSettings?appSettings.updateCheck:void 0;if(o===false)return null;return o&&typeof o==="object"?o:{}}function _lmShowUpdateBar(opts,latest){if(_lmUpdateShown)return;_lmUpdateShown=true;var reload=function(){var done=false;var go2=function(){if(!done){done=true;location.reload()}};setTimeout(go2,4e3);try{fetch(location.href,{cache:"reload",credentials:"same-origin"}).then(go2,go2)}catch(e){go2()}};if(typeof opts.onUpdate==="function"){try{opts.onUpdate({current:LM_BUILD,latest,reload})}catch(e){cl(e)}return}if(!document.getElementById("lm-update-style")){var st=document.createElement("style");st.id="lm-update-style";st.textContent=".lm-update-bar{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);z-index:100001;display:flex;align-items:center;gap:14px;max-width:calc(100vw - 32px);padding:10px 12px 10px 18px;background:var(--color-card-background,#1c1c1e);border:1px solid var(--color-border--dark,#333);border-radius:12px;box-shadow:0 16px 40px -10px rgba(0,0,0,.55);color:var(--color-text,#e8e8e8);font-size:13px;font-family:inherit}.lm-update-go{background:#e5484d;color:#fff;border:0;border-radius:8px;padding:6px 14px;font-weight:700;cursor:pointer;font-size:13px}.lm-update-x{background:none;border:0;color:#8a8a8a;font-size:18px;line-height:1;cursor:pointer;padding:2px 4px}.lm-update-x:hover{color:var(--color-text,#e8e8e8)}";document.head.appendChild(st)}var bar=document.createElement("div");bar.className="lm-update-bar";bar.setAttribute("role","status");var msg=document.createElement("span");msg.textContent=opts.message||"A new version is available.";var go=document.createElement("button");go.type="button";go.className="lm-update-go";go.textContent=opts.buttonText||"Reload";go.onclick=reload;var x=document.createElement("button");x.type="button";x.className="lm-update-x";x.setAttribute("aria-label","Dismiss");x.textContent="\xD7";x.onclick=function(){if(bar.parentNode)bar.parentNode.removeChild(bar)};bar.appendChild(msg);bar.appendChild(go);bar.appendChild(x);document.body.appendChild(bar)}function _lmAssetSig(html){var out=[];var re=/<(?:script|link)\b[^>]*?\b(?:src|href)\s*=\s*["']([^"']+)["'][^>]*>/gi,m;while(m=re.exec(html||"")){var u=m[1];if(/^(?:https?:)?\/\//i.test(u)||/^(?:data|blob|mailto):/i.test(u))continue;if(/\.(?:js|mjs|css)(?:[?#]|$)/i.test(u))out.push(u)}var b=/<meta\b[^>]*name\s*=\s*["']lm-build["'][^>]*content\s*=\s*["']([^"']*)["']/i.exec(html||"")||/<meta\b[^>]*content\s*=\s*["']([^"']*)["'][^>]*name\s*=\s*["']lm-build["']/i.exec(html||"");if(b)out.push("lm-build="+b[1]);return out.sort().join("|")}var _lmBaseSig=null;function lmCheckForUpdate(){var opts=_lmUpdateOpts();if(!opts||!LM_BUILD||_lmUpdateShown||typeof fetch!=="function")return Promise.resolve(false);var url=opts.url||"/";return fetch(url+(url.indexOf("?")>-1?"&":"?")+"_v="+Date.now(),{cache:"no-store",credentials:"same-origin"}).then(function(r){return r.ok?r.text():""}).then(function(html){if(!html)return false;var m=/\/js\/app\.(\d+)\.js/.exec(html);var latest=m?parseInt(m[1],10):0;if(latest>LM_BUILD){_lmShowUpdateBar(opts,latest);return true}var sig=_lmAssetSig(html);if(_lmBaseSig===null)_lmBaseSig=sig;if(latest===LM_BUILD&&sig!==_lmBaseSig){_lmShowUpdateBar(opts,latest);return true}return false}).catch(function(){return false})}(function(){if(!LM_BUILD)return;document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")lmCheckForUpdate()});setTimeout(function(){lmCheckForUpdate();var o=_lmUpdateOpts();var every=o&&o.interval>0?o.interval:5*60*1e3;if(o)setInterval(lmCheckForUpdate,every)},15e3)})();
|
|
32
32
|
|
|
33
33
|
!(function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()})(this,function(){function a(b,c,d){function l(a2,b2){var c2=document.createEvent("CustomEvent");return c2.initCustomEvent(a2,false,false,b2),c2}var e={debug:false,automaticOpen:true,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1,timeoutInterval:3e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i2=false,j=false,k=document.createElement("div");k.addEventListener("open",function(a2){g.onopen(a2)}),k.addEventListener("close",function(a2){g.onclose(a2)}),k.addEventListener("connecting",function(a2){g.onconnecting(a2)}),k.addEventListener("message",function(a2){g.onmessage(a2)}),k.addEventListener("error",function(a2){g.onerror(a2)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b2){try{h=new WebSocket(g.url,c||[]),b2||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d2=h,e2=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=true,j=false;if(d2.readyState==1)d2.close()},g.timeoutInterval);h.onopen=function(){clearTimeout(e2),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d3=l("open");d3.isReconnect=b2,b2=false,k.dispatchEvent(d3)},h.onclose=function(c2){if(clearTimeout(e3),h=null,i2)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d3=l("connecting");d3.code=c2.code,d3.reason=c2.reason,d3.wasClean=c2.wasClean,k.dispatchEvent(d3),b2||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e3=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(true)},e3>g.maxReconnectInterval?g.maxReconnectInterval:e3)}},h.onmessage=function(b3){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b3.data);var c2=l("message");c2.data=b3.data,k.dispatchEvent(c2)},h.onerror=function(b3){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b3),k.dispatchEvent(l("error"))}}catch(error){console.error("WebSocket connection error:",error)}},1==this.automaticOpen&&this.open(false),this.send=function(b2){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b2),h.send(b2);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a2,b2){"undefined"==typeof a2&&(a2=1e3),i2=true,h&&h.close(a2,b2)},this.refresh=function(){h&&h.readyState==1&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=false,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a});let _isTipped=false;var _debugMode=false;var _initialized=null;var _dbcrs={};var _dbcrsTime=200;var _tickTime=20;var _scW=0;var cl=console.log;if(!_vcData)var _vcData=void 0;if(!_beaTn)var _beaTn=void 0;var beas;var appSettings;var execEl="";var currentlyValidTags=new Array;var _upwrk=new WebWorker("_upw");var _csswrk=new WebWorker("_cssw");_csswrk.start();var _ups=[];(function(e,t2){typeof module!="undefined"&&module.exports?module.exports=t2():typeof define=="function"&&define.amd?define(t2):this[e]=t2()})("bea",function(){function p(e2,t3){for(var n3=0,i3=e2.length;n3<i3;++n3)if(!t3(e2[n3]))return r2;return 1}function d(e2,t3){p(e2,function(e3){return t3(e3),1})}function v(e2,t3,n3){function g(e3){return e3.call?e3():u[e3]}function y(){if(!--h2){u[o2]=1,s2&&s2();for(var e3 in f)p(e3.split("|"),g)&&!d(f[e3],g)&&(f[e3]=[])}}e2=e2[i2]?e2:[e2];var r3=t3&&t3.call,s2=r3?t3:n3,o2=r3?e2.join(""):t3,h2=e2.length;return setTimeout(function(){d(e2,function t4(e3,n4){if(e3===null)return y();/*!n &&
|
|
34
34
|
!/^https?:\/\//.test(e) &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmjs/cli",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
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.6.
|
|
55
|
+
"@lmjs/core": "2.6.2"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=18.0.0"
|