jetc 0.5.8 → 0.5.9
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/conf/build.js +1 -1
- package/index.js +20 -20
- package/package.json +2 -2
package/conf/build.js
CHANGED
package/index.js
CHANGED
|
@@ -2,26 +2,26 @@
|
|
|
2
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
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
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}
|
|
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={"single-string":"single-quote *((escape any) | !single-quote) single-quote"},
|
|
6
|
-
const
|
|
7
|
-
code:"compress |
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
path:h}));return[a,'<script src="'+z("/",h)+'">\x3c/script>']}return m?[a,""]:[a,b.filter((n,k)=>1===k%2).join("")]}function
|
|
15
|
-
function
|
|
16
|
-
class
|
|
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
|
+
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
|
+
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
|
+
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
|
+
"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
|
+
"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
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,
|
|
19
|
-
class
|
|
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
|
|
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
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
|
|
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
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=
|
|
25
|
-
function
|
|
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?L
|
|
27
|
-
d.map(f=>
|
|
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}};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jetc",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
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.
|
|
25
|
+
"jeti": "^0.8.6"
|
|
26
26
|
}
|
|
27
27
|
}
|