hyperbuild 0.1.12 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cad15272abd95d79881d6d56d99f743627436488cddfbcf1bee632b912e1f58
4
- data.tar.gz: cd671f2a74fc1b577396cb04411431b5f1865f363747a0a578673551a011e790
3
+ metadata.gz: 2d7fbd72c38ff0d0538916b9ff6e00a84adf12124666dd14d7813d7afe128242
4
+ data.tar.gz: 61e2dbc5bb2f90f2d7d09e85e8763ccf2394d40a2bc68273c7b9d2eccbc13c17
5
5
  SHA512:
6
- metadata.gz: '05259be3bcb59ead8c44b7574f6e6e2a21b4cb2f82fbea9ee54608fbb5b31f5fd4f24071be31d509b215190c77fb9155364a8a8b41111093a9b6c62d2f107af1'
7
- data.tar.gz: afada323b7945068258a5c956c008f68cdde3b91bef2a6976927510ef4da3f39fa6db0ec25a30ff15fb891a5d0e2fc8764ae14a4289bb32f11666060bac845d2
6
+ metadata.gz: c880cc9b43f1267b413b7966c7c372f3837c68f236b2051df048b848de4f04ef55a89e18de02a9d5c4178dee6c42e2a12d9e14be1f22fad032d2aeea7b3edd84
7
+ data.tar.gz: 8e42e3e6ba37452d39fcc516bfa6705f876eb4550dafe01cd1cebc3448b3fe0bae11fbd8c81358af8c0e40f091cc72d7bb81358770fe2fdf5ab67ea82f1c0cba
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A fast one-pass in-place HTML minifier written in Rust with context-aware whitespace handling.
4
4
 
