hyperbuild 0.0.41 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +72 -18
- data/lib/linux-ruby2.5 +0 -0
- data/lib/linux-ruby2.6 +0 -0
- data/lib/linux-ruby2.7 +0 -0
- data/lib/macos-ruby2.5 +0 -0
- data/lib/macos-ruby2.6 +0 -0
- data/lib/macos-ruby2.7 +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e6a1e10782a31b58f66b59d7cd44ef2dbd5d8dc2261381b13b2d254f8b5c4a2
|
4
|
+
data.tar.gz: ee8f6ee1d6915cd7f5f1d0639cb721a537c7b1f8049630c997c52540275ff057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f0adf1f11aab729d17a00c04f6b01c5d1fdc8da6c0d8b3013218382bd0925091ce8293ac72a9aad730bec937cdc3db4b9e74c6d2c58989ad97a849cfdb9c33
|
7
|
+
data.tar.gz: eac51647abc8c8646d1b818303d3a8fb5af3c5ff046db8a0bafa385271cbef7dc68415453881bfac5b0e7e31497d3f4285666cfe996a20f5c4fa2e01961f258c
|
data/README.md
CHANGED
@@ -15,21 +15,21 @@ 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.
|
20
|
+
<img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.3/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.3/average-sizes.png">
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
### CLI
|
25
25
|
|
26
|
-
Precompiled binaries are available for x86-64 Windows, macOS, and Linux.
|
26
|
+
Precompiled binaries are available for x86-64 Windows, macOS, and Linux.
|
27
27
|
|
28
28
|
##### Get
|
29
29
|
|
30
|
-
[Windows](https://wilsonl.in/hyperbuild/bin/0.
|
31
|
-
[macOS](https://wilsonl.in/hyperbuild/bin/0.
|
32
|
-
[Linux](https://wilsonl.in/hyperbuild/bin/0.
|
30
|
+
[Windows](https://wilsonl.in/hyperbuild/bin/0.1.3-windows-x86_64.exe) |
|
31
|
+
[macOS](https://wilsonl.in/hyperbuild/bin/0.1.3-macos-x86_64) |
|
32
|
+
[Linux](https://wilsonl.in/hyperbuild/bin/0.1.3-linux-x86_64)
|
33
33
|
|
34
34
|
##### Use
|
35
35
|
|
@@ -46,19 +46,48 @@ hyperbuild --src /path/to/src.html --out /path/to/output.min.html
|
|
46
46
|
|
47
47
|
```toml
|
48
48
|
[dependencies]
|
49
|
-
hyperbuild = "0.
|
49
|
+
hyperbuild = "0.1.3"
|
50
50
|
```
|
51
51
|
|
52
52
|
##### Use
|
53
53
|
|
54
54
|
```rust
|
55
|
-
use hyperbuild::hyperbuild;
|
55
|
+
use hyperbuild::{FriendlyError, hyperbuild};
|
56
56
|
|
57
57
|
fn main() {
|
58
58
|
let mut code = b"<p> Hello, world! </p>".to_vec();
|
59
|
+
|
60
|
+
// Minifies a slice in-place and returns the new minified length,
|
61
|
+
// but leaves any original code after the minified code intact.
|
59
62
|
match hyperbuild(&mut code) {
|
60
63
|
Ok(minified_len) => {}
|
61
|
-
Err((error_type,
|
64
|
+
Err((error_type, error_position)) => {}
|
65
|
+
};
|
66
|
+
|
67
|
+
// Creates a vector copy containing only minified code
|
68
|
+
// instead of minifying in-place.
|
69
|
+
match hyperbuild_copy(&code) {
|
70
|
+
Ok(minified) => {}
|
71
|
+
Err((error_type, error_position)) => {}
|
72
|
+
};
|
73
|
+
|
74
|
+
// Minifies a vector in-place, and then truncates the
|
75
|
+
// vector to the new minified length.
|
76
|
+
match hyperbuild_truncate(&mut code) {
|
77
|
+
Ok(()) => {}
|
78
|
+
Err((error_type, error_position)) => {}
|
79
|
+
};
|
80
|
+
|
81
|
+
// Identical to `hyperbuild` except with FriendlyError instead.
|
82
|
+
// `code_context` is a string of a visual representation of the source,
|
83
|
+
// with line numbers and position markers to aid in debugging syntax.
|
84
|
+
match hyperbuild_friendly_error(&mut code) {
|
85
|
+
Ok(minified_len) => {}
|
86
|
+
Err(FriendlyError { position, message, code_context }) => {
|
87
|
+
eprintln!("Failed at character {}:", position);
|
88
|
+
eprintln!("{}", message);
|
89
|
+
eprintln!("{}", code_context);
|
90
|
+
}
|
62
91
|
};
|
63
92
|
}
|
64
93
|
```
|
@@ -90,6 +119,20 @@ yarn add hyperbuild
|
|
90
119
|
const hyperbuild = require("hyperbuild");
|
91
120
|
|
92
121
|
const minified = hyperbuild.minify("<p> Hello, world! </p>");
|
122
|
+
|
123
|
+
// Alternatively, minify in place to avoid copying.
|
124
|
+
const source = Buffer.from("<p> Hello, world! </p>");
|
125
|
+
hyperbuild.minifyInPlace(source);
|
126
|
+
```
|
127
|
+
|
128
|
+
hyperbuild is also available for TypeScript:
|
129
|
+
|
130
|
+
```ts
|
131
|
+
import * as hyperbuild from "hyperbuild";
|
132
|
+
import * as fs from "fs";
|
133
|
+
|
134
|
+
const minified = hyperbuild.minify("<p> Hello, world! </p>");
|
135
|
+
hyperbuild.minifyInPlace(fs.readFileSync("source.html"));
|
93
136
|
```
|
94
137
|
|
95
138
|
</details>
|
@@ -107,7 +150,7 @@ Add as a Maven dependency:
|
|
107
150
|
<dependency>
|
108
151
|
<groupId>in.wilsonl.hyperbuild</groupId>
|
109
152
|
<artifactId>hyperbuild</artifactId>
|
110
|
-
<version>0.
|
153
|
+
<version>0.1.3</version>
|
111
154
|
</dependency>
|
112
155
|
```
|
113
156
|
|
@@ -116,11 +159,15 @@ Add as a Maven dependency:
|
|
116
159
|
```java
|
117
160
|
import in.wilsonl.hyperbuild.Hyperbuild;
|
118
161
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
162
|
+
try {
|
163
|
+
String minified = Hyperbuild.minify("<p> Hello, world! </p>");
|
164
|
+
} catch (Hyperbuild.SyntaxException e) {
|
165
|
+
System.err.println(e.getMessage());
|
123
166
|
}
|
167
|
+
|
168
|
+
// Alternatively, minify in place:
|
169
|
+
assert source instanceof ByteBuffer && source.isDirect();
|
170
|
+
Hyperbuild.minifyInPlace(source);
|
124
171
|
```
|
125
172
|
|
126
173
|
</details>
|
@@ -139,7 +186,10 @@ Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
|
|
139
186
|
```python
|
140
187
|
import hyperbuild
|
141
188
|
|
142
|
-
|
189
|
+
try:
|
190
|
+
minified = hyperbuild.minify("<p> Hello, world! </p>")
|
191
|
+
except SyntaxError as e:
|
192
|
+
print(e)
|
143
193
|
```
|
144
194
|
|
145
195
|
</details>
|
@@ -165,6 +215,10 @@ print Hyperbuild.minify "
Hello, world! " |
|
165
215
|
|
166
216
|
## Minification
|
167
217
|
|
218
|
+
### Configurability
|
219
|
+
|
220
|
+
Configuration of minification is currently WIP across all languages. The behaviour mentioned below is the default.
|
221
|
+
|
168
222
|
### Whitespace
|
169
223
|
|
170
224
|
hyperbuild has advanced context-aware whitespace minification that does things such as:
|
@@ -208,7 +262,7 @@ Reduce a sequence of whitespace characters in text nodes to a single space (U+00
|
|
208
262
|
|
209
263
|
> **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.
|
210
264
|
|
211
|
-
Remove any text nodes that only consist of whitespace characters.
|
265
|
+
Remove any text nodes between tags that only consist of whitespace characters.
|
212
266
|
|
213
267
|
<table><thead><tr><th>Before<th>After<tbody><tr><td>
|
214
268
|
|
@@ -383,10 +437,10 @@ Spaces are removed between attributes if possible.
|
|
383
437
|
Entities are decoded if valid (see relevant parsing section) and their decoded characters as UTF-8 is shorter or equal in length.
|
384
438
|
|
385
439
|
Numeric entities that do not refer to a valid [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) are replaced with the [replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character).
|
386
|
-
|
440
|
+
|
387
441
|
If an entity is unintentionally formed after decoding, the leading ampersand is encoded, e.g. `&amp;` becomes `&amp;`. This is done as `&` 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`.
|
388
442
|
|
389
|
-
|
443
|
+
Left chevrons after any decoding in text are encoded to `<` if possible or `<` otherwise.
|
390
444
|
|
391
445
|
### Comments
|
392
446
|
|
data/lib/linux-ruby2.5
CHANGED
Binary file
|
data/lib/linux-ruby2.6
CHANGED
Binary file
|
data/lib/linux-ruby2.7
CHANGED
Binary file
|
data/lib/macos-ruby2.5
CHANGED
Binary file
|
data/lib/macos-ruby2.6
CHANGED
Binary file
|
data/lib/macos-ruby2.7
CHANGED
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.
|
4
|
+
version: 0.1.3
|
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-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fiddle
|