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.6.0 to 0.7.0

1

lib/build-content/jsx/attributes/build-prop.js

@@ -8,3 +8,2 @@ const singleProps = ["disabled", "checked", "readonly", "required", "hidden", "autofocus", "multiple", "selected", "controls", "loop", "muted", "open", "spellcheck", "draggable", "contenteditable", "novalidate"];

if (name === 'className') name = 'class'
name = name.toLowerCase()
if (singleProps.includes(name)) {

@@ -11,0 +10,0 @@ name = `\${${value} ? '${name}' : ''}`

33

lib/build-content/jsx/breckets.js
function getInsideBreckets(i, content) {
let count = 0, quote = null;
let count = 0;
const quotes = { '"':[],"'":[],"`":[] }
content.replace(/["'`]/g,(m,i) => {
if(content[i-1] !== '\\') quotes[m].push(i)
})
while (i < content.length) {
i++
if (quote === null && /["'`]/.test(content[i])) quote = content[i]
else if (quote) {
if (content[i] === quote && content[i - 1] !== '\\') quote = null
} else {
if (content[i] === '{') count++
else if (content[i] === '}') {
if (count > 0) count--
else break
const char = content[i]
if(count && quotes[char] && quotes[char].length) {
let next
for(const index of quotes[char]) {
if(index > i) {
next = index
break
}
}
if(next) {
i = next
quotes[char] = quotes[char].filter(index => index > i)
}
} else if (char === '{') count++
else if (char === '}') {
if (count > 0) count--
else break
}
i++;
}
i++
return i

@@ -18,0 +29,0 @@ }

function removeComments(code) {
return code
.replace(/\/\/.*(?=\n|$)/g, '') // Удаление однострочных комментариев
.replace(/\{?\/\*[\s\S]*?\*\/\}?/g, '') // Удаление многострочных комментариев
.replace(/\/\/(?![^'"]*['"][^'"]*$).*$(?=\n|$)/gm,'')
.replace(/\{?\/\*[\s\S]*?\*\/\}?/g, '')
}
module.exports = removeComments

@@ -18,4 +18,5 @@ function buildFn(fnBody,path) {

${keys.map((path, i) => buildFn(contents[path],path)).join('\n')}
modules['${keys[keys.length-1]}'](data)
const result = modules['${keys[keys.length-1]}'](data)
context.runActions()
return result
}`

@@ -22,0 +23,0 @@ return fn

{
"name": "als-render",
"version": "0.6.0",
"version": "0.7.0",
"main": "index.js",
"scripts": {
"test": "node --test --experimental-test-coverage",
"report": "node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info ./tests/index.test.js",
"readme":"node build-readme.js",
"build":"node build.js",
"todos":"node ./projects/build.js todos"
},
"keywords": [

@@ -21,3 +28,3 @@ "ALS-Render",

"dependencies": {
"als-require": "^1.2.0",
"als-require": "^1.3.1",
"uglify-js": "^3.18.0"

@@ -24,0 +31,0 @@ },

@@ -28,12 +28,23 @@ const Require = (function(){

if (nodeModules.length === 0) return content
for (const { match, modulePath } of nodeModules) {
for (let { match, modulePath } of nodeModules) {
let fullPath
if(modulePath.includes('/')) {
fullPath = `/node_modules/${modulePath}`
if(!fullPath.endsWith('.js')) fullPath += '.js'
modulePath = modulePath.split('/').shift()
}
const pkgJsonPath = `/node_modules/${modulePath}/package.json`
const exists = await fetch(pkgJsonPath, { method: 'HEAD' })
if (!exists.ok) {
content = content.replace(match, '')
if (exists.ok === false) {
const r = new RegExp(`require\\(["'\`]${modulePath}["'\`]\\)`)
content = content.replace(r, 'null')
console.warn(`The module "${modulePath}" can't be imported and will be replaced with null`)
continue
}
const { main: filename = 'index.js' } = await $fetch(pkgJsonPath, 'json')
const fullPath = `/node_modules/${modulePath}/${filename}`
if(!fullPath) {
const { main: filename = 'index.js' } = await $fetch(pkgJsonPath, 'json')
fullPath = `/node_modules/${modulePath}/${filename}`
}
isCyclyc(fullPath, modulePath)

@@ -66,5 +77,3 @@ children.push(fullPath);

contents[path] = content
for (let childPath of children) {
await getContent(childPath)
}
await Promise.all(children.map(childPath => getContent(childPath)))
}

@@ -328,4 +337,4 @@ await getContent(fullPath)

return code
.replace(/\/\/.*(?=\n|$)/g, '') // Удаление однострочных комментариев
.replace(/\{?\/\*[\s\S]*?\*\/\}?/g, '') // Удаление многострочных комментариев
.replace(/\/\/(?![^'"]*['"][^'"]*$).*$(?=\n|$)/gm,'')
.replace(/\{?\/\*[\s\S]*?\*\/\}?/g, '')
}

@@ -423,18 +432,48 @@

const exports = module.exports
// function getInsideBreckets(i, content) {
// let count = 0, quote = null;
// while (i < content.length) {
// i++;
// if (quote === null && /["'`]/.test(content[i])) quote = content[i]; // начало строки в кавычках
// else if (quote) {
// if (content[i] === quote && content[i - 1] !== '\\') quote = null; // конец строки в кавычках
// } else {
// if (content[i] === '{') count++
// else if (content[i] === '}') {
// if (count > 0) count--
// else break
// }
// }
// }
// i++
// return i
// }
function getInsideBreckets(i, content) {
let count = 0, quote = null;
let count = 0;
const quotes = { '"':[],"'":[],"`":[] }
content.replace(/["'`]/g,(m,i) => {
if(content[i-1] !== '\\') quotes[m].push(i)
})
while (i < content.length) {
i++
if (quote === null && /["'`]/.test(content[i])) quote = content[i]
else if (quote) {
if (content[i] === quote && content[i - 1] !== '\\') quote = null
} else {
if (content[i] === '{') count++
else if (content[i] === '}') {
if (count > 0) count--
else break
const char = content[i]
if(count && quotes[char] && quotes[char].length) {
let next
for(const index of quotes[char]) {
if(index > i) {
next = index
break
}
}
if(next) {
i = next
quotes[char] = quotes[char].filter(index => index > i)
}
} else if (char === '{') count++
else if (char === '}') {
if (count > 0) count--
else break
}
i++;
}
i++
return i

@@ -469,3 +508,2 @@ }

if (name === 'className') name = 'class'
name = name.toLowerCase()
if (singleProps.includes(name)) {

@@ -732,4 +770,4 @@ name = `\${${value} ? '${name}' : ''}`

} catch(error) {
parseError(error, {"/lib/context/component.js":{"from":4,"to":78},"/lib/context/context.js":{"from":79,"to":137},"/lib/build-content/remove-comments.js":{"from":138,"to":149},"/lib/build-content/build-component/get-function.js":{"from":150,"to":181},"/lib/build-content/build-component/index.js":{"from":182,"to":203},"/lib/build-content/jsx/outer.js":{"from":204,"to":233},"/lib/build-content/jsx/breckets.js":{"from":234,"to":258},"/lib/build-content/jsx/attributes/build-action.js":{"from":259,"to":271},"/lib/build-content/jsx/attributes/build-prop.js":{"from":272,"to":293},"/lib/build-content/jsx/attributes/get-attributes.js":{"from":294,"to":365},"/lib/build-content/jsx/element.js":{"from":366,"to":439},"/lib/build-content/jsx/jsx-parser.js":{"from":440,"to":467},"/lib/build-content/index.js":{"from":468,"to":484},"/lib/build.js":{"from":485,"to":511},"/lib/browser.js":{"from":512,"to":535}}, 535)
parseError(error, {"/lib/context/component.js":{"from":4,"to":78},"/lib/context/context.js":{"from":79,"to":137},"/lib/build-content/remove-comments.js":{"from":138,"to":149},"/lib/build-content/build-component/get-function.js":{"from":150,"to":181},"/lib/build-content/build-component/index.js":{"from":182,"to":203},"/lib/build-content/jsx/outer.js":{"from":204,"to":233},"/lib/build-content/jsx/breckets.js":{"from":234,"to":288},"/lib/build-content/jsx/attributes/build-action.js":{"from":289,"to":301},"/lib/build-content/jsx/attributes/build-prop.js":{"from":302,"to":322},"/lib/build-content/jsx/attributes/get-attributes.js":{"from":323,"to":394},"/lib/build-content/jsx/element.js":{"from":395,"to":468},"/lib/build-content/jsx/jsx-parser.js":{"from":469,"to":496},"/lib/build-content/index.js":{"from":497,"to":513},"/lib/build.js":{"from":514,"to":540},"/lib/browser.js":{"from":541,"to":564}}, 564)
}
})()

@@ -1,2 +0,2 @@

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

@@ -7,5 +7,5 @@ const exports = module.exports

})();`;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 i{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(i.components[o])return(s=i.components[o]).init(e,n),s;(i.components[o]=this).mounted=!1,this.name=o,this.selector=`[component=${this.name}]`,this.fn=i.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,i.context.runActions())}genHash(t){var e=i.genHash(t+this.name);return this.oldHash=this.hash,(i.componentsToUpdate[this.name]=this).hash=e,t}}return t.exports=i,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:i}=t;let e=document.querySelector(i),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:r}=l.components[e];document.querySelector(s)||(r.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){return t.replace(/\/\/.*(?=\n|$)/g,"").replace(/\{?\/\*[\s\S]*?\*\/\}?/g,"")},s.exports),e["/lib/build-content/build-component/get-function.js"]=((s={exports:{}}).exports=function(s,t){var e="[\\s\\S]*?",t=new RegExp(`^\\s*?function\\s*?${t}\\s*?\\(${e}\\)${e}{`,"m");if(!(e=s.match(t)))return null;let o=0,i;for(let n=e.index+e[0].length;n<s.length;n++){let t=s[n],e=s[n-1];if(t.match(/["'`]/)&&"\\"!==e)for(;e=s[n],s[++n]!==t&&"\\"!==e;);if("{"===t)o++;else if("}"===t)if(0<o)o--;else if(0===o){i=n+1;break}}return s.slice(e.index,i)},s.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=s(t,e);return null===n?t:t.replace(n,`function ${e}(props={},inner) {
return modules['${t}']`),s[t]={from:o+1},o+=n.split("\n").length,s[t].to=o,n}).join("\n");return{fn:new Function("modules",t,`function require(path) { return modules[path] || null };
`+e),modulesLines:s,curLastLine:o}})(r,this);try{return r(t,e)}catch(n){{r=n;var a=s;var i=o;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,s,e=Number(e[2]),o=Object.entries(a).filter(([,{from:t,to:e}])=>n>=t&&n<=e);if(0!==o.length)return[o,{from:r,to:s}]=o[0],` at ${t.match(/at\s(.*?)\s/)[1]} ${o} (${n-r-2}:${e})`}}}).filter(Boolean),r.stack=t+"\n"+e.join("\n"),r;return}}}}return s})(),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 i{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(i.components[o])return(s=i.components[o]).init(e,n),s;(i.components[o]=this).mounted=!1,this.name=o,this.selector=`[component=${this.name}]`,this.fn=i.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,i.context.runActions())}genHash(t){var e=i.genHash(t+this.name);return this.oldHash=this.hash,(i.componentsToUpdate[this.name]=this).hash=e,t}}return t.exports=i,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:i}=t;let e=document.querySelector(i),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:r}=l.components[e];document.querySelector(s)||(r.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){return t.replace(/\/\/(?![^'"]*['"][^'"]*$).*$(?=\n|$)/gm,"").replace(/\{?\/\*[\s\S]*?\*\/\}?/g,"")},s.exports),e["/lib/build-content/build-component/get-function.js"]=((s={exports:{}}).exports=function(s,t){var e="[\\s\\S]*?",t=new RegExp(`^\\s*?function\\s*?${t}\\s*?\\(${e}\\)${e}{`,"m");if(!(e=s.match(t)))return null;let o=0,i;for(let n=e.index+e[0].length;n<s.length;n++){let t=s[n],e=s[n-1];if(t.match(/["'`]/)&&"\\"!==e)for(;e=s[n],s[++n]!==t&&"\\"!==e;);if("{"===t)o++;else if("}"===t)if(0<o)o--;else if(0===o){i=n+1;break}}return s.slice(e.index,i)},s.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=s(t,e);return null===n?t:t.replace(n,`function ${e}(props={},inner) {
let originalFn = ${n}

@@ -17,3 +17,3 @@ const component = context.component('${e}',props,inner)

context.addComponentFn('${e}',${e})
`)},t.exports})(),e["/lib/build-content/jsx/outer.js"]=((s={exports:{}}).exports=function(t){let{tagName:e,selfClosed:n,attributes:s,props:o,isComponent:i,rest:r,inner:l}=t,u="";if(i){t=[...o,...s.map(([t,e])=>[t,'"'+e+'"'])].map(([t,e])=>t+":"+e);r&&t.push(r),o="{"+t.join(",")+"}",u="${"+`${e}(${o},\`${l}\`)`+"}"}else{if(""===e)return l||"";o=o.map(([t,e])=>[t,"${"+e+"}"]);t=[...s,...o].map(([t,e])=>e?t+`="${e}"`:t).join(" ");u=`<${e}${t.length?" "+t:""}>`,n||(u+=l+`</${e}>`)}return u},s.exports),e["/lib/build-content/jsx/breckets.js"]=((s={exports:{}}).exports=function(t,e){let n=0,s=null;for(;t<e.length;)if(t++,null===s&&/["'`]/.test(e[t]))s=e[t];else if(s)e[t]===s&&"\\"!==e[t-1]&&(s=null);else if("{"===e[t])n++;else if("}"===e[t]){if(!(0<n))break;n--}return++t},s.exports),e["/lib/build-content/jsx/attributes/build-action.js"]=((s={exports:{}}).exports=function(t,e){var[t,n]=t,t=t.split("on")[1].toLowerCase();e.attributes.push([t,"$"+`{this.addAction('${t}',${n})}`])},s.exports),e["/lib/build-content/jsx/attributes/build-prop.js"]=(()=>{var t={exports:{}};let i=["disabled","checked","readonly","required","hidden","autofocus","multiple","selected","controls","loop","muted","open","spellcheck","draggable","contenteditable","novalidate"],r=n("/lib/build-content/jsx/attributes/build-action.js");return t.exports=function(n,s,o){if(n){let[t,e]=n;t=(t="className"===t?"class":t).toLowerCase(),i.includes(t)?(t=`\${${e} ? '${t}' : ''}`,e=void 0,o.attributes.push([t])):"props"===s&&t.startsWith("on")?r(n,o):o[s].push([t,e])}},t.exports})(),e["/lib/build-content/jsx/attributes/get-attributes.js"]=(()=>{var t={exports:{}};let p=n("/lib/build-content/jsx/attributes/build-prop.js");return t.exports=function(t,e,s,o){let i="",r="",l=!0,u=!1,c,n=0;function a(t,e,n="attributes"){for(p(e,n,s),l=!0,u=!1,i="",r="",c=null;0===o[t].trim().length;)t++;return t}for(;">"!==t&&!(e>=o.length);){if(l)if("{"===t){for(;e<o.length&&"}"!==(t=o[++e]);)s.rest+=t;a(e)}else if("="===t||0===t.trim().length)0<i.length&&(l=!1,u=!0);else{if(">"===o[e+1]){"/"===t?s.selfClosed=!0:""!==i&&s.attributes.push([i+t]),e++;break}i+=t}else u&&(c?"{"===c?(r+=t,"{"===t?n++:"}"===t&&(0<n?n--:e=a(e,[i,r.slice(0,-1)],"props"))):"\\"!==o[e-1]&&t===c?e=a(e,[i,r]):r+=t:/["'`{]/.test(t)?c=t:/[a-zA-Z]/.test(t)&&(""!==i&&s.attributes.push([i]),l=!0,u=!1,i=t));">"===(t=o[++e])&&u&&(r+=t,t=o[++e])}return++e},t.exports})(),e["/lib/build-content/jsx/element.js"]=(()=>{var t={exports:{}};let s=n("/lib/build-content/jsx/attributes/get-attributes.js"),o=n("/lib/build-content/jsx/breckets.js"),e=n("/lib/build-content/jsx/outer.js");class i{tagName="";rest="";inner="";attributes=[];props=[];selfClosed=!1;constructor(t,e,n){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];n&&this.attributes.push(["component","${this.name}"]),this.i=s(t[e],e,this,t)}!1===this.selfClosed&&this.getInner(t)}get outer(){return e(this)}getInner(t){var e=`</${this.tagName}>`;let n=0;for(var s="</>"==e?"<>":"<"+this.tagName;this.i<t.length;){if(this.inner+=t[this.i],this.inner.endsWith(s)&&n++,this.inner.endsWith(e)){if(!(0<n)){this.inner=this.inner.slice(0,-e.length).trim();break}n--}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 n,s;"<"===this.inner[t]?(n=new i(this.inner,t),e+=n.outer,t=n.i):"{"===this.inner[t]?(n=t,t=o(t,this.inner),s=this.inner.slice(n,t),e+="$"+i.jsxParser(s)):e+=this.inner[t]}this.inner=e}}}return t.exports=i,t.exports})(),e["/lib/build-content/jsx/jsx-parser.js"]=(()=>{var t={exports:{}};let r=n("/lib/build-content/jsx/element.js");function e(e,n){let s="";for(let t=0;t<e.length;t++)if("("===e[t]){var o=t;for(t++;0===e[t].trim().length;)t++;if("<"===e[t]){var i=new r(e,t,n);for(t=i.i,s+="`"+i.outer+"`";")"!==e[t];)t++}else s+=e.slice(o,t+1)}else s+=e[t];return s}return r.jsxParser=e,t.exports=e,t.exports})(),e["/lib/build-content/index.js"]=(()=>{var t={exports:{}};let s=n("/lib/build-content/jsx/jsx-parser.js"),o=n("/lib/build-content/build-component/index.js"),i=n("/lib/build-content/remove-comments.js");return t.exports=function(t,e){var n=e.split("/").pop().replace(/\.js$/,""),e=`context.currentPath = '${e}';
`+s(i(t),n);return o(e,n)},t.exports})(),e["/lib/build.js"]=(()=>{var t={exports:{}};let c=n("/lib/build-content/index.js"),a=n("/lib/context/context.js");return t.exports=function(t,e="context",n,s){var o,i=new a(n,s);for(o in t.contents)t.contents[o]=c(t.contents[o],o);let r="";var{links:l,styles:u}=i;return{resultFn:t.build({},i,e),context:i,add:r=s&&!n||!s&&n?[...l.map(t=>`<link rel="stylesheet" href="${t}">`),u.length?`<style>${u.join("\n")}</style>`:""].filter(Boolean).join("\n")+"\n":r}},t.exports})(),e["/lib/browser.js"]=(()=>{var t={exports:{}};let i=n("/lib/build.js");return t.exports=async function(t,e="body",n={},s){await(t=new Require(t)).getContent();var{resultFn:t,context:s,add:o}=i(t,s,!0,!1);return s.data=n,e&&(e=document.querySelector(e))&&(e.innerHTML=o+t(n).trim(),s.runActions()),s},t.exports})(),e["/lib/browser.js"]}{var e;let s=new Function("return "+"{}")();(function t(e){for(var n in e)"function"==typeof e[n]&&e[n].name===Obj.recursiveName?e[n]=e[n](s):null!==e[n]&&"object"==typeof e[n]&&t(e[n])})(s),s}try{t({})}catch(n){{var s=n;var r={"/lib/context/component.js":{from:4,to:78},"/lib/context/context.js":{from:79,to:137},"/lib/build-content/remove-comments.js":{from:138,to:149},"/lib/build-content/build-component/get-function.js":{from:150,to:181},"/lib/build-content/build-component/index.js":{from:182,to:203},"/lib/build-content/jsx/outer.js":{from:204,to:233},"/lib/build-content/jsx/breckets.js":{from:234,to:258},"/lib/build-content/jsx/attributes/build-action.js":{from:259,to:271},"/lib/build-content/jsx/attributes/build-prop.js":{from:272,to:293},"/lib/build-content/jsx/attributes/get-attributes.js":{from:294,to:365},"/lib/build-content/jsx/element.js":{from:366,to:439},"/lib/build-content/jsx/jsx-parser.js":{from:440,to:467},"/lib/build-content/index.js":{from:468,to:484},"/lib/build.js":{from:485,to:511},"/lib/browser.js":{from:512,to:535}};var l=535;let[t,...e]=s.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!==l){var s,o,e=Number(e[2]),i=Object.entries(r).filter(([,{from:t,to:e}])=>n>=t&&n<=e);if(0!==i.length)return[i,{from:s,to:o}]=i[0],` at ${t.match(/at\s(.*?)\s/)[1]} ${i} (${n-s-2}:${e})`}}}).filter(Boolean),s.stack=t+"\n"+e.join("\n"),s;return}}})();
`)},t.exports})(),e["/lib/build-content/jsx/outer.js"]=((s={exports:{}}).exports=function(t){let{tagName:e,selfClosed:n,attributes:s,props:o,isComponent:i,rest:r,inner:l}=t,u="";if(i){t=[...o,...s.map(([t,e])=>[t,'"'+e+'"'])].map(([t,e])=>t+":"+e);r&&t.push(r),o="{"+t.join(",")+"}",u="${"+`${e}(${o},\`${l}\`)`+"}"}else{if(""===e)return l||"";o=o.map(([t,e])=>[t,"${"+e+"}"]);t=[...s,...o].map(([t,e])=>e?t+`="${e}"`:t).join(" ");u=`<${e}${t.length?" "+t:""}>`,n||(u+=l+`</${e}>`)}return u},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(t&&s[o]&&s[o].length){let t;for(var i of s[o])if(i>e){t=i;break}t&&(e=t,s[o]=s[o].filter(t=>e<t))}else if("{"===o)t++;else if("}"===o){if(!(0<t))break;t--}e++}return e},s.exports),e["/lib/build-content/jsx/attributes/build-action.js"]=((s={exports:{}}).exports=function(t,e){var[t,n]=t,t=t.split("on")[1].toLowerCase();e.attributes.push([t,"$"+`{this.addAction('${t}',${n})}`])},s.exports),e["/lib/build-content/jsx/attributes/build-prop.js"]=(()=>{var t={exports:{}};let i=["disabled","checked","readonly","required","hidden","autofocus","multiple","selected","controls","loop","muted","open","spellcheck","draggable","contenteditable","novalidate"],r=n("/lib/build-content/jsx/attributes/build-action.js");return t.exports=function(n,s,o){if(n){let[t,e]=n;"className"===t&&(t="class"),i.includes(t)?(t=`\${${e} ? '${t}' : ''}`,e=void 0,o.attributes.push([t])):"props"===s&&t.startsWith("on")?r(n,o):o[s].push([t,e])}},t.exports})(),e["/lib/build-content/jsx/attributes/get-attributes.js"]=(()=>{var t={exports:{}};let p=n("/lib/build-content/jsx/attributes/build-prop.js");return t.exports=function(t,e,s,o){let i="",r="",l=!0,u=!1,c,n=0;function a(t,e,n="attributes"){for(p(e,n,s),l=!0,u=!1,i="",r="",c=null;0===o[t].trim().length;)t++;return t}for(;">"!==t&&!(e>=o.length);){if(l)if("{"===t){for(;e<o.length&&"}"!==(t=o[++e]);)s.rest+=t;a(e)}else if("="===t||0===t.trim().length)0<i.length&&(l=!1,u=!0);else{if(">"===o[e+1]){"/"===t?s.selfClosed=!0:""!==i&&s.attributes.push([i+t]),e++;break}i+=t}else u&&(c?"{"===c?(r+=t,"{"===t?n++:"}"===t&&(0<n?n--:e=a(e,[i,r.slice(0,-1)],"props"))):"\\"!==o[e-1]&&t===c?e=a(e,[i,r]):r+=t:/["'`{]/.test(t)?c=t:/[a-zA-Z]/.test(t)&&(""!==i&&s.attributes.push([i]),l=!0,u=!1,i=t));">"===(t=o[++e])&&u&&(r+=t,t=o[++e])}return++e},t.exports})(),e["/lib/build-content/jsx/element.js"]=(()=>{var t={exports:{}};let s=n("/lib/build-content/jsx/attributes/get-attributes.js"),o=n("/lib/build-content/jsx/breckets.js"),e=n("/lib/build-content/jsx/outer.js");class i{tagName="";rest="";inner="";attributes=[];props=[];selfClosed=!1;constructor(t,e,n){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];n&&this.attributes.push(["component","${this.name}"]),this.i=s(t[e],e,this,t)}!1===this.selfClosed&&this.getInner(t)}get outer(){return e(this)}getInner(t){var e=`</${this.tagName}>`;let n=0;for(var s="</>"==e?"<>":"<"+this.tagName;this.i<t.length;){if(this.inner+=t[this.i],this.inner.endsWith(s)&&n++,this.inner.endsWith(e)){if(!(0<n)){this.inner=this.inner.slice(0,-e.length).trim();break}n--}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 n,s;"<"===this.inner[t]?(n=new i(this.inner,t),e+=n.outer,t=n.i):"{"===this.inner[t]?(n=t,t=o(t,this.inner),s=this.inner.slice(n,t),e+="$"+i.jsxParser(s)):e+=this.inner[t]}this.inner=e}}}return t.exports=i,t.exports})(),e["/lib/build-content/jsx/jsx-parser.js"]=(()=>{var t={exports:{}};let r=n("/lib/build-content/jsx/element.js");function e(e,n){let s="";for(let t=0;t<e.length;t++)if("("===e[t]){var o=t;for(t++;0===e[t].trim().length;)t++;if("<"===e[t]){var i=new r(e,t,n);for(t=i.i,s+="`"+i.outer+"`";")"!==e[t];)t++}else s+=e.slice(o,t+1)}else s+=e[t];return s}return r.jsxParser=e,t.exports=e,t.exports})(),e["/lib/build-content/index.js"]=(()=>{var t={exports:{}};let s=n("/lib/build-content/jsx/jsx-parser.js"),o=n("/lib/build-content/build-component/index.js"),i=n("/lib/build-content/remove-comments.js");return t.exports=function(t,e){var n=e.split("/").pop().replace(/\.js$/,""),e=`context.currentPath = '${e}';
`+s(i(t),n);return o(e,n)},t.exports})(),e["/lib/build.js"]=(()=>{var t={exports:{}};let c=n("/lib/build-content/index.js"),a=n("/lib/context/context.js");return t.exports=function(t,e="context",n,s){var o,i=new a(n,s);for(o in t.contents)t.contents[o]=c(t.contents[o],o);let r="";var{links:l,styles:u}=i;return{resultFn:t.build({},i,e),context:i,add:r=s&&!n||!s&&n?[...l.map(t=>`<link rel="stylesheet" href="${t}">`),u.length?`<style>${u.join("\n")}</style>`:""].filter(Boolean).join("\n")+"\n":r}},t.exports})(),e["/lib/browser.js"]=(()=>{var t={exports:{}};let i=n("/lib/build.js");return t.exports=async function(t,e="body",n={},s){await(t=new Require(t)).getContent();var{resultFn:t,context:s,add:o}=i(t,s,!0,!1);return s.data=n,e&&(e=document.querySelector(e))&&(e.innerHTML=o+t(n).trim(),s.runActions()),s},t.exports})(),e["/lib/browser.js"]}{var e;let s=new Function("return "+"{}")();(function t(e){for(var n in e)"function"==typeof e[n]&&e[n].name===Obj.recursiveName?e[n]=e[n](s):null!==e[n]&&"object"==typeof e[n]&&t(e[n])})(s),s}try{t({})}catch(n){{var s=n;var r={"/lib/context/component.js":{from:4,to:78},"/lib/context/context.js":{from:79,to:137},"/lib/build-content/remove-comments.js":{from:138,to:149},"/lib/build-content/build-component/get-function.js":{from:150,to:181},"/lib/build-content/build-component/index.js":{from:182,to:203},"/lib/build-content/jsx/outer.js":{from:204,to:233},"/lib/build-content/jsx/breckets.js":{from:234,to:288},"/lib/build-content/jsx/attributes/build-action.js":{from:289,to:301},"/lib/build-content/jsx/attributes/build-prop.js":{from:302,to:322},"/lib/build-content/jsx/attributes/get-attributes.js":{from:323,to:394},"/lib/build-content/jsx/element.js":{from:395,to:468},"/lib/build-content/jsx/jsx-parser.js":{from:469,to:496},"/lib/build-content/index.js":{from:497,to:513},"/lib/build.js":{from:514,to:540},"/lib/browser.js":{from:541,to:564}};var l=564;let[t,...e]=s.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!==l){var s,o,e=Number(e[2]),i=Object.entries(r).filter(([,{from:t,to:e}])=>n>=t&&n<=e);if(0!==i.length)return[i,{from:s,to:o}]=i[0],` at ${t.match(/at\s(.*?)\s/)[1]} ${i} (${n-s-2}:${e})`}}}).filter(Boolean),s.stack=t+"\n"+e.join("\n"),s;return}}})();

@@ -1,3 +0,7 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const getInsideBreckets = require('../lib/build-content/jsx/breckets');

@@ -44,5 +48,5 @@ describe('getInsideBreckets', () => {

const i = getInsideBreckets(0, content);
assert.strictEqual(i, content.length+1);
assert.strictEqual(i, content.length);
});
});

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const buildAction = require('../lib/build-content/jsx/attributes/build-action');

@@ -4,0 +9,0 @@ const Component = require('../lib/context/component')

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const buildProp = require('../lib/build-content/jsx/attributes/build-prop');

@@ -4,0 +9,0 @@

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const Element = require('../lib/build-content/jsx/element');

@@ -4,0 +9,0 @@ const jsxParser = require('../lib/build-content/jsx/jsx-parser')

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const getAttributes = require('../lib/build-content/jsx/attributes/get-attributes');

@@ -4,0 +9,0 @@ const Component = require('../lib/context/component')

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const getFunction = require('../lib/build-content/build-component/get-function');

@@ -4,0 +9,0 @@

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const jsxParser = require('../lib/build-content/jsx/jsx-parser');

@@ -4,0 +9,0 @@

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const getOuter = require('../lib/build-content/jsx/outer');

@@ -4,0 +9,0 @@

@@ -1,3 +0,8 @@

const { describe, it } = require('node:test');
const assert = require('node:assert');
try {
const { describe, it } = require('node:test');
global.describe = describe;
global.it = it
global.assert = require('node:assert');
} catch (error) {}
const removeComments = require('../lib/build-content/remove-comments');

@@ -4,0 +9,0 @@

Sorry, the diff of this file is not supported yet

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