5
+ Also supports JS minification by plugging into [esbuild](https://github.com/evanw/esbuild).
6
+
5
7
  Available as:
6
8
  - CLI for Windows, macOS, and Linux.
7
9
  - Rust library.
@@ -12,12 +14,13 @@ Available as:
12
14
  - Minification is done in one pass with no backtracking or DOM/AST building.
13
15
  - No extra heap memory is allocated during processing, which increases performance.
14
16
  - Context-aware whitespace handling allows maximum minification while retaining desired spaces.
17
+ - Well tested with a large test suite and extensive [fuzzing](./fuzz).
15
18
 
16
19
  ## Performance
17
20
 
18
21
  Speed and effectiveness of Node.js version compared to [html-minfier](https://github.com/kangax/html-minifier) and [minimize](https://github.com/Swaagie/minimize), run on popular already-minified web pages. See [bench](./bench) folder for more details.
19
22
 
20
- <img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.12/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.12/average-sizes.png">
23
+ <img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.2.2/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.2.2/average-sizes.png">
21
24
 
22
25
  ## Usage
23
26
 
@@ -25,14 +28,18 @@ Speed and effectiveness of Node.js version compared to [html-minfier](https://gi
25
28
 
26
29
  Precompiled binaries are available for x86-64 Windows, macOS, and Linux.
27
30
 
31
+ Building from source currently requires the Go compiler to be installed as well, to build the [JS minifier](https://github.com/evanw/esbuild).
32
+
28
33
  ##### Get
29
34
 
30
- [Windows](https://wilsonl.in/hyperbuild/bin/0.1.12-windows-x86_64.exe) |
31
- [macOS](https://wilsonl.in/hyperbuild/bin/0.1.12-macos-x86_64) |
32
- [Linux](https://wilsonl.in/hyperbuild/bin/0.1.12-linux-x86_64)
35
+ [Windows](https://wilsonl.in/hyperbuild/bin/0.2.2-windows-x86_64.exe) |
36
+ [macOS](https://wilsonl.in/hyperbuild/bin/0.2.2-macos-x86_64) |
37
+ [Linux](https://wilsonl.in/hyperbuild/bin/0.2.2-linux-x86_64)
33
38
 
34
39
  ##### Use
35
40
 
41
+ Use the `--help` argument for more details.
42
+
36
43
  ```bash
37
44
  hyperbuild --src /path/to/src.html --out /path/to/output.min.html
38
45
  ```
@@ -46,34 +53,37 @@ hyperbuild --src /path/to/src.html --out /path/to/output.min.html
46
53
 
47
54
  ```toml
48
55
  [dependencies]
49
- hyperbuild = "0.1.12"
56
+ hyperbuild = "0.2.2"
50
57
  ```
51
58
 
52
59
  ##### Use
53
60
 
54
61
  ```rust
55
- use hyperbuild::{FriendlyError, hyperbuild};
62
+ use hyperbuild::{Cfg, FriendlyError, hyperbuild, hyperbuild_copy, hyperbuild_friendly_error, hyperbuild_truncate};
56
63
 
57
64
  fn main() {
58
65
  let mut code = b"<p> Hello, world! </p>".to_vec();
66
+ let cfg = &Cfg {
67
+ minify_js: false,
68
+ };
59
69
 
60
70
  // Minifies a slice in-place and returns the new minified length,
61
71
  // but leaves any original code after the minified code intact.
62
- match hyperbuild(&mut code) {
72
+ match hyperbuild(&mut code, cfg) {
63
73
  Ok(minified_len) => {}
64
74
  Err((error_type, error_position)) => {}
65
75
  };
66
76
 
67
77
  // Creates a vector copy containing only minified code
68
78
  // instead of minifying in-place.
69
- match hyperbuild_copy(&code) {
79
+ match hyperbuild_copy(&code, cfg) {
70
80
  Ok(minified) => {}
71
81
  Err((error_type, error_position)) => {}
72
82
  };
73
83
 
74
84
  // Minifies a vector in-place, and then truncates the
75
85
  // vector to the new minified length.
76
- match hyperbuild_truncate(&mut code) {
86
+ match hyperbuild_truncate(&mut code, cfg) {
77
87
  Ok(()) => {}
78
88
  Err((error_type, error_position)) => {}
79
89
  };
@@ -81,7 +91,7 @@ fn main() {
81
91
  // Identical to `hyperbuild` except with FriendlyError instead.
82
92
  // `code_context` is a string of a visual representation of the source,
83
93
  // with line numbers and position markers to aid in debugging syntax.
84
- match hyperbuild_friendly_error(&mut code) {
94
+ match hyperbuild_friendly_error(&mut code, cfg) {
85
95
  Ok(minified_len) => {}
86
96
  Err(FriendlyError { position, message, code_context }) => {
87
97
  eprintln!("Failed at character {}:", position);
@@ -118,10 +128,11 @@ yarn add hyperbuild
118
128
  ```js
119
129
  const hyperbuild = require("hyperbuild");
120
130
 
121
- const minified = hyperbuild.minify("<p> Hello, world! </p>");
131
+ const cfg = { minifyJs: false };
132
+ const minified = hyperbuild.minify("<p> Hello, world! </p>", cfg);
122
133
 
123
134
  // Alternatively, minify in place to avoid copying.
124
- const source = Buffer.from("<p> Hello, world! </p>");
135
+ const source = Buffer.from("<p> Hello, world! </p>", cfg);
125
136
  hyperbuild.minifyInPlace(source);
126
137
  ```
127
138
 
@@ -131,8 +142,9 @@ hyperbuild is also available for TypeScript:
131
142
  import * as hyperbuild from "hyperbuild";
132
143
  import * as fs from "fs";
133
144
 
134
- const minified = hyperbuild.minify("<p> Hello, world! </p>");
135
- hyperbuild.minifyInPlace(fs.readFileSync("source.html"));
145
+ const cfg = { minifyJs: false };
146
+ const minified = hyperbuild.minify("<p> Hello, world! </p>", cfg);
147
+ hyperbuild.minifyInPlace(fs.readFileSync("source.html"), cfg);
136
148
  ```
137
149
 
138
150
  </details>
@@ -150,7 +162,7 @@ Add as a Maven dependency:
150
162
  <dependency>
151
163
  <groupId>in.wilsonl.hyperbuild</groupId>
152
164
  <artifactId>hyperbuild</artifactId>
153
- <version>0.1.12</version>
165
+ <version>0.2.2</version>
154
166
  </dependency>
155
167
  ```
156
168
 
@@ -159,15 +171,18 @@ Add as a Maven dependency:
159
171
  ```java
160
172
  import in.wilsonl.hyperbuild.Hyperbuild;
161
173
 
174
+ Hyperbuild.Configuration cfg = new Hyperbuild.Configuration.Builder()
175
+ .setMinifyJs(false)
176
+ .build();
162
177
  try {
163
- String minified = Hyperbuild.minify("<p> Hello, world! </p>");
178
+ String minified = Hyperbuild.minify("<p> Hello, world! </p>", cfg);
164
179
  } catch (Hyperbuild.SyntaxException e) {
165
180
  System.err.println(e.getMessage());
166
181
  }
167
182
 
168
183
  // Alternatively, minify in place:
169
184
  assert source instanceof ByteBuffer && source.isDirect();
170
- Hyperbuild.minifyInPlace(source);
185
+ Hyperbuild.minifyInPlace(source, cfg);
171
186
  ```
172
187
 
173
188
  </details>
@@ -187,7 +202,7 @@ Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
187
202
  import hyperbuild
188
203
 
189
204
  try:
190
- minified = hyperbuild.minify("<p> Hello, world! </p>")
205
+ minified = hyperbuild.minify("<p> Hello, world! </p>", minify_js=False)
191
206
  except SyntaxError as e:
192
207
  print(e)
193
208
  ```
@@ -208,17 +223,13 @@ Add the library as a dependency to `Gemfile` or `*.gemspec`.
208
223
  ```ruby
209
224
  require 'hyperbuild'
210
225
 
211
- print Hyperbuild.minify "<p> Hello, world! </p>"
226
+ print Hyperbuild.minify("<p> Hello, world! </p>", { :minify_js => false })
212
227
  ```
213
228
 
214
229
  </details>
215
230
 
216
231
  ## Minification
217
232
 
218
- ### Configurability
219
-
220
- Configuration of minification is currently WIP across all languages. The behaviour mentioned below is the default.
221
-
222
233
  ### Whitespace
223
234
 
224
235
  hyperbuild has advanced context-aware whitespace minification that does things such as:
@@ -456,7 +467,7 @@ Bangs, [processing instructions](https://en.wikipedia.org/wiki/Processing_Instru
456
467
 
457
468
  Only UTF-8/ASCII-encoded HTML code is supported.
458
469
 
459
- hyperbuild simply does HTML minification, and almost does no syntax checking or standards enforcement for performance and code complexity reasons.
470
+ hyperbuild does no syntax checking or standards enforcement for performance and code complexity reasons.
460
471
 
461
472
  For example, this means that it's not an error to have self-closing tags, declare multiple `<body>` elements, use incorrect attribute names and values, or write something like `<br>alert('');</br>`
462
473
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilson Lin
@@ -62,6 +62,5 @@ rubyforge_project:
62
62
  rubygems_version: 2.7.6.2
63
63
  signing_key:
64
64
  specification_version: 4
65
- summary: Fast one-pass in-place HTML minifier written in Rust with context-aware whitespace
66
- handling
65
+ summary: Fast allocation-less HTML minifier with smart whitespace handling
67
66
  test_files: []