Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

als-render

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

als-render - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

2

lib/context/component.js

@@ -68,3 +68,3 @@ class Component {

if(newHtml instanceof Promise) newHtml.then(html => this.publish(element,html))
else this.publish(element,html)
else this.publish(element,newHtml)
}

@@ -71,0 +71,0 @@

{
"name": "als-render",
"version": "0.9.1",
"version": "0.9.2",
"main": "index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -624,3 +624,3 @@ const Require = (function(){

if(newHtml instanceof Promise) newHtml.then(html => this.publish(element,html))
else this.publish(element,html)
else this.publish(element,newHtml)
}

@@ -627,0 +627,0 @@

@@ -17,3 +17,3 @@ let Require=(()=>{let d={};function a(t,e){var n,t=t.split("/"),s=[];for(n of[...e.split("/").slice(0,-1),...t])".."===n?0<s.length&&".."!==s[s.length-1]?s.pop():s.push(n):"."!==n&&s.push(n);e=s.join("/");return e.endsWith(".js")?e:e+".js"}async function t({contents:n,fullPath:t},i){let s=async o=>{if(void 0===n[o]){if(!i.contents[o]){let t=await i.fetch(o),s=[],r=[];t=t.replace(/^(?!\/\/|\/\*.*\*\/).*require\(["'`](.*)["'`]\)/gm,(t,e)=>{var n;return e.startsWith(".")?(n=a(e,o),i.isCyclyc(n,o),s.push(n),t.replace(e,n)):(r.push({match:t,modulePath:e}),t)}),t=await(async(t,r,o,i)=>{if(0!==t.length)for(var{match:a,modulePath:c}of t){let n,t,e,s=c;c.includes("/")&&(l=c.split("/"),s=l.shift(),t=l.join("/"));var l=`/node_modules/${s}/package.json`,u=await fetch(l,{method:"HEAD"}),h=new RegExp(`require\\((["'\`])${c}["'\`]\\)`);!1===u.ok?(o=o.replace(h,"{}"),console.warn(`The module "${c}" can't be imported and will be replaced with {}`)):(e=d[l]||({main:u="index.js"}=await i.fetch(l,"json"),d[l]=u),(n=(n=t?((u=e.split("/")).pop(),`/node_modules/${s}/${u.join("/")}/`+t):`/node_modules/${s}/`+e).replace(/\/\.?\//g,"/")).endsWith(".js")||(n+=".js"),i.isCyclyc(n,c),r.push(n),o=o.replace(a,a.replace(h,(t,e)=>`require(${e}${n}${e})`)))}return o})(r,s,t,i),i.contents[o]={content:t,children:s}}let{content:t,children:e}=i.contents[o];n[o]=t,await Promise.all(e.map(t=>s(t)))}};await s(t)}class r{static contents={};static version;static isCyclyc(t,e){if(this.contents[t]&&this.contents[t].children.includes(e))throw`cyclic dependency between ${e} and `+t}static async fetch(t,e="text"){this.version&&(t+="?version="+this.version);t=await fetch(t);return t.ok||console.error("HTTP error! status: "+t.status),t[e]()}static async getModule(t,e,n,s){t=new r(t);return await t.getContent(),t.build(s,e,n)}constructor(t){this.contents={},this.path=t,this.fullPath=a(t,location.pathname),this.contentReady=!1}async getContent(){return this.contentReady||(await t(this,r),this.keys=((e,n)=>{let s=new Set,r=t=>{t.forEach(t=>{e[t]&&(r(n.contents[t].children),s.add(t))})};return r(Object.keys(e).reverse()),Array.from(s)})(this.contents,r),this.contentReady=!0),this}build(t={},e={},s="context"){var{fn:s,modulesLines:r,curLastLine:o}=((t="context",s)=>{let r={},o=3;var e=s.keys.map((t,e)=>{let n=`modules['${t}'] = (function (){

context.addComponentFn('${e}',${e})
`))},t.exports})(),e["/lib/jsx/outer.js"]=((n={exports:{}}).exports=function(t){let{tagName:e,selfClosed:s,attributes:n,props:r,isComponent:o,rest:i,inner:l}=t,a="";if(o){t=[...r,...n.map(([t,e])=>[t,'"'+e+'"'])].map(([t,e])=>t+":"+e);i&&t.push(i),r="{"+t.join(",")+"}",a="${"+`${e}(${r},\`${l}\`)`+"}"}else{if(""===e)return l||"";r=r.map(([t,e])=>[t,"${"+e+"}"]);t=[...n,...r].map(([t,e])=>e?`${t}="${e.replace(/\"/g,'\\"')}"`:t).join(" ");a=`<${e}${t.length?" "+t:""}>`,s||(a+=l+`</${e}>`)}return a},n.exports),e["/lib/jsx/attributes/build-action.js"]=((n={exports:{}}).exports=function(t,e){var[t,s]=t,t=t.split("on")[1].toLowerCase();e.attributes.push([t,"$"+`{this.addAction('${t}',${s})}`])},n.exports),e["/lib/jsx/attributes/build-prop.js"]=(()=>{var t={exports:{}};let o=["disabled","checked","readonly","required","hidden","autofocus","multiple","selected","controls","loop","muted","open","spellcheck","draggable","contenteditable","novalidate"],i=s("/lib/jsx/attributes/build-action.js");return t.exports=function(s,n,r){if(s){let[t,e]=s;"className"===t&&(t="class"),o.includes(t)?(e&&(t=`\${${e} ? '${t}' : ''}`),r.attributes.push([t])):"props"===n&&t.startsWith("on")?i(s,r):r[n].push([t,e])}},t.exports})(),e["/lib/jsx/attributes/get-attributes.js"]=(()=>{var t={exports:{}};let p=s("/lib/jsx/attributes/build-prop.js");return t.exports=function(t,e,n,r){let o="",i="",l=!0,a=!1,u,s=0;function c(t,e,s="attributes"){for(p(e,s,n),l=!0,a=!1,o="",i="",u=null;0===r[t].trim().length;)t++;return t}for(;">"!==t&&!(e>=r.length);){if(l)if("{"===t){for(;e<r.length&&"}"!==(t=r[++e]);)n.rest+=t;c(e)}else if("="===t||0===t.trim().length)0<o.length&&(" "===t&&"="!==r[e+1]?(n.attributes.push([o]),o=""):(l=!1,a=!0));else{if(">"===r[e+1]){"/"===t?n.selfClosed=!0:""!==o&&n.attributes.push([o+t]),e++;break}o+=t}else a&&(u?"{"===u?(i+=t,"{"===t?s++:"}"===t&&(0<s?s--:e=c(e,[o,i.slice(0,-1)],"props"))):"\\"!==r[e-1]&&t===u?e=c(e,[o,i]):i+=t:/["'`{]/.test(t)?u=t:/[a-zA-Z]/.test(t)&&(""!==o&&n.attributes.push([o]),l=!0,a=!1,o=t));">"===(t=r[++e])&&a&&(i+=t,t=r[++e])}return++e},t.exports})(),e["/lib/jsx/element.js"]=(()=>{var t={exports:{}};let n=s("/lib/jsx/attributes/get-attributes.js"),r=s("/lib/jsx/breckets.js"),e=s("/lib/jsx/outer.js");class o{tagName="";rest="";inner="";attributes=[];props=[];selfClosed=!1;constructor(t,e,s){if(">"===t[e+1])this.isComponent=!1,this.tagName="",this.i=e+2;else{for(this.isComponent=/[A-Z]/.test(t[e+1]);e<t.length&&!1!==/[A-Za-z0-9.]/.test(t[++e]);)this.tagName+=t[e];s&&this.attributes.push(["component","${this.name}"]),this.i=n(t[e],e,this,t)}!1===this.selfClosed&&this.getInner(t)}get outer(){return e(this)}getInner(t){var e=`</${this.tagName}>`;let s=0;for(var n="</>"==e?"<>":"<"+this.tagName;this.i<t.length;){if(this.inner+=t[this.i],this.inner.endsWith(n)&&s++,this.inner.endsWith(e)){if(!(0<s)){this.inner=this.inner.slice(0,-e.length).trim();break}s--}this.i++}this.buildInner()}buildInner(){let e="";if(!(this.inner.trim().length<2)&&(this.inner.includes("<")||this.inner.includes("{"))){for(let t=0;t<this.inner.length;t++){var s,n;"<"===this.inner[t]?(s=new o(this.inner,t),e+=s.outer,t=s.i):"{"===this.inner[t]?(s=t,t=r(t,this.inner),n=this.inner.slice(s,t+1),e+="$"+o.jsxParser(n)):e+=this.inner[t]}this.inner=e}}}return t.exports=o,t.exports})(),e["/lib/jsx/jsx-parser.js"]=(()=>{var t={exports:{}};let i=s("/lib/jsx/element.js");function e(e,s){let n="";for(let t=0;t<e.length;t++)if("("===e[t]){var r=t;for(t++;0===e[t].trim().length;)t++;if("<"===e[t]){var o=new i(e,t,s);for(t=o.i,n+="`"+o.outer+"`";")"!==e[t];)t++}else n+=e.slice(r,t+1)}else n+=e[t];return n}return i.jsxParser=e,t.exports=e,t.exports})(),e["/lib/context/component.js"]=(()=>{var t={exports:{}};class o{static fns={};static components={};static componentsToUpdate={};static genHash(t){t=(new TextEncoder).encode(t);let e=0,s=0;var n,r=[t=>(e+=t,1),t=>(e-=t,0)];for(n of t)s=r[s](n);return e}constructor(t,e={},s){var n,{key:r=""}=e,r=t+r;if(o.components[r])return(n=o.components[r]).init(e,s),n;(o.components[r]=this).mounted=!1,this.name=r,this.selector=`[component=${this.name}]`,this.fn=o.fns[t],this.hash,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 s=this.name+this.counter++;return this.actions.push({event:t,id:s,fn:e}),s}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 s=document.querySelector(this.selector);s&&this.fn&&(t=this.fn(t,e,this),this.hash!==this.oldHash)&&(s.outerHTML=t,o.context.runActions())}update(t=this.props,e=this.inner){this.props=t,this.inner=e;let s=document.querySelector(this.selector);s&&this.fn&&((t=this.fn(t,e,this))instanceof Promise?t.then(t=>this.publish(s,t)):this.publish(s,html))}publish(t,e){var s=o.genHash(e+this.name);this.hash!==s&&(t.outerHTML=e,o.context.runActions(),this.hash=s)}add(t){return o.componentsToUpdate[this.name]=this,t}}return t.exports=o,t.exports})(),e["/lib/context/context.js"]=(()=>{var t={exports:{}};let l=s("/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,s){return new l(t,e,s)}style(t){this.styles.push(t)}runActions(){for(var t in l.componentsToUpdate){var t=l.componentsToUpdate[t],{actions:s,hooks:r,selector:o}=t;let e=document.querySelector(o),n=e||document;r.mount.forEach(t=>t(e)),s.forEach(({event:t,fn:e,id:s})=>{s=n.querySelector(`[${t}="${s}"]`);s&&("load"===t?e(s):s.addEventListener(t,e))}),t.actions=[],r.mount=[]}for(var e in l.components){var{selector:n,hooks:i}=l.components[e];document.querySelector(n)||(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.js"]=(()=>{var t={exports:{}};let p=s("/lib/context/context.js"),h=s("/lib/jsx/jsx-parser.js"),m=s("/lib/build-component/index.js"),b=s("/lib/utils/remove-comments.js");return t.exports=function(t,e="context",s,n){var r,o=new p(s,n);for(r in t.contents){var i=r.split("/").pop().replace(/\.js$/,""),l=`context.currentPath = '${r}';
`))},t.exports})(),e["/lib/jsx/outer.js"]=((n={exports:{}}).exports=function(t){let{tagName:e,selfClosed:s,attributes:n,props:r,isComponent:o,rest:i,inner:l}=t,a="";if(o){t=[...r,...n.map(([t,e])=>[t,'"'+e+'"'])].map(([t,e])=>t+":"+e);i&&t.push(i),r="{"+t.join(",")+"}",a="${"+`${e}(${r},\`${l}\`)`+"}"}else{if(""===e)return l||"";r=r.map(([t,e])=>[t,"${"+e+"}"]);t=[...n,...r].map(([t,e])=>e?`${t}="${e.replace(/\"/g,'\\"')}"`:t).join(" ");a=`<${e}${t.length?" "+t:""}>`,s||(a+=l+`</${e}>`)}return a},n.exports),e["/lib/jsx/attributes/build-action.js"]=((n={exports:{}}).exports=function(t,e){var[t,s]=t,t=t.split("on")[1].toLowerCase();e.attributes.push([t,"$"+`{this.addAction('${t}',${s})}`])},n.exports),e["/lib/jsx/attributes/build-prop.js"]=(()=>{var t={exports:{}};let o=["disabled","checked","readonly","required","hidden","autofocus","multiple","selected","controls","loop","muted","open","spellcheck","draggable","contenteditable","novalidate"],i=s("/lib/jsx/attributes/build-action.js");return t.exports=function(s,n,r){if(s){let[t,e]=s;"className"===t&&(t="class"),o.includes(t)?(e&&(t=`\${${e} ? '${t}' : ''}`),r.attributes.push([t])):"props"===n&&t.startsWith("on")?i(s,r):r[n].push([t,e])}},t.exports})(),e["/lib/jsx/attributes/get-attributes.js"]=(()=>{var t={exports:{}};let p=s("/lib/jsx/attributes/build-prop.js");return t.exports=function(t,e,n,r){let o="",i="",l=!0,a=!1,u,s=0;function c(t,e,s="attributes"){for(p(e,s,n),l=!0,a=!1,o="",i="",u=null;0===r[t].trim().length;)t++;return t}for(;">"!==t&&!(e>=r.length);){if(l)if("{"===t){for(;e<r.length&&"}"!==(t=r[++e]);)n.rest+=t;c(e)}else if("="===t||0===t.trim().length)0<o.length&&(" "===t&&"="!==r[e+1]?(n.attributes.push([o]),o=""):(l=!1,a=!0));else{if(">"===r[e+1]){"/"===t?n.selfClosed=!0:""!==o&&n.attributes.push([o+t]),e++;break}o+=t}else a&&(u?"{"===u?(i+=t,"{"===t?s++:"}"===t&&(0<s?s--:e=c(e,[o,i.slice(0,-1)],"props"))):"\\"!==r[e-1]&&t===u?e=c(e,[o,i]):i+=t:/["'`{]/.test(t)?u=t:/[a-zA-Z]/.test(t)&&(""!==o&&n.attributes.push([o]),l=!0,a=!1,o=t));">"===(t=r[++e])&&a&&(i+=t,t=r[++e])}return++e},t.exports})(),e["/lib/jsx/element.js"]=(()=>{var t={exports:{}};let n=s("/lib/jsx/attributes/get-attributes.js"),r=s("/lib/jsx/breckets.js"),e=s("/lib/jsx/outer.js");class o{tagName="";rest="";inner="";attributes=[];props=[];selfClosed=!1;constructor(t,e,s){if(">"===t[e+1])this.isComponent=!1,this.tagName="",this.i=e+2;else{for(this.isComponent=/[A-Z]/.test(t[e+1]);e<t.length&&!1!==/[A-Za-z0-9.]/.test(t[++e]);)this.tagName+=t[e];s&&this.attributes.push(["component","${this.name}"]),this.i=n(t[e],e,this,t)}!1===this.selfClosed&&this.getInner(t)}get outer(){return e(this)}getInner(t){var e=`</${this.tagName}>`;let s=0;for(var n="</>"==e?"<>":"<"+this.tagName;this.i<t.length;){if(this.inner+=t[this.i],this.inner.endsWith(n)&&s++,this.inner.endsWith(e)){if(!(0<s)){this.inner=this.inner.slice(0,-e.length).trim();break}s--}this.i++}this.buildInner()}buildInner(){let e="";if(!(this.inner.trim().length<2)&&(this.inner.includes("<")||this.inner.includes("{"))){for(let t=0;t<this.inner.length;t++){var s,n;"<"===this.inner[t]?(s=new o(this.inner,t),e+=s.outer,t=s.i):"{"===this.inner[t]?(s=t,t=r(t,this.inner),n=this.inner.slice(s,t+1),e+="$"+o.jsxParser(n)):e+=this.inner[t]}this.inner=e}}}return t.exports=o,t.exports})(),e["/lib/jsx/jsx-parser.js"]=(()=>{var t={exports:{}};let i=s("/lib/jsx/element.js");function e(e,s){let n="";for(let t=0;t<e.length;t++)if("("===e[t]){var r=t;for(t++;0===e[t].trim().length;)t++;if("<"===e[t]){var o=new i(e,t,s);for(t=o.i,n+="`"+o.outer+"`";")"!==e[t];)t++}else n+=e.slice(r,t+1)}else n+=e[t];return n}return i.jsxParser=e,t.exports=e,t.exports})(),e["/lib/context/component.js"]=(()=>{var t={exports:{}};class o{static fns={};static components={};static componentsToUpdate={};static genHash(t){t=(new TextEncoder).encode(t);let e=0,s=0;var n,r=[t=>(e+=t,1),t=>(e-=t,0)];for(n of t)s=r[s](n);return e}constructor(t,e={},s){var n,{key:r=""}=e,r=t+r;if(o.components[r])return(n=o.components[r]).init(e,s),n;(o.components[r]=this).mounted=!1,this.name=r,this.selector=`[component=${this.name}]`,this.fn=o.fns[t],this.hash,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 s=this.name+this.counter++;return this.actions.push({event:t,id:s,fn:e}),s}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 s=document.querySelector(this.selector);s&&this.fn&&(t=this.fn(t,e,this),this.hash!==this.oldHash)&&(s.outerHTML=t,o.context.runActions())}update(t=this.props,e=this.inner){this.props=t,this.inner=e;let s=document.querySelector(this.selector);s&&this.fn&&((t=this.fn(t,e,this))instanceof Promise?t.then(t=>this.publish(s,t)):this.publish(s,t))}publish(t,e){var s=o.genHash(e+this.name);this.hash!==s&&(t.outerHTML=e,o.context.runActions(),this.hash=s)}add(t){return o.componentsToUpdate[this.name]=this,t}}return t.exports=o,t.exports})(),e["/lib/context/context.js"]=(()=>{var t={exports:{}};let l=s("/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,s){return new l(t,e,s)}style(t){this.styles.push(t)}runActions(){for(var t in l.componentsToUpdate){var t=l.componentsToUpdate[t],{actions:s,hooks:r,selector:o}=t;let e=document.querySelector(o),n=e||document;r.mount.forEach(t=>t(e)),s.forEach(({event:t,fn:e,id:s})=>{s=n.querySelector(`[${t}="${s}"]`);s&&("load"===t?e(s):s.addEventListener(t,e))}),t.actions=[],r.mount=[]}for(var e in l.components){var{selector:n,hooks:i}=l.components[e];document.querySelector(n)||(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.js"]=(()=>{var t={exports:{}};let p=s("/lib/context/context.js"),h=s("/lib/jsx/jsx-parser.js"),m=s("/lib/build-component/index.js"),b=s("/lib/utils/remove-comments.js");return t.exports=function(t,e="context",s,n){var r,o=new p(s,n);for(r in t.contents){var i=r.split("/").pop().replace(/\.js$/,""),l=`context.currentPath = '${r}';
`+h(b(t.contents[r]),i);t.contents[r]=m(l,i)}let a="";var{links:u,styles:c}=o;return{resultFn:t.build({},o,e),context:o,add:a=n&&!s||!n&&s?[...u.map(t=>`<link rel="stylesheet" href="${t}">`),c.length?`<style>${c.join("\n")}</style>`:""].filter(Boolean).join("\n")+"\n":a}},t.exports})(),e["/lib/browser.js"]=(()=>{var t={exports:{}};let o=s("/lib/build.js");return t.exports=async function(t,e={},s={}){var{selector:s="body",contextName:n,version:r}=s;Require.version=r;await(r=new Require(t)).getContent();var{resultFn:t,context:r,add:n}=o(r,n,!0,!1);return r.data=e,s&&(s=document.querySelector(s))&&(t=await t(e),s.innerHTML=n+t.trim(),r.runActions()),r},t.exports})(),e["/lib/browser.js"]}{var e;let n=new Function("return "+"{}")();(function t(e){for(var s in e)"function"==typeof e[s]&&e[s].name===Obj.recursiveName?e[s]=e[s](n):null!==e[s]&&"object"==typeof e[s]&&t(e[s])})(n),n}try{t({})}catch(s){{var n=s;var i={"/lib/utils/remove-comments.js":{from:4,to:20},"/lib/jsx/breckets.js":{from:21,to:56},"/lib/build-component/get-function.js":{from:57,to:75},"/lib/build-component/index.js":{from:76,to:100},"/lib/jsx/outer.js":{from:101,to:131},"/lib/jsx/attributes/build-action.js":{from:132,to:144},"/lib/jsx/attributes/build-prop.js":{from:145,to:164},"/lib/jsx/attributes/get-attributes.js":{from:165,to:241},"/lib/jsx/element.js":{from:242,to:314},"/lib/jsx/jsx-parser.js":{from:315,to:342},"/lib/context/component.js":{from:343,to:432},"/lib/context/context.js":{from:433,to:491},"/lib/build.js":{from:492,to:523},"/lib/browser.js":{from:524,to:550}};var l=550;let[t,...e]=n.stack.split("\n");throw e=e.map(t=>{var e=t.match(/<anonymous>:(\d*):(\d*)\)$/);if(e){let s=Number(e[1]);if(s+1!==l){var n,r,e=Number(e[2]),o=Object.entries(i).filter(([,{from:t,to:e}])=>s>=t&&s<=e);if(0!==o.length)return[o,{from:n,to:r}]=o[0],` at ${t.match(/at\s(.*?)\s/)[1]} ${o} (${s-n-2}:${e})`}}}).filter(Boolean),n.stack=t+"\n"+e.join("\n"),n;return}}})();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc