@kubb/ast 5.23.3 → 5.23.5

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 (79) hide show
  1. package/dist/factory.cjs +2 -2
  2. package/dist/factory.d.cts +4 -4
  3. package/dist/factory.d.ts +4 -4
  4. package/dist/factory.js +2 -2
  5. package/dist/{file-KunZhFIV.d.cts → file-B269mZh4.d.cts} +67 -33
  6. package/dist/file-Bq2GPaxh.js +427 -0
  7. package/dist/file-Bq2GPaxh.js.map +1 -0
  8. package/dist/file-C4pqV8yl.cjs +469 -0
  9. package/dist/file-C4pqV8yl.cjs.map +1 -0
  10. package/dist/{file-Dj9lsbJu.js → file-D_ih0x7q.js} +15 -11
  11. package/dist/file-D_ih0x7q.js.map +1 -0
  12. package/dist/{file-BAICym_L.cjs → file-DiPZBLSP.cjs} +15 -11
  13. package/dist/file-DiPZBLSP.cjs.map +1 -0
  14. package/dist/{file-DkFGn_Os.d.ts → file-oLlejzZV.d.ts} +67 -33
  15. package/dist/file.cjs +5 -2
  16. package/dist/file.d.cts +2 -2
  17. package/dist/file.d.ts +2 -2
  18. package/dist/file.js +3 -1
  19. package/dist/graph.d.cts +1 -1
  20. package/dist/graph.d.ts +1 -1
  21. package/dist/{guards-C6w6KQSY.d.ts → guards-RCnH6re9.d.ts} +1 -1
  22. package/dist/{guards-COBkDtgu.d.cts → guards-u-dAAtl8.d.cts} +1 -1
  23. package/dist/http.d.cts +2 -2
  24. package/dist/http.d.ts +2 -2
  25. package/dist/{index-CX7yfAGI.d.ts → index-2TMYDLjK.d.ts} +1 -1
  26. package/dist/index-6-ZZCX9W.d.ts +24 -0
  27. package/dist/index-B2nnOQjf.d.cts +24 -0
  28. package/dist/{index-DkThxxxq.d.cts → index-BgFaJtnv.d.ts} +9 -3
  29. package/dist/index-Bj7a0aSM.d.cts +5 -0
  30. package/dist/{index-dgiKWRpD.d.cts → index-Bw2oMIM1.d.cts} +3 -3
  31. package/dist/{index-gDZYBeJw.d.cts → index-C1za72gL.d.cts} +1 -1
  32. package/dist/index-CW-ztJjd.d.ts +5 -0
  33. package/dist/{index-DjThtAn4.d.ts → index-DF7CbpYW.d.ts} +2 -2
  34. package/dist/{index-CPXo4cA8.d.cts → index-D_WLsIMP.d.cts} +2 -2
  35. package/dist/{index-B5w-X5V6.d.ts → index-DbAnYRRM.d.ts} +1 -1
  36. package/dist/{index-jWtEIa7j.d.ts → index-DbQ-J072.d.cts} +9 -3
  37. package/dist/{index-CnY3KmAg.d.ts → index-DfRcRYF2.d.ts} +1 -1
  38. package/dist/{index-DZe5evGM.d.cts → index-DpnCCtXt.d.cts} +1 -1
  39. package/dist/{index-CwFC71XK.d.ts → index-DzHcy3vy.d.ts} +2 -2
  40. package/dist/{index-9l1xMEl_.d.ts → index-UwSVys3m.d.ts} +3 -3
  41. package/dist/{index-Dr81DOsC.d.cts → index-c9FD2S5f.d.cts} +2 -2
  42. package/dist/{index-D-BjRrJo.d.cts → index-sdprVPKQ.d.cts} +1 -1
  43. package/dist/index.cjs +2 -2
  44. package/dist/index.d.cts +15 -15
  45. package/dist/index.d.ts +15 -15
  46. package/dist/index.js +2 -2
  47. package/dist/json.d.cts +1 -1
  48. package/dist/json.d.ts +1 -1
  49. package/dist/macro.d.cts +1 -1
  50. package/dist/macro.d.ts +1 -1
  51. package/dist/node.d.cts +2 -2
  52. package/dist/node.d.ts +2 -2
  53. package/dist/{nodes-CwYIFVt5.js → nodes-ClL1C158.js} +2 -2
  54. package/dist/nodes-ClL1C158.js.map +1 -0
  55. package/dist/{nodes-BT2Ocq0x.cjs → nodes-DEQjVliP.cjs} +2 -2
  56. package/dist/nodes-DEQjVliP.cjs.map +1 -0
  57. package/dist/{operation-BUhPuZMY.d.cts → operation-AFw8tzIN.d.cts} +21 -5
  58. package/dist/{operation-jxEr2No4.d.ts → operation-Cu4XSaJQ.d.ts} +21 -5
  59. package/dist/ref.d.cts +1 -1
  60. package/dist/ref.d.ts +1 -1
  61. package/dist/schema-gSjYgaCl.cjs.map +1 -1
  62. package/dist/schema-tH14gE6i.js.map +1 -1
  63. package/dist/schema.d.cts +3 -3
  64. package/dist/schema.d.ts +3 -3
  65. package/dist/{visitor-CFbuH7BY.d.ts → visitor-CpmsR8o5.d.ts} +2 -2
  66. package/dist/{visitor-DxhkIQyP.d.cts → visitor-DnBK2MNl.d.cts} +2 -2
  67. package/package.json +1 -1
  68. package/dist/file-BAICym_L.cjs.map +0 -1
  69. package/dist/file-DUFttt26.js +0 -293
  70. package/dist/file-DUFttt26.js.map +0 -1
  71. package/dist/file-Dj9lsbJu.js.map +0 -1
  72. package/dist/file-Dz1HPMld.cjs +0 -329
  73. package/dist/file-Dz1HPMld.cjs.map +0 -1
  74. package/dist/index-Be5d4Zcl.d.ts +0 -24
  75. package/dist/index-CI6Tu2c7.d.ts +0 -5
  76. package/dist/index-DuDvNFQ8.d.cts +0 -5
  77. package/dist/index-ss1YqjpW.d.cts +0 -24
  78. package/dist/nodes-BT2Ocq0x.cjs.map +0 -1
  79. package/dist/nodes-CwYIFVt5.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
