jetc 0.4.3 → 0.5.0

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/build.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';const c=require("fs"),d=require("path"),{parser:e}=require("jeti"),f=d.join(process.cwd(),"./build.js");function g(){let a=null;try{const b=c.readFileSync(f,"utf8"),h="(function() {\nconst module = {exports: {}};\nlet exports = module.exports;\n"+e(b)+"return module.exports;})()";a=eval(h)}catch(b){console.error(b),process.exit(1)}return a&&a.default||a}require.main===module&&c.existsSync(f)&&g()();
2
+ 'use strict';const c=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 b=c.readFileSync(f,"utf8"),h="(function() {\nconst module = {exports: {}};\nlet exports = module.exports;\n"+e(b)+"\nreturn module.exports;\n})()";a=eval(h)}catch(b){console.error(b),process.exit(1)}return a&&a.default||a}require.main===module&&c.existsSync(f)&&g()();
package/bin/server.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';function h(a){return l.existsSync(a)&&l.statSync(a).isDirectory()}function n(a){return l.existsSync(a)&&l.statSync(a).isFile()}function p(...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 q(a,c){try{return require.resolve(a,c).replace(/\\/g,"/")}catch(b){}return null}function r(a,c){return"\u001b["+a+"m"+c+"\u001b[39m"}function t(){return r(90,"["+(new Date).toLocaleString("en-US")+"]")}
4
- function v(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])?{"Content-Type":a[c]}:null}const l=require("fs"),w=require("url"),x=require("http"),y=process.argv[3]||process.argv[2],z=process.argv[2],B=parseInt(y,10),C=B||3E3,D=!z||z===y&&B?"":z;function E(a){let c="";a=a.split("/").map(d=>{d=c+d;c=d+"/";return[d,d+"/node_modules"]}).reverse();const b=a.length;for(let d=0;d<b;d++)if(h(a[d][1]))return a[d][0];return null}
6
- function F(){const a=x.createServer((c,b)=>{{var {pathname:d}=w.parse(c.url);var e=process.cwd().replace(/\\/g,"/");var g=D?p(e,D):e,k=p(g,d);const m=p(k,"index.html");var f="";e="";if(n(k))f=k,e=d;else if(n(m))f=m,e=p(d,"index.html");else if(0===d.indexOf("/node_modules/")){if(d=d.split("/node_modules/"),k=E(g),g=d.pop(),k&&g&&(f=p(k,d.join("/node_modules/")),f=q(g,{paths:[f]})))d=f.split("/node_modules/"),d[0]="",e=d.join("/node_modules/")}else(f=q(p(".",d),{paths:[g]}))?e=f.slice(g.length):(f=
7
- q(d.slice(1),{paths:[g]}))&&(e=p("/node_modules/",f.split("/node_modules/").pop()));e={filename:f,location:e}}const {filename:A,location:u}=e;e="";if(A){try{e=l.readFileSync(A,"binary")}catch(m){e=m;c=c.url;b.writeHead(500,v(".txt"));b.write(e+"\n");b.end();console.log(t(),c+" "+r(31,500));return}c=c.url;f=Object.assign({},{Location:u},v(u),{"Cache-Control":"max-age=0, no-cache, must-revalidate, proxy-revalidate",Expires:"Thu, 01 Jan 1970 00:00:00 GMT","Last-Modified":(new Date).toUTCString()});b.writeHead(200,
8
- f);b.write(e,"binary");b.end();console.log(t(),c+" 200 "+e.length+" "+u)}else c=c.url,b.writeHead(404,v(".txt")),b.write("404 Not Found\n"),b.end(),console.log(t(),c+" "+r(31,404))});a.on("error",c=>console.error(c));a.listen(C,"localhost");console.log("Development server is running at http://localhost:"+C+"/\nPress Ctrl + C to shutdown.\n")}require.main===module&&F();
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")+"]")}
4
+ function A(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])?{"Content-Type":a[c]}:null}const n=require("fs"),B=require("http");function C(){var a=process.argv;let c=!1,b="",f=3E3;const g=a.length;for(let k=2;k<g;k++){const d=a[k];d.startsWith("--port=")?f=parseInt(d.slice(7),10):"--all"===d?c=!0:k===g-1&&(b=d)}return{a:c,folder:b,port:f}}function D(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}
6
+ function E(){const {a,folder:c,port:b}=C(),f=B.createServer((g,k)=>{{var d=g.url.split("?")[0];var e=process.cwd().replace(/\\/g,"/");var m=c?t(e,c):e,p=t(m,"index.html");const q=t(m,d),y=t(q,"index.html");var h="";e="";if(r(q))h=q,e=d;else if(r(y))h=y,e=t(d,"index.html");else if(0===d.indexOf("/node_modules/")){if(d=d.split("/node_modules/"),p=D(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]="",e=d.join("/node_modules/")}else(h=u(t(".",d),
7
+ {paths:[m]}))?e=h.slice(m.length):(h=u(d.slice(1),{paths:[m]}))&&(e=t("/node_modules/",h.split("/node_modules/").pop())),h||!a||1<d.split("/").pop().split(".").length||!r(p)||(h=p,e=t("/index.html"));e={filename:h,location:e}}const {filename:z,location:x}=e;e="";if(z){try{e=n.readFileSync(z,"binary")}catch(q){e=q;g=g.url;k.writeHead(500,A(".txt"));k.write("500 Internal Server Error\n");k.end();console.log(w(),g+" "+v(31,500)+" "+e);return}g=g.url;h=Object.assign({},{Location:x},A(x),{"Cache-Control":"max-age=0, no-cache, must-revalidate, proxy-revalidate",
8
+ Expires:"Thu, 01 Jan 1970 00:00:00 GMT","Last-Modified":(new Date).toUTCString()});k.writeHead(200,h);k.write(e,"binary");k.end();console.log(w(),g+" 200 "+e.length+" "+x)}else g=g.url,k.writeHead(404,A(".txt")),k.write("404 Not Found\n"),k.end(),console.log(w(),g+" "+v(31,404))});f.on("error",g=>console.error(g));f.listen(b,"localhost");console.log("Development server is running at http://localhost:"+b+"/\nPress Ctrl + C to shutdown.\n")}require.main===module&&E();
package/conf/build.js CHANGED
@@ -4,6 +4,6 @@ export default () => {
4
4
  entry('./src/index.html')
5
5
  .then(parse)
6
6
  .then(pack)
7
- .save('./dist')
7
+ .save('./dist', {remove: false})
8
8
  .catch((error) => void console.error(error));
9
9
  };
package/index.js CHANGED
@@ -1,23 +1,26 @@
1
- 'use strict';const p=require("fs"),{closeContext:q,getContext:r,openContext:t,parser:u}=require("jeti");function v(a){return p.existsSync(a)&&p.statSync(a).isDirectory()}function x(a){return p.existsSync(a)&&p.statSync(a).isFile()}function y(a,b,c,d){let g;for(let e=1;g=b+(1<e?e:"")+"."+c,p.existsSync(z(a,g))||-1!==(d||[]).indexOf(g);e++);return g}
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}
3
- class B{constructor(a){this.path=a;this.a=this.path.split("/");this.i=this.a.pop();this.folder=this.a.join("/");this.ext=this.name=null;a=this.i.split(".");this.ext=1<a.length&&(a[0]||2<a.length)?a.pop():"";this.name=a.join(".")}c(){return 0===this.a.length||-1===["",".",".."].indexOf(this.a[0])}mimeType(){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 C(a){return"application/javascript"===a}
5
- const D={comment:"less exclamation dash dash *!(dash dash more) dash dash more","single-string":"single-quote *((escape any) | !single-quote) single-quote","double-string":"double-quote *((escape any) | !double-quote) double-quote",string:"single-string | double-string","attribute-name":"letter *(letter | digit | dash)","attribute-value":"single-string | double-string",attribute:"attribute-name ?(equal attribute-value)","tag-name":"letter *(letter | digit | dash)","tag-body":"*(space | attribute)",
6
- "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","tag-head":"start-head content-head end-head","tag-script":"start-script content-script end-script",tag:"tag-head | tag-script | any-tag",
7
- grammar:"*(tag | comment | any)"},E={"single-comment":"slash slash *!end-line end-line","multi-comment":"slash star *!(star slash) star slash",comment:"single-comment | multi-comment","single-string":"single-quote *((escape any) | !single-quote) single-quote","double-string":"double-quote *((escape any) | !double-quote) double-quote","back-string":"back-quote *((escape any) | (dollar context) | !back-quote) back-quote",string:"single-string | double-string | back-string","import-source":"single-string | double-string",
8
- "module-require":"require *space lparen import-source rparen",code:"module-require | comment | string",grammar:"*(code | any)"},H={attribute:null,"content-head":null,"content-script":null,"end-head":null,"start-head":null,"tag-head":F,"tag-script":G},J={"import-source":null,"module-require":I};
9
- function F(a,b){var c=r(),{href:d}=c||{};c='<link href="'+d+'" rel="stylesheet">\n';const g=b.length;let e="",h="",f="";if(d){for(d=0;d<g;d+=2){const m=b[d],l=b[d+1];"start-head"===m?h=l:"end-head"===m?f=l:"content-head"===m&&(e=l)}return[a,h+e+c+f]}return[a,b.filter((m,l)=>1===l%2).join("")]}
10
- function I(a,b){const c=r(),{aliases:d}=c||{},g=b.length;let e=null;for(let h=0;h<g;h+=2){const f=b[h+1];"import-source"===b[h]&&(c?(e=f.slice(1,-1),e=d[e]||e,e=f[0]+e+f[f.length-1]):e=f)}return[a,"require("+e+")"]}
11
- function G(a,b){const c=r(),{folder:d,name:g}=c||{},e=b.length;let h="",f="",m="",l=!1;c&&!c.deps&&(c.deps=[]);for(let k=0;k<e;k+=2){const n=b[k],w=b[k+1];"attribute"===n?"src="===w.slice(0,4).toLowerCase()?(f=w.slice(5,-1),l="jeti/index.js"===f.slice(-13)):"type="===w.slice(0,5).toLowerCase()&&(m=w.slice(6,-1).toLowerCase()):"content-script"===n&&(h=w)}if("application/jet"===m){if(!f&&!h)return[a,""];c&&(!f&&g&&(b=c.deps.map(k=>k.request),f=y(d,g,"js",b)),c.deps.push({content:h,request:f}));return[a,
12
- '<script src="'+f+'">\x3c/script>']}return l?[a,""]:[a,b.filter((k,n)=>1===n%2).join("")]}q;t;u;function K(a,b){t().href=b;a=u(a,D,H);q();return a}class L extends Promise{save(a){return this.then(b=>{{const c=b.b;v(a)&&p.rmdirSync(a,{recursive:!0});for(let d in c){const g=c[d].content,e=z(a,d),h=(new B(e)).folder;v(h)||p.mkdirSync(h,{recursive:!0});p.writeFileSync(e,g)}}return b})}}
13
- class M{constructor(a,b,c){this.content=c;this.deps=[];this.root=this.request=this.path=this.name=this.module=this.mimeType=null;if("undefined"===typeof this.content){c=a.root;var d=new B(b);if(0<d.a.length&&"."===d.a[0]){d=z(c,b);d=x(d)?b.slice(1):null;if(!d){d=c;var g=new B(d);g=0<g.a.length&&""===g.a[0];var e=z(g?"":".",d,b);if(e=A(e)){const h=process.cwd().replace(/\\/g,"/");d=g?d:z(h,d);d=e.slice(d.length)}else d=null}if(this.request=d)this.root=c}else if(d.c()){a:{if(c=A(b,{paths:[c]})){const [h,
14
- f]=N(c);if(f){d=require(f);c=[d.name+"@"+d.version,h,c.slice(h.length)];break a}}c=null}c&&([this.module,this.root,this.request]=c)}}else this.request="/"+b,this.root=a.root;if(this.request)this.name=(this.module||a.name)+this.request,this.path=z(this.root,this.request),this.request="."+this.request,a=new B(this.request),this.folder=a.folder,this.mimeType=a.mimeType();else throw Error("Cannot find "+b);}c(){return-1<this.root.indexOf("node_modules/")}load(){this.content||(this.content=p.readFileSync(this.path,
15
- "utf8"))}parse(){if("text/html"===this.mimeType){var a=this.content,b=this.request;var c=t(this.root);c.name=(new B(b)).name;a=u(a,D,H);q();c=[a,c.deps];[this.content,this.deps]=c}else C(this.mimeType)&&(a=this.content,c=t(this.folder),a=u(a),q(),c=[a,c.deps],[this.content,this.deps]=c)}f(){return{content:this.content,deps:this.deps,mimeType:this.mimeType}}translate(a){if(C(this.mimeType)){var b=this.content;t().aliases=a;a=u(b,E,J);q();this.content=a}}}
16
- function N(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[]}class O{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 P{create(a,b){return this[a]=new O(a,b)}get(a){return this[a]}}
17
- function Q(a,b,c,d){const g=a.b,e=a.h,h=a.namespaces;d=new M(b,c,d);const f=d.name;b.set(c,f);if(!g[f]&&!e[f]){let m=!1;d.load();"jete"!==c&&d.parse();if(d.c()){e[f]={};c=d.module;const k=d.root;c&&(b=h.get(c)||h.create(c,k))}else g[f]={};const l=[];d.deps.length&&(m=!0,d.deps.forEach(k=>{let n=null;"string"===typeof k?(n=b.get(k))||(n=Q(a,b,k)):k&&k.request&&(n=Q(a,b,k.request,k.content));l.push(n)}),d.deps=l);m&&d.translate(b.aliases);d.c()?e[f]=d.f():g[f]=d.f()}return f}
18
- class R{constructor(a,b,c){this.content=[];this.deps=c;this.name=a;this.mimeType=b}f(){const a=this.deps,b=this.mimeType;return{content:this.content.join(""),deps:a,mimeType:b}}}class S{constructor(){this.all=[]}close(a){delete this[a]}create(a,b,c){this[b]=new R(a,b,c);this.all.push(this[b]);return this[b]}get(a){return this[a]}getAll(){return this.all}}
19
- class T{constructor(){this["application/javascript"]=this.l={}}close(a){delete this[a]}get(a){this[a]||(this[a]={});return this[a]}has(a,b){a=this.get(a);return this.l[b]||a[b]}put(a,b){this.get(a)[b]=!0}}
20
- function U(a,b){const c=a.j;var d=a.h;const g=a.register;var e=a.g.root;d=a.b[b]||d[b];if(!d)throw Error("Fragment not found "+b);var h=d.deps;const f=d.mimeType;if(!g.has(f,b)){const l=c.get(f)||c.create(b,f,"text/html"===f?h:[]);C(f)&&(d.content="require('"+b+"', function(module, exports) {\n"+d.content+"});\n",g["application/javascript"]===g.l&&l.name===b&&l.content.push("(function(){function e(b,a){if('function'===typeof a)b=c[b]=a;else{a=c[b];if('function'===typeof a){var d={exports:{}};a(d,d.exports);a=c[b]=d}b=a.exports}return b}var c={};'object'!==typeof window||window.require||(window.require=e)})();\n"));
21
- g.put(f,b);h.forEach(k=>{var n;if(n="text/html"===f)n=0!==Object.keys(g["application/javascript"]).length;n&&(g.close("application/javascript"),c.close("application/javascript"));U(a,k)});if("text/html"===f&&(h=c.get("text/css"))){var {name:m}=new B(b);e=y(e,m,"css");m=z(".",e);d.content=K(d.content,e);l.deps.push(m);h.name=m}l.content.push(d.content);C(f)&&l.name===b&&l.content.push("'object'===typeof window&&window.addEventListener('DOMContentLoaded',function(){require('"+b+"')});\n")}}
22
- module.exports={entry:function(a){return new L((b,c)=>{try{const {i:d,folder:g}=new B(a),e={g:{root:z(process.cwd(),g),entries:[d]},b:{},h:{}};b(e)}catch(d){c(d)}})},pack:function(a){const b=a.g.entries,c=new S,d=new T;a.j=c;a.register=d;b.forEach(e=>U(a,e));const g={};c.getAll().forEach(e=>{const h=e.name;h&&(g[h]=e.f())});a.b=g;a.h={};delete a.j;delete a.register;return a},parse:function(a){const b=a.g,c=b.entries,d=new P,g=d.create(".",b.root);a.namespaces=d;b.entries=c.map(e=>Q(a,g,e,""));delete a.namespaces;
23
- return a}};
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.a.length&&""===a.a[0]}
3
+ class C{constructor(a){this.path=a;this.a=this.path.split("/");this.filename=this.a.pop();this.folder=this.a.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(".")}mimeType(){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}var G={"single-comment":"slash slash *!end-line end-line","multi-comment":"slash star *!(star slash) star slash",comment:"single-comment | multi-comment"},H={"single-string":"single-quote *((escape any) | !single-quote) single-quote"},I={"double-string":"double-quote *((escape any) | !double-quote) double-quote"};
5
+ const J={...G,...H,...I,string:"single-string | double-string",bracket:"lbrace | rbrace | lparen | rparen | lbracket | rbracket","extended-symbol":"symbol | punctuation | bracket",delimiter:"comment | string | extended-symbol",compress:"*space +delimiter *space",grammar:"*(compress | any)"},K={comment:"less exclamation dash dash *!(dash dash more) dash dash more",...H,...I,"attribute-name":"letter *(letter | digit | dash)","attribute-value":"single-string | double-string",attribute:"attribute-name ?(equal attribute-value)",
6
+ "tag-name":"letter *(letter | digit | dash)","tag-body":"*(space | 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","tag-head":"start-head content-head end-head","tag-script":"start-script content-script end-script",
7
+ tag:"tag-head | tag-script | any-tag",grammar:"*(tag | comment | any)"},L={...G,...H,...I,"back-string":"back-quote *((escape any) | (dollar context) | !back-quote) back-quote",string:"single-string | double-string | back-string","import-source":"single-string | double-string","module-require":"require *space lparen import-source rparen",code:"module-require | comment | string",grammar:"*(code | any)"},O={comment:M,compress:N,delimiter:null},R={attribute:null,"content-head":null,"content-script":null,
8
+ "end-head":null,"start-head":null,"tag-head":P,"tag-script":Q},T={"import-source":null,"module-require":S};function M(a){return[a,""]}function N(a,b){const c=b.length;let d="";for(let e=0;e<c;e+=2){const f=b[e+1];"delimiter"===b[e]&&(d+=f)}return[a,d]}
9
+ function P(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("")]}
10
+ function S(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+")"]}
11
+ function Q(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,
12
+ path:h}));return[a,'<script src="'+z("/",h)+'">\x3c/script>']}return m?[a,""]:[a,b.filter((n,k)=>1===k%2).join("")]}function U(a,b){u({path:b});a=v(a,K,R);r();return a}class V extends Promise{config(a){return this.then(b=>{Object.assign(b.config,a);return b})}save(a,b){return this.then(c=>W(a,c,b))}}
13
+ function W(a,b,c){const d=b.fragments;(c||{}).remove&&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}
14
+ class X{constructor(a,b,c,d){({resolve:d}=d||{});this.content=c||"";this.deps=[];this.root=this.path=this.name=this.module=this.mimeType=this.location=null;if(d)if(c=a.root,d=new C(b),B(d)||0<d.a.length&&("."===d.a[0]||".."===d.a[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]=aa(c);if(g){d=
15
+ require(g);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.mimeType=a.mimeType();else throw Error("Cannot find "+b);}load(){this.content||(this.content=q.readFileSync(this.location,"utf8"))}parse(){if("text/html"===this.mimeType){var a=this.content;
16
+ var b=u({folder:this.root,name:(new C(this.path)).name});a=v(a,K,R);r();b=[a,b.deps];[this.content,this.deps]=b}else F(this.mimeType)&&(a=this.content,b=u({folder:this.folder}),a=v(a),r(),b=[a,b.deps],[this.content,this.deps]=b)}b(){return{content:this.content,deps:this.deps,mimeType:this.mimeType}}translate(a){if(F(this.mimeType)){var b=this.content;u({aliases:a});a=v(b,L,T);r();this.content=a}}}
17
+ function aa(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[]}class ba{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 ca{create(a,b){return this[a]=new ba(a,b)}get(a){return this[a]}}
18
+ 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 X(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]=
19
+ {};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.b():g[e]=d.b()}return e}
20
+ class da{constructor(a,b,c){this.content=[];this.deps=c;this.name=a;this.mimeType=b}b(){const a=this.deps,b=this.mimeType;return{content:this.content.join(""),deps:a,mimeType:b}}}class ea{constructor(){this.all=[]}close(a){this[a]&&delete this[a]}create(a,b,c){this[b]=new da(a,b,c);this.all.push(this[b]);return this[b]}get(a){return this[a]}getAll(){return this.all}}
21
+ class fa{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}}
22
+ function Z(a,b){var c=a.config;const d=a.c;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.mimeType;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=>c.text()).then(c=>{{const f=document.createElement(a);f.appendChild(document.createTextNode(c));document.head.appendChild(f)}})};'object'!==typeof window||window.require||(window.require=e)})();\n");
23
+ 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=U(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")}}
24
+ function ha(a,b){const c=b[a];if(!F(c.mimeType))throw Error("Entry must be a JavaScript to make module");Object.keys(b).forEach(d=>{const e=b[d],f=e.content;"text/css"===e.mimeType&&(c.content="if('object'===typeof document){const a=document.createElement('style');a.appendChild(document.createTextNode('"+f.replace(/\\/g,"\\\\").replace(/[']/g,"\\'")+"'));document.head.appendChild(a);}"+c.content,delete b[d])});c.content="'jet module';"+c.content}
25
+ module.exports={compress:function(a){const b=a.fragments;Object.keys(b).forEach(c=>{c=b[c];const d=c.content,e=c.mimeType;if(F(e)||"text/css"===e)c.content=v(d,J,O)});return a},entry:function(a){return new V((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.fragments;a.config.entries.map(c=>ha(c,b));return a},pack:function(a){const b=a.config.entries,c=new ea,d=new fa;a.c=c;
26
+ a.register=d;b.forEach(f=>Z(a,f));const e={};c.getAll().forEach(f=>{const g=f.name;g&&(e[g]=f.b())});a.fragments=e;a.modules={};delete a.c;delete a.register;return a},parse:function(a){const b=a.config,c=b.entries,d=new ca,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-2021 by Oleksandr Krayilo
3
+ Copyright © 2020-2022 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,10 +1,12 @@
1
1
  {
2
2
  "name": "jetc",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Jet.js Compiler and Server.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "postinstall": "node postinstall"
7
+ "postinstall": "node postinstall",
8
+ "start": "jetc-server",
9
+ "build": "jetc-build"
8
10
  },
9
11
  "files": [
10
12
  "bin/",
@@ -20,6 +22,6 @@
20
22
  "author": "Oleksandr Krayilo",
21
23
  "license": "ISC",
22
24
  "dependencies": {
23
- "jeti": "^0.7.3"
25
+ "jeti": "^0.8.1"
24
26
  }
25
27
  }
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",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
+ '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)}};
package/README.md DELETED
@@ -1,17 +0,0 @@
1
- To build package:
2
-
3
- ```
4
- node build
5
- ```
6
-
7
- To run tests:
8
-
9
- ```
10
- node test
11
- ```
12
-
13
- To publish package:
14
-
15
- ```
16
- npm publish
17
- ```