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

@xiee/utils

Package Overview
Dependencies
Maintainers
1
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xiee/utils - npm Package Compare versions

Comparing version 1.13.20 to 1.13.21

13

js/pages.js

@@ -6,2 +6,3 @@ // move elements into page boxes such that each box contains as many elements as

function $$(s, el = d) { return el ? el.querySelectorAll(s) : []; }
function nChild(el) { return el.childElementCount; }

@@ -31,3 +32,3 @@ const tpl = d.createElement('div'), book = $$('h1').length > 1;

// if current element is not empty, fill its content into the box
if (el.childElementCount > 3) {
if (nChild(el) > 3) {
box_body.append(...[...el.children].slice(3));

@@ -44,3 +45,3 @@ // TODO: should we fragment this page if it's too long?

// if there's more than one child in the box, move the last child to next box
box_body2.childElementCount > 1 && box_body.append(box_body2.lastElementChild);
nChild(box_body2) > 1 && box_body.append(box_body2.lastChild);
}

@@ -59,7 +60,7 @@ box_body.append(el);

// for DIVs containing a single child (e.g., #TOC > ul), try to break the child
if (el.tagName === 'DIV' && el.childElementCount === 1) {
if (el.tagName === 'DIV' && nChild(el) === 1) {
fragment(el.firstElementChild, el2, el, box_cur);
}
// keep moving el's first item to el2 until page height > H
if (['UL', 'BLOCKQUOTE'].indexOf(el.tagName) > -1 && el.childElementCount > 1) while (true) {
if (['UL', 'BLOCKQUOTE'].indexOf(el.tagName) > -1 && nChild(el) > 1) while (true) {
const item = el.firstChild;

@@ -69,4 +70,4 @@ if (!item) break;

if (box_cur.scrollHeight > H) {
// move item back to el, only if the clone el2 is not the only element on page
el2.previousElementSibling && el.insertBefore(item, el.firstChild);
// move item back to el if the clone el2 is not the only element on page or has more than one child
(el2.previousElementSibling || nChild(el2) > 1) && el.insertBefore(item, el.firstChild);
break;

@@ -73,0 +74,0 @@ }

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

(e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}const r=e.createElement("div"),a=n("h1").length>1;r.className="pagesjs-page",r.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let s,i,o,l=[];function c(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",r.innerHTML),s=e||r.cloneNode(!0),i=s.children[1],l.length&&s.classList.add(...l),s}function d(e){if(!e)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function f(e){if(e.classList.contains("pagesjs-page"))return s.after(c(e)),void(e.childElementCount>3&&(i.append(...[...e.children].slice(3)),s.after(c())));if(s.scrollHeight>o){const[e,t]=[s,i];e.after(c()),t.childElementCount>1&&i.append(t.lastElementChild)}i.append(e),p(e)}function p(e,t,n,r){if(s.scrollHeight<=o)return;const a=r||s,l=e.cloneNode();if(t?t.append(l):(i.append(l),a.after(c()),i.append(e)),"DIV"===e.tagName&&1===e.childElementCount&&p(e.firstElementChild,l,e,a),["UL","BLOCKQUOTE"].indexOf(e.tagName)>-1&&e.childElementCount>1)for(;;){const t=e.firstChild;if(!t)break;if(l.append(t),a.scrollHeight>o){l.previousElementSibling&&e.insertBefore(t,e.firstChild);break}}l.lastChild||l.remove(),p(t?n:e)}function g(e){return e&&(e.dataset.shortTitle||e.innerText)}const h=g(t("h1.title, .frontmatter h1, .title, h1")),u=(a?"h1":"h2")+":not(.frontmatter *)",m=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));function b(){const r=e.body.classList;if(r.contains("pagesjs"))return;r.add("pagesjs"),a&&r.add("page-book"),e.body.insertAdjacentElement("afterbegin",c()),o=s.clientHeight||window.innerHeight,n(":is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side").forEach((e=>{e.classList.remove("side","side-left","side-right")})),r.add("pagesjs-filling"),n(".frontmatter, #TOC, .abstract").forEach((e=>(f(e),a&&s.after(c())))),n(".body").forEach((e=>{l=["chapter","appendix"].filter((t=>e.classList.contains(t))),a&&(""===s.innerText?c(s):s.after(c())),[...e.children].map(f),d(e.parentNode),d(e)})),r.remove("pagesjs-filling"),n('#TOC a[href^="#"]').forEach((t=>{const n=e.createElement("span"),r=t.firstElementChild;for(r?.classList.contains("section-number")?r.after(n):t.insertAdjacentElement("afterbegin",n);n.nextSibling;)n.append(n.nextSibling);t.insertAdjacentHTML("beforeend",'<span class="dot-leader"></span>'),t.dataset.pageNumber="000"}));let i,p=0;n(".pagesjs-page").forEach((e=>{if(d(e))return;if(a){if(t(".frontmatter",e))return;t(u,e)&&(i="")}const r=function(e){let t=+e.dataset.pagesOffset;if(t)return t;const r=e.scrollHeight;if(t=Math.ceil(r/o),t<=1)return t;const a=m.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!a)return t;function s(){return Math.ceil((r+(t-1)*a)/o)}let i=s();for(;i>t;)t=i,i=s();return t}(e);r>1&&e.classList.add("page-multiple"),p+=r;const s={pageNumber:p,mainTitle:h,pageTitle:i};let l;[e.children[0],e.children[2]].forEach((e=>{for(const t in s)s[t]&&(e.dataset[t]=s[t])})),i=g([...n(u,e)].pop())||i,n(".footnotes",e).forEach(((t,n)=>{0===n?(l=t,e.children[1].after(t)):(l.append(...t.children),t.remove())}))})),n('#TOC a[href^="#"]').forEach((e=>{const n=t(`.pagesjs-page:has(${e.getAttribute("href")}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}))}addEventListener("beforeprint",b);let E=sessionStorage.getItem("pagesjs");E&&b(),addEventListener("keypress",(e=>"p"===e.key&&(b(),E=E?"":"1",sessionStorage.setItem("pagesjs",E),E||location.reload())))})(document);
(e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}function r(e){return e.childElementCount}const a=e.createElement("div"),s=n("h1").length>1;a.className="pagesjs-page",a.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let i,o,c,l=[];function d(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",a.innerHTML),i=e||a.cloneNode(!0),o=i.children[1],l.length&&i.classList.add(...l),i}function f(e){if(!e)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function p(e){if(e.classList.contains("pagesjs-page"))return i.after(d(e)),void(r(e)>3&&(o.append(...[...e.children].slice(3)),i.after(d())));if(i.scrollHeight>c){const[e,t]=[i,o];e.after(d()),r(t)>1&&o.append(t.lastChild)}o.append(e),g(e)}function g(e,t,n,a){if(i.scrollHeight<=c)return;const s=a||i,l=e.cloneNode();if(t?t.append(l):(o.append(l),s.after(d()),o.append(e)),"DIV"===e.tagName&&1===r(e)&&g(e.firstElementChild,l,e,s),["UL","BLOCKQUOTE"].indexOf(e.tagName)>-1&&r(e)>1)for(;;){const t=e.firstChild;if(!t)break;if(l.append(t),s.scrollHeight>c){(l.previousElementSibling||r(l)>1)&&e.insertBefore(t,e.firstChild);break}}l.lastChild||l.remove(),g(t?n:e)}function h(e){return e&&(e.dataset.shortTitle||e.innerText)}const u=h(t("h1.title, .frontmatter h1, .title, h1")),m=(s?"h1":"h2")+":not(.frontmatter *)",b=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));function E(){const r=e.body.classList;if(r.contains("pagesjs"))return;r.add("pagesjs"),s&&r.add("page-book"),e.body.insertAdjacentElement("afterbegin",d()),c=i.clientHeight||window.innerHeight,n(":is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side").forEach((e=>{e.classList.remove("side","side-left","side-right")})),r.add("pagesjs-filling"),n(".frontmatter, #TOC, .abstract").forEach((e=>(p(e),s&&i.after(d())))),n(".body").forEach((e=>{l=["chapter","appendix"].filter((t=>e.classList.contains(t))),s&&(""===i.innerText?d(i):i.after(d())),[...e.children].map(p),f(e.parentNode),f(e)})),r.remove("pagesjs-filling"),n('#TOC a[href^="#"]').forEach((t=>{const n=e.createElement("span"),r=t.firstElementChild;for(r?.classList.contains("section-number")?r.after(n):t.insertAdjacentElement("afterbegin",n);n.nextSibling;)n.append(n.nextSibling);t.insertAdjacentHTML("beforeend",'<span class="dot-leader"></span>'),t.dataset.pageNumber="000"}));let a,o=0;n(".pagesjs-page").forEach((e=>{if(f(e))return;if(s){if(t(".frontmatter",e))return;t(m,e)&&(a="")}const r=function(e){let t=+e.dataset.pagesOffset;if(t)return t;const r=e.scrollHeight;if(t=Math.ceil(r/c),t<=1)return t;const a=b.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!a)return t;function s(){return Math.ceil((r+(t-1)*a)/c)}let i=s();for(;i>t;)t=i,i=s();return t}(e);r>1&&e.classList.add("page-multiple"),o+=r;const i={pageNumber:o,mainTitle:u,pageTitle:a};let l;[e.children[0],e.children[2]].forEach((e=>{for(const t in i)i[t]&&(e.dataset[t]=i[t])})),a=h([...n(m,e)].pop())||a,n(".footnotes",e).forEach(((t,n)=>{0===n?(l=t,e.children[1].after(t)):(l.append(...t.children),t.remove())}))})),n('#TOC a[href^="#"]').forEach((e=>{const n=t(`.pagesjs-page:has(${e.getAttribute("href")}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}))}addEventListener("beforeprint",E);let j=sessionStorage.getItem("pagesjs");j&&E(),addEventListener("keypress",(e=>"p"===e.key&&(E(),j=j?"":"1",sessionStorage.setItem("pagesjs",j),j||location.reload())))})(document);
{
"name": "@xiee/utils",
"version": "1.13.20",
"version": "1.13.21",
"description": "Miscellaneous tools and utilities to manipulate HTML pages",

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

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