@kubb/parser-ts 5.10.2 → 5.10.4
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/dist/index.cjs +2 -2
- package/dist/index.d.cts +79 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +3 -3
- package/kubb-extension.json +1 -1
- package/package.json +12 -7
- package/dist/rolldown-runtime-CRm0XQPb.js +0 -9
package/dist/index.cjs
CHANGED
|
@@ -7,11 +7,11 @@ let node_path = require("node:path");
|
|
|
7
7
|
//#region kubb-extension.json
|
|
8
8
|
var compatibility = {
|
|
9
9
|
"kubb": ">=5.8.3",
|
|
10
|
-
"node": ">=22"
|
|
10
|
+
"node": ">=22.12"
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region package.json
|
|
14
|
-
var version = "5.10.
|
|
14
|
+
var version = "5.10.4";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/utils.ts
|
|
17
17
|
let compiler;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ast } from "@kubb/ast";
|
|
2
|
+
import * as ts from "typescript";
|
|
3
|
+
//#region src/parserTs.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options accepted by `parserTs` and `parserTsx`.
|
|
6
|
+
*/
|
|
7
|
+
type ParserTsOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Rewrite extensions on relative `import`/`export` statements. Each key is the extension of a
|
|
10
|
+
* generated file, and its value is the extension written on the relative specifiers in that
|
|
11
|
+
* file. `''` drops it, and so does a generated file whose extension has no key. Package
|
|
12
|
+
* specifiers stay unchanged. Also applies to relative paths in `copy` templates.
|
|
13
|
+
*
|
|
14
|
+
* Use `{ '.ts': '.js' }` for ESM output compiled to JavaScript, or `{ '.ts': '.ts' }` to run the
|
|
15
|
+
* `.ts` files directly in Node.js or compile them with `rewriteRelativeImportExtensions`.
|
|
16
|
+
*
|
|
17
|
+
* @default { '.ts': '' }
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* parserTs({ extension: { '.ts': '.js' } }) // import './api.js' instead of './api'
|
|
21
|
+
* parserTs({ extension: { '.ts': '.ts' } }) // import './api.ts' instead of './api'
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
extension?: Record<ast.FileNode['extname'], ast.FileNode['extname'] | ''>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Default Kubb parser for `.ts` and `.js` files. Takes the universal AST
|
|
28
|
+
* produced by an adapter and prints it as TypeScript source. Imports and exports
|
|
29
|
+
* are rewritten based on each file's metadata and the `extension` option. The
|
|
30
|
+
* `print` helper renders TypeScript compiler nodes with the TypeScript printer.
|
|
31
|
+
*
|
|
32
|
+
* Used automatically when no `parsers` option is set on `defineConfig`. Use
|
|
33
|
+
* `parserTsx` instead for React projects that emit JSX.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { defineConfig } from 'kubb'
|
|
38
|
+
* import { adapterOas } from '@kubb/adapter-oas'
|
|
39
|
+
* import { parserTs } from '@kubb/parser-ts'
|
|
40
|
+
*
|
|
41
|
+
* export default defineConfig({
|
|
42
|
+
* input: './petStore.yaml',
|
|
43
|
+
* output: { path: './src/gen' },
|
|
44
|
+
* adapter: adapterOas(),
|
|
45
|
+
* parsers: [parserTs()],
|
|
46
|
+
* plugins: [],
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const parserTs: import("@kubb/core").ParserFactory<ParserTsOptions, object, ts.Node>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/parserTsx.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* Kubb parser for `.tsx` and `.jsx` files. Delegates to `parserTs` because the
|
|
55
|
+
* TypeScript compiler handles JSX natively via `ScriptKind.TSX`, so it shares the
|
|
56
|
+
* same `extension` option.
|
|
57
|
+
*
|
|
58
|
+
* Add to the `parsers` array on `defineConfig` when generating components for
|
|
59
|
+
* React (or any framework that emits JSX).
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { defineConfig } from 'kubb'
|
|
64
|
+
* import { adapterOas } from '@kubb/adapter-oas'
|
|
65
|
+
* import { parserTsx } from '@kubb/parser-ts'
|
|
66
|
+
*
|
|
67
|
+
* export default defineConfig({
|
|
68
|
+
* input: './petStore.yaml',
|
|
69
|
+
* output: { path: './src/gen' },
|
|
70
|
+
* adapter: adapterOas(),
|
|
71
|
+
* parsers: [parserTsx()],
|
|
72
|
+
* plugins: [],
|
|
73
|
+
* })
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare const parserTsx: import("@kubb/core").ParserFactory<ParserTsOptions, object, ts.Node>;
|
|
77
|
+
//#endregion
|
|
78
|
+
export type { ParserTsOptions };
|
|
79
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
1
|
import { createRequire } from "node:module";
|
|
3
2
|
import { ast } from "@kubb/ast";
|
|
4
3
|
import { defineExtension } from "@kubb/core";
|
|
5
4
|
import { dirname, extname, relative, resolve } from "node:path";
|
|
5
|
+
//#endregion
|
|
6
6
|
//#region kubb-extension.json
|
|
7
7
|
var compatibility = {
|
|
8
8
|
"kubb": ">=5.8.3",
|
|
9
|
-
"node": ">=22"
|
|
9
|
+
"node": ">=22.12"
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "5.10.
|
|
13
|
+
var version = "5.10.4";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/utils.ts
|
|
16
16
|
let compiler;
|
package/kubb-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/parser-ts",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.4",
|
|
4
4
|
"description": "TypeScript and TSX source file parser for Kubb. Converts AST nodes into formatted source strings using the TypeScript compiler API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|
|
@@ -47,9 +47,14 @@
|
|
|
47
47
|
"types": "./dist/index.d.ts",
|
|
48
48
|
"exports": {
|
|
49
49
|
".": {
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
"import": {
|
|
51
|
+
"types": "./dist/index.d.ts",
|
|
52
|
+
"default": "./dist/index.js"
|
|
53
|
+
},
|
|
54
|
+
"require": {
|
|
55
|
+
"types": "./dist/index.d.cts",
|
|
56
|
+
"default": "./dist/index.cjs"
|
|
57
|
+
}
|
|
53
58
|
},
|
|
54
59
|
"./kubb-extension.json": "./kubb-extension.json",
|
|
55
60
|
"./package.json": "./package.json"
|
|
@@ -59,12 +64,12 @@
|
|
|
59
64
|
"registry": "https://registry.npmjs.org/"
|
|
60
65
|
},
|
|
61
66
|
"dependencies": {
|
|
62
|
-
"@kubb/ast": "5.10.
|
|
63
|
-
"@kubb/core": "5.10.
|
|
67
|
+
"@kubb/ast": "5.10.4",
|
|
68
|
+
"@kubb/core": "5.10.4",
|
|
64
69
|
"typescript": "^6.0.3"
|
|
65
70
|
},
|
|
66
71
|
"engines": {
|
|
67
|
-
"node": ">=22"
|
|
72
|
+
"node": ">=22.12"
|
|
68
73
|
},
|
|
69
74
|
"scripts": {
|
|
70
75
|
"build": "tsdown",
|