jetc 0.6.5 → 0.7.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/bin/run.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ const a=require("fs"),d=require("path"),{parse:e}=require("jeti"),f=d.join(process.cwd(),process.argv[2]);function g(){var b=null;try{let c=a.readFileSync(f,"utf8"),h="(function() {\nconst module = {exports: {}};\nlet exports = module.exports;\n"+e(c)+"\nreturn module.exports;\n})()";b=eval(h)}catch(c){console.error(c),process.exit(1)}return b&&b.default||b}require.main===module&&(f&&a.existsSync(f)?g()():console.error("Error:",f,"not found."));
package/bin/server.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';function l(a){return n.existsSync(a)&&n.statSync(a).isDirectory()}function r(a){return n.existsSync(a)&&n.statSync(a).isFile()}function t(...a){a=a.join("/").split("/");let c=a.length;for(let b=1;b<c;b++)0<b&&b<c-1&&!a[b]?(a.splice(b,1),--c,--b):0<b&&"."===a[b]?(a.splice(b,1),--c,--b):1===b&&".."===a[b]&&"."===a[b-1]?(a.splice(b-1,1),--c,--b):0<b&&".."===a[b]&&"."!==a[b-1]&&".."!==a[b-1]&&(a.splice(b-1,2),c-=2,b-=2);return a.join("/")}
3
- function u(a,c){try{return require.resolve(a,c).replace(/\\/g,"/")}catch(b){}return null}function v(a,c){return"\u001b["+a+"m"+c+"\u001b[39m"}function w(){return v(90,"["+(new Date).toLocaleString("en-US")+"]")}function z(a){return(a=B(a))?{"Content-Type":a}:null}
4
- function B(a){a=a.split("/");var c=a[a.length-1].split(".");a={css:"text/css",csv:"text/csv",eot:"application/vnd.ms-fontobject",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",otf:"font/otf",pdf:"application/pdf",png:"image/png",svg:"image/svg+xml",tif:"image/tiff",tiff:"image/tiff",ttf:"font/ttf",txt:"text/plain",woff:"font/woff",woff2:"font/woff2",xml:"text/xml"};return 1<c.length&&
5
- (c=c[c.length-1],a[c])?a[c]:null}const n=require("fs"),C=require("http");function D(){var a=process.argv;let c=!1,b="",f=3E3;const e=a.length;for(let k=2;k<e;k++){const d=a[k];d.startsWith("--port=")?f=parseInt(d.slice(7),10):d.startsWith("--all=")?c=d.slice(6):"--all"===d?c="/index.html":k===e-1&&(b=d)}return{a:c,folder:b,port:f}}function E(a,c){a=a.headers.accept;let b=!0;if(a){const f=B(c);b=!1;a.split(",").forEach(e=>{e=e.split(";")[0].trim();if(e===f||"*/*"===e)b=!0})}return b}
6
- function F(a){let c="";a=a.split("/").map(f=>{f=c+f;c=f+"/";return[f,f+"/node_modules"]}).reverse();const b=a.length;for(let f=0;f<b;f++)if(l(a[f][1]))return a[f][0];return null}
7
- function G(){const {a,folder:c,port:b}=D(),f=C.createServer((e,k)=>{{var d=e.url.split("?")[0];var g=process.cwd().replace(/\\/g,"/");var m=c?t(g,c):g,p=t(m,a);const q=t(m,d),A=t(q,"index.html");var h="";g="";if(r(q))h=q,g=d;else if(r(A))h=A,g=t(d,"index.html");else if(0===d.indexOf("/node_modules/")){if(d=d.split("/node_modules/"),p=F(m),m=d.pop(),p&&m&&(h=t(p,d.join("/node_modules/")),h=u(m,{paths:[h]})))d=h.split("/node_modules/"),d[0]="",g=d.join("/node_modules/")}else"/"!==d&&(h=u(t(".",d),{paths:[m]}))&&
8
- (g=h.slice(m.length)),h||(h=u(d.slice(1),{paths:[m]}))&&(g=t("/node_modules/",h.split("/node_modules/").pop())),h||!a||1<d.split("/").pop().split(".").length||!r(p)||(h=p,g=t(a));g={filename:h,location:g}}const {filename:x,location:y}=g;g="";if(x&&E(e,x)){try{g=n.readFileSync(x,"binary")}catch(q){g=q;e=e.url;k.writeHead(500,z(".txt"));k.write("500 Internal Server Error\n");k.end();console.log(w(),'"GET '+e+'" '+v(31,500)+" "+g);return}e=e.url;h=Object.assign({},{Location:y},z(y),{"Cache-Control":"max-age=0, no-cache, must-revalidate, proxy-revalidate",
9
- Expires:"Thu, 01 Jan 1970 00:00:00 GMT","Last-Modified":(new Date).toUTCString()});k.writeHead(200,h);k.write(g,"binary");k.end();console.log(w(),'"GET '+e+'" 200 '+g.length+" "+y)}else e=e.url,k.writeHead(404,z(".txt")),k.write("404 Not Found\n"),k.end(),console.log(w(),'"GET '+e+'" '+v(31,404))});f.on("error",e=>console.error(e));f.listen(b,"localhost");console.log("Development server is running at http://localhost:"+b+"/\nPress Ctrl + C to shutdown.\n")}require.main===module&&G();
2
+ function l(a){return n.existsSync(a)&&n.statSync(a).isDirectory()}function q(a){return n.existsSync(a)&&n.statSync(a).isFile()}function r(...a){a=a.join("/").split("/");var c=a.length;for(let b=1;b<c;b++)b>0&&b<c-1&&!a[b]?(a.splice(b,1),--c,--b):b>0&&a[b]==="."?(a.splice(b,1),--c,--b):b===1&&a[b]===".."&&a[b-1]==="."?(a.splice(b-1,1),--c,--b):b>0&&a[b]===".."&&a[b-1]!=="."&&a[b-1]!==".."&&(a.splice(b-1,2),c-=2,b-=2);return a.join("/")}
3
+ function t(a,c){try{return require.resolve(a,c).replace(/\\/g,"/")}catch(b){}return null}function u(a,c){return"\u001b["+a+"m"+c+"\u001b[39m"}function v(){return u(90,"["+(new Date).toLocaleString("en-US")+"]")}function z(a){return(a=B(a))?{"Content-Type":a}:null}
4
+ function B(a){a=a.split("/");var c=a[a.length-1].split(".");a={css:"text/css",csv:"text/csv",eot:"application/vnd.ms-fontobject",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",otf:"font/otf",pdf:"application/pdf",png:"image/png",svg:"image/svg+xml",tif:"image/tiff",tiff:"image/tiff",ttf:"font/ttf",txt:"text/plain",woff:"font/woff",woff2:"font/woff2",xml:"text/xml"};return c.length>
5
+ 1&&(c=c[c.length-1],a[c])?a[c]:null}const n=require("fs"),C=require("http");function D(){var a=process.argv,c=!1,b="",f=3E3,e=a.length;for(let k=2;k<e;k++){let d=a[k];d.startsWith("--port=")?f=parseInt(d.slice(7),10):d.startsWith("--all=")?c=d.slice(6):d==="--all"?c="/index.html":k===e-1&&(b=d)}return{g:c,folder:b,port:f}}function E(a,c){a=a.headers.accept;var b=!0;if(a){let f=B(c);b=!1;a.split(",").forEach(e=>{e=e.split(";")[0].trim();if(e===f||e==="*/*")b=!0})}return b}
6
+ function F(a){var c="";a=a.split("/").map(f=>{f=c+f;c=f+"/";return[f,f+"/node_modules"]}).reverse();var b=a.length;for(let f=0;f<b;f++)if(l(a[f][1]))return a[f][0];return null}
7
+ function G(){var {g:a,folder:c,port:b}=D(),f=C.createServer((e,k)=>{var d=e.url.split("?")[0],g=process.cwd().replace(/\\/g,"/"),m=c?r(g,c):g,p=r(m,a),w=r(m,d),A=r(w,"index.html"),h="";g="";if(q(w))h=w,g=d;else if(q(A))h=A,g=r(d,"index.html");else if(d.indexOf("/node_modules/")===0){if(d=d.split("/node_modules/"),p=F(m),m=d.pop(),p&&m&&(h=r(p,d.join("/node_modules/")),h=t(m,{paths:[h]})))d=h.split("/node_modules/"),d[0]="",g=d.join("/node_modules/")}else d!=="/"&&(h=t(r(".",d),{paths:[m]}))&&(g=h.slice(m.length)),
8
+ h||(h=t(d.slice(1),{paths:[m]}))&&(g=r("/node_modules/",h.split("/node_modules/").pop())),h||!a||d.split("/").pop().split(".").length>1||!q(p)||(h=p,g=r(a));var {filename:x,location:y}={filename:h,location:g};g="";if(x&&E(e,x)){try{g=n.readFileSync(x,"binary")}catch(H){g=H;e=e.url;k.writeHead(500,z(".txt"));k.write("500 Internal Server Error\n");k.end();console.log(v(),'"GET '+e+'" '+u(31,500)+" "+g);return}e=e.url;h=Object.assign({},{Location:y},z(y),{"Cache-Control":"max-age=0, no-cache, must-revalidate, proxy-revalidate",
9
+ Expires:"Thu, 01 Jan 1970 00:00:00 GMT","Last-Modified":(new Date).toUTCString()});k.writeHead(200,h);k.write(g,"binary");k.end();console.log(v(),'"GET '+e+'" 200 '+g.length+" "+y)}else e=e.url,k.writeHead(404,z(".txt")),k.write("404 Not Found\n"),k.end(),console.log(v(),'"GET '+e+'" '+u(31,404))});f.on("error",e=>console.error(e));f.listen(b,"localhost");console.log("Development server is running at http://localhost:"+b+"/\nPress Ctrl + C to shutdown.\n")}require.main===module&&G();
package/index.js CHANGED
@@ -1,27 +1,28 @@
1
- 'use strict';const q=require("fs"),{closeContext:r,getContext:t,openContext:u,parser:v}=require("jeti");function w(a){return q.existsSync(a)&&q.statSync(a).isDirectory()}function x(a){return q.existsSync(a)&&q.statSync(a).isFile()}function y(a,b,c,d){let e;for(let f=1;e=b+(1<f?f:"")+"."+c,q.existsSync(z(a,e))||-1!==(d||[]).indexOf(e);f++);return e}
2
- function z(...a){a=a.join("/").split("/");let b=a.length;for(let c=1;c<b;c++)0<c&&c<b-1&&!a[c]?(a.splice(c,1),--b,--c):0<c&&"."===a[c]?(a.splice(c,1),--b,--c):1===c&&".."===a[c]&&"."===a[c-1]?(a.splice(c-1,1),--b,--c):0<c&&".."===a[c]&&"."!==a[c-1]&&".."!==a[c-1]&&(a.splice(c-1,2),b-=2,c-=2);return a.join("/")}function A(a,b){try{return require.resolve(a,b).replace(/\\/g,"/")}catch(c){}return null}function B(a){return 0<a.b.length&&""===a.b[0]}
3
- class C{constructor(a){this.path=a;this.b=this.path.split("/");this.filename=this.b.pop();this.folder=this.b.join("/");this.ext=this.name=null;a=this.filename.split(".");this.ext=1<a.length&&(a[0]||2<a.length)?a.pop():"";this.name=a.join(".")}a(){return{css:"text/css",htm:"text/html",html:"text/html",js:"application/javascript",json:"application/json",scss:"text/scss",txt:"text/plain",xml:"text/xml"}[this.ext]||""}toString(){return this.path}}
4
- function D(a,b,c){({name:b}=new C(b));a=y(a,b,"css");b=z(".",a);c.name=b;return{href:a,filename:b}}function E(a){return a&&"'jet module';"===a.slice(0,13)}function F(a){return"application/javascript"===a}
1
+ const q=require("fs"),{closeContext:r,getContext:t,openContext:u,transpile:v}=require("jeti");function w(a){return q.existsSync(a)&&q.statSync(a).isDirectory()}function x(a){return q.existsSync(a)&&q.statSync(a).isFile()}function y(a,b,c,d){for(let f=1;;f++){var e=b+(f>1?f:"")+"."+c;if(!q.existsSync(z(a,e))&&(d||[]).indexOf(e)===-1)break}return e}
2
+ function z(...a){a=a.join("/").split("/");var b=a.length;for(let c=1;c<b;c++)c>0&&c<b-1&&!a[c]?(a.splice(c,1),--b,--c):c>0&&a[c]==="."?(a.splice(c,1),--b,--c):c===1&&a[c]===".."&&a[c-1]==="."?(a.splice(c-1,1),--b,--c):c>0&&a[c]===".."&&a[c-1]!=="."&&a[c-1]!==".."&&(a.splice(c-1,2),b-=2,c-=2);return a.join("/")}function A(a,b){try{return require.resolve(a,b).replace(/\\/g,"/")}catch(c){}return null}function B(a){return a.g.length>0&&a.g[0]===""}
3
+ class C{constructor(a){this.path=a;this.g=this.path.split("/");this.filename=this.g.pop();this.folder=this.g.join("/");this.ext=this.name=null;a=this.filename.split(".");this.ext=a.length>1&&(a[0]||a.length>2)?a.pop():"";this.name=a.join(".")}mediaType(){return{css:"text/css",htm:"text/html",html:"text/html",js:"application/javascript",json:"application/json",scss:"text/scss",txt:"text/plain",xml:"text/xml"}[this.ext]||""}toString(){return this.path}}
4
+ function D(a,b,c){({name:b}=new C(b));a=y(a,b,"css");b=z(".",a);c.name=b;return{href:a,filename:b}}function E(a){return a&&a.slice(0,13)==="'jet module';"}function F(a){return a==="application/javascript"}
5
5
  var G={"single-comment":"slash slash *!end-line end-line","multi-comment":"slash star *!(star slash) star slash",comment:"single-comment | multi-comment"},H={space:"+(whitespace | comment)"},I={"single-string":"single-quote *((escape any) | !single-quote) single-quote"},J={"double-string":"double-quote *((escape any) | !double-quote) double-quote"},K={"back-string":"back-quote *((escape any) | (dollar context) | !back-quote) back-quote"};
6
6
  const L={...G,...H,...I,...J,...K,string:"single-string | double-string | back-string",identifier:"letter *(letter | digit)",number:"digit *(digit | e | x)",operator:"+symbol",context:"lbrace *(code | !rbrace) rbrace",expression:"lparen *(code | !rparen) rparen",selector:"lbracket *(code | !rbracket) rbracket",bracket:"lbrace | rbrace | lparen | rparen | lbracket | rbracket","extended-symbol":"symbol | punctuation | bracket",delimiter:"extended-symbol | string",compress:"*space delimiter *space",
7
7
  code:"compress | space | identifier | number | string | context | expression | selector | operator | punctuation",grammar:"*(code | any)"},M={...G,...H,...I,...J,string:"single-string | double-string",delimiter:"comma | colon | semicolon | lbrace | rbrace",compress:"*space +delimiter *space",grammar:"*(compress | string | space | any)"},N={comment:"less exclamation dash dash *!(dash dash more) dash dash more",...I,...J,"attribute-name":"letter *(letter | digit | dash)","attribute-value":"single-string | double-string",
8
8
  attribute:"attribute-name ?(equal attribute-value)","tag-name":"letter *(letter | digit | dash)","tag-body":"*(whitespace | attribute)","any-tag":"less ?slash tag-name tag-body more",head:"(H | h) (E | e) (A | a) (D | d)",script:"(S | s) (C | c) (R | r) (I | i) (P | p) (T | t)","start-head":"less head tag-body more","end-head":"less slash head more","content-head":"*(tag-script | !end-head)","start-script":"less script tag-body more","end-script":"less slash script more","content-script":"*!end-script",
9
9
  "tag-head":"start-head content-head end-head","tag-script":"start-script content-script end-script",tag:"tag-head | tag-script | any-tag",grammar:"*(tag | comment | any)"},O={...G,...H,...I,...J,...K,string:"single-string | double-string | back-string",identifier:"letter *(letter | digit)",number:"digit *(digit | e | x)",operator:"+symbol",context:"lbrace *(code | !rbrace) rbrace",expression:"lparen *(code | !rparen) rparen",selector:"lbracket *(code | !rbracket) rbracket","import-source":"single-string | double-string",
10
10
  "module-require":"require *space lparen *space import-source *space rparen",code:"module-require | identifier | number | space | string | context | expression | selector | operator | punctuation",grammar:"*(code | any)"},R={comment:P,compress:Q,delimiter:null,whitespace:P},U={attribute:null,"content-head":null,"content-script":null,"end-head":null,"start-head":null,"tag-head":S,"tag-script":T},W={"import-source":null,"module-require":V};
11
- function Q(a,b){const c=b.length;let d="";for(let e=0;e<c;e+=2){const f=b[e+1];"whitespace"!==b[e]&&(d+=f)}return[a,d]}function S(a,b){var c=t(),{path:d}=c||{};c=' <link href="'+z("/",d)+'" rel="stylesheet">\n ';const e=b.length;let f="",g="",h="";if(d){for(d=0;d<e;d+=2){const l=b[d],m=b[d+1];"start-head"===l?g=m:"end-head"===l?h=m:"content-head"===l&&(f=m)}return[a,g+f+c+h]}return[a,b.filter((l,m)=>1===m%2).join("")]}
12
- function V(a,b){const c=t(),{aliases:d}=c||{},e=b.length;let f=null;for(let g=0;g<e;g+=2){const h=b[g+1];"import-source"===b[g]&&(c?(f=h.slice(1,-1),f=d[f]||f,f=h[0]+f+h[h.length-1]):f=h)}return[a,"require("+f+")"]}
13
- function T(a,b){const c=t(),{folder:d,name:e}=c||{},f=b.length;let g="",h="",l="",m=!1;c&&!c.deps&&(c.deps=[]);for(let n=0;n<f;n+=2){const k=b[n],p=b[n+1];"attribute"===k?"src="===p.slice(0,4).toLowerCase()?(h=p.slice(5,-1),m="jeti"===h.slice(-4)||"jeti/index.js"===h.slice(-13)):"type="===p.slice(0,5).toLowerCase()&&(l=p.slice(6,-1).toLowerCase()):"content-script"===k&&(g=p)}if("application/jet"===l){if(!h&&!g)return[a,""];c&&(!h&&e&&(b=c.deps.map(n=>n.path),h=y(d,e,"js",b)),c.deps.push({content:g,
14
- path:h}));return[a,'<script src="'+z("/",h)+'">\x3c/script>']}return m?[a,""]:[a,b.filter((n,k)=>1===k%2).join("")]}function P(a){return[a," "]}function X(a,b){u({path:b});a=v(a,N,U);r();return a}class aa extends Promise{config(a){return this.then(b=>{Object.assign(b.config,a);return b})}save(a,b){return this.then(c=>ba(a,c,b))}}
15
- function ba(a,b,c){const d=b.fragments;(c||{}).remove&&"."!==a&&w(a)&&q.rmSync(a,{recursive:!0});Object.keys(d).forEach(e=>{const f=d[e].content;e=z(a,e);const g=(new C(e)).folder;w(g)||q.mkdirSync(g,{recursive:!0});q.writeFileSync(e,f)});return b}
16
- class ca{constructor(a,b,c,d){({resolve:d}=d||{});this.content=c||"";this.deps=[];this.root=this.path=this.name=this.module=this.a=this.location=null;if(d)if(c=a.root,d=new C(b),B(d)||0<d.b.length&&("."===d.b[0]||".."===d.b[0])){d=z(c,b);d=x(d)?b.slice(1):null;if(!d){{d=c;const f=B(new C(d));var e=z(f?"":".",d,b);if(e=A(e)){const g=process.cwd().replace(/\\/g,"/");d=f?d:z(g,d);d=e.slice(d.length)}else d=null}}if(this.path=d)this.root=c}else{a:{if(c=A(b,{paths:[c]})){const [f,g]=da(c);if(g){d=require(g);
17
- c=[d.name+"@"+d.version,f,c.slice(f.length)];break a}}c=null}c&&([this.module,this.root,this.path]=c)}else this.path="/"+b,this.root=a.root;if(this.path)this.name=z(this.module||a.name,this.path),this.location=z(this.root,this.path),this.path="."+this.path,a=new C(this.path),this.folder=a.folder,this.a=a.a();else throw Error("Cannot find "+b);}load(){this.content||(this.content=q.readFileSync(this.location,"utf8"))}parse(){if("text/html"===this.a){var a=this.content;var b=u({folder:this.root,name:(new C(this.path)).name});
18
- a=v(a,N,U);r();b=[a,b.deps];[this.content,this.deps]=b}else F(this.a)&&(a=this.content,b=u({folder:this.folder}),a=v(a),r(),b=[a,b.deps],[this.content,this.deps]=b)}c(){return{content:this.content,deps:this.deps,a:this.a}}translate(a){if(F(this.a)){var b=this.content;u({aliases:a});a=v(b,O,W);r();this.content=a}}}function da(a){a=a.split("/");let b="";a.pop();a=a.map(d=>{d=b+d;b=d+"/";return[d,d+"/package.json"]}).reverse();const c=a.length;for(let d=0;d<c;d++)if(x(a[d][1]))return a[d];return[]}
19
- class ea{constructor(a,b){this.aliases={};this.name=a;this.root=b}get(a){return this.aliases[a]}set(a,b){this.aliases[a]=b}}class fa{create(a,b){return this[a]=new ea(a,b)}get(a){return this[a]}}
20
- function Y(a,b,c,d,e){const f=a.config,g=a.fragments,h=a.modules,l=a.namespaces;({resolve:e}=e||{});d=new ca(b,c,d,{resolve:e});e=d.name;var m=f&&f["module-name"];f&&f.externs&&-1<f.externs.indexOf(c)?e=c:!(f&&f.entries&&-1<f.entries.indexOf(c))&&m&&(e=m+"/"+("./"===e.slice(0,2)?e.slice(2):e));b.set(c,e);if(!g[e]&&!h[e]){m=!1;d.load();E(d.content)?(e=c,b.set(c,e)):"jete"===c||d.parse();if(-1<d.root.indexOf("node_modules/")){h[e]={};c=d.root;const k=d.module;k&&(b=l.get(k)||l.create(k,c))}else g[e]=
21
- {};const n=[];d.deps.length&&(m=!0,d.deps.forEach(k=>{if(!(f&&f.externs&&-1<f.externs.indexOf(k))||f&&f["include-externs"]){var p=null;"string"===typeof k?(p=b.get(k))||(p=Y(a,b,k,"",{resolve:!0})):k&&k.path&&(p=Y(a,b,k.path,k.content));n.push(p)}}),d.deps=n);m&&d.translate(b.aliases);-1<d.root.indexOf("node_modules/")?h[e]=d.c():g[e]=d.c()}return e}
22
- class ha{constructor(a,b,c){this.content=[];this.deps=c;this.name=a;this.a=b}c(){const a=this.deps,b=this.a;return{content:this.content.join(""),deps:a,a:b}}}class ia{constructor(){this.all=[]}close(a){this[a]&&delete this[a]}create(a,b,c){this[b]=new ha(a,b,c);this.all.push(this[b]);return this[b]}get(a){return this[a]}getAll(){return this.all}}class ja{close(a){this[a]&&delete this[a]}get(a){this[a]||(this[a]={});return this[a]}has(a,b){return(this[a]||{})[b]}put(a,b){this.get(a)[b]=!0}}
23
- function Z(a,b){var c=a.config;const d=a.f;var e=a.modules;const f=a.register,g=c.root;e=a.fragments[b]||e[b];if(!e)throw Error("Fragment not found "+b);var h=e.deps;const l=e.a;if(!f.has(l,b)){const m=d.get(l)||d.create(b,l,"text/html"===l?h:[]),n=m.name===b&&F(l);c=c&&c["module-name"];if(F(l)){const k=n&&c?c:b;e.content=E(e.content)?e.content.slice(13):"require('"+k+"', function(module, exports) {\n"+e.content+"});\n"}n&&!c&&m.content.push("(function(){function e(b,a){if('function'===typeof a)b=d[b]=a;else{a=d[b];if('function'===typeof a){{const c={exports:{}};a(c,c.exports);a=c}a=d[b]=a}b=a?a.exports:null}return b}const d={};e.load=function(b){const a=b.indexOf('.css')===b.length-4?'style':'script';return fetch(b).then(c=>200===c.status?c.text():'').then(c=>{if(c){const f=document.createElement(a);f.appendChild(document.createTextNode(c));document.head.appendChild(f)}})};'object'!==typeof window||window.require||(window.require=e)})();\n");
24
- f.put(l,b);h.forEach(k=>{"text/html"===l&&(f.close("application/javascript"),d.close("application/javascript"));Z(a,k)});F(l)&&n&&0===Object.keys(f["text/html"]||{}).length&&(h=d.get("text/css"))&&D(g,b,h);if("text/html"===l&&(h=d.get("text/css"))){const {href:k,filename:p}=D(g,b,h);e.content=X(e.content,k);m.deps.push(p)}m.content.push(e.content);n&&!c&&m.content.push("'object'===typeof window&&window.addEventListener('DOMContentLoaded',function(){require('"+b+"')});\n")}}
25
- function ka(a,b,c){const d=c[b];if(!F(d.a))throw Error("Entry must be a JavaScript to make a module");Object.keys(c).forEach(e=>{const f=c[e],g=f.content;"text/css"===f.a&&(d.content="if('object'===typeof document){const a=document.createElement('style');"+(a?"a.id='"+a+"';":"")+"a.appendChild(document.createTextNode('"+g.replace(/\\/g,"\\\\").replace(/[']/g,"\\'")+"'));document.head.appendChild(a);}"+d.content,delete c[e])});d.content="'jet module';"+d.content}
26
- module.exports={compress:function(a){const b=a.fragments;Object.keys(b).forEach(c=>{c=b[c];const d=c.content,e=c.a;if(F(e)||"text/css"===e)c.content=v(d,"text/css"===e?M:L,R).trim()});return a},entry:function(a){return new aa((b,c)=>{try{const {filename:d,folder:e}=new C(a),f={config:{root:z(process.cwd(),e),entries:[d]},fragments:{},modules:{}};b(f)}catch(d){c(d)}})},makemod:function(a){const b=a.config,c=a.fragments,d=b.entries,e=b&&b["module-name"];if(!e)throw Error("Config must include 'module-name' to make a module");
27
- d.map(f=>ka(e,f,c));return a},pack:function(a){const b=a.config.entries,c=new ia,d=new ja;a.f=c;a.register=d;b.forEach(f=>Z(a,f));const e={};c.getAll().forEach(f=>{const g=f.name;g&&(e[g]=f.c())});a.fragments=e;a.modules={};delete a.f;delete a.register;return a},parse:function(a){const b=a.config,c=b.entries,d=new fa,e=d.create(".",b.root);a.namespaces=d;b.entries=c.map(f=>Y(a,e,f));delete a.namespaces;return a}};
11
+ function Q(a,b){var c=b.length,d="";for(let e=0;e<c;e+=2){let f=b[e+1];b[e]!=="whitespace"&&(d+=f)}return[a,d]}function S(a,b){var c=t(),{path:d}=c||{};c=' <link href="'+z("/",d)+'" rel="stylesheet">\n ';var e=b.length,f="",g="",h="";if(d){for(d=0;d<e;d+=2){let k=b[d],m=b[d+1];k==="start-head"?g=m:k==="end-head"?h=m:k==="content-head"&&(f=m)}return[a,g+f+c+h]}return[a,b.filter((k,m)=>m%2===1).join("")]}
12
+ function V(a,b){var c=t(),{aliases:d}=c||{},e=b.length,f=null;for(let g=0;g<e;g+=2){let h=b[g+1];b[g]==="import-source"&&(c?(f=h.slice(1,-1),f=d[f]||f,f=h[0]+f+h[h.length-1]):f=h)}return[a,"require("+f+")"]}
13
+ function T(a,b){var c=t(),{folder:d,name:e}=c||{},f=b.length,g="",h="",k="",m=!1;c&&!c.deps&&(c.deps=[]);for(let n=0;n<f;n+=2){let l=b[n],p=b[n+1];l==="attribute"?p.slice(0,4).toLowerCase()==="src="?(h=p.slice(5,-1),m=h.slice(-4)==="jeti"||h.slice(-13)==="jeti/index.js"):p.slice(0,5).toLowerCase()==="type="&&(k=p.slice(6,-1).toLowerCase()):l==="content-script"&&(g=p)}if(k==="application/jet"){if(!h&&!g)return[a,""];c&&(!h&&e&&(b=c.deps.map(n=>n.path),h=y(d,e,"js",b)),c.deps.push({content:g,path:h}));
14
+ return[a,'<script src="'+z("/",h)+'">\x3c/script>']}return m?[a,""]:[a,b.filter((n,l)=>l%2===1).join("")]}function P(a){return[a," "]}function X(a,b){u({path:b});a=v(a,N,U);r();return a}class aa extends Promise{config(a){return this.then(b=>{Object.assign(b.config,a);return b})}save(a,b){return this.then(c=>ba(a,c,b))}}
15
+ function ba(a,b,c){var d=b.fragments;(c||{}).remove&&a!=="."&&w(a)&&q.rmSync(a,{recursive:!0});Object.keys(d).forEach(e=>{var f=d[e].content;e=z(a,e);var g=(new C(e)).folder;w(g)||q.mkdirSync(g,{recursive:!0});q.writeFileSync(e,f)});return b}
16
+ class ca{constructor(a,b,c,d){({resolve:d}=d||{});this.content=c||"";this.deps=[];this.root=this.path=this.name=this.module=this.mediaType=this.location=null;if(d)if(c=a.root,d=new C(b),B(d)||d.g.length>0&&(d.g[0]==="."||d.g[0]==="..")){d=z(c,b);if(!(d=x(d)?b.slice(1):null)){{d=c;let f=B(new C(d));var e=z(f?"":".",d,b);if(e=A(e)){let g=process.cwd().replace(/\\/g,"/");d=f?d:z(g,d);d=e.slice(d.length)}else d=null}}if(this.path=d)this.root=c}else{a:{if(c=A(b,{paths:[c]})){let [f,g]=da(c);if(g){d=require(g);
17
+ c=[d.name+"@"+d.version,f,c.slice(f.length)];break a}}c=null}c&&([this.module,this.root,this.path]=c)}else this.path="/"+b,this.root=a.root;if(this.path)this.name=z(this.module||a.getName(),this.path),this.location=z(this.root,this.path),this.path="."+this.path,a=new C(this.path),this.folder=a.folder,this.mediaType=a.mediaType();else throw Error("Cannot find "+b);}getName(){return this.name}load(){this.content||(this.content=q.readFileSync(this.location,"utf8"))}parse(){if(this.mediaType==="text/html"){var a=
18
+ this.content,b=u({folder:this.root,name:(new C(this.path)).name});a=v(a,N,U);r();[this.content,this.deps]=[a,b.deps]}else F(this.mediaType)&&(a=this.content,b=u({folder:this.folder}),a=v(a),r(),[this.content,this.deps]=[a,b.deps])}h(){return{content:this.content,deps:this.deps,mediaType:this.mediaType}}translate(a){if(F(this.mediaType)){var b=this.content;u({aliases:a});a=v(b,O,W);r();this.content=a}}}
19
+ function da(a){a=a.split("/");var b="";a.pop();a=a.map(d=>{d=b+d;b=d+"/";return[d,d+"/package.json"]}).reverse();var c=a.length;for(let d=0;d<c;d++)if(x(a[d][1]))return a[d];return[]}class ea{constructor(a,b){this.aliases={};this.name=a;this.root=b}get(a){return this.aliases[a]}getName(){return this.name}set(a,b){this.aliases[a]=b}}class fa{create(a,b){return this[a]=new ea(a,b)}get(a){return this[a]}}
20
+ function Y(a,b,c,d,e){var f=a.config,g=a.fragments,h=a.modules,k=a.namespaces;({resolve:e}=e||{});d=new ca(b,c,d,{resolve:e});e=d.getName();var m=f&&f["module-name"];f&&f.externs&&f.externs.indexOf(c)>-1?e=c:!(f&&f.entries&&f.entries.indexOf(c)>-1)&&m&&(e=m+"/"+(e.slice(0,2)==="./"?e.slice(2):e));b.set(c,e);if(!g[e]&&!h[e]){m=!1;d.load();E(d.content)?(e=c,b.set(c,e)):c==="jete"||d.parse();if(d.root.indexOf("node_modules/")>-1){h[e]={};c=d.root;let l=d.module;l&&(b=k.get(l)||k.create(l,c))}else g[e]=
21
+ {};let n=[];d.deps.length&&(m=!0,d.deps.forEach(l=>{if(!(f&&f.externs&&f.externs.indexOf(l)>-1)||f&&f["include-externs"]){var p=null;typeof l==="string"?(p=b.get(l))||(p=Y(a,b,l,"",{resolve:!0})):l&&l.path&&(p=Y(a,b,l.path,l.content));n.push(p)}}),d.deps=n);m&&d.translate(b.aliases);d.root.indexOf("node_modules/")>-1?h[e]=d.h():g[e]=d.h()}return e}
22
+ class ha{constructor(a,b,c){this.content=[];this.deps=c;this.name=a;this.mediaType=b}getName(){return this.name}h(){var a=this.deps,b=this.mediaType;return{content:this.content.join(""),deps:a,mediaType:b}}}class ia{constructor(){this.all=[]}close(a){this[a]&&delete this[a]}create(a,b,c){this[b]=new ha(a,b,c);this.all.push(this[b]);return this[b]}get(a){return this[a]}getAll(){return this.all}}
23
+ class ja{close(a){this[a]&&delete this[a]}get(a){this[a]||(this[a]={});return this[a]}has(a,b){return(this[a]||{})[b]}put(a,b){this.get(a)[b]=!0}}
24
+ function Z(a,b){var c=a.config,d=a.i,e=a.modules,f=a.register,g=c.root;e=a.fragments[b]||e[b];if(!e)throw Error("Fragment not found "+b);var h=e.deps,k=e.mediaType;if(!f.has(k,b)){let m=d.get(k)||d.create(b,k,k==="text/html"?h:[]),n=m.name===b&&F(k);c=c&&c["module-name"];F(k)&&(e.content=E(e.content)?e.content.slice(13):"require('"+(n&&c?c:b)+"', function(module, exports) {\n"+e.content+"});\n");n&&!c&&m.content.push("(function(){function e(b,a){if('function'===typeof a)b=d[b]=a;else{a=d[b];if('function'===typeof a){{const c={exports:{}};a(c,c.exports);a=c}a=d[b]=a}b=a?a.exports:null}return b}const d={};e.load=function(b){const a=b.indexOf('.css')===b.length-4?'style':'script';return fetch(b).then(c=>200===c.status?c.text():'').then(c=>{if(c){const f=document.createElement(a);f.appendChild(document.createTextNode(c));document.head.appendChild(f)}})};'object'!==typeof window||window.require||(window.require=e)})();\n");
25
+ f.put(k,b);h.forEach(l=>{k==="text/html"&&(f.close("application/javascript"),d.close("application/javascript"));Z(a,l)});F(k)&&n&&Object.keys(f["text/html"]||{}).length===0&&(h=d.get("text/css"))&&D(g,b,h);if(k==="text/html"&&(h=d.get("text/css"))){let {href:l,filename:p}=D(g,b,h);e.content=X(e.content,l);m.deps.push(p)}m.content.push(e.content);n&&!c&&m.content.push("'object'===typeof window&&window.addEventListener('DOMContentLoaded',function(){require('"+b+"')});\n")}}
26
+ function ka(a,b,c){var d=c[b];if(!F(d.mediaType))throw Error("Entry must be a JavaScript to make a module");Object.keys(c).forEach(e=>{var f=c[e],g=f.content;f.mediaType==="text/css"&&(d.content="if('object'===typeof document){const a=document.createElement('style');"+(a?"a.id='"+a+"';":"")+"a.appendChild(document.createTextNode('"+g.replace(/\\/g,"\\\\").replace(/[']/g,"\\'")+"'));document.head.appendChild(a);}"+d.content,delete c[e])});d.content="'jet module';"+d.content}
27
+ module.exports={compress:function(a){var b=a.fragments;Object.keys(b).forEach(c=>{c=b[c];var d=c.content,e=c.mediaType;if(F(e)||e==="text/css")c.content=v(d,e==="text/css"?M:L,R).trim()});return a},entry:function(a){return new aa((b,c)=>{try{let {filename:d,folder:e}=new C(a),f={config:{root:z(process.cwd(),e),entries:[d]},fragments:{},modules:{}};b(f)}catch(d){c(d)}})},makemod:function(a){var b=a.config,c=a.fragments,d=b.entries,e=b&&b["module-name"];if(!e)throw Error("Config must include 'module-name' to make a module");
28
+ d.map(f=>ka(e,f,c));return a},pack:function(a){var b=a.config.entries,c=new ia,d=new ja;a.i=c;a.register=d;b.forEach(f=>Z(a,f));var e={};c.getAll().forEach(f=>{var g=f.getName();g&&(e[g]=f.h())});a.fragments=e;a.modules={};delete a.i;delete a.register;return a},parse:function(a){var b=a.config,c=b.entries,d=new fa,e=d.create(".",b.root);a.namespaces=d;b.entries=c.map(f=>Y(a,e,f));delete a.namespaces;return a}};
package/license.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  License
2
2
 
3
- Copyright © 2020-2023 by Oleksandr Krayilo
3
+ Copyright © 2020-2026 by Oleksandr Krayilo
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "jetc",
3
- "version": "0.6.5",
3
+ "version": "0.7.1",
4
4
  "description": "Jet.js Compiler and Server.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "postinstall": "node postinstall",
8
- "start": "jetc-server",
9
- "build": "jetc-build"
7
+ "postinstall": "node postinstall"
10
8
  },
11
9
  "files": [
12
10
  "bin/",
@@ -16,13 +14,12 @@
16
14
  "postinstall.js"
17
15
  ],
18
16
  "bin": {
19
- "jetc-build": "bin/build.js",
20
- "jetc-server": "bin/server.js",
21
- "jetc-update": "bin/update.js"
17
+ "jetc": "bin/run.js",
18
+ "jetc-server": "bin/server.js"
22
19
  },
23
20
  "author": "Oleksandr Krayilo",
24
21
  "license": "ISC",
25
22
  "dependencies": {
26
- "jeti": "^0.8.7"
23
+ "jeti": "^0.8.11"
27
24
  }
28
25
  }
package/postinstall.js CHANGED
@@ -1 +1 @@
1
- 'use strict';const b=require("fs"),d=require.main.paths[0].split("node_modules")[0],f=d+"package.json";if(require.main===module&&b.existsSync(f)){{const a=require(f);let e=!1;a.hasOwnProperty("scripts")||(a.scripts={});const c=a.scripts;c.hasOwnProperty("start")||(c.start="jetc-server --port=3000 --all src",e=!0);c.hasOwnProperty("build")||(c.build="jetc-build",e=!0);e&&b.writeFileSync(f,JSON.stringify(a,null,2))}{const a=d+"build.js";b.existsSync(a)||b.copyFileSync("conf/build.js",a)}};
1
+ const a=require("fs"),d=require.main.paths[0].split("node_modules")[0],f=d+"package.json";if(require.main===module&&a.existsSync(f)){let b=require(f),e=!1;b.hasOwnProperty("scripts")||(b.scripts={});let c=b.scripts;c.hasOwnProperty("start")||(c.start="jetc-server --port=3000 --all src",e=!0);c.hasOwnProperty("build")||(c.build="jetc build.js",e=!0);e&&a.writeFileSync(f,JSON.stringify(b,null,2));let g=d+"build.js";a.existsSync(g)||a.copyFileSync("conf/build.js",g)};
package/bin/build.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';const b=require("fs"),d=require("path"),{parser:e}=require("jeti"),f=d.join(process.cwd(),process.argv[2]||"./build.js");function g(){let a=null;try{const c=b.readFileSync(f,"utf8"),h="(function() {\nconst module = {exports: {}};\nlet exports = module.exports;\n"+e(c)+"\nreturn module.exports;\n})()";a=eval(h)}catch(c){console.error(c),process.exit(1)}return a&&a.default||a}require.main===module&&(b.existsSync(f)?g()():console.error("Error:",f,"not found."));
package/bin/update.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';const c=require("fs"),{execSync:d}=require("child_process");if(require.main===module)if(c.existsSync("./package.json")){var e;{let a=null;try{const b=c.readFileSync("./package.json","utf8");a=JSON.parse(b)}catch(b){console.error(b),process.exit(1)}e=a}var f=e.dependencies;if(f)for(const a in f){const b="npm install "+a+("file:"!==f[a].slice(0,5)?"@latest":"");console.log("Updating",a,"...");d(b,{stdio:"inherit"});console.log("")}}else console.error("Error:","./package.json","not found.");