@kubb/parser-ts 5.27.1 → 5.28.0
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 +698 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +699 -47
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["extname","getExtname"],"sources":["../kubb-extension.json","../package.json","../src/inline.ts","../../../internals/utils/src/text.ts","../src/utils.ts","../src/parserTs.ts","../src/parserTsx.ts"],"sourcesContent":["","","import type { ast } from '@kubb/ast'\nimport { parse, TokenKind } from 'yuku'\n\n// A name followed by `:` or `?:` right after one of these is a key or parameter name (`{ Name: x }`, `(Name: x)`).\nconst keyStarts = new Set<number>([TokenKind.LeftBrace, TokenKind.Comma, TokenKind.Semicolon, TokenKind.LeftParen])\n\n/**\n * Calls `replace` for every identifier that references something, and swaps in what it returns.\n * yuku's tokens leave out strings, comments and template text; member access (`x.Name`) and keys are skipped here.\n */\nexport function replaceIdentifiers(text: string, replace: (name: string) => string | undefined, lang: 'ts' | 'tsx' = 'ts'): string {\n // Generated fragments such as `options: Options<Pet>` are not whole programs; yuku still tokenizes them.\n const tokens = parse(text, { lang, sourceType: 'module', tokens: true }).tokens!\n\n // `TokenList` is indexed, not iterable; a plain array also makes the neighbours of a token `undefined` at the ends.\n const kinds = Array.from({ length: tokens.length }, (_, i) => tokens.kind(i))\n\n let out = ''\n let last = 0\n\n for (const [i, kind] of kinds.entries()) {\n if (kind !== TokenKind.Identifier || kinds[i - 1] === TokenKind.Dot || kinds[i - 1] === TokenKind.OptionalChaining) continue\n const isKey = kinds[i + 1] === TokenKind.Colon || (kinds[i + 1] === TokenKind.Question && kinds[i + 2] === TokenKind.Colon)\n // `? Name :` in a conditional type is a reference.\n if (isKey && (i === 0 || tokens.newlineBefore(i) || keyStarts.has(kinds[i - 1]!))) continue\n\n const replacement = replace(tokens.text(i))\n if (replacement === undefined) continue\n out += text.slice(last, tokens.start(i)) + replacement\n last = tokens.end(i)\n }\n\n return out + text.slice(last)\n}\n\nfunction createInline(lang: 'ts' | 'tsx'): ast.InlineLanguage {\n return {\n replaceIdentifiers: (text, replace) => replaceIdentifiers(text, replace, lang),\n wrap: (expression) => (/^[\\w$.]+$/.test(expression) ? expression : `(${expression})`),\n }\n}\n\n/**\n * Inline support for TypeScript and JavaScript files: identifiers are found with {@link replaceIdentifiers},\n * and a definition that is more than a name or a dotted path goes in parentheses.\n */\nexport const inlineTs = createInline('ts')\n\n/**\n * {@link inlineTs} for `.tsx` and `.jsx` files, where JSX text and attribute names are not identifiers.\n */\nexport const inlineTsx = createInline('tsx')\n","/**\n * Indents every non-empty line of `text` by `unit`, leaving blank lines empty.\n * @example\n * `indent({ text: 'a\\n\\nb' }) // ' a\\n\\n b'`\n */\nexport function indent({ text, unit = ' ' }: { text: string; unit?: string }): string {\n if (!text) return ''\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${unit}${line}` : ''))\n .join('\\n')\n}\n\n/**\n * Strips the common leading whitespace and the surrounding blank lines, counting tabs and spaces alike, so indented template literals start at column zero.\n */\nexport function dedent(text: string): string {\n if (!text) return ''\n // Most text nodes are one line, so the common indent is its leading whitespace.\n if (!text.includes('\\n')) return text.trim() ? text.trimStart() : ''\n\n const lines = text.split('\\n')\n const indents = lines.map((line) => {\n const indent = line.length - line.trimStart().length\n return indent === line.length ? -1 : indent\n })\n const start = indents.findIndex((indent) => indent !== -1)\n if (start === -1) return ''\n const end = indents.findLastIndex((indent) => indent !== -1)\n // `-1` marks a blank line. `reduce`, not `Math.min(...indents)`, which overflows the stack on very long text.\n const min = indents.reduce((lowest, indent) => (indent !== -1 && indent < lowest ? indent : lowest), Infinity)\n\n return lines\n .slice(start, end + 1)\n .map((line, i) => (indents[start + i] === -1 ? '' : line.slice(min)))\n .join('\\n')\n}\n\n/**\n * Strips one matching pair of `\"`, `'` or `` ` `` from both ends of `text`. Returns `text` unchanged without a matching pair.\n * @example\n * `unquote('\"hello\"') // 'hello'`\n */\nexport function unquote(text: string): string {\n if (text.length < 2) return text\n const first = text[0]\n return (first === '\"' || first === \"'\" || first === '`') && text.at(-1) === first ? text.slice(1, -1) : text\n}\n\n/**\n * Returns `name` when it is free, otherwise the first free `name2`, `name3`, and so on.\n * @example\n * `uniqueName('Options', (name) => name === 'Options') // 'Options2'`\n */\nexport function uniqueName(name: string, isTaken: (candidate: string) => boolean): string {\n let candidate = name\n for (let suffix = 2; isTaken(candidate); suffix++) candidate = `${name}${suffix}`\n return candidate\n}\n","import { dedent, indent } from '@internals/utils'\nimport { createRequire } from 'node:module'\nimport { dirname, extname as getExtname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { ast } from '@kubb/ast'\nimport { type ImportSpecifier, type ModuleExportName, parse, type ProgramStatement } from 'yuku'\n\n/**\n * A TypeScript compiler node, typed structurally so `@kubb/parser-ts` does not depend on `@typescript/typescript6`.\n *\n * @deprecated Pass printed strings to `print` instead. Removed in Kubb v6.\n */\nexport type TsNode = { readonly kind: number }\n\ntype Compiler = {\n printNodes: (nodes: Array<TsNode>) => string\n}\n\nlet compiler: Compiler | undefined\n\n// The parts of the TypeScript 6 API that printing compiler nodes uses, typed here so no package depends on it\ntype TypeScript = {\n createPrinter(options: { omitTrailingSemicolon: boolean; newLine: number; removeComments: boolean; noEmitHelpers: boolean }): {\n printList(format: number, list: unknown, sourceFile: unknown): string\n }\n createSourceFile(fileName: string, text: string, target: number, setParentNodes: boolean, kind: number): unknown\n factory: { createNodeArray(nodes: Array<TsNode>): unknown }\n NewLineKind: { LineFeed: number }\n ScriptTarget: { ES2022: number }\n ScriptKind: { TSX: number }\n ListFormat: { MultiLine: number }\n}\n\n/**\n * Loads TypeScript the first time `print` gets a compiler node. Strings never need it, so bundles for edge runtimes such as Cloudflare Workers leave it out.\n *\n * Loaded with `require`, not `import`: when ESM imports a CommonJS package, Node keeps a second copy of its source\n * to detect named exports, and for TypeScript that copy is about 9 MB.\n */\nfunction loadCompiler(): Compiler {\n if (compiler) return compiler\n\n process.emitWarning(\n 'Printing TypeScript compiler nodes with `print` from `@kubb/parser-ts` is deprecated and is removed in the next major. Return printed strings from printer handlers instead.',\n { type: 'DeprecationWarning', code: 'KUBB_PRINT_TS_NODE' },\n )\n\n const requireModule = createRequire(import.meta.url)\n // Look in the user's project first: a strict package manager such as pnpm does not link it next to this package\n const paths = [process.cwd(), dirname(fileURLToPath(import.meta.url))]\n let typescript: TypeScript | undefined\n // `typescript` 5 and 6 ship the compiler API; next to TypeScript 7 it comes from `@typescript/typescript6`\n for (const name of ['typescript', '@typescript/typescript6']) {\n try {\n const candidate = requireModule(requireModule.resolve(name, { paths }))\n if (typeof candidate.createPrinter === 'function') {\n typescript = candidate as TypeScript\n break\n }\n } catch {}\n }\n if (!typescript) {\n throw new Error(\n '`print` received a TypeScript compiler node, which needs `typescript` 5 or 6, or `@typescript/typescript6`, installed. Pass a printed string instead.',\n )\n }\n\n // One printer serves every call; printing does not mutate the source file, which only lends its compiler options\n const printer = typescript.createPrinter({\n omitTrailingSemicolon: true,\n newLine: typescript.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n const sourceFile = typescript.createSourceFile('print.tsx', '', typescript.ScriptTarget.ES2022, true, typescript.ScriptKind.TSX)\n\n compiler = {\n printNodes: (nodes) => printer.printList(typescript.ListFormat.MultiLine, typescript.factory.createNodeArray(nodes), sourceFile),\n }\n\n return compiler\n}\n\n/**\n * Swaps the extension of a relative import/export path for `extname`. Package specifiers and extension-less paths stay as-is.\n */\nexport function resolveOutputPath(path: string, extname: string | undefined, rootAware: boolean): string {\n if (!rootAware) return path\n const current = getExtname(path)\n return current ? `${path.slice(0, -current.length)}${extname ?? ''}` : path\n}\n\n/**\n * Node types this module reads from the yuku AST.\n */\nconst nodeTypes = {\n identifier: 'Identifier',\n literal: 'Literal',\n importDeclaration: 'ImportDeclaration',\n importSpecifier: 'ImportSpecifier',\n importDefaultSpecifier: 'ImportDefaultSpecifier',\n importNamespaceSpecifier: 'ImportNamespaceSpecifier',\n exportAllDeclaration: 'ExportAllDeclaration',\n exportNamedDeclaration: 'ExportNamedDeclaration',\n} as const\n\n/**\n * `importKind` and `exportKind` values this module reads from the yuku AST.\n */\nconst declarationKinds = {\n type: 'type',\n} as const\n\nfunction nameOf(node: ModuleExportName): string {\n return node.type === nodeTypes.literal ? node.value : node.name\n}\n\n/**\n * Converts an import specifier into a module name, keeping the quotes of a string-literal name (`{ 'a-b' as ab }`).\n */\nfunction toModuleName({ imported, local }: ImportSpecifier): ast.ModuleName {\n if (imported.type === nodeTypes.identifier && imported.name === local.name) return { name: local.name }\n\n return { name: imported.type === nodeTypes.literal ? quoteModulePath(imported.value) : imported.name, alias: local.name }\n}\n\n/**\n * Converts an `import` declaration into `ImportNode`s. Side-effect imports and imports with attributes or a phase stay as written.\n */\nfunction toImportNodes(statement: ProgramStatement, filePath: string): Array<ast.ImportNode> {\n if (statement.type !== nodeTypes.importDeclaration || !statement.specifiers.length || statement.attributes.length || statement.phase) return []\n\n const specifier = statement.source.value\n const target = specifier.startsWith('.') ? { path: resolve(dirname(filePath), specifier), root: filePath } : { path: specifier }\n const space: ast.Space = statement.importKind === declarationKinds.type ? 'type' : 'value'\n const names = statement.specifiers.map((element): ast.ModuleName => {\n if (element.type === nodeTypes.importDefaultSpecifier) return { name: 'default', alias: element.local.name, space }\n if (element.type === nodeTypes.importNamespaceSpecifier) return { name: '*', alias: element.local.name, space }\n return { ...toModuleName(element), space: element.importKind === declarationKinds.type ? 'type' : space }\n })\n\n return [ast.factory.createImport({ ...target, names })]\n}\n\n/**\n * Converts an `export … from` declaration into `ExportNode`s. Forms `printExport` cannot print stay as written.\n */\nfunction toExportNodes(statement: ProgramStatement): Array<ast.ExportNode> {\n if (statement.type !== nodeTypes.exportAllDeclaration && statement.type !== nodeTypes.exportNamedDeclaration) return []\n if (!statement.source || statement.attributes.length) return []\n\n const path = statement.source.value\n const space: ast.Space = statement.exportKind === declarationKinds.type ? 'type' : 'value'\n\n if (statement.type === nodeTypes.exportAllDeclaration) {\n return [ast.factory.createExport({ path, names: [{ name: '*', ...(statement.exported ? { alias: nameOf(statement.exported) } : {}), space }] })]\n }\n if (\n statement.specifiers.some(\n (element) =>\n element.exportKind === declarationKinds.type || element.exported.type === nodeTypes.literal || nameOf(element.exported) !== nameOf(element.local),\n )\n )\n return []\n\n return [ast.factory.createExport({ path, names: statement.specifiers.map((element) => ({ name: nameOf(element.local), space })) })]\n}\n\n/**\n * Splits `source` into its lifted `import`/`export … from` nodes, the `header` above the first one (shebang, directives, comments) and the rest as `body`.\n */\nexport function splitModuleDeclarations(\n source: string,\n filePath: string,\n): { header: string; imports: Array<ast.ImportNode>; exports: Array<ast.ExportNode>; body: string } {\n const { program } = parse(source, { lang: 'ts', sourceType: 'module' })\n const imports: Array<ast.ImportNode> = []\n const exports: Array<ast.ExportNode> = []\n let header = ''\n let body = ''\n let cursor = 0\n\n for (const statement of program.body) {\n const importNodes = toImportNodes(statement, filePath)\n const exportNodes = toExportNodes(statement)\n if (!importNodes.length && !exportNodes.length) {\n // Lifted declarations print above the body, so stop at the first one that stays in place to keep the evaluation order.\n if (\n statement.type === nodeTypes.importDeclaration ||\n ((statement.type === nodeTypes.exportNamedDeclaration || statement.type === nodeTypes.exportAllDeclaration) && statement.source)\n )\n break\n continue\n }\n\n const text = source.slice(cursor, statement.start)\n if (imports.length || exports.length) body += text\n else header = text\n imports.push(...importNodes)\n exports.push(...exportNodes)\n cursor = statement.end\n }\n\n return { header: header.trim(), imports, exports, body: `${body}${source.slice(cursor)}`.trim() }\n}\n\n/**\n * Joins the printed `nodes` with `separator`; a `Break` widens the next separator to a blank line, and leading, trailing and repeated breaks fold into one.\n *\n * Imperative on purpose: this runs once per source fragment and `map().filter().join()` showed up in deopt traces.\n */\nfunction printNodes({ nodes, separator }: { nodes: Array<ast.CodeNode> | undefined; separator: '\\n' | '\\n\\n' }): string {\n let result = ''\n let pendingBreak = false\n\n for (const node of nodes ?? []) {\n if (node.kind === ast.node.kinds.break) {\n pendingBreak = result !== ''\n continue\n }\n\n const text = printCodeNode(node)\n if (!text) continue\n\n if (result) result += pendingBreak ? '\\n\\n' : separator\n result += text\n pendingBreak = false\n }\n\n return result\n}\n\n/**\n * Renders `<T>(params): ReturnType`; an async function wraps its return type in `Promise<>`.\n */\nfunction signature({ async: isAsync, generics, params, returnType }: Pick<ast.FunctionNode, 'async' | 'generics' | 'params' | 'returnType'>): string {\n const genericsStr = generics ? `<${Array.isArray(generics) ? generics.join(', ') : generics}>` : ''\n const wrapped = isAsync ? `Promise<${returnType}>` : returnType\n const returnTypeStr = returnType ? `: ${wrapped}` : ''\n\n return `${genericsStr}(${params ?? ''})${returnTypeStr}`\n}\n\n/**\n * Puts the JSDoc block, when it renders to something, above `declaration`.\n */\nfunction withJSDoc({ jsDoc, declaration }: { jsDoc?: ast.JSDocNode | null; declaration: string }): string {\n const jsDocStr = jsDoc ? printJSDoc(jsDoc) : ''\n\n return jsDocStr ? `${jsDocStr}\\n${declaration}` : declaration\n}\n\n/**\n * Joins printed code fragments with a newline.\n *\n * Passing TypeScript compiler nodes still works but is deprecated and needs `typescript` 5 or 6, or `@typescript/typescript6`, installed.\n * Support for compiler nodes is removed in the next major.\n */\nexport function print(...elements: Array<string | TsNode>): string {\n const filtered = elements.filter(Boolean)\n if (filtered.length === 0) return ''\n if (filtered.every((element) => typeof element === 'string')) return filtered.join('\\n')\n // Printing compiler nodes as one list keeps the output byte-for-byte the same as before strings were accepted\n if (filtered.every((element) => typeof element !== 'string')) return loadCompiler().printNodes(filtered)\n\n return filtered.map((element) => (typeof element === 'string' ? element : loadCompiler().printNodes([element]).trimEnd())).join('\\n')\n}\n\n/**\n * Converts a {@link ast.JSDocNode} to a `/** … *\\/` block, dropping blank comments.\n */\nfunction printJSDoc(jsDoc: ast.JSDocNode): string {\n const comments = (jsDoc.comments ?? []).filter((c) => c != null)\n if (comments.length === 0) return ''\n\n const lines = comments\n .flatMap((c) => c.split(/\\r?\\n/))\n .map((l) => l.replace(/\\*\\//g, '* /').replace(/\\r/g, ''))\n .filter((l) => l.trim().length > 0)\n\n if (lines.length === 0) return ''\n\n return ['/**', ...lines.map((l) => ` * ${l}`), ' */'].join('\\n')\n}\n\n/**\n * Converts a {@link ast.ConstNode} to a `const` declaration, mirroring the `Const` component from `@kubb/renderer-jsx`.\n */\nfunction printConst(node: ast.ConstNode): string {\n const { name, export: canExport, type, JSDoc, asConst, nodes } = node\n\n const declaration = `${canExport ? 'export ' : ''}const ${name}${type ? `: ${type}` : ''} = ${printNodes({ nodes, separator: '\\n' })}${asConst ? ' as const' : ''}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Converts a {@link ast.TypeNode} to a `type` alias or an `interface`, mirroring the `Type` component from `@kubb/renderer-jsx`.\n */\nfunction printType(node: ast.TypeNode): string {\n const { name, export: canExport, syntax, JSDoc, nodes } = node\n const body = printNodes({ nodes, separator: '\\n' })\n\n const declaration = `${canExport ? 'export ' : ''}${syntax === 'interface' ? `interface ${name} ${body}` : `type ${name} = ${body}`}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Converts a {@link ast.FunctionNode} to a `function` declaration, mirroring the `Function` component from `@kubb/renderer-jsx`.\n */\nfunction printFunction(node: ast.FunctionNode): string {\n const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc, nodes } = node\n\n const body = indent({ text: printNodes({ nodes, separator: '\\n' }) })\n const prefix = `${canExport ? 'export ' : ''}${isDefault ? 'default ' : ''}${isAsync ? 'async ' : ''}`\n const declaration = `${prefix}function ${name}${signature({ async: isAsync, generics, params, returnType })} {${body ? `\\n${body}\\n` : ''}}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Converts an {@link ast.ArrowFunctionNode} to a `const` arrow function, mirroring the `Function.Arrow` component from `@kubb/renderer-jsx`.\n */\nfunction printArrowFunction(node: ast.ArrowFunctionNode): string {\n const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc, nodes, singleLine } = node\n\n const body = printNodes({ nodes, separator: '\\n' })\n const arrowBody = singleLine ? ` => ${body}` : body ? ` => {\\n${indent({ text: body })}\\n}` : ' => {}'\n const prefix = `${canExport ? 'export ' : ''}${isDefault ? 'default ' : ''}`\n const declaration = `${prefix}const ${name} = ${isAsync ? 'async ' : ''}${signature({ async: isAsync, generics, params, returnType })}${arrowBody}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Dispatches a {@link ast.CodeNode} to the printer for its `kind`.\n */\nfunction printCodeNode(node: ast.CodeNode): string {\n switch (node.kind) {\n case ast.node.kinds.break:\n return ''\n case ast.node.kinds.text:\n case ast.node.kinds.jsx:\n return dedent(node.value)\n case ast.node.kinds.const:\n return printConst(node)\n case ast.node.kinds.type:\n return printType(node)\n case ast.node.kinds.function:\n return printFunction(node)\n case ast.node.kinds.arrowFunction:\n return printArrowFunction(node)\n }\n}\n\n/**\n * Prints a {@link ast.SourceNode} with a blank line between its top-level nodes.\n */\nexport function printSource(node: ast.SourceNode): string {\n return printNodes({ nodes: node.nodes, separator: '\\n\\n' })\n}\n\n/**\n * Wraps a module specifier in single quotes, escaping embedded backslashes and quotes.\n */\nfunction quoteModulePath(path: string): string {\n return `'${path.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`\n}\n\n// `{ a, b as c }`, with `type` before the braces when every name is a type, else before each type name.\nfunction printNamed(names: ReadonlyArray<ast.ModuleName>): string {\n const allTypes = names.every((item) => item.space === 'type')\n const specifiers = names.map((item) => `${!allTypes && item.space === 'type' ? 'type ' : ''}${item.alias ? `${item.name} as ${item.alias}` : item.name}`)\n return `${allTypes ? 'type ' : ''}{ ${specifiers.join(', ')} }`\n}\n\n/**\n * Renders the `import` declarations for `names`: one per default or `* as` name, and one for the named members.\n * `path` is used verbatim, so resolve it first.\n */\nexport function printImport({ names, path }: { names: ReadonlyArray<ast.ModuleName>; path: string }): string {\n const from = quoteModulePath(path)\n const lines: Array<string> = []\n const named: Array<ast.ModuleName> = []\n for (const item of names) {\n const type = item.space === 'type' ? 'type ' : ''\n if (item.alias && item.name === '*') lines.push(`import ${type}* as ${item.alias} from ${from}`)\n else if (item.alias && item.name === 'default') lines.push(`import ${type}${item.alias} from ${from}`)\n // Without a local name, a default or whole-module import binds nothing, and `{ default }` does not parse.\n else if (item.name !== '*' && item.name !== 'default') named.push(item)\n }\n if (named.length) lines.push(`import ${printNamed(named)} from ${from}`)\n return lines.join('\\n')\n}\n\n/**\n * Renders the `export … from` declarations for `names`: one per `*` name, as `export *` or `export * as`, and one\n * for the named members. `path` is used verbatim, so resolve it first.\n */\nexport function printExport({ names, path }: { names: ReadonlyArray<ast.ModuleName>; path: string }): string {\n const from = quoteModulePath(path)\n const lines = names\n .filter((item) => item.name === '*')\n .map((item) => {\n // An identifier cannot start with a digit, so prefix `_` and keep the digit\n const alias = item.alias && (/^\\d/.test(item.alias) ? `_${item.alias}` : item.alias)\n return `export ${item.space === 'type' ? 'type ' : ''}* ${alias ? `as ${alias} ` : ''}from ${from}`\n })\n const named = names.filter((item) => item.name !== '*')\n if (named.length) lines.push(`export ${printNamed(named)} from ${from}`)\n return lines.join('\\n')\n}\n","import { ast } from '@kubb/ast'\nimport { defineExtension } from '@kubb/core'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { inlineTs } from './inline.ts'\nimport { print, printExport, printImport, printSource, resolveOutputPath, splitModuleDeclarations, type TsNode } from './utils.ts'\n\nconst DEFAULT_EXTENSION: Record<ast.FileNode['extname'], ast.FileNode['extname'] | ''> = { '.ts': '' }\n\n/**\n * Options accepted by `parserTs` and `parserTsx`.\n */\nexport type ParserTsOptions = {\n /**\n * Rewrite extensions on relative `import`/`export` statements. Each key is the extension of a\n * generated file, and its value is the extension written on the relative specifiers in that\n * file. `''` drops it, and so does a generated file whose extension has no key. Package\n * specifiers stay unchanged. Also applies to relative paths in `copy` templates.\n *\n * Use `{ '.ts': '.js' }` for ESM output compiled to JavaScript, or `{ '.ts': '.ts' }` to run the\n * `.ts` files directly in Node.js or compile them with `rewriteRelativeImportExtensions`.\n *\n * @default { '.ts': '' }\n * @example\n * ```ts\n * parserTs({ extension: { '.ts': '.js' } }) // import './api.js' instead of './api'\n * parserTs({ extension: { '.ts': '.ts' } }) // import './api.ts' instead of './api'\n * ```\n */\n extension?: Record<ast.FileNode['extname'], ast.FileNode['extname'] | ''>\n}\n\n/**\n * Default Kubb parser for `.ts` and `.js` files. Takes the universal AST\n * produced by an adapter and prints it as TypeScript source. Imports and exports\n * are rewritten based on each file's metadata and the `extension` option.\n *\n * Used automatically when no `parsers` option is set on `defineConfig`. Use\n * `parserTsx` instead for React projects that emit JSX.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { adapterOas } from '@kubb/adapter-oas'\n * import { parserTs } from '@kubb/parser-ts'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * adapter: adapterOas(),\n * parsers: [parserTs()],\n * plugins: [],\n * })\n * ```\n */\nexport const parserTs = defineExtension<ParserTsOptions, object, string | TsNode>({\n kind: 'parser',\n meta: { name: 'typescript', version, compatibility, issues: 'https://github.com/kubb-labs/kubb/issues' },\n build({ extension = DEFAULT_EXTENSION }) {\n return {\n extNames: ['.ts', '.js'],\n print,\n inline: inlineTs,\n parse(file) {\n const extname = extension[file.extname] || undefined\n\n const source = file.sources\n .map((item) => printSource(item))\n .filter(Boolean)\n .map((text) => text.trimEnd())\n .join('\\n\\n')\n\n const importLines = file.imports.map((item) =>\n printImport({\n names: ast.file.getNames(item),\n path: resolveOutputPath(item.root ? ast.file.getRelativePath(item.root, item.path) : item.path, extname, Boolean(item.root)),\n }),\n )\n\n const exportLines = file.exports.map((item) =>\n printExport({ names: ast.file.getNames(item), path: resolveOutputPath(item.path, extname, item.path.startsWith('.')) }),\n )\n\n const importExportBlock = [...importLines, ...exportLines].join('\\n')\n\n const parts = [file.banner, importExportBlock, source, file.footer].filter((segment): segment is string => Boolean(segment)).map((s) => s.trimEnd())\n\n return parts.join('\\n\\n')\n },\n copy(file, source) {\n const { header, imports, exports, body } = splitModuleDeclarations(source, file.path)\n\n return {\n ...file,\n banner: [header, file.banner].filter(Boolean).join('\\n') || undefined,\n imports: [...file.imports, ...imports],\n exports: [...file.exports, ...exports],\n sources: [ast.factory.createSource({ nodes: [ast.factory.createText(body)] })],\n }\n },\n }\n },\n})\n","import { defineExtension } from '@kubb/core'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { inlineTsx } from './inline.ts'\nimport { parserTs, type ParserTsOptions } from './parserTs.ts'\nimport type { TsNode } from './utils.ts'\n\n/**\n * Kubb parser for `.tsx` and `.jsx` files. Delegates to `parserTs`, since JSX\n * prints as text the same way, so it shares the same `extension` option.\n *\n * Add to the `parsers` array on `defineConfig` when generating components for\n * React (or any framework that emits JSX).\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { adapterOas } from '@kubb/adapter-oas'\n * import { parserTsx } from '@kubb/parser-ts'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * adapter: adapterOas(),\n * parsers: [parserTsx()],\n * plugins: [],\n * })\n * ```\n */\nexport const parserTsx = defineExtension<ParserTsOptions, object, string | TsNode>({\n kind: 'parser',\n meta: { name: 'tsx', version, compatibility, issues: 'https://github.com/kubb-labs/kubb/issues' },\n build: (options) => ({ ...parserTs(options), extNames: ['.tsx', '.jsx'], inline: inlineTsx }),\n})\n"],"mappings":";;;;;;;;;;;;;;AEIA,MAAM,4BAAY,IAAI,IAAY;CAAC,UAAU;CAAW,UAAU;CAAO,UAAU;CAAW,UAAU;AAAS,CAAC;;;;;AAMlH,SAAgB,mBAAmB,MAAc,SAA+C,OAAqB,MAAc;CAEjI,MAAM,SAAS,MAAM,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AC5D,SAAS,CAAC,GAAG,KAAK,SAAS,GAAG,OAAO;KACrC,SAAS,CAAC,GAAG,KAAK,SAAS,GAAG,OAAO;KACrC,SAAS,CAAC,IAAI,QAAQ,aAAa,EAAE,OAAO,CAAC,IAAI,QAAQ,WAAW,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E;GACF;EACF;CACF;AACF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;ACzED,MAAa,YAAY,gBAA0D;CACjF,MAAM;CACN,MAAM;EAAE,MAAM;EAAO;EAAS;EAAe,QAAQ;CAA2C;CAChG,QAAQ,aAAa;EAAE,GAAG,SAAS,OAAO;EAAG,UAAU,CAAC,QAAQ,MAAM;EAAG,QAAQ;CAAU;AAC7F,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["extname","getExtname"],"sources":["../kubb-extension.json","../package.json","../../../internals/utils/src/promise.ts","../../../internals/utils/src/text.ts","../../../internals/utils/src/renamer.ts","../src/inline.ts","../src/definitions.ts","../src/nodeText.ts","../src/fileRewriter.ts","../src/inlineFiles.ts","../src/utils.ts","../src/parserTs.ts","../src/parserTsx.ts"],"sourcesContent":["","","/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\nexport type Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Returns the value cached under `key` in `store`, computing and storing it on the first call.\n * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive\n * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.\n *\n * @example\n * `const refs = memo(refCache, node, () => collectRefs(node))`\n */\nexport function memo<TKey, TValue>(store: Store<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n const cached = store.get(key)\n if (cached !== undefined || store.has(key)) return cached as TValue\n const value = compute()\n store.set(key, value)\n return value\n}\n\nclass BoundedStore<TKey, TValue> implements Store<TKey, TValue> {\n readonly #entry = new Map<TKey, TValue>()\n readonly #max: number\n\n constructor(max: number) {\n this.#max = max\n }\n\n has(key: TKey): boolean {\n return this.#entry.has(key)\n }\n\n get(key: TKey): TValue | undefined {\n return this.#entry.get(key)\n }\n\n set(key: TKey, value: TValue): void {\n if (this.#entry.size >= this.#max) this.#entry.clear()\n this.#entry.set(key, value)\n }\n}\n\nclass LastEntryStore<TKey, TValue> extends BoundedStore<TKey, TValue> {\n constructor() {\n super(1)\n }\n\n // A key equal to the stored one but a different object, such as a copy of a string, replaces the\n // stored key, so the next lookup is an identity hit instead of a full comparison.\n #touch(key: TKey): boolean {\n if (!super.has(key)) return false\n this.set(key, super.get(key) as TValue)\n return true\n }\n\n override has(key: TKey): boolean {\n return this.#touch(key)\n }\n\n override get(key: TKey): TValue | undefined {\n return this.#touch(key) ? super.get(key) : undefined\n }\n}\n\n/**\n * Creates a store for `memo`. With no options it is a `Map`. Each option changes one thing:\n *\n * - `weak` holds the keys weakly, in a `WeakMap`, so an entry goes away with its key.\n * - `max` bounds the store: it empties itself before the entry that would pass `max`, which keeps a\n * cache in a long-running process from growing without end. `max: 1` keeps only the last entry.\n *\n * @example\n * `const patterns = memo.create<string, RegExp>()`\n *\n * @example Freed with its key\n * `const refs = memo.create<SchemaNode, Array<string>>({ weak: true })`\n *\n * @example Bounded\n * `const names = memo.create<string, string>({ max: 100_000 })`\n *\n * @example Many values per key\n * ```ts\n * const filesByPlugin = memo.create<string, Array<string>>()\n * memo(filesByPlugin, 'plugin-ts', () => []).push('models.ts')\n * ```\n */\nfunction createStore<TKey, TValue>(options?: { weak?: false; max?: undefined }): Map<TKey, TValue>\nfunction createStore<TKey extends WeakKey, TValue>(options: { weak: true; max?: undefined }): WeakMap<TKey, TValue>\nfunction createStore<TKey, TValue>(options: { max: number; weak?: false }): Store<TKey, TValue>\nfunction createStore<TKey, TValue>({ weak, max }: { weak?: boolean; max?: number } = {}): Store<TKey, TValue> {\n if (weak) return new WeakMap<WeakKey, TValue>() as Store<TKey, TValue>\n if (max === undefined) return new Map<TKey, TValue>()\n if (max !== 1) return new BoundedStore<TKey, TValue>(max)\n return new LastEntryStore<TKey, TValue>()\n}\n\nmemo.create = createStore\n\nexport type InParallelOptions<TItem> = {\n /**\n * Items to work through, handed out in order.\n */\n items: ReadonlyArray<TItem>\n /**\n * How many items may be in flight at once.\n */\n limit: number\n /**\n * Runs once per item, with the item's position so a caller can report progress.\n */\n run(item: TItem, index: number): Promise<void>\n}\n\n/**\n * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each\n * takes the next item the moment it frees up instead of waiting for a batch to drain. The first\n * rejection rejects the call, and the other workers start no new item after it.\n *\n * @example\n * ```ts\n * await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })\n * ```\n */\nexport async function inParallel<TItem>({ items, limit, run }: InParallelOptions<TItem>): Promise<void> {\n const queue = items.entries()\n let failed = false\n\n const worker = async (): Promise<void> => {\n for (const [index, item] of queue) {\n if (failed) return\n await run(item, index).catch((error: unknown) => {\n failed = true\n throw error\n })\n }\n }\n\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()))\n}\n","/**\n * Indents every non-empty line of `text` by `unit`, leaving blank lines empty.\n * @example\n * `indent({ text: 'a\\n\\nb' }) // ' a\\n\\n b'`\n */\nexport function indent({ text, unit = ' ' }: { text: string; unit?: string }): string {\n if (!text) return ''\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${unit}${line}` : ''))\n .join('\\n')\n}\n\n/**\n * Strips the common leading whitespace and the surrounding blank lines, counting tabs and spaces alike, so indented template literals start at column zero.\n */\nexport function dedent(text: string): string {\n if (!text) return ''\n // Most text nodes are one line, so the common indent is its leading whitespace.\n if (!text.includes('\\n')) return text.trim() ? text.trimStart() : ''\n\n const lines = text.split('\\n')\n const indents = lines.map((line) => {\n const indent = line.length - line.trimStart().length\n return indent === line.length ? -1 : indent\n })\n const start = indents.findIndex((indent) => indent !== -1)\n if (start === -1) return ''\n const end = indents.findLastIndex((indent) => indent !== -1)\n // `-1` marks a blank line. `reduce`, not `Math.min(...indents)`, which overflows the stack on very long text.\n const min = indents.reduce((lowest, indent) => (indent !== -1 && indent < lowest ? indent : lowest), Infinity)\n\n return lines\n .slice(start, end + 1)\n .map((line, i) => (indents[start + i] === -1 ? '' : line.slice(min)))\n .join('\\n')\n}\n\n/**\n * Strips one matching pair of `\"`, `'` or `` ` `` from both ends of `text`. Returns `text` unchanged without a matching pair.\n * @example\n * `unquote('\"hello\"') // 'hello'`\n */\nexport function unquote(text: string): string {\n if (text.length < 2) return text\n const first = text[0]\n return (first === '\"' || first === \"'\" || first === '`') && text.at(-1) === first ? text.slice(1, -1) : text\n}\n\n/**\n * Returns `name` when it is free, otherwise the first free `name2`, `name3`, and so on.\n * @example\n * `uniqueName('Options', (name) => name === 'Options') // 'Options2'`\n */\nexport function uniqueName(name: string, isTaken: (candidate: string) => boolean): string {\n let candidate = name\n for (let suffix = 2; isTaken(candidate); suffix++) candidate = `${name}${suffix}`\n return candidate\n}\n","import { uniqueName } from './text.ts'\n\n/**\n * The names one candidate claims: the candidate itself by default, or several, such as an enum's value and its type.\n */\nexport type RenamerEmits = (candidate: string) => string | ReadonlyArray<string>\n\nexport type RenamerAssignOptions = {\n /**\n * The name to start from. A number is added when it is taken, as in `Options2`.\n */\n name: string\n /**\n * Who claims the name. The same owner may take a name it already holds. Leave it out to always take a free name.\n */\n owner?: string\n /**\n * The names a candidate claims. All of them must be free.\n */\n emits?: RenamerEmits\n}\n\n// The owner of a reserved name, such as a global, which nobody can take.\nconst reserved = Symbol('reserved')\n\n/**\n * Hands out names that do not clash, adding 2, 3 and so on when a name is taken, and remembers which owner holds each.\n *\n * @example\n * ```ts\n * const renamer = createRenamer()\n * renamer.reserve({ name: 'Response' }) // a global the file uses\n * renamer.assign({ name: 'Response' }) // 'Response2'\n * ```\n *\n * @example\n * ```ts\n * const renamer = createRenamer()\n * renamer.bind({ name: 'Options', owner: '@kubb/client' })\n * renamer.assign({ name: 'Options', owner: '@kubb/client' }) // 'Options', the same owner\n * renamer.assign({ name: 'Options', owner: './models.ts' }) // 'Options2'\n * ```\n */\nexport class Renamer {\n readonly #owners = new Map<string, string | symbol>()\n\n /**\n * Keeps `name` from being assigned, unless something already holds it.\n */\n reserve({ name }: { name: string }): void {\n if (!this.#owners.has(name)) this.#owners.set(name, reserved)\n }\n\n /**\n * Gives `name` to `owner` as it is, such as a name a file already imports.\n */\n bind({ name, owner }: { name: string; owner: string }): void {\n this.#owners.set(name, owner)\n }\n\n /**\n * Returns the first free name from `name`, and claims every name it emits for `owner`.\n */\n assign({ name, owner, emits = (candidate) => candidate }: RenamerAssignOptions): string {\n const holder = owner ?? Symbol(name)\n // `emits` may be costly, such as casing an enum's names, so each candidate is read once.\n const read = new Map<string, ReadonlyArray<string>>()\n const claimed = (candidate: string): ReadonlyArray<string> => {\n const known = read.get(candidate)\n if (known) return known\n const names = emits(candidate)\n const list = typeof names === 'string' ? [names] : names\n read.set(candidate, list)\n return list\n }\n const isTaken = (candidate: string) => claimed(candidate).some((emitted) => this.#owners.has(emitted) && this.#owners.get(emitted) !== holder)\n const local = uniqueName(name, isTaken)\n for (const emitted of claimed(local)) this.#owners.set(emitted, holder)\n return local\n }\n}\n\n/**\n * Creates an empty renamer.\n */\nexport function createRenamer(): Renamer {\n return new Renamer()\n}\n","import { memo } from '@internals/utils'\nimport type { InlineTextKind } from './nodeText.ts'\nimport { parse } from 'yuku'\n\nexport type Lang = 'ts' | 'tsx'\n\n// A name in the text that refers to something declared outside it, by its offsets in the text.\n// `shorthand` is `{ x }`, and `exported` is `export { x }`, where a new name has to keep the old one as the key or export name.\ntype Reference = { name: string; start: number; end: number; shorthand: boolean; exported: boolean }\n// What one read of a fragment keeps: its free references and every name it declares or uses.\ntype Analysis = { references: Array<Reference>; names: Array<string> }\n\n// The name of the declaration a fragment is wrapped in. It is left out of the names the fragment uses.\nconst placeholder = '__kubb'\n\n// A fragment such as `options: Options<Pet>` or `{ body: Pet }` is not a program, so it is parsed inside the code its kind\n// stands for. The prefix length is subtracted from every offset, and each wrapper closes on its own line so a trailing `//`\n// comment cannot swallow it.\nconst contexts: Record<InlineTextKind, [before: string, after: string]> = {\n code: ['', ''],\n type: [`type ${placeholder} = `, ''],\n value: [`const ${placeholder} = (`, '\\n)'],\n parameters: [`function ${placeholder}(`, '\\n) {}'],\n typeParameters: [`function ${placeholder}<`, '\\n>() {}'],\n}\nconst kinds = Object.keys(contexts) as Array<InlineTextKind>\n\n// The same fragment is read several times while one file is inlined.\nconst analyses = memo.create<string, Analysis>({ max: 1000 })\n\n// Reads `text` as `kind`, or, when that fails or no kind is given, as the first kind it parses as without errors.\nfunction analyze(text: string, lang: Lang, kind: InlineTextKind | undefined): Analysis {\n return memo(analyses, `${lang}\\0${kind ?? ''}\\0${text}`, () => {\n const first = kind ?? 'code'\n const fallback = parseAs(text, lang, first)\n if (fallback.clean) return fallback.analysis\n for (const candidate of kinds.filter((item) => item !== first)) {\n const parsed = parseAs(text, lang, candidate)\n if (parsed.clean) return parsed.analysis\n }\n return fallback.analysis\n })\n}\n\nfunction parseAs(text: string, lang: Lang, kind: InlineTextKind): { analysis: Analysis; clean: boolean } {\n const [before, after] = contexts[kind]\n const file = parse(before + text + after, { lang, sourceType: 'module', analyze: true })\n const references = file.references\n .filter((reference) => !reference.binding && reference.node.type !== 'JSXIdentifier')\n .map((reference): Reference => {\n const parent = file.parentOf(reference.node)\n const shorthand = parent?.type === 'Property' && parent.shorthand\n const exported = parent?.type === 'ExportSpecifier' && parent.exported.start === parent.local.start\n return { name: reference.name, start: reference.node.start - before.length, end: reference.node.end - before.length, shorthand, exported }\n })\n const names = [...file.bindings.map((binding) => binding.name), ...file.references.map((reference) => reference.name)].filter((name) => name !== placeholder)\n return { analysis: { references, names }, clean: !file.diagnostics.some((diagnostic) => diagnostic.severity === 'error') }\n}\n\n/**\n * Calls `replace` for every name in `text` that refers to something declared outside it, and swaps in what it returns.\n * Bound names (parameters, type parameters, locals), keys, members, strings, comments and JSX tag names are left alone. A\n * shorthand property `{ x }` keeps its key, so it becomes `{ x: replacement }`, and `export { x }` keeps its export name.\n */\nexport function replaceIdentifiers(text: string, replace: (name: string) => string | undefined, lang: Lang = 'ts', kind?: InlineTextKind): string {\n let out = ''\n let last = 0\n\n for (const { name, start, end, shorthand, exported } of analyze(text, lang, kind).references) {\n const replacement = replace(name)\n if (replacement === undefined) continue\n out += text.slice(last, start) + (shorthand ? `${name}: ${replacement}` : exported ? `${replacement} as ${name}` : replacement)\n last = end\n }\n\n return out + text.slice(last)\n}\n\n/**\n * The free names in `text`, in order, the same ones `replaceIdentifiers` would offer to replace.\n */\nexport function referencesIn(text: string, lang: Lang, kind: InlineTextKind): Array<string> {\n return analyze(text, lang, kind).references.map((reference) => reference.name)\n}\n\n/**\n * Every name `text` declares or uses, so a declaration added next to it never shadows one.\n */\nexport function namesIn(text: string, lang: Lang, kind: InlineTextKind): Array<string> {\n return analyze(text, lang, kind).names\n}\n\n/**\n * Makes `expression` safe to put where a name was: a name or dotted path stays bare, and anything else goes in parentheses.\n */\nexport function wrap(expression: string): string {\n return /^[\\w$.]+$/.test(expression) ? expression : `(${expression})`\n}\n","import { ast, type ConstNode, type FileNode, type ImportNode, type ModuleName, type SourceNode, type Space, type TypeNode } from '@kubb/ast'\nimport { namesIn, referencesIn, wrap, type Lang } from './inline.ts'\nimport type { InlineTextKind } from './nodeText.ts'\n\n/**\n * A name a virtual file declares. `id` is its module and exported name. `problem` is set when a use of it cannot be inlined.\n */\nexport type Definition = {\n id: string\n name: string\n file: FileNode\n space: Space\n body: string | undefined\n // A body that is only a name or dotted path, such as `Error`, costs less to repeat than to declare.\n isPath: boolean\n constant: ConstNode | undefined\n problem: string | undefined\n}\n\n/**\n * A piece of text in a file, read once: the definition each free name in it resolves to, the imports of its file it uses,\n * and the names nothing in the run declares, such as the fetch `Response`.\n */\nexport type Fragment = {\n file: FileNode\n text: string\n kind: InlineTextKind\n references: Array<Definition | undefined>\n imports: Array<ImportNode>\n unresolved: Array<string>\n}\n\nexport type DefinitionsOptions = {\n // The virtual files of the run, by path.\n virtual: ReadonlyMap<string, FileNode>\n lang: Lang\n}\n\n/**\n * Where a name a file binds comes from: the virtual module and the name it exports.\n */\nexport type Binding = { path: string; name: string }\n\n/**\n * Every definition of the virtual files in one run, and the fragments that refer to them. Each is read on first use and\n * kept, because the same virtual bodies are read for every file that imports them.\n *\n * @example\n * ```ts\n * const definitions = createDefinitions({ virtual, lang: 'ts' })\n * definitions.resolve({ file, name: 'AddPetOptions' }) // the definition the name points at, or `undefined`\n * definitions.fragment({ file, text: 'options: AddPetOptions', kind: 'parameters' })\n * ```\n */\nexport class Definitions {\n readonly lang: Lang\n readonly #virtual: ReadonlyMap<string, FileNode>\n readonly #bindings = new WeakMap<FileNode, Map<string, Binding>>()\n readonly #definitions = new Map<string, Definition>()\n readonly #fragments = new Map<string, Fragment>()\n\n constructor({ virtual, lang }: DefinitionsOptions) {\n this.#virtual = virtual\n this.lang = lang\n }\n\n isVirtual(path: string): boolean {\n return this.#virtual.has(path)\n }\n\n /**\n * The virtual definition `name` points at in `file`, or `undefined` when it points at nothing virtual.\n */\n resolve({ file, name }: { file: FileNode; name: string }): Definition | undefined {\n const binding = this.#bindingsOf(file).get(name)\n return binding && this.#definitionOf(binding)\n }\n\n fragment({ file, text, kind }: { file: FileNode; text: string; kind: InlineTextKind }): Fragment {\n const id = `${file.path}\\0${kind}\\0${text}`\n const known = this.#fragments.get(id)\n if (known) return known\n\n const names = referencesIn(text, this.lang, kind)\n const references = names.map((name) => this.resolve({ file, name }))\n const external = new Set(names.filter((_, index) => !references[index]))\n const fragment: Fragment = {\n file,\n text,\n kind,\n references,\n imports: file.imports.flatMap((imp) => (this.isVirtual(imp.path) ? [] : pickNames({ imp, used: external }))),\n unresolved: namesIn(text, this.lang, kind).filter((name) => !this.resolve({ file, name }) && !importsName({ file, name })),\n }\n this.#fragments.set(id, fragment)\n return fragment\n }\n\n body(definition: Definition): Fragment {\n return this.fragment({ file: definition.file, text: definition.body ?? '', kind: definition.space })\n }\n\n // The names `file` binds to a virtual file. A virtual file's own declarations win over its imports.\n #bindingsOf(file: FileNode): Map<string, Binding> {\n const known = this.#bindings.get(file)\n if (known) return known\n\n const bindings = new Map<string, Binding>()\n for (const imp of file.imports) {\n if (!this.isVirtual(imp.path)) continue\n for (const item of ast.file.getNames(imp)) if (!bindings.has(localName(item))) bindings.set(localName(item), { path: imp.path, name: item.name })\n }\n if (this.isVirtual(file.path)) for (const source of file.sources) if (source.name) bindings.set(source.name, { path: file.path, name: source.name })\n this.#bindings.set(file, bindings)\n return bindings\n }\n\n #definitionOf(binding: Binding): Definition {\n const id = idOf(binding)\n const known = this.#definitions.get(id)\n if (known) return known\n\n const definition = readDefinition({ ...binding, id, file: this.#virtual.get(binding.path)! })\n this.#definitions.set(id, definition)\n return definition\n }\n}\n\n// What the virtual `file` declares under `name`.\nfunction readDefinition({ id, name, path, file }: Binding & { id: string; file: FileNode }): Definition {\n const [source, ...others] = file.sources.filter((item) => item.name === name)\n const node = declarationOf(source)\n const body = bodyOf({ source, node })\n return {\n id,\n name,\n file,\n space: source ? ast.file.getSpace(source) : 'value',\n body,\n isPath: isPath(body),\n constant: node?.kind === ast.node.kinds.const ? node : undefined,\n problem: problemOf({ name, path, body, duplicated: others.length > 0 }),\n }\n}\n\n// The right-hand side of a source: its deprecated `inline` expression, or the text of its `Const` or `Type`. A function\n// body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf({ source, node }: { source: SourceNode | undefined; node: ConstNode | TypeNode | undefined }): string | undefined {\n if (source?.inline) return source.inline.expression\n if (!node) return undefined\n return ast.node.getText(node.nodes) || undefined\n}\n\nfunction isPath(body: string | undefined): boolean {\n if (body === undefined) return false\n const trimmed = body.trim()\n return wrap(trimmed) === trimmed\n}\n\n/**\n * Creates the definition table for the virtual files of one run.\n */\nexport function createDefinitions(options: DefinitionsOptions): Definitions {\n return new Definitions(options)\n}\n\n/**\n * The id of a name in a module: the module's path and the name it exports.\n */\nexport function idOf({ path, name }: Binding): string {\n return `${path}\\0${name}`\n}\n\n/**\n * The name an import entry binds in its file: its alias, or else its name.\n */\nexport function localName(item: ModuleName): string {\n return item.alias ?? item.name\n}\n\nexport function withNames({ imp, names }: { imp: ImportNode; names: Array<ModuleName> }): ImportNode {\n return ast.factory.createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names })\n}\n\n// Why a use of `name` cannot be inlined: it has no body, or more than one declaration.\nfunction problemOf({ name, path, body, duplicated }: Binding & { body: string | undefined; duplicated: boolean }): string | undefined {\n if (body === undefined) return `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.`\n if (duplicated) return `\"${name}\" from \"${path}\" has more than one declaration, so its uses cannot be told apart.`\n return undefined\n}\n\n// The one `Const` or `Type` node a source holds.\nfunction declarationOf(source: SourceNode | undefined): ConstNode | TypeNode | undefined {\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n return node?.kind === ast.node.kinds.const || node?.kind === ast.node.kinds.type ? node : undefined\n}\n\nfunction importsName({ file, name }: { file: FileNode; name: string }): boolean {\n return file.imports.some((imp) => ast.file.getNames(imp).some((item) => localName(item) === name))\n}\n\nfunction pickNames({ imp, used }: { imp: ImportNode; used: ReadonlySet<string> }): Array<ImportNode> {\n const names = ast.file.getNames(imp).filter((item) => used.has(localName(item)))\n return names.length > 0 ? [withNames({ imp, names })] : []\n}\n","import { ast, type CodeNode, type NodeKind } from '@kubb/ast'\n\n/**\n * What a piece of node text holds, so a fragment such as a type or a parameter list is parsed as one.\n */\nexport type InlineTextKind = 'code' | 'type' | 'value' | 'parameters' | 'typeParameters'\n\n// The string fields of each node kind and what they hold. `inherit` is the kind of the text around the node.\nconst TEXT_FIELDS: Partial<Record<NodeKind, Readonly<Record<string, InlineTextKind | 'inherit'>>>> = {\n Text: { value: 'inherit' },\n Jsx: { value: 'inherit' },\n Function: { params: 'parameters', generics: 'typeParameters', returnType: 'type' },\n ArrowFunction: { params: 'parameters', generics: 'typeParameters', returnType: 'type' },\n Const: { type: 'type' },\n}\n\n// What the nested `nodes` of a node hold: a type's body, a constant's value, or code.\nconst NESTED_KIND: Partial<Record<NodeKind, InlineTextKind>> = { Type: 'type', Const: 'value', Function: 'code', ArrowFunction: 'code' }\n\n/**\n * Rewrites every string field of `nodes`, passing what each one holds. JSDoc stays as written.\n */\nexport function rewriteNodes(\n nodes: Array<CodeNode> | undefined,\n rewrite: (text: string, kind: InlineTextKind) => string,\n kind: InlineTextKind = 'code',\n): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node, kind) as unknown as CodeNode\n if (node.kind === ast.node.kinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const [field, fieldKind] of Object.entries(TEXT_FIELDS[node.kind] ?? {})) {\n next[field] = rewriteField(next[field], (text) => rewrite(text, fieldKind === 'inherit' ? kind : fieldKind))\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite, NESTED_KIND[node.kind] ?? kind)\n return next as unknown as CodeNode\n })\n}\n\nfunction rewriteField(value: unknown, rewrite: (text: string) => string): unknown {\n if (Array.isArray(value)) return value.map(rewrite)\n return typeof value === 'string' && value ? rewrite(value) : value\n}\n","import { createRenamer, type Renamer } from '@internals/utils'\nimport { ast, type FileNode, type ImportNode, type SourceNode } from '@kubb/ast'\nimport type { InlineResult } from '@kubb/core'\nimport { idOf, localName, withNames, type Definition, type Definitions, type Fragment } from './definitions.ts'\nimport { namesIn, replaceIdentifiers, wrap } from './inline.ts'\nimport { rewriteNodes } from './nodeText.ts'\n\nexport type RewriteFileOptions = {\n file: FileNode\n definitions: Definitions\n}\n\n// A definition used in `from`, the file whose text is being written.\ntype Use = { from: FileNode; definition: Definition }\n\n// The state of one rewrite: use counts, the names given out, and the declarations and imports added so far.\nclass FileRewriter {\n readonly #file: FileNode\n readonly #definitions: Definitions\n readonly #renamer: Renamer\n readonly #uses = new Map<string, number>()\n // The paths being followed while counting, so a loop between two of them stops.\n readonly #following = new Set<string>()\n // The definitions being written, so a value defined in terms of itself is reported.\n readonly #writing = new Set<string>()\n readonly #locals = new Map<string, string>()\n readonly #declarations: Array<SourceNode> = []\n readonly #carried: Array<ImportNode> = []\n readonly #problems: InlineResult['problems'] = []\n\n constructor({ file, definitions }: RewriteFileOptions) {\n this.#file = file\n this.#definitions = definitions\n this.#renamer = createFileRenamer(file)\n }\n\n rewrite(): { file: FileNode; problems: InlineResult['problems'] } {\n const file = this.#file\n const { lang } = this.#definitions\n for (const source of file.sources) {\n rewriteNodes(source.nodes, (text, kind) => {\n for (const name of namesIn(text, lang, kind)) this.#renamer.reserve({ name })\n this.#count(this.#definitions.fragment({ file, text, kind }))\n return text\n })\n }\n\n const sources = file.sources.map((source) => ({\n ...source,\n nodes: rewriteNodes(source.nodes, (text, kind) => replaceIdentifiers(text, (name) => this.#replacement({ from: file, name }), lang, kind)),\n }))\n // A carried import keeps its target; `root` moves to this file so the relative path is computed from here.\n const carried = this.#carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))\n const imports = [...file.imports.filter((imp) => !this.#definitions.isVirtual(imp.path)), ...carried]\n\n return { file: ast.factory.createFile({ ...file, sources: [...this.#declarations, ...sources], imports }), problems: this.#problems }\n }\n\n // Counts the uses in a fragment and reserves the names nothing declares. A body is counted once, but a path is followed\n // at each use, so the count of what it names stays right.\n #count(fragment: Fragment): void {\n for (const name of fragment.unresolved) this.#renamer.reserve({ name })\n for (const definition of fragment.references) if (definition?.body !== undefined) this.#countUse(definition)\n }\n\n #countUse(definition: Definition): void {\n const { id } = definition\n const seen = this.#uses.get(id) ?? 0\n this.#uses.set(id, seen + 1)\n if (definition.isPath && !this.#following.has(id)) {\n this.#following.add(id)\n this.#count(this.#definitions.body(definition))\n this.#following.delete(id)\n return\n }\n if (seen === 0) this.#count(this.#definitions.body(definition))\n }\n\n // What `name` in `from` is replaced with, or `undefined` to keep it as it is.\n #replacement({ from, name }: { from: FileNode; name: string }): string | undefined {\n const definition = this.#definitions.resolve({ file: from, name })\n const written = definition && this.#write({ from, definition })\n return written === name ? undefined : written\n }\n\n #write({ from, definition }: Use): string | undefined {\n if (definition.problem) return this.#report({ from, message: definition.problem })\n return this.#locals.get(definition.id) ?? this.#writeOnce({ from, definition })\n }\n\n #writeOnce({ from, definition }: Use): string | undefined {\n const declare = this.#declares(definition)\n // A type claims its name before its body is written, so a type that refers to itself can use it. A value cannot.\n const early = declare && definition.space === 'type' ? this.#claim(definition) : undefined\n if (!early && this.#writing.has(definition.id)) {\n return this.#report({ from, message: `\"${definition.name}\" from \"${definition.file.path}\" is defined in terms of itself.` })\n }\n\n const body = this.#writeBody(definition)\n return declare ? this.#declare({ definition, local: early ?? this.#claim(definition), body }) : wrap(body)\n }\n\n // A path is written in place. A value is always declared, and a type when it is used more than once.\n #declares({ id, isPath, space }: Definition): boolean {\n if (isPath) return false\n return space === 'value' || (this.#uses.get(id) ?? 0) > 1\n }\n\n #writeBody(definition: Definition): string {\n this.#writing.add(definition.id)\n const body = this.#rewriteFragment(this.#definitions.body(definition))\n this.#writing.delete(definition.id)\n return body\n }\n\n // The imports a fragment needs are carried first, so their aliases never rename a local the fragment resolves to.\n #rewriteFragment(fragment: Fragment): string {\n const aliases = this.#carry(fragment.imports)\n const { lang } = this.#definitions\n return replaceIdentifiers(fragment.text, (name) => this.#replacement({ from: fragment.file, name }) ?? aliases.get(name), lang, fragment.kind)\n }\n\n #declare({ definition, local, body }: { definition: Definition; local: string; body: string }): string {\n const { constant, space } = definition\n // A constant keeps its type annotation and `as const`, so its literal types do not widen.\n const type = constant?.type ? this.#rewriteFragment(this.#definitions.fragment({ file: definition.file, text: constant.type, kind: 'type' })) : undefined\n const node =\n space === 'type'\n ? ast.factory.createType({ name: local, nodes: [ast.factory.createText(body)] })\n : ast.factory.createConst({\n name: local,\n ...(type ? { type } : {}),\n ...(constant?.asConst ? { asConst: true } : {}),\n nodes: [ast.factory.createText(body)],\n })\n this.#declarations.push(ast.factory.createSource({ name: local, isTypeOnly: space === 'type', nodes: [node] }))\n return local\n }\n\n #claim(definition: Definition): string {\n const local = this.#renamer.assign({ name: definition.name, owner: definition.id })\n this.#locals.set(definition.id, local)\n return local\n }\n\n // Carries `imports` into the file and returns the alias of each name that clashed, such as `Options` becoming `Options2`.\n #carry(imports: ReadonlyArray<ImportNode>): Map<string, string> {\n const aliases = new Map<string, string>()\n for (const imp of imports) {\n const before = aliases.size\n const names = ast.file.getNames(imp).map((item) => {\n const local = localName(item)\n const name = this.#renamer.assign({ name: local, owner: idOf({ path: imp.path, name: item.name }) })\n if (name === local) return item\n aliases.set(local, name)\n return { ...item, alias: name }\n })\n this.#carried.push(aliases.size > before ? withNames({ imp, names }) : imp)\n }\n return aliases\n }\n\n #report({ from, message }: { from: FileNode; message: string }): undefined {\n this.#problems.push({ path: from.path, message })\n return undefined\n }\n}\n\n/**\n * Rewrites one file that imports from virtual files, in two passes. The first counts how often each definition is used and\n * reserves every name in sight. The second writes each use: a path in place, a value as one local constant, and a type as\n * one local type when it is used more than once, or in place otherwise.\n *\n * @example\n * ```ts\n * const { file, problems } = rewriteFile({ file: clientFile, definitions })\n * ```\n */\nexport function rewriteFile(options: RewriteFileOptions): { file: FileNode; problems: InlineResult['problems'] } {\n return new FileRewriter(options).rewrite()\n}\n\n// A renamer holding the names the file's imports and sources already bind, so a carried import or a local declaration\n// never takes one of them.\nfunction createFileRenamer(file: FileNode): Renamer {\n const renamer = createRenamer()\n for (const imp of file.imports) {\n for (const item of ast.file.getNames(imp)) renamer.bind({ name: localName(item), owner: idOf({ path: imp.path, name: item.name }) })\n }\n for (const source of file.sources) if (source.name) renamer.bind({ name: source.name, owner: file.path })\n return renamer\n}\n","import type { FileNode, InlineLanguage } from '@kubb/ast'\nimport type { InlineHook, InlineResult } from '@kubb/core'\nimport { createDefinitions } from './definitions.ts'\nimport { rewriteFile } from './fileRewriter.ts'\nimport { replaceIdentifiers, wrap, type Lang } from './inline.ts'\n\nexport type InlineOptions = {\n lang: Lang\n // Only files with one of these extensions are rewritten.\n extNames: ReadonlyArray<string>\n}\n\n/**\n * The parser's `inline` hook for `lang`. It also carries the deprecated `InlineLanguage` members, so a `@kubb/core` from\n * before the hook, which reads `inline` as an object, still inlines these files.\n *\n * @example\n * ```ts\n * const inline = createInline({ lang: 'ts', extNames: ['.ts', '.js'] })\n * inline(files) // { files, virtualPaths, problems }\n * ```\n */\nexport function createInline({ lang, extNames }: InlineOptions): InlineHook & InlineLanguage {\n const language: InlineLanguage = {\n replaceIdentifiers(text, replace) {\n return replaceIdentifiers(text, replace, lang)\n },\n wrap,\n }\n return Object.assign((files: ReadonlyArray<FileNode>) => inlineFiles({ files, lang, extNames }), language)\n}\n\n/**\n * Moves what a file imports from a virtual file (one marked `inline`, so it is never written) into that file. A value, and a\n * type used more than once, becomes one local, non-exported declaration. A type used once or a bare name is written in place.\n * The moved declarations' own imports move to the importing file.\n */\nexport function inlineFiles({ files, lang, extNames }: InlineOptions & { files: ReadonlyArray<FileNode> }): InlineResult {\n const virtual = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineResult = { files: [], virtualPaths: [...virtual.keys()], problems: [] }\n // Shared by every file, so each virtual body is read once per run.\n const definitions = createDefinitions({ virtual, lang })\n\n for (const file of files) {\n if (!extNames.includes(file.extname) || virtual.has(file.path) || !file.imports.some((imp) => virtual.has(imp.path))) continue\n\n const inlined = rewriteFile({ file, definitions })\n result.files.push(inlined.file)\n result.problems.push(...inlined.problems)\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n","import { dedent, indent } from '@internals/utils'\nimport { createRequire } from 'node:module'\nimport { dirname, extname as getExtname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { ast } from '@kubb/ast'\nimport { type ImportSpecifier, type ModuleExportName, parse, type ProgramStatement } from 'yuku'\n\n/**\n * A TypeScript compiler node, typed structurally so `@kubb/parser-ts` does not depend on `@typescript/typescript6`.\n *\n * @deprecated Pass printed strings to `print` instead. Removed in Kubb v6.\n */\nexport type TsNode = { readonly kind: number }\n\ntype Compiler = {\n printNodes: (nodes: Array<TsNode>) => string\n}\n\nlet compiler: Compiler | undefined\n\n// The parts of the TypeScript 6 API that printing compiler nodes uses, typed here so no package depends on it\ntype TypeScript = {\n createPrinter(options: { omitTrailingSemicolon: boolean; newLine: number; removeComments: boolean; noEmitHelpers: boolean }): {\n printList(format: number, list: unknown, sourceFile: unknown): string\n }\n createSourceFile(fileName: string, text: string, target: number, setParentNodes: boolean, kind: number): unknown\n factory: { createNodeArray(nodes: Array<TsNode>): unknown }\n NewLineKind: { LineFeed: number }\n ScriptTarget: { ES2022: number }\n ScriptKind: { TSX: number }\n ListFormat: { MultiLine: number }\n}\n\n/**\n * Loads TypeScript the first time `print` gets a compiler node. Strings never need it, so bundles for edge runtimes such as Cloudflare Workers leave it out.\n *\n * Loaded with `require`, not `import`: when ESM imports a CommonJS package, Node keeps a second copy of its source\n * to detect named exports, and for TypeScript that copy is about 9 MB.\n */\nfunction loadCompiler(): Compiler {\n if (compiler) return compiler\n\n process.emitWarning(\n 'Printing TypeScript compiler nodes with `print` from `@kubb/parser-ts` is deprecated and is removed in the next major. Return printed strings from printer handlers instead.',\n { type: 'DeprecationWarning', code: 'KUBB_PRINT_TS_NODE' },\n )\n\n const requireModule = createRequire(import.meta.url)\n // Look in the user's project first: a strict package manager such as pnpm does not link it next to this package\n const paths = [process.cwd(), dirname(fileURLToPath(import.meta.url))]\n let typescript: TypeScript | undefined\n // `typescript` 5 and 6 ship the compiler API; next to TypeScript 7 it comes from `@typescript/typescript6`\n for (const name of ['typescript', '@typescript/typescript6']) {\n try {\n const candidate = requireModule(requireModule.resolve(name, { paths }))\n if (typeof candidate.createPrinter === 'function') {\n typescript = candidate as TypeScript\n break\n }\n } catch {}\n }\n if (!typescript) {\n throw new Error(\n '`print` received a TypeScript compiler node, which needs `typescript` 5 or 6, or `@typescript/typescript6`, installed. Pass a printed string instead.',\n )\n }\n\n // One printer serves every call; printing does not mutate the source file, which only lends its compiler options\n const printer = typescript.createPrinter({\n omitTrailingSemicolon: true,\n newLine: typescript.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n const sourceFile = typescript.createSourceFile('print.tsx', '', typescript.ScriptTarget.ES2022, true, typescript.ScriptKind.TSX)\n\n compiler = {\n printNodes: (nodes) => printer.printList(typescript.ListFormat.MultiLine, typescript.factory.createNodeArray(nodes), sourceFile),\n }\n\n return compiler\n}\n\n/**\n * Swaps the extension of a relative import/export path for `extname`. Package specifiers and extension-less paths stay as-is.\n */\nexport function resolveOutputPath(path: string, extname: string | undefined, rootAware: boolean): string {\n if (!rootAware) return path\n const current = getExtname(path)\n return current ? `${path.slice(0, -current.length)}${extname ?? ''}` : path\n}\n\n/**\n * Node types this module reads from the yuku AST.\n */\nconst nodeTypes = {\n identifier: 'Identifier',\n literal: 'Literal',\n importDeclaration: 'ImportDeclaration',\n importSpecifier: 'ImportSpecifier',\n importDefaultSpecifier: 'ImportDefaultSpecifier',\n importNamespaceSpecifier: 'ImportNamespaceSpecifier',\n exportAllDeclaration: 'ExportAllDeclaration',\n exportNamedDeclaration: 'ExportNamedDeclaration',\n} as const\n\n/**\n * `importKind` and `exportKind` values this module reads from the yuku AST.\n */\nconst declarationKinds = {\n type: 'type',\n} as const\n\nfunction nameOf(node: ModuleExportName): string {\n return node.type === nodeTypes.literal ? node.value : node.name\n}\n\n/**\n * Converts an import specifier into a module name, keeping the quotes of a string-literal name (`{ 'a-b' as ab }`).\n */\nfunction toModuleName({ imported, local }: ImportSpecifier): ast.ModuleName {\n if (imported.type === nodeTypes.identifier && imported.name === local.name) return { name: local.name }\n\n return { name: imported.type === nodeTypes.literal ? quoteModulePath(imported.value) : imported.name, alias: local.name }\n}\n\n/**\n * Converts an `import` declaration into `ImportNode`s. Side-effect imports and imports with attributes or a phase stay as written.\n */\nfunction toImportNodes(statement: ProgramStatement, filePath: string): Array<ast.ImportNode> {\n if (statement.type !== nodeTypes.importDeclaration || !statement.specifiers.length || statement.attributes.length || statement.phase) return []\n\n const specifier = statement.source.value\n const target = specifier.startsWith('.') ? { path: resolve(dirname(filePath), specifier), root: filePath } : { path: specifier }\n const space: ast.Space = statement.importKind === declarationKinds.type ? 'type' : 'value'\n const names = statement.specifiers.map((element): ast.ModuleName => {\n if (element.type === nodeTypes.importDefaultSpecifier) return { name: 'default', alias: element.local.name, space }\n if (element.type === nodeTypes.importNamespaceSpecifier) return { name: '*', alias: element.local.name, space }\n return { ...toModuleName(element), space: element.importKind === declarationKinds.type ? 'type' : space }\n })\n\n return [ast.factory.createImport({ ...target, names })]\n}\n\n/**\n * Converts an `export … from` declaration into `ExportNode`s. Forms `printExport` cannot print stay as written.\n */\nfunction toExportNodes(statement: ProgramStatement): Array<ast.ExportNode> {\n if (statement.type !== nodeTypes.exportAllDeclaration && statement.type !== nodeTypes.exportNamedDeclaration) return []\n if (!statement.source || statement.attributes.length) return []\n\n const path = statement.source.value\n const space: ast.Space = statement.exportKind === declarationKinds.type ? 'type' : 'value'\n\n if (statement.type === nodeTypes.exportAllDeclaration) {\n return [ast.factory.createExport({ path, names: [{ name: '*', ...(statement.exported ? { alias: nameOf(statement.exported) } : {}), space }] })]\n }\n if (\n statement.specifiers.some(\n (element) =>\n element.exportKind === declarationKinds.type || element.exported.type === nodeTypes.literal || nameOf(element.exported) !== nameOf(element.local),\n )\n )\n return []\n\n return [ast.factory.createExport({ path, names: statement.specifiers.map((element) => ({ name: nameOf(element.local), space })) })]\n}\n\n/**\n * Splits `source` into its lifted `import`/`export … from` nodes, the `header` above the first one (shebang, directives, comments) and the rest as `body`.\n */\nexport function splitModuleDeclarations(\n source: string,\n filePath: string,\n): { header: string; imports: Array<ast.ImportNode>; exports: Array<ast.ExportNode>; body: string } {\n const { program } = parse(source, { lang: 'ts', sourceType: 'module' })\n const imports: Array<ast.ImportNode> = []\n const exports: Array<ast.ExportNode> = []\n let header = ''\n let body = ''\n let cursor = 0\n\n for (const statement of program.body) {\n const importNodes = toImportNodes(statement, filePath)\n const exportNodes = toExportNodes(statement)\n if (!importNodes.length && !exportNodes.length) {\n // Lifted declarations print above the body, so stop at the first one that stays in place to keep the evaluation order.\n if (\n statement.type === nodeTypes.importDeclaration ||\n ((statement.type === nodeTypes.exportNamedDeclaration || statement.type === nodeTypes.exportAllDeclaration) && statement.source)\n )\n break\n continue\n }\n\n const text = source.slice(cursor, statement.start)\n if (imports.length || exports.length) body += text\n else header = text\n imports.push(...importNodes)\n exports.push(...exportNodes)\n cursor = statement.end\n }\n\n return { header: header.trim(), imports, exports, body: `${body}${source.slice(cursor)}`.trim() }\n}\n\n/**\n * Joins the printed `nodes` with `separator`; a `Break` widens the next separator to a blank line, and leading, trailing and repeated breaks fold into one.\n *\n * Imperative on purpose: this runs once per source fragment and `map().filter().join()` showed up in deopt traces.\n */\nfunction printNodes({ nodes, separator }: { nodes: Array<ast.CodeNode> | undefined; separator: '\\n' | '\\n\\n' }): string {\n let result = ''\n let pendingBreak = false\n\n for (const node of nodes ?? []) {\n if (node.kind === ast.node.kinds.break) {\n pendingBreak = result !== ''\n continue\n }\n\n const text = printCodeNode(node)\n if (!text) continue\n\n if (result) result += pendingBreak ? '\\n\\n' : separator\n result += text\n pendingBreak = false\n }\n\n return result\n}\n\n/**\n * Renders `<T>(params): ReturnType`; an async function wraps its return type in `Promise<>`.\n */\nfunction signature({ async: isAsync, generics, params, returnType }: Pick<ast.FunctionNode, 'async' | 'generics' | 'params' | 'returnType'>): string {\n const genericsStr = generics ? `<${Array.isArray(generics) ? generics.join(', ') : generics}>` : ''\n const wrapped = isAsync ? `Promise<${returnType}>` : returnType\n const returnTypeStr = returnType ? `: ${wrapped}` : ''\n\n return `${genericsStr}(${params ?? ''})${returnTypeStr}`\n}\n\n/**\n * Puts the JSDoc block, when it renders to something, above `declaration`.\n */\nfunction withJSDoc({ jsDoc, declaration }: { jsDoc?: ast.JSDocNode | null; declaration: string }): string {\n const jsDocStr = jsDoc ? printJSDoc(jsDoc) : ''\n\n return jsDocStr ? `${jsDocStr}\\n${declaration}` : declaration\n}\n\n/**\n * Joins printed code fragments with a newline.\n *\n * Passing TypeScript compiler nodes still works but is deprecated and needs `typescript` 5 or 6, or `@typescript/typescript6`, installed.\n * Support for compiler nodes is removed in the next major.\n */\nexport function print(...elements: Array<string | TsNode>): string {\n const filtered = elements.filter(Boolean)\n if (filtered.length === 0) return ''\n if (filtered.every((element) => typeof element === 'string')) return filtered.join('\\n')\n // Printing compiler nodes as one list keeps the output byte-for-byte the same as before strings were accepted\n if (filtered.every((element) => typeof element !== 'string')) return loadCompiler().printNodes(filtered)\n\n return filtered.map((element) => (typeof element === 'string' ? element : loadCompiler().printNodes([element]).trimEnd())).join('\\n')\n}\n\n/**\n * Converts a {@link ast.JSDocNode} to a `/** … *\\/` block, dropping blank comments.\n */\nfunction printJSDoc(jsDoc: ast.JSDocNode): string {\n const comments = (jsDoc.comments ?? []).filter((c) => c != null)\n if (comments.length === 0) return ''\n\n const lines = comments\n .flatMap((c) => c.split(/\\r?\\n/))\n .map((l) => l.replace(/\\*\\//g, '* /').replace(/\\r/g, ''))\n .filter((l) => l.trim().length > 0)\n\n if (lines.length === 0) return ''\n\n return ['/**', ...lines.map((l) => ` * ${l}`), ' */'].join('\\n')\n}\n\n/**\n * Converts a {@link ast.ConstNode} to a `const` declaration, mirroring the `Const` component from `@kubb/renderer-jsx`.\n */\nfunction printConst(node: ast.ConstNode): string {\n const { name, export: canExport, type, JSDoc, asConst, nodes } = node\n\n const declaration = `${canExport ? 'export ' : ''}const ${name}${type ? `: ${type}` : ''} = ${printNodes({ nodes, separator: '\\n' })}${asConst ? ' as const' : ''}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Converts a {@link ast.TypeNode} to a `type` alias or an `interface`, mirroring the `Type` component from `@kubb/renderer-jsx`.\n */\nfunction printType(node: ast.TypeNode): string {\n const { name, export: canExport, syntax, JSDoc, nodes } = node\n const body = printNodes({ nodes, separator: '\\n' })\n\n const declaration = `${canExport ? 'export ' : ''}${syntax === 'interface' ? `interface ${name} ${body}` : `type ${name} = ${body}`}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Converts a {@link ast.FunctionNode} to a `function` declaration, mirroring the `Function` component from `@kubb/renderer-jsx`.\n */\nfunction printFunction(node: ast.FunctionNode): string {\n const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc, nodes } = node\n\n const body = indent({ text: printNodes({ nodes, separator: '\\n' }) })\n const prefix = `${canExport ? 'export ' : ''}${isDefault ? 'default ' : ''}${isAsync ? 'async ' : ''}`\n const declaration = `${prefix}function ${name}${signature({ async: isAsync, generics, params, returnType })} {${body ? `\\n${body}\\n` : ''}}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Converts an {@link ast.ArrowFunctionNode} to a `const` arrow function, mirroring the `Function.Arrow` component from `@kubb/renderer-jsx`.\n */\nfunction printArrowFunction(node: ast.ArrowFunctionNode): string {\n const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc, nodes, singleLine } = node\n\n const body = printNodes({ nodes, separator: '\\n' })\n const arrowBody = singleLine ? ` => ${body}` : body ? ` => {\\n${indent({ text: body })}\\n}` : ' => {}'\n const prefix = `${canExport ? 'export ' : ''}${isDefault ? 'default ' : ''}`\n const declaration = `${prefix}const ${name} = ${isAsync ? 'async ' : ''}${signature({ async: isAsync, generics, params, returnType })}${arrowBody}`\n\n return withJSDoc({ jsDoc: JSDoc, declaration })\n}\n\n/**\n * Dispatches a {@link ast.CodeNode} to the printer for its `kind`.\n */\nfunction printCodeNode(node: ast.CodeNode): string {\n switch (node.kind) {\n case ast.node.kinds.break:\n return ''\n case ast.node.kinds.text:\n case ast.node.kinds.jsx:\n return dedent(node.value)\n case ast.node.kinds.const:\n return printConst(node)\n case ast.node.kinds.type:\n return printType(node)\n case ast.node.kinds.function:\n return printFunction(node)\n case ast.node.kinds.arrowFunction:\n return printArrowFunction(node)\n }\n}\n\n/**\n * Prints a {@link ast.SourceNode} with a blank line between its top-level nodes.\n */\nexport function printSource(node: ast.SourceNode): string {\n return printNodes({ nodes: node.nodes, separator: '\\n\\n' })\n}\n\n/**\n * Wraps a module specifier in single quotes, escaping embedded backslashes and quotes.\n */\nfunction quoteModulePath(path: string): string {\n return `'${path.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`\n}\n\n// `{ a, b as c }`, with `type` before the braces when every name is a type, else before each type name.\nfunction printNamed(names: ReadonlyArray<ast.ModuleName>): string {\n const allTypes = names.every((item) => item.space === 'type')\n const specifiers = names.map((item) => `${!allTypes && item.space === 'type' ? 'type ' : ''}${item.alias ? `${item.name} as ${item.alias}` : item.name}`)\n return `${allTypes ? 'type ' : ''}{ ${specifiers.join(', ')} }`\n}\n\n/**\n * Renders the `import` declarations for `names`: one per default or `* as` name, and one for the named members.\n * `path` is used verbatim, so resolve it first.\n */\nexport function printImport({ names, path }: { names: ReadonlyArray<ast.ModuleName>; path: string }): string {\n const from = quoteModulePath(path)\n const lines: Array<string> = []\n const named: Array<ast.ModuleName> = []\n for (const item of names) {\n const type = item.space === 'type' ? 'type ' : ''\n if (item.alias && item.name === '*') lines.push(`import ${type}* as ${item.alias} from ${from}`)\n else if (item.alias && item.name === 'default') lines.push(`import ${type}${item.alias} from ${from}`)\n // Without a local name, a default or whole-module import binds nothing, and `{ default }` does not parse.\n else if (item.name !== '*' && item.name !== 'default') named.push(item)\n }\n if (named.length) lines.push(`import ${printNamed(named)} from ${from}`)\n return lines.join('\\n')\n}\n\n/**\n * Renders the `export … from` declarations for `names`: one per `*` name, as `export *` or `export * as`, and one\n * for the named members. `path` is used verbatim, so resolve it first.\n */\nexport function printExport({ names, path }: { names: ReadonlyArray<ast.ModuleName>; path: string }): string {\n const from = quoteModulePath(path)\n const lines = names\n .filter((item) => item.name === '*')\n .map((item) => {\n // An identifier cannot start with a digit, so prefix `_` and keep the digit\n const alias = item.alias && (/^\\d/.test(item.alias) ? `_${item.alias}` : item.alias)\n return `export ${item.space === 'type' ? 'type ' : ''}* ${alias ? `as ${alias} ` : ''}from ${from}`\n })\n const named = names.filter((item) => item.name !== '*')\n if (named.length) lines.push(`export ${printNamed(named)} from ${from}`)\n return lines.join('\\n')\n}\n","import { ast } from '@kubb/ast'\nimport { defineExtension } from '@kubb/core'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { createInline } from './inlineFiles.ts'\nimport { print, printExport, printImport, printSource, resolveOutputPath, splitModuleDeclarations, type TsNode } from './utils.ts'\n\nconst DEFAULT_EXTENSION: Record<ast.FileNode['extname'], ast.FileNode['extname'] | ''> = { '.ts': '' }\n\n/**\n * Options accepted by `parserTs` and `parserTsx`.\n */\nexport type ParserTsOptions = {\n /**\n * Rewrite extensions on relative `import`/`export` statements. Each key is the extension of a\n * generated file, and its value is the extension written on the relative specifiers in that\n * file. `''` drops it, and so does a generated file whose extension has no key. Package\n * specifiers stay unchanged. Also applies to relative paths in `copy` templates.\n *\n * Use `{ '.ts': '.js' }` for ESM output compiled to JavaScript, or `{ '.ts': '.ts' }` to run the\n * `.ts` files directly in Node.js or compile them with `rewriteRelativeImportExtensions`.\n *\n * @default { '.ts': '' }\n * @example\n * ```ts\n * parserTs({ extension: { '.ts': '.js' } }) // import './api.js' instead of './api'\n * parserTs({ extension: { '.ts': '.ts' } }) // import './api.ts' instead of './api'\n * ```\n */\n extension?: Record<ast.FileNode['extname'], ast.FileNode['extname'] | ''>\n}\n\n/**\n * Default Kubb parser for `.ts` and `.js` files. Takes the universal AST\n * produced by an adapter and prints it as TypeScript source. Imports and exports\n * are rewritten based on each file's metadata and the `extension` option.\n *\n * Used automatically when no `parsers` option is set on `defineConfig`. Use\n * `parserTsx` instead for React projects that emit JSX.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { adapterOas } from '@kubb/adapter-oas'\n * import { parserTs } from '@kubb/parser-ts'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * adapter: adapterOas(),\n * parsers: [parserTs()],\n * plugins: [],\n * })\n * ```\n */\nexport const parserTs = defineExtension<ParserTsOptions, object, string | TsNode>({\n kind: 'parser',\n meta: { name: 'typescript', version, compatibility, issues: 'https://github.com/kubb-labs/kubb/issues' },\n build({ extension = DEFAULT_EXTENSION }) {\n return {\n extNames: ['.ts', '.js'],\n print,\n inline: createInline({ lang: 'ts', extNames: ['.ts', '.js'] }),\n parse(file) {\n const extname = extension[file.extname] || undefined\n\n const source = file.sources\n .map((item) => printSource(item))\n .filter(Boolean)\n .map((text) => text.trimEnd())\n .join('\\n\\n')\n\n const importLines = file.imports.map((item) =>\n printImport({\n names: ast.file.getNames(item),\n path: resolveOutputPath(item.root ? ast.file.getRelativePath(item.root, item.path) : item.path, extname, Boolean(item.root)),\n }),\n )\n\n const exportLines = file.exports.map((item) =>\n printExport({ names: ast.file.getNames(item), path: resolveOutputPath(item.path, extname, item.path.startsWith('.')) }),\n )\n\n const importExportBlock = [...importLines, ...exportLines].join('\\n')\n\n const parts = [file.banner, importExportBlock, source, file.footer].filter((segment): segment is string => Boolean(segment)).map((s) => s.trimEnd())\n\n return parts.join('\\n\\n')\n },\n copy(file, source) {\n const { header, imports, exports, body } = splitModuleDeclarations(source, file.path)\n\n return {\n ...file,\n banner: [header, file.banner].filter(Boolean).join('\\n') || undefined,\n imports: [...file.imports, ...imports],\n exports: [...file.exports, ...exports],\n sources: [ast.factory.createSource({ nodes: [ast.factory.createText(body)] })],\n }\n },\n }\n },\n})\n","import { defineExtension } from '@kubb/core'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { createInline } from './inlineFiles.ts'\nimport { parserTs, type ParserTsOptions } from './parserTs.ts'\nimport type { TsNode } from './utils.ts'\n\n/**\n * Kubb parser for `.tsx` and `.jsx` files. Delegates to `parserTs`, since JSX\n * prints as text the same way, so it shares the same `extension` option.\n *\n * Add to the `parsers` array on `defineConfig` when generating components for\n * React (or any framework that emits JSX).\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { adapterOas } from '@kubb/adapter-oas'\n * import { parserTsx } from '@kubb/parser-ts'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * adapter: adapterOas(),\n * parsers: [parserTsx()],\n * plugins: [],\n * })\n * ```\n */\nexport const parserTsx = defineExtension<ParserTsOptions, object, string | TsNode>({\n kind: 'parser',\n meta: { name: 'tsx', version, compatibility, issues: 'https://github.com/kubb-labs/kubb/issues' },\n build: (options) => ({\n ...parserTs(options),\n extNames: ['.tsx', '.jsx'],\n inline: createInline({ lang: 'tsx', extNames: ['.tsx', '.jsx'] }),\n }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AEyBA,SAAgB,KAAmB,OAA4B,KAAW,SAA+B;CACvG,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,KAAa,MAAM,IAAI,GAAG,GAAG,OAAO;CACnD,MAAM,QAAQ,QAAQ;CACtB,MAAM,IAAI,KAAK,KAAK;CACpB,OAAO;AACT;AAEA,IAAM,eAAN,MAAgE;CACrD,yBAAS,IAAI,IAAkB;CAC/B;CAET,YAAY,KAAa;EACvB,KAAK,OAAO;CACd;CAEA,IAAI,KAAoB;EACtB,OAAO,KAAK,OAAO,IAAI,GAAG;CAC5B;CAEA,IAAI,KAA+B;EACjC,OAAO,KAAK,OAAO,IAAI,GAAG;CAC5B;CAEA,IAAI,KAAW,OAAqB;EAClC,IAAI,KAAK,OAAO,QAAQ,KAAK,MAAM,KAAK,OAAO,MAAM;EACrD,KAAK,OAAO,IAAI,KAA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B,UAAU,CAAC,QAAQ,MAAM;EACzB,QAAQ,aAAa;GAAE,MAAM;GAAO,UAAU,CAAC,QAAQ,MAAM;EAAE,CAAC;CAClE;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/parser-ts",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.28.0",
|
|
4
4
|
"description": "TypeScript and TSX parser for Kubb. Prints AST nodes as TypeScript and TSX source, with imports, exports and JSDoc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@internals/utils": "0.0.1",
|
|
71
|
-
"@kubb/ast": "5.
|
|
72
|
-
"@kubb/core": "5.
|
|
71
|
+
"@kubb/ast": "5.28.0",
|
|
72
|
+
"@kubb/core": "5.28.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@kubb/ast": "^5.
|
|
76
|
-
"@kubb/core": "^5.
|
|
75
|
+
"@kubb/ast": "^5.28.0",
|
|
76
|
+
"@kubb/core": "^5.28.0"
|
|
77
77
|
},
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">=22.22"
|