2
2
  import { t as nodeKinds } from "./constants-BTTus9ee.js";
3
- import { n as createFile, o as importLocalName } from "./file-DUFttt26.js";
3
+ import { n as createFile, o as getNames, r as createImport, s as getSpace } from "./file-Bq2GPaxh.js";
4
4
  import { n as getNodeText, t as CODE_NODE_TEXT_FIELDS } from "./nodeText-BSYvDZOH.js";
5
5
  // src/utils/inline.ts
6
6
  /**
@@ -68,10 +68,10 @@ function inlineFiles(files, { language }) {
68
68
  name: local
69
69
  };
70
70
  for (const imp of file.imports) {
71
- const item = virtualFiles.has(imp.path) && [imp.name].flat().find((item) => importLocalName(item) === local);
71
+ const item = virtualFiles.has(imp.path) && getNames(imp).find((item) => (item.alias ?? item.name) === local);
72
72
  if (item) return {
73
73
  path: imp.path,
74
- name: typeof item === "string" ? item : item.propertyName
74
+ name: item.name
75
75
  };
76
76
  }
77
77
  }
@@ -112,12 +112,12 @@ function bodyOf(source) {
112
112
  return getNodeText(node.nodes) || void 0;
113
113
  }
114
114
  function pickNames(imp, used) {
115
- if (!Array.isArray(imp.name)) return used.has(imp.name) ? [imp] : [];
116
- const name = imp.name.filter((item) => used.has(importLocalName(item)));
117
- return name.length > 0 ? [{
118
- ...imp,
119
- name
120
- }] : [];
115
+ const names = getNames(imp).filter((item) => used.has(item.alias ?? item.name));
116
+ return names.length > 0 ? [createImport({
117
+ path: imp.path,
118
+ ...imp.root != null ? { root: imp.root } : {},
119
+ names
120
+ })] : [];
121
121
  }
122
122
  function rewriteNodes(nodes, rewrite) {
123
123
  return nodes?.map((node) => {
@@ -134,7 +134,11 @@ function rewriteNodes(nodes, rewrite) {
134
134
  });
135
135
  }
136
136
  // src/file/index.ts
137
- var file_exports = /* @__PURE__ */ __exportAll({ inline: () => inlineFiles });
137
+ var file_exports = /* @__PURE__ */ __exportAll({
138
+ getNames: () => getNames,
139
+ getSpace: () => getSpace,
140
+ inline: () => inlineFiles
141
+ });
138
142
  export { inlineFiles as n, file_exports as t };
