hyperbuild 0.0.44 → 0.1.1

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: c08a3df4ded7e9f0e90457cbcd2bece9e33ebe8ce47246f0e6a93095a517ea19
4
- data.tar.gz: 0bb130c76c5ed061cf3610ce73a9a2b0ebab72f12df0d16767330c8d7cc61f63
3
+ metadata.gz: 1caffe6030b630477a348d3ec79ff73b6f67b1abbab3caff22a7cba2252da378
4
+ data.tar.gz: 29c61e146de8f1ca6084879d6dbf50168fbc9cf7cd5019f22699df3a2f2bf751
5
5
  SHA512:
6
- metadata.gz: d74715dc36e9201b399401b944eb27348e5a0a88885d6db4f9aa609db048f251496bc0b9acbb5f9dea5978789b15d72504be64febc6905b251af200a1bf037fd
7
- data.tar.gz: db810d4b7e4290c5f07dfd7c2302ad1396d07d614a1c5fbc153d8e5fc9e273f589e59bc36c3023748693d9e4646864198160bf4e7c1e70571ae84db7a0dc874a
6
+ metadata.gz: 13bb7e4921171a136092018227b8b77a3d64599844c19cc7f6e835f9f47a3b5776660c49c13bffadbc68409b10fb7d6eb559f6c650f152d67f18e2650f1e9db2
7
+ data.tar.gz: 1e0b9c28914954a37a2dabc64544f876c7ab718408a8942d5aeff5781e4625002bb730e9707a768e5aca0f28b0fa9ca83397b5cb9b3154cfcf3c1b53b7d74941
data/README.md CHANGED
@@ -15,9 +15,9 @@ Available as:
15
15
 
16
16
  ## Performance
17
17
 
