@swc/html 0.0.16 → 0.0.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/binding.d.ts +29 -2
- package/binding.js +4 -1
- package/index.js +9 -1
- package/index.ts +63 -2
- package/package.json +14 -14
package/binding.d.ts
CHANGED
|
@@ -3,9 +3,36 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
+
export interface Diagnostic {
|
|
7
|
+
level: string;
|
|
8
|
+
message: string;
|
|
9
|
+
span: any;
|
|
10
|
+
}
|
|
11
|
+
export interface TransformOutput {
|
|
12
|
+
code: string;
|
|
13
|
+
errors?: Array<Diagnostic>;
|
|
14
|
+
}
|
|
15
|
+
export interface Attribute {
|
|
16
|
+
namespace?: string;
|
|
17
|
+
prefix?: string;
|
|
18
|
+
name: string;
|
|
19
|
+
value?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Element {
|
|
22
|
+
tagName: string;
|
|
23
|
+
namespace: string;
|
|
24
|
+
attributes: Array<Attribute>;
|
|
25
|
+
isSelfClosing: boolean;
|
|
26
|
+
}
|
|
6
27
|
export function minify(
|
|
7
28
|
code: Buffer,
|
|
8
29
|
opts: Buffer,
|
|
9
30
|
signal?: AbortSignal | undefined | null
|
|
10
|
-
): Promise<
|
|
11
|
-
export function
|
|
31
|
+
): Promise<TransformOutput>;
|
|
32
|
+
export function minifyFragment(
|
|
33
|
+
code: Buffer,
|
|
34
|
+
opts: Buffer,
|
|
35
|
+
signal?: AbortSignal | undefined | null
|
|
36
|
+
): Promise<TransformOutput>;
|
|
37
|
+
export function minifySync(code: Buffer, opts: Buffer): TransformOutput;
|
|
38
|
+
export function minifyFragmentSync(code: Buffer, opts: Buffer): TransformOutput;
|
package/binding.js
CHANGED
|
@@ -240,7 +240,10 @@ if (!nativeBinding) {
|
|
|
240
240
|
throw new Error(`Failed to load native binding`);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
const { minify, minifySync } =
|
|
243
|
+
const { minify, minifyFragment, minifySync, minifyFragmentSync } =
|
|
244
|
+
nativeBinding;
|
|
244
245
|
|
|
245
246
|
module.exports.minify = minify;
|
|
247
|
+
module.exports.minifyFragment = minifyFragment;
|
|
246
248
|
module.exports.minifySync = minifySync;
|
|
249
|
+
module.exports.minifyFragmentSync = minifyFragmentSync;
|
package/index.js
CHANGED
|
@@ -23,16 +23,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.minifySync = exports.minify = void 0;
|
|
26
|
+
exports.minifyFragmentSync = exports.minifySync = exports.minifyFragment = exports.minify = void 0;
|
|
27
27
|
const binding = __importStar(require("./binding"));
|
|
28
28
|
async function minify(content, options) {
|
|
29
29
|
return binding.minify(content, toBuffer(options !== null && options !== void 0 ? options : {}));
|
|
30
30
|
}
|
|
31
31
|
exports.minify = minify;
|
|
32
|
+
async function minifyFragment(content, options) {
|
|
33
|
+
return binding.minifyFragment(content, toBuffer(options !== null && options !== void 0 ? options : {}));
|
|
34
|
+
}
|
|
35
|
+
exports.minifyFragment = minifyFragment;
|
|
32
36
|
function minifySync(content, options) {
|
|
33
37
|
return binding.minifySync(content, toBuffer(options !== null && options !== void 0 ? options : {}));
|
|
34
38
|
}
|
|
35
39
|
exports.minifySync = minifySync;
|
|
40
|
+
async function minifyFragmentSync(content, options) {
|
|
41
|
+
return binding.minifyFragmentSync(content, toBuffer(options !== null && options !== void 0 ? options : {}));
|
|
42
|
+
}
|
|
43
|
+
exports.minifyFragmentSync = minifyFragmentSync;
|
|
36
44
|
function toBuffer(t) {
|
|
37
45
|
return Buffer.from(JSON.stringify(t));
|
|
38
46
|
}
|
package/index.ts
CHANGED
|
@@ -1,13 +1,74 @@
|
|
|
1
1
|
import * as binding from "./binding";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type MinifierType = "js-module" | "js-script" | "json" | "css" | "html";
|
|
4
|
+
|
|
5
|
+
export type Options = {
|
|
6
|
+
filename?: string;
|
|
7
|
+
iframeSrcdoc?: boolean;
|
|
8
|
+
scriptingEnabled?: boolean;
|
|
9
|
+
forceSetHtml5Doctype?: boolean;
|
|
10
|
+
collapseWhitespaces?:
|
|
11
|
+
| "none"
|
|
12
|
+
| "all"
|
|
13
|
+
| "smart"
|
|
14
|
+
| "conservative"
|
|
15
|
+
| "advanced-conservative"
|
|
16
|
+
| "only-metadata";
|
|
17
|
+
removeEmptyMetadataElements?: boolean;
|
|
18
|
+
removeComments?: boolean;
|
|
19
|
+
preserveComments: string[];
|
|
20
|
+
minifyConditionalComments?: boolean;
|
|
21
|
+
removeEmptyAttributes?: boolean;
|
|
22
|
+
removeRedundantAttributes?: boolean;
|
|
23
|
+
collapseBooleanAttributes?: boolean;
|
|
24
|
+
normalizeAttributes?: boolean;
|
|
25
|
+
minifyJson?: boolean | { pretty?: boolean };
|
|
26
|
+
// TODO improve me after typing `@swc/css`
|
|
27
|
+
minifyJs?: boolean | { parser?: any; minifier?: any; codegen?: any };
|
|
28
|
+
minifyCss?: boolean | { parser?: any; minifier?: any; codegen?: any };
|
|
29
|
+
minifyAdditionalScriptsContent?: [string, MinifierType][];
|
|
30
|
+
minifyAdditionalAttributes?: [string, MinifierType][];
|
|
31
|
+
sortSpaceSeparatedAttributeValues?: boolean;
|
|
32
|
+
sortAttributes?: boolean;
|
|
33
|
+
tagOmission?: boolean;
|
|
34
|
+
selfClosingVoidElements?: boolean;
|
|
35
|
+
quotes?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type FragmentOptions = Options & {
|
|
39
|
+
mode?: "no-quirks" | "limited-quirks" | "quirks";
|
|
40
|
+
context_element?: binding.Element;
|
|
41
|
+
form_element?: binding.Element;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export async function minify(
|
|
45
|
+
content: Buffer,
|
|
46
|
+
options?: Options
|
|
47
|
+
): Promise<binding.TransformOutput> {
|
|
4
48
|
return binding.minify(content, toBuffer(options ?? {}));
|
|
5
49
|
}
|
|
6
50
|
|
|
7
|
-
export function
|
|
51
|
+
export async function minifyFragment(
|
|
52
|
+
content: Buffer,
|
|
53
|
+
options?: FragmentOptions
|
|
54
|
+
): Promise<binding.TransformOutput> {
|
|
55
|
+
return binding.minifyFragment(content, toBuffer(options ?? {}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function minifySync(
|
|
59
|
+
content: Buffer,
|
|
60
|
+
options?: Options
|
|
61
|
+
): binding.TransformOutput {
|
|
8
62
|
return binding.minifySync(content, toBuffer(options ?? {}));
|
|
9
63
|
}
|
|
10
64
|
|
|
65
|
+
export async function minifyFragmentSync(
|
|
66
|
+
content: Buffer,
|
|
67
|
+
options?: FragmentOptions
|
|
68
|
+
): Promise<binding.TransformOutput> {
|
|
69
|
+
return binding.minifyFragmentSync(content, toBuffer(options ?? {}));
|
|
70
|
+
}
|
|
71
|
+
|
|
11
72
|
function toBuffer(t: any): Buffer {
|
|
12
73
|
return Buffer.from(JSON.stringify(t));
|
|
13
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swc/html",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Super-fast alternative for posthtml",
|
|
5
5
|
"homepage": "https://swc.rs",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"version": "napi version -p scripts/npm"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@swc/html-win32-x64-msvc": "0.0.
|
|
58
|
-
"@swc/html-darwin-x64": "0.0.
|
|
59
|
-
"@swc/html-linux-x64-gnu": "0.0.
|
|
60
|
-
"@swc/html-linux-x64-musl": "0.0.
|
|
61
|
-
"@swc/html-freebsd-x64": "0.0.
|
|
62
|
-
"@swc/html-win32-ia32-msvc": "0.0.
|
|
63
|
-
"@swc/html-linux-arm64-gnu": "0.0.
|
|
64
|
-
"@swc/html-linux-arm-gnueabihf": "0.0.
|
|
65
|
-
"@swc/html-darwin-arm64": "0.0.
|
|
66
|
-
"@swc/html-android-arm64": "0.0.
|
|
67
|
-
"@swc/html-linux-arm64-musl": "0.0.
|
|
68
|
-
"@swc/html-win32-arm64-msvc": "0.0.
|
|
69
|
-
"@swc/html-android-arm-eabi": "0.0.
|
|
57
|
+
"@swc/html-win32-x64-msvc": "0.0.18",
|
|
58
|
+
"@swc/html-darwin-x64": "0.0.18",
|
|
59
|
+
"@swc/html-linux-x64-gnu": "0.0.18",
|
|
60
|
+
"@swc/html-linux-x64-musl": "0.0.18",
|
|
61
|
+
"@swc/html-freebsd-x64": "0.0.18",
|
|
62
|
+
"@swc/html-win32-ia32-msvc": "0.0.18",
|
|
63
|
+
"@swc/html-linux-arm64-gnu": "0.0.18",
|
|
64
|
+
"@swc/html-linux-arm-gnueabihf": "0.0.18",
|
|
65
|
+
"@swc/html-darwin-arm64": "0.0.18",
|
|
66
|
+
"@swc/html-android-arm64": "0.0.18",
|
|
67
|
+
"@swc/html-linux-arm64-musl": "0.0.18",
|
|
68
|
+
"@swc/html-win32-arm64-msvc": "0.0.18",
|
|
69
|
+
"@swc/html-android-arm-eabi": "0.0.18"
|
|
70
70
|
}
|
|
71
71
|
}
|