139
143
 
140
- //# sourceMappingURL=file-Dj9lsbJu.js.map
144
+ //# sourceMappingURL=file-D_ih0x7q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-D_ih0x7q.js","names":[],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["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 { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\ntype 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 */\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\ntype 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 */\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, imports)\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 // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\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 imports.push(...definition.imports)\n return lang.wrap(definition.expression)\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 sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).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// 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 { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;AAiDA,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,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,QAAQ,OAAO,WAAW,IAAI,OAAO,MAAM,KAAK,KAAA;CAC7D,IAAI,MAAM,SAAS,UAAU,SAAS,MAAM,SAAS,UAAU,MAAM,OAAO,KAAA;CAC5E,OAAO,YAAY,KAAK,KAAK,KAAK,KAAA;AACpC;AAEA,SAAS,UAAU,KAAiB,MAA8C;CAChF,MAAM,QAAQ,SAAS,GAAG,CAAC,CAAC,QAAQ,SAAS,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,CAAC;CAC9E,OAAO,MAAM,SAAS,IAAI,CAAC,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,SAAS,UAAU,OAAO,OAAO;EAE1C,MAAM,OAAO,EAAE,GAAG,KAAK;EACvB,KAAK,MAAM,SAAS,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,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
2
  const require_constants = require("./constants-DztHlVmY.cjs");
3
- const require_file = require("./file-Dz1HPMld.cjs");
3
+ const require_file = require("./file-C4pqV8yl.cjs");
4
4
  const require_nodeText = require("./nodeText-CZ7wgxu9.cjs");
5
5
  // src/utils/inline.ts
6
6
  /**
@@ -68,10 +68,10 @@ function inlineFiles(files, { language }) {
68
68
  name: local
69
69
  };
70
70
  for (const imp of file.imports) {
71
- const item = virtualFiles.has(imp.path) && [imp.name].flat().find((item) => require_file.importLocalName(item) === local);
71
+ const item = virtualFiles.has(imp.path) && require_file.getNames(imp).find((item) => (item.alias ?? item.name) === local);
72
72
  if (item) return {
73
73
  path: imp.path,
74
- name: typeof item === "string" ? item : item.propertyName
74
+ name: item.name
75
75
  };
76
76
  }
77
77
  }
@@ -112,12 +112,12 @@ function bodyOf(source) {
112
112
  return require_nodeText.getNodeText(node.nodes) || void 0;
113
113
  }
114
114
  function pickNames(imp, used) {
115
- if (!Array.isArray(imp.name)) return used.has(imp.name) ? [imp] : [];
116
- const name = imp.name.filter((item) => used.has(require_file.importLocalName(item)));
117
- return name.length > 0 ? [{
118
- ...imp,
119
- name
120
- }] : [];
115
+ const names = require_file.getNames(imp).filter((item) => used.has(item.alias ?? item.name));
116
+ return names.length > 0 ? [require_file.createImport({
117
+ path: imp.path,
118
+ ...imp.root != null ? { root: imp.root } : {},
119
+ names
120
+ })] : [];
121
121
  }
122
122
  function rewriteNodes(nodes, rewrite) {
123
123
  return nodes?.map((node) => {
@@ -134,7 +134,11 @@ function rewriteNodes(nodes, rewrite) {
134
134
  });
135
135
  }
136
136
  // src/file/index.ts
137
- var file_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ inline: () => inlineFiles });
137
+ var file_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
138
+ getNames: () => require_file.getNames,
139
+ getSpace: () => require_file.getSpace,
140
+ inline: () => inlineFiles
141
+ });
138
142
  Object.defineProperty(exports, "file_exports", {
139
143
  enumerable: true,
140
144
  get: function() {
@@ -148,4 +152,4 @@ Object.defineProperty(exports, "inlineFiles", {
148
152
  }
149
153
  });
150
154
 
151
- //# sourceMappingURL=file-BAICym_L.cjs.map
155
+ //# sourceMappingURL=file-DiPZBLSP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-DiPZBLSP.cjs","names":["getNames","createFile","nodeKinds","getNodeText","createImport","CODE_NODE_TEXT_FIELDS"],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["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 { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\ntype 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 */\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\ntype 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 */\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, imports)\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 // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\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 imports.push(...definition.imports)\n return lang.wrap(definition.expression)\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 sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).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// 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 { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;AAiDA,SAAgB,YAAY,OAA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AAM,SAASG,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"}
@@ -315,39 +315,61 @@ type ImportName = string | Array<string | {
315
315
  propertyName: string;
316
316
  name?: string;
317
317
  }>;
