yuku-codegen 0.5.14 → 0.5.16
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/README.md +23 -24
- package/encode.js +294 -46
- package/index.d.ts +10 -5
- package/index.js +21 -8
- package/package.json +13 -13
package/index.d.ts
CHANGED
|
@@ -42,8 +42,13 @@ export interface CodegenOptions {
|
|
|
42
42
|
indent?: number;
|
|
43
43
|
/** @default "double" */
|
|
44
44
|
quotes?: Quotes;
|
|
45
|
-
/**
|
|
46
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Enable Source Map V3 output. `true` uses default metadata; pass a
|
|
47
|
+
* {@link SourceMapOptions} object to fill in `file`, `sources`,
|
|
48
|
+
* `sourcesContent`, and `sourceRoot`.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
sourceMaps?: boolean | SourceMapOptions;
|
|
47
52
|
/**
|
|
48
53
|
* Comment passthrough filter. Defaults to `"some"`, which preserves
|
|
49
54
|
* legal headers, JSDoc, and tree-shaking annotations.
|
|
@@ -83,13 +88,13 @@ export interface CodegenResult {
|
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
/** Renders the AST verbatim, preserving TypeScript syntax. */
|
|
86
|
-
export function print(
|
|
91
|
+
export function print(result: ParseResult, options?: CodegenOptions): CodegenResult;
|
|
87
92
|
|
|
88
93
|
/** Renders the AST as JavaScript, dropping TypeScript-specific syntax. */
|
|
89
|
-
export function strip(
|
|
94
|
+
export function strip(result: ParseResult, options?: CodegenOptions): CodegenResult;
|
|
90
95
|
|
|
91
96
|
/**
|
|
92
97
|
* Renders the AST with size-reducing rewrites. Combine with
|
|
93
98
|
* `format: "compact"` for full minification.
|
|
94
99
|
*/
|
|
95
|
-
export function minify(
|
|
100
|
+
export function minify(result: ParseResult, options?: CodegenOptions): CodegenResult;
|
package/index.js
CHANGED
|
@@ -13,18 +13,31 @@ function normalizeOptions(options) {
|
|
|
13
13
|
return next;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function
|
|
17
|
-
|
|
16
|
+
function prepare(result, options) {
|
|
17
|
+
if (!result || !result.program || !result.program.type) {
|
|
18
|
+
throw new TypeError(
|
|
19
|
+
"Expected a `ParseResult` from yuku-parser, got " +
|
|
20
|
+
(result === null ? "null" : typeof result),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (options?.sourceMaps && !result.lineStarts) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"Source maps require a `ParseResult` with `lineStarts`. " +
|
|
26
|
+
"If you built or transformed this result outside of yuku-parser, " +
|
|
27
|
+
"either drop `sourceMaps` or attach a `lineStarts` array.",
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return encode(result);
|
|
18
31
|
}
|
|
19
32
|
|
|
20
|
-
export function print(
|
|
21
|
-
return binding.print(
|
|
33
|
+
export function print(result, options) {
|
|
34
|
+
return binding.print(prepare(result, options), normalizeOptions(options));
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
export function strip(
|
|
25
|
-
return binding.strip(
|
|
37
|
+
export function strip(result, options) {
|
|
38
|
+
return binding.strip(prepare(result, options), normalizeOptions(options));
|
|
26
39
|
}
|
|
27
40
|
|
|
28
|
-
export function minify(
|
|
29
|
-
return binding.minify(
|
|
41
|
+
export function minify(result, options) {
|
|
42
|
+
return binding.minify(prepare(result, options), normalizeOptions(options));
|
|
30
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuku-codegen",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.16",
|
|
4
4
|
"description": "High-performance JavaScript/TypeScript code generator written in Zig",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"encode.js"
|
|
18
18
|
],
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@yuku-codegen/binding-linux-x64-gnu": "0.5.
|
|
21
|
-
"@yuku-codegen/binding-linux-arm64-gnu": "0.5.
|
|
22
|
-
"@yuku-codegen/binding-linux-arm-gnu": "0.5.
|
|
23
|
-
"@yuku-codegen/binding-linux-x64-musl": "0.5.
|
|
24
|
-
"@yuku-codegen/binding-linux-arm64-musl": "0.5.
|
|
25
|
-
"@yuku-codegen/binding-linux-arm-musl": "0.5.
|
|
26
|
-
"@yuku-codegen/binding-darwin-x64": "0.5.
|
|
27
|
-
"@yuku-codegen/binding-darwin-arm64": "0.5.
|
|
28
|
-
"@yuku-codegen/binding-win32-x64": "0.5.
|
|
29
|
-
"@yuku-codegen/binding-win32-arm64": "0.5.
|
|
30
|
-
"@yuku-codegen/binding-freebsd-x64": "0.5.
|
|
20
|
+
"@yuku-codegen/binding-linux-x64-gnu": "0.5.16",
|
|
21
|
+
"@yuku-codegen/binding-linux-arm64-gnu": "0.5.16",
|
|
22
|
+
"@yuku-codegen/binding-linux-arm-gnu": "0.5.16",
|
|
23
|
+
"@yuku-codegen/binding-linux-x64-musl": "0.5.16",
|
|
24
|
+
"@yuku-codegen/binding-linux-arm64-musl": "0.5.16",
|
|
25
|
+
"@yuku-codegen/binding-linux-arm-musl": "0.5.16",
|
|
26
|
+
"@yuku-codegen/binding-darwin-x64": "0.5.16",
|
|
27
|
+
"@yuku-codegen/binding-darwin-arm64": "0.5.16",
|
|
28
|
+
"@yuku-codegen/binding-win32-x64": "0.5.16",
|
|
29
|
+
"@yuku-codegen/binding-win32-arm64": "0.5.16",
|
|
30
|
+
"@yuku-codegen/binding-freebsd-x64": "0.5.16"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
33
|
"ast",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"typescript"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"yuku-parser": "0.5.
|
|
43
|
+
"yuku-parser": "0.5.14"
|
|
44
44
|
}
|
|
45
45
|
}
|