html-crush 5.1.16 → 5.1.18
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 +18 -42
- package/dist/html-crush.esm.js +2 -2
- package/dist/html-crush.umd.js +11 -11
- package/package.json +7 -7
- package/examples/_quickTake.js +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +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.1.0 (2022-08-12)
|
|
7
|
-
|
|
8
|
-
### Features
|
|
9
|
-
|
|
10
|
-
- export types ([11b5fb9](https://github.com/codsen/codsen/commit/11b5fb936ce20e0a77c3a09806773e1cd7695c50))
|
|
11
|
-
|
|
12
6
|
## [5.0.22](https://github.com/codsen/codsen/compare/html-crush@5.0.21...html-crush@5.0.22) (2022-08-02)
|
|
13
7
|
|
|
14
8
|
### Bug Fixes
|
|
@@ -21,24 +15,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
21
15
|
|
|
22
16
|
- tweak types ([104a64a](https://github.com/codsen/codsen/commit/104a64ab783c05af4ae8bd3eb653742eb95d0cd2))
|
|
23
17
|
|
|
24
|
-
## 5.0.10 (2021-12-24)
|
|
25
|
-
|
|
26
|
-
### Bug Fixes
|
|
27
|
-
|
|
28
|
-
- add missing extension ([147bd6e](https://github.com/codsen/codsen/commit/147bd6ec2a2d44c09749f0fba0ca3e3d9c52da94))
|
|
29
|
-
|
|
30
|
-
## 5.0.9 (2021-12-24)
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
- add missing extension ([147bd6e](https://github.com/codsen/codsen/commit/147bd6ec2a2d44c09749f0fba0ca3e3d9c52da94))
|
|
35
|
-
|
|
36
|
-
## 5.0.8 (2021-12-24)
|
|
37
|
-
|
|
38
|
-
### Bug Fixes
|
|
39
|
-
|
|
40
|
-
- add missing extension ([147bd6e](https://github.com/codsen/codsen/commit/147bd6ec2a2d44c09749f0fba0ca3e3d9c52da94))
|
|
41
|
-
|
|
42
18
|
## 5.0.0 (2021-09-09)
|
|
43
19
|
|
|
44
20
|
### Bug Fixes
|
|
@@ -229,45 +205,45 @@ That's now implemented.
|
|
|
229
205
|
|
|
230
206
|
## 0.8.0 (2019-01-20)
|
|
231
207
|
|
|
232
|
-
-
|
|
233
|
-
-
|
|
208
|
+
- Various documentation and setup tweaks after we migrated to monorepo
|
|
209
|
+
- Setup refresh: updated dependencies and all config files using automated tools
|
|
234
210
|
|
|
235
211
|
## 0.7.0 (2019-01-11)
|
|
236
212
|
|
|
237
|
-
-
|
|
213
|
+
- Add one more tag before which there will be a line break ([4f00871](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/4f00871))
|
|
238
214
|
|
|
239
215
|
## 0.6.0 (2018-12-26)
|
|
240
216
|
|
|
241
|
-
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
-
|
|
246
|
-
-
|
|
247
|
-
-
|
|
248
|
-
-
|
|
217
|
+
- Add licence block at the top of built files in dist/ folder ([cb2c259](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/cb2c259))
|
|
218
|
+
- Add more logging for doNothing state ([25262e5](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/25262e5))
|
|
219
|
+
- Do not touch CDATA blocks ([920e9d9](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/920e9d9))
|
|
220
|
+
- Don't minify script tags contents ([557e8fa](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/557e8fa))
|
|
221
|
+
- Don't touch code within pre-code blocks ([d32c092](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/d32c092))
|
|
222
|
+
- Fetch a handful of real websites and minify them for tests ([f7e8153](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/f7e8153))
|
|
223
|
+
- Remove whitespace within `<script>` blocks, in front of `</script>` ([d1efb20](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/d1efb20))
|
|
224
|
+
- Treat the whitespace in front of `<script>` ([75d85dc](https://gitlab.com/codsen/codsen/tree/master/packages/html-crush/commits/75d85dc))
|
|
249
225
|
|
|
250
226
|
## 0.5.0 (2018-12-14)
|
|
251
227
|
|
|
252
|
-
-
|
|
253
|
-
-
|
|
228
|
+
- Added licence banner at the top of each built file (all files in `dist/` folder)
|
|
229
|
+
- Improved readme file
|
|
254
230
|
|
|
255
231
|
## 0.4.0 (2018-12-13)
|
|
256
232
|
|
|
257
|
-
-
|
|
258
|
-
-
|
|
233
|
+
- Delete whitespace within `<script>` tag, before closing `</script>`.
|
|
234
|
+
- Added unit tests minifying a handful of real-world websites. If URL fetch succeeds and source HTML is a string and not an empty-one, we minify with couple settings and measure, are results less than or equal to the original sources.
|
|
259
235
|
|
|
260
236
|
## 0.3.0 (2018-12-12)
|
|
261
237
|
|
|
262
|
-
-
|
|
238
|
+
- Improvements to whitespace control in front of `<script>` tag when some options are on.
|
|
263
239
|
|
|
264
240
|
## 0.2.0 (2018-12-11)
|
|
265
241
|
|
|
266
|
-
-
|
|
242
|
+
- Program will not touch:
|
|
267
243
|
- CDATA blocks
|
|
268
244
|
- `<pre><code>...</code></pre>` blocks
|
|
269
245
|
- `<script>` tag contents
|
|
270
246
|
|
|
271
247
|
## 0.1.0 (2018-12-10)
|
|
272
248
|
|
|
273
|
-
-
|
|
249
|
+
- First public release
|
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 5.1.
|
|
4
|
+
* @version 5.1.18
|
|
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";var Y="5.1.
|
|
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";var Y="5.1.18";var ge=Y,$=new le({limitToBeAddedWhitespace:!0}),te={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 N(n){return typeof n=="string"}function A(n){return typeof n=="string"&&n.toUpperCase()!==n.toLowerCase()}function ce(n,E){let W=Date.now();if(!N(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&&typeof E!="object")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(!N(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={...te,...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="<",B="{},:;<>~+",k=B,J=B,C=!0,h=n.length,Q=Math.floor(h/2),x=.01,j;l.reportProgressFunc&&(j=Math.floor(l.reportProgressFuncTo-(l.reportProgressFuncTo-l.reportProgressFuncFrom)*x-l.reportProgressFuncFrom));let d,R=0,b=`
|
|
13
13
|
`;if(n.includes(`\r
|
package/dist/html-crush.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name html-crush
|
|
3
3
|
* @fileoverview Minify email templates
|
|
4
|
-
* @version 5.1.
|
|
4
|
+
* @version 5.1.18
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/html-crush/}
|
|
@@ -24,7 +24,7 @@ ${JSON.stringify(a.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that arr
|
|
|
24
24
|
\r`.includes(e[a])||n&&e[a]===K)return a;return null}function D(e,t=0){return oi({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function si({str:e,idx:t,stopAtNewlines:r,stopAtRawNbsp:n}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||r&&`
|
|
25
25
|
\r`.includes(e[~-t])||n&&e[~-t]===K))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&`
|
|
26
26
|
\r`.includes(e[t-2])||n&&e[t-2]===K))return t-2;for(let a=t;a--;)if(e[a]&&(e[a].trim()||r&&`
|
|
27
|
-
\r`.includes(e[a])||n&&e[a]===K))return a;return null}function de(e,t=0){return si({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}var zt="5.1.
|
|
27
|
+
\r`.includes(e[a])||n&&e[a]===K))return a;return null}function de(e,t=0){return si({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}var zt="5.1.18";var ai=zt,E=new et({limitToBeAddedWhitespace:!0}),Zt={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 Y(e){return typeof e=="string"}function X(e){return typeof e=="string"&&e.toUpperCase()!==e.toLowerCase()}function ui(e,t){let r=Date.now();if(!Y(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:
|
|
28
28
|
${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")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 i=0,Q=t.breakToTheLeftOf.length;i<Q;i++)if(!Y(t.breakToTheLeftOf[i]))throw new TypeError(`html-crush: [THROW_ID_05] the resolvedOpts.breakToTheLeftOf array contains non-string elements! For example, element at index ${i} is of a type "${typeof t.breakToTheLeftOf[i]}" and is equal to:
|
|
29
29
|
${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.removeHTMLComments=="boolean"&&(n.removeHTMLComments=n.removeHTMLComments?1:0);let a="";Array.isArray(n.breakToTheLeftOf)&&n.breakToTheLeftOf.length&&(a=[...new Set(n.breakToTheLeftOf.map(i=>i[0]))].join(""));let o={removeHTMLComments:!1,removeCSSComments:!1},u=null,l=null,c=!1,s=0,d=0,p=!1,T=!1,f=null,m=null,w=null,L=null,b,h=null,$=null,y=null,A=null,I=null,V=null,z=">};",Z="<",Qt="!",en=">",tn="<",We="{},:;<>~+",be=We,Te=We,j=!0,v=e.length,nn=Math.floor(v/2),je=.01,Je;n.reportProgressFunc&&(Je=Math.floor(n.reportProgressFuncTo-(n.reportProgressFuncTo-n.reportProgressFuncFrom)*je-n.reportProgressFuncFrom));let R,oe=0,C=`
|
|
30
30
|
`;if(e.includes(`\r
|
|
@@ -42,7 +42,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
42
42
|
/**
|
|
43
43
|
* @name arrayiffy-if-string
|
|
44
44
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
45
|
-
* @version 4.1.
|
|
45
|
+
* @version 4.1.2
|
|
46
46
|
* @author Roy Revelt, Codsen Ltd
|
|
47
47
|
* @license MIT
|
|
48
48
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
@@ -50,7 +50,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
50
50
|
/**
|
|
51
51
|
* @name ranges-apply
|
|
52
52
|
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
53
|
-
* @version 6.2.
|
|
53
|
+
* @version 6.2.8
|
|
54
54
|
* @author Roy Revelt, Codsen Ltd
|
|
55
55
|
* @license MIT
|
|
56
56
|
* {@link https://codsen.com/os/ranges-apply/}
|
|
@@ -58,7 +58,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
58
58
|
/**
|
|
59
59
|
* @name ranges-merge
|
|
60
60
|
* @fileoverview Merge and sort string index ranges
|
|
61
|
-
* @version 8.2.
|
|
61
|
+
* @version 8.2.3
|
|
62
62
|
* @author Roy Revelt, Codsen Ltd
|
|
63
63
|
* @license MIT
|
|
64
64
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
@@ -66,7 +66,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
66
66
|
/**
|
|
67
67
|
* @name ranges-push
|
|
68
68
|
* @fileoverview Gather string index ranges
|
|
69
|
-
* @version 6.2.
|
|
69
|
+
* @version 6.2.3
|
|
70
70
|
* @author Roy Revelt, Codsen Ltd
|
|
71
71
|
* @license MIT
|
|
72
72
|
* {@link https://codsen.com/os/ranges-push/}
|
|
@@ -74,7 +74,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
74
74
|
/**
|
|
75
75
|
* @name ranges-sort
|
|
76
76
|
* @fileoverview Sort string index ranges
|
|
77
|
-
* @version 5.1.
|
|
77
|
+
* @version 5.1.2
|
|
78
78
|
* @author Roy Revelt, Codsen Ltd
|
|
79
79
|
* @license MIT
|
|
80
80
|
* {@link https://codsen.com/os/ranges-sort/}
|
|
@@ -82,7 +82,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
82
82
|
/**
|
|
83
83
|
* @name string-collapse-leading-whitespace
|
|
84
84
|
* @fileoverview Collapse the leading and trailing whitespace of a string
|
|
85
|
-
* @version 6.1.
|
|
85
|
+
* @version 6.1.3
|
|
86
86
|
* @author Roy Revelt, Codsen Ltd
|
|
87
87
|
* @license MIT
|
|
88
88
|
* {@link https://codsen.com/os/string-collapse-leading-whitespace/}
|
|
@@ -90,7 +90,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
90
90
|
/**
|
|
91
91
|
* @name string-left-right
|
|
92
92
|
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
93
|
-
* @version 5.1.
|
|
93
|
+
* @version 5.1.3
|
|
94
94
|
* @author Roy Revelt, Codsen Ltd
|
|
95
95
|
* @license MIT
|
|
96
96
|
* {@link https://codsen.com/os/string-left-right/}
|
|
@@ -98,7 +98,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
98
98
|
/**
|
|
99
99
|
* @name string-match-left-right
|
|
100
100
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
101
|
-
* @version 8.2.
|
|
101
|
+
* @version 8.2.3
|
|
102
102
|
* @author Roy Revelt, Codsen Ltd
|
|
103
103
|
* @license MIT
|
|
104
104
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
@@ -106,7 +106,7 @@ ${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Zt),t);typeof n.r
|
|
|
106
106
|
/**
|
|
107
107
|
* @name string-range-expander
|
|
108
108
|
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met
|
|
109
|
-
* @version 3.1.
|
|
109
|
+
* @version 3.1.2
|
|
110
110
|
* @author Roy Revelt, Codsen Ltd
|
|
111
111
|
* @license MIT
|
|
112
112
|
* {@link https://codsen.com/os/string-range-expander/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-crush",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.18",
|
|
4
4
|
"description": "Minify email templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"breaks",
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"ranges-apply": "^6.2.
|
|
82
|
-
"ranges-push": "^6.2.
|
|
83
|
-
"string-left-right": "^5.1.
|
|
84
|
-
"string-match-left-right": "^8.2.
|
|
85
|
-
"string-range-expander": "^3.1.
|
|
86
|
-
"test-mixer": "^3.1.
|
|
81
|
+
"ranges-apply": "^6.2.8",
|
|
82
|
+
"ranges-push": "^6.2.3",
|
|
83
|
+
"string-left-right": "^5.1.3",
|
|
84
|
+
"string-match-left-right": "^8.2.3",
|
|
85
|
+
"string-range-expander": "^3.1.2",
|
|
86
|
+
"test-mixer": "^3.1.2"
|
|
87
87
|
}
|
|
88
88
|
}
|
package/examples/_quickTake.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
// Quick Take
|
|
3
|
-
|
|
4
|
-
import { strict as assert } from "assert";
|
|
5
|
-
|
|
6
|
-
import { crush, defaults, version } from "../dist/html-crush.esm.js";
|
|
7
|
-
|
|
8
|
-
assert.equal(
|
|
9
|
-
crush(
|
|
10
|
-
`<table width="100" border="0" cellpadding="0" cellspacing="0">
|
|
11
|
-
<tr>
|
|
12
|
-
<td>
|
|
13
|
-
hi
|
|
14
|
-
</td>
|
|
15
|
-
</tr>
|
|
16
|
-
</table>`,
|
|
17
|
-
{ removeLineBreaks: true }
|
|
18
|
-
).result,
|
|
19
|
-
`<table width="100" border="0" cellpadding="0" cellspacing="0"><tr><td> hi
|
|
20
|
-
</td></tr></table>`
|
|
21
|
-
);
|