hyperbuild 0.0.44 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +62 -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: e21d3b86b868b267d86aa1dd93fce3ef9b3bfb3e8f7c813cbb679c6917a31078
|
4
|
+
data.tar.gz: 7f3c329e7e2a416d37ee2ca60d039d05075395b709dffa97f9bb66447e7d7903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1b6c0d39a46b52435c59df3eac0f1979c9e15c316edd1a253929e1f9939e35fdb4828237f6838924ac98ef03a1803d8c272466dee76ae2cd024bd1c38c20b95
|
7
|
+
data.tar.gz: a87b707918f82a4d76e48ca5fec21027f0577472ff21537226c5607e6c5fc466679e41b4c76334177a4b312fdc0f12f454861dcb3a25ef5c11f9df606d8a3d5f
|
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.
|
20
|
+
<img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.5/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.1.5/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.
|
33
|
-
[macOS](https://wilsonl.in/hyperbuild/bin/0.
|
34
|
-
[Linux](https://wilsonl.in/hyperbuild/bin/0.
|
30
|
+
[Windows](https://wilsonl.in/hyperbuild/bin/0.1.5-windows-x86_64.exe) |
|
31
|
+
[macOS](https://wilsonl.in/hyperbuild/bin/0.1.5-macos-x86_64) |
|
32
|
+
[Linux](https://wilsonl.in/hyperbuild/bin/0.1.5-linux-x86_64)
|
35
33
|
|
36
34
|
##### Use
|
37
35
|
|
@@ -48,19 +46,48 @@ hyperbuild --src /path/to/src.html --out /path/to/output.min.html
|
|
48
46
|
|
49
47
|
```toml
|
50
48
|
[dependencies]
|
51
|
-
hyperbuild = "0.
|
49
|
+
hyperbuild = "0.1.5"
|
52
50
|
```
|
53
51
|
|
54
52
|
##### Use
|
55
53
|
|
56
54
|
```rust
|
57
|
-
use hyperbuild::hyperbuild;
|
55
|
+
use hyperbuild::{FriendlyError, hyperbuild};
|
58
56
|
|
59
57
|
fn main() {
|
60
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.
|
61
62
|
match hyperbuild(&mut code) {
|
62
63
|
Ok(minified_len) => {}
|
63
|
-
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
|
+
}
|
64
91
|
};
|
65
92
|
}
|
66
93
|
```
|
@@ -92,14 +119,20 @@ yarn add hyperbuild
|
|
92
119
|
const hyperbuild = require("hyperbuild");
|
93
120
|
|
94
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);
|
95
126
|
```
|
96
127
|
|
97
128
|
hyperbuild is also available for TypeScript:
|
98
129
|
|
99
130
|
```ts
|
100
131
|
import * as hyperbuild from "hyperbuild";
|
132
|
+
import * as fs from "fs";
|
101
133
|
|
102
134
|
const minified = hyperbuild.minify("<p> Hello, world! </p>");
|
135
|
+
hyperbuild.minifyInPlace(fs.readFileSync("source.html"));
|
103
136
|
```
|
104
137
|
|
105
138
|
</details>
|
@@ -117,7 +150,7 @@ Add as a Maven dependency:
|
|
117
150
|
<dependency>
|
118
151
|
<groupId>in.wilsonl.hyperbuild</groupId>
|
119
152
|
<artifactId>hyperbuild</artifactId>
|
120
|
-
<version>0.
|
153
|
+
<version>0.1.5</version>
|
121
154
|
</dependency>
|
122
155
|
```
|
123
156
|
|
@@ -126,11 +159,15 @@ Add as a Maven dependency:
|
|
126
159
|
```java
|
127
160
|
import in.wilsonl.hyperbuild.Hyperbuild;
|
128
161
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
162
|
+
try {
|
163
|
+
String minified = Hyperbuild.minify("<p> Hello, world! </p>");
|
164
|
+
} catch (Hyperbuild.SyntaxException e) {
|
165
|
+
System.err.println(e.getMessage());
|
133
166
|
}
|
167
|
+
|
168
|
+
// Alternatively, minify in place:
|
169
|
+
assert source instanceof ByteBuffer && source.isDirect();
|
170
|
+
Hyperbuild.minifyInPlace(source);
|
134
171
|
```
|
135
172
|
|
136
173
|
</details>
|
@@ -149,7 +186,10 @@ Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
|
|
149
186
|
```python
|
150
187
|
import hyperbuild
|
151
188
|
|
152
|
-
|
189
|
+
try:
|
190
|
+
minified = hyperbuild.minify("<p> Hello, world! </p>")
|
191
|
+
except SyntaxError as e:
|
192
|
+
print(e)
|
153
193
|
```
|
154
194
|
|
155
195
|
</details>
|
@@ -175,6 +215,10 @@ print Hyperbuild.minify "
Hello, world! " |
|
175
215
|
|
176
216
|
## Minification
|
177
217
|
|
218
|
+
### Configurability
|
219
|
+
|
220
|
+
Configuration of minification is currently WIP across all languages. The behaviour mentioned below is the default.
|
221
|
+
|
178
222
|
### Whitespace
|
179
223
|
|
180
224
|
hyperbuild has advanced context-aware whitespace minification that does things such as:
|
@@ -218,7 +262,7 @@ Reduce a sequence of whitespace characters in text nodes to a single space (U+00
|
|
218
262
|
|
219
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.
|
220
264
|
|
221
|
-
Remove any text nodes that only consist of whitespace characters.
|
265
|
+
Remove any text nodes between tags that only consist of whitespace characters.
|
222
266
|
|
223
267
|
<table><thead><tr><th>Before<th>After<tbody><tr><td>
|
224
268
|
|
@@ -396,7 +440,7 @@ Numeric entities that do not refer to a valid [Unicode Scalar Value](https://www
|
|
396
440
|
|
397
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`.
|
398
442
|
|
399
|
-
|
443
|
+
Left chevrons after any decoding in text are encoded to `<` if possible or `<` otherwise.
|
400
444
|
|
401
445
|
### Comments
|
402
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.5
|
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
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fiddle
|