Skip to content

Commit fdcad09

Browse files
authored
chore: Fix typings (#35)
1 parent 7be09b0 commit fdcad09

File tree

9 files changed

+82
-66
lines changed

9 files changed

+82
-66
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"prepare": "husky install && git config feature.manyFiles true"
3939
},
4040
"devDependencies": {
41-
"@napi-rs/cli": "^2.10.0",
4241
"@taplo/cli": "^0.3.2",
4342
"@types/jest": "^28.1.4",
4443
"@types/node": "^14.14.41",

packages/css/binding.d.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
/* auto-generated by NAPI-RS */
55

66
export interface Diagnostic {
7-
level: string;
8-
message: string;
9-
span: any;
7+
level: string
8+
message: string
9+
span: any
1010
}
1111
export interface TransformOutput {
12-
code: string;
13-
map?: string;
14-
errors?: Array<Diagnostic>;
12+
code: string
13+
map?: string
14+
errors?: Array<Diagnostic>
1515
}
16-
export function minify(
17-
code: Buffer,
18-
opts: Buffer,
19-
signal?: AbortSignal | undefined | null
20-
): Promise<TransformOutput>;
21-
export function minifySync(code: Buffer, opts: Buffer): TransformOutput;
16+
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
17+
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
18+
export function transform(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
19+
export function transformSync(code: Buffer, opts: Buffer): TransformOutput

packages/css/index.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
import * as binding from "./binding";
22

3-
export type Options = {
3+
export type MinifyOptions = {
44
filename?: string;
55
sourceMap?: boolean;
66
};
77

8+
export type TransformOptions = {
9+
filename?: string;
10+
11+
sourceMap?: boolean
12+
13+
cssModules?: CssModuleTransformOptions
14+
15+
minify?: boolean
16+
}
17+
18+
export type CssModuleTransformOptions = {
19+
pattern: String,
20+
}
21+
822
export async function minify(
923
content: Buffer,
10-
options: Options
24+
options: MinifyOptions
1125
): Promise<binding.TransformOutput> {
1226
return binding.minify(content, toBuffer(options ?? {}));
1327
}
1428

15-
export function minifySync(content: Buffer, options: Options) {
29+
export function minifySync(content: Buffer, options: MinifyOptions) {
1630
return binding.minifySync(content, toBuffer(options ?? {}));
1731
}
1832

33+
export async function transform(
34+
content: Buffer,
35+
options: TransformOptions
36+
): Promise<binding.TransformOutput> {
37+
return binding.transform(content, toBuffer(options ?? {}));
38+
}
39+
40+
export function transformSync(content: Buffer, options: TransformOptions) {
41+
return binding.transformSync(content, toBuffer(options ?? {}));
42+
}
43+
1944
function toBuffer(t: any): Buffer {
2045
return Buffer.from(JSON.stringify(t));
2146
}

packages/css/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"version": "napi version -p scripts/npm"
5555
},
5656
"devDependencies": {
57+
"@napi-rs/cli": "^2.16.1",
5758
"typescript": "^5.1.6"
5859
}
5960
}

packages/html/binding.d.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,27 @@
44
/* auto-generated by NAPI-RS */
55

66
export interface Diagnostic {
7-
level: string;
8-
message: string;
9-
span: any;
7+
level: string
8+
message: string
9+
span: any
1010
}
1111
export interface TransformOutput {
12-
code: string;
13-
errors?: Array<Diagnostic>;
12+
code: string
13+
errors?: Array<Diagnostic>
1414
}
1515
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
2020
}
2121
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
2626
}
27-
export function minify(
28-
code: Buffer,
29-
opts: Buffer,
30-
signal?: AbortSignal | undefined | null
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

packages/html/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,9 @@
5252
"build:dev": "tsc -d && napi build --platform --cargo-name html_node --js ./binding.js --dts binding.d.ts -p html_node --cargo-cwd ../..",
5353
"test": "echo 'done!'",
5454
"version": "napi version -p scripts/npm"
55+
},
56+
"devDependencies": {
57+
"@napi-rs/cli": "^2.16.1",
58+
"typescript": "^5.1.6"
5559
}
5660
}

packages/linter/binding.d.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
/* auto-generated by NAPI-RS */
55

66
export interface Diagnostic {
7-
level: string;
8-
message: string;
9-
span: any;
7+
level: string
8+
message: string
9+
span: any
1010
}
1111
export interface TransformOutput {
12-
errors?: Array<Diagnostic>;
12+
errors?: Array<Diagnostic>
1313
}
14-
export function lint(
15-
code: Buffer,
16-
opts: Buffer,
17-
signal?: AbortSignal | undefined | null
18-
): Promise<TransformOutput>;
19-
export function lintSync(code: Buffer, opts: Buffer): TransformOutput;
14+
export function lint(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
15+
export function lintSync(code: Buffer, opts: Buffer): TransformOutput

packages/linter/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,9 @@
5353
"build:dev": "tsc -d && napi build --platform --cargo-name linter_node --js ./binding.js --dts binding.d.ts -p linter_node --cargo-cwd ../..",
5454
"test": "echo 'done!'",
5555
"version": "napi version -p scripts/npm"
56+
},
57+
"devDependencies": {
58+
"@napi-rs/cli": "^2.16.1",
59+
"typescript": "^5.1.6"
5660
}
5761
}

yarn.lock

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,12 +1059,12 @@ __metadata:
10591059
languageName: node
10601060
linkType: hard
10611061

1062-
"@napi-rs/cli@npm:^2.10.0":
1063-
version: 2.10.1
1064-
resolution: "@napi-rs/cli@npm:2.10.1"
1062+
"@napi-rs/cli@npm:^2.16.1":
1063+
version: 2.16.1
1064+
resolution: "@napi-rs/cli@npm:2.16.1"
10651065
bin:
10661066
napi: scripts/index.js
1067-
checksum: 2c3ee83577c45d1ba01934d5f8a7068a451877e230f6bbf5559a0c767aa4e0f626fe6511705dc9a1add43d75a8fa08e890dc620277aede27ddbbc0ba0d502b30
1067+
checksum: 5f61712cf1a4002b7b9b65bc4a6f2a7df68b197cfc7024c7d28820e3b12b5e9c0baa0d85f262f25dbf928586ce01c5c06837754f9f98ef4ebafa55dd027c6837
10681068
languageName: node
10691069
linkType: hard
10701070

@@ -1144,7 +1144,6 @@ __metadata:
11441144
version: 0.0.0-use.local
11451145
resolution: "@swc/bindings@workspace:."
11461146
dependencies:
1147-
"@napi-rs/cli": ^2.10.0
11481147
"@taplo/cli": ^0.3.2
11491148
"@types/jest": ^28.1.4
11501149
"@types/node": ^14.14.41
@@ -1159,32 +1158,30 @@ __metadata:
11591158
languageName: unknown
11601159
linkType: soft
11611160

1162-
"@swc/css-loader@workspace:packages/css-loader":
1163-
version: 0.0.0-use.local
1164-
resolution: "@swc/css-loader@workspace:packages/css-loader"
1165-
dependencies:
1166-
"@swc/css": "workspace:^"
1167-
typescript: ^5.1.6
1168-
languageName: unknown
1169-
linkType: soft
1170-
1171-
"@swc/css@workspace:^, @swc/css@workspace:packages/css":
1161+
"@swc/css@workspace:packages/css":
11721162
version: 0.0.0-use.local
11731163
resolution: "@swc/css@workspace:packages/css"
11741164
dependencies:
1165+
"@napi-rs/cli": ^2.16.1
11751166
typescript: ^5.1.6
11761167
languageName: unknown
11771168
linkType: soft
11781169

11791170
"@swc/html@workspace:packages/html":
11801171
version: 0.0.0-use.local
11811172
resolution: "@swc/html@workspace:packages/html"
1173+
dependencies:
1174+
"@napi-rs/cli": ^2.16.1
1175+
typescript: ^5.1.6
11821176
languageName: unknown
11831177
linkType: soft
11841178

11851179
"@swc/linter@workspace:packages/linter":
11861180
version: 0.0.0-use.local
11871181
resolution: "@swc/linter@workspace:packages/linter"
1182+
dependencies:
1183+
"@napi-rs/cli": ^2.16.1
1184+
typescript: ^5.1.6
11881185
languageName: unknown
11891186
linkType: soft
11901187

0 commit comments

Comments
 (0)