🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@kubb/parser

Package Overview
Dependencies
Maintainers
1
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kubb/parser - npm Package Compare versions

Comparing version

to
2.1.0

src/api.ts

11

dist/index.d.ts
import ts, { PrinterOptions } from 'typescript';
export { default as ts } from 'typescript';
type ExportsResult = {
name: string;
isTypeOnly: boolean;
};
/**
* @link https://github.com/microsoft/TypeScript/issues/15840
*/
declare function getExports(filePath: string): undefined | Array<ExportsResult>;
type ParseResult = {

@@ -16,2 +25,2 @@ ast: ts.Node;

export { parse, print };
export { getExports, parse, print };
import { createRequire } from 'module';
import ts from 'typescript';
import path from 'path';
import ts2 from 'typescript';
createRequire(import.meta.url);
var { factory } = ts;
function getExports(filePath) {
const rootName = path.extname(filePath) ? filePath : `${filePath}.ts`;
if (!rootName) {
return void 0;
}
const program = ts2.createProgram({
rootNames: [rootName],
options: {}
});
const checker = program.getTypeChecker();
const sources = program.getSourceFiles();
const sourceFile = sources.find((sourceFile2) => sourceFile2.fileName === rootName);
if (!sourceFile) {
return void 0;
}
const symbol = checker.getSymbolAtLocation(sourceFile);
if (!symbol?.flags) {
return void 0;
}
const exports = checker.getExportsOfModule(symbol);
return exports.map((e) => {
const type = checker.getTypeOfSymbol(e);
return {
name: e.escapedName.toString(),
isTypeOnly: type?.id === 5
};
});
}
var { factory } = ts2;
var escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */");
var restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, "\n");
function print(elements, { source = "", baseName = "print.ts", removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed } = {}) {
const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, ts.ScriptKind.TS);
const printer = ts.createPrinter({ omitTrailingSemicolon: true, newLine, removeComments, noEmitHelpers });
function print(elements, { source = "", baseName = "print.ts", removeComments, noEmitHelpers, newLine = ts2.NewLineKind.LineFeed } = {}) {
const sourceFile = ts2.createSourceFile(baseName, escapeNewLines(source), ts2.ScriptTarget.ES2022, false, ts2.ScriptKind.TS);
const printer = ts2.createPrinter({ omitTrailingSemicolon: true, newLine, removeComments, noEmitHelpers });
let nodes = [];

@@ -20,3 +49,3 @@ if (!elements) {

}
const outputFile = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile);
const outputFile = printer.printList(ts2.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile);
const outputSource = printer.printFile(sourceFile);

@@ -34,4 +63,4 @@ return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join("\n");

export { parse, print };
export { getExports, parse, print };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map

4

package.json
{
"name": "@kubb/parser",
"version": "2.0.6",
"version": "2.1.0",
"description": "Generator parser",

@@ -47,3 +47,3 @@ "keywords": [

"devDependencies": {
"eslint": "^8.55.0",
"eslint": "^8.56.0",
"tsup": "^8.0.1",

@@ -50,0 +50,0 @@ "@kubb/eslint-config": "1.1.8",

@@ -0,3 +1,4 @@

export { getExports } from './api.ts'
export { parse } from './parse.ts'
export { print } from './print.ts'
export type { default as ts } from 'typescript'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet