@kubb/parser-ts 3.0.0-alpha.20 → 3.0.0-alpha.21
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.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/format.ts +3 -0
- package/src/index.ts +0 -1
- package/src/print.ts +3 -0
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":["ts"],"mappings":";;;;;;;;;AAIA,IAAM,EAAE,SAAY,GAAAA,mBAAA,CAAA;AAYpB,IAAM,iBAAiB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,SAAS,mBAAmB,CAAA,CAAA;AAOlF,IAAM,kBAAkB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,wBAAwB,IAAI,CAAA,CAAA;
|
|
1
|
+
{"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":["ts"],"mappings":";;;;;;;;;AAIA,IAAM,EAAE,SAAY,GAAAA,mBAAA,CAAA;AAYpB,IAAM,iBAAiB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,SAAS,mBAAmB,CAAA,CAAA;AAOlF,IAAM,kBAAkB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,wBAAwB,IAAI,CAAA,CAAA;AAK5E,SAAS,KACd,CAAA,QAAA,EACA,EAAE,MAAA,GAAS,IAAI,QAAW,GAAA,UAAA,EAAY,cAAgB,EAAA,aAAA,EAAe,UAAUA,mBAAG,CAAA,WAAA,CAAY,QAAS,EAAA,GAAa,EAC5G,EAAA;AACR,EAAA,MAAM,UAAa,GAAAA,mBAAA,CAAG,gBAAiB,CAAA,QAAA,EAAU,cAAe,CAAA,MAAM,CAAG,EAAAA,mBAAA,CAAG,YAAa,CAAA,MAAA,EAAQ,KAAO,EAAAA,mBAAA,CAAG,WAAW,EAAE,CAAA,CAAA;AACxH,EAAM,MAAA,OAAA,GAAUA,oBAAG,aAAc,CAAA;AAAA,IAC/B,qBAAuB,EAAA,IAAA;AAAA,IACvB,OAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAA,IAAI,QAAwB,EAAC,CAAA;AAE7B,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAO,OAAA,EAAA,CAAA;AAAA,GACT;AAEA,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,QAAQ,CAAG,EAAA;AAC3B,IAAQ,KAAA,GAAA,QAAA,CAAS,OAAO,OAAO,CAAA,CAAA;AAAA,GAC1B,MAAA;AACL,IAAA,KAAA,GAAQ,CAAC,QAAQ,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA,CAAA;AAAA,GACnC;AAEA,EAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,SAAA,CAAUA,mBAAG,CAAA,UAAA,CAAW,WAAW,OAAQ,CAAA,eAAA,CAAgB,KAAK,CAAA,EAAG,UAAU,CAAA,CAAA;AACxG,EAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,SAAA,CAAU,UAAU,CAAA,CAAA;AAEjD,EAAO,OAAA,CAAC,UAAY,EAAA,eAAA,CAAgB,YAAY,CAAC,EAAE,MAAO,CAAA,OAAO,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AAC9E,CAAA;;;ACnDO,SAAS,OAAO,MAAgB,EAAA;AAErC,EAAA,OAAO,MAAM,EAAC,EAAG,EAAE,MAAQ,EAAA,aAAA,EAAe,OAAO,CAAA,CAAA;AACnD","file":"index.cjs","sourcesContent":["import ts from 'typescript'\n\nimport type { PrinterOptions } from 'typescript'\n\nconst { factory } = ts\n\ntype Options = {\n source?: string\n baseName?: string\n} & PrinterOptions\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param {string} code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param {string} code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript nodes to a string based on the TypeScript printer.\n */\nexport function print(\n elements: Array<ts.Node>,\n { source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed }: Options = {},\n): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, ts.ScriptKind.TS)\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine,\n removeComments,\n noEmitHelpers,\n })\n\n let nodes: Array<ts.Node> = []\n\n if (!elements) {\n return ''\n }\n\n if (Array.isArray(elements)) {\n nodes = elements.filter(Boolean)\n } else {\n nodes = [elements].filter(Boolean)\n }\n\n const outputFile = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n const outputSource = printer.printFile(sourceFile)\n\n return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join('\\n')\n}\n","import { print } from './print.ts'\n\n/**\n * Format the generated code based on the TypeScript printer.\n */\nexport function format(source: string) {\n // do some basic linting with the ts compiler\n return print([], { source, noEmitHelpers: false })\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import ts, { PrinterOptions } from 'typescript';
|
|
2
|
-
export { default as ts } from 'typescript';
|
|
3
2
|
export { f as factory } from './factory-CFXA_d49.cjs';
|
|
4
3
|
|
|
5
4
|
type Options = {
|
|
6
5
|
source?: string;
|
|
7
6
|
baseName?: string;
|
|
8
7
|
} & PrinterOptions;
|
|
8
|
+
/**
|
|
9
|
+
* Convert AST TypeScript nodes to a string based on the TypeScript printer.
|
|
10
|
+
*/
|
|
9
11
|
declare function print(elements: Array<ts.Node>, { source, baseName, removeComments, noEmitHelpers, newLine }?: Options): string;
|
|
10
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Format the generated code based on the TypeScript printer.
|
|
15
|
+
*/
|
|
11
16
|
declare function format(source: string): string;
|
|
12
17
|
|
|
13
18
|
export { format, print };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import ts, { PrinterOptions } from 'typescript';
|
|
2
|
-
export { default as ts } from 'typescript';
|
|
3
2
|
export { f as factory } from './factory-CFXA_d49.js';
|
|
4
3
|
|
|
5
4
|
type Options = {
|
|
6
5
|
source?: string;
|
|
7
6
|
baseName?: string;
|
|
8
7
|
} & PrinterOptions;
|
|
8
|
+
/**
|
|
9
|
+
* Convert AST TypeScript nodes to a string based on the TypeScript printer.
|
|
10
|
+
*/
|
|
9
11
|
declare function print(elements: Array<ts.Node>, { source, baseName, removeComments, noEmitHelpers, newLine }?: Options): string;
|
|
10
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Format the generated code based on the TypeScript printer.
|
|
15
|
+
*/
|
|
11
16
|
declare function format(source: string): string;
|
|
12
17
|
|
|
13
18
|
export { format, print };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":[],"mappings":";;;AAIA,IAAM,EAAE,SAAY,GAAA,EAAA,CAAA;AAYpB,IAAM,iBAAiB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,SAAS,mBAAmB,CAAA,CAAA;AAOlF,IAAM,kBAAkB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,wBAAwB,IAAI,CAAA,CAAA;
|
|
1
|
+
{"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":[],"mappings":";;;AAIA,IAAM,EAAE,SAAY,GAAA,EAAA,CAAA;AAYpB,IAAM,iBAAiB,CAAC,IAAA,K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EjD,EAAO,OAAA,CAAC,UAAY,EAAA,eAAA,CAAgB,YAAY,CAAC,EAAE,MAAO,CAAA,OAAO,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AAC9E,CAAA;;;ACnDO,SAAS,OAAO,MAAgB,EAAA;AAErC,EAAA,OAAO,MAAM,EAAC,EAAG,EAAE,MAAQ,EAAA,aAAA,EAAe,OAAO,CAAA,CAAA;AACnD","file":"index.js","sourcesContent":["import ts from 'typescript'\n\nimport type { PrinterOptions } from 'typescript'\n\nconst { factory } = ts\n\ntype Options = {\n source?: string\n baseName?: string\n} & PrinterOptions\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param {string} code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param {string} code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript nodes to a string based on the TypeScript printer.\n */\nexport function print(\n elements: Array<ts.Node>,\n { source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed }: Options = {},\n): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, ts.ScriptKind.TS)\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine,\n removeComments,\n noEmitHelpers,\n })\n\n let nodes: Array<ts.Node> = []\n\n if (!elements) {\n return ''\n }\n\n if (Array.isArray(elements)) {\n nodes = elements.filter(Boolean)\n } else {\n nodes = [elements].filter(Boolean)\n }\n\n const outputFile = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n const outputSource = printer.printFile(sourceFile)\n\n return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join('\\n')\n}\n","import { print } from './print.ts'\n\n/**\n * Format the generated code based on the TypeScript printer.\n */\nexport function format(source: string) {\n // do some basic linting with the ts compiler\n return print([], { source, noEmitHelpers: false })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/parser-ts",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.21",
|
|
4
4
|
"description": "TypeScript parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
"!/**/__tests__/**"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"remeda": "^2.
|
|
51
|
+
"remeda": "^2.14.0",
|
|
52
52
|
"typescript": "^5.6.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"tsup": "^8.
|
|
56
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
57
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
55
|
+
"tsup": "^8.3.0",
|
|
56
|
+
"@kubb/config-ts": "3.0.0-alpha.21",
|
|
57
|
+
"@kubb/config-tsup": "3.0.0-alpha.21"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=20"
|
package/src/format.ts
CHANGED
package/src/index.ts
CHANGED
package/src/print.ts
CHANGED
|
@@ -23,6 +23,9 @@ const escapeNewLines = (code: string) => code.replace(/\n\n/g, '\n/* :newline: *
|
|
|
23
23
|
*/
|
|
24
24
|
const restoreNewLines = (code: string) => code.replace(/\/\* :newline: \*\//g, '\n')
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Convert AST TypeScript nodes to a string based on the TypeScript printer.
|
|
28
|
+
*/
|
|
26
29
|
export function print(
|
|
27
30
|
elements: Array<ts.Node>,
|
|
28
31
|
{ source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed }: Options = {},
|