318
+ /**
319
+ * Whether a declaration exists only at compile time (`'type'`) or also at runtime (`'value'`).
320
+ */
321
+ type Space = 'type' | 'value';
322
+ /**
323
+ * One name an import or export brings across, as in the ECMAScript `ImportEntry` record.
324
+ */
325
+ type ModuleName = {
326
+ /**
327
+ * Name in the other module: `'default'` for its default export, `'*'` for the whole module.
328
+ */
329
+ name: string;
330
+ /**
331
+ * Local name for an import, or the exported name for an export.
332
+ */
333
+ alias?: string | null;
334
+ /**
335
+ * Type or value.
336
+ * @default 'value'
337
+ */
338
+ space?: Space | null;
339
+ };
318
340
  /**
319
341
  * Represents a language-agnostic import/dependency declaration.
320
342
  *
321
343
  * @example Named import (TypeScript: `import { useState } from 'react'`)
322
344
  * ```ts
323
- * createImport({ name: ['useState'], path: 'react' })
345
+ * createImport({ names: [{ name: 'useState' }], path: 'react' })
324
346
  * ```
325
347
  *
326
348
  * @example Default import (TypeScript: `import React from 'react'`)
327
349
  * ```ts
328
- * createImport({ name: 'React', path: 'react' })
350
+ * createImport({ names: [{ name: 'default', alias: 'React' }], path: 'react' })
329
351
  * ```
330
352
  *
331
353
  * @example Type-only import (TypeScript: `import type { FC } from 'react'`)
332
354
  * ```ts
333
- * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
355
+ * createImport({ names: [{ name: 'FC', space: 'type' }], path: 'react' })
334
356
  * ```
335
357
  *
336
358
  * @example Namespace import (TypeScript: `import * as React from 'react'`)
337
359
  * ```ts
338
- * createImport({ name: 'React', path: 'react', isNameSpace: true })
360
+ * createImport({ names: [{ name: '*', alias: 'React' }], path: 'react' })
339
361
  * ```
340
362
  */
