@swc/html 0.0.20 → 0.0.25
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/binding.js +132 -121
- package/package.json +18 -15
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/binding.js
CHANGED
|
@@ -1,249 +1,260 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
9
15
|
|
|
10
16
|
function isMusl() {
|
|
11
17
|
// For Node 10
|
|
12
|
-
if (!process.report || typeof process.report.getReport !==
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
13
19
|
try {
|
|
14
|
-
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
15
22
|
} catch (e) {
|
|
16
|
-
return true
|
|
23
|
+
return true
|
|
17
24
|
}
|
|
18
25
|
} else {
|
|
19
|
-
const { glibcVersionRuntime } = process.report.getReport().header
|
|
20
|
-
return !glibcVersionRuntime
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
switch (platform) {
|
|
25
|
-
case
|
|
32
|
+
case 'android':
|
|
26
33
|
switch (arch) {
|
|
27
|
-
case
|
|
28
|
-
localFileExisted = existsSync(
|
|
29
|
-
join(__dirname, "html.android-arm64.node")
|
|
30
|
-
);
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'html.android-arm64.node'))
|
|
31
36
|
try {
|
|
32
37
|
if (localFileExisted) {
|
|
33
|
-
nativeBinding = require(
|
|
38
|
+
nativeBinding = require('./html.android-arm64.node')
|
|
34
39
|
} else {
|
|
35
|
-
nativeBinding = require(
|
|
40
|
+
nativeBinding = require('@swc/html-android-arm64')
|
|
36
41
|
}
|
|
37
42
|
} catch (e) {
|
|
38
|
-
loadError = e
|
|
43
|
+
loadError = e
|
|
39
44
|
}
|
|
40
|
-
break
|
|
41
|
-
case
|
|
42
|
-
localFileExisted = existsSync(
|
|
43
|
-
join(__dirname, "html.android-arm-eabi.node")
|
|
44
|
-
);
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'html.android-arm-eabi.node'))
|
|
45
48
|
try {
|
|
46
49
|
if (localFileExisted) {
|
|
47
|
-
nativeBinding = require(
|
|
50
|
+
nativeBinding = require('./html.android-arm-eabi.node')
|
|
48
51
|
} else {
|
|
49
|
-
nativeBinding = require(
|
|
52
|
+
nativeBinding = require('@swc/html-android-arm-eabi')
|
|
50
53
|
}
|
|
51
54
|
} catch (e) {
|
|
52
|
-
loadError = e
|
|
55
|
+
loadError = e
|
|
53
56
|
}
|
|
54
|
-
break
|
|
57
|
+
break
|
|
55
58
|
default:
|
|
56
|
-
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
57
60
|
}
|
|
58
|
-
break
|
|
59
|
-
case
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
60
63
|
switch (arch) {
|
|
61
|
-
case
|
|
64
|
+
case 'x64':
|
|
62
65
|
localFileExisted = existsSync(
|
|
63
|
-
join(__dirname,
|
|
64
|
-
)
|
|
66
|
+
join(__dirname, 'html.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
65
68
|
try {
|
|
66
69
|
if (localFileExisted) {
|
|
67
|
-
nativeBinding = require(
|
|
70
|
+
nativeBinding = require('./html.win32-x64-msvc.node')
|
|
68
71
|
} else {
|
|
69
|
-
nativeBinding = require(
|
|
72
|
+
nativeBinding = require('@swc/html-win32-x64-msvc')
|
|
70
73
|
}
|
|
71
74
|
} catch (e) {
|
|
72
|
-
loadError = e
|
|
75
|
+
loadError = e
|
|
73
76
|
}
|
|
74
|
-
break
|
|
75
|
-
case
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
76
79
|
localFileExisted = existsSync(
|
|
77
|
-
join(__dirname,
|
|
78
|
-
)
|
|
80
|
+
join(__dirname, 'html.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
79
82
|
try {
|
|
80
83
|
if (localFileExisted) {
|
|
81
|
-
nativeBinding = require(
|
|
84
|
+
nativeBinding = require('./html.win32-ia32-msvc.node')
|
|
82
85
|
} else {
|
|
83
|
-
nativeBinding = require(
|
|
86
|
+
nativeBinding = require('@swc/html-win32-ia32-msvc')
|
|
84
87
|
}
|
|
85
88
|
} catch (e) {
|
|
86
|
-
loadError = e
|
|
89
|
+
loadError = e
|
|
87
90
|
}
|
|
88
|
-
break
|
|
89
|
-
case
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
90
93
|
localFileExisted = existsSync(
|
|
91
|
-
join(__dirname,
|
|
92
|
-
)
|
|
94
|
+
join(__dirname, 'html.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
93
96
|
try {
|
|
94
97
|
if (localFileExisted) {
|
|
95
|
-
nativeBinding = require(
|
|
98
|
+
nativeBinding = require('./html.win32-arm64-msvc.node')
|
|
96
99
|
} else {
|
|
97
|
-
nativeBinding = require(
|
|
100
|
+
nativeBinding = require('@swc/html-win32-arm64-msvc')
|
|
98
101
|
}
|
|
99
102
|
} catch (e) {
|
|
100
|
-
loadError = e
|
|
103
|
+
loadError = e
|
|
101
104
|
}
|
|
102
|
-
break
|
|
105
|
+
break
|
|
103
106
|
default:
|
|
104
|
-
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
105
108
|
}
|
|
106
|
-
break
|
|
107
|
-
case
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'html.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./html.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@swc/html-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
108
120
|
switch (arch) {
|
|
109
|
-
case
|
|
110
|
-
localFileExisted = existsSync(join(__dirname,
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'html.darwin-x64.node'))
|
|
111
123
|
try {
|
|
112
124
|
if (localFileExisted) {
|
|
113
|
-
nativeBinding = require(
|
|
125
|
+
nativeBinding = require('./html.darwin-x64.node')
|
|
114
126
|
} else {
|
|
115
|
-
nativeBinding = require(
|
|
127
|
+
nativeBinding = require('@swc/html-darwin-x64')
|
|
116
128
|
}
|
|
117
129
|
} catch (e) {
|
|
118
|
-
loadError = e
|
|
130
|
+
loadError = e
|
|
119
131
|
}
|
|
120
|
-
break
|
|
121
|
-
case
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
122
134
|
localFileExisted = existsSync(
|
|
123
|
-
join(__dirname,
|
|
124
|
-
)
|
|
135
|
+
join(__dirname, 'html.darwin-arm64.node')
|
|
136
|
+
)
|
|
125
137
|
try {
|
|
126
138
|
if (localFileExisted) {
|
|
127
|
-
nativeBinding = require(
|
|
139
|
+
nativeBinding = require('./html.darwin-arm64.node')
|
|
128
140
|
} else {
|
|
129
|
-
nativeBinding = require(
|
|
141
|
+
nativeBinding = require('@swc/html-darwin-arm64')
|
|
130
142
|
}
|
|
131
143
|
} catch (e) {
|
|
132
|
-
loadError = e
|
|
144
|
+
loadError = e
|
|
133
145
|
}
|
|
134
|
-
break
|
|
146
|
+
break
|
|
135
147
|
default:
|
|
136
|
-
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
137
149
|
}
|
|
138
|
-
break
|
|
139
|
-
case
|
|
140
|
-
if (arch !==
|
|
141
|
-
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
142
154
|
}
|
|
143
|
-
localFileExisted = existsSync(join(__dirname,
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'html.freebsd-x64.node'))
|
|
144
156
|
try {
|
|
145
157
|
if (localFileExisted) {
|
|
146
|
-
nativeBinding = require(
|
|
158
|
+
nativeBinding = require('./html.freebsd-x64.node')
|
|
147
159
|
} else {
|
|
148
|
-
nativeBinding = require(
|
|
160
|
+
nativeBinding = require('@swc/html-freebsd-x64')
|
|
149
161
|
}
|
|
150
162
|
} catch (e) {
|
|
151
|
-
loadError = e
|
|
163
|
+
loadError = e
|
|
152
164
|
}
|
|
153
|
-
break
|
|
154
|
-
case
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
155
167
|
switch (arch) {
|
|
156
|
-
case
|
|
168
|
+
case 'x64':
|
|
157
169
|
if (isMusl()) {
|
|
158
170
|
localFileExisted = existsSync(
|
|
159
|
-
join(__dirname,
|
|
160
|
-
)
|
|
171
|
+
join(__dirname, 'html.linux-x64-musl.node')
|
|
172
|
+
)
|
|
161
173
|
try {
|
|
162
174
|
if (localFileExisted) {
|
|
163
|
-
nativeBinding = require(
|
|
175
|
+
nativeBinding = require('./html.linux-x64-musl.node')
|
|
164
176
|
} else {
|
|
165
|
-
nativeBinding = require(
|
|
177
|
+
nativeBinding = require('@swc/html-linux-x64-musl')
|
|
166
178
|
}
|
|
167
179
|
} catch (e) {
|
|
168
|
-
loadError = e
|
|
180
|
+
loadError = e
|
|
169
181
|
}
|
|
170
182
|
} else {
|
|
171
183
|
localFileExisted = existsSync(
|
|
172
|
-
join(__dirname,
|
|
173
|
-
)
|
|
184
|
+
join(__dirname, 'html.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
174
186
|
try {
|
|
175
187
|
if (localFileExisted) {
|
|
176
|
-
nativeBinding = require(
|
|
188
|
+
nativeBinding = require('./html.linux-x64-gnu.node')
|
|
177
189
|
} else {
|
|
178
|
-
nativeBinding = require(
|
|
190
|
+
nativeBinding = require('@swc/html-linux-x64-gnu')
|
|
179
191
|
}
|
|
180
192
|
} catch (e) {
|
|
181
|
-
loadError = e
|
|
193
|
+
loadError = e
|
|
182
194
|
}
|
|
183
195
|
}
|
|
184
|
-
break
|
|
185
|
-
case
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
186
198
|
if (isMusl()) {
|
|
187
199
|
localFileExisted = existsSync(
|
|
188
|
-
join(__dirname,
|
|
189
|
-
)
|
|
200
|
+
join(__dirname, 'html.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
190
202
|
try {
|
|
191
203
|
if (localFileExisted) {
|
|
192
|
-
nativeBinding = require(
|
|
204
|
+
nativeBinding = require('./html.linux-arm64-musl.node')
|
|
193
205
|
} else {
|
|
194
|
-
nativeBinding = require(
|
|
206
|
+
nativeBinding = require('@swc/html-linux-arm64-musl')
|
|
195
207
|
}
|
|
196
208
|
} catch (e) {
|
|
197
|
-
loadError = e
|
|
209
|
+
loadError = e
|
|
198
210
|
}
|
|
199
211
|
} else {
|
|
200
212
|
localFileExisted = existsSync(
|
|
201
|
-
join(__dirname,
|
|
202
|
-
)
|
|
213
|
+
join(__dirname, 'html.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
203
215
|
try {
|
|
204
216
|
if (localFileExisted) {
|
|
205
|
-
nativeBinding = require(
|
|
217
|
+
nativeBinding = require('./html.linux-arm64-gnu.node')
|
|
206
218
|
} else {
|
|
207
|
-
nativeBinding = require(
|
|
219
|
+
nativeBinding = require('@swc/html-linux-arm64-gnu')
|
|
208
220
|
}
|
|
209
221
|
} catch (e) {
|
|
210
|
-
loadError = e
|
|
222
|
+
loadError = e
|
|
211
223
|
}
|
|
212
224
|
}
|
|
213
|
-
break
|
|
214
|
-
case
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
215
227
|
localFileExisted = existsSync(
|
|
216
|
-
join(__dirname,
|
|
217
|
-
)
|
|
228
|
+
join(__dirname, 'html.linux-arm-gnueabihf.node')
|
|
229
|
+
)
|
|
218
230
|
try {
|
|
219
231
|
if (localFileExisted) {
|
|
220
|
-
nativeBinding = require(
|
|
232
|
+
nativeBinding = require('./html.linux-arm-gnueabihf.node')
|
|
221
233
|
} else {
|
|
222
|
-
nativeBinding = require(
|
|
234
|
+
nativeBinding = require('@swc/html-linux-arm-gnueabihf')
|
|
223
235
|
}
|
|
224
236
|
} catch (e) {
|
|
225
|
-
loadError = e
|
|
237
|
+
loadError = e
|
|
226
238
|
}
|
|
227
|
-
break
|
|
239
|
+
break
|
|
228
240
|
default:
|
|
229
|
-
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
241
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
230
242
|
}
|
|
231
|
-
break
|
|
243
|
+
break
|
|
232
244
|
default:
|
|
233
|
-
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
245
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
234
246
|
}
|
|
235
247
|
|
|
236
248
|
if (!nativeBinding) {
|
|
237
249
|
if (loadError) {
|
|
238
|
-
throw loadError
|
|
250
|
+
throw loadError
|
|
239
251
|
}
|
|
240
|
-
throw new Error(`Failed to load native binding`)
|
|
252
|
+
throw new Error(`Failed to load native binding`)
|
|
241
253
|
}
|
|
242
254
|
|
|
243
|
-
const { minify, minifyFragment, minifySync, minifyFragmentSync } =
|
|
244
|
-
nativeBinding;
|
|
255
|
+
const { minify, minifyFragment, minifySync, minifyFragmentSync } = nativeBinding
|
|
245
256
|
|
|
246
|
-
module.exports.minify = minify
|
|
247
|
-
module.exports.minifyFragment = minifyFragment
|
|
248
|
-
module.exports.minifySync = minifySync
|
|
249
|
-
module.exports.minifyFragmentSync = minifyFragmentSync
|
|
257
|
+
module.exports.minify = minify
|
|
258
|
+
module.exports.minifyFragment = minifyFragment
|
|
259
|
+
module.exports.minifySync = minifySync
|
|
260
|
+
module.exports.minifyFragmentSync = minifyFragmentSync
|
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.25",
|
|
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.25",
|
|
62
|
+
"@swc/html-darwin-x64": "0.0.25",
|
|
63
|
+
"@swc/html-linux-x64-gnu": "0.0.25",
|
|
64
|
+
"@swc/html-linux-x64-musl": "0.0.25",
|
|
65
|
+
"@swc/html-win32-ia32-msvc": "0.0.25",
|
|
66
|
+
"@swc/html-linux-arm64-gnu": "0.0.25",
|
|
67
|
+
"@swc/html-linux-arm-gnueabihf": "0.0.25",
|
|
68
|
+
"@swc/html-darwin-arm64": "0.0.25",
|
|
69
|
+
"@swc/html-android-arm64": "0.0.25",
|
|
70
|
+
"@swc/html-linux-arm64-musl": "0.0.25",
|
|
71
|
+
"@swc/html-win32-arm64-msvc": "0.0.25",
|
|
72
|
+
"@swc/html-android-arm-eabi": "0.0.25"
|
|
70
73
|
}
|
|
71
74
|
}
|