jetc 0.5.3 → 0.5.4
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/index.js +4 -4
- package/license.txt +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -19,8 +19,8 @@ function Y(a,b,c,d,e){const f=a.config,g=a.fragments,h=a.modules,l=a.namespaces;
|
|
|
19
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
20
|
class ea{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 fa{constructor(){this.all=[]}close(a){this[a]&&delete this[a]}create(a,b,c){this[b]=new ea(a,b,c);this.all.push(this[b]);return this[b]}get(a){return this[a]}getAll(){return this.all}}
|
|
21
21
|
class ha{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");
|
|
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=>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");
|
|
23
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=V(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 ia(a,b){const c
|
|
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,"text/css"===e?K:J,P).trim()});return a},entry:function(a){return new W((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.
|
|
26
|
-
c=new fa,d=new ha;a.c=c;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 da,e=d.create(".",b.root);a.namespaces=d;b.entries=c.map(f=>Y(a,e,f));delete a.namespaces;return a}};
|
|
24
|
+
function ia(a,b,c){const d=c[b];if(!F(d.mimeType))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.mimeType&&(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}
|
|
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,"text/css"===e?K:J,P).trim()});return a},entry:function(a){return new W((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");
|
|
26
|
+
d.map(f=>ia(e,f,c));return a},pack:function(a){const b=a.config.entries,c=new fa,d=new ha;a.c=c;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 da,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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jetc",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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.3"
|
|
26
26
|
}
|
|
27
27
|
}
|