@lmjs/cli 2.1.0 → 2.1.1
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/app.js +2 -2
- package/dist/lib/fcs.js +1 -1
- package/dist/lib/files/project/src/layouts/default.layout +14 -2
- package/dist/lib/files/project/src/views/about.view +24 -0
- package/dist/lib/files/project/src/views/home.view +27 -27
- package/dist/lib/files/project/src/views/widgets/footer.view +11 -0
- package/dist/lib/files/project/src/views/widgets/nav.view +9 -0
- package/package.json +2 -2
- package/dist/lib/files/libs/lm-with-plugins.js +0 -539
- package/dist/lib/files/libs/lumenjs-plugins.css +0 -2822
package/dist/lib/app.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var fs=require("fs");const path=require("path");const chokidar=require("chokidar");const express=require("express");var compression=require("compression");const app=express();const server=require("http").createServer(app);var WebSocketServer=require("ws").Server;var wss=new WebSocketServer({server,path:"/"});const fcs=require("./fcs.js");var cl=console.log;var cookieParser=require("cookie-parser");var expressSession=require("express-session");const bodyParser=require("body-parser");var multer=require("multer");var upload=multer();let session=expressSession({secret:"keyboardcat",resave:true,saveUninitialized:true,cookie:{maxAge:9999e3}});var config=fcs.getConfig();var _views={};var _layouts={};var _tpls={};function readTpls(){let dir=`${process.cwd()}`+path.sep+`src`+path.sep+`tpls`+path.sep;return fs.existsSync(dir)?fcs.getAllFiles(dir,{},false,true):{}}function readLayouts(){let dir=`${process.cwd()}`+path.sep+`src`+path.sep+`layouts`+path.sep;return fs.existsSync(dir)?fcs.annotateLayoutRegions(fcs.getAllFiles(dir,{},false,true)):{}}function readViews(){let dir=`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep;return fs.existsSync(dir)?fcs.getAllFiles(dir,{},false,true):{}}var _compiledScripts={};(function buildCompiledScriptsMap(){try{var projectRoot=`${process.cwd()}`;var srcRoot=projectRoot+path.sep+`src`;var hasOwnDeps=fcs.hasOwnDependencies(projectRoot);var indexJsPath=srcRoot+path.sep+"index.js";if(fs.existsSync(indexJsPath)){var indexJsSrc=hasOwnDeps?fcs.buildEntryWithImports(indexJsPath,projectRoot):fs.readFileSync(indexJsPath,"utf8");_compiledScripts["/index.js"]=fcs.compileProjectScript(indexJsSrc,"index")}var indexHtmlPath=srcRoot+path.sep+"index.html";if(fs.existsSync(indexHtmlPath)){var localSrcs=fcs.detectLocalProjectScripts(fs.readFileSync(indexHtmlPath,"utf8"));for(const src of localSrcs){var scriptPath=srcRoot+src.split("/").join(path.sep);if(fs.existsSync(scriptPath)){var scriptSrc=hasOwnDeps?fcs.buildEntryWithImports(scriptPath,projectRoot):fs.readFileSync(scriptPath,"utf8");_compiledScripts[src]=fcs.compileProjectScript(scriptSrc,src)}}}}catch(e){cl("Failed to compile index.js / project scripts for reactivity \u2014 serving them raw. "+e.message)}})();var _pluginsJs=null;var _pluginsCss=null;(async function buildSelectedPluginsBundle(){try{var projectRoot=`${process.cwd()}`;var selected=fcs.selectedProjectPlugins(projectRoot);if(!selected.length)return;var pluginsEsbuild=require(path.join(__dirname,"plugins-esbuild-plugin.js"));_pluginsJs=await pluginsEsbuild.buildSelectedPluginsBundle(selected,projectRoot);_pluginsCss=await pluginsEsbuild.buildSelectedCss(selected,projectRoot+path.sep+"node_modules");var indexHtmlPath=projectRoot+path.sep+"src"+path.sep+"index.html";if(fs.existsSync(indexHtmlPath)){var html5=fs.readFileSync(indexHtmlPath,"utf8");var tags="";if(html5.indexOf("/js/lumenjs-plugins.js")==-1){tags+=`
|
|
1
|
+
var fs=require("fs");const path=require("path");const chokidar=require("chokidar");const express=require("express");var compression=require("compression");const app=express();const server=require("http").createServer(app);var WebSocketServer=require("ws").Server;var wss=new WebSocketServer({server,path:"/"});const fcs=require("./fcs.js");var cl=console.log;var cookieParser=require("cookie-parser");var expressSession=require("express-session");const bodyParser=require("body-parser");var multer=require("multer");var upload=multer();let session=expressSession({secret:"keyboardcat",resave:true,saveUninitialized:true,cookie:{maxAge:9999e3}});var config=fcs.getConfig();var _views={};var _layouts={};var _tpls={};function readTpls(){let dir=`${process.cwd()}`+path.sep+`src`+path.sep+`tpls`+path.sep;return fs.existsSync(dir)?fcs.getAllFiles(dir,{},false,true):{}}function readLayouts(){let dir=`${process.cwd()}`+path.sep+`src`+path.sep+`layouts`+path.sep;return fs.existsSync(dir)?fcs.annotateLayoutRegions(fcs.getAllFiles(dir,{},false,true)):{}}function readViews(){let dir=`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep;return fs.existsSync(dir)?fcs.getAllFiles(dir,{},false,true):{}}var _compiledScripts={};(function buildCompiledScriptsMap(){try{var projectRoot=`${process.cwd()}`;var srcRoot=projectRoot+path.sep+`src`;var hasOwnDeps=fcs.hasOwnDependencies(projectRoot);var indexJsPath=srcRoot+path.sep+"index.js";if(fs.existsSync(indexJsPath)){var indexJsSrc=hasOwnDeps?fcs.buildEntryWithImports(indexJsPath,projectRoot):fs.readFileSync(indexJsPath,"utf8");_compiledScripts["/index.js"]=fcs.compileProjectScript(indexJsSrc,"index")}var indexHtmlPath=srcRoot+path.sep+"index.html";if(fs.existsSync(indexHtmlPath)){var localSrcs=fcs.detectLocalProjectScripts(fs.readFileSync(indexHtmlPath,"utf8"));for(const src of localSrcs){var scriptPath=srcRoot+src.split("/").join(path.sep);if(fs.existsSync(scriptPath)){var scriptSrc=hasOwnDeps?fcs.buildEntryWithImports(scriptPath,projectRoot):fs.readFileSync(scriptPath,"utf8");_compiledScripts[src]=fcs.compileProjectScript(scriptSrc,src)}}}}catch(e){cl("Failed to compile index.js / project scripts for reactivity \u2014 serving them raw. "+e.message)}})();var _pluginsJs=null;var _pluginsCss=null;var _pluginsBuildPromise=null;_pluginsBuildPromise=(async function buildSelectedPluginsBundle(){try{var projectRoot=`${process.cwd()}`;var selected=fcs.selectedProjectPlugins(projectRoot);if(!selected.length)return;var pluginsEsbuild=require(path.join(__dirname,"plugins-esbuild-plugin.js"));_pluginsJs=await pluginsEsbuild.buildSelectedPluginsBundle(selected,projectRoot);_pluginsCss=await pluginsEsbuild.buildSelectedCss(selected,projectRoot+path.sep+"node_modules");var indexHtmlPath=projectRoot+path.sep+"src"+path.sep+"index.html";if(fs.existsSync(indexHtmlPath)){var html5=fs.readFileSync(indexHtmlPath,"utf8");var tags="";if(html5.indexOf("/js/lumenjs-plugins.js")==-1){tags+=`
|
|
2
2
|
<script src="/js/lumenjs-plugins.js" type="text/javascript"><\/script>`}if(_pluginsCss&&_pluginsCss.trim()!=""&&html5.indexOf("/css/lumenjs-plugins.css")==-1){tags+=`
|
|
3
|
-
<link href="/css/lumenjs-plugins.css" rel="stylesheet" type="text/css" />`}if(tags!=""){fs.writeFileSync(indexHtmlPath,html5.split("</head>").join(tags+"\n</head>"))}}}catch(e){cl("Failed to build the selective plugins bundle \u2014 "+e.message)}})();app.use(compression());app.use(cookieParser());app.use(session);app.use("/",function(req,res,next){if(Object.prototype.hasOwnProperty.call(_compiledScripts,req.path)){res.type("application/javascript").send(_compiledScripts[req.path]);return}if(req.path==="/js/lumenjs-plugins.js"&&_pluginsJs!=null){res.type("application/javascript").send(_pluginsJs);return}if(req.path==="/css/lumenjs-plugins.css"&&_pluginsCss!=null){res.type("text/css").send(_pluginsCss);return}next()});app.use("/",express.static(`${process.cwd()}`+path.sep+`src`));app.set("etag",false);app.use(bodyParser.urlencoded({extended:true}));app.use(bodyParser.json());app.use(bodyParser.raw());app.use(upload.array());wss.on("connection",ws=>{ws.on("message",async message=>{try{const buffer=Buffer.from(message);const data=JSON.parse(buffer.toString());if(data.hasOwnProperty("e")){var _data={"e":data.e,"_iter":data._iter,"payload":{}};if(data.e=="getfiles"){_data["payload"]={"hstFormatVersion":fcs.HST_FORMAT_VERSION,"views":_views,"layouts":_layouts,"tpls":_tpls}}else if(data.e=="getlayout"){_data.payload=_layouts[data.payload]}else if(data.e=="getview"){_data.payload=_views[data.payload]}else if(data.e=="request"){try{let pata=data.payload;let __data=pata["data"];let _body=pata["body"];var resa=await API.req(_body["path"],__data,_body["headers"],_body["method"],_body["api"],true);let res=await resa.text();try{res=JSON.parse(res)}catch(e){}_data.payload=_body["full"]?{"headers":resa.headers,"data":res}:res;ws.send(JSON.stringify(_data))}catch(e){_data.payload={"code":108,"error":e.message,"type":"RequestError"};ws.send(JSON.stringify(_data))}return}ws.send(JSON.stringify(_data))}}catch(e){}})}).on("error",e=>{});global.app=app;var fetch=fcs.fetch;global.fetch=fetch;global.wss=wss;global.fs=fs;global.path=path;var API=fcs.API;global.API=API;if(fs.existsSync(`${process.cwd()}`+path.sep+`src`+path.sep+`app.js`)){require(`${process.cwd()}`+path.sep+`src`+path.sep+`app.js`)}app.get("*",function(req,res){let nodes=req.params[0].split("/");if(nodes.length)nodes.shift();res.sendFile(`${process.cwd()}`+path.sep+`src`+path.sep+(fs.existsSync(`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep+nodes[0]+`.view`)?"index":"404")+`.html`);return});app.post("*",function(req,res){let nodes=req.params[0].split("/");if(nodes.length)nodes.shift();res.sendFile(`${process.cwd()}`+path.sep+`src`+path.sep+(fs.existsSync(`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep+nodes[0]+`.view`)?"index":"404")+`.html`);return});function broadcastFilesChanged(){wss.clients.forEach(function(client){if(client.readyState===1){client.send(JSON.stringify({e:"files-changed"}))}})}chokidar.watch(`${process.cwd()}`+path.sep+`src`+path.sep+`views`,{ignoreInitial:true}).on("all",function(){_views=readViews();broadcastFilesChanged()});chokidar.watch(`${process.cwd()}`+path.sep+`src`+path.sep+`layouts`,{ignoreInitial:true}).on("all",function(){_layouts=readLayouts();broadcastFilesChanged()});chokidar.watch(`${process.cwd()}`+path.sep+`src`+path.sep+`tpls`,{ignoreInitial:true}).on("all",function(){_tpls=readTpls();broadcastFilesChanged()});server.listen(config.server.port>0?config.server.port:0,function(err){cl(`LumenJS server running at http://${config.server.host}:${config.server.port>0&&server.address().port==config.server.port?config.server.port:server.address().port}/`);config.server.port=server.address().port;_views=readViews();_layouts=readLayouts();_tpls=readTpls()}).on("error",e=>{if(e.code==="EADDRINUSE"){cl("Port "+config.server.port+" is already in use..");server.close();server.listen(0)}});
|
|
3
|
+
<link href="/css/lumenjs-plugins.css" rel="stylesheet" type="text/css" />`}if(tags!=""){fs.writeFileSync(indexHtmlPath,html5.split("</head>").join(tags+"\n</head>"))}}}catch(e){cl("Failed to build the selective plugins bundle \u2014 "+e.message)}})();app.use(compression());app.use(cookieParser());app.use(session);app.use("/",async function(req,res,next){if(Object.prototype.hasOwnProperty.call(_compiledScripts,req.path)){res.type("application/javascript").send(_compiledScripts[req.path]);return}if(req.path==="/js/lumenjs-plugins.js"||req.path==="/css/lumenjs-plugins.css"){if(_pluginsBuildPromise){try{await _pluginsBuildPromise}catch(e){}}if(req.path==="/js/lumenjs-plugins.js"&&_pluginsJs!=null){res.type("application/javascript").send(_pluginsJs);return}if(req.path==="/css/lumenjs-plugins.css"&&_pluginsCss!=null){res.type("text/css").send(_pluginsCss);return}}next()});app.use("/",express.static(`${process.cwd()}`+path.sep+`src`));app.set("etag",false);app.use(bodyParser.urlencoded({extended:true}));app.use(bodyParser.json());app.use(bodyParser.raw());app.use(upload.array());wss.on("connection",ws=>{ws.on("message",async message=>{try{const buffer=Buffer.from(message);const data=JSON.parse(buffer.toString());if(data.hasOwnProperty("e")){var _data={"e":data.e,"_iter":data._iter,"payload":{}};if(data.e=="getfiles"){_data["payload"]={"hstFormatVersion":fcs.HST_FORMAT_VERSION,"views":_views,"layouts":_layouts,"tpls":_tpls}}else if(data.e=="getlayout"){_data.payload=_layouts[data.payload]}else if(data.e=="getview"){_data.payload=_views[data.payload]}else if(data.e=="request"){try{let pata=data.payload;let __data=pata["data"];let _body=pata["body"];var resa=await API.req(_body["path"],__data,_body["headers"],_body["method"],_body["api"],true);let res=await resa.text();try{res=JSON.parse(res)}catch(e){}_data.payload=_body["full"]?{"headers":resa.headers,"data":res}:res;ws.send(JSON.stringify(_data))}catch(e){_data.payload={"code":108,"error":e.message,"type":"RequestError"};ws.send(JSON.stringify(_data))}return}ws.send(JSON.stringify(_data))}}catch(e){}})}).on("error",e=>{});global.app=app;var fetch=fcs.fetch;global.fetch=fetch;global.wss=wss;global.fs=fs;global.path=path;var API=fcs.API;global.API=API;if(fs.existsSync(`${process.cwd()}`+path.sep+`src`+path.sep+`app.js`)){require(`${process.cwd()}`+path.sep+`src`+path.sep+`app.js`)}app.get("*",function(req,res){let nodes=req.params[0].split("/");if(nodes.length)nodes.shift();res.sendFile(`${process.cwd()}`+path.sep+`src`+path.sep+(fs.existsSync(`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep+nodes[0]+`.view`)?"index":"404")+`.html`);return});app.post("*",function(req,res){let nodes=req.params[0].split("/");if(nodes.length)nodes.shift();res.sendFile(`${process.cwd()}`+path.sep+`src`+path.sep+(fs.existsSync(`${process.cwd()}`+path.sep+`src`+path.sep+`views`+path.sep+nodes[0]+`.view`)?"index":"404")+`.html`);return});function broadcastFilesChanged(){wss.clients.forEach(function(client){if(client.readyState===1){client.send(JSON.stringify({e:"files-changed"}))}})}chokidar.watch(`${process.cwd()}`+path.sep+`src`+path.sep+`views`,{ignoreInitial:true}).on("all",function(){_views=readViews();broadcastFilesChanged()});chokidar.watch(`${process.cwd()}`+path.sep+`src`+path.sep+`layouts`,{ignoreInitial:true}).on("all",function(){_layouts=readLayouts();broadcastFilesChanged()});chokidar.watch(`${process.cwd()}`+path.sep+`src`+path.sep+`tpls`,{ignoreInitial:true}).on("all",function(){_tpls=readTpls();broadcastFilesChanged()});server.listen(config.server.port>0?config.server.port:0,function(err){cl(`LumenJS server running at http://${config.server.host}:${config.server.port>0&&server.address().port==config.server.port?config.server.port:server.address().port}/`);config.server.port=server.address().port;_views=readViews();_layouts=readLayouts();_tpls=readTpls()}).on("error",e=>{if(e.code==="EADDRINUSE"){cl("Port "+config.server.port+" is already in use..");server.close();server.listen(0)}});
|
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");var _min=require("html-minifier").minify;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{const pkgPath=path.join(projectRoot,"package.json");if(!fs.existsSync(pkgPath))return[];const pkg=JSON.parse(fs.readFileSync(pkgPath,"utf8"));if(!pkg.dependencies)return[];return _pluginsBundle.selectedRegistryEntries(pkg.dependencies)}catch(e){return[]}}exports.selectedProjectPlugins=selectedProjectPlugins;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 detectLocalProjectScripts(indexHtmlSource){let found=[];let re=/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi;let m;while(m=re.exec(indexHtmlSource)){let src=m[1];if(src.indexOf("/")!==0)continue;if(src==="/js/lm.js"||src==="/index.js")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=1;exports.HST_FORMAT_VERSION=HST_FORMAT_VERSION;exports.getAllFiles=getAllFiles;exports.validateTplsAreHtmlOnly=validateTplsAreHtmlOnly;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 applyWithPlugins(filePath,libsPath){let pluginsJsSrc=libsPath+path.sep+"lm-with-plugins.js";let pluginsCssSrc=libsPath+path.sep+"lumenjs-plugins.css";if(!fs.existsSync(pluginsJsSrc)||!fs.existsSync(pluginsCssSrc)){console.log("--with-plugins was requested, but "+pluginsJsSrc+" / "+pluginsCssSrc+" aren't present in this CLI install \u2014 falling back to the default (no-plugins) build. Run the with-plugins build in packages/core first.");return}fs.writeFileSync(filePath+path.sep+"src"+path.sep+"js"+path.sep+"lm.js",fs.readFileSync(pluginsJsSrc));fs.writeFileSync(filePath+path.sep+"src"+path.sep+"css"+path.sep+"lumenjs-plugins.css",fs.readFileSync(pluginsCssSrc));let indexHtmlPath=filePath+path.sep+"src"+path.sep+"index.html";if(fs.existsSync(indexHtmlPath)){let html5=fs.readFileSync(indexHtmlPath,"utf8");if(html5.indexOf("lumenjs-plugins.css")==-1){html5=html5.replace('<link href="/css/styles.css" rel="stylesheet" type="text/css" />','<link href="/css/styles.css" rel="stylesheet" type="text/css" />\n <link href="/css/lumenjs-plugins.css" rel="stylesheet" type="text/css" />');fs.writeFileSync(indexHtmlPath,html5)}}}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));if(conf.withPlugins)applyWithPlugins(filePath3,libsPath2)})}).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));if(conf.withPlugins)applyWithPlugins(filePath2,libsPath)}})}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 validateTplsAreHtmlOnly(tpls){function scan(nodes,fileKey){if(!Array.isArray(nodes))return;for(const node of nodes){if(!node)continue;if(node.type==="tag"&&node.name){let n=node.name.toLowerCase();if(n==="script"||n==="js"||n==="style"){let name=Buffer.from(fileKey,"base64").toString("utf8");throw new Error('tpls/*.tpl files are HTML-only \u2014 "'+name+'" has a <'+node.name+"> block. Templates render inside whatever scope they're used from (a :for item's own), not an isolated one, so they can't carry their own script/style. Use a view= subview instead if this needs its own state or styling.")}}if(node.children)scan(node.children,fileKey)}}for(const fileKey in tpls){if(Object.prototype.hasOwnProperty.call(tpls,fileKey)){scan(tpls[fileKey].hst,fileKey)}}}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?(".*?"|'.*?')/g;tagRE=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;whitespaceRE=/^\s*$/;empty=Object.create(null);reactiveVariables=[];constructor(html){let hst2=this.parse(html);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);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);this.reactiveVariables.push(res.forX.js)}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);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}}}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,"jst":JST,"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"?{jst:acorn.parse(hl,{ecmaVersion:"latest"})}:{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);if(par.whitespaceRE.test(content)){content=" "}if(_end>-1&&level+parent.length>=0||content!==" "){if(parent&&Array.isArray(parent)){if(content!==" "){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);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;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 withPlugins=process.argv.includes("--with-plugins");let c=process.argv.slice(3,process.argv.length).filter(a=>a!="--with-plugins");let t=lw(c[0]);create({type:t[0]=="-"?t.split("-").join(""):t,name:t[0]=="-"?c.slice(1,c.length):c,withPlugins})}else if(command=="purge"){import("ora").then(async({default:ora,oraPromise})=>{const spinner=ora({color:"green"});spinner.start("Purging..");try{const corejsRes=await API.req(CORE_Libs.COREJS,{},void 0,"GET",void 0,true);if(!corejsRes.ok)throw new Error("fetching core JS failed: HTTP "+corejsRes.status);const corejs=await corejsRes.text();if(!corejs||corejs.length<1e3||/^\s*<(!doctype|html)/i.test(corejs)){throw new Error("fetched core JS doesn't look valid ("+(corejs?corejs.length:0)+" bytes, possibly an error page) \u2014 refusing to overwrite the real bundle")}spinner.start("Gathering Resources..");const mobiuscssRes=await API.req(CORE_Libs.BEACSS,{},void 0,"GET",void 0,true);if(!mobiuscssRes.ok)throw new Error("fetching core CSS failed: HTTP "+mobiuscssRes.status);const mobiuscss=await mobiuscssRes.text();if(mobiuscss==null||/^\s*<(!doctype|html)/i.test(mobiuscss)){throw new Error("fetched core CSS doesn't look valid \u2014 refusing to overwrite")}spinner.start("Writing Files...");var filePath=`${process.cwd()}`;var libsPath=`${__dirname}`+path.sep+`files`+path.sep+`libs`;cd(libsPath);fs.writeFileSync(libsPath+path.sep+"lm.js",String(corejs));fs.writeFileSync(libsPath+path.sep+"mobius.css",String(mobiuscss));fs.writeFileSync(filePath+path.sep+"src"+path.sep+"js"+path.sep+"lm.js",String(corejs));fs.writeFileSync(filePath+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css",String(mobiuscss));spinner.succeed("Successfully Purged!")}catch(err){spinner.fail("Purge Failed! "+(err&&err.message?err.message:""))}})}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()}`;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 _tplsDir=`${process.cwd()}`+path.sep+`src`+path.sep+`tpls`+path.sep;let _tpls=fs.existsSync(_tplsDir)?getAllFiles(_tplsDir,{},false,true):{};validateTplsAreHtmlOnly(_tpls);var indexCode=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"index.html","utf8");var beaCSSCode=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"css"+path.sep+"mobius.css","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 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");var _min=require("html-minifier").minify;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{const pkgPath=path.join(projectRoot,"package.json");if(!fs.existsSync(pkgPath))return[];const pkg=JSON.parse(fs.readFileSync(pkgPath,"utf8"));if(!pkg.dependencies)return[];return _pluginsBundle.selectedRegistryEntries(pkg.dependencies)}catch(e){return[]}}exports.selectedProjectPlugins=selectedProjectPlugins;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 detectLocalProjectScripts(indexHtmlSource){let found=[];let re=/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi;let m;while(m=re.exec(indexHtmlSource)){let src=m[1];if(src.indexOf("/")!==0)continue;if(src==="/js/lm.js"||src==="/index.js")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=1;exports.HST_FORMAT_VERSION=HST_FORMAT_VERSION;exports.getAllFiles=getAllFiles;exports.validateTplsAreHtmlOnly=validateTplsAreHtmlOnly;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 validateTplsAreHtmlOnly(tpls){function scan(nodes,fileKey){if(!Array.isArray(nodes))return;for(const node of nodes){if(!node)continue;if(node.type==="tag"&&node.name){let n=node.name.toLowerCase();if(n==="script"||n==="js"||n==="style"){let name=Buffer.from(fileKey,"base64").toString("utf8");throw new Error('tpls/*.tpl files are HTML-only \u2014 "'+name+'" has a <'+node.name+"> block. Templates render inside whatever scope they're used from (a :for item's own), not an isolated one, so they can't carry their own script/style. Use a view= subview instead if this needs its own state or styling.")}}if(node.children)scan(node.children,fileKey)}}for(const fileKey in tpls){if(Object.prototype.hasOwnProperty.call(tpls,fileKey)){scan(tpls[fileKey].hst,fileKey)}}}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?(".*?"|'.*?')/g;tagRE=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;whitespaceRE=/^\s*$/;empty=Object.create(null);reactiveVariables=[];constructor(html){let hst2=this.parse(html);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);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);this.reactiveVariables.push(res.forX.js)}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);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}}}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,"jst":JST,"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"?{jst:acorn.parse(hl,{ecmaVersion:"latest"})}:{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);if(par.whitespaceRE.test(content)){content=" "}if(_end>-1&&level+parent.length>=0||content!==" "){if(parent&&Array.isArray(parent)){if(content!==" "){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);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;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=="purge"){import("ora").then(async({default:ora,oraPromise})=>{const spinner=ora({color:"green"});spinner.start("Purging..");try{const corejsRes=await API.req(CORE_Libs.COREJS,{},void 0,"GET",void 0,true);if(!corejsRes.ok)throw new Error("fetching core JS failed: HTTP "+corejsRes.status);const corejs=await corejsRes.text();if(!corejs||corejs.length<1e3||/^\s*<(!doctype|html)/i.test(corejs)){throw new Error("fetched core JS doesn't look valid ("+(corejs?corejs.length:0)+" bytes, possibly an error page) \u2014 refusing to overwrite the real bundle")}spinner.start("Gathering Resources..");const mobiuscssRes=await API.req(CORE_Libs.BEACSS,{},void 0,"GET",void 0,true);if(!mobiuscssRes.ok)throw new Error("fetching core CSS failed: HTTP "+mobiuscssRes.status);const mobiuscss=await mobiuscssRes.text();if(mobiuscss==null||/^\s*<(!doctype|html)/i.test(mobiuscss)){throw new Error("fetched core CSS doesn't look valid \u2014 refusing to overwrite")}spinner.start("Writing Files...");var filePath=`${process.cwd()}`;var libsPath=`${__dirname}`+path.sep+`files`+path.sep+`libs`;cd(libsPath);fs.writeFileSync(libsPath+path.sep+"lm.js",String(corejs));fs.writeFileSync(libsPath+path.sep+"mobius.css",String(mobiuscss));fs.writeFileSync(filePath+path.sep+"src"+path.sep+"js"+path.sep+"lm.js",String(corejs));fs.writeFileSync(filePath+path.sep+"src"+path.sep+"css"+path.sep+"mobius.css",String(mobiuscss));spinner.succeed("Successfully Purged!")}catch(err){spinner.fail("Purge Failed! "+(err&&err.message?err.message:""))}})}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()}`;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 _tplsDir=`${process.cwd()}`+path.sep+`src`+path.sep+`tpls`+path.sep;let _tpls=fs.existsSync(_tplsDir)?getAllFiles(_tplsDir,{},false,true):{};validateTplsAreHtmlOnly(_tpls);var indexCode=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"index.html","utf8");var beaCSSCode=fs.readFileSync(projectPath+path.sep+`src`+path.sep+"css"+path.sep+"mobius.css","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 vt=`
|
|
2
2
|
var _vcData = {
|
|
3
3
|
"hstFormatVersion": `+HST_FORMAT_VERSION+`,
|
|
4
4
|
"views": `+JSON.stringify(_views)+`,
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
<
|
|
1
|
+
<style>
|
|
2
|
+
body {
|
|
3
|
+
margin: 0;
|
|
4
|
+
color: rgba(255, 255, 255, .87);
|
|
5
|
+
background-color: #181818;
|
|
6
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
a {
|
|
10
|
+
color: inherit;
|
|
11
|
+
}
|
|
12
|
+
</style>
|
|
13
|
+
|
|
2
14
|
<nav nav></nav>
|
|
3
15
|
<main body></main>
|
|
4
|
-
<footer footer></footer>
|
|
16
|
+
<footer footer></footer>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<div style="max-width:640px;margin:0 auto;padding:80px 24px 40px;">
|
|
2
|
+
<h1 class="cw" style="font-size:32px;margin:0 0 16px;">About this project</h1>
|
|
3
|
+
<p class="fs15" style="opacity:.75;line-height:1.6;">
|
|
4
|
+
This project was scaffolded with <code>lm create</code>. The navigation bar and
|
|
5
|
+
footer you're looking at right now are LumenJS <strong>widgets</strong> — real
|
|
6
|
+
files under <code>src/views/widgets/</code>, wired into
|
|
7
|
+
<code>src/layouts/default.layout</code>. Unlike this page's own content, they
|
|
8
|
+
don't re-render when you navigate between pages.
|
|
9
|
+
</p>
|
|
10
|
+
<p class="fs15" style="opacity:.75;line-height:1.6;">
|
|
11
|
+
Add more pages under <code>src/views/</code>, more widgets under
|
|
12
|
+
<code>src/views/widgets/</code>, and point any layout element at one by giving it
|
|
13
|
+
a bare attribute matching the widget's name — LumenJS mounts and keeps it
|
|
14
|
+
persistent automatically.
|
|
15
|
+
</p>
|
|
16
|
+
<a href="/" class="cw fs14" style="opacity:.85;">Back home</a>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<settings>
|
|
20
|
+
{
|
|
21
|
+
layout: 'default',
|
|
22
|
+
requireAuth: false
|
|
23
|
+
}
|
|
24
|
+
</settings>
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
</
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</
|
|
1
|
+
<div style="max-width:720px;margin:0 auto;padding:80px 24px 40px;text-align:center;">
|
|
2
|
+
<img src="/images/lumenjs.svg" alt="LumenJS" style="width:96px;height:96px;margin-bottom:24px;" />
|
|
3
|
+
<h1 class="cw" style="font-size:40px;margin:0 0 12px;">Welcome to LumenJS</h1>
|
|
4
|
+
<p class="fs16" style="opacity:.75;margin:0 0 32px;">
|
|
5
|
+
A tiny, fast reactive framework for building web apps with plain HTML, CSS and JavaScript.
|
|
6
|
+
</p>
|
|
7
|
+
<a href="https://www.lumenjs.com/guide/getting-started" class="cw fs15" style="display:inline-block;padding:12px 28px;background:#FFA302;color:#181818;border-radius:6px;text-decoration:none;font-weight:600;">
|
|
8
|
+
Read the Docs
|
|
9
|
+
</a>
|
|
10
|
+
|
|
11
|
+
<div style="display:flex;gap:20px;justify-content:center;margin-top:60px;flex-wrap:wrap;">
|
|
12
|
+
<div style="flex:1;min-width:180px;max-width:220px;padding:20px;background:#1f1f1f;border-radius:8px;text-align:left;">
|
|
13
|
+
<div class="cw fs15" style="font-weight:600;margin-bottom:6px;">Reactive by default</div>
|
|
14
|
+
<div class="fs13" style="opacity:.65;">Mustaches and directives update automatically when your data changes.</div>
|
|
15
|
+
</div>
|
|
16
|
+
<div style="flex:1;min-width:180px;max-width:220px;padding:20px;background:#1f1f1f;border-radius:8px;text-align:left;">
|
|
17
|
+
<div class="cw fs15" style="font-weight:600;margin-bottom:6px;">Widgets & layouts</div>
|
|
18
|
+
<div class="fs13" style="opacity:.65;">The nav and footer on this page persist across navigation — try the About link.</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div style="flex:1;min-width:180px;max-width:220px;padding:20px;background:#1f1f1f;border-radius:8px;text-align:left;">
|
|
21
|
+
<div class="cw fs15" style="font-weight:600;margin-bottom:6px;">Just HTML & JS</div>
|
|
22
|
+
<div class="fs13" style="opacity:.65;">No build step to learn — write real HTML, CSS and JavaScript.</div>
|
|
22
23
|
</div>
|
|
23
24
|
</div>
|
|
24
|
-
<div class="cc sq cov" style="background-image: url('/images/lumenjs.svg'); height: 250px;"></div>
|
|
25
25
|
</div>
|
|
26
26
|
|
|
27
27
|
<settings>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</settings>
|
|
28
|
+
{
|
|
29
|
+
layout: 'default',
|
|
30
|
+
requireAuth: false
|
|
31
|
+
}
|
|
32
|
+
</settings>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<div style="display:flex;align-items:center;justify-content:space-between;padding:20px 30px;background:#1a1a1a;margin-top:40px;flex-wrap:wrap;gap:10px;">
|
|
2
|
+
<span class="fs13" style="opacity:.6;">Built with LumenJS</span>
|
|
3
|
+
<div style="display:flex;align-items:center;gap:16px;">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@lmjs/cli" style="opacity:.7;">
|
|
5
|
+
<span data-icon="mdi:npm" class="iconify cw fs20"></span>
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://github.com/bea-technology/lmjs-cli" style="opacity:.7;">
|
|
8
|
+
<span data-icon="mdi:github" class="iconify cw fs20"></span>
|
|
9
|
+
</a>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div style="display:flex;align-items:center;justify-content:space-between;padding:14px 30px;background:#1f1f1f;box-shadow:0 1px 0 rgba(255,255,255,.06);">
|
|
2
|
+
<a href="/" style="display:flex;align-items:center;gap:8px;text-decoration:none;">
|
|
3
|
+
<strong class="cw fs18">LumenJS</strong>
|
|
4
|
+
</a>
|
|
5
|
+
<div style="display:flex;align-items:center;gap:24px;">
|
|
6
|
+
<a href="/" class="cw fs14" style="text-decoration:none;opacity:.85;">Home</a>
|
|
7
|
+
<a href="/about" class="cw fs14" style="text-decoration:none;opacity:.85;">About</a>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmjs/cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
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",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"ora": "^6.1.2",
|
|
52
52
|
"semver": "^7.3.7",
|
|
53
53
|
"ws": "^8.8.1",
|
|
54
|
-
"@lmjs/core": "2.1.
|
|
54
|
+
"@lmjs/core": "2.1.1"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.0.0"
|