@kubb/ast 5.28.6 → 5.29.1

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.
Files changed (102) hide show
  1. package/README.md +19 -10
  2. package/dist/factory.cjs +6 -6
  3. package/dist/factory.d.cts +2 -2
  4. package/dist/factory.d.ts +2 -2
  5. package/dist/factory.js +2 -2
  6. package/dist/{combineFileMembers-B-mdjXrG.js → file-AcKQt60j.js} +137 -123
  7. package/dist/file-AcKQt60j.js.map +1 -0
  8. package/dist/{file-DJqd2j3y.d.cts → file-CLh8vdcR.d.cts} +20 -29
  9. package/dist/{file-lssk85C8.cjs → file-DVw2Htda.cjs} +13 -13
  10. package/dist/{file-lssk85C8.cjs.map → file-DVw2Htda.cjs.map} +1 -1
  11. package/dist/{combineFileMembers-DZCKxAN0.cjs → file-Db_PYobC.cjs} +136 -122
  12. package/dist/file-Db_PYobC.cjs.map +1 -0
  13. package/dist/{file-Dg70hXm3.d.ts → file-VRwu7Set.d.ts} +20 -29
  14. package/dist/{file-CO9KnOvT.js → file-pjdyWLJ0.js} +2 -2
  15. package/dist/{file-CO9KnOvT.js.map → file-pjdyWLJ0.js.map} +1 -1
  16. package/dist/file.cjs +6 -6
  17. package/dist/file.d.cts +1 -1
  18. package/dist/file.d.ts +1 -1
  19. package/dist/file.js +2 -2
  20. package/dist/{graph-DWlCmvm6.js → graph-Cu2-NiKi.js} +78 -15
  21. package/dist/graph-Cu2-NiKi.js.map +1 -0
  22. package/dist/{graph-D6Ffy9YD.cjs → graph-CymJtC1M.cjs} +78 -15
  23. package/dist/graph-CymJtC1M.cjs.map +1 -0
  24. package/dist/graph.cjs +1 -1
  25. package/dist/graph.d.cts +1 -1
  26. package/dist/graph.d.ts +1 -1
  27. package/dist/graph.js +1 -1
  28. package/dist/{index-BGhhO3z8.d.ts → index-B4DY8ewx.d.ts} +2 -2
  29. package/dist/{index-DjwCRndP.d.ts → index-BEvWuiSq.d.ts} +1 -1
  30. package/dist/{index-DphKh9u9.d.ts → index-BXHrCLGe.d.ts} +1 -1
  31. package/dist/{index-C4ZZnf_X.d.cts → index-BgmSdJKJ.d.cts} +2 -2
  32. package/dist/{index-CKd3ogUZ.d.cts → index-C0YF5kEb.d.cts} +2 -2
  33. package/dist/{index-Ck6nqnxZ.d.cts → index-CGvAotBX.d.cts} +2 -2
  34. package/dist/{index-DVX6E3vZ.d.ts → index-CHilsNw-.d.ts} +2 -2
  35. package/dist/{index-C0_Y9yA1.d.ts → index-CsySa8TT.d.ts} +2 -2
  36. package/dist/{index-BM3jzSca.d.ts → index-DA-Ztg07.d.ts} +1 -1
  37. package/dist/{index-CiVsdeOh.d.cts → index-DPGecgel.d.cts} +1 -1
  38. package/dist/{index-DdD4PIY8.d.cts → index-Dbtc7izw.d.cts} +1 -1
  39. package/dist/{index-DSW89P6k.d.cts → index-QDfAzfWY.d.cts} +1 -1
  40. package/dist/{index-B8ZxUpy4.d.ts → index-QZa0vqFW.d.ts} +1 -1
  41. package/dist/{index-7A3j-6Np.d.cts → index-oY3-BSwC.d.cts} +1 -1
  42. package/dist/index.cjs +8 -8
  43. package/dist/index.d.cts +9 -9
  44. package/dist/index.d.ts +9 -9
  45. package/dist/index.js +8 -8
  46. package/dist/isRecord-CwlfDtHp.cjs +16 -0
  47. package/dist/isRecord-CwlfDtHp.cjs.map +1 -0
  48. package/dist/isRecord-DaSp13D_.js +11 -0
  49. package/dist/isRecord-DaSp13D_.js.map +1 -0
  50. package/dist/{json-DeqPhPUQ.js → json-IKokiUCp.js} +34 -19
  51. package/dist/json-IKokiUCp.js.map +1 -0
  52. package/dist/{json-KV2VhBue.cjs → json-mEYdjumm.cjs} +34 -19
  53. package/dist/json-mEYdjumm.cjs.map +1 -0
  54. package/dist/json.cjs +1 -1
  55. package/dist/json.d.cts +1 -1
  56. package/dist/json.d.ts +1 -1
  57. package/dist/json.js +1 -1
  58. package/dist/{macro-3uGSg-ic.js → macro-DhgoqDs6.js} +2 -2
  59. package/dist/{macro-3uGSg-ic.js.map → macro-DhgoqDs6.js.map} +1 -1
  60. package/dist/{macro-Ywn4-0s5.cjs → macro-h3bm9G48.cjs} +2 -2
  61. package/dist/{macro-Ywn4-0s5.cjs.map → macro-h3bm9G48.cjs.map} +1 -1
  62. package/dist/macro.cjs +1 -1
  63. package/dist/macro.d.cts +1 -1
  64. package/dist/macro.d.ts +1 -1
  65. package/dist/macro.js +1 -1
  66. package/dist/{node-BeccjrHH.cjs → node-Dhh4jTDv.cjs} +2 -2
  67. package/dist/{node-BeccjrHH.cjs.map → node-Dhh4jTDv.cjs.map} +1 -1
  68. package/dist/{node-Dm56432_.js → node-Dy0mq_hi.js} +2 -2
  69. package/dist/{node-Dm56432_.js.map → node-Dy0mq_hi.js.map} +1 -1
  70. package/dist/node.cjs +2 -2
  71. package/dist/node.d.cts +2 -2
  72. package/dist/node.d.ts +2 -2
  73. package/dist/node.js +2 -2
  74. package/dist/{nodes-KgbYiyJQ.js → nodes-B-MW8yk-.js} +2 -2
  75. package/dist/{nodes-KgbYiyJQ.js.map → nodes-B-MW8yk-.js.map} +1 -1
  76. package/dist/{nodes-BGxHocS_.cjs → nodes-BjVv21pb.cjs} +12 -12
  77. package/dist/{nodes-BGxHocS_.cjs.map → nodes-BjVv21pb.cjs.map} +1 -1
  78. package/dist/promise-DMQPWp6M.cjs.map +1 -1
  79. package/dist/promise-bi4pc8Xr.js.map +1 -1
  80. package/dist/{schema-XGRiAvok.cjs → schema-CMe0Dvgd.cjs} +2 -2
  81. package/dist/{schema-XGRiAvok.cjs.map → schema-CMe0Dvgd.cjs.map} +1 -1
  82. package/dist/{schema-B05JSQRq.js → schema-CVIk19Mh.js} +2 -2
  83. package/dist/{schema-B05JSQRq.js.map → schema-CVIk19Mh.js.map} +1 -1
  84. package/dist/schema.cjs +2 -2
  85. package/dist/schema.d.cts +2 -2
  86. package/dist/schema.d.ts +2 -2
  87. package/dist/schema.js +2 -2
  88. package/dist/{visitor-xxcbpM5-.d.ts → visitor-BWHpwRgc.d.ts} +2 -2
  89. package/dist/{visitor-BIldddZd.d.cts → visitor-CPlsMCPZ.d.cts} +2 -2
  90. package/dist/{visitor-DA5yfOJz.js → visitor-CitcdWu0.js} +5 -10
  91. package/dist/visitor-CitcdWu0.js.map +1 -0
  92. package/dist/{visitor-DhuKS-7x.cjs → visitor-DT712cxr.cjs} +5 -10
  93. package/dist/visitor-DT712cxr.cjs.map +1 -0
  94. package/package.json +1 -1
  95. package/dist/combineFileMembers-B-mdjXrG.js.map +0 -1
  96. package/dist/combineFileMembers-DZCKxAN0.cjs.map +0 -1
  97. package/dist/graph-D6Ffy9YD.cjs.map +0 -1
  98. package/dist/graph-DWlCmvm6.js.map +0 -1
  99. package/dist/json-DeqPhPUQ.js.map +0 -1
  100. package/dist/json-KV2VhBue.cjs.map +0 -1
  101. package/dist/visitor-DA5yfOJz.js.map +0 -1
  102. package/dist/visitor-DhuKS-7x.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_combineFileMembers = require("./combineFileMembers-DZCKxAN0.cjs");
2
+ const require_file = require("./file-Db_PYobC.cjs");
3
3
  const require_constants = require("./constants-BCRkFAiy.cjs");
4
4
  const require_nodeText = require("./nodeText-DH4dLGUb.cjs");
5
5
  // ../../internals/utils/src/text.ts
@@ -83,7 +83,7 @@ function inlineFiles(files, { language }) {
83
83
  name: local
84
84
  };
85
85
  for (const imp of file.imports) {
86
- const item = virtualFiles.has(imp.path) && require_combineFileMembers.getNames(imp).find((item) => (item.alias ?? item.name) === local);
86
+ const item = virtualFiles.has(imp.path) && require_file.getNames(imp).find((item) => (item.alias ?? item.name) === local);
87
87
  if (item) return {
88
88
  path: imp.path,
89
89
  name: item.name
@@ -110,7 +110,7 @@ function inlineFiles(files, { language }) {
110
110
  ...imp,
111
111
  root: file.path
112
112
  } : imp)];
113
- result.files.push(require_combineFileMembers.createFile({
113
+ result.files.push(require_file.createFile({
114
114
  ...file,
115
115
  sources,
116
116
  imports
@@ -120,7 +120,7 @@ function inlineFiles(files, { language }) {
120
120
  }
121
121
  function carryImports(file, lang, carried) {
122
122
  const bindings = /* @__PURE__ */ new Map();
123
- for (const imp of file.imports) for (const item of require_combineFileMembers.getNames(imp)) bindings.set(item.alias ?? item.name, `${imp.path}\0${item.name}`);
123
+ for (const imp of file.imports) for (const item of require_file.getNames(imp)) bindings.set(item.alias ?? item.name, `${imp.path}\0${item.name}`);
124
124
  for (const source of file.sources) {
125
125
  if (source.name) bindings.set(source.name, file.path);
126
126
  rewriteNodes(source.nodes, (text) => lang.replaceIdentifiers(text, (name) => {
@@ -131,7 +131,7 @@ function carryImports(file, lang, carried) {
131
131
  const aliases = /* @__PURE__ */ new Map();
132
132
  for (const imp of definition.imports) {
133
133
  const before = aliases.size;
134
- const names = require_combineFileMembers.getNames(imp).map((item) => {
134
+ const names = require_file.getNames(imp).map((item) => {
135
135
  const local = item.alias ?? item.name;
136
136
  const binding = `${imp.path}\0${item.name}`;
137
137
  const name = uniqueName(local, (candidate) => bindings.has(candidate) && bindings.get(candidate) !== binding);
@@ -143,7 +143,7 @@ function carryImports(file, lang, carried) {
143
143
  alias: name
144
144
  };
145
145
  });
146
- carried.push(aliases.size > before ? require_combineFileMembers.createImport({
146
+ carried.push(aliases.size > before ? require_file.createImport({
147
147
  path: imp.path,
148
148
  ...imp.root != null ? { root: imp.root } : {},
149
149
  names
@@ -162,8 +162,8 @@ function bodyOf(source) {
162
162
  return require_nodeText.getNodeText(node.nodes) || void 0;
163
163
  }
164
164
  function pickNames(imp, used) {
165
- const names = require_combineFileMembers.getNames(imp).filter((item) => used.has(item.alias ?? item.name));
166
- return names.length > 0 ? [require_combineFileMembers.createImport({
165
+ const names = require_file.getNames(imp).filter((item) => used.has(item.alias ?? item.name));
166
+ return names.length > 0 ? [require_file.createImport({
167
167
  path: imp.path,
168
168
  ...imp.root != null ? { root: imp.root } : {},
169
169
  names
@@ -185,11 +185,11 @@ function rewriteNodes(nodes, rewrite) {
185
185
  }
186
186
  // src/file/index.ts
187
187
  var file_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
188
- getNames: () => require_combineFileMembers.getNames,
189
- getRelativePath: () => require_combineFileMembers.getRelativePath,
190
- getSpace: () => require_combineFileMembers.getSpace,
188
+ getNames: () => require_file.getNames,
189
+ getRelativePath: () => require_file.getRelativePath,
190
+ getSpace: () => require_file.getSpace,
191
191
  inline: () => inlineFiles,
192
- isExported: () => require_combineFileMembers.isExported
192
+ isExported: () => require_file.isExported
193
193
  });
194
194
  Object.defineProperty(exports, "file_exports", {
195
195
  enumerable: true,
@@ -204,4 +204,4 @@ Object.defineProperty(exports, "inlineFiles", {
204
204
  }
205
205
  });
206
206
 
207
- //# sourceMappingURL=file-lssk85C8.cjs.map
207
+ //# sourceMappingURL=file-DVw2Htda.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-lssk85C8.cjs","names":["getNames","createFile","createImport","nodeKinds","getNodeText","CODE_NODE_TEXT_FIELDS"],"sources":["../../../internals/utils/src/text.ts","../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["/**\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\n/** The offset where each line of `text` starts, for {@link toPosition}. */\nexport function lineStarts(text: string): Array<number> {\n const starts = [0]\n for (let index = text.indexOf('\\n'); index !== -1; index = text.indexOf('\\n', index + 1)) starts.push(index + 1)\n return starts\n}\n\n/** The 1-based line and column (UTF-16) of `offset`, from the {@link lineStarts} of the same text. */\nexport function toPosition(starts: ReadonlyArray<number>, offset: number): { line: number; column: number } {\n let low = 0\n let high = starts.length - 1\n while (low < high) {\n const middle = (low + high + 1) >> 1\n if (starts[middle]! <= offset) low = middle\n else high = middle - 1\n }\n return { line: low + 1, column: offset - starts[low]! + 1 }\n}\n","import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile, createImport } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { uniqueName } from '@internals/utils'\nimport { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\nexport type InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n *\n * @deprecated Make the parser's `inline` a function, `(files) => InlineResult`, as `@kubb/parser-ts` does. Removed in v6.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\nexport type InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n *\n * @deprecated Make the parser's `inline` a function, `(files) => InlineResult`, as `@kubb/parser-ts` does. Removed in v6.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, (inner) => {\n imports.push(...inner.imports)\n return inner.expression\n })\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // `use` takes each replaced definition's imports and returns its text; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, use: (definition: Definition) => string) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n return lang.wrap(use(definition))\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && getNames(imp).find((item) => (item.alias ?? item.name) === local)\n if (item) return { path: imp.path, name: item.name }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const carry = carryImports(file, lang, carried)\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carry).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// Moves each definition's imports into `carried` and returns the definition's text. A carried name the file already binds to\n// something else, such as a schema `Options` next to the client's own `Options`, gets an alias like `Options2`.\nfunction carryImports(file: FileNode, lang: InlineLanguage, carried: Array<ImportNode>) {\n // Each name the file uses, to the import (module and exported name) or declaration behind it. `''` marks a global, such as\n // the fetch `Response` next to a schema `Response`.\n const bindings = new Map<string, string>()\n for (const imp of file.imports) for (const item of getNames(imp)) bindings.set(item.alias ?? item.name, `${imp.path}\\0${item.name}`)\n for (const source of file.sources) {\n if (source.name) bindings.set(source.name, file.path)\n rewriteNodes(source.nodes, (text) =>\n lang.replaceIdentifiers(text, (name) => {\n if (!bindings.has(name)) bindings.set(name, '')\n return undefined\n }),\n )\n }\n\n return (definition: Definition): string => {\n const aliases = new Map<string, string>()\n for (const imp of definition.imports) {\n const before = aliases.size\n const names = getNames(imp).map((item) => {\n const local = item.alias ?? item.name\n const binding = `${imp.path}\\0${item.name}`\n const name = uniqueName(local, (candidate) => bindings.has(candidate) && bindings.get(candidate) !== binding)\n bindings.set(name, binding)\n if (name === local) return item\n aliases.set(local, name)\n return { ...item, alias: name }\n })\n carried.push(aliases.size > before ? createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names }) : imp)\n }\n\n return aliases.size ? lang.replaceIdentifiers(definition.expression, (name) => aliases.get(name)) : definition.expression\n }\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\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n const names = getNames(imp).filter((item) => used.has(item.alias ?? item.name))\n return names.length > 0 ? [createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names })] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): 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) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { getRelativePath } from '../utils/combineFileMembers.ts'\nexport { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace, isExported } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;;AAsDA,SAAgB,WAAW,MAAc,SAAiD;CACxF,IAAI,YAAY;CAChB,KAAK,IAAI,SAAS,GAAG,QAAQ,SAAS,GAAG,UAAU,YAAY,GAAG,OAAO;CACzE,OAAO;AACT;;;;;;;;ACJA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;CACxF,MAAM,SAA4B;EAAE,OAAO,CAAC;EAAG,cAAc,CAAC,GAAG,aAAa,KAAK,CAAC;EAAG,UAAU,CAAC;CAAE;CACpG,IAAI,aAAa,SAAS,GAAG,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAA+B;CAEvD,SAAS,OAAO,MAAc,MAAc,MAAc,MAA8C;EACtG,MAAM,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,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"file-DVw2Htda.cjs","names":["getNames","createFile","createImport","nodeKinds","getNodeText","CODE_NODE_TEXT_FIELDS"],"sources":["../../../internals/utils/src/text.ts","../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["/**\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\n/** The offset where each line of `text` starts, for {@link toPosition}. */\nexport function lineStarts(text: string): Array<number> {\n const starts = [0]\n for (let index = text.indexOf('\\n'); index !== -1; index = text.indexOf('\\n', index + 1)) starts.push(index + 1)\n return starts\n}\n\n/** The 1-based line and column (UTF-16) of `offset`, from the {@link lineStarts} of the same text. */\nexport function toPosition(starts: ReadonlyArray<number>, offset: number): { line: number; column: number } {\n let low = 0\n let high = starts.length - 1\n while (low < high) {\n const middle = (low + high + 1) >> 1\n if (starts[middle]! <= offset) low = middle\n else high = middle - 1\n }\n return { line: low + 1, column: offset - starts[low]! + 1 }\n}\n","import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile, createImport } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { uniqueName } from '@internals/utils'\nimport { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\nexport type InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n *\n * @deprecated Make the parser's `inline` a function, `(files) => InlineResult`, as `@kubb/parser-ts` does. Removed in v6.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\nexport type InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n *\n * @deprecated Make the parser's `inline` a function, `(files) => InlineResult`, as `@kubb/parser-ts` does. Removed in v6.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, (inner) => {\n imports.push(...inner.imports)\n return inner.expression\n })\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // `use` takes each replaced definition's imports and returns its text; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, use: (definition: Definition) => string) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n return lang.wrap(use(definition))\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && getNames(imp).find((item) => (item.alias ?? item.name) === local)\n if (item) return { path: imp.path, name: item.name }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const carry = carryImports(file, lang, carried)\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carry).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// Moves each definition's imports into `carried` and returns the definition's text. A carried name the file already binds to\n// something else, such as a schema `Options` next to the client's own `Options`, gets an alias like `Options2`.\nfunction carryImports(file: FileNode, lang: InlineLanguage, carried: Array<ImportNode>) {\n // Each name the file uses, to the import (module and exported name) or declaration behind it. `''` marks a global, such as\n // the fetch `Response` next to a schema `Response`.\n const bindings = new Map<string, string>()\n for (const imp of file.imports) for (const item of getNames(imp)) bindings.set(item.alias ?? item.name, `${imp.path}\\0${item.name}`)\n for (const source of file.sources) {\n if (source.name) bindings.set(source.name, file.path)\n rewriteNodes(source.nodes, (text) =>\n lang.replaceIdentifiers(text, (name) => {\n if (!bindings.has(name)) bindings.set(name, '')\n return undefined\n }),\n )\n }\n\n return (definition: Definition): string => {\n const aliases = new Map<string, string>()\n for (const imp of definition.imports) {\n const before = aliases.size\n const names = getNames(imp).map((item) => {\n const local = item.alias ?? item.name\n const binding = `${imp.path}\\0${item.name}`\n const name = uniqueName(local, (candidate) => bindings.has(candidate) && bindings.get(candidate) !== binding)\n bindings.set(name, binding)\n if (name === local) return item\n aliases.set(local, name)\n return { ...item, alias: name }\n })\n carried.push(aliases.size > before ? createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names }) : imp)\n }\n\n return aliases.size ? lang.replaceIdentifiers(definition.expression, (name) => aliases.get(name)) : definition.expression\n }\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\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n const names = getNames(imp).filter((item) => used.has(item.alias ?? item.name))\n return names.length > 0 ? [createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names })] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): 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) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { getRelativePath } from '../utils/combineFileMembers.ts'\nexport { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace, isExported } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;;AAsDA,SAAgB,WAAW,MAAc,SAAiD;CACxF,IAAI,YAAY;CAChB,KAAK,IAAI,SAAS,GAAG,QAAQ,SAAS,GAAG,UAAU,YAAY,GAAG,OAAO;CACzE,OAAO;AACT;;;;;;;;ACJA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;CACxF,MAAM,SAA4B;EAAE,OAAO,CAAC;EAAG,cAAc,CAAC,GAAG,aAAa,KAAK,CAAC;EAAG,UAAU,CAAC;CAAE;CACpG,IAAI,aAAa,SAAS,GAAG,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAA+B;CAEvD,SAAS,OAAO,MAAc,MAAc,MAAc,MAA8C;EACtG,MAAM,MAAM,GAAG,KAAK,IAAI;EACxB,IAAI,YAAY,IAAI,GAAG,GAAG;GACxB,MAAM,aAAa,YAAY,IAAI,GAAG;GACtC,IAAI,eAAe,MAAM,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,UAAU,KAAK;GAAkC,CAAC;GAChI,OAAO,cAAc,KAAA;EACvB;EAEA,MAAM,OAAO,aAAa,IAAI,IAAI;EAClC,MAAM,aAAa,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,CAAC;EAC7E,IAAI,eAAe,KAAA,GAAW;GAC5B,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,sBAAsB,KAAK;GAA+D,CAAC;GAChJ;EACF;EAEA,Y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,MAAM,QAAQJ,aAAAA,SAAS,GAAG,CAAC,CAAC,QAAQ,SAAS,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,CAAC;CAC9E,OAAO,MAAM,SAAS,IAAI,CAACE,aAAAA,aAAa;EAAE,MAAM,IAAI;EAAM,GAAI,IAAI,QAAQ,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;EAAI;CAAM,CAAC,CAAC,IAAI,CAAC;AAC1H;AAGA,SAAS,aAAa,OAAoC,SAAgE;CACxH,OAAO,OAAO,KAAK,SAAmB;EAEpC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;EACjD,IAAI,KAAK,SAASC,kBAAAA,UAAU,OAAO,OAAO;EAE1C,MAAM,OAAO,EAAE,GAAG,KAAK;EACvB,KAAK,MAAM,SAASE,iBAAAA,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
@@ -1,9 +1,9 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
+ let node_crypto = require("node:crypto");
2
3
  let node_path = require("node:path");
4
+ const require_constants = require("./constants-BCRkFAiy.cjs");
3
5
  let node_process = require("node:process");
4
6
  const require_promise = require("./promise-DMQPWp6M.cjs");
5
- let node_crypto = require("node:crypto");
6
- const require_constants = require("./constants-BCRkFAiy.cjs");
7
7
  const require_nodeText = require("./nodeText-DH4dLGUb.cjs");
8
8
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
9
9
  node_process = require_rolldown_runtime.__toESM(node_process, 1);
@@ -108,17 +108,7 @@ function toDeprecatedExport(names) {
108
108
  asAlias: false
109
109
  };
110
110
  }
111
- // src/nodes/base.ts
112
- /** Builds a `createX` factory for a node whose only computed field is `kind`. */
113
- function nodeFactory(kind) {
114
- return (input) => {
115
- return {
116
- ...input,
117
- kind
118
- };
119
- };
120
- }
121
- // src/nodes/file.ts
111
+ // src/nodes/importExport.ts
122
112
  function overrideSpace(names, { value, derived }) {
123
113
  if (value == null || value === derived) return names;
124
114
  const space = value ? "type" : "value";
@@ -129,7 +119,6 @@ function overrideSpace(names, { value, derived }) {
129
119
  }
130
120
  const isOverride = ({ value, derived }) => value !== void 0 && JSON.stringify(value) !== JSON.stringify(derived);
131
121
  const DERIVED = Symbol.for("kubb.ast.derived");
132
- /** The deprecated fields the caller set: a value equal to the one the spread node derived is dropped, so `names` decides it. */
133
122
  function ownFields(input) {
134
123
  const snapshot = input[DERIVED];
135
124
  if (!snapshot) return {
@@ -146,15 +135,13 @@ function withoutDerived(input) {
146
135
  return rest;
147
136
  }
148
137
  /**
149
- * Creates an `ImportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
150
- * `isTypeOnly` that differs from the one `names` gives overrides it, so `{ ...imp, isTypeOnly: true }` still works.
151
- * Fields a spread copies over unchanged are not overrides, so `{ ...imp, names }` uses the new `names`.
138
+ * Creates an `ImportNode` and fills the deprecated `name` and `isTypeOnly` from `names`. A deprecated field
139
+ * that differs from the one `names` gives overrides it.
152
140
  *
153
- * @example Named import
154
- * ```ts
155
- * createImport({ names: [{ name: 'useState' }], path: 'react' })
156
- * // import { useState } from 'react'
157
- * ```
141
+ * A spread keeps the record of the derived fields only when the original node has one, which a node made
142
+ * from `names` does. For a node made without `names`, or a JSON or `structuredClone` copy, leave out `name`
143
+ * and `isTypeOnly` before you pass new `names`, or the old `name` replaces the new `names` and the old
144
+ * `isTypeOnly` sets their space.
158
145
  */
159
146
  function createImport(input) {
160
147
  if (!input.names) return {
@@ -190,15 +177,8 @@ function createImport(input) {
190
177
  };
191
178
  }
192
179
  /**
193
- * Creates an `ExportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
194
- * `isTypeOnly` that differs from the one `names` gives overrides it. Fields a spread copies over unchanged are not
195
- * overrides, so `{ ...exp, names }` uses the new `names`.
196
- *
197
- * @example Named export
198
- * ```ts
199
- * createExport({ names: [{ name: 'Pet' }], path: './Pet' })
200
- * // export { Pet } from './Pet'
201
- * ```
180
+ * Creates an `ExportNode`, with the deprecated fields of {@link createImport}. For a node made without
181
+ * `names`, or a JSON or `structuredClone` copy, leave out `name` and `isTypeOnly` before you pass new `names`.
202
182
  */
203
183
  function createExport(input) {
204
184
  if (!input.names) return {
@@ -233,92 +213,6 @@ function createExport(input) {
233
213
  kind: require_constants.nodeKinds.export
234
214
  };
235
215
  }
236
- /**
237
- * Creates a `SourceNode` representing a fragment of source code within a file.
238
- *
239
- * @example
240
- * ```ts
241
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
242
- * ```
243
- */
244
- const createSource = nodeFactory(require_constants.nodeKinds.source);
245
- /**
246
- * Creates a fully resolved `FileNode` from a file input descriptor.
247
- *
248
- * Computes:
249
- * - `id` SHA256 hash of the file path
250
- * - `name` `baseName` without extension
251
- * - `extname` extension extracted from `baseName`
252
- *
253
- * Deduplicates:
254
- * - `sources` via `combineSources`
255
- * - `exports` via `combineExports`
256
- * - `imports` via `combineImports` (also filters unused imports)
257
- *
258
- * @throws {Error} when `baseName` has no extension.
259
- *
260
- * @example
261
- * ```ts
262
- * const file = createFile({
263
- * baseName: 'petStore.ts',
264
- * path: 'src/models/petStore.ts',
265
- * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
266
- * imports: [createImport({ name: ['z'], path: 'zod' })],
267
- * exports: [createExport({ name: ['Pet'], path: './petStore' })],
268
- * })
269
- * // file.id = SHA256 hash of 'src/models/petStore.ts'
270
- * // file.name = 'petStore'
271
- * // file.extname = '.ts'
272
- * ```
273
- *
274
- * @example Copy a real file into the output
275
- * ```ts
276
- * const file = createFile({
277
- * baseName: 'client.ts',
278
- * path: 'src/gen/client.ts',
279
- * copy: '/abs/path/to/templates/client.ts',
280
- * })
281
- * ```
282
- */
283
- function createFile(input) {
284
- const extname = node_path.default.extname(input.baseName);
285
- if (!extname) throw new Error(`No extname found for ${input.baseName}`);
286
- const resolvedExports = input.exports?.length ? combineExports(input.exports) : [];
287
- const resolvedSources = input.sources?.length ? combineSources(input.sources) : [];
288
- const resolvedImports = (() => {
289
- if (!input.imports?.length) return [];
290
- const sourceParts = [];
291
- const localNames = /* @__PURE__ */ new Set();
292
- for (const item of resolvedSources) {
293
- const extracted = item.nodes && require_nodeText.getNodeText(item.nodes);
294
- if (extracted) sourceParts.push(extracted);
295
- if (item.name) localNames.add(item.name);
296
- }
297
- const source = sourceParts.join("\n") || void 0;
298
- return combineImports(input.imports, resolvedExports, source).flatMap((imp) => {
299
- if (imp.path === input.path) return [];
300
- const names = getNames(imp);
301
- const kept = names.filter((item) => !localNames.has(item.alias ?? item.name));
302
- if (!kept.length) return [];
303
- return [kept.length === names.length ? imp : createImport({
304
- path: imp.path,
305
- ...imp.root != null ? { root: imp.root } : {},
306
- names: kept
307
- })];
308
- });
309
- })();
310
- return {
311
- ...input,
312
- kind: require_constants.nodeKinds.file,
313
- id: (0, node_crypto.hash)("sha256", input.path, "hex"),
314
- name: node_path.default.basename(input.baseName, extname),
315
- extname,
316
- imports: resolvedImports,
317
- exports: resolvedExports,
318
- sources: resolvedSources,
319
- meta: input.meta ?? {}
320
- };
321
- }
322
216
  // src/utils/combineFileMembers.ts
323
217
  /**
324
218
  * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and
@@ -326,7 +220,26 @@ function createFile(input) {
326
220
  * `combineImports` also drops imports nothing references. This works on a file's members, not on
327
221
  * schema content.
328
222
  */
329
- const IDENTIFIER_RUN = /[\w$]+/g;
223
+ const IDENTIFIER_RUN = /[\p{ID_Continue}$\u200C\u200D]+/gu;
224
+ const IDENTIFIER_CHAR = /[\p{ID_Continue}$\u200C\u200D]/u;
225
+ function codePointBefore({ source, index }) {
226
+ return [...source.slice(Math.max(0, index - 2), index)].at(-1);
227
+ }
228
+ function codePointAt({ source, index }) {
229
+ const point = source.codePointAt(index);
230
+ return point === void 0 ? void 0 : String.fromCodePoint(point);
231
+ }
232
+ function occursAsIdentifier({ source, name }) {
233
+ const isPart = (char) => char !== void 0 && IDENTIFIER_CHAR.test(char);
234
+ for (let index = source.indexOf(name); index !== -1; index = source.indexOf(name, index + 1)) if (!isPart(codePointBefore({
235
+ source,
236
+ index
237
+ })) && !isPart(codePointAt({
238
+ source,
239
+ index: index + name.length
240
+ }))) return true;
241
+ return false;
242
+ }
330
243
  /**
331
244
  * How many imports a file needs before indexing the source beats scanning it once per name.
332
245
  */
@@ -451,13 +364,17 @@ function combineExports(exports) {
451
364
  /**
452
365
  * Deduplicates and merges `ImportNode` objects, filtering out unused imports.
453
366
  *
454
- * Retains imports that are referenced in `source` or re-exported. One import per path, form and space. Returns
455
- * a sorted, deduplicated, filtered array.
367
+ * Retains imports whose local name occurs in `source` as a whole identifier, or that are re-exported. A name
368
+ * that only occurs inside a longer identifier, such as `Pet` in `PetStatus`, counts as unused. One import per path,
369
+ * form and space. Returns a sorted, deduplicated, filtered array.
456
370
  */
457
371
  function combineImports(imports, exports, source) {
458
372
  const exportedNames = new Set(exports.flatMap((node) => getNames(node).map((item) => item.alias ?? item.name)));
459
373
  const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? new Set(source.match(IDENTIFIER_RUN)) : null;
460
- const isUsed = (importName) => !source || identifiers?.has(importName) || source.includes(importName) || exportedNames.has(importName);
374
+ const isUsed = (importName) => !source || exportedNames.has(importName) || (identifiers ? identifiers.has(importName) : occursAsIdentifier({
375
+ source,
376
+ name: importName
377
+ }));
461
378
  const statements = toStatements(imports.filter((node) => node.path !== node.root), importForm);
462
379
  const pathsWithUsedNamedImport = new Set(statements.filter(({ form, names }) => form === "named" && names.some((item) => isUsed(item.alias ?? item.name))).map(({ path }) => path));
463
380
  const keep = (item, { form, path }) => isUsed(item.alias ?? item.name) || form !== "named" && pathsWithUsedNamedImport.has(path);
@@ -467,6 +384,103 @@ function combineImports(imports, exports, source) {
467
384
  names
468
385
  }));
469
386
  }
387
+ // src/nodes/base.ts
388
+ /** Builds a `createX` factory for a node whose only computed field is `kind`. */
389
+ function nodeFactory(kind) {
390
+ return (input) => {
391
+ return {
392
+ ...input,
393
+ kind
394
+ };
395
+ };
396
+ }
397
+ // src/nodes/file.ts
398
+ /**
399
+ * Creates a `SourceNode` representing a fragment of source code within a file.
400
+ *
401
+ * @example
402
+ * ```ts
403
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
404
+ * ```
405
+ */
406
+ const createSource = nodeFactory(require_constants.nodeKinds.source);
407
+ /**
408
+ * Creates a fully resolved `FileNode` from a file input descriptor.
409
+ *
410
+ * Computes:
411
+ * - `id` SHA256 hash of the file path
412
+ * - `name` `baseName` without extension
413
+ * - `extname` extension extracted from `baseName`
414
+ *
415
+ * Deduplicates:
416
+ * - `sources` via `combineSources`
417
+ * - `exports` via `combineExports`
418
+ * - `imports` via `combineImports` (also filters unused imports)
419
+ *
420
+ * @throws {Error} when `baseName` has no extension.
421
+ *
422
+ * @example
423
+ * ```ts
424
+ * const file = createFile({
425
+ * baseName: 'petStore.ts',
426
+ * path: 'src/models/petStore.ts',
427
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
428
+ * imports: [createImport({ names: [{ name: 'z' }], path: 'zod' })],
429
+ * exports: [createExport({ names: [{ name: 'Pet' }], path: './petStore' })],
430
+ * })
431
+ * // file.id = SHA256 hash of 'src/models/petStore.ts'
432
+ * // file.name = 'petStore'
433
+ * // file.extname = '.ts'
434
+ * ```
435
+ *
436
+ * @example Copy a real file into the output
437
+ * ```ts
438
+ * const file = createFile({
439
+ * baseName: 'client.ts',
440
+ * path: 'src/gen/client.ts',
441
+ * copy: '/abs/path/to/templates/client.ts',
442
+ * })
443
+ * ```
444
+ */
445
+ function createFile(input) {
446
+ const extname = node_path.default.extname(input.baseName);
447
+ if (!extname) throw new Error(`No extname found for ${input.baseName}`);
448
+ const resolvedExports = input.exports?.length ? combineExports(input.exports) : [];
449
+ const resolvedSources = input.sources?.length ? combineSources(input.sources) : [];
450
+ const resolvedImports = (() => {
451
+ if (!input.imports?.length) return [];
452
+ const sourceParts = [];
453
+ const localNames = /* @__PURE__ */ new Set();
454
+ for (const item of resolvedSources) {
455
+ const extracted = item.nodes && require_nodeText.getNodeText(item.nodes);
456
+ if (extracted) sourceParts.push(extracted);
457
+ if (item.name) localNames.add(item.name);
458
+ }
459
+ const source = sourceParts.join("\n") || void 0;
460
+ return combineImports(input.imports, resolvedExports, source).flatMap((imp) => {
461
+ if (imp.path === input.path) return [];
462
+ const names = getNames(imp);
463
+ const kept = names.filter((item) => !localNames.has(item.alias ?? item.name));
464
+ if (!kept.length) return [];
465
+ return [kept.length === names.length ? imp : createImport({
466
+ path: imp.path,
467
+ ...imp.root != null ? { root: imp.root } : {},
468
+ names: kept
469
+ })];
470
+ });
471
+ })();
472
+ return {
473
+ ...input,
474
+ kind: require_constants.nodeKinds.file,
475
+ id: (0, node_crypto.hash)("sha256", input.path, "hex"),
476
+ name: node_path.default.basename(input.baseName, extname),
477
+ extname,
478
+ imports: resolvedImports,
479
+ exports: resolvedExports,
480
+ sources: resolvedSources,
481
+ meta: input.meta ?? {}
482
+ };
483
+ }
470
484
  Object.defineProperty(exports, "createExport", {
471
485
  enumerable: true,
472
486
  get: function() {
@@ -522,4 +536,4 @@ Object.defineProperty(exports, "nodeFactory", {
522
536
  }
523
537
  });
524
538
 
525
- //# sourceMappingURL=combineFileMembers-DZCKxAN0.cjs.map
539
+ //# sourceMappingURL=file-Db_PYobC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-Db_PYobC.cjs","names":["nodeKinds","memo","path","process","nodeKinds","path","getNodeText","hash"],"sources":["../src/utils/moduleNames.ts","../src/nodes/importExport.ts","../src/utils/combineFileMembers.ts","../src/nodes/base.ts","../src/nodes/file.ts"],"sourcesContent":["import type { ExportNode, ImportNode, ModuleName, SourceNode, Space } from '../nodes/file.ts'\n\n/**\n * Returns the names an import or export brings across. A node built with the deprecated fields gets them from\n * those, each with an explicit `space`, so it prints exactly as before.\n */\nexport function getNames(node: ImportNode | ExportNode): Array<ModuleName> {\n if (node.names) return node.names\n return node.kind === 'Import' ? fromDeprecatedImport(node) : fromDeprecatedExport(node)\n}\n\n/**\n * Returns `true` when a source is an exported declaration. Reads the deprecated `isIndexable` and `isExportable`, in that order, when `export` is unset.\n */\nexport function isExported(source: Pick<SourceNode, 'export' | 'isIndexable' | 'isExportable'>): boolean {\n return !!(source.export ?? source.isIndexable ?? source.isExportable)\n}\n\nexport function getSpace(source: SourceNode): Space {\n if (source.space) return source.space\n if (source.isTypeOnly != null) return source.isTypeOnly ? 'type' : 'value'\n return source.nodes?.[0]?.kind === 'Type' ? 'type' : 'value'\n}\n\nexport type DeprecatedImport = Pick<ImportNode, 'name' | 'isTypeOnly' | 'isNameSpace'>\nexport type DeprecatedExport = Pick<ExportNode, 'name' | 'isTypeOnly' | 'asAlias'>\n\n/**\n * @deprecated Converts a node built with `name`, `isTypeOnly` and `isNameSpace` to `names`. Removed in Kubb v6.\n */\nfunction fromDeprecatedImport({ name, isTypeOnly, isNameSpace }: DeprecatedImport): Array<ModuleName> {\n const space: Space = isTypeOnly ? 'type' : 'value'\n if (!Array.isArray(name)) return [{ name: isNameSpace ? '*' : 'default', alias: name, space }]\n return name.map((item) => (typeof item === 'string' ? { name: item, space } : { name: item.propertyName, ...(item.name ? { alias: item.name } : {}), space }))\n}\n\n/**\n * @deprecated Converts a node built with `name`, `isTypeOnly` and `asAlias` to `names`. Removed in Kubb v6.\n */\nfunction fromDeprecatedExport({ name, isTypeOnly, asAlias }: DeprecatedExport): Array<ModuleName> {\n const space: Space = isTypeOnly ? 'type' : 'value'\n if (name == null) return [{ name: '*', space }]\n if (!Array.isArray(name)) return [asAlias ? { name: '*', alias: name, space } : { name, space }]\n return name.map((item) => ({ name: item, space }))\n}\n\n/**\n * @deprecated The old import fields for `names`, for code that still reads them. Removed in Kubb v6.\n */\nexport function toDeprecatedImport(names: ReadonlyArray<ModuleName>): DeprecatedImport {\n const isTypeOnly = names.length > 0 && names.every((item) => item.space === 'type')\n const [first] = names\n if (names.length === 1 && first?.alias && (first.name === '*' || first.name === 'default')) {\n return { name: first.alias, isTypeOnly, isNameSpace: first.name === '*' }\n }\n return { name: names.map((item) => (item.alias ? { propertyName: item.name, name: item.alias } : item.name)), isTypeOnly, isNameSpace: false }\n}\n\n/**\n * @deprecated The old export fields for `names`; an alias stands in for its name. Removed in Kubb v6.\n */\nexport function toDeprecatedExport(names: ReadonlyArray<ModuleName>): DeprecatedExport {\n const isTypeOnly = names.length > 0 && names.every((item) => item.space === 'type')\n const [first] = names\n if (names.length === 1 && first?.name === '*') {\n return first.alias ? { name: first.alias, isTypeOnly, asAlias: true } : { isTypeOnly, asAlias: false }\n }\n return { name: names.map((item) => item.alias ?? item.name), isTypeOnly, asAlias: false }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { toDeprecatedExport, toDeprecatedImport } from '../utils/moduleNames.ts'\nimport type { ExportInput, ExportNode, ImportInput, ImportNode, ModuleName } from './file.ts'\n\ntype Override<TValue> = { value: TValue | null | undefined; derived: TValue | null | undefined }\n\nfunction overrideSpace(names: Array<ModuleName>, { value, derived }: Override<boolean>): Array<ModuleName> {\n if (value == null || value === derived) return names\n const space = value ? 'type' : 'value'\n return names.map((item) => ({ ...item, space }))\n}\n\nconst isOverride = ({ value, derived }: Override<unknown>): boolean => value !== undefined && JSON.stringify(value) !== JSON.stringify(derived)\n\n// Object spread copies symbol keys, so `{ ...imp, names }` carries the fields `imp` derived and they can be told apart from an override.\nconst DERIVED = Symbol.for('kubb.ast.derived')\n// `name` is stored as JSON, so changing the node's `name` array in place still counts as an override.\ntype Derived = { name: string | undefined; isTypeOnly?: boolean | null }\ntype WithDerived = { [DERIVED]?: Derived }\n\nfunction ownFields<TName>(input: { name?: TName; isTypeOnly?: boolean | null } & WithDerived): { name?: TName; isTypeOnly?: boolean | null } {\n const snapshot = input[DERIVED]\n if (!snapshot) return { name: input.name, isTypeOnly: input.isTypeOnly }\n return {\n name: JSON.stringify(input.name) === snapshot.name ? undefined : input.name,\n isTypeOnly: input.isTypeOnly === snapshot.isTypeOnly ? undefined : input.isTypeOnly,\n }\n}\n\nfunction withoutDerived<T extends object>(input: T): T {\n const { [DERIVED]: _, ...rest } = input as T & WithDerived\n return rest as T\n}\n\n/**\n * Creates an `ImportNode` and fills the deprecated `name` and `isTypeOnly` from `names`. A deprecated field\n * that differs from the one `names` gives overrides it.\n *\n * A spread keeps the record of the derived fields only when the original node has one, which a node made\n * from `names` does. For a node made without `names`, or a JSON or `structuredClone` copy, leave out `name`\n * and `isTypeOnly` before you pass new `names`, or the old `name` replaces the new `names` and the old\n * `isTypeOnly` sets their space.\n */\nexport function createImport(input: ImportInput): ImportNode {\n if (!input.names) return { ...withoutDerived(input), name: input.name ?? [], kind: nodeKinds.import }\n const own = ownFields(input)\n const derived = toDeprecatedImport(input.names)\n if (isOverride({ value: own.name, derived: derived.name })) return { ...withoutDerived(input), names: null, name: own.name ?? [], kind: nodeKinds.import }\n const names = overrideSpace(input.names, { value: own.isTypeOnly, derived: derived.isTypeOnly })\n const fields = toDeprecatedImport(names)\n const node: ImportNode & WithDerived = {\n ...input,\n ...fields,\n names,\n [DERIVED]: { name: JSON.stringify(fields.name), isTypeOnly: fields.isTypeOnly },\n kind: nodeKinds.import,\n }\n return node\n}\n\n/**\n * Creates an `ExportNode`, with the deprecated fields of {@link createImport}. For a node made without\n * `names`, or a JSON or `structuredClone` copy, leave out `name` and `isTypeOnly` before you pass new `names`.\n */\nexport function createExport(input: ExportInput): ExportNode {\n if (!input.names) return { ...withoutDerived(input), kind: nodeKinds.export }\n const own = ownFields(input)\n const derived = toDeprecatedExport(input.names)\n if (isOverride({ value: own.name, derived: derived.name })) return { ...withoutDerived(input), name: own.name, names: null, kind: nodeKinds.export }\n const names = overrideSpace(input.names, { value: own.isTypeOnly, derived: derived.isTypeOnly })\n const fields = toDeprecatedExport(names)\n const node: ExportNode & WithDerived = {\n ...input,\n ...fields,\n name: fields.name,\n names,\n [DERIVED]: { name: JSON.stringify(fields.name), isTypeOnly: fields.isTypeOnly },\n kind: nodeKinds.export,\n }\n return node\n}\n","/**\n * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and\n * export entries of one file, while `combineSources` deduplicates source entries in original order.\n * `combineImports` also drops imports nothing references. This works on a file's members, not on\n * schema content.\n */\nimport path from 'node:path'\nimport process from 'node:process'\nimport { memo } from '@internals/utils'\nimport type { ExportNode, ImportNode, ModuleName, SourceNode, Space } from '../nodes/file.ts'\nimport { createExport, createImport } from '../nodes/importExport.ts'\nimport { getNames, getSpace, isExported } from './moduleNames.ts'\n\n// The characters that continue a JavaScript identifier, so `éPet` and `PetStatus` are one identifier each, not a use of `Pet`.\nconst IDENTIFIER_RUN = /[\\p{ID_Continue}$\\u200C\\u200D]+/gu\nconst IDENTIFIER_CHAR = /[\\p{ID_Continue}$\\u200C\\u200D]/u\n\n// Whole code points, so a surrogate pair such as `𐐀` counts as the one character it is.\nfunction codePointBefore({ source, index }: { source: string; index: number }): string | undefined {\n return [...source.slice(Math.max(0, index - 2), index)].at(-1)\n}\n\nfunction codePointAt({ source, index }: { source: string; index: number }): string | undefined {\n const point = source.codePointAt(index)\n return point === undefined ? undefined : String.fromCodePoint(point)\n}\n\nfunction occursAsIdentifier({ source, name }: { source: string; name: string }): boolean {\n const isPart = (char: string | undefined) => char !== undefined && IDENTIFIER_CHAR.test(char)\n for (let index = source.indexOf(name); index !== -1; index = source.indexOf(name, index + 1)) {\n if (!isPart(codePointBefore({ source, index })) && !isPart(codePointAt({ source, index: index + name.length }))) return true\n }\n return false\n}\n\n/**\n * How many imports a file needs before indexing the source beats scanning it once per name.\n */\nconst INDEX_ABOVE_IMPORTS = 128\n\ntype Form = 'named' | 'default' | '*'\n\ntype Statement = { path: string; root?: string | null; form: Form; space: Space; names: Array<ModuleName> }\n\nconst importForm = (item: ModuleName): Form => (item.alias && (item.name === '*' || item.name === 'default') ? item.name : 'named')\nconst exportForm = (item: ModuleName): Form => (item.name === '*' ? '*' : 'named')\nconst label = (item: ModuleName): string => (item.alias ? `${item.name} as ${item.alias}` : item.name)\n\nfunction statementKey({ path, form, space, names }: Statement): string {\n return form === 'named' ? `${path}\\0named\\0${space}` : `${path}\\0${form}\\0${names[0]?.alias ?? ''}\\0${space}`\n}\n\nfunction toStatements(nodes: ReadonlyArray<ImportNode | ExportNode>, formOf: (item: ModuleName) => Form): Array<Statement> {\n return nodes.flatMap((node) => {\n const statements = new Map<string, Statement>()\n for (const item of getNames(node)) {\n const statement: Statement = {\n path: node.path,\n root: node.kind === 'Import' ? node.root : undefined,\n form: formOf(item),\n space: item.space ?? 'value',\n names: [],\n }\n const key = statementKey({ ...statement, names: [item] })\n const existing = statements.get(key) ?? statement\n statements.set(key, existing)\n existing.names.push(item)\n }\n return [...statements.values()]\n })\n}\n\n/**\n * Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every\n * merge, and the path math dominated that sort on large specs. Two levels keep the existing strings\n * as keys, so lookups reuse their hashes instead of hashing a new joined key each time.\n */\nconst specifierCache = memo.create<string, Map<string, string>>({ max: 10_000 })\n\n/**\n * Module specifier that imports `filePath` from the file at `root`: POSIX, relative to that file's directory, `./`-prefixed unless it climbs with `../`.\n *\n * @example\n * ```ts\n * getRelativePath('/root/src/models/pet.ts', '/root/lib/client.ts') // '../../lib/client.ts'\n * ```\n */\nexport function getRelativePath(root: string, filePath: string): string {\n // A relative input resolves against the working directory, so that directory is part of its key.\n const rootKey = path.isAbsolute(root) && path.isAbsolute(filePath) ? root : `${process.cwd()}\\u0000${root}`\n const byPath = memo(specifierCache, rootKey, () => new Map<string, string>())\n return memo(byPath, filePath, () => {\n const relative = path.relative(path.dirname(root), filePath).replaceAll('\\\\', '/')\n return relative.startsWith('../') ? relative : `./${relative}`\n })\n}\n\n/** The specifier a member is written with, so sorting on it gives the same order on every OS. */\nfunction specifier(node: { path: string; root?: string | null }): string {\n return node.root ? getRelativePath(node.root, node.path) : node.path\n}\n\nfunction sortKey(statement: Statement): string {\n const form = statement.form === 'named' ? '1' : '0'\n const space = statement.space === 'type' ? '0' : '1'\n return `${form}:${space}:${specifier(statement)}:${statement.names.map(label).toSorted().join('\\0')}`\n}\n\nfunction mergeStatements(statements: Array<Statement>, keep: (item: ModuleName, statement: Statement) => boolean = () => true): Array<Statement> {\n const merged = new Map<string, { statement: Statement; seen: Set<string> }>()\n const sorted = statements.map((statement) => ({ statement, key: sortKey(statement) })).sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n\n for (const { statement } of sorted) {\n const key = statementKey(statement)\n const entry = merged.get(key) ?? { statement: { ...statement, names: [] }, seen: new Set<string>() }\n merged.set(key, entry)\n for (const item of statement.names) {\n const id = item.alias ?? item.name\n if (entry.seen.has(id) || !keep(item, statement)) continue\n entry.seen.add(id)\n entry.statement.names.push(item)\n }\n }\n\n const result = [...merged.values()].map(({ statement }) => statement)\n // A name kept as a value also serves its type uses, so a type statement from the same path must not bind it again.\n const bound = ({ path, item }: { path: string; item: ModuleName }) => `${path}\\0${item.alias ?? item.name}`\n const values = new Set(result.filter(({ space }) => space === 'value').flatMap(({ path, names }) => names.map((item) => bound({ path, item }))))\n return result\n .map((statement) =>\n statement.space === 'type' ? { ...statement, names: statement.names.filter((item) => !values.has(bound({ path: statement.path, item }))) } : statement,\n )\n .filter((statement) => statement.names.length > 0)\n}\n\n/**\n * Deduplicates `SourceNode` objects by `name + export + space`, keeping the first of each\n * key. An unnamed source only drops when the same node appears twice, so markdown can repeat a\n * paragraph or a table. Returns the deduplicated array in original order.\n */\nexport function combineSources(sources: Array<SourceNode>): Array<SourceNode> {\n const seen = new Set<SourceNode | string>()\n return sources.filter((source) => {\n const key = source.name != null ? `${source.name}:${isExported(source)}:${getSpace(source)}` : source\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\n/**\n * Deduplicates and merges `ExportNode` objects: one export per path, form and space. Returns a sorted array.\n */\nexport function combineExports(exports: Array<ExportNode>): Array<ExportNode> {\n // Built through `createExport`, so a later `{ ...exp, names }` keeps the new names.\n return mergeStatements(toStatements(exports, exportForm)).map(({ path, names }) => createExport({ path, names }))\n}\n\n/**\n * Deduplicates and merges `ImportNode` objects, filtering out unused imports.\n *\n * Retains imports whose local name occurs in `source` as a whole identifier, or that are re-exported. A name\n * that only occurs inside a longer identifier, such as `Pet` in `PetStatus`, counts as unused. One import per path,\n * form and space. Returns a sorted, deduplicated, filtered array.\n */\nexport function combineImports(imports: Array<ImportNode>, exports: Array<ExportNode>, source?: string): Array<ImportNode> {\n // Build a lookup of all exported names to retain imports that are re-exported\n const exportedNames = new Set(exports.flatMap((node) => getNames(node).map((item) => item.alias ?? item.name)))\n // `createFile` re-runs on every merge into a file, so scanning the source once per import name\n // costs a heavily merged file that scan again for every fragment it already holds. Indexing pays\n // for itself there, and costs more than it saves on the small files the default output produces.\n const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? new Set(source.match(IDENTIFIER_RUN)) : null\n\n const isUsed = (importName: string): boolean =>\n !source || exportedNames.has(importName) || (identifiers ? identifiers.has(importName) : occursAsIdentifier({ source, name: importName }))\n\n const statements = toStatements(\n imports.filter((node) => node.path !== node.root),\n importForm,\n )\n\n // Paths that keep at least one used named import. A default import from such a path is retained\n // even when its binding can't be found in `source` e.g. a generated `client` default import\n // alongside `import type { Client } from <same path>`, where merged grouped output omits the body.\n const pathsWithUsedNamedImport = new Set(\n statements.filter(({ form, names }) => form === 'named' && names.some((item) => isUsed(item.alias ?? item.name))).map(({ path }) => path),\n )\n const keep = (item: ModuleName, { form, path }: Statement) => isUsed(item.alias ?? item.name) || (form !== 'named' && pathsWithUsedNamedImport.has(path))\n\n return mergeStatements(statements, keep).map(({ path, root, names }) => createImport({ path, ...(root != null ? { root } : {}), names }))\n}\n","import type { ValueOf } from '@internals/utils'\nimport type { nodeKinds } from '../constants.ts'\n\n/**\n * `kind` values used by AST nodes.\n *\n * @example\n * ```ts\n * const kind: NodeKind = 'Schema'\n * ```\n */\nexport type NodeKind = ValueOf<typeof nodeKinds>\n\n/**\n * Base shape shared by all AST nodes.\n *\n * @example\n * ```ts\n * const base: BaseNode = { kind: 'Input' }\n * ```\n */\nexport type BaseNode = {\n /**\n * Node discriminator.\n */\n kind: NodeKind\n /**\n * Where the node comes from in the input, in the form the adapter's `locate` reads. Document\n * adapters such as OpenAPI and AsyncAPI use an RFC 6901 JSON pointer, for example\n * `#/components/schemas/Pet`. Plugins can copy it to the code nodes they emit.\n */\n pointer?: string\n}\n\n/** `Omit` applied to each member of a union, so the union survives. */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** Builds a `createX` factory for a node whose only computed field is `kind`. */\nexport function nodeFactory<T extends BaseNode>(kind: T['kind']): (input: Omit<T, 'kind'>) => T {\n return (input) => {\n const node = { ...input, kind }\n return node as T\n }\n}\n","import { hash } from 'node:crypto'\nimport path from 'node:path'\nimport { nodeKinds } from '../constants.ts'\nimport { combineExports, combineImports, combineSources } from '../utils/combineFileMembers.ts'\nimport { getNames } from '../utils/moduleNames.ts'\nimport { getNodeText } from '../utils/nodeText.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { CodeNode } from './code.ts'\nimport { createExport, createImport } from './importExport.ts'\n\nexport { createExport, createImport }\n\n/**\n * Supported file extensions.\n */\nexport type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\nexport type ImportName = string | Array<string | { propertyName: string; name?: string }>\n\n/**\n * Whether a declaration exists only at compile time (`'type'`) or also at runtime (`'value'`).\n */\nexport type Space = 'type' | 'value'\n\n/**\n * One name an import or export brings across, as in the ECMAScript `ImportEntry` record.\n */\nexport type ModuleName = {\n /**\n * Name in the other module: `'default'` for its default export, `'*'` for the whole module.\n */\n name: string\n /**\n * Local name for an import, or the exported name for an export.\n */\n alias?: string | null\n /**\n * Type or value.\n * @default 'value'\n */\n space?: Space | null\n}\n\n/**\n * Represents a language-agnostic import/dependency declaration.\n *\n * @example Named import (TypeScript: `import { useState } from 'react'`)\n * ```ts\n * createImport({ names: [{ name: 'useState' }], path: 'react' })\n * ```\n *\n * @example Default import (TypeScript: `import React from 'react'`)\n * ```ts\n * createImport({ names: [{ name: 'default', alias: 'React' }], path: 'react' })\n * ```\n *\n * @example Type-only import (TypeScript: `import type { FC } from 'react'`)\n * ```ts\n * createImport({ names: [{ name: 'FC', space: 'type' }], path: 'react' })\n * ```\n *\n * @example Namespace import (TypeScript: `import * as React from 'react'`)\n * ```ts\n * createImport({ names: [{ name: '*', alias: 'React' }], path: 'react' })\n * ```\n */\nexport type ImportNode = BaseNode & {\n kind: 'Import'\n /**\n * The names the import brings in. `ast.file.getNames` also reads the deprecated fields.\n */\n names?: Array<ModuleName> | null\n /**\n * Import name(s) to be used.\n *\n * @deprecated Use `names`. Removed in Kubb v6.\n */\n name: ImportName\n /**\n * Path for the import.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only import prefix.\n *\n * @deprecated Set `space: 'type'` on each name. Removed in Kubb v6.\n */\n isTypeOnly?: boolean | null\n /**\n * Import the entire module as a namespace.\n *\n * @deprecated Use `{ name: '*', alias }` in `names`. Removed in Kubb v6.\n */\n isNameSpace?: boolean | null\n /**\n * When set, the import path is resolved relative to this root.\n */\n root?: string | null\n}\n\n/**\n * Represents a language-agnostic export/public API declaration.\n *\n * @example Named export (TypeScript: `export { Pets } from './Pets'`)\n * ```ts\n * createExport({ names: [{ name: 'Pets' }], path: './Pets' })\n * ```\n *\n * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)\n * ```ts\n * createExport({ names: [{ name: 'Pet', space: 'type' }], path: './Pet' })\n * ```\n *\n * @example Wildcard export (TypeScript: `export * from './utils'`)\n * ```ts\n * createExport({ names: [{ name: '*' }], path: './utils' })\n * ```\n *\n * @example Namespace alias (TypeScript: `export * as utils from './utils'`)\n * ```ts\n * createExport({ names: [{ name: '*', alias: 'utils' }], path: './utils' })\n * ```\n */\nexport type ExportNode = BaseNode & {\n kind: 'Export'\n /**\n * The names the export passes on. `ast.file.getNames` also reads the deprecated fields.\n */\n names?: Array<ModuleName> | null\n /**\n * Export name(s) to be used. When omitted, generates a wildcard export.\n *\n * @deprecated Use `names`. Removed in Kubb v6.\n */\n name?: string | Array<string> | null\n /**\n * Path for the export.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only export prefix.\n *\n * @deprecated Set `space: 'type'` on each name. Removed in Kubb v6.\n */\n isTypeOnly?: boolean | null\n /**\n * Export as an aliased namespace.\n *\n * @deprecated Use `{ name: '*', alias }` in `names`. Removed in Kubb v6.\n */\n asAlias?: boolean | null\n}\n\n/**\n * Represents a fragment of source code within a file.\n *\n * @example Named exportable source\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n *\n * @example Inline unnamed code block\n * ```ts\n * createSource({ nodes: [createText('const x = 1')] })\n * ```\n */\nexport type SourceNode = BaseNode & {\n kind: 'Source'\n /**\n * Optional name identifying this source (used for deduplication and barrel generation).\n */\n name?: string | null\n /**\n * Type or value. When unset, a source whose first node is a `Type` is a type.\n */\n space?: Space | null\n /**\n * Mark this source as a type-only export.\n *\n * @deprecated Use `space: 'type'`. Removed in Kubb v6.\n */\n isTypeOnly?: boolean | null\n /**\n * Mark this source as an exported declaration, which barrels list. The source text carries its own `export` keyword.\n */\n export?: boolean | null\n /**\n * Mark this exported source as the module's default export. Barrels skip it, since they can't re-export it by name.\n */\n default?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isExportable?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isIndexable?: boolean | null\n /**\n * Marks the source as a definition that importing files absorb instead of import. `expression` is\n * the declaration's right-hand side, such as `{ body: Pet }`.\n *\n * @deprecated Set `inline` on the file. Removed in Kubb v6.\n */\n inline?: { expression: string } | null\n /**\n * Child nodes that make up this source fragment, in DOM order.\n * Use a {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * Represents a fully resolved file in the AST.\n *\n * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input\n * and deduplicates `imports`, `exports`, and `sources`.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })],\n * imports: [createImport({ names: [{ name: 'z' }], path: 'zod' })],\n * exports: [createExport({ names: [{ name: 'Pet' }], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of the path\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n */\nexport type FileNode<TMeta extends object = object> = BaseNode & {\n kind: 'File'\n /**\n * Unique identifier derived from a SHA256 hash of the file path. `createFile`\n * computes it, so callers do not need to provide it.\n */\n id: string\n /**\n * File name without extension, derived from `baseName`.\n *\n * @see https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n /**\n * File base name, including extension, shaped like `${name}${extname}`.\n *\n * @see https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: `${string}.${string}`\n /**\n * Full qualified path to the file.\n */\n path: string\n /**\n * File extension extracted from `baseName`.\n */\n extname: Extname\n /**\n * Deduplicated list of source code fragments.\n */\n sources: Array<SourceNode>\n /**\n * Deduplicated list of import declarations.\n */\n imports: Array<ImportNode>\n /**\n * Deduplicated list of export declarations.\n */\n exports: Array<ExportNode>\n /**\n * Optional metadata attached to this file, read by plugins during barrel generation.\n */\n meta?: TMeta\n /**\n * Optional banner prepended to the generated file content.\n * Accepts `null` so `resolver.default.banner()` results can be passed directly.\n */\n banner?: string | null\n /**\n * Optional footer appended to the generated file content.\n * Accepts `null` so `resolver.default.footer()` results can be passed directly.\n */\n footer?: string | null\n /**\n * Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has one.\n *\n * Use to emit a real source file shipped inside a package (a template) into the generated\n * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for\n * output; `sources` may still carry `name`/`export` so barrel generation\n * treats the file the same as a rendered one.\n */\n copy?: string | null\n /**\n * Marks a file that is never written. Each file that imports from it gets the body of each imported declaration, such as `{ body: Pet }`, in place of its name.\n */\n inline?: boolean | null\n}\n\nexport type ImportInput = Omit<ImportNode, 'kind' | 'name'> & { name?: ImportName }\n\nexport type ExportInput = Omit<ExportNode, 'kind'>\n\n/**\n * Creates a `SourceNode` representing a fragment of source code within a file.\n *\n * @example\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n */\nexport const createSource = nodeFactory<SourceNode>(nodeKinds.source)\n\n/**\n * Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed\n * and `imports`/`exports`/`sources` are deduplicated.\n */\nexport type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> &\n Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>\n\n/**\n * Creates a fully resolved `FileNode` from a file input descriptor.\n *\n * Computes:\n * - `id` SHA256 hash of the file path\n * - `name` `baseName` without extension\n * - `extname` extension extracted from `baseName`\n *\n * Deduplicates:\n * - `sources` via `combineSources`\n * - `exports` via `combineExports`\n * - `imports` via `combineImports` (also filters unused imports)\n *\n * @throws {Error} when `baseName` has no extension.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],\n * imports: [createImport({ names: [{ name: 'z' }], path: 'zod' })],\n * exports: [createExport({ names: [{ name: 'Pet' }], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of 'src/models/petStore.ts'\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n *\n * @example Copy a real file into the output\n * ```ts\n * const file = createFile({\n * baseName: 'client.ts',\n * path: 'src/gen/client.ts',\n * copy: '/abs/path/to/templates/client.ts',\n * })\n * ```\n */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const extname = path.extname(input.baseName) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n // Skip building the source text and local-name set when there are no imports to resolve against them.\n const resolvedImports: Array<ImportNode> = (() => {\n if (!input.imports?.length) return []\n\n const sourceParts: Array<string> = []\n const localNames = new Set<string>()\n // Only the sources the file keeps count: an import used just by a dropped duplicate is unused.\n for (const item of resolvedSources) {\n const extracted = item.nodes && getNodeText(item.nodes)\n if (extracted) sourceParts.push(extracted)\n if (item.name) localNames.add(item.name)\n }\n const source = sourceParts.join('\\n') || undefined\n const combinedImports = combineImports(input.imports, resolvedExports, source)\n // Consolidating output (`mode: 'file'`) can put a symbol's definition and an import of it in the\n // same file: by path when the import still targets this file, by name when consolidation moved it.\n return combinedImports.flatMap((imp) => {\n if (imp.path === input.path) return []\n const names = getNames(imp)\n const kept = names.filter((item) => !localNames.has(item.alias ?? item.name))\n if (!kept.length) return []\n return [kept.length === names.length ? imp : createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names: kept })]\n })\n })()\n\n return {\n ...input,\n kind: nodeKinds.file,\n id: hash('sha256', input.path, 'hex'),\n name: path.basename(input.baseName, extname),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,\n sources: resolvedSources,\n meta: (input.meta ?? {}) as TMeta,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,SAAS,MAAkD;CACzE,IAAI,KAAK,OAAO,OA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