als-render
Advanced tools
Comparing version 0.8.1 to 0.8.2
{ | ||
"name": "als-render", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"main": "index.js", | ||
@@ -28,3 +28,3 @@ "scripts": { | ||
"dependencies": { | ||
"als-require": "^1.5.0", | ||
"als-require": "^1.5.1", | ||
"uglify-js": "^3.18.0" | ||
@@ -31,0 +31,0 @@ }, |
const Require = (function(){ | ||
const packageJsonCache = {}; | ||
function isCyclyc(fullPath, path) { | ||
@@ -3,0 +4,0 @@ if (Require.contents[fullPath] && Require.contents[fullPath].children.includes(path)) { |
@@ -1,9 +0,9 @@ | ||
let Require=(()=>{function h(e,t){if(o.contents[e]&&o.contents[e].children.includes(t))throw`cyclic dependency between ${t} and `+e}function i(e,t){var n,e=e.split("/"),r=[];for(n of[...t.split("/").slice(0,-1),...e])".."===n?0<r.length&&".."!==r[r.length-1]?r.pop():r.push(n):"."!==n&&r.push(n);t=r.join("/");return t.endsWith(".js")?t:t+".js"}async function d(e,t="text"){e=await fetch(e);if(e.ok)return e[t]();throw new Error("HTTP error! status: "+e.status)}async function e({contents:n,fullPath:e},a){let r=async s=>{if(void 0===n[s]){if(!a.contents[s]){let e=await d(s),r=[],o=[];e=e.replace(/^(?!\/\/|\/\*.*\*\/).*require\(["'`](.*)["'`]\)/gm,(e,t)=>{var n;return t.startsWith(".")?(h(n=i(t,s),s),r.push(n),e.replace(t,n)):(o.push({match:e,modulePath:t}),e)}),e=await(async(e,o,s)=>{if(0!==e.length)for(var{match:a,modulePath:i}of e){let n,e,t,r=i;i.includes("/")&&(c=i.split("/"),r=c.shift(),e=c.join("/"));var c=`/node_modules/${r}/package.json`,l=await fetch(c,{method:"HEAD"}),u=new RegExp(`require\\((["'\`])${i}["'\`]\\)`);!1===l.ok?(s=s.replace(u,"{}"),console.warn(`The module "${i}" can't be imported and will be replaced with {}`)):(packageJsonCache[c]?t=packageJsonCache[c]:({main:l="index.js"}=await d(c,"json"),packageJsonCache[c]=l),(n=(n=e?((l=t.split("/")).pop(),`/node_modules/${r}/${l.join("/")}/`+e):`/node_modules/${r}/`+t).replace(/\/\.?\//g,"/")).endsWith(".js")||(n+=".js"),h(n,i),o.push(n),s=s.replace(a,a.replace(u,(e,t)=>`require(${t}${n}${t})`)))}return s})(o,r,e),a.contents[s]={content:e,children:r}}let{content:e,children:t}=a.contents[s];n[s]=e,await Promise.all(t.map(e=>r(e)))}};await r(e)}class o{static contents={};static async getModule(e,t,n,r){e=new o(e);return await e.getContent(),e.build(r,t,n)}constructor(e){this.contents={},this.path=e,this.fullPath=i(e,location.pathname),this.contentReady=!1}async getContent(){return this.contentReady||(await e(this,o),this.keys=((t,n)=>{let r=new Set,o=e=>{e.forEach(e=>{t[e]&&(o(n.contents[e].children),r.add(e))})};return o(Object.keys(t).reverse()),Array.from(r)})(this.contents,o),this.contentReady=!0),this}build(e={},t={},r="context"){var{fn:r,modulesLines:o,curLastLine:s}=((e="context",r)=>{let o={},s=3;var t=r.keys.map((e,t)=>{let n=`modules['${e}'] = (function (){ | ||
let Require=(()=>{let h={};function d(t,e){if(o.contents[t]&&o.contents[t].children.includes(e))throw`cyclic dependency between ${e} and `+t}function i(t,e){var n,t=t.split("/"),r=[];for(n of[...e.split("/").slice(0,-1),...t])".."===n?0<r.length&&".."!==r[r.length-1]?r.pop():r.push(n):"."!==n&&r.push(n);e=r.join("/");return e.endsWith(".js")?e:e+".js"}async function p(t,e="text"){t=await fetch(t);if(t.ok)return t[e]();throw new Error("HTTP error! status: "+t.status)}async function t({contents:n,fullPath:t},a){let r=async s=>{if(void 0===n[s]){if(!a.contents[s]){let t=await p(s),r=[],o=[];t=t.replace(/^(?!\/\/|\/\*.*\*\/).*require\(["'`](.*)["'`]\)/gm,(t,e)=>{var n;return e.startsWith(".")?(d(n=i(e,s),s),r.push(n),t.replace(e,n)):(o.push({match:t,modulePath:e}),t)}),t=await(async(t,o,s)=>{if(0!==t.length)for(var{match:a,modulePath:i}of t){let n,t,e,r=i;i.includes("/")&&(c=i.split("/"),r=c.shift(),t=c.join("/"));var c=`/node_modules/${r}/package.json`,l=await fetch(c,{method:"HEAD"}),u=new RegExp(`require\\((["'\`])${i}["'\`]\\)`);!1===l.ok?(s=s.replace(u,"{}"),console.warn(`The module "${i}" can't be imported and will be replaced with {}`)):(h[c]?e=h[c]:({main:l="index.js"}=await p(c,"json"),h[c]=l),(n=(n=t?((l=e.split("/")).pop(),`/node_modules/${r}/${l.join("/")}/`+t):`/node_modules/${r}/`+e).replace(/\/\.?\//g,"/")).endsWith(".js")||(n+=".js"),d(n,i),o.push(n),s=s.replace(a,a.replace(u,(t,e)=>`require(${e}${n}${e})`)))}return s})(o,r,t),a.contents[s]={content:t,children:r}}let{content:t,children:e}=a.contents[s];n[s]=t,await Promise.all(e.map(t=>r(t)))}};await r(t)}class o{static contents={};static async getModule(t,e,n,r){t=new o(t);return await t.getContent(),t.build(r,e,n)}constructor(t){this.contents={},this.path=t,this.fullPath=i(t,location.pathname),this.contentReady=!1}async getContent(){return this.contentReady||(await t(this,o),this.keys=((e,n)=>{let r=new Set,o=t=>{t.forEach(t=>{e[t]&&(o(n.contents[t].children),r.add(t))})};return o(Object.keys(e).reverse()),Array.from(r)})(this.contents,o),this.contentReady=!0),this}build(t={},e={},r="context"){var{fn:r,modulesLines:o,curLastLine:s}=((t="context",r)=>{let o={},s=3;var e=r.keys.map((t,e)=>{let n=`modules['${t}'] = (function (){ | ||
const module = { exports: {} } | ||
const exports = module.exports | ||
${r.contents[e]} | ||
${r.contents[t]} | ||
return module.exports; | ||
})();`;return t===r.keys.length-1&&(n+=` | ||
return modules['${e}']`),o[e]={from:s+1},s+=n.split("\n").length,o[e].to=s,n}).join("\n");return{fn:new Function("modules",e,`function require(path) { return modules[path] || null }; | ||
`+t),modulesLines:o,curLastLine:s}})(r,this);try{return r(e,t)}catch(n){{r=n;var a=o;var i=s;let[e,...t]=r.stack.split("\n");throw t=t.map(e=>{var t=e.match(/<anonymous>:(\d*):(\d*)\)$/);if(t){let n=Number(t[1]);if(n+1!==i){var r,o,t=Number(t[2]),s=Object.entries(a).filter(([,{from:e,to:t}])=>n>=e&&n<=t);if(0!==s.length)return[s,{from:r,to:o}]=s[0],` at ${e.match(/at\s(.*?)\s/)[1]} ${s} (${n-r-2}:${t})`}}}).filter(Boolean),r.stack=e+"\n"+t.join("\n"),r;return}}}}return o})(),require=Require.getModule; | ||
})();`;return e===r.keys.length-1&&(n+=` | ||
return modules['${t}']`),o[t]={from:s+1},s+=n.split("\n").length,o[t].to=s,n}).join("\n");return{fn:new Function("modules",t,`function require(path) { return modules[path] || null }; | ||
`+e),modulesLines:o,curLastLine:s}})(r,this);try{return r(t,e)}catch(n){{r=n;var a=o;var i=s;let[t,...e]=r.stack.split("\n");throw e=e.map(t=>{var e=t.match(/<anonymous>:(\d*):(\d*)\)$/);if(e){let n=Number(e[1]);if(n+1!==i){var r,o,e=Number(e[2]),s=Object.entries(a).filter(([,{from:t,to:e}])=>n>=t&&n<=e);if(0!==s.length)return[s,{from:r,to:o}]=s[0],` at ${t.match(/at\s(.*?)\s/)[1]} ${s} (${n-r-2}:${e})`}}}).filter(Boolean),r.stack=t+"\n"+e.join("\n"),r;return}}}}return o})(),require=Require.getModule; | ||
const render = (()=>{function t(e,t){function n(t){return e[t]||null}var s;return e["/lib/context/component.js"]=(()=>{var t={exports:{}};class r{static fns={};static components={};static componentsToUpdate={};static genHash(t){t=(new TextEncoder).encode(t);let e=0,n=0;var s,o=[t=>(e+=t,1),t=>(e-=t,0)];for(s of t)n=o[n](s);return e}constructor(t,e={},n){var s,{key:o=""}=e,o=t+o;if(r.components[o])return(s=r.components[o]).init(e,n),s;(r.components[o]=this).mounted=!1,this.name=o,this.selector=`[component=${this.name}]`,this.fn=r.fns[t],this.init()}init(t,e){this.actions=[],this.counter=0,this.props=t,this.inner=e,this.hooks={mount:[()=>this.mounted=!0],unmount:[]}}addAction(t,e){var n=this.name+this.counter++;return this.actions.push({event:t,id:n,fn:e}),n}on(t,e){this.hooks[t]&&this.hooks[t].push(e)}update(t=this.props,e=this.inner){this.props=t,this.inner=e;var n=document.querySelector(this.selector);n&&this.fn&&(t=this.fn(t,e,this),this.hash!==this.oldHash)&&(n.outerHTML=t,r.context.runActions())}genHash(t){var e=r.genHash(t+this.name);return this.oldHash=this.hash,(r.componentsToUpdate[this.name]=this).hash=e,t}}return t.exports=r,t.exports})(),e["/lib/context/context.js"]=(()=>{var t={exports:{}};let l=n("/lib/context/component.js");return t.exports=class{links=[];styles=[];counter=0;constructor(t=!0,e=!1){(l.context=this).browser=t,this.ssr=e}addComponentFn(t,e){l.fns[t]=e}component(t,e,n){return new l(t,e,n)}style(t){this.styles.push(t)}runActions(){for(var t in l.componentsToUpdate){var t=l.componentsToUpdate[t],{actions:n,hooks:o,selector:r}=t;let e=document.querySelector(r),s=e||document;o.mount.forEach(t=>t(e)),n.forEach(({event:t,fn:e,id:n})=>{n=s.querySelector(`[${t}="${n}"]`);n&&("load"===t?e(n):n.addEventListener(t,e))}),t.actions=[],o.mount=[]}for(var e in l.components){var{selector:s,hooks:i}=l.components[e];document.querySelector(s)||(i.unmount.forEach(t=>t()),delete l.components[e])}l.componentsToUpdate={}}link(t){let e=this.currentPath.split("/");e.pop(),t.split("/").forEach(t=>{".."===t?e.pop():"."!==t&&e.push(t)}),this.links.push(e.join("/"))}},t.exports})(),e["/lib/build-content/remove-comments.js"]=((s={exports:{}}).exports=function(t){let s=/`.*?\/\/.*?`|".*?\/\/.*?"|'.*?\/\/.*?'/;return t.replace(/^(.*)(\/\/.*)($|\n)/gm,(t,e,n)=>{n=(e+n).match(s);return n&&n.index<e.length?t:e}).replace(/\{?\/\*[\s\S]*?\*\/\}?/gm,"")},s.exports),e["/lib/build-content/jsx/breckets.js"]=((s={exports:{}}).exports=function(e,n){let t=0,s={'"':[],"'":[],"`":[]};for(n.replace(/["'`]/g,(t,e)=>{"\\"!==n[e-1]&&s[t].push(e)});e<n.length;){var o=n[++e];if(s[o]&&s[o].length){let t;for(var r of s[o])if(r>e){t=r;break}t&&(e=t,s[o]=s[o].filter(t=>e<t))}else if("{"===o)t++;else if("}"===o){if(!(0<t))break;t--}}return e+1},s.exports),e["/lib/build-content/build-component/get-function.js"]=(()=>{var t={exports:{}};let s=n("/lib/build-content/jsx/breckets.js");return t.exports=function(t,e){var n="[\\s\\S]*?",e=new RegExp(`^\\s*?function\\s*?${e}\\s*?\\(${n}\\)${n}{`,"m");return(n=t.match(e))?(e=n.index+n[0].length,e=s(e,t),t.slice(n.index,e)):null},t.exports})(),e["/lib/build-content/build-component/index.js"]=(()=>{var t={exports:{}};let s=n("/lib/build-content/build-component/get-function.js");return t.exports=function(t,e){var n;return!1===/[A-Z]/.test(e[0])||null===(n=s(t,e))?t:t.replace(n,`function ${e}(props={},inner) { | ||
@@ -10,0 +10,0 @@ let originalFn = ${n} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2104
128197
Updatedals-require@^1.5.1