18
- Speed and effectiveness of Node.js version compared to [html-minfier](https://github.com/kangax/html-minifier) and [minimize](https://github.com/Swaagie/minimize). See [bench](./bench) folder for more details.
18
+ 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
19
 
20
- <img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.0.44/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.0.44/average-sizes.png">
20
+ <img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.1/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.1/average-sizes.png">
21
21
 
22
22
  ## Usage
23
23
 
@@ -25,13 +25,11 @@ Speed and effectiveness of Node.js version compared to [html-minfier](https://gi
25
25
 
26
26
  Precompiled binaries are available for x86-64 Windows, macOS, and Linux.
27
27
 
28
- To compile and install from source, run `cargo install hyperbuild`, which requires [Rust](https://www.rust-lang.org/tools/install).
29
-
30
28
  ##### Get
31
29
 
32
- [Windows](https://wilsonl.in/hyperbuild/bin/0.0.44-windows-x86_64.exe) |
33
- [macOS](https://wilsonl.in/hyperbuild/bin/0.0.44-macos-x86_64) |
34
- [Linux](https://wilsonl.in/hyperbuild/bin/0.0.44-linux-x86_64)
30
+ [Windows](https://wilsonl.in/hyperbuild/bin/0.1.1-windows-x86_64.exe) |
31
+ [macOS](https://wilsonl.in/hyperbuild/bin/0.1.1-macos-x86_64) |
32
+ [Linux](https://wilsonl.in/hyperbuild/bin/0.1.1-linux-x86_64)
35
33
 
36
34
  ##### Use
37
35
 
@@ -48,7 +46,7 @@ hyperbuild --src /path/to/src.html --out /path/to/output.min.html
48
46
 
49
47
  ```toml
50
48
  [dependencies]
51
- hyperbuild = "0.0.44"
49
+ hyperbuild = "0.1.1"
52
50
  ```
53
51
 
54
52
  ##### Use
@@ -58,9 +56,34 @@ use hyperbuild::hyperbuild;
58
56
 
59
57
  fn main() {
60
58
  let mut code = b"<p> Hello, world! </p>".to_vec();
59
+
60
+ // `hyperbuild` minifies a slice in-place and returns the new minified length, but leaves any original code after the minified code intact.
61
61
  match hyperbuild(&mut code) {
62
62
  Ok(minified_len) => {}
63
- Err((error_type, error_at_char_no)) => {}
63
+ Err((error_type, error_position)) => {}
64
+ };
65
+
66
+ // `hyperbuild_copy` creates a vector copy containing only minified code instead of minifying in-place.
67
+ match hyperbuild_copy(&code) {
68
+ Ok(minified) => {}
69
+ Err((error_type, error_position)) => {}
70
+ };
71
+
72
+ // `hyperbuild_truncate` minifies a vector in-place, and then truncates the vector to the new minified length.
73
+ match hyperbuild_truncate(&mut code) {
74
+ Ok(()) => {}
75
+ Err((error_type, error_position)) => {}
76
+ };
77
+
78
+ // `hyperbuild_friendly_error` is identical to `hyperbuild` except the error is a FriendlyError instead.
79
+ // `code_context` is a string of a visual representation of the source code with line numbers and position markers to aid in debugging syntax issues, and should be printed.
80
+ match hyperbuild_friendly_error(&mut code) {
81
+ Ok(minified_len) => {}
82
+ Err(FriendlyError { position, message, code_context }) => {
83
+ eprintln!("Failed at character {}:", position);
84
+ eprintln!("{}", message);
85
+ eprintln!("{}", code_context);
86
+ }
64
87
  };
65
88
  }
66
89
  ```
@@ -92,14 +115,20 @@ yarn add hyperbuild
92
115
  const hyperbuild = require("hyperbuild");
93
116
 
94
117
  const minified = hyperbuild.minify("<p> Hello, world! </p>");
118
+
119
+ // Alternatively, minify in place to avoid copying.
120
+ const source = Buffer.from("<p> Hello, world! </p>");
121
+ hyperbuild.minifyInPlace(source);
95
122
  ```
96
123
 
97
124
  hyperbuild is also available for TypeScript:
98
125
 
99
126
  ```ts
100
127
  import * as hyperbuild from "hyperbuild";
128
+ import * as fs from "fs";
101
129
 
102
130
  const minified = hyperbuild.minify("<p> Hello, world! </p>");
131
+ hyperbuild.minifyInPlace(fs.readFileSync("source.html"));
103
132
  ```
104
133
 
105
134
  </details>
@@ -117,7 +146,7 @@ Add as a Maven dependency:
117
146
  <dependency>
118
147
  <groupId>in.wilsonl.hyperbuild</groupId>
119
148
  <artifactId>hyperbuild</artifactId>
120
- <version>0.0.44</version>
149
+ <version>0.1.1</version>
121
150
  </dependency>
122
151
  ```
123
152
 
@@ -126,11 +155,15 @@ Add as a Maven dependency:
126
155
  ```java
127
156
  import in.wilsonl.hyperbuild.Hyperbuild;
128
157
 
129
- class Main {
130
- public static void main(String[] args) {
131
- String minified = Hyperbuild.minify("<p> Hello, world! </p>");
132
- }
158
+ try {
159
+ String minified = Hyperbuild.minify("<p> Hello, world! </p>");
160
+ } catch (Hyperbuild.SyntaxException e) {
161
+ System.err.println(e.getMessage());
133
162
  }
163
+
164
+ // Alternatively, minify in place:
165
+ assert source instanceof ByteBuffer && source.isDirect();
166
+ Hyperbuild.minifyInPlace(source);
134
167
  ```
135
168
 
136
169
  </details>
@@ -149,7 +182,10 @@ Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
149
182
  ```python
150
183
  import hyperbuild
151
184
 
152
- minified = hyperbuild.minify("<p> Hello, world! </p>")
185
+ try:
186
+ minified = hyperbuild.minify("<p> Hello, world! </p>")
187
+ except SyntaxError as e:
188
+ print(e)
153
189
  ```
154
190
 
155
191
  </details>
@@ -175,6 +211,10 @@ print Hyperbuild.minify "

Hello, world!

"
175
211
 
176
212
  ## Minification
177
213
 
214
+ ### Configurability
215
+
216
+ Configuration of minification is currently WIP across all languages. The behaviour mentioned below is the default.
217
+
178
218
  ### Whitespace
179
219
 
180
220
  hyperbuild has advanced context-aware whitespace minification that does things such as:
@@ -218,7 +258,7 @@ Reduce a sequence of whitespace characters in text nodes to a single space (U+00
218
258
 
219
259
  > **Applies to:** any element except [whitespace sensitive](./src/spec/tag/whitespace.rs), [content](src/spec/tag/whitespace.rs), [content-first](./src/spec/tag/whitespace.rs), and [formatting](./src/spec/tag/whitespace.rs) elements.
220
260
 
221
- Remove any text nodes that only consist of whitespace characters.
261
+ Remove any text nodes between tags that only consist of whitespace characters.
222
262
 
223
263
  <table><thead><tr><th>Before<th>After<tbody><tr><td>
224
264
 
@@ -396,7 +436,7 @@ Numeric entities that do not refer to a valid [Unicode Scalar Value](https://www
396
436
 
397
437
  If an entity is unintentionally formed after decoding, the leading ampersand is encoded, e.g. `&&#97;&#109;&#112;;` becomes `&ampamp;`. This is done as `&amp` is equal to or shorter than all other entity representations of characters part of an entity (`[&#a-zA-Z0-9;]`), and there is no other conflicting entity name that starts with `amp`.
398
438
 
399
- Right chevrons after any decoding in text are encoded to `&GT` if possible or `&GT;` otherwise.
439
+ Left chevrons after any decoding in text are encoded to `&LT` if possible or `&LT;` otherwise.
400
440
 
401
441
  ### Comments
402
442
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.44
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilson Lin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-01 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle