html-crush 5.0.4 → 5.0.5

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/CHANGELOG.md CHANGED
@@ -3,26 +3,6 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## 5.0.3 (2021-11-02)
7
-
8
- ### Bug Fixes
9
-
10
- - bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
11
-
12
- ### Features
13
-
14
- - migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
15
-
16
- ### BREAKING CHANGES
17
-
18
- - programs now are in ES Modules and won't work with Common JS require()
19
-
20
- ## 5.0.1 (2021-09-13)
21
-
22
- ### Bug Fixes
23
-
24
- - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
25
-
26
6
  ## 5.0.0 (2021-09-09)
27
7
 
28
8
  ### Bug Fixes
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-%YEAR% Roy Revelt and other contributors
3
+ Copyright (c) 2010-2021 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name html-crush
3
3
  * @fileoverview Minifies HTML/CSS: valid or broken, pure or mixed with other languages
4
- * @version 5.0.4
4
+ * @version 5.0.5
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/html-crush/}
@@ -13,7 +13,7 @@ import { matchRightIncl, matchRight, matchLeft } from 'string-match-left-right';
13
13
  import { expander } from 'string-range-expander';
14
14
  import { right, left } from 'string-left-right';
15
15
 
16
- var version$1 = "5.0.4";
16
+ var version$1 = "5.0.5";
17
17
 
18
18
  const version = version$1;
19
19
  const finalIndexesToDelete = new Ranges({
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name html-crush
3
3
  * @fileoverview Minifies HTML/CSS: valid or broken, pure or mixed with other languages
4
- * @version 5.0.4
4
+ * @version 5.0.5
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/html-crush/}
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * @name ranges-sort
13
13
  * @fileoverview Sort string index ranges
14
- * @version 5.0.4
14
+ * @version 5.0.5
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/ranges-sort/}
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * @name ranges-merge
21
21
  * @fileoverview Merge and sort string index ranges
22
- * @version 8.0.4
22
+ * @version 8.0.5
23
23
  * @author Roy Revelt, Codsen Ltd
24
24
  * @license MIT
25
25
  * {@link https://codsen.com/os/ranges-merge/}
@@ -27,7 +27,7 @@
27
27
  /**
28
28
  * @name ranges-apply
29
29
  * @fileoverview Take an array of string index ranges, delete/replace the string according to them
30
- * @version 6.0.4
30
+ * @version 6.0.5
31
31
  * @author Roy Revelt, Codsen Ltd
32
32
  * @license MIT
33
33
  * {@link https://codsen.com/os/ranges-apply/}
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * @name string-collapse-leading-whitespace
37
37
  * @fileoverview Collapse the leading and trailing whitespace of a string
38
- * @version 6.0.4
38
+ * @version 6.0.5
39
39
  * @author Roy Revelt, Codsen Ltd
40
40
  * @license MIT
41
41
  * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
@@ -44,7 +44,7 @@ function s(e,t=1){function r(e){return Array.from(e).reverse().join("")}function
44
44
  /**
45
45
  * @name ranges-push
46
46
  * @fileoverview Gather string index ranges
47
- * @version 6.0.4
47
+ * @version 6.0.5
48
48
  * @author Roy Revelt, Codsen Ltd
49
49
  * @license MIT
50
50
  * {@link https://codsen.com/os/ranges-push/}
@@ -52,7 +52,7 @@ function s(e,t=1){function r(e){return Array.from(e).reverse().join("")}function
52
52
  /**
53
53
  * @name string-match-left-right
54
54
  * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
55
- * @version 8.0.4
55
+ * @version 8.0.5
56
56
  * @author Roy Revelt, Codsen Ltd
57
57
  * @license MIT
58
58
  * {@link https://codsen.com/os/string-match-left-right/}
@@ -61,7 +61,7 @@ function g(e){return e&&"object"==typeof e&&!Array.isArray(e)}function p(e){retu
61
61
  /**
62
62
  * @name arrayiffy-if-string
63
63
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
64
- * @version 4.0.4
64
+ * @version 4.0.5
65
65
  * @author Roy Revelt, Codsen Ltd
66
66
  * @license MIT
67
67
  * {@link https://codsen.com/os/arrayiffy-if-string/}
@@ -70,7 +70,7 @@ var o;if("string"==typeof s.trimCharsBeforeMatching&&(s.trimCharsBeforeMatching=
70
70
  /**
71
71
  * @name string-range-expander
72
72
  * @fileoverview Expands string index ranges within whitespace boundaries until letters are met
73
- * @version 3.0.4
73
+ * @version 3.0.5
74
74
  * @author Roy Revelt, Codsen Ltd
75
75
  * @license MIT
76
76
  * {@link https://codsen.com/os/string-range-expander/}
@@ -78,9 +78,9 @@ var o;if("string"==typeof s.trimCharsBeforeMatching&&(s.trimCharsBeforeMatching=
78
78
  /**
79
79
  * @name string-left-right
80
80
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
81
- * @version 5.0.4
81
+ * @version 5.0.5
82
82
  * @author Roy Revelt, Codsen Ltd
83
83
  * @license MIT
84
84
  * {@link https://codsen.com/os/string-left-right/}
85
85
  */
86
- const A=" ";function S(e,t=0){return function({str:e,idx:t=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if("string"!=typeof e||!e.length)return null;if(t&&"number"==typeof t||(t=0),!e[t+1])return null;if(e[t+1]&&(e[t+1].trim()||r&&"\n\r".includes(e[t+1])||n&&e[t+1]===A))return t+1;if(e[t+2]&&(e[t+2].trim()||r&&"\n\r".includes(e[t+2])||n&&e[t+2]===A))return t+2;for(let i=t+1,s=e.length;i<s;i++)if(e[i].trim()||r&&"\n\r".includes(e[i])||n&&e[i]===A)return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function $(e,t=0){return function({str:e,idx:t,stopAtNewlines:r,stopAtRawNbsp:n}){if("string"!=typeof e||!e.length)return null;if(t&&"number"==typeof t||(t=0),t<1)return null;if(e[~-t]&&(e[~-t].trim()||r&&"\n\r".includes(e[~-t])||n&&e[~-t]===A))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&"\n\r".includes(e[t-2])||n&&e[t-2]===A))return t-2;for(let i=t;i--;)if(e[i]&&(e[i].trim()||r&&"\n\r".includes(e[i])||n&&e[i]===A))return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}const C=new class{constructor(e){const t={...c,...e};if(t.mergeType&&1!==t.mergeType&&2!==t.mergeType)if(f(t.mergeType)&&"1"===t.mergeType.trim())t.mergeType=1;else{if(!f(t.mergeType)||"2"!==t.mergeType.trim())throw new Error(`ranges-push: [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)}`);t.mergeType=2}this.opts=t,this.ranges=[]}ranges;opts;add(e,t,r){if(null==e&&null==t)return;if(u(e)&&!u(t)){if(Array.isArray(e)){if(e.length){if(e.some((e=>Array.isArray(e))))return void e.forEach((e=>{Array.isArray(e)&&this.add(...e)}));e.length&&h(+e[0])&&h(+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(t,null,0)})`)}if(!u(e)&&u(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);const n=+e,i=+t;if(h(r)&&(r=String(r)),!h(n)||!h(i))throw h(n)&&n>=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 i}" equal to: ${JSON.stringify(i,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 n}" equal to: ${JSON.stringify(n,null,4)}`);if(u(r)&&!f(r)&&!h(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`);if(u(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=i,this.last(),null!==this.last()[2]&&u(r)){let e=!(this.last()[2]&&this.last()[2].length>0)||this.opts&&this.opts.mergeType&&1!==this.opts.mergeType?r:this.last()[2]+r;this.opts.limitToBeAddedWhitespace&&(e=s(e,this.opts.limitLinebreaksCount)),f(e)&&!e.length||(this.last()[2]=e)}}else{this.ranges||(this.ranges=[]);const e=void 0===r||f(r)&&!r.length?[n,i]:[n,i,r&&this.opts.limitToBeAddedWhitespace?s(r,this.opts.limitLinebreaksCount):r];this.ranges.push(e)}}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=function(e,t){function r(e){return e&&"object"==typeof e&&!Array.isArray(e)}if(!Array.isArray(e)||!e.length)return null;let n;if(t){if(!r(t))throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n${JSON.stringify(t,null,4)} (type ${typeof t})`);if(n={...l,...t},n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&"function"!=typeof n.progressFn)throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(n.mergeType&&1!=+n.mergeType&&2!=+n.mergeType)throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if("boolean"!=typeof n.joinRangesThatTouchEdges)throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else n={...l};const i=e.filter((e=>e)).map((e=>[...e])).filter((e=>void 0!==e[2]||e[0]!==e[1]));let s,o,u;if(s=n.progressFn?a(i,{progressFn:e=>{u=Math.floor(e/5),u!==o&&(o=u,n.progressFn(u))}}):a(i),!s)return null;const h=s.length-1;for(let e=h;e>0;e--)n.progressFn&&(u=Math.floor(78*(1-e/h))+21,u!==o&&u>o&&(o=u,n.progressFn(u))),(s[e][0]<=s[e-1][0]||!n.joinRangesThatTouchEdges&&s[e][0]<s[e-1][1]||n.joinRangesThatTouchEdges&&s[e][0]<=s[e-1][1])&&(s[e-1][0]=Math.min(s[e][0],s[e-1][0]),s[e-1][1]=Math.max(s[e][1],s[e-1][1]),void 0!==s[e][2]&&(s[e-1][0]>=s[e][0]||s[e-1][1]<=s[e][1])&&null!==s[e-1][2]&&(null===s[e][2]&&null!==s[e-1][2]?s[e-1][2]=null:null!=s[e-1][2]?2==+n.mergeType&&s[e-1][0]===s[e][0]?s[e-1][2]=s[e][2]:s[e-1][2]+=s[e][2]:s[e-1][2]=s[e][2]),s.splice(e,1),e=s.length);return s.length?s:null}(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map((e=>u(e[2])?[e[0],e[1],s(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])||!h(e[0][0]))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.`);this.ranges=Array.from(e)}else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}}({limitToBeAddedWhitespace:!0}),R={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","\x3c!--[if","\x3c!--<![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"]},M={removeHTMLComments:!1,removeCSSComments:!1};function j(e){return"string"==typeof e}function x(e){return"string"==typeof e&&e.toUpperCase()!==e.toLowerCase()}e.crush=function(e,t){const r=Date.now();if(!j(e))throw void 0===e?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:\n${JSON.stringify(e,null,4)}`);if(t&&"object"!=typeof t)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 t}, equal to ${JSON.stringify(t,null,4)}`);if(t&&Array.isArray(t.breakToTheLeftOf)&&t.breakToTheLeftOf.length)for(let e=0,r=t.breakToTheLeftOf.length;e<r;e++)if(!j(t.breakToTheLeftOf[e]))throw new TypeError(`html-crush: [THROW_ID_05] the opts.breakToTheLeftOf array contains non-string elements! For example, element at index ${e} is of a type "${typeof t.breakToTheLeftOf[e]}" and is equal to:\n${JSON.stringify(t.breakToTheLeftOf[e],null,4)}`);const n={...R,...t};"boolean"==typeof n.removeHTMLComments&&(n.removeHTMLComments=n.removeHTMLComments?1:0);let s="";Array.isArray(n.breakToTheLeftOf)&&n.breakToTheLeftOf.length&&(s=[...new Set(n.breakToTheLeftOf.map((e=>e[0])))].join(""));let o,a=null,l=null,u=!1,h=0,f=0,c=!1,g=!1,p=null,m=null,d=null,y=null,T=null,v=null,I=null,L=null,A=null,W=null;const E=">};",F="<",N="!",H=">",k="<",B="{},:;<>~+",D=B,J=B;let P=!0;const q=e.length,U=Math.floor(q/2);let z,V;n.reportProgressFunc&&(z=Math.floor(n.reportProgressFuncTo-.01*(n.reportProgressFuncTo-n.reportProgressFuncFrom)-n.reportProgressFuncFrom));let G=0,Y="\n";if(e.includes("\r\n")?Y="\r\n":e.includes("\r")&&(Y="\r"),q){for(let t=0;t<q;t++)if(n.reportProgressFunc&&(q>1e3&&q<2e3?t===U&&n.reportProgressFunc(Math.floor((n.reportProgressFuncTo-n.reportProgressFuncFrom)/2)):q>=2e3&&(V=n.reportProgressFuncFrom+Math.floor(t/q*(z||1)),V!==G&&(G=V,n.reportProgressFunc(V)))),f++,!o&&c&&"}"===e[t]&&"}"===e[t-1]&&(h+1>=n.lineLengthLimit?(C.push(t,t,Y),h=0):(T=t,v=t,I=" ")),o&&"number"==typeof o&&t>=o&&(o=void 0),null===y||!e.startsWith("</script",t)||x(e[t+8])){if(!o&&!c&&e.startsWith("<script",t)&&!x(e[t+7])){y=t,o=!0;let e="";(n.removeLineBreaks||n.removeIndentations)&&null!==l&&(l>0&&(e=Y),C.push(l,t,e)),l=null,a=null}if(null!==A&&null===L&&!/\w/.test(e[t])){L=e.slice(A,t);const r=S(e,~-t);"number"==typeof r&&">"===e[r]&&!e[t].trim()&&S(e,t)?C.push(t,S(e,t)):r&&"/"===e[r]&&">"===e[S(e,r)]&&(!e[t].trim()&&S(e,t)&&C.push(t,S(e,t)),">"!==e[r+1]&&S(e,r+1)&&C.push(r+1,S(e,r+1)))}if(o||c||p||"<"!==e[~-t]||null!==A||(/\w/.test(e[t])?A=t:"/"===e[S(e,~-t)]&&/\w/.test(e[S(e,S(e,~-t))]||"")&&(A=S(e,S(e,~-t)))),o||!c&&!p||null===m||"*"!==e[t]||"/"!==e[t+1]||([T,v]=O({str:e,from:m,to:t+2,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J}),m=null,null!=T?C.push(T,v):(h+=1,t+=1),o=t+2),o||!c&&!p||null!==m||"/"!==e[t]||"*"!==e[t+1]||(M.removeCSSComments||(M.removeCSSComments=!0),n.removeCSSComments&&(m=t)),g&&e.startsWith("![endif",t+1)&&(g=!1),!o&&!c&&!p&&null!==d){let r;e.startsWith("--\x3e",t)?r=3:">"===e[t]&&"]"===e[t-1]&&(r=1),r&&([T,v]=O({str:e,from:d,to:t+r}),d=null,null!=T?n.lineLengthLimit&&f-(v-T)>=n.lineLengthLimit?(C.push(T,v,Y),f=-r):(C.push(T,v),f-=v-T):(h+=r-1,t+=r-1),o=t+r)}if(o||c||p||!e.startsWith("\x3c!--",t)||null!==d||(e.startsWith("[if",t+4)?(g||(g=!0),2===n.removeHTMLComments&&(d=t)):!n.removeHTMLComments||g&&2!==n.removeHTMLComments||(d=t),M.removeHTMLComments||(M.removeHTMLComments=!0)),!o&&c&&null===m&&e.startsWith("</style",t)&&!x(e[t+7])?c=!1:o||c||null!==m||!e.startsWith("<style",t)||x(e[t+6])||(c=!0,(n.removeLineBreaks||n.removeIndentations)&&n.breakToTheLeftOf.includes("<style")&&e.startsWith(' type="text/css">',t+6)&&e[t+24]&&C.push(t+23,t+23,Y)),!o&&!p&&"\"'".includes(e[t])&&e.endsWith("style=",t)&&(p=t),o||e[t].trim()){if(!o&&(!c&&!p||null===m)){if(null!==l){if(n.removeLineBreaks&&(h+=1),P)P=!1,(n.removeIndentations||n.removeLineBreaks)&&C.push(0,t);else if(n.removeIndentations&&!n.removeLineBreaks&&(!u&&null!==a&&t>a?C.push(a+1,t):l+1<t&&(e.endsWith("]>",l)||e.endsWith("--\x3e",l)||e.startsWith("<![",t)||e.startsWith("\x3c!--<![",t)?C.push(l,t):" "===e[l]?C.push(l+1,t):" "===e[~-t]?C.push(l,~-t):C.push(l,t," "))),n.removeLineBreaks||p){if(s.includes(e[t])&&w(e,t,n.breakToTheLeftOf)){"\r\n".includes(e[~-t])&&l===~-t||"\n"===e[~-t]&&"\r"===e[t-2]&&l===t-2||C.push(l,t,Y),T=null,v=null,I=null,l=null,h=1;continue}let r=" ";"<"===e[t]&&_(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||(e[~-l]&&H.includes(e[~-l])&&k.includes(e[t])||(c||p)&&null===m&&(D.includes(e[~-l])||J.includes(e[t]))||e.startsWith("!important",t)&&!g||p&&("'"===e[~-l]||'"'===e[~-l])||"}"===e[~-l]&&e.startsWith("</style",t)||">"===e[t]&&("'\"".includes(e[$(e,t)])||"<"===e[S(e,t)])||"/"===e[t]&&">"===e[S(e,t)])&&(r="","/"===e[t]&&">"===e[t+1]&&S(e,t)&&S(e,t)>t+1&&(C.push(t+1,S(e,t)),h-=S(e,t)-t+1)),c&&"}"===e[t]&&l&&"}"===e[l-1]&&(r=" "),r&&r.length&&(h+=1),n.lineLengthLimit?h>=n.lineLengthLimit||!e[t+1]||">"===e[t]||"/"===e[t]&&">"===e[t+1]?((h>n.lineLengthLimit||h===n.lineLengthLimit&&e[t+1]&&e[t+1].trim()&&!E.includes(e[t])&&!F.includes(e[t+1]))&&(r=Y,h=1),(h>n.lineLengthLimit||" "!==r||t!==l+1)&&(C.push(l,t,r),a=null),T=null,v=null,I=null):(null===T||l<T)&&(T=l,v=t,I=r):t===l+1&&" "===r||C.push(l,t,r)}l=null,u||(u=!0)}else P&&(P=!1),n.removeLineBreaks&&(h+=1);u||(u=!0)}}else null===l&&(l=t);if(!o&&!P&&0!==t&&n.removeLineBreaks&&(n.lineLengthLimit||s)&&!e.startsWith("</a",t)){if(s&&w(e,t,n.breakToTheLeftOf)&&e.slice(0,t).trim()&&(!e.startsWith("<![endif]",t)||!b(e,t,"\x3c!--"))){C.push(t,t,Y),T=null,v=null,I=null,h=1;continue}if(n.lineLengthLimit&&h<=n.lineLengthLimit){if(!e[t+1]||F.includes(e[t])&&!N.includes(e[t])||E.includes(e[t])||!e[t].trim()){if(null!==T&&null!==v&&(T!==v||I&&I.length)){let r=I;e[t].trim()&&e[t+1]&&e[t+1].trim()&&h+(I?I.length:0)>n.lineLengthLimit&&(r=Y),(h+(r?r.length:0)>n.lineLengthLimit||" "!==r||v!==T+1||" "!==e[T])&&("}"===e[~-T]&&"{"===e[v]||(C.push(T,v,r),a=null))}!(e[t].trim()&&(F.includes(e[t])||e[~-t]&&E.includes(e[~-t]))&&j(W))||L&&n.mindTheInlineTags.includes(L)||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})?null!==m||null===T||!(p||!n.mindTheInlineTags||!Array.isArray(n.mindTheInlineTags)||Array.isArray(n.mindTheInlineTags.length)&&!n.mindTheInlineTags.length||!j(L)||Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&j(L)&&!n.mindTheInlineTags.includes(L))||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})||(T=null,v=null,I=null):(T=t,v=t,I=null)}}else if(n.lineLengthLimit)if(!F.includes(e[t])||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)}))e[t+1]&&E.includes(e[t])&&j(L)&&Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&!n.mindTheInlineTags.includes(L)?null!==T&&null!==v&&(T!==v||I&&I.length)||(C.push(t+1,t+1,Y),h=0):e[t].trim()&&(e[t+1]||null!==T&&null!==v&&(T!==v||I&&I.length)&&C.push(T,v,Y));else if(null!==T&&null!==v&&(T!==v||I&&I.length)){const e=I&&I.length?I.length:0;h-(v-T-e)-1>n.lineLengthLimit||(C.push(T,v,I),h-(v-T-e)-1===n.lineLengthLimit&&(C.push(t,t,Y),h=0),T=null,v=null,I=null)}else C.push(t,t,Y),h=0}if(!o&&!P&&n.removeLineBreaks&&n.lineLengthLimit&&h>=n.lineLengthLimit&&null!==T&&null!==v&&!E.includes(e[t])&&!F.includes(e[t])&&!"/".includes(e[t])&&(h!==n.lineLengthLimit||!e[t+1]||e[t+1].trim())){let r=Y;e[t+1]&&!e[t+1].trim()&&h===n.lineLengthLimit&&(r=I),r===Y&&!e[~-T].trim()&&$(e,T)&&(T=$(e,T)+1),C.push(T,v,r),h=t-v,e[t].length&&(h+=1),T=null,v=null,I=null}if((!o&&"\n"===e[t]||"\r"===e[t]&&(!e[t+1]||e[t+1]&&"\n"!==e[t+1]))&&(a=t,u&&(u=!1),!n.removeLineBreaks&&null!==l&&l<t&&e[t+1]&&"\r"!==e[t+1]&&"\n"!==e[t+1]&&C.push(l,t)),e[t+1]||(c&&null!==m?C.push(...O({str:e,from:m,to:t,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J})):l&&"\n"!==e[t]&&"\r"!==e[t]?C.push(l,t+1):l&&("\r"===e[t]&&"\n"===e[t+1]||"\n"===e[t]&&"\r"!==e[t-1])&&C.push(l,t)),!o&&p&&p<t&&e[p]===e[t]&&(p=null),!o&&!c&&e.startsWith("<pre",t)&&!x(e[t+4])){const r=e.indexOf("</pre",t+5);r>0&&(o=r)}if(!o&&!c&&e.startsWith("<code",t)&&!x(e[t+5])){const r=e.indexOf("</code",t+5);r>0&&(o=r)}if(!o&&e.startsWith("<![CDATA[",t)){const r=e.indexOf("]]>",t+9);r>0&&(o=r)}o||c||p||null===A||">"!==e[t]||("<"===e[S(e,t)]&&(W=L),A=null,L=null),"<"===e[t]&&null!==W&&(W=null),c&&"{"===e[t]&&"{"===e[t+1]&&-1!==e.indexOf("}}")&&(o=e.indexOf("}}")+2)}else{if((n.removeIndentations||n.removeLineBreaks)&&t>0&&e[~-t]&&!e[~-t].trim())for(let r=t;r--;)if("\n"===e[r]||"\r"===e[r]||e[r].trim()){r+1<t&&C.push(r+1,t);break}y=null,o=!1,t+=8}if(C.current()){const t=C.current();C.wipe();const s=n.reportProgressFuncTo-.01*(n.reportProgressFuncTo-n.reportProgressFuncFrom),o=function(e,t,r){let n,s=0,o=0;if(0===arguments.length)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if("string"!=typeof e)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(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&"function"!=typeof r)throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter((e=>e)).length)return e;n=Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?[Array.from(t)]:Array.from(t);const a=n.length;let l=0;n.filter((e=>e)).forEach(((e,t)=>{if(r&&(s=Math.floor(l/a*10),s!==o&&(o=s,r(s))),!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${t}th element not an array: ${JSON.stringify(e,null,4)}, which is ${typeof e}`);if(!Number.isInteger(e[0])){if(!Number.isInteger(+e[0])||+e[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its first element is not an integer, string index, but ${typeof e[0]}, equal to: ${JSON.stringify(e[0],null,4)}.`);n[t][0]=+n[t][0]}if(!Number.isInteger(e[1])){if(!Number.isInteger(+e[1])||+e[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its second element is not an integer, string index, but ${typeof e[1]}, equal to: ${JSON.stringify(e[1],null,4)}.`);n[t][1]=+n[t][1]}l+=1}));const u=i(n,{progressFn:e=>{r&&(s=10+Math.floor(e/10),s!==o&&(o=s,r(s)))}}),h=Array.isArray(u)?u.length:0;if(h>0){const t=e.slice(u[h-1][1]);e=u.reduce(((t,n,i,a)=>(r&&(s=20+Math.floor(i/h*80),s!==o&&(o=s,r(s))),t+e.slice(0===i?0:a[i-1][1],a[i][0])+(a[i][2]||""))),""),e+=t}return e}(e,t,(e=>{n.reportProgressFunc&&q>=2e3&&(V=Math.floor(s+e/100*(n.reportProgressFuncTo-s)),V!==G&&(G=V,n.reportProgressFunc(V)))})),a=o.length;return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:q,cleanedLength:a,bytesSaved:Math.max(q-a,0),percentageReducedOfOriginal:q?Math.round(100*Math.max(q-a,0)/q):0},ranges:t,applicableOpts:M,result:o}}}return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:q,cleanedLength:q,bytesSaved:0,percentageReducedOfOriginal:0},applicableOpts:M,ranges:null,result:e}},e.defaults=R,e.version="5.0.4",Object.defineProperty(e,"__esModule",{value:!0})}));
86
+ const A=" ";function S(e,t=0){return function({str:e,idx:t=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if("string"!=typeof e||!e.length)return null;if(t&&"number"==typeof t||(t=0),!e[t+1])return null;if(e[t+1]&&(e[t+1].trim()||r&&"\n\r".includes(e[t+1])||n&&e[t+1]===A))return t+1;if(e[t+2]&&(e[t+2].trim()||r&&"\n\r".includes(e[t+2])||n&&e[t+2]===A))return t+2;for(let i=t+1,s=e.length;i<s;i++)if(e[i].trim()||r&&"\n\r".includes(e[i])||n&&e[i]===A)return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function $(e,t=0){return function({str:e,idx:t,stopAtNewlines:r,stopAtRawNbsp:n}){if("string"!=typeof e||!e.length)return null;if(t&&"number"==typeof t||(t=0),t<1)return null;if(e[~-t]&&(e[~-t].trim()||r&&"\n\r".includes(e[~-t])||n&&e[~-t]===A))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&"\n\r".includes(e[t-2])||n&&e[t-2]===A))return t-2;for(let i=t;i--;)if(e[i]&&(e[i].trim()||r&&"\n\r".includes(e[i])||n&&e[i]===A))return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}const C=new class{constructor(e){const t={...c,...e};if(t.mergeType&&1!==t.mergeType&&2!==t.mergeType)if(f(t.mergeType)&&"1"===t.mergeType.trim())t.mergeType=1;else{if(!f(t.mergeType)||"2"!==t.mergeType.trim())throw new Error(`ranges-push: [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)}`);t.mergeType=2}this.opts=t,this.ranges=[]}ranges;opts;add(e,t,r){if(null==e&&null==t)return;if(u(e)&&!u(t)){if(Array.isArray(e)){if(e.length){if(e.some((e=>Array.isArray(e))))return void e.forEach((e=>{Array.isArray(e)&&this.add(...e)}));e.length&&h(+e[0])&&h(+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(t,null,0)})`)}if(!u(e)&&u(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);const n=+e,i=+t;if(h(r)&&(r=String(r)),!h(n)||!h(i))throw h(n)&&n>=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 i}" equal to: ${JSON.stringify(i,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 n}" equal to: ${JSON.stringify(n,null,4)}`);if(u(r)&&!f(r)&&!h(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`);if(u(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=i,this.last(),null!==this.last()[2]&&u(r)){let e=!(this.last()[2]&&this.last()[2].length>0)||this.opts&&this.opts.mergeType&&1!==this.opts.mergeType?r:this.last()[2]+r;this.opts.limitToBeAddedWhitespace&&(e=s(e,this.opts.limitLinebreaksCount)),f(e)&&!e.length||(this.last()[2]=e)}}else{this.ranges||(this.ranges=[]);const e=void 0===r||f(r)&&!r.length?[n,i]:[n,i,r&&this.opts.limitToBeAddedWhitespace?s(r,this.opts.limitLinebreaksCount):r];this.ranges.push(e)}}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=function(e,t){function r(e){return e&&"object"==typeof e&&!Array.isArray(e)}if(!Array.isArray(e)||!e.length)return null;let n;if(t){if(!r(t))throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n${JSON.stringify(t,null,4)} (type ${typeof t})`);if(n={...l,...t},n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&"function"!=typeof n.progressFn)throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(n.mergeType&&1!=+n.mergeType&&2!=+n.mergeType)throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if("boolean"!=typeof n.joinRangesThatTouchEdges)throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else n={...l};const i=e.filter((e=>e)).map((e=>[...e])).filter((e=>void 0!==e[2]||e[0]!==e[1]));let s,o,u;if(s=n.progressFn?a(i,{progressFn:e=>{u=Math.floor(e/5),u!==o&&(o=u,n.progressFn(u))}}):a(i),!s)return null;const h=s.length-1;for(let e=h;e>0;e--)n.progressFn&&(u=Math.floor(78*(1-e/h))+21,u!==o&&u>o&&(o=u,n.progressFn(u))),(s[e][0]<=s[e-1][0]||!n.joinRangesThatTouchEdges&&s[e][0]<s[e-1][1]||n.joinRangesThatTouchEdges&&s[e][0]<=s[e-1][1])&&(s[e-1][0]=Math.min(s[e][0],s[e-1][0]),s[e-1][1]=Math.max(s[e][1],s[e-1][1]),void 0!==s[e][2]&&(s[e-1][0]>=s[e][0]||s[e-1][1]<=s[e][1])&&null!==s[e-1][2]&&(null===s[e][2]&&null!==s[e-1][2]?s[e-1][2]=null:null!=s[e-1][2]?2==+n.mergeType&&s[e-1][0]===s[e][0]?s[e-1][2]=s[e][2]:s[e-1][2]+=s[e][2]:s[e-1][2]=s[e][2]),s.splice(e,1),e=s.length);return s.length?s:null}(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map((e=>u(e[2])?[e[0],e[1],s(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])||!h(e[0][0]))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.`);this.ranges=Array.from(e)}else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}}({limitToBeAddedWhitespace:!0}),R={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","\x3c!--[if","\x3c!--<![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"]},M={removeHTMLComments:!1,removeCSSComments:!1};function j(e){return"string"==typeof e}function x(e){return"string"==typeof e&&e.toUpperCase()!==e.toLowerCase()}e.crush=function(e,t){const r=Date.now();if(!j(e))throw void 0===e?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:\n${JSON.stringify(e,null,4)}`);if(t&&"object"!=typeof t)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 t}, equal to ${JSON.stringify(t,null,4)}`);if(t&&Array.isArray(t.breakToTheLeftOf)&&t.breakToTheLeftOf.length)for(let e=0,r=t.breakToTheLeftOf.length;e<r;e++)if(!j(t.breakToTheLeftOf[e]))throw new TypeError(`html-crush: [THROW_ID_05] the opts.breakToTheLeftOf array contains non-string elements! For example, element at index ${e} is of a type "${typeof t.breakToTheLeftOf[e]}" and is equal to:\n${JSON.stringify(t.breakToTheLeftOf[e],null,4)}`);const n={...R,...t};"boolean"==typeof n.removeHTMLComments&&(n.removeHTMLComments=n.removeHTMLComments?1:0);let s="";Array.isArray(n.breakToTheLeftOf)&&n.breakToTheLeftOf.length&&(s=[...new Set(n.breakToTheLeftOf.map((e=>e[0])))].join(""));let o,a=null,l=null,u=!1,h=0,f=0,c=!1,g=!1,p=null,m=null,d=null,y=null,T=null,v=null,I=null,L=null,A=null,W=null;const E=">};",F="<",N="!",H=">",k="<",B="{},:;<>~+",D=B,J=B;let P=!0;const q=e.length,U=Math.floor(q/2);let z,V;n.reportProgressFunc&&(z=Math.floor(n.reportProgressFuncTo-.01*(n.reportProgressFuncTo-n.reportProgressFuncFrom)-n.reportProgressFuncFrom));let G=0,Y="\n";if(e.includes("\r\n")?Y="\r\n":e.includes("\r")&&(Y="\r"),q){for(let t=0;t<q;t++)if(n.reportProgressFunc&&(q>1e3&&q<2e3?t===U&&n.reportProgressFunc(Math.floor((n.reportProgressFuncTo-n.reportProgressFuncFrom)/2)):q>=2e3&&(V=n.reportProgressFuncFrom+Math.floor(t/q*(z||1)),V!==G&&(G=V,n.reportProgressFunc(V)))),f++,!o&&c&&"}"===e[t]&&"}"===e[t-1]&&(h+1>=n.lineLengthLimit?(C.push(t,t,Y),h=0):(T=t,v=t,I=" ")),o&&"number"==typeof o&&t>=o&&(o=void 0),null===y||!e.startsWith("</script",t)||x(e[t+8])){if(!o&&!c&&e.startsWith("<script",t)&&!x(e[t+7])){y=t,o=!0;let e="";(n.removeLineBreaks||n.removeIndentations)&&null!==l&&(l>0&&(e=Y),C.push(l,t,e)),l=null,a=null}if(null!==A&&null===L&&!/\w/.test(e[t])){L=e.slice(A,t);const r=S(e,~-t);"number"==typeof r&&">"===e[r]&&!e[t].trim()&&S(e,t)?C.push(t,S(e,t)):r&&"/"===e[r]&&">"===e[S(e,r)]&&(!e[t].trim()&&S(e,t)&&C.push(t,S(e,t)),">"!==e[r+1]&&S(e,r+1)&&C.push(r+1,S(e,r+1)))}if(o||c||p||"<"!==e[~-t]||null!==A||(/\w/.test(e[t])?A=t:"/"===e[S(e,~-t)]&&/\w/.test(e[S(e,S(e,~-t))]||"")&&(A=S(e,S(e,~-t)))),o||!c&&!p||null===m||"*"!==e[t]||"/"!==e[t+1]||([T,v]=O({str:e,from:m,to:t+2,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J}),m=null,null!=T?C.push(T,v):(h+=1,t+=1),o=t+2),o||!c&&!p||null!==m||"/"!==e[t]||"*"!==e[t+1]||(M.removeCSSComments||(M.removeCSSComments=!0),n.removeCSSComments&&(m=t)),g&&e.startsWith("![endif",t+1)&&(g=!1),!o&&!c&&!p&&null!==d){let r;e.startsWith("--\x3e",t)?r=3:">"===e[t]&&"]"===e[t-1]&&(r=1),r&&([T,v]=O({str:e,from:d,to:t+r}),d=null,null!=T?n.lineLengthLimit&&f-(v-T)>=n.lineLengthLimit?(C.push(T,v,Y),f=-r):(C.push(T,v),f-=v-T):(h+=r-1,t+=r-1),o=t+r)}if(o||c||p||!e.startsWith("\x3c!--",t)||null!==d||(e.startsWith("[if",t+4)?(g||(g=!0),2===n.removeHTMLComments&&(d=t)):!n.removeHTMLComments||g&&2!==n.removeHTMLComments||(d=t),M.removeHTMLComments||(M.removeHTMLComments=!0)),!o&&c&&null===m&&e.startsWith("</style",t)&&!x(e[t+7])?c=!1:o||c||null!==m||!e.startsWith("<style",t)||x(e[t+6])||(c=!0,(n.removeLineBreaks||n.removeIndentations)&&n.breakToTheLeftOf.includes("<style")&&e.startsWith(' type="text/css">',t+6)&&e[t+24]&&C.push(t+23,t+23,Y)),!o&&!p&&"\"'".includes(e[t])&&e.endsWith("style=",t)&&(p=t),o||e[t].trim()){if(!o&&(!c&&!p||null===m)){if(null!==l){if(n.removeLineBreaks&&(h+=1),P)P=!1,(n.removeIndentations||n.removeLineBreaks)&&C.push(0,t);else if(n.removeIndentations&&!n.removeLineBreaks&&(!u&&null!==a&&t>a?C.push(a+1,t):l+1<t&&(e.endsWith("]>",l)||e.endsWith("--\x3e",l)||e.startsWith("<![",t)||e.startsWith("\x3c!--<![",t)?C.push(l,t):" "===e[l]?C.push(l+1,t):" "===e[~-t]?C.push(l,~-t):C.push(l,t," "))),n.removeLineBreaks||p){if(s.includes(e[t])&&w(e,t,n.breakToTheLeftOf)){"\r\n".includes(e[~-t])&&l===~-t||"\n"===e[~-t]&&"\r"===e[t-2]&&l===t-2||C.push(l,t,Y),T=null,v=null,I=null,l=null,h=1;continue}let r=" ";"<"===e[t]&&_(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||(e[~-l]&&H.includes(e[~-l])&&k.includes(e[t])||(c||p)&&null===m&&(D.includes(e[~-l])||J.includes(e[t]))||e.startsWith("!important",t)&&!g||p&&("'"===e[~-l]||'"'===e[~-l])||"}"===e[~-l]&&e.startsWith("</style",t)||">"===e[t]&&("'\"".includes(e[$(e,t)])||"<"===e[S(e,t)])||"/"===e[t]&&">"===e[S(e,t)])&&(r="","/"===e[t]&&">"===e[t+1]&&S(e,t)&&S(e,t)>t+1&&(C.push(t+1,S(e,t)),h-=S(e,t)-t+1)),c&&"}"===e[t]&&l&&"}"===e[l-1]&&(r=" "),r&&r.length&&(h+=1),n.lineLengthLimit?h>=n.lineLengthLimit||!e[t+1]||">"===e[t]||"/"===e[t]&&">"===e[t+1]?((h>n.lineLengthLimit||h===n.lineLengthLimit&&e[t+1]&&e[t+1].trim()&&!E.includes(e[t])&&!F.includes(e[t+1]))&&(r=Y,h=1),(h>n.lineLengthLimit||" "!==r||t!==l+1)&&(C.push(l,t,r),a=null),T=null,v=null,I=null):(null===T||l<T)&&(T=l,v=t,I=r):t===l+1&&" "===r||C.push(l,t,r)}l=null,u||(u=!0)}else P&&(P=!1),n.removeLineBreaks&&(h+=1);u||(u=!0)}}else null===l&&(l=t);if(!o&&!P&&0!==t&&n.removeLineBreaks&&(n.lineLengthLimit||s)&&!e.startsWith("</a",t)){if(s&&w(e,t,n.breakToTheLeftOf)&&e.slice(0,t).trim()&&(!e.startsWith("<![endif]",t)||!b(e,t,"\x3c!--"))){C.push(t,t,Y),T=null,v=null,I=null,h=1;continue}if(n.lineLengthLimit&&h<=n.lineLengthLimit){if(!e[t+1]||F.includes(e[t])&&!N.includes(e[t])||E.includes(e[t])||!e[t].trim()){if(null!==T&&null!==v&&(T!==v||I&&I.length)){let r=I;e[t].trim()&&e[t+1]&&e[t+1].trim()&&h+(I?I.length:0)>n.lineLengthLimit&&(r=Y),(h+(r?r.length:0)>n.lineLengthLimit||" "!==r||v!==T+1||" "!==e[T])&&("}"===e[~-T]&&"{"===e[v]||(C.push(T,v,r),a=null))}!(e[t].trim()&&(F.includes(e[t])||e[~-t]&&E.includes(e[~-t]))&&j(W))||L&&n.mindTheInlineTags.includes(L)||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})?null!==m||null===T||!(p||!n.mindTheInlineTags||!Array.isArray(n.mindTheInlineTags)||Array.isArray(n.mindTheInlineTags.length)&&!n.mindTheInlineTags.length||!j(L)||Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&j(L)&&!n.mindTheInlineTags.includes(L))||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})||(T=null,v=null,I=null):(T=t,v=t,I=null)}}else if(n.lineLengthLimit)if(!F.includes(e[t])||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)}))e[t+1]&&E.includes(e[t])&&j(L)&&Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&!n.mindTheInlineTags.includes(L)?null!==T&&null!==v&&(T!==v||I&&I.length)||(C.push(t+1,t+1,Y),h=0):e[t].trim()&&(e[t+1]||null!==T&&null!==v&&(T!==v||I&&I.length)&&C.push(T,v,Y));else if(null!==T&&null!==v&&(T!==v||I&&I.length)){const e=I&&I.length?I.length:0;h-(v-T-e)-1>n.lineLengthLimit||(C.push(T,v,I),h-(v-T-e)-1===n.lineLengthLimit&&(C.push(t,t,Y),h=0),T=null,v=null,I=null)}else C.push(t,t,Y),h=0}if(!o&&!P&&n.removeLineBreaks&&n.lineLengthLimit&&h>=n.lineLengthLimit&&null!==T&&null!==v&&!E.includes(e[t])&&!F.includes(e[t])&&!"/".includes(e[t])&&(h!==n.lineLengthLimit||!e[t+1]||e[t+1].trim())){let r=Y;e[t+1]&&!e[t+1].trim()&&h===n.lineLengthLimit&&(r=I),r===Y&&!e[~-T].trim()&&$(e,T)&&(T=$(e,T)+1),C.push(T,v,r),h=t-v,e[t].length&&(h+=1),T=null,v=null,I=null}if((!o&&"\n"===e[t]||"\r"===e[t]&&(!e[t+1]||e[t+1]&&"\n"!==e[t+1]))&&(a=t,u&&(u=!1),!n.removeLineBreaks&&null!==l&&l<t&&e[t+1]&&"\r"!==e[t+1]&&"\n"!==e[t+1]&&C.push(l,t)),e[t+1]||(c&&null!==m?C.push(...O({str:e,from:m,to:t,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J})):l&&"\n"!==e[t]&&"\r"!==e[t]?C.push(l,t+1):l&&("\r"===e[t]&&"\n"===e[t+1]||"\n"===e[t]&&"\r"!==e[t-1])&&C.push(l,t)),!o&&p&&p<t&&e[p]===e[t]&&(p=null),!o&&!c&&e.startsWith("<pre",t)&&!x(e[t+4])){const r=e.indexOf("</pre",t+5);r>0&&(o=r)}if(!o&&!c&&e.startsWith("<code",t)&&!x(e[t+5])){const r=e.indexOf("</code",t+5);r>0&&(o=r)}if(!o&&e.startsWith("<![CDATA[",t)){const r=e.indexOf("]]>",t+9);r>0&&(o=r)}o||c||p||null===A||">"!==e[t]||("<"===e[S(e,t)]&&(W=L),A=null,L=null),"<"===e[t]&&null!==W&&(W=null),c&&"{"===e[t]&&"{"===e[t+1]&&-1!==e.indexOf("}}")&&(o=e.indexOf("}}")+2)}else{if((n.removeIndentations||n.removeLineBreaks)&&t>0&&e[~-t]&&!e[~-t].trim())for(let r=t;r--;)if("\n"===e[r]||"\r"===e[r]||e[r].trim()){r+1<t&&C.push(r+1,t);break}y=null,o=!1,t+=8}if(C.current()){const t=C.current();C.wipe();const s=n.reportProgressFuncTo-.01*(n.reportProgressFuncTo-n.reportProgressFuncFrom),o=function(e,t,r){let n,s=0,o=0;if(0===arguments.length)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if("string"!=typeof e)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(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&"function"!=typeof r)throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter((e=>e)).length)return e;n=Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?[Array.from(t)]:Array.from(t);const a=n.length;let l=0;n.filter((e=>e)).forEach(((e,t)=>{if(r&&(s=Math.floor(l/a*10),s!==o&&(o=s,r(s))),!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${t}th element not an array: ${JSON.stringify(e,null,4)}, which is ${typeof e}`);if(!Number.isInteger(e[0])){if(!Number.isInteger(+e[0])||+e[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its first element is not an integer, string index, but ${typeof e[0]}, equal to: ${JSON.stringify(e[0],null,4)}.`);n[t][0]=+n[t][0]}if(!Number.isInteger(e[1])){if(!Number.isInteger(+e[1])||+e[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its second element is not an integer, string index, but ${typeof e[1]}, equal to: ${JSON.stringify(e[1],null,4)}.`);n[t][1]=+n[t][1]}l+=1}));const u=i(n,{progressFn:e=>{r&&(s=10+Math.floor(e/10),s!==o&&(o=s,r(s)))}}),h=Array.isArray(u)?u.length:0;if(h>0){const t=e.slice(u[h-1][1]);e=u.reduce(((t,n,i,a)=>(r&&(s=20+Math.floor(i/h*80),s!==o&&(o=s,r(s))),t+e.slice(0===i?0:a[i-1][1],a[i][0])+(a[i][2]||""))),""),e+=t}return e}(e,t,(e=>{n.reportProgressFunc&&q>=2e3&&(V=Math.floor(s+e/100*(n.reportProgressFuncTo-s)),V!==G&&(G=V,n.reportProgressFunc(V)))})),a=o.length;return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:q,cleanedLength:a,bytesSaved:Math.max(q-a,0),percentageReducedOfOriginal:q?Math.round(100*Math.max(q-a,0)/q):0},ranges:t,applicableOpts:M,result:o}}}return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:q,cleanedLength:q,bytesSaved:0,percentageReducedOfOriginal:0},applicableOpts:M,ranges:null,result:e}},e.defaults=R,e.version="5.0.5",Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-crush",
3
- "version": "5.0.4",
3
+ "version": "5.0.5",
4
4
  "description": "Minifies HTML/CSS: valid or broken, pure or mixed with other languages",
