jetc 0.4.5 → 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(),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)+"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
@@ -4,5 +4,5 @@ function u(a,c){try{return require.resolve(a,c).replace(/\\/g,"/")}catch(b){}ret
4
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
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
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(e+"\n");k.end();console.log(w(),g+" "+v(31,500));return}g=g.url;h=Object.assign({},{Location:x},A(x),{"Cache-Control":"max-age=0, no-cache, must-revalidate, proxy-revalidate",
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
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
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}
3
- class B{constructor(a){this.path=a;this.a=this.path.split("/");this.g=this.a.pop();this.folder=this.a.join("/");this.ext=this.name=null;a=this.g.split(".");this.ext=1<a.length&&(a[0]||2<a.length)?a.pop():"";this.name=a.join(".")}b(){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=t(),{href: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 k=b[d],n=b[d+1];"start-head"===k?g=n:"end-head"===k?h=n:"content-head"===k&&(f=n)}return[a,g+f+c+h]}return[a,b.filter((k,n)=>1===n%2).join("")]}
10
- function I(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 G(a,b){const c=t(),{folder:d,name:e}=c||{},f=b.length;let g="",h="",k="",n=!1;c&&!c.deps&&(c.deps=[]);for(let l=0;l<f;l+=2){const m=b[l],p=b[l+1];"attribute"===m?"src="===p.slice(0,4).toLowerCase()?(h=p.slice(5,-1),n="jeti"===h.slice(-4)||"jeti/index.js"===h.slice(-13)):"type="===p.slice(0,5).toLowerCase()&&(k=p.slice(6,-1).toLowerCase()):"content-script"===m&&(g=p)}if("application/jet"===k){if(!h&&!g)return[a,""];c&&(!h&&e&&(b=c.deps.map(l=>l.request),h=y(d,e,"js",b)),c.deps.push({content:g,
12
- request:h}));return[a,'<script src="'+z("/",h)+'">\x3c/script>']}return n?[a,""]:[a,b.filter((l,m)=>1===m%2).join("")]}function K(a,b){u().href=b;a=v(a,D,H);r();return a}class L extends Promise{config(a){return this.then(b=>{Object.assign(b.config,a);return b})}save(a){return this.then(b=>{{const c=b.fragments;w(a)&&q.rmSync(a,{recursive:!0});for(let d in c){const e=c[d].content,f=z(a,d),g=(new B(f)).folder;w(g)||q.mkdirSync(g,{recursive:!0});q.writeFileSync(f,e)}}return b})}}
13
- class M{constructor(a,b,c,d){this.f=null;this.config=a;this.content=d;this.deps=[];this.root=this.request=this.path=this.name=this.module=this.mimeType=null;if("undefined"===typeof this.content)if(a=b.root,d=new B(c),!d.b()){d=z(a,c);d=x(d)?c.slice(1):null;if(!d){d=a;var e=new B(d);e=0<e.a.length&&""===e.a[0];var f=z(e?"":".",d,c);if(f=A(f)){const g=process.cwd().replace(/\\/g,"/");d=e?d:z(g,d);d=f.slice(d.length)}else d=null}if(this.request=d)this.root=a}else{if(d.b()){a:{if(a=A(c,{paths:[a]})){const [g,
14
- h]=N(a);if(h){d=require(h);a=[d.name+"@"+d.version,g,a.slice(g.length)];break a}}a=null}a&&([this.module,this.root,this.request]=a)}}else this.request="/"+c,this.root=b.root;if(this.request)this.name=z(this.module||b.name,this.request),this.config.namespace&&(this.f=this.config.namespace+":"+("./"===this.name.slice(0,2)?this.name.slice(2):this.name)),this.path=z(this.root,this.request),this.request="."+this.request,b=new B(this.request),this.folder=b.folder,this.mimeType=b.mimeType();else throw Error("Cannot find "+
15
- c);}b(){return-1<this.root.indexOf("node_modules/")}load(){this.content||(this.content=q.readFileSync(this.path,"utf8"))}parse(){if("text/html"===this.mimeType){var a=this.content,b=this.request;var c=u(this.root);c.name=(new B(b)).name;a=v(a,D,H);r();c=[a,c.deps];[this.content,this.deps]=c}else C(this.mimeType)&&(a=this.content,c=u(this.folder),a=v(a),r(),c=[a,c.deps],[this.content,this.deps]=c)}c(){return{content:this.content,deps:this.deps,mimeType:this.mimeType}}translate(a){if(C(this.mimeType)){var b=
16
- this.content;u().aliases=a;a=v(b,E,J);r();this.content=a}}}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 e=a.config,f=a.fragments,g=a.modules,h=a.namespaces;d=new M(e,b,c,d);const k=e.externs&&e.externs.indexOf(c)+1?c:d.f||d.name;b.set(c,k);if(!f[k]&&!g[k]){let n=!1;d.load();"jete"!==c&&d.parse();if(d.b()){g[k]={};c=d.module;const m=d.root;c&&(b=h.get(c)||h.create(c,m))}else f[k]={};const l=[];d.deps.length&&(n=!0,d.deps.forEach(m=>{if(!(e.module&&e.externs&&e.externs.indexOf(m)+1)){var p=null;"string"===typeof m?(p=b.get(m))||(p=Q(a,b,m)):m&&m.request&&(p=Q(a,b,m.request,m.content));
18
- l.push(p)}}),d.deps=l);n&&d.translate(b.aliases);d.b()?g[k]=d.c():f[k]=d.c()}return k}class R{constructor(a,b,c){this.content=[];this.deps=c;this.name=a;this.mimeType=b}c(){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.i={}}close(a){delete this[a]}get(a){this[a]||(this[a]={});return this[a]}has(a,b){a=this.get(a);return this.i[b]||a[b]}put(a,b){this.get(a)[b]=!0}}
20
- function U(a,b){const c=a.config,d=a.h;var e=a.modules;const f=a.register;var g=c.root;e=a.fragments[b]||e[b];if(!e)throw Error("Fragment not found "+b);var h=e.deps;const k=e.mimeType;if(!f.has(k,b)){const l=d.get(k)||d.create(b,k,"text/html"===k?h:[]);C(k)&&(e.content="require('"+b+"', function(module, exports) {\n"+e.content+"});\n",f["application/javascript"]!==f.i||l.name!==b||c.module||l.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"));
21
- f.put(k,b);h.forEach(m=>{var p;if(p="text/html"===k)p=0!==Object.keys(f["application/javascript"]).length;p&&(f.close("application/javascript"),d.close("application/javascript"));U(a,m)});if("text/html"===k&&(h=d.get("text/css"))){var {name:n}=new B(b);g=y(g,n,"css");n=z(".",g);e.content=K(e.content,g);l.deps.push(n);h.name=n}l.content.push(e.content);C(k)&&l.name===b&&!c.module&&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 {g:d,folder:e}=new B(a),f={config:{root:z(process.cwd(),e),entries:[d]},fragments:{},modules:{}};b(f)}catch(d){c(d)}})},pack:function(a){const b=a.config.entries,c=new S,d=new T;a.h=c;a.register=d;b.forEach(f=>U(a,f));const e={};c.getAll().forEach(f=>{const g=f.name;g&&(e[g]=f.c())});a.fragments=e;a.modules={};delete a.h;delete a.register;return a},parse:function(a){const b=a.config,c=b.entries,d=new P,e=d.create(".",b.root);a.namespaces=
23
- d;b.entries=c.map(f=>Q(a,e,f,""));delete a.namespaces;return a}};
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jetc",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "Jet.js Compiler and Server.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,6 +22,6 @@
22
22
  "author": "Oleksandr Krayilo",
23
23
  "license": "ISC",
24
24
  "dependencies": {
25
- "jeti": "^0.8.0"
25
+ "jeti": "^0.8.1"
26
26
  }
27
- }
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)}};