html-crush 6.0.18 → 6.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-crush.esm.js +2 -2
- package/dist/html-crush.umd.js +27 -27
- package/package.json +3 -3
package/dist/html-crush.esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name html-crush
|
|
3
3
|
* @fileoverview Minify email templates
|
|
4
|
-
* @version 6.0.
|
|
4
|
+
* @version 6.0.19
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/html-crush/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{rApply as ne}from"ranges-apply";import{Ranges as le}from"ranges-push";import{matchLeft as oe,matchRight as F,matchRightIncl as X}from"string-match-left-right";import{expander as _}from"string-range-expander";import{left as G,right as a}from"string-left-right";import{isStr as A,isLetter as y,isPlainObject as te}from"codsen-utils";var Y="6.0.
|
|
10
|
+
import{rApply as ne}from"ranges-apply";import{Ranges as le}from"ranges-push";import{matchLeft as oe,matchRight as F,matchRightIncl as X}from"string-match-left-right";import{expander as _}from"string-range-expander";import{left as G,right as a}from"string-left-right";import{isStr as A,isLetter as y,isPlainObject as te}from"codsen-utils";var Y="6.0.19";var be=Y,$=new le({limitToBeAddedWhitespace:!0}),ie={lineLengthLimit:500,removeIndentations:!0,removeLineBreaks:!1,removeHTMLComments:!1,removeCSSComments:!0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,breakToTheLeftOf:["</td","<html","</html","<head","</head","<meta","<link","<table","<script","</script","<!DOCTYPE","<style","</style","<title","<body","@media","</body","<!--[if","<!--<![endif","<![endif]"],mindTheInlineTags:["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]};function he(n,E){let x=Date.now();if(!A(n))throw n===void 0?new Error("html-crush: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`html-crush: [THROW_ID_02] the first input argument must be string! It was given as "${typeof n}", equal to:
|
|
11
11
|
${JSON.stringify(n,null,4)}`);if(E&&!te(E))throw new Error(`html-crush: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof E}, equal to ${JSON.stringify(E,null,4)}`);if(E&&Array.isArray(E.breakToTheLeftOf)&&E.breakToTheLeftOf.length){for(let e=0,w=E.breakToTheLeftOf.length;e<w;e++)if(!A(E.breakToTheLeftOf[e]))throw new TypeError(`html-crush: [THROW_ID_05] the resolvedOpts.breakToTheLeftOf array contains non-string elements! For example, element at index ${e} is of a type "${typeof E.breakToTheLeftOf[e]}" and is equal to:
|
|
12
12
|
${JSON.stringify(E.breakToTheLeftOf[e],null,4)}`)}let l={...ie,...E};typeof l.removeHTMLComments=="boolean"&&(l.removeHTMLComments=l.removeHTMLComments?1:0);let v="";Array.isArray(l.breakToTheLeftOf)&&l.breakToTheLeftOf.length&&(v=[...new Set(l.breakToTheLeftOf.map(e=>e[0]))].join(""));let L={removeHTMLComments:!1,removeCSSComments:!1},p=null,i=null,S=!1,m=0,H=0,g=!1,O=!1,c=null,f=null,V=null,U=null,u,t=null,s=null,r=null,T=null,D=null,M=null,P=">};",I="<",K="!",q=">",z="<",W="{},:;<>~+",k=W,J=W,C=!0,h=n.length,Q=Math.floor(h/2),B=.01,j;l.reportProgressFunc&&(j=Math.floor(l.reportProgressFuncTo-(l.reportProgressFuncTo-l.reportProgressFuncFrom)*B-l.reportProgressFuncFrom));let d,R=0,b=`
|
|
13
13
|
`;if(n.includes(`\r
|
package/dist/html-crush.umd.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name html-crush
|
|
3
3
|
* @fileoverview Minify email templates
|
|
4
|
-
* @version 6.0.
|
|
4
|
+
* @version 6.0.19
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/html-crush/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var htmlCrush=(()=>{var Me=Object.create;var G=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames,ge=Object.getOwnPropertySymbols,_e=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var Z=(e,o,u)=>o in e?G(e,o,{enumerable:!0,configurable:!0,writable:!0,value:u}):e[o]=u,
|
|
11
|
-
${JSON.stringify(o,null,4)} (type ${typeof o})`);else t=
|
|
10
|
+
"use strict";var htmlCrush=(()=>{var Me=Object.create;var G=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames,ge=Object.getOwnPropertySymbols,_e=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var Z=(e,o,u)=>o in e?G(e,o,{enumerable:!0,configurable:!0,writable:!0,value:u}):e[o]=u,O=(e,o)=>{for(var u in o||(o={}))me.call(o,u)&&Z(e,u,o[u]);if(ge)for(var u of ge(o))He.call(o,u)&&Z(e,u,o[u]);return e};var xe=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports),We=(e,o)=>{for(var u in o)G(e,u,{get:o[u],enumerable:!0})},fe=(e,o,u,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Fe(o))!me.call(e,s)&&s!==u&&G(e,s,{get:()=>o[s],enumerable:!(t=Pe(o,s))||t.enumerable});return e};var $e=(e,o,u)=>(u=e!=null?Me(_e(e)):{},fe(o||!e||!e.__esModule?G(u,"default",{value:e,enumerable:!0}):u,e)),Je=e=>fe(G({},"__esModule",{value:!0}),e);var ee=(e,o,u)=>(Z(e,typeof o!="symbol"?o+"":o,u),u);var ne=xe((ht,be)=>{"use strict";be.exports=Ue;function J(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function Ue(e){if(e=e||{},e.circles)return ke(e);return e.proto?t:u;function o(s,r){for(var a=Object.keys(s),l=new Array(a.length),g=0;g<a.length;g++){var i=a[g],$=s[i];typeof $!="object"||$===null?l[i]=$:$ instanceof Date?l[i]=new Date($):ArrayBuffer.isView($)?l[i]=J($):l[i]=r($)}return l}function u(s){if(typeof s!="object"||s===null)return s;if(s instanceof Date)return new Date(s);if(Array.isArray(s))return o(s,u);if(s instanceof Map)return new Map(o(Array.from(s),u));if(s instanceof Set)return new Set(o(Array.from(s),u));var r={};for(var a in s)if(Object.hasOwnProperty.call(s,a)!==!1){var l=s[a];typeof l!="object"||l===null?r[a]=l:l instanceof Date?r[a]=new Date(l):l instanceof Map?r[a]=new Map(o(Array.from(l),u)):l instanceof Set?r[a]=new Set(o(Array.from(l),u)):ArrayBuffer.isView(l)?r[a]=J(l):r[a]=u(l)}return r}function t(s){if(typeof s!="object"||s===null)return s;if(s instanceof Date)return new Date(s);if(Array.isArray(s))return o(s,t);if(s instanceof Map)return new Map(o(Array.from(s),t));if(s instanceof Set)return new Set(o(Array.from(s),t));var r={};for(var a in s){var l=s[a];typeof l!="object"||l===null?r[a]=l:l instanceof Date?r[a]=new Date(l):l instanceof Map?r[a]=new Map(o(Array.from(l),t)):l instanceof Set?r[a]=new Set(o(Array.from(l),t)):ArrayBuffer.isView(l)?r[a]=J(l):r[a]=t(l)}return r}}function ke(e){var o=[],u=[];return e.proto?r:s;function t(a,l){for(var g=Object.keys(a),i=new Array(g.length),$=0;$<g.length;$++){var d=g[$],E=a[d];if(typeof E!="object"||E===null)i[d]=E;else if(E instanceof Date)i[d]=new Date(E);else if(ArrayBuffer.isView(E))i[d]=J(E);else{var f=o.indexOf(E);f!==-1?i[d]=u[f]:i[d]=l(E)}}return i}function s(a){if(typeof a!="object"||a===null)return a;if(a instanceof Date)return new Date(a);if(Array.isArray(a))return t(a,s);if(a instanceof Map)return new Map(t(Array.from(a),s));if(a instanceof Set)return new Set(t(Array.from(a),s));var l={};o.push(a),u.push(l);for(var g in a)if(Object.hasOwnProperty.call(a,g)!==!1){var i=a[g];if(typeof i!="object"||i===null)l[g]=i;else if(i instanceof Date)l[g]=new Date(i);else if(i instanceof Map)l[g]=new Map(t(Array.from(i),s));else if(i instanceof Set)l[g]=new Set(t(Array.from(i),s));else if(ArrayBuffer.isView(i))l[g]=J(i);else{var $=o.indexOf(i);$!==-1?l[g]=u[$]:l[g]=s(i)}}return o.pop(),u.pop(),l}function r(a){if(typeof a!="object"||a===null)return a;if(a instanceof Date)return new Date(a);if(Array.isArray(a))return t(a,r);if(a instanceof Map)return new Map(t(Array.from(a),r));if(a instanceof Set)return new Set(t(Array.from(a),r));var l={};o.push(a),u.push(l);for(var g in a){var i=a[g];if(typeof i!="object"||i===null)l[g]=i;else if(i instanceof Date)l[g]=new Date(i);else if(i instanceof Map)l[g]=new Map(t(Array.from(i),r));else if(i instanceof Set)l[g]=new Set(t(Array.from(i),r));else if(ArrayBuffer.isView(i))l[g]=J(i);else{var $=o.indexOf(i);$!==-1?l[g]=u[$]:l[g]=r(i)}}return o.pop(),u.pop(),l}}});var nt={};We(nt,{crush:()=>tt,defaults:()=>Ie,version:()=>et});var Be={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function W(e,o){if(!Array.isArray(e)||!e.length)return e;let u=O(O({},Be),o),t,s;if(u.strictlyTwoElementsInRangeArrays&&!e.every((l,g)=>!Array.isArray(l)||l.length!==2?(t=g,s=l.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${t}th range (${JSON.stringify(e[t],null,4)}) has not two but ${s} elements!`);if(!e.every((l,g)=>!Array.isArray(l)||!Number.isInteger(l[0])||l[0]<0||!Number.isInteger(l[1])||l[1]<0?(t=g,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${t}th range (${JSON.stringify(e[t],null,4)}) does not consist of only natural numbers!`);let r=e.length**2,a=0;return Array.from(e).sort((l,g)=>(u.progressFn&&(a+=1,u.progressFn(Math.floor(a*100/r))),l[0]===g[0]?l[1]<g[1]?-1:l[1]>g[1]?1:0:l[0]<g[0]?-1:1))}var he={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function ce(e,o){function u(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;let t;if(o)if(u(o)){if(t=O(O({},he),o),t.progressFn&&u(t.progressFn)&&!Object.keys(t.progressFn).length)t.progressFn=null;else if(t.progressFn&&typeof t.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof t.progressFn}", equal to ${JSON.stringify(t.progressFn,null,4)}`);if(![1,2,"1","2"].includes(t.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);if(typeof t.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof t.joinRangesThatTouchEdges}", equal to ${JSON.stringify(t.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
11
|
+
${JSON.stringify(o,null,4)} (type ${typeof o})`);else t=O({},he);let s=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,a,l;t.progressFn?r=W(s,{progressFn:i=>{l=Math.floor(i/5),l!==a&&(a=l,t.progressFn(l))}}):r=W(s);let g=r.length-1;for(let i=g;i>0;i--)t.progressFn&&(l=Math.floor((1-i/g)*78)+21,l!==a&&l>a&&(a=l,t.progressFn(l))),(r[i][0]<=r[i-1][0]||!t.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||t.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+t.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}var je=!0,te="Invariant failed";function pe(e,o){if(!e){if(je)throw new Error(te);var u=typeof o=="function"?o():o,t=u?"".concat(te,": ").concat(u):te;throw new Error(t)}}function de(e,o,u){let t=0,s=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(o&&!Array.isArray(o))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof o}, equal to: ${JSON.stringify(o,null,4)}`);if(u&&typeof u!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof u}, equal to: ${JSON.stringify(u,null,4)}`);if(!(o!=null&&o.filter($=>$).length))return e;let r;Array.isArray(o)&&Number.isInteger(o[0])&&Number.isInteger(o[1])?r=[Array.from(o)]:r=Array.from(o);let a=r.length,l=0;r.filter($=>$).forEach(($,d)=>{if(u&&(t=Math.floor(l/a*10),t!==s&&(s=t,u(t))),!Array.isArray($))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${d}th element not an array: ${JSON.stringify($,null,4)}, which is ${typeof $}`);if(!Number.isInteger($[0])){if(!Number.isInteger(+$[0])||+$[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${d}th element, array ${JSON.stringify($,null,0)}. Its first element is not an integer, string index, but ${typeof $[0]}, equal to: ${JSON.stringify($[0],null,4)}.`);r[d][0]=+r[d][0]}if(!Number.isInteger($[1])){if(!Number.isInteger(+$[1])||+$[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${d}th element, array ${JSON.stringify($,null,0)}. Its second element is not an integer, string index, but ${typeof $[1]}, equal to: ${JSON.stringify($[1],null,4)}.`);r[d][1]=+r[d][1]}l+=1});let g=ce(r,{progressFn:$=>{u&&(t=10+Math.floor($/10),t!==s&&(s=t,u(t)))}});pe(g);let i=g.length;if(i>0){let $=e.slice(g[i-1][1]);e=g.reduce((d,E,f,h)=>{u&&(t=20+Math.floor(f/i*80),t!==s&&(s=t,u(t)));let w=f===0?0:h[f-1][1],C=h[f][0];return`${d}${e.slice(w,C)}${h[f][2]||""}`},""),e+=$}return e}function Y(e,o=1){let u="\xA0";function t(r){return Array.from(r).reverse().join("")}function s(r,a,l){let g=l?`
|
|
12
12
|
`:"\r",i=l?"\r":`
|
|
13
|
-
`;if(!r)return r;let $=0,d=0,
|
|
14
|
-
`.includes(r[f])||r[f]===u?($=0,r[f]===u?
|
|
15
|
-
${JSON.stringify(o,null,4)} (type ${typeof o})`);else t=
|
|
16
|
-
${JSON.stringify(u,null,4)}`);if(
|
|
13
|
+
`;if(!r)return r;let $=0,d=0,E="";for(let f=0,h=r.length;f<h;f++)(r[f]===g||r[f]===i&&r[f-1]!==g)&&d++,`\r
|
|
14
|
+
`.includes(r[f])||r[f]===u?($=0,r[f]===u?E+=r[f]:r[f]===g?d<=a&&(E+=r[f],r[f+1]===i&&(E+=r[f+1],f++)):r[f]===i&&(r==null?void 0:r[f-1])!==g&&d<=a&&(E+=r[f])):($++,!r[f+1]&&!d&&(E+=" "));return E}if(typeof e=="string"&&e.length){let r=1;typeof+o=="number"&&Number.isInteger(+o)&&+o>=0&&(r=+o);let a="",l="";if(!e.trim())a=e;else if(!e[0].trim()){for(let g=0,i=e.length;g<i;g++)if(e[g].trim()){a=e.slice(0,g);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===u)){for(let g=e.length;g--;)if(e[g].trim()){l=e.slice(g+1);break}}return`${s(a,r,!1)}${e.trim()}${t(s(t(l),r,!0))}`}return e}var Te=$e(ne(),1);var ct=(0,Te.default)();function _(e){return S(e)&&e.length===1&&e.toUpperCase()!==e.toLowerCase()}function M(e){if(e==null||typeof e!="object")return!1;let o=Object.getPrototypeOf(e);return o!==null&&o!==Object.prototype&&Object.getPrototypeOf(o)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function S(e){return typeof e=="string"}function N(e){return Number.isSafeInteger(e)&&e>=0}function P(e){return e!=null}function ye(e,o){return M(e)&&S(o)&&o in e}var Ee={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Ge(e,o){function u(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;let t;if(o)if(u(o)){if(t=O(O({},Ee),o),t.progressFn&&u(t.progressFn)&&!Object.keys(t.progressFn).length)t.progressFn=null;else if(t.progressFn&&typeof t.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof t.progressFn}", equal to ${JSON.stringify(t.progressFn,null,4)}`);if(![1,2,"1","2"].includes(t.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);if(typeof t.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof t.joinRangesThatTouchEdges}", equal to ${JSON.stringify(t.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
15
|
+
${JSON.stringify(o,null,4)} (type ${typeof o})`);else t=O({},Ee);let s=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,a,l;t.progressFn?r=W(s,{progressFn:i=>{l=Math.floor(i/5),l!==a&&(a=l,t.progressFn(l))}}):r=W(s);let g=r.length-1;for(let i=g;i>0;i--)t.progressFn&&(l=Math.floor((1-i/g)*78)+21,l!==a&&l>a&&(a=l,t.progressFn(l))),(r[i][0]<=r[i-1][0]||!t.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||t.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+t.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}var qe={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},Se=class{constructor(e){ee(this,"ranges");ee(this,"opts");let o=O(O({},qe),e);if(o.mergeType&&o.mergeType!==1&&o.mergeType!==2)if(S(o.mergeType)&&o.mergeType.trim()==="1")o.mergeType=1;else if(S(o.mergeType)&&o.mergeType.trim()==="2")o.mergeType=2;else throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof o.mergeType}", equal to ${JSON.stringify(o.mergeType,null,4)}`);this.opts=o,this.ranges=[]}add(e,o,u){var r;if(e==null&&o==null)return;if(P(e)&&!P(o)){if(Array.isArray(e)){if(e.length){if(e.some(a=>Array.isArray(a))){e.forEach(a=>{Array.isArray(a)&&this.add(...a)});return}e.length&&N(+e[0])&&N(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(o,null,0)})`)}else if(!P(e)&&P(o))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(o,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let t=+e,s=+o;if(N(u)&&(u=String(u)),N(t)&&N(s)){if(P(u)&&!S(u)&&!N(u))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof u}, equal to:
|
|
16
|
+
${JSON.stringify(u,null,4)}`);if(P(this.ranges)&&Array.isArray(this.last())&&t===this.last()[1]){if(this.last()[1]=s,this.last()[2],this.last()[2]!==null&&P(u)){let a=this.last()[2]&&this.last()[2].length&&(!((r=this.opts)!=null&&r.mergeType)||this.opts.mergeType===1)?`${this.last()[2]}${u}`:u;this.opts.limitToBeAddedWhitespace&&(a=Y(a,this.opts.limitLinebreaksCount)),S(a)&&!a.length||(this.last()[2]=a)}}else{this.ranges||(this.ranges=[]);let a=u!==void 0&&!(S(u)&&!u.length)?[t,s,u&&this.opts.limitToBeAddedWhitespace?Y(u,this.opts.limitLinebreaksCount):u]:[t,s];this.ranges.push(a)}}else throw N(t)&&t>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof s}" equal to: ${JSON.stringify(s,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof t}" equal to: ${JSON.stringify(t,null,4)}`)}push(e,o,u){this.add(e,o,u)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=Ge(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>P(e[2])?[e[0],e[1],Y(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&N(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};function we(e){return typeof e!="string"?e:e.length?[e]:[]}var Oe={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},Ye=e=>e+1;function Ke(e,o,u,t,s=!1,r=Ye){var b;let a=typeof u=="function"?u():u;if(+o<0&&s&&a==="EOL")return a;let l=O(O({},Oe),t);if(o>=e.length&&!s)return!1;let g=s?1:u.length,i=0,$=!1,d=!1,E=!1,f=l.maxMismatches,h=o,w=!1,C=!1,T=!1;function c(){return i===1&&f<l.maxMismatches-1}for(;e[h];){let p=r(h);if(l.trimBeforeMatching&&e[h].trim()===""){if(!e[p]&&s&&u==="EOL")return!0;h=r(h);continue}if(l&&!l.i&&((b=l==null?void 0:l.trimCharsBeforeMatching)!=null&&b.includes(e[h]))||l!=null&&l.i&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.map(v=>v.toLowerCase()).includes(e[h].toLowerCase())){if(s&&u==="EOL"&&!e[p])return!0;h=r(h);continue}let L=p>h?u[u.length-g]:u[g-1];if(!l.i&&e[h]===L||l.i&&e[h].toLowerCase()===L.toLowerCase()){if(w||(w=!0),E||(E=!0),g===u.length){if(C=!0,f!==l.maxMismatches)return!1}else g===1&&(T=!0);if(g-=1,i++,c())return!1;if(!g)return i!==u.length||f===l.maxMismatches||!$?h:!1}else if(!$&&!i&&($=!0),l.maxMismatches&&f&&h){f-=1;for(let v=0;v<=f;v++){let R=p>h?u[u.length-g+1+v]:u[g-2-v],V=e[r(h)];if(R&&(!l.i&&e[h]===R||l.i&&e[h].toLowerCase()===R.toLowerCase())&&(!l.firstMustMatch||g!==u.length)){if(i++,c())return!1;g-=2,w=!0;break}else if(V&&R&&(!l.i&&V===R||l.i&&V.toLowerCase()===R.toLowerCase())&&(!l.firstMustMatch||g!==u.length)){if(!i&&!l.hungry)return!1;g-=1,w=!0;break}else if(R===void 0&&f>=0&&w&&(!l.firstMustMatch||C)&&(!l.lastMustMatch||T))return h}w||(d=h)}else return h===0&&g===1&&!l.lastMustMatch&&E?0:!1;if(d!==!1&&d!==h&&(d=!1),g<1)return h;h=r(h)}if(g>0)return s&&a==="EOL"?!0:l&&l.maxMismatches>=g&&E?d||0:!1}function ie(e,o,u,t,s){var $,d,E;if(M(s)&&ye(s,"trimBeforeMatching")&&s&&typeof s.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(s.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let r=O(O({},Oe),s);if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=we(r.trimCharsBeforeMatching)),r.trimCharsBeforeMatching=r.trimCharsBeforeMatching.map(f=>S(f)?f:String(f)),!S(o)||!o.length)return!1;if(!Number.isInteger(u)||u<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof u}, equal to:
|
|
17
17
|
${JSON.stringify(u,null,4)}`);let a,l;if(S(t))a=[t];else if(Array.isArray(t))a=t;else if(!t)a=t;else if(typeof t=="function")a=[],a.push(t);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof t}, equal to:
|
|
18
|
-
${JSON.stringify(t,null,4)}`);if(s&&!
|
|
19
|
-
${JSON.stringify(s,null,4)}`);let g=0,i="";if(r
|
|
20
|
-
${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${i}`)}if(!N(e.from))throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! It's been given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(!N(e.to))throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! It's been given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if(e!=null&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if(e!=null&&e.str&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.str ("${e.str}") must contain the character at index before "to" ("${e.to-1}")`);if(e.from>e.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${e.from}" is greater than "to" index, "${e.to}". That's wrong!`);if(e.extendToOneSide===null||S(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!S(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The options value "extendToOneSide" is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or one of strings: "left" or "right"`);if(e!=null&&e.ifLeftSideIncludesThisThenCropTightly&&!S(e.ifLeftSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,0)}`);if(e!=null&&e.ifLeftSideIncludesThisCropItToo&&!S(e.ifLeftSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisCropItToo,null,0)}`);if(e!=null&&e.ifRightSideIncludesThisThenCropTightly&&!S(e.ifRightSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifRightSideIncludesThisThenCropTightly,null,0)}`);if(e!=null&&e.ifRightSideIncludesThisCropItToo&&!S(e.ifRightSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifRightSideIncludesThisCropItToo,null,0)}`);let t=
|
|
21
|
-
\r`.includes(e[o+1])||t&&e[o+1]===
|
|
22
|
-
\r`.includes(e[o+2])||t&&e[o+2]===
|
|
23
|
-
\r`.includes(e[s])||t&&e[s]===
|
|
24
|
-
\r`.includes(e[~-o])||t&&e[~-o]===
|
|
25
|
-
\r`.includes(e[o-2])||t&&e[o-2]===
|
|
26
|
-
\r`.includes(e[s])||t&&e[s]===
|
|
27
|
-
${JSON.stringify(e,null,4)}`);if(o&&!
|
|
28
|
-
${JSON.stringify(o.breakToTheLeftOf[n],null,4)}`)}let t=
|
|
18
|
+
${JSON.stringify(t,null,4)}`);if(s&&!M(s))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof s}", and equal to:
|
|
19
|
+
${JSON.stringify(s,null,4)}`);let g=0,i="";if(($=r==null?void 0:r.trimCharsBeforeMatching)!=null&&$.some((f,h)=>f.length>1?(g=h,i=f,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${g} is longer than 1 character, ${i.length} (equals to ${i}). Please split it into separate characters and put into array as separate elements.`);if(!a||!Array.isArray(a)||Array.isArray(a)&&!a.length||Array.isArray(a)&&a.length===1&&S(a[0])&&!a[0].trim()){if(typeof r.cb=="function"){let h,w=u;if((e==="matchLeftIncl"||e==="matchRight")&&(w+=1),e[5]==="L")for(let b=w;b--;){let p=o[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&(p!=null&&p.trim()))&&(!((d=r.trimCharsBeforeMatching)!=null&&d.length)||p!==void 0&&!r.trimCharsBeforeMatching.includes(p))){h=b;break}}else if(e.startsWith("matchRight"))for(let b=w;b<o.length;b++){let p=o[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&p.trim())&&(!((E=r.trimCharsBeforeMatching)!=null&&E.length)||!r.trimCharsBeforeMatching.includes(p))){h=b;break}}if(h===void 0)return!1;let C=o[h],T=h+1,c="";return T&&T>0&&(c=o.slice(0,T)),e[5]==="L"||h&&h>0&&(c=o.slice(h)),r.cb(C,c,h)}let f="";throw s||(f=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${f}`)}for(let f=0,h=a.length;f<h;f++){l=typeof a[f]=="function";let w=a[f],C,T,c="",b=u;e==="matchRight"?b+=1:e==="matchLeft"&&(b-=1);let p=Ke(o,b,w,r,l,L=>e[5]==="L"?L-1:L+1);if(p&&l&&typeof w=="function"&&w()==="EOL")return w()&&(!r.cb||r.cb(C,c,T))?w():!1;if(Number.isInteger(p)&&(T=e.startsWith("matchLeft")?p-1:p+1,e[5]==="L"?c=o.slice(0,p):c=o.slice(T)),T<0&&(T=void 0),o[T]&&(C=o[T]),Number.isInteger(p)&&(!r.cb||r.cb(C,c,T)))return w}return!1}function De(e,o,u,t){return ie("matchLeft",e,o,u,t)}function re(e,o,u,t){return ie("matchRightIncl",e,o,u,t)}function B(e,o,u,t){return ie("matchRight",e,o,u,t)}var ze={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function K(e){var l,g;let o=/^[0-9a-zA-Z]+$/;function u(i){return S(i)&&!i.trim()}if(M(e)){if(!Object.keys(e).length)throw new Error(`string-range-expander: [THROW_ID_02] Input must be a plain object but it's been given as a plain object without any keys. However, "from" and "to" settings are obligatory!`)}else{let i;throw e===void 0?i="but it is missing completely.":e===null?i="but it was given as null.":i=`but it was given as ${typeof e}, equal to:
|
|
20
|
+
${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${i}`)}if(!N(e.from))throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! It's been given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(!N(e.to))throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! It's been given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if(e!=null&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if(e!=null&&e.str&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.str ("${e.str}") must contain the character at index before "to" ("${e.to-1}")`);if(e.from>e.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${e.from}" is greater than "to" index, "${e.to}". That's wrong!`);if(e.extendToOneSide===null||S(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!S(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The options value "extendToOneSide" is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or one of strings: "left" or "right"`);if(e!=null&&e.ifLeftSideIncludesThisThenCropTightly&&!S(e.ifLeftSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,0)}`);if(e!=null&&e.ifLeftSideIncludesThisCropItToo&&!S(e.ifLeftSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisCropItToo,null,0)}`);if(e!=null&&e.ifRightSideIncludesThisThenCropTightly&&!S(e.ifRightSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifRightSideIncludesThisThenCropTightly,null,0)}`);if(e!=null&&e.ifRightSideIncludesThisCropItToo&&!S(e.ifRightSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifRightSideIncludesThisCropItToo,null,0)}`);let t=O(O({},ze),e),s=t.str,r=t.from,a=t.to;if(t.extendToOneSide!=="right"&&(u(s[r-1])&&(u(s[r-2])||t.ifLeftSideIncludesThisCropItToo.includes(s[r-2]))||s[r-1]&&t.ifLeftSideIncludesThisCropItToo.includes(s[r-1])||t.wipeAllWhitespaceOnLeft&&u(s[r-1]))){for(let i=r;i--;)if(!t.ifLeftSideIncludesThisCropItToo.includes(s[i])){if(s[i].trim()){t.wipeAllWhitespaceOnLeft||t.ifLeftSideIncludesThisCropItToo.includes(s[i+1])?r=i+1:r=i+2;break}else if(i===0){t.wipeAllWhitespaceOnLeft?r=0:r=1;break}}}if(t.extendToOneSide!=="left"&&(u(s[a])&&(t.wipeAllWhitespaceOnRight||u(s[a+1]))||t.ifRightSideIncludesThisCropItToo.includes(s[a]))){for(let i=a,$=s.length;i<$;i++)if(!t.ifRightSideIncludesThisCropItToo.includes(s[i])){if(s[i].trim()){t.wipeAllWhitespaceOnRight||t.ifRightSideIncludesThisCropItToo.includes(s[i-1])?a=i:a=i-1;break}else if(i===s.length-1){t.wipeAllWhitespaceOnRight?a=s.length:a=s.length-1;break}}}return(t.extendToOneSide!=="right"&&S(t.ifLeftSideIncludesThisThenCropTightly)&&t.ifLeftSideIncludesThisThenCropTightly&&(s[r-2]&&t.ifLeftSideIncludesThisThenCropTightly.includes(s[r-2])||s[r-1]&&t.ifLeftSideIncludesThisThenCropTightly.includes(s[r-1]))||t.extendToOneSide!=="left"&&S(t.ifRightSideIncludesThisThenCropTightly)&&t.ifRightSideIncludesThisThenCropTightly&&(s[a+1]&&t.ifRightSideIncludesThisThenCropTightly.includes(s[a+1])||s[a]&&t.ifRightSideIncludesThisThenCropTightly.includes(s[a])))&&(t.extendToOneSide!=="right"&&u(s[r-1])&&!t.wipeAllWhitespaceOnLeft&&(r-=1),t.extendToOneSide!=="left"&&u(s[a])&&!t.wipeAllWhitespaceOnRight&&(a+=1)),t.addSingleSpaceToPreventAccidentalConcatenation&&((l=s[r-1])!=null&&l.trim())&&((g=s[a])!=null&&g.trim())&&(!t.ifLeftSideIncludesThisThenCropTightly&&!t.ifRightSideIncludesThisThenCropTightly||!((!t.ifLeftSideIncludesThisThenCropTightly||t.ifLeftSideIncludesThisThenCropTightly.includes(s[r-1]))&&(!t.ifRightSideIncludesThisThenCropTightly||s[a]&&t.ifRightSideIncludesThisThenCropTightly.includes(s[a]))))&&(o.test(s[r-1])||o.test(s[a]))?[r,a," "]:[r,a]}var Le=$e(ne(),1);var Rt=(0,Le.default)();var j="\xA0";function Qe({str:e,idx:o=0,stopAtNewlines:u=!1,stopAtRawNbsp:t=!1}){if(typeof e!="string"||!e.length||((!o||typeof o!="number")&&(o=0),!e[o+1]))return null;if(e[o+1]&&(e[o+1].trim()||u&&`
|
|
21
|
+
\r`.includes(e[o+1])||t&&e[o+1]===j))return o+1;if(e[o+2]&&(e[o+2].trim()||u&&`
|
|
22
|
+
\r`.includes(e[o+2])||t&&e[o+2]===j))return o+2;for(let s=o+1,r=e.length;s<r;s++)if(e[s].trim()||u&&`
|
|
23
|
+
\r`.includes(e[s])||t&&e[s]===j)return s;return null}function D(e,o=0){return Qe({str:e,idx:o,stopAtNewlines:!1,stopAtRawNbsp:!1})}function Xe({str:e,idx:o,stopAtNewlines:u,stopAtRawNbsp:t}){if(typeof e!="string"||!e.length||((!o||typeof o!="number")&&(o=0),o<1))return null;if(e[~-o]&&(e[~-o].trim()||u&&`
|
|
24
|
+
\r`.includes(e[~-o])||t&&e[~-o]===j))return~-o;if(e[o-2]&&(e[o-2].trim()||u&&`
|
|
25
|
+
\r`.includes(e[o-2])||t&&e[o-2]===j))return o-2;for(let s=o;s--;)if(e[s]&&(e[s].trim()||u&&`
|
|
26
|
+
\r`.includes(e[s])||t&&e[s]===j))return s;return null}function z(e,o=0){return Xe({str:e,idx:o,stopAtNewlines:!1,stopAtRawNbsp:!1})}var Ae="6.0.19";var et=Ae,y=new Se({limitToBeAddedWhitespace:!0}),Ie={lineLengthLimit:500,removeIndentations:!0,removeLineBreaks:!1,removeHTMLComments:!1,removeCSSComments:!0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,breakToTheLeftOf:["</td","<html","</html","<head","</head","<meta","<link","<table","<script","<\/script","<!DOCTYPE","<style","</style","<title","<body","@media","</body","<!--[if","<!--<![endif","<![endif]"],mindTheInlineTags:["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]};function tt(e,o){var ae,ue;let u=Date.now();if(!S(e))throw e===void 0?new Error("html-crush: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`html-crush: [THROW_ID_02] the first input argument must be string! It was given as "${typeof e}", equal to:
|
|
27
|
+
${JSON.stringify(e,null,4)}`);if(o&&!M(o))throw new Error(`html-crush: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof o}, equal to ${JSON.stringify(o,null,4)}`);if(o&&Array.isArray(o.breakToTheLeftOf)&&o.breakToTheLeftOf.length){for(let n=0,k=o.breakToTheLeftOf.length;n<k;n++)if(!S(o.breakToTheLeftOf[n]))throw new TypeError(`html-crush: [THROW_ID_05] the resolvedOpts.breakToTheLeftOf array contains non-string elements! For example, element at index ${n} is of a type "${typeof o.breakToTheLeftOf[n]}" and is equal to:
|
|
28
|
+
${JSON.stringify(o.breakToTheLeftOf[n],null,4)}`)}let t=O(O({},Ie),o);typeof t.removeHTMLComments=="boolean"&&(t.removeHTMLComments=t.removeHTMLComments?1:0);let s="";Array.isArray(t.breakToTheLeftOf)&&t.breakToTheLeftOf.length&&(s=[...new Set(t.breakToTheLeftOf.map(n=>n[0]))].join(""));let r={removeHTMLComments:!1,removeCSSComments:!1},a=null,l=null,g=!1,i=0,$=0,d=!1,E=!1,f=null,h=null,w=null,C=null,T,c=null,b=null,p=null,L=null,v=null,R=null,V=">};",U="<",Ce="!",ve=">",Ne="<",oe="{},:;<>~+",Q=oe,X=oe,H=!0,I=e.length,Re=Math.floor(I/2),le=.01,se;t.reportProgressFunc&&(se=Math.floor(t.reportProgressFuncTo-(t.reportProgressFuncTo-t.reportProgressFuncFrom)*le-t.reportProgressFuncFrom));let F,q=0,A=`
|
|
29
29
|
`;if(e.includes(`\r
|
|
30
|
-
`)?
|
|
31
|
-
`:e.includes("\r")&&(
|
|
32
|
-
`||e[m]==="\r"||e[m].trim()){m+1<n&&
|
|
30
|
+
`)?A=`\r
|
|
31
|
+
`:e.includes("\r")&&(A="\r"),I){for(let n=0;n<I;n++){if(t.reportProgressFunc&&(I>1e3&&I<2e3?n===Re&&t.reportProgressFunc(Math.floor((t.reportProgressFuncTo-t.reportProgressFuncFrom)/2)):I>=2e3&&(F=t.reportProgressFuncFrom+Math.floor(n/I*(se||1)),F!==q&&(q=F,t.reportProgressFunc(F)))),$++,!T&&d&&e[n]==="}"&&e[n-1]==="}"&&(i+1>=t.lineLengthLimit?(y.push(n,n,A),i=0):(c=n,b=n,p=" ")),T&&typeof T=="number"&&n>=T&&(T=void 0),C!==null&&e.startsWith("<\/script",n)&&!_(e[n+8])){if((t.removeIndentations||t.removeLineBreaks)&&n>0&&e[~-n]&&!e[~-n].trim()){for(let m=n;m--;)if(e[m]===`
|
|
32
|
+
`||e[m]==="\r"||e[m].trim()){m+1<n&&y.push(m+1,n);break}}C=null,T=!1,n+=8;continue}if(!T&&!d&&e.startsWith("<script",n)&&!_(e[n+7])){C=n,T=!0;let m="";(t.removeLineBreaks||t.removeIndentations)&&l!==null&&(l>0&&(m=A),y.push(l,n,m)),l=null,a=null}if(v!==null&&L===null&&!/\w/.test(e[n])){L=e.slice(v,n);let m=D(e,~-n);typeof m=="number"&&e[m]===">"&&!e[n].trim()&&D(e,n)?y.push(n,D(e,n)):m&&e[m]==="/"&&e[D(e,m)]===">"&&(!e[n].trim()&&D(e,n)&&y.push(n,D(e,n)),e[m+1]!==">"&&D(e,m+1)&&y.push(m+1,D(e,m+1)))}if(!T&&!d&&!f&&e[~-n]==="<"&&v===null&&(/\w/.test(e[n])?v=n:e[D(e,~-n)]==="/"&&/\w/.test(e[D(e,D(e,~-n))]||"")&&(v=D(e,D(e,~-n)))),!T&&(d||f)&&h!==null&&e[n]==="*"&&e[n+1]==="/"&&([c,b]=K({str:e,from:h,to:n+2,ifLeftSideIncludesThisThenCropTightly:Q||"",ifRightSideIncludesThisThenCropTightly:X||""}),h=null,c!=null?y.push(c,b):(i+=1,n+=1),T=n+2),!T&&(d||f)&&h===null&&e[n]==="/"&&e[n+1]==="*"&&(r.removeCSSComments||(r.removeCSSComments=!0),t.removeCSSComments&&(h=n)),E&&e.startsWith("![endif",n+1)&&(E=!1),!T&&!d&&!f&&w!==null){let m;e.startsWith("-->",n)?m=3:e[n]===">"&&e[n-1]==="]"&&(m=1),m&&([c,b]=K({str:e,from:w,to:n+m}),w=null,c!=null?t.lineLengthLimit&&$-(b-c)>=t.lineLengthLimit?(y.push(c,b,A),$=-m):(y.push(c,b),$-=b-c):(i+=m-1,n+=m-1),T=n+m)}if(!T&&!d&&!f&&(e.startsWith("<!--",n)||t.removeHTMLComments===2&&e.startsWith("<![endif",n))&&w===null&&(e.startsWith("[if",n+4)?(E||(E=!0),t.removeHTMLComments===2&&(w=n)):t.removeHTMLComments&&(!E||t.removeHTMLComments===2)&&(w=n),r.removeHTMLComments||(r.removeHTMLComments=!0)),!T&&d&&h===null&&e.startsWith("</style",n)&&!_(e[n+7])?d=!1:!T&&!d&&h===null&&e.startsWith("<style",n)&&!_(e[n+6])&&(d=!0,(t.removeLineBreaks||t.removeIndentations)&&t.breakToTheLeftOf.includes("<style")&&e.startsWith(' type="text/css">',n+6)&&e[n+24]&&y.push(n+23,n+23,A)),!T&&!f&&`"'`.includes(e[n])&&e.endsWith("style=",n)&&(f=n),!T&&!e[n].trim())l===null&&(l=n);else if(!T&&!((d||f)&&h!==null)){if(l!==null){if(t.removeLineBreaks&&(i+=1),H)H=!1,(t.removeIndentations||t.removeLineBreaks)&&y.push(0,n);else if(t.removeIndentations&&!t.removeLineBreaks&&(!g&&a!==null&&n>a?y.push(a+1,n):l+1<n&&(e.endsWith("]>",l)||e.endsWith("-->",l)||e.startsWith("<![",n)||e.startsWith("<!--<![",n)?y.push(l,n):e[l]===" "?y.push(l+1,n):e[~-n]===" "?y.push(l,~-n):y.push(l,n," "))),t.removeLineBreaks||f){if(s.includes(e[n])&&re(e,n,t.breakToTheLeftOf)){!(`\r
|
|
33
33
|
`.includes(e[~-n])&&l===~-n)&&!(e[~-n]===`
|
|
34
|
-
`&&e[n-2]==="\r"&&l===n-2)&&
|
|
34
|
+
`&&e[n-2]==="\r"&&l===n-2)&&y.push(l,n,A),c=null,b=null,p=null,l=null,i=1;continue}let m=" ";e[n]==="<"&&B(e,n,t.mindTheInlineTags,{cb:x=>!x||!/\w/.test(x)})||(e[~-l]&&ve.includes(e[~-l])&&Ne.includes(e[n])||(d||f)&&h===null&&(Q.includes(e[~-l])||X.includes(e[n]))||e.startsWith("!important",n)&&!E||f&&(e[~-l]==="'"||e[~-l]==='"')||e[~-l]==="}"&&e.startsWith("</style",n)||e[n]===">"&&(`'"`.includes(e[z(e,n)])||e[D(e,n)]==="<")||e[n]==="/"&&e[D(e,n)]===">")&&(m="",e[n]==="/"&&e[n+1]===">"&&D(e,n)&&D(e,n)>n+1&&(y.push(n+1,D(e,n)),i-=D(e,n)-n+1)),d&&e[n]==="}"&&l&&e[l-1]==="}"&&(m=" "),m!=null&&m.length&&(i+=1),t.lineLengthLimit?i>=t.lineLengthLimit||!e[n+1]||e[n]===">"||e[n]==="/"&&e[n+1]===">"?((i>t.lineLengthLimit||i===t.lineLengthLimit&&((ae=e[n+1])!=null&&ae.trim())&&!V.includes(e[n])&&!U.includes(e[n+1]))&&(m=A,i=1),(i>t.lineLengthLimit||!(m===" "&&n===l+1))&&(y.push(l,n,m),a=null),c=null,b=null,p=null):(c===null||l<c)&&(c=l,b=n,p=m):n===l+1&&m===" "||y.push(l,n,m)}l=null,g||(g=!0)}else H&&(H=!1),t.removeLineBreaks&&(i+=1);g||(g=!0)}if(!T&&!H&&n!==0&&t.removeLineBreaks&&(t.lineLengthLimit||s)&&!e.startsWith("</a",n)){if(s&&re(e,n,t.breakToTheLeftOf)&&e.slice(0,n).trim()&&(!e.startsWith("<![endif]",n)||!De(e,n,"<!--"))){y.push(n,n,A),c=null,b=null,p=null,i=1;continue}else if(t.lineLengthLimit&&i<=t.lineLengthLimit){if(!e[n+1]||U.includes(e[n])&&!Ce.includes(e[n])||V.includes(e[n])||!e[n].trim()){if(c!==null&&b!==null&&(c!==b||p!=null&&p.length)){let m=p;e[n].trim()&&((ue=e[n+1])!=null&&ue.trim())&&i+(p?p.length:0)>t.lineLengthLimit&&(m=A),(i+(m?m.length:0)>t.lineLengthLimit||!(m===" "&&b===c+1&&e[c]===" "))&&(e[~-c]==="}"&&e[b]==="{"||(y.push(c,b,m),a=null))}e[n].trim()&&(U.includes(e[n])||e[~-n]&&V.includes(e[~-n]))&&S(R)&&(!L||!t.mindTheInlineTags.includes(L))&&!(e[n]==="<"&&B(e,n,t.mindTheInlineTags,{cb:m=>!m||!/\w/.test(m)}))&&!(e[n]==="<"&&B(e,n,t.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:m=>!m||!/\w/.test(m)}))?(c=n,b=n,p=null):h===null&&c!==null&&(f||!t.mindTheInlineTags||!Array.isArray(t.mindTheInlineTags)||Array.isArray(t.mindTheInlineTags.length)&&!t.mindTheInlineTags.length||!S(L)||Array.isArray(t.mindTheInlineTags)&&t.mindTheInlineTags.length&&S(L)&&!t.mindTheInlineTags.includes(L))&&!(e[n]==="<"&&B(e,n,t.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:m=>!m||!/\w/.test(m)}))&&(c=null,b=null,p=null)}}else if(t.lineLengthLimit)if(U.includes(e[n])&&!(e[n]==="<"&&B(e,n,t.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:m=>!m||!/\w/.test(m)})))if(c!==null&&b!==null&&(c!==b||p!=null&&p.length)){let m=p!=null&&p.length?p.length:0;i-(b-c-m)-1>t.lineLengthLimit||(y.push(c,b,p),i-(b-c-m)-1===t.lineLengthLimit&&(y.push(n,n,A),i=0),c=null,b=null,p=null)}else y.push(n,n,A),i=0;else e[n+1]&&V.includes(e[n])&&S(L)&&Array.isArray(t.mindTheInlineTags)&&t.mindTheInlineTags.length&&!t.mindTheInlineTags.includes(L)?c!==null&&b!==null&&(c!==b||p!=null&&p.length)||(y.push(n+1,n+1,A),i=0):e[n].trim()&&(e[n+1]||c!==null&&b!==null&&(c!==b||p!=null&&p.length)&&y.push(c,b,A))}if(!T&&!H&&t.removeLineBreaks&&t.lineLengthLimit&&i>=t.lineLengthLimit&&c!==null&&b!==null&&!V.includes(e[n])&&!U.includes(e[n])&&!"/".includes(e[n])&&!(i===t.lineLengthLimit&&e[n+1]&&!e[n+1].trim())){let m=A;e[n+1]&&!e[n+1].trim()&&i===t.lineLengthLimit&&(m=p),m===A&&!e[~-c].trim()&&z(e,c)&&(c=z(e,c)+1),y.push(c,b,m),i=n-b,e[n].length&&(i+=1),c=null,b=null,p=null}if((!T&&e[n]===`
|
|
35
35
|
`||e[n]==="\r"&&(!e[n+1]||e[n+1]&&e[n+1]!==`
|
|
36
36
|
`))&&(a=n,g&&(g=!1),!t.removeLineBreaks&&l!==null&&l<n&&e[n+1]&&e[n+1]!=="\r"&&e[n+1]!==`
|
|
37
|
-
`&&
|
|
38
|
-
`&&e[n]!=="\r"?
|
|
37
|
+
`&&y.push(l,n)),e[n+1]||(d&&h!==null?y.push([...K({str:e,from:h,to:n,ifLeftSideIncludesThisThenCropTightly:Q||"",ifRightSideIncludesThisThenCropTightly:X||""})]):l&&e[n]!==`
|
|
38
|
+
`&&e[n]!=="\r"?y.push(l,n+1):l&&(e[n]==="\r"&&e[n+1]===`
|
|
39
39
|
`||e[n]===`
|
|
40
|
-
`&&e[n-1]!=="\r")&&
|
|
40
|
+
`&&e[n-1]!=="\r")&&y.push(l,n)),!T&&f&&f<n&&e[f]===e[n]&&(f=null),!T&&!d&&e.startsWith("<pre",n)&&!_(e[n+4])){let m=e.indexOf("</pre",n+5);m>0&&(T=m)}if(!T&&!d&&e.startsWith("<code",n)&&!_(e[n+5])){let m=e.indexOf("</code",n+5);m>0&&(T=m)}if(!T&&e.startsWith("<![CDATA[",n)){let m=e.indexOf("]]>",n+9);m>0&&(T=m)}!T&&!d&&!f&&v!==null&&e[n]===">"&&(e[D(e,n)]==="<"&&(R=L),v=null,L=null),e[n]==="<"&&R!==null&&(R=null),d&&e[n]==="{"&&e[n+1]==="{"&&e.indexOf("}}")!==-1&&(T=e.indexOf("}}")+2);let k=!0}if(y.current()){let n=y.current();y.wipe();let k=t.reportProgressFuncTo-(t.reportProgressFuncTo-t.reportProgressFuncFrom)*le,m=de(e,n,Ve=>{t.reportProgressFunc&&I>=2e3&&(F=Math.floor(k+(t.reportProgressFuncTo-k)*(Ve/100)),F!==q&&(q=F,t.reportProgressFunc(F)))}),x=m.length;return{log:{timeTakenInMilliseconds:Date.now()-u,originalLength:I,cleanedLength:x,bytesSaved:Math.max(I-x,0),percentageReducedOfOriginal:I?Math.round(Math.max(I-x,0)*100/I):0},ranges:n,applicableOpts:r,result:m}}}return{log:{timeTakenInMilliseconds:Date.now()-u,originalLength:I,cleanedLength:I,bytesSaved:0,percentageReducedOfOriginal:0},applicableOpts:r,ranges:null,result:e}}return Je(nt);})();
|
|
41
41
|
/**
|
|
42
42
|
* @name ranges-sort
|
|
43
43
|
* @fileoverview Sort string index ranges
|
|
@@ -57,7 +57,7 @@ ${JSON.stringify(o.breakToTheLeftOf[n],null,4)}`)}let t=w(w({},Ie),o);typeof t.r
|
|
|
57
57
|
/**
|
|
58
58
|
* @name ranges-apply
|
|
59
59
|
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
60
|
-
* @version 7.0.
|
|
60
|
+
* @version 7.0.16
|
|
61
61
|
* @author Roy Revelt, Codsen Ltd
|
|
62
62
|
* @license MIT
|
|
63
63
|
* {@link https://codsen.com/os/ranges-apply/}
|
|
@@ -97,7 +97,7 @@ ${JSON.stringify(o.breakToTheLeftOf[n],null,4)}`)}let t=w(w({},Ie),o);typeof t.r
|
|
|
97
97
|
/**
|
|
98
98
|
* @name string-match-left-right
|
|
99
99
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
100
|
-
* @version 9.0.
|
|
100
|
+
* @version 9.0.19
|
|
101
101
|
* @author Roy Revelt, Codsen Ltd
|
|
102
102
|
* @license MIT
|
|
103
103
|
* {@link https://codsen.com/os/string-match-left-right/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-crush",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.19",
|
|
4
4
|
"description": "Minify email templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"breaks",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"codsen-utils": "^1.6.4",
|
|
84
|
-
"ranges-apply": "^7.0.
|
|
84
|
+
"ranges-apply": "^7.0.16",
|
|
85
85
|
"ranges-push": "^7.0.15",
|
|
86
86
|
"string-left-right": "^6.0.17",
|
|
87
|
-
"string-match-left-right": "^9.0.
|
|
87
|
+
"string-match-left-right": "^9.0.19",
|
|
88
88
|
"string-range-expander": "^4.0.14",
|
|
89
89
|
"test-mixer": "^4.1.14"
|
|
90
90
|
}
|