5
5
  "keywords": [
6
6
  "breaks",
@@ -94,12 +94,12 @@
94
94
  },
95
95
  "dependencies": {
96
96
  "@babel/runtime": "^7.16.0",
97
- "ranges-apply": "^6.0.4",
98
- "ranges-push": "^6.0.4",
99
- "string-left-right": "^5.0.4",
100
- "string-match-left-right": "^8.0.4",
101
- "string-range-expander": "^3.0.4",
102
- "test-mixer": "^3.0.4"
97
+ "ranges-apply": "^6.0.5",
98
+ "ranges-push": "^6.0.5",
99
+ "string-left-right": "^5.0.5",
100
+ "string-match-left-right": "^8.0.5",
101
+ "string-range-expander": "^3.0.5",
102
+ "test-mixer": "^3.0.5"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@babel/cli": "^7.16.0",
@@ -128,15 +128,15 @@
128
128
  "@typescript-eslint/parser": "^5.3.0",
129
129
  "core-js": "^3.19.1",
130
130
  "cross-env": "^7.0.3",
131
- "eslint": "^8.1.0",
132
- "lect": "^0.18.4",
131
+ "eslint": "^8.2.0",
132
+ "lect": "^0.18.5",
133
133
  "node-fetch": "^3.0.0",
134
134
  "p-map": "^5.3.0",
135
135
  "rollup": "^2.59.0",
136
136
  "rollup-plugin-ascii": "^0.0.3",
137
137
  "rollup-plugin-banner": "^0.2.1",
138
138
  "rollup-plugin-cleanup": "^3.2.1",
139
- "rollup-plugin-dts": "^4.0.0",
139
+ "rollup-plugin-dts": "^4.0.1",
140
140
  "rollup-plugin-node-builtins": "^2.1.2",
141
141
  "rollup-plugin-terser": "^7.0.2",
142
142
  "tap": "^15.0.10",