@swc/html 0.0.20 → 0.0.24
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 +17 -25
- package/package.json +18 -15
- package/binding.js +0 -249
package/binding.d.ts
CHANGED
|
@@ -4,35 +4,27 @@
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
6
|
export interface Diagnostic {
|
|
7
|
-
level: string
|
|
8
|
-
message: string
|
|
9
|
-
span: any
|
|
7
|
+
level: string
|
|
8
|
+
message: string
|
|
9
|
+
span: any
|
|
10
10
|
}
|
|
11
11
|
export interface TransformOutput {
|
|
12
|
-
code: string
|
|
13
|
-
errors?: Array<Diagnostic
|
|
12
|
+
code: string
|
|
13
|
+
errors?: Array<Diagnostic>
|
|
14
14
|
}
|
|
15
15
|
export interface Attribute {
|
|
16
|
-
namespace?: string
|
|
17
|
-
prefix?: string
|
|
18
|
-
name: string
|
|
19
|
-
value?: string
|
|
16
|
+
namespace?: string
|
|
17
|
+
prefix?: string
|
|
18
|
+
name: string
|
|
19
|
+
value?: string
|
|
20
20
|
}
|
|
21
21
|
export interface Element {
|
|
22
|
-
tagName: string
|
|
23
|
-
namespace: string
|
|
24
|
-
attributes: Array<Attribute
|
|
25
|
-
isSelfClosing: boolean
|
|
22
|
+
tagName: string
|
|
23
|
+
namespace: string
|
|
24
|
+
attributes: Array<Attribute>
|
|
25
|
+
isSelfClosing: boolean
|
|
26
26
|
}
|
|
27
|
-
export function minify(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
27
|
+
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
|
28
|
+
export function minifyFragment(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
|
29
|
+
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
|
30
|
+
export function minifyFragmentSync(code: Buffer, opts: Buffer): TransformOutput
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swc/html",
|
|
3
|
-
"
|
|
3
|
+
"packageManager": "yarn@3.2.3",
|
|
4
|
+
"version": "0.0.24",
|
|
4
5
|
"description": "Super-fast alternative for posthtml",
|
|
5
6
|
"homepage": "https://swc.rs",
|
|
6
7
|
"main": "./index.js",
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
"defaults": true,
|
|
27
28
|
"additional": [
|
|
28
29
|
"x86_64-unknown-linux-musl",
|
|
29
|
-
"x86_64-unknown-freebsd",
|
|
30
30
|
"i686-pc-windows-msvc",
|
|
31
31
|
"aarch64-unknown-linux-gnu",
|
|
32
32
|
"armv7-unknown-linux-gnueabihf",
|
|
@@ -53,19 +53,22 @@
|
|
|
53
53
|
"test": "echo 'done!'",
|
|
54
54
|
"version": "napi version -p scripts/npm"
|
|
55
55
|
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@napi-rs/cli": "^2.16.1",
|
|
58
|
+
"typescript": "^5.1.6"
|
|
59
|
+
},
|
|
56
60
|
"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-
|
|
62
|
-
"@swc/html-
|
|
63
|
-
"@swc/html-linux-
|
|
64
|
-
"@swc/html-
|
|
65
|
-
"@swc/html-
|
|
66
|
-
"@swc/html-
|
|
67
|
-
"@swc/html-
|
|
68
|
-
"@swc/html-
|
|
69
|
-
"@swc/html-android-arm-eabi": "0.0.20"
|
|
61
|
+
"@swc/html-win32-x64-msvc": "0.0.24",
|
|
62
|
+
"@swc/html-darwin-x64": "0.0.24",
|
|
63
|
+
"@swc/html-linux-x64-gnu": "0.0.24",
|
|
64
|
+
"@swc/html-linux-x64-musl": "0.0.24",
|
|
65
|
+
"@swc/html-win32-ia32-msvc": "0.0.24",
|
|
66
|
+
"@swc/html-linux-arm64-gnu": "0.0.24",
|
|
67
|
+
"@swc/html-linux-arm-gnueabihf": "0.0.24",
|
|
68
|
+
"@swc/html-darwin-arm64": "0.0.24",
|
|
69
|
+
"@swc/html-android-arm64": "0.0.24",
|
|
70
|
+
"@swc/html-linux-arm64-musl": "0.0.24",
|
|
71
|
+
"@swc/html-win32-arm64-msvc": "0.0.24",
|
|
72
|
+
"@swc/html-android-arm-eabi": "0.0.24"
|
|
70
73
|
}
|
|
71
74
|
}
|
package/binding.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
const { existsSync, readFileSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
|
-
|
|
4
|
-
const { platform, arch } = process;
|
|
5
|
-
|
|
6
|
-
let nativeBinding = null;
|
|
7
|
-
let localFileExisted = false;
|
|
8
|
-
let loadError = null;
|
|
9
|
-
|
|
10
|
-
function isMusl() {
|
|
11
|
-
// For Node 10
|
|
12
|
-
if (!process.report || typeof process.report.getReport !== "function") {
|
|
13
|
-
try {
|
|
14
|
-
return readFileSync("/usr/bin/ldd", "utf8").includes("musl");
|
|
15
|
-
} catch (e) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
20
|
-
return !glibcVersionRuntime;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
switch (platform) {
|
|
25
|
-
case "android":
|
|
26
|
-
switch (arch) {
|
|
27
|
-
case "arm64":
|
|
28
|
-
localFileExisted = existsSync(
|
|
29
|
-
join(__dirname, "html.android-arm64.node")
|
|
30
|
-
);
|
|
31
|
-
try {
|
|
32
|
-
if (localFileExisted) {
|
|
33
|
-
nativeBinding = require("./html.android-arm64.node");
|
|
34
|
-
} else {
|
|
35
|
-
nativeBinding = require("@swc/html-android-arm64");
|
|
36
|
-
}
|
|
37
|
-
} catch (e) {
|
|
38
|
-
loadError = e;
|
|
39
|
-
}
|
|
40
|
-
break;
|
|
41
|
-
case "arm":
|
|
42
|
-
localFileExisted = existsSync(
|
|
43
|
-
join(__dirname, "html.android-arm-eabi.node")
|
|
44
|
-
);
|
|
45
|
-
try {
|
|
46
|
-
if (localFileExisted) {
|
|
47
|
-
nativeBinding = require("./html.android-arm-eabi.node");
|
|
48
|
-
} else {
|
|
49
|
-
nativeBinding = require("@swc/html-android-arm-eabi");
|
|
50
|
-
}
|
|
51
|
-
} catch (e) {
|
|
52
|
-
loadError = e;
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
throw new Error(`Unsupported architecture on Android ${arch}`);
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case "win32":
|
|
60
|
-
switch (arch) {
|
|
61
|
-
case "x64":
|
|
62
|
-
localFileExisted = existsSync(
|
|
63
|
-
join(__dirname, "html.win32-x64-msvc.node")
|
|
64
|
-
);
|
|
65
|
-
try {
|
|
66
|
-
if (localFileExisted) {
|
|
67
|
-
nativeBinding = require("./html.win32-x64-msvc.node");
|
|
68
|
-
} else {
|
|
69
|
-
nativeBinding = require("@swc/html-win32-x64-msvc");
|
|
70
|
-
}
|
|
71
|
-
} catch (e) {
|
|
72
|
-
loadError = e;
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
case "ia32":
|
|
76
|
-
localFileExisted = existsSync(
|
|
77
|
-
join(__dirname, "html.win32-ia32-msvc.node")
|
|
78
|
-
);
|
|
79
|
-
try {
|
|
80
|
-
if (localFileExisted) {
|
|
81
|
-
nativeBinding = require("./html.win32-ia32-msvc.node");
|
|
82
|
-
} else {
|
|
83
|
-
nativeBinding = require("@swc/html-win32-ia32-msvc");
|
|
84
|
-
}
|
|
85
|
-
} catch (e) {
|
|
86
|
-
loadError = e;
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
case "arm64":
|
|
90
|
-
localFileExisted = existsSync(
|
|
91
|
-
join(__dirname, "html.win32-arm64-msvc.node")
|
|
92
|
-
);
|
|
93
|
-
try {
|
|
94
|
-
if (localFileExisted) {
|
|
95
|
-
nativeBinding = require("./html.win32-arm64-msvc.node");
|
|
96
|
-
} else {
|
|
97
|
-
nativeBinding = require("@swc/html-win32-arm64-msvc");
|
|
98
|
-
}
|
|
99
|
-
} catch (e) {
|
|
100
|
-
loadError = e;
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
default:
|
|
104
|
-
throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case "darwin":
|
|
108
|
-
switch (arch) {
|
|
109
|
-
case "x64":
|
|
110
|
-
localFileExisted = existsSync(join(__dirname, "html.darwin-x64.node"));
|
|
111
|
-
try {
|
|
112
|
-
if (localFileExisted) {
|
|
113
|
-
nativeBinding = require("./html.darwin-x64.node");
|
|
114
|
-
} else {
|
|
115
|
-
nativeBinding = require("@swc/html-darwin-x64");
|
|
116
|
-
}
|
|
117
|
-
} catch (e) {
|
|
118
|
-
loadError = e;
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
case "arm64":
|
|
122
|
-
localFileExisted = existsSync(
|
|
123
|
-
join(__dirname, "html.darwin-arm64.node")
|
|
124
|
-
);
|
|
125
|
-
try {
|
|
126
|
-
if (localFileExisted) {
|
|
127
|
-
nativeBinding = require("./html.darwin-arm64.node");
|
|
128
|
-
} else {
|
|
129
|
-
nativeBinding = require("@swc/html-darwin-arm64");
|
|
130
|
-
}
|
|
131
|
-
} catch (e) {
|
|
132
|
-
loadError = e;
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
default:
|
|
136
|
-
throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
137
|
-
}
|
|
138
|
-
break;
|
|
139
|
-
case "freebsd":
|
|
140
|
-
if (arch !== "x64") {
|
|
141
|
-
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
|
|
142
|
-
}
|
|
143
|
-
localFileExisted = existsSync(join(__dirname, "html.freebsd-x64.node"));
|
|
144
|
-
try {
|
|
145
|
-
if (localFileExisted) {
|
|
146
|
-
nativeBinding = require("./html.freebsd-x64.node");
|
|
147
|
-
} else {
|
|
148
|
-
nativeBinding = require("@swc/html-freebsd-x64");
|
|
149
|
-
}
|
|
150
|
-
} catch (e) {
|
|
151
|
-
loadError = e;
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
case "linux":
|
|
155
|
-
switch (arch) {
|
|
156
|
-
case "x64":
|
|
157
|
-
if (isMusl()) {
|
|
158
|
-
localFileExisted = existsSync(
|
|
159
|
-
join(__dirname, "html.linux-x64-musl.node")
|
|
160
|
-
);
|
|
161
|
-
try {
|
|
162
|
-
if (localFileExisted) {
|
|
163
|
-
nativeBinding = require("./html.linux-x64-musl.node");
|
|
164
|
-
} else {
|
|
165
|
-
nativeBinding = require("@swc/html-linux-x64-musl");
|
|
166
|
-
}
|
|
167
|
-
} catch (e) {
|
|
168
|
-
loadError = e;
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
localFileExisted = existsSync(
|
|
172
|
-
join(__dirname, "html.linux-x64-gnu.node")
|
|
173
|
-
);
|
|
174
|
-
try {
|
|
175
|
-
if (localFileExisted) {
|
|
176
|
-
nativeBinding = require("./html.linux-x64-gnu.node");
|
|
177
|
-
} else {
|
|
178
|
-
nativeBinding = require("@swc/html-linux-x64-gnu");
|
|
179
|
-
}
|
|
180
|
-
} catch (e) {
|
|
181
|
-
loadError = e;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
break;
|
|
185
|
-
case "arm64":
|
|
186
|
-
if (isMusl()) {
|
|
187
|
-
localFileExisted = existsSync(
|
|
188
|
-
join(__dirname, "html.linux-arm64-musl.node")
|
|
189
|
-
);
|
|
190
|
-
try {
|
|
191
|
-
if (localFileExisted) {
|
|
192
|
-
nativeBinding = require("./html.linux-arm64-musl.node");
|
|
193
|
-
} else {
|
|
194
|
-
nativeBinding = require("@swc/html-linux-arm64-musl");
|
|
195
|
-
}
|
|
196
|
-
} catch (e) {
|
|
197
|
-
loadError = e;
|
|
198
|
-
}
|
|
199
|
-
} else {
|
|
200
|
-
localFileExisted = existsSync(
|
|
201
|
-
join(__dirname, "html.linux-arm64-gnu.node")
|
|
202
|
-
);
|
|
203
|
-
try {
|
|
204
|
-
if (localFileExisted) {
|
|
205
|
-
nativeBinding = require("./html.linux-arm64-gnu.node");
|
|
206
|
-
} else {
|
|
207
|
-
nativeBinding = require("@swc/html-linux-arm64-gnu");
|
|
208
|
-
}
|
|
209
|
-
} catch (e) {
|
|
210
|
-
loadError = e;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
break;
|
|
214
|
-
case "arm":
|
|
215
|
-
localFileExisted = existsSync(
|
|
216
|
-
join(__dirname, "html.linux-arm-gnueabihf.node")
|
|
217
|
-
);
|
|
218
|
-
try {
|
|
219
|
-
if (localFileExisted) {
|
|
220
|
-
nativeBinding = require("./html.linux-arm-gnueabihf.node");
|
|
221
|
-
} else {
|
|
222
|
-
nativeBinding = require("@swc/html-linux-arm-gnueabihf");
|
|
223
|
-
}
|
|
224
|
-
} catch (e) {
|
|
225
|
-
loadError = e;
|
|
226
|
-
}
|
|
227
|
-
break;
|
|
228
|
-
default:
|
|
229
|
-
throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
default:
|
|
233
|
-
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (!nativeBinding) {
|
|
237
|
-
if (loadError) {
|
|
238
|
-
throw loadError;
|
|
239
|
-
}
|
|
240
|
-
throw new Error(`Failed to load native binding`);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const { minify, minifyFragment, minifySync, minifyFragmentSync } =
|
|
244
|
-
nativeBinding;
|
|
245
|
-
|
|
246
|
-
module.exports.minify = minify;
|
|
247
|
-
module.exports.minifyFragment = minifyFragment;
|
|
248
|
-
module.exports.minifySync = minifySync;
|
|
249
|
-
module.exports.minifyFragmentSync = minifyFragmentSync;
|