341
363
  type ImportNode = BaseNode & {
342
364
  kind: 'Import';
365
+ /**
366
+ * The names the import brings in. `ast.file.getNames` also reads the deprecated fields.
367
+ */
368
+ names?: Array<ModuleName> | null;
343
369
  /**
344
370
  * Import name(s) to be used.
345
371
  *
346
- * @example Named imports
347
- * `['useState']`
348
- *
349
- * @example Default import
350
- * `'React'`
372
+ * @deprecated Use `names`. Removed in Kubb v6.
351
373
  */
352
374
  name: ImportName;
353
375
  /**
@@ -359,14 +381,14 @@ type ImportNode = BaseNode & {
359
381
  path: string;
360
382
  /**
361
383
  * Add a type-only import prefix.
362
- * - `true` generates `import type { Type } from './path'`
363
- * - `false` generates `import { Type } from './path'`
384
+ *
385
+ * @deprecated Set `space: 'type'` on each name. Removed in Kubb v6.
364
386
  */
365
387
  isTypeOnly?: boolean | null;
366
388
  /**
367
389
  * Import the entire module as a namespace.
368
- * - `true` generates `import * as Name from './path'`
369
- * - `false` generates a standard import
390
+ *
391
+ * @deprecated Use `{ name: '*', alias }` in `names`. Removed in Kubb v6.
370
392
  */
371
393
  isNameSpace?: boolean | null;
372
394
  /**
@@ -379,34 +401,34 @@ type ImportNode = BaseNode & {
379
401
  *
380
402
  * @example Named export (TypeScript: `export { Pets } from './Pets'`)
381
403
  * ```ts
382
- * createExport({ name: ['Pets'], path: './Pets' })
404
+ * createExport({ names: [{ name: 'Pets' }], path: './Pets' })
383
405
  * ```
384
406
  *
385
407
  * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
386
408
  * ```ts
387
- * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
409
+ * createExport({ names: [{ name: 'Pet', space: 'type' }], path: './Pet' })
388
410
  * ```
389
411
  *
390
412
  * @example Wildcard export (TypeScript: `export * from './utils'`)
391
413
  * ```ts
392
- * createExport({ path: './utils' })
414
+ * createExport({ names: [{ name: '*' }], path: './utils' })
393
415
  * ```
394
416
  *
395
417
  * @example Namespace alias (TypeScript: `export * as utils from './utils'`)
396
418
  * ```ts
397
- * createExport({ name: 'utils', path: './utils', asAlias: true })
419
+ * createExport({ names: [{ name: '*', alias: 'utils' }], path: './utils' })
398
420
  * ```
399
421
  */
400
422
  type ExportNode = BaseNode & {
401
423
  kind: 'Export';
424
+ /**
425
+ * The names the export passes on. `ast.file.getNames` also reads the deprecated fields.
426
+ */
427
+ names?: Array<ModuleName> | null;
402
428
  /**
403
429
  * Export name(s) to be used. When omitted, generates a wildcard export.
404
430
  *
405
- * @example Named exports
406
- * `['useState']`
407
- *
408
- * @example Single export
409
- * `'React'`
431
+ * @deprecated Use `names`. Removed in Kubb v6.
410
432
  */
411
433
  name?: string | Array<string> | null;
412
434
  /**
@@ -418,14 +440,14 @@ type ExportNode = BaseNode & {
418
440
  path: string;
419
441
  /**
420
442
  * Add a type-only export prefix.
421
- * - `true` generates `export type { Type } from './path'`
422
- * - `false` generates `export { Type } from './path'`
443
+ *
444
+ * @deprecated Set `space: 'type'` on each name. Removed in Kubb v6.
423
445
  */
424
446
  isTypeOnly?: boolean | null;
425
447
  /**
426
448
  * Export as an aliased namespace.
427
- * - `true` generates `export * as aliasName from './path'`
428
- * - `false` generates a standard export
449
+ *
450
+ * @deprecated Use `{ name: '*', alias }` in `names`. Removed in Kubb v6.
429
451
  */
430
452
  asAlias?: boolean | null;
431
453
  };
@@ -448,8 +470,14 @@ type SourceNode = BaseNode & {
448
470
  * Optional name identifying this source (used for deduplication and barrel generation).
449
471
  */
450
472
  name?: string | null;
473
+ /**
474
+ * Type or value. When unset, a source whose first node is a `Type` is a type.
475
+ */
476
+ space?: Space | null;
451
477
  /**
452
478
  * Mark this source as a type-only export.
479
+ *
480
+ * @deprecated Use `space: 'type'`. Removed in Kubb v6.
453
481
  */
454
482
  isTypeOnly?: boolean | null;
455
483
  /**
@@ -570,26 +598,32 @@ type FileNode<TMeta extends object = object> = BaseNode & {
570
598
  */
571
599
  inline?: boolean | null;
572
600
  };
601
+ type ImportInput = Omit<ImportNode, 'kind' | 'name'> & {
602
+ name?: ImportName;
603
+ };
604
+ type ExportInput = Omit<ExportNode, 'kind'>;
573
605
  /**
574
- * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
606
+ * Creates an `ImportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
607
+ * `isTypeOnly` that differs from the one `names` gives overrides it, so `{ ...imp, isTypeOnly: true }` still works.
575
608
  *
576
609
  * @example Named import
577
610
  * ```ts
578
- * createImport({ name: ['useState'], path: 'react' })
611
+ * createImport({ names: [{ name: 'useState' }], path: 'react' })
579
612
  * // import { useState } from 'react'
580
613
  * ```
581
614
  */
582
- declare const createImport: (input: Omit<ImportNode, "kind">) => ImportNode;
615
+ declare function createImport(input: ImportInput): ImportNode;
583
616
  /**
584
- * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
617
+ * Creates an `ExportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
618
+ * `isTypeOnly` that differs from the one `names` gives overrides it.
585
619
  *
586
620
  * @example Named export
587
621
  * ```ts
588
- * createExport({ name: ['Pet'], path: './Pet' })
622
+ * createExport({ names: [{ name: 'Pet' }], path: './Pet' })
589
623
  * // export { Pet } from './Pet'
590
624
  * ```
591
625
  */
592
- declare const createExport: (input: Omit<ExportNode, "kind">) => ExportNode;
626
+ declare function createExport(input: ExportInput): ExportNode;
593
627
  /**
594
628
  * Creates a `SourceNode` representing a fragment of source code within a file.
595
629
  *
@@ -643,4 +677,4 @@ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind'
643
677
  * ```
644
678
  */
645
679
  declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
646
- export { createJsx as C, createFunction as S, createType as T, TextNode as _, UserFileNode as a, createBreak as b, createImport as c, BreakNode as d, CodeNode as f, JsxNode as g, JSDocNode as h, SourceNode as i, createSource as l, FunctionNode as m, FileNode as n, createExport as o, ConstNode as p, ImportNode as r, createFile as s, ExportNode as t, ArrowFunctionNode as u, TypeNode as v, createText as w, createConst as x, createArrowFunction as y };
680
+ export { createArrowFunction as C, createJsx as D, createFunction as E, createText as O, TypeNode as S, createConst as T, ConstNode as _, ImportNode as a, JsxNode as b, Space as c, createFile as d, createImport as f, CodeNode as g, BreakNode as h, ImportInput as i, createType as k, UserFileNode as l, ArrowFunctionNode as m, ExportNode as n, ModuleName as o, createSource as p, FileNode as r, SourceNode as s, ExportInput as t, createExport as u, FunctionNode as v, createBreak as w, TextNode as x, JSDocNode as y };
package/dist/file.cjs CHANGED
@@ -1,3 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_file = require("./file-BAICym_L.cjs");
3
- exports.inline = require_file.inlineFiles;
2
+ const require_file = require("./file-C4pqV8yl.cjs");
3
+ const require_file$1 = require("./file-DiPZBLSP.cjs");
4
+ exports.getNames = require_file.getNames;
5
+ exports.getSpace = require_file.getSpace;
6
+ exports.inline = require_file$1.inlineFiles;
package/dist/file.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { r as inlineFiles } from "./index-DkThxxxq.cjs";
2
- export { inlineFiles as inline };
1
+ import { a as inlineFiles, n as getNames, r as getSpace } from "./index-DbQ-J072.cjs";
2
+ export { getNames, getSpace, inlineFiles as inline };
package/dist/file.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { r as inlineFiles } from "./index-jWtEIa7j.js";
2
- export { inlineFiles as inline };
1
+ import { a as inlineFiles, n as getNames, r as getSpace } from "./index-BgFaJtnv.js";
2
+ export { getNames, getSpace, inlineFiles as inline };
package/dist/file.js CHANGED
@@ -1 +1,3 @@
1
- export { n as inline } from "./file-Dj9lsbJu.js";
1
+ import { o as getNames, s as getSpace } from "./file-Bq2GPaxh.js";
2
+ import { n as inlineFiles } from "./file-D_ih0x7q.js";
3
+ export { getNames, getSpace, inlineFiles as inline };
package/dist/graph.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-D-BjRrJo.cjs";
1
+ import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-sdprVPKQ.cjs";
2
2
  export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
package/dist/graph.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-B5w-X5V6.js";
1
+ import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-DbAnYRRM.js";
2
2
  export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, U as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-jxEr2No4.js";
1
+ import { U as SchemaNode, W as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-Cu4XSaJQ.js";
2
2
  /**
3
3
  * Narrows a `SchemaNode` to the variant that matches `type`.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, U as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-BUhPuZMY.cjs";
1
+ import { U as SchemaNode, W as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-AFw8tzIN.cjs";
2
2
  /**
3
3
  * Narrows a `SchemaNode` to the variant that matches `type`.
4
4
  *
package/dist/http.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as isHttpOperationNode } from "./guards-COBkDtgu.cjs";
2
- import "./index-DuDvNFQ8.cjs";
1
+ import { t as isHttpOperationNode } from "./guards-u-dAAtl8.cjs";
2
+ import "./index-Bj7a0aSM.cjs";
3
3
  export { isHttpOperationNode as isOperation };
package/dist/http.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as isHttpOperationNode } from "./guards-C6w6KQSY.js";
2
- import "./index-CI6Tu2c7.js";
1
+ import { t as isHttpOperationNode } from "./guards-RCnH6re9.js";
2
+ import "./index-CW-ztJjd.js";
3
3
  export { isHttpOperationNode as isOperation };
@@ -1,4 +1,4 @@
1
- import { T as InputNode } from "./operation-jxEr2No4.js";
1
+ import { T as InputNode } from "./operation-Cu4XSaJQ.js";
2
2
  declare namespace index_d_exports {
3
3
  export { parse, stringify };
4
4
  }
@@ -0,0 +1,24 @@
1
+ import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-oLlejzZV.js";
2
+ import { Q as createProperty, T as InputNode, U as SchemaNode, X as createSchema, Z as PropertyNode, a as createOperation, d as createRequestBody, g as ContentNode, h as createParameter, i as OperationNode, k as createInput, l as createResponse, p as ParameterNode, s as ResponseNode, u as RequestBodyNode, y as createContent } from "./operation-Cu4XSaJQ.js";
3
+ declare namespace index_d_exports {
4
+ export { ExportInput, ImportInput, ModuleName, Node, Space, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
5
+ }
6
+ /**
7
+ * Union of all AST node types.
8
+ *
9
+ * This lets TypeScript narrow types in `switch (node.kind)` blocks.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * function getKind(node: Node): string {
14
+ * switch (node.kind) {
15
+ * case nodeKinds.input:
16
+ * return 'input'
17
+ * default:
18
+ * return 'other'
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ type Node = InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
24
+ export { index_d_exports as n, Node as t };
@@ -0,0 +1,24 @@
1
+ import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-B269mZh4.cjs";
2
+ import { Q as createProperty, T as InputNode, U as SchemaNode, X as createSchema, Z as PropertyNode, a as createOperation, d as createRequestBody, g as ContentNode, h as createParameter, i as OperationNode, k as createInput, l as createResponse, p as ParameterNode, s as ResponseNode, u as RequestBodyNode, y as createContent } from "./operation-AFw8tzIN.cjs";
3
+ declare namespace index_d_exports {
4
+ export { ExportInput, ImportInput, ModuleName, Node, Space, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
5
+ }
6
+ /**
7
+ * Union of all AST node types.
8
+ *
9
+ * This lets TypeScript narrow types in `switch (node.kind)` blocks.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * function getKind(node: Node): string {
14
+ * switch (node.kind) {
15
+ * case nodeKinds.input:
16
+ * return 'input'
17
+ * default:
18
+ * return 'other'
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ type Node = InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
24
+ export { index_d_exports as n, Node as t };
@@ -1,4 +1,4 @@
1
- import { n as FileNode } from "./file-KunZhFIV.cjs";
1
+ import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-oLlejzZV.js";
2
2
  type InlineFilesResult = {
3
3
  /**
4
4
  * Files that imported an inline name, rewritten to hold its definition.
@@ -40,7 +40,13 @@ type InlineFilesOptions = {
40
40
  * declaration, until no inline names are left. The definitions' own imports move to the importing file.
41
41
  */
42
42
  declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
43
+ /**
44
+ * Returns the names an import or export brings across. A node built with the deprecated fields gets them from
45
+ * those, each with an explicit `space`, so it prints exactly as before.
46
+ */
47
+ declare function getNames(node: ImportNode | ExportNode): Array<ModuleName>;
48
+ declare function getSpace(source: SourceNode): Space;
43
49
  declare namespace index_d_exports {
44
- export { inlineFiles as inline };
50
+ export { getNames, getSpace, inlineFiles as inline };
45
51
  }
46
- export { InlineLanguage as n, inlineFiles as r, index_d_exports as t };
52
+ export { inlineFiles as a, InlineLanguage as i, getNames as n, getSpace as r, index_d_exports as t };
@@ -0,0 +1,5 @@
1
+ import { t as isHttpOperationNode } from "./guards-u-dAAtl8.cjs";
2
+ declare namespace index_d_exports {
3
+ export { isHttpOperationNode as isOperation };
4
+ }
5
+ export { index_d_exports as t };
@@ -1,7 +1,7 @@
1
- import { G as StringSchemaNode, H as SchemaNode, X as PropertyNode } from "./operation-BUhPuZMY.cjs";
1
+ import { K as StringSchemaNode, U as SchemaNode, Z as PropertyNode } from "./operation-AFw8tzIN.cjs";
2
2
  import { a as schemaTypes } from "./base-UFBZi-FO.cjs";
3
- import { n as narrowSchema } from "./guards-COBkDtgu.cjs";
4
- import { o as findSchema } from "./visitor-DxhkIQyP.cjs";
3
+ import { n as narrowSchema } from "./guards-u-dAAtl8.cjs";
4
+ import { o as findSchema } from "./visitor-DnBK2MNl.cjs";
5
5
  /**
6
6
  * Generic JSON Schema optionality: a non-required field is optional, and a
7
7
  * non-required nullable field is nullish.
@@ -1,4 +1,4 @@
1
- import { T as InputNode } from "./operation-BUhPuZMY.cjs";
1
+ import { T as InputNode } from "./operation-AFw8tzIN.cjs";
2
2
  declare namespace index_d_exports {
3
3
  export { parse, stringify };
4
4
  }
@@ -0,0 +1,5 @@
1
+ import { t as isHttpOperationNode } from "./guards-RCnH6re9.js";
2
+ declare namespace index_d_exports {
3
+ export { isHttpOperationNode as isOperation };
4
+ }
5
+ export { index_d_exports as t };
@@ -1,6 +1,6 @@
1
1
  import { i as nodeKinds } from "./base-LhsPvVY1.js";
2
- import { f as CodeNode } from "./file-DkFGn_Os.js";
3
- import { a as collect, s as transform } from "./visitor-CFbuH7BY.js";
2
+ import { g as CodeNode } from "./file-oLlejzZV.js";
3
+ import { a as collect, s as transform } from "./visitor-CpmsR8o5.js";
4
4
  /**
5
5
  * Extracts all string content from a `CodeNode` tree recursively.
6
6
  * Collects the text fields and nested node content, to build the source string for import filtering.
@@ -1,5 +1,5 @@
1
- import { t as Node } from "./index-ss1YqjpW.cjs";
2
- import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-DxhkIQyP.cjs";
1
+ import { t as Node } from "./index-B2nnOQjf.cjs";
2
+ import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-DnBK2MNl.cjs";
3
3
  /**
4
4
  * Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
5
5
  * and `undefined` keeps declaration order.
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, i as OperationNode } from "./operation-jxEr2No4.js";
1
+ import { U as SchemaNode, i as OperationNode } from "./operation-Cu4XSaJQ.js";
2
2
  /**
3
3
  * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.
4
4
  * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by
@@ -1,4 +1,4 @@
1
- import { n as FileNode } from "./file-DkFGn_Os.js";
1
+ import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-B269mZh4.cjs";
2
2
  type InlineFilesResult = {
3
3
  /**
4
4
  * Files that imported an inline name, rewritten to hold its definition.
@@ -40,7 +40,13 @@ type InlineFilesOptions = {
40
40
  * declaration, until no inline names are left. The definitions' own imports move to the importing file.
41
41
  */
42
42
  declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
43
+ /**
44
+ * Returns the names an import or export brings across. A node built with the deprecated fields gets them from
45
+ * those, each with an explicit `space`, so it prints exactly as before.
46
+ */
47
+ declare function getNames(node: ImportNode | ExportNode): Array<ModuleName>;
48
+ declare function getSpace(source: SourceNode): Space;
43
49
  declare namespace index_d_exports {
44
- export { inlineFiles as inline };
50
+ export { getNames, getSpace, inlineFiles as inline };
45
51
  }
46
- export { InlineLanguage as n, inlineFiles as r, index_d_exports as t };
52
+ export { inlineFiles as a, InlineLanguage as i, getNames as n, getSpace as r, index_d_exports as t };
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, z as RefSchemaNode } from "./operation-jxEr2No4.js";
1
+ import { B as RefSchemaNode, U as SchemaNode } from "./operation-Cu4XSaJQ.js";
2
2
  /**
3
3
  * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
4
4
  *