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

@rallie/load-html

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rallie/load-html - npm Package Compare versions

Comparing version 0.15.1 to 0.16.0

2

./dist/index.umd.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RallieImportHtml={})}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(o,l){function i(t){try{s(r.next(t))}catch(t){l(t)}}function c(t){try{s(r.throw(t))}catch(t){l(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,c)}s((r=r.apply(t,e||[])).next())}))}const n=t=>`[@rallie/load-html] ${t}`,r=/^(http:\/\/|https:\/\/|\/\/)([^?#]*)(\?[^?#]+)?(#.+)?/,o=t=>n(`Invalid html path: ${t}`),l=(t,e)=>n(`Can not construct a url by the base '${t}' and the path '${e}'`),i=t=>{const e=Array.from(t.attributes),n=document.createElement(t.tagName);return e.forEach((t=>{n.setAttribute(t.name,t.value)})),n.innerHTML=t.innerHTML,n},c=(t={})=>(n,c)=>e(void 0,void 0,void 0,(function*(){var s;const a=null!==(s=t.fetch)&&void 0!==s?s:window.fetch;n.loadHtml=c=>e(void 0,void 0,void 0,(function*(){var e,s;const u=null!==(s=null!==(e=n.regardHtmlPathAsRoot)&&void 0!==e?e:t.regardHtmlPathAsRoot)&&void 0!==s&&s,d=yield a(c),f=yield d.text(),[h,m]=(t=>{const e=r.exec(t);if(e)return[e[0],e[4]||null];throw new Error(o(t))})(c),{root:p,scripts:y,links:v,styles:A}=((t,e,n)=>{const r=document.createElement("html");r.innerHTML=t;const o=Array.from(r.querySelectorAll("script")).map((t=>i(t))).map((t=>{const e=t.getAttribute("src");return n&&e&&t.setAttribute("src",n(e)),t})),l=Array.from(r.querySelectorAll("link")).map((t=>i(t))).map((t=>{const e=t.getAttribute("href");return n&&e&&t.setAttribute("href",n(e)),t})),c=Array.from(r.querySelectorAll("style")).map((t=>i(t)));return{root:e?r.querySelector(e):null,scripts:o,links:l,styles:c}})(f,m,(t=>((t,e,n=!1)=>{if(/^(http:\/\/|https:\/\/|\/\/).+/.test(t))return t;const o=r.exec(e);if(o){const e=o[1],r=o[2];n&&t.startsWith("/")&&(t=t.slice(1));let l="";return l=new URL(t,("//"===e?"http://":e)+r).href,"//"===e&&(l=l.slice(5)),l}return console.error(l(e,t)),""})(t,h,u)));for(const t of A)document.head.appendChild(t);for(const t of v)n.loadLink(t);if(p){const t=document.querySelector(m);t?t.innerHTML=p.innerHTML:document.body.appendChild(p)}for(const t of y)yield n.loadScript(t);return!!(y.length+v.length+A.length)||!!p}));const u=(t.entries||{})[n.name];u?yield n.loadHtml(u):yield c()}));t.default=c,t.loadHtml=c,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RallieImportHtml={})}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(o,l){function i(t){try{s(r.next(t))}catch(t){l(t)}}function c(t){try{s(r.throw(t))}catch(t){l(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,c)}s((r=r.apply(t,e||[])).next())}))}const n=t=>`[@rallie/load-html] ${t}`,r=/^(http:\/\/|https:\/\/|\/\/)([^?#]*)(\?[^?#]+)?(#.+)?/,o=t=>n(`Invalid html path: ${t}`),l=(t,e)=>n(`Can not construct a url by the base '${t}' and the path '${e}'`),i=t=>{const e=Array.from(t.attributes),n=document.createElement(t.tagName);return e.forEach((t=>{n.setAttribute(t.name,t.value)})),n.innerHTML=t.innerHTML,n},c=(t={})=>(n,c)=>e(void 0,void 0,void 0,(function*(){var s;const a=null!==(s=t.fetch)&&void 0!==s?s:window.fetch,u=t.filter;n.loadHtml=c=>e(void 0,void 0,void 0,(function*(){var e;const s=null!==(e=t.regardHtmlPathAsRoot)&&void 0!==e&&e,f=yield a(c),d=yield f.text(),[h,m]=(t=>{const e=r.exec(t);if(e)return[e[0],e[4]||null];throw new Error(o(t))})(c),{root:p,scripts:y,links:v,styles:b}=((t,e,n,r=(()=>!0))=>{const o=document.createElement("html");o.innerHTML=t;const l=Array.from(o.querySelectorAll("script")).filter(r).map((t=>i(t))).map((t=>{const e=t.getAttribute("src");return n&&e&&t.setAttribute("src",n(e)),t})),c=Array.from(o.querySelectorAll("link")).filter(r).map((t=>i(t))).map((t=>{const e=t.getAttribute("href");return n&&e&&t.setAttribute("href",n(e)),t})),s=Array.from(o.querySelectorAll("style")).filter(r).map((t=>i(t)));return{root:e?o.querySelector(e):null,scripts:l,links:c,styles:s}})(d,m,(t=>((t,e,n=!1)=>{if(/^(http:\/\/|https:\/\/|\/\/).+/.test(t))return t;const o=r.exec(e);if(o){const e=o[1],r=o[2];n&&t.startsWith("/")&&(t=t.slice(1));let l="";return l=new URL(t,("//"===e?"http://":e)+r).href,"//"===e&&(l=l.slice(5)),l}return console.error(l(e,t)),""})(t,h,s)),u);for(const t of b)document.head.appendChild(t);for(const t of v)n.loadLink(t);if(p){const t=document.querySelector(m);t?t.innerHTML=p.innerHTML:document.body.appendChild(p)}for(const t of y)yield n.loadScript(t);return!!(y.length+v.length+b.length)||!!p}));const f=(t.entries||{})[n.name];f?yield n.loadHtml(f):yield c()}));t.default=c,t.loadHtml=c,Object.defineProperty(t,"__esModule",{value:!0})}));

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

function t(t,e,r,n){return new(r||(r=Promise))((function(o,l){function c(t){try{a(n.next(t))}catch(t){l(t)}}function i(t){try{a(n.throw(t))}catch(t){l(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(c,i)}a((n=n.apply(t,e||[])).next())}))}const e=t=>`[@rallie/load-html] ${t}`,r=/^(http:\/\/|https:\/\/|\/\/)([^?#]*)(\?[^?#]+)?(#.+)?/,n=t=>e(`Invalid html path: ${t}`),o=(t,r)=>e(`Can not construct a url by the base '${t}' and the path '${r}'`),l=t=>{const e=Array.from(t.attributes),r=document.createElement(t.tagName);return e.forEach((t=>{r.setAttribute(t.name,t.value)})),r.innerHTML=t.innerHTML,r},c=(e={})=>(c,i)=>t(void 0,void 0,void 0,(function*(){var a;const s=null!==(a=e.fetch)&&void 0!==a?a:window.fetch;c.loadHtml=i=>t(void 0,void 0,void 0,(function*(){var t,a;const u=null!==(a=null!==(t=c.regardHtmlPathAsRoot)&&void 0!==t?t:e.regardHtmlPathAsRoot)&&void 0!==a&&a,d=yield s(i),h=yield d.text(),[f,m]=(t=>{const e=r.exec(t);if(e)return[e[0],e[4]||null];throw new Error(n(t))})(i),{root:p,scripts:y,links:v,styles:A}=((t,e,r)=>{const n=document.createElement("html");n.innerHTML=t;const o=Array.from(n.querySelectorAll("script")).map((t=>l(t))).map((t=>{const e=t.getAttribute("src");return r&&e&&t.setAttribute("src",r(e)),t})),c=Array.from(n.querySelectorAll("link")).map((t=>l(t))).map((t=>{const e=t.getAttribute("href");return r&&e&&t.setAttribute("href",r(e)),t})),i=Array.from(n.querySelectorAll("style")).map((t=>l(t)));return{root:e?n.querySelector(e):null,scripts:o,links:c,styles:i}})(h,m,(t=>((t,e,n=!1)=>{if(/^(http:\/\/|https:\/\/|\/\/).+/.test(t))return t;const l=r.exec(e);if(l){const e=l[1],r=l[2];n&&t.startsWith("/")&&(t=t.slice(1));let o="";return o=new URL(t,("//"===e?"http://":e)+r).href,"//"===e&&(o=o.slice(5)),o}return console.error(o(e,t)),""})(t,f,u)));for(const t of A)document.head.appendChild(t);for(const t of v)c.loadLink(t);if(p){const t=document.querySelector(m);t?t.innerHTML=p.innerHTML:document.body.appendChild(p)}for(const t of y)yield c.loadScript(t);return!!(y.length+v.length+A.length)||!!p}));const u=(e.entries||{})[c.name];u?yield c.loadHtml(u):yield i()}));export{c as default,c as loadHtml};
function t(t,e,r,n){return new(r||(r=Promise))((function(o,l){function i(t){try{s(n.next(t))}catch(t){l(t)}}function c(t){try{s(n.throw(t))}catch(t){l(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,c)}s((n=n.apply(t,e||[])).next())}))}const e=t=>`[@rallie/load-html] ${t}`,r=/^(http:\/\/|https:\/\/|\/\/)([^?#]*)(\?[^?#]+)?(#.+)?/,n=t=>e(`Invalid html path: ${t}`),o=(t,r)=>e(`Can not construct a url by the base '${t}' and the path '${r}'`),l=t=>{const e=Array.from(t.attributes),r=document.createElement(t.tagName);return e.forEach((t=>{r.setAttribute(t.name,t.value)})),r.innerHTML=t.innerHTML,r},i=(e={})=>(i,c)=>t(void 0,void 0,void 0,(function*(){var s;const a=null!==(s=e.fetch)&&void 0!==s?s:window.fetch,u=e.filter;i.loadHtml=c=>t(void 0,void 0,void 0,(function*(){var t;const s=null!==(t=e.regardHtmlPathAsRoot)&&void 0!==t&&t,d=yield a(c),f=yield d.text(),[h,m]=(t=>{const e=r.exec(t);if(e)return[e[0],e[4]||null];throw new Error(n(t))})(c),{root:p,scripts:y,links:v,styles:A}=((t,e,r,n=(()=>!0))=>{const o=document.createElement("html");o.innerHTML=t;const i=Array.from(o.querySelectorAll("script")).filter(n).map((t=>l(t))).map((t=>{const e=t.getAttribute("src");return r&&e&&t.setAttribute("src",r(e)),t})),c=Array.from(o.querySelectorAll("link")).filter(n).map((t=>l(t))).map((t=>{const e=t.getAttribute("href");return r&&e&&t.setAttribute("href",r(e)),t})),s=Array.from(o.querySelectorAll("style")).filter(n).map((t=>l(t)));return{root:e?o.querySelector(e):null,scripts:i,links:c,styles:s}})(f,m,(t=>((t,e,n=!1)=>{if(/^(http:\/\/|https:\/\/|\/\/).+/.test(t))return t;const l=r.exec(e);if(l){const e=l[1],r=l[2];n&&t.startsWith("/")&&(t=t.slice(1));let o="";return o=new URL(t,("//"===e?"http://":e)+r).href,"//"===e&&(o=o.slice(5)),o}return console.error(o(e,t)),""})(t,h,s)),u);for(const t of A)document.head.appendChild(t);for(const t of v)i.loadLink(t);if(p){const t=document.querySelector(m);t?t.innerHTML=p.innerHTML:document.body.appendChild(p)}for(const t of y)yield i.loadScript(t);return!!(y.length+v.length+A.length)||!!p}));const d=(e.entries||{})[i.name];d?yield i.loadHtml(d):yield c()}));export{i as default,i as loadHtml};

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RallieImportHtml={})}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(o,l){function i(t){try{s(r.next(t))}catch(t){l(t)}}function c(t){try{s(r.throw(t))}catch(t){l(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,c)}s((r=r.apply(t,e||[])).next())}))}const n=t=>`[@rallie/load-html] ${t}`,r=/^(http:\/\/|https:\/\/|\/\/)([^?#]*)(\?[^?#]+)?(#.+)?/,o=t=>n(`Invalid html path: ${t}`),l=(t,e)=>n(`Can not construct a url by the base '${t}' and the path '${e}'`),i=t=>{const e=Array.from(t.attributes),n=document.createElement(t.tagName);return e.forEach((t=>{n.setAttribute(t.name,t.value)})),n.innerHTML=t.innerHTML,n},c=(t={})=>(n,c)=>e(void 0,void 0,void 0,(function*(){var s;const a=null!==(s=t.fetch)&&void 0!==s?s:window.fetch;n.loadHtml=c=>e(void 0,void 0,void 0,(function*(){var e,s;const u=null!==(s=null!==(e=n.regardHtmlPathAsRoot)&&void 0!==e?e:t.regardHtmlPathAsRoot)&&void 0!==s&&s,d=yield a(c),f=yield d.text(),[h,m]=(t=>{const e=r.exec(t);if(e)return[e[0],e[4]||null];throw new Error(o(t))})(c),{root:p,scripts:y,links:v,styles:A}=((t,e,n)=>{const r=document.createElement("html");r.innerHTML=t;const o=Array.from(r.querySelectorAll("script")).map((t=>i(t))).map((t=>{const e=t.getAttribute("src");return n&&e&&t.setAttribute("src",n(e)),t})),l=Array.from(r.querySelectorAll("link")).map((t=>i(t))).map((t=>{const e=t.getAttribute("href");return n&&e&&t.setAttribute("href",n(e)),t})),c=Array.from(r.querySelectorAll("style")).map((t=>i(t)));return{root:e?r.querySelector(e):null,scripts:o,links:l,styles:c}})(f,m,(t=>((t,e,n=!1)=>{if(/^(http:\/\/|https:\/\/|\/\/).+/.test(t))return t;const o=r.exec(e);if(o){const e=o[1],r=o[2];n&&t.startsWith("/")&&(t=t.slice(1));let l="";return l=new URL(t,("//"===e?"http://":e)+r).href,"//"===e&&(l=l.slice(5)),l}return console.error(l(e,t)),""})(t,h,u)));for(const t of A)document.head.appendChild(t);for(const t of v)n.loadLink(t);if(p){const t=document.querySelector(m);t?t.innerHTML=p.innerHTML:document.body.appendChild(p)}for(const t of y)yield n.loadScript(t);return!!(y.length+v.length+A.length)||!!p}));const u=(t.entries||{})[n.name];u?yield n.loadHtml(u):yield c()}));t.default=c,t.loadHtml=c,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RallieImportHtml={})}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(o,l){function i(t){try{s(r.next(t))}catch(t){l(t)}}function c(t){try{s(r.throw(t))}catch(t){l(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,c)}s((r=r.apply(t,e||[])).next())}))}const n=t=>`[@rallie/load-html] ${t}`,r=/^(http:\/\/|https:\/\/|\/\/)([^?#]*)(\?[^?#]+)?(#.+)?/,o=t=>n(`Invalid html path: ${t}`),l=(t,e)=>n(`Can not construct a url by the base '${t}' and the path '${e}'`),i=t=>{const e=Array.from(t.attributes),n=document.createElement(t.tagName);return e.forEach((t=>{n.setAttribute(t.name,t.value)})),n.innerHTML=t.innerHTML,n},c=(t={})=>(n,c)=>e(void 0,void 0,void 0,(function*(){var s;const a=null!==(s=t.fetch)&&void 0!==s?s:window.fetch,u=t.filter;n.loadHtml=c=>e(void 0,void 0,void 0,(function*(){var e;const s=null!==(e=t.regardHtmlPathAsRoot)&&void 0!==e&&e,f=yield a(c),d=yield f.text(),[h,m]=(t=>{const e=r.exec(t);if(e)return[e[0],e[4]||null];throw new Error(o(t))})(c),{root:p,scripts:y,links:v,styles:b}=((t,e,n,r=(()=>!0))=>{const o=document.createElement("html");o.innerHTML=t;const l=Array.from(o.querySelectorAll("script")).filter(r).map((t=>i(t))).map((t=>{const e=t.getAttribute("src");return n&&e&&t.setAttribute("src",n(e)),t})),c=Array.from(o.querySelectorAll("link")).filter(r).map((t=>i(t))).map((t=>{const e=t.getAttribute("href");return n&&e&&t.setAttribute("href",n(e)),t})),s=Array.from(o.querySelectorAll("style")).filter(r).map((t=>i(t)));return{root:e?o.querySelector(e):null,scripts:l,links:c,styles:s}})(d,m,(t=>((t,e,n=!1)=>{if(/^(http:\/\/|https:\/\/|\/\/).+/.test(t))return t;const o=r.exec(e);if(o){const e=o[1],r=o[2];n&&t.startsWith("/")&&(t=t.slice(1));let l="";return l=new URL(t,("//"===e?"http://":e)+r).href,"//"===e&&(l=l.slice(5)),l}return console.error(l(e,t)),""})(t,h,s)),u);for(const t of b)document.head.appendChild(t);for(const t of v)n.loadLink(t);if(p){const t=document.querySelector(m);t?t.innerHTML=p.innerHTML:document.body.appendChild(p)}for(const t of y)yield n.loadScript(t);return!!(y.length+v.length+b.length)||!!p}));const f=(t.entries||{})[n.name];f?yield n.loadHtml(f):yield c()}));t.default=c,t.loadHtml=c,Object.defineProperty(t,"__esModule",{value:!0})}));

@@ -6,3 +6,4 @@ import { MiddlewareFnType } from '@rallie/core';

entries?: Record<string, string>;
filter?: (element: HTMLElement) => boolean;
};
export declare const loadHtml: (config?: Config) => MiddlewareFnType;

@@ -7,3 +7,3 @@ export declare const errors: {

export declare const parseHtmlPath: (base: string) => [string, string];
export declare const parseHtml: (html: string, rootSelector?: string, transferPath?: (src: string) => string) => {
export declare const parseHtml: (html: string, rootSelector?: string, transferPath?: (src: string) => string, filter?: (element: HTMLElement) => boolean) => {
root?: HTMLElement;

@@ -10,0 +10,0 @@ scripts: Array<HTMLScriptElement>;

{
"name": "@rallie/load-html",
"version": "0.15.1",
"version": "0.16.0",
"description": "a middleware to load resources from html",

@@ -25,5 +25,5 @@ "main": "./dist/index.umd.js",

"devDependencies": {
"@rallie/core": "0.15.1"
"@rallie/core": "0.16.0"
},
"gitHead": "c5fbcc7792b5f673ba54ca35b7460d8da2c29b14"
"gitHead": "a7d26f83e61f737148896b61eae9ad18a25036fb"
}
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