@kubb/ast 5.0.0-beta.58 → 5.0.0-beta.59

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 (67) hide show
  1. package/README.md +10 -0
  2. package/dist/casing-BE2R1RXg.cjs +88 -0
  3. package/dist/casing-BE2R1RXg.cjs.map +1 -0
  4. package/dist/extractStringsFromNodes-WMYJ8nQL.d.ts +82 -0
  5. package/dist/factory-BmcGBdeg.cjs +1251 -0
  6. package/dist/factory-BmcGBdeg.cjs.map +1 -0
  7. package/dist/factory-Du7nEP4B.js +282 -0
  8. package/dist/factory-Du7nEP4B.js.map +1 -0
  9. package/dist/factory.cjs +25 -28
  10. package/dist/factory.d.ts +3 -3
  11. package/dist/factory.js +3 -3
  12. package/dist/{ast-ClnJg9BN.d.ts → index-BzjwdK2M.d.ts} +74 -372
  13. package/dist/index.cjs +445 -46
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.ts +94 -59
  16. package/dist/index.js +7 -113
  17. package/dist/index.js.map +1 -1
  18. package/dist/operationParams-BZ07xDm0.d.ts +204 -0
  19. package/dist/response-DKxTr522.js +683 -0
  20. package/dist/response-DKxTr522.js.map +1 -0
  21. package/dist/{types-CB2oY8Dw.d.ts → types-olVl9v5p.d.ts} +222 -227
  22. package/dist/types.d.ts +4 -3
  23. package/dist/utils-BCtRXfhI.cjs +275 -0
  24. package/dist/utils-BCtRXfhI.cjs.map +1 -0
  25. package/dist/{utils-DN4XLVqz.js → utils-SdZU0F3H.js} +472 -1235
  26. package/dist/utils-SdZU0F3H.js.map +1 -0
  27. package/dist/utils.cjs +127 -22
  28. package/dist/utils.d.ts +112 -80
  29. package/dist/utils.js +3 -2
  30. package/package.json +1 -1
  31. package/src/constants.ts +8 -14
  32. package/src/dedupe.ts +8 -0
  33. package/src/factory.ts +1 -2
  34. package/src/guards.ts +1 -1
  35. package/src/index.ts +4 -13
  36. package/src/nodes/code.ts +29 -47
  37. package/src/nodes/content.ts +2 -2
  38. package/src/nodes/file.ts +28 -23
  39. package/src/nodes/function.ts +0 -15
  40. package/src/nodes/input.ts +6 -6
  41. package/src/nodes/operation.ts +1 -1
  42. package/src/nodes/parameter.ts +0 -3
  43. package/src/nodes/property.ts +0 -3
  44. package/src/nodes/requestBody.ts +3 -6
  45. package/src/nodes/schema.ts +3 -2
  46. package/src/printer.ts +1 -1
  47. package/src/registry.ts +31 -26
  48. package/src/signature.ts +3 -3
  49. package/src/transformers.ts +28 -1
  50. package/src/types.ts +2 -53
  51. package/src/utils/codegen.ts +104 -0
  52. package/src/utils/fileMerge.ts +184 -0
  53. package/src/utils/index.ts +7 -339
  54. package/src/utils/operationParams.ts +353 -0
  55. package/src/utils/refs.ts +112 -0
  56. package/src/utils/schemaGraph.ts +169 -0
  57. package/src/utils/strings.ts +139 -0
  58. package/src/visitor.ts +43 -19
  59. package/dist/extractStringsFromNodes-Bn9cOos9.d.ts +0 -14
  60. package/dist/factory-C5gHvtLU.js +0 -138
  61. package/dist/factory-C5gHvtLU.js.map +0 -1
  62. package/dist/factory-JN-Ylfl6.cjs +0 -155
  63. package/dist/factory-JN-Ylfl6.cjs.map +0 -1
  64. package/dist/utils-C8bWAzhv.cjs +0 -2696
  65. package/dist/utils-C8bWAzhv.cjs.map +0 -1
  66. package/dist/utils-DN4XLVqz.js.map +0 -1
  67. package/src/utils/ast.ts +0 -816
@@ -1,138 +0,0 @@
1
- import { t as __exportAll } from "./chunk-CNktS9qV.js";
2
- import { B as createOperation, H as createRequestBody, I as createParameter, J as createSource, K as createExport, P as createResponse, R as createOutput, S as combineSources, T as createOperationParams, W as createInput, _t as createFunctionParameter, at as createBreak, b as combineExports, bt as createObjectBindingPattern, ct as createJsx, et as createContent, ht as createProperty, it as createArrowFunction, jt as createSchema, kt as extractStringsFromNodes, lt as createText, ot as createConst, q as createImport, st as createFunction, ut as createType, vt as createFunctionParameters, w as createDiscriminantNode, x as combineImports, xt as createTypeLiteral, yt as createIndexedAccessType } from "./utils-DN4XLVqz.js";
3
- import { hash } from "node:crypto";
4
- import path from "node:path";
5
- //#region ../../internals/utils/src/fs.ts
6
- /**
7
- * Strips the file extension from a path or file name.
8
- * Only removes the last `.ext` segment when the dot is not part of a directory name.
9
- *
10
- * @example
11
- * trimExtName('petStore.ts') // 'petStore'
12
- * trimExtName('/src/models/pet.ts') // '/src/models/pet'
13
- * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
14
- * trimExtName('noExtension') // 'noExtension'
15
- */
16
- function trimExtName(text) {
17
- const dotIndex = text.lastIndexOf(".");
18
- if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
19
- return text;
20
- }
21
- //#endregion
22
- //#region src/factory.ts
23
- var factory_exports = /* @__PURE__ */ __exportAll({
24
- createArrowFunction: () => createArrowFunction,
25
- createBreak: () => createBreak,
26
- createConst: () => createConst,
27
- createContent: () => createContent,
28
- createDiscriminantNode: () => createDiscriminantNode,
29
- createExport: () => createExport,
30
- createFile: () => createFile,
31
- createFunction: () => createFunction,
32
- createFunctionParameter: () => createFunctionParameter,
33
- createFunctionParameters: () => createFunctionParameters,
34
- createImport: () => createImport,
35
- createIndexedAccessType: () => createIndexedAccessType,
36
- createInput: () => createInput,
37
- createJsx: () => createJsx,
38
- createObjectBindingPattern: () => createObjectBindingPattern,
39
- createOperation: () => createOperation,
40
- createOperationParams: () => createOperationParams,
41
- createOutput: () => createOutput,
42
- createParameter: () => createParameter,
43
- createProperty: () => createProperty,
44
- createRequestBody: () => createRequestBody,
45
- createResponse: () => createResponse,
46
- createSchema: () => createSchema,
47
- createSource: () => createSource,
48
- createText: () => createText,
49
- createType: () => createType,
50
- createTypeLiteral: () => createTypeLiteral,
51
- update: () => update
52
- });
53
- /**
54
- * Identity-preserving node update: returns `node` unchanged when every field in
55
- * `changes` already equals (by reference) the current value, otherwise a new node
56
- * with the changes applied.
57
- *
58
- * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the
59
- * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and
60
- * downstream passes can detect "nothing changed" by identity. Comparison is
61
- * shallow: a structurally-equal but newly-allocated array/object counts as a change.
62
- *
63
- * @example
64
- * ```ts
65
- * update(node, { name: node.name }) // -> same `node` reference
66
- * update(node, { name: 'renamed' }) // -> new node, `name` replaced
67
- * ```
68
- */
69
- function update(node, changes) {
70
- for (const key in changes) if (changes[key] !== node[key]) return {
71
- ...node,
72
- ...changes
73
- };
74
- return node;
75
- }
76
- /**
77
- * Creates a fully resolved `FileNode` from a file input descriptor.
78
- *
79
- * Computes:
80
- * - `id` SHA256 hash of the file path
81
- * - `name` `baseName` without extension
82
- * - `extname` extension extracted from `baseName`
83
- *
84
- * Deduplicates:
85
- * - `sources` via `combineSources`
86
- * - `exports` via `combineExports`
87
- * - `imports` via `combineImports` (also filters unused imports)
88
- *
89
- * @throws {Error} when `baseName` has no extension.
90
- *
91
- * @example
92
- * ```ts
93
- * const file = createFile({
94
- * baseName: 'petStore.ts',
95
- * path: 'src/models/petStore.ts',
96
- * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
97
- * imports: [createImport({ name: ['z'], path: 'zod' })],
98
- * exports: [createExport({ name: ['Pet'], path: './petStore' })],
99
- * })
100
- * // file.id = SHA256 hash of 'src/models/petStore.ts'
101
- * // file.name = 'petStore'
102
- * // file.extname = '.ts'
103
- * ```
104
- */
105
- function createFile(input) {
106
- const extname = path.extname(input.baseName) || (input.baseName.startsWith(".") ? input.baseName : "");
107
- if (!extname) throw new Error(`No extname found for ${input.baseName}`);
108
- const source = (input.sources ?? []).flatMap((item) => item.nodes ?? []).map((node) => extractStringsFromNodes([node])).filter(Boolean).join("\n\n");
109
- const resolvedExports = input.exports?.length ? combineExports(input.exports) : [];
110
- const combinedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || void 0) : [];
111
- const localNames = new Set((input.sources ?? []).map((item) => item.name).filter((name) => Boolean(name)));
112
- const nameOf = (item) => typeof item === "string" ? item : item.name ?? item.propertyName;
113
- const resolvedImports = combinedImports.filter((imp) => imp.path !== input.path).flatMap((imp) => {
114
- if (!Array.isArray(imp.name)) return typeof imp.name === "string" && localNames.has(imp.name) ? [] : [imp];
115
- const kept = imp.name.filter((item) => !localNames.has(nameOf(item)));
116
- if (!kept.length) return [];
117
- return [kept.length === imp.name.length ? imp : {
118
- ...imp,
119
- name: kept
120
- }];
121
- });
122
- const resolvedSources = input.sources?.length ? combineSources(input.sources) : [];
123
- return {
124
- kind: "File",
125
- ...input,
126
- id: hash("sha256", input.path, "hex"),
127
- name: trimExtName(input.baseName),
128
- extname,
129
- imports: resolvedImports,
130
- exports: resolvedExports,
131
- sources: resolvedSources,
132
- meta: input.meta ?? {}
133
- };
134
- }
135
- //#endregion
136
- export { factory_exports as n, update as r, createFile as t };
137
-
138
- //# sourceMappingURL=factory-C5gHvtLU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory-C5gHvtLU.js","names":[],"sources":["../../../internals/utils/src/fs.ts","../src/factory.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname, join, posix, resolve } from 'node:path'\nimport { camelCase } from './casing.ts'\nimport { runtime } from './runtime.ts'\n\n/**\n * Walks up the directory tree from `cwd` (defaults to `process.cwd()`) and\n * returns the absolute path of the nearest `package.json`, or `null` when none\n * is found before reaching the filesystem root.\n *\n * @example\n * ```ts\n * const pkgPath = findPackageJSON('/home/user/project/src') // '/home/user/project/package.json'\n * ```\n */\nexport function findPackageJSON(cwd?: string): string | null {\n let dir = cwd ? resolve(cwd) : process.cwd()\n while (true) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) return pkgPath\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\n/**\n * Converts all backslashes to forward slashes.\n * Extended-length Windows paths (`\\\\?\\...`) are left unchanged.\n */\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Resolves to `true` when the file or directory at `path` exists.\n * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.\n *\n * @example\n * ```ts\n * if (await exists('./kubb.config.ts')) {\n * const content = await read('./kubb.config.ts')\n * }\n * ```\n */\nexport async function exists(path: string): Promise<boolean> {\n if (runtime.isBun) {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\n/**\n * Reads the file at `path` as a UTF-8 string.\n * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.\n *\n * @example\n * ```ts\n * const source = await read('./src/Pet.ts')\n * ```\n */\nexport async function read(path: string): Promise<string> {\n if (runtime.isBun) {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\ntype WriteOptions = {\n /**\n * When `true`, re-reads the file immediately after writing and throws if the\n * content does not match — useful for catching write failures on unreliable file systems.\n */\n sanity?: boolean\n}\n\n/**\n * Writes `data` to `path`, trimming leading/trailing whitespace before saving.\n * Skips the write when the trimmed content is empty or identical to what is already on disk.\n * Creates any missing parent directories automatically.\n * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.\n *\n * @example\n * ```ts\n * await write('./src/Pet.ts', source) // writes and returns trimmed content\n * await write('./src/Pet.ts', source) // null — file unchanged\n * await write('./src/Pet.ts', ' ') // null — empty content skipped\n * ```\n */\nexport async function write(path: string, data: string, options: WriteOptions = {}): Promise<string | null> {\n const trimmed = data.trim()\n if (trimmed === '') return null\n\n const resolved = resolve(path)\n\n if (runtime.isBun) {\n const file = Bun.file(resolved)\n const oldContent = (await file.exists()) ? await file.text() : null\n if (oldContent === trimmed) return null\n await Bun.write(resolved, trimmed)\n return trimmed\n }\n\n try {\n const oldContent = await readFile(resolved, { encoding: 'utf-8' })\n if (oldContent === trimmed) return null\n } catch {\n /* file doesn't exist yet */\n }\n\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, trimmed, { encoding: 'utf-8' })\n\n if (options.sanity) {\n const savedData = await readFile(resolved, { encoding: 'utf-8' })\n if (savedData !== trimmed) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n return savedData\n }\n\n return trimmed\n}\n\n/**\n * Recursively removes `path`. Silently succeeds when `path` does not exist.\n *\n * @example\n * ```ts\n * await clean('./dist')\n * ```\n */\nexport async function clean(path: string): Promise<void> {\n return rm(path, { recursive: true, force: true })\n}\n\n/**\n * Converts a filesystem path to use POSIX (`/`) separators.\n *\n * Most of the codebase compares and composes paths as strings (prefix matching, joining for\n * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated\n * paths, but on Windows it returns `\\`-separated paths, which breaks every such comparison.\n *\n * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the\n * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is\n * exercisable from POSIX CI.\n *\n * @example\n * toPosixPath('C:\\\\repo\\\\src\\\\pet.ts') // 'C:/repo/src/pet.ts'\n */\nexport function toPosixPath(filePath: string): string {\n return filePath.replaceAll('\\\\', '/')\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = camelCase): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : camelCase(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { hash } from 'node:crypto'\nimport path from 'node:path'\nimport { trimExtName } from '@internals/utils'\nimport type { FileNode, Node } from './nodes/index.ts'\nimport { combineExports, combineImports, combineSources } from './utils/ast.ts'\nimport { extractStringsFromNodes } from './utils/extractStringsFromNodes.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createImport, createSource } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\nexport { createDiscriminantNode, createOperationParams } from './utils/ast.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the\n * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is\n * shallow: a structurally-equal but newly-allocated array/object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\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({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ 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 */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const rawExtname = path.extname(input.baseName)\n // Handle dotfile basename like '.ts' where path.extname returns ''\n const extname = (rawExtname || (input.baseName.startsWith('.') ? input.baseName : '')) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const source = (input.sources ?? [])\n .flatMap((item) => item.nodes ?? [])\n .map((node) => extractStringsFromNodes([node]))\n .filter(Boolean)\n .join('\\n\\n')\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const combinedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || undefined) : []\n const localNames = new Set((input.sources ?? []).map((item) => item.name).filter((name): name is string => Boolean(name)))\n const nameOf = (item: string | { propertyName: string; name?: string }): string => (typeof item === 'string' ? item : (item.name ?? item.propertyName))\n // Drop self-imports. Consolidating output (`mode: 'file'`) can place a symbol's\n // definition and a cross-file import of it in the same file. The first pass catches imports that\n // resolve to this file's own path. The second drops imports of names the file already defines,\n // the case consolidation produces when the import path no longer matches `input.path`. Sources\n // stay intact, so the local definition remains. Bare specifiers like `'zod'` never match a path.\n const resolvedImports = combinedImports\n .filter((imp) => imp.path !== input.path)\n .flatMap((imp) => {\n if (!Array.isArray(imp.name)) {\n return typeof imp.name === 'string' && localNames.has(imp.name) ? [] : [imp]\n }\n const kept = imp.name.filter((item) => !localNames.has(nameOf(item)))\n if (!kept.length) return []\n return [kept.length === imp.name.length ? imp : { ...imp, name: kept }]\n })\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n return {\n kind: 'File',\n ...input,\n id: hash('sha256', input.path, 'hex'),\n name: trimExtName(input.baseName),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,\n sources: resolvedSources,\n meta: input.meta ?? ({} as TMeta),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8LA,SAAgB,YAAY,MAAsB;CAChD,MAAM,WAAW,KAAK,YAAY,GAAG;CACrC,IAAI,WAAW,KAAK,CAAC,KAAK,SAAS,KAAK,QAAQ,GAC9C,OAAO,KAAK,MAAM,GAAG,QAAQ;CAE/B,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5JA,SAAgB,OAAuB,MAAS,SAAwB;CACtE,KAAK,MAAM,OAAO,SAChB,IAAI,QAAQ,SAAS,KAAK,MACxB,OAAO;EAAE,GAAG;EAAM,GAAG;CAAQ;CAIjC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,WAA0C,OAA6C;CAGrG,MAAM,UAFa,KAAK,QAAQ,MAAM,QAEZ,MAAM,MAAM,SAAS,WAAW,GAAG,IAAI,MAAM,WAAW;CAClF,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,wBAAwB,MAAM,UAAU;CAG1D,MAAM,UAAU,MAAM,WAAW,CAAC,EAAA,CAC/B,SAAS,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CACnC,KAAK,SAAS,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAC9C,OAAO,OAAO,CAAC,CACf,KAAK,MAAM;CACd,MAAM,kBAAkB,MAAM,SAAS,SAAS,eAAe,MAAM,OAAO,IAAI,CAAC;CACjF,MAAM,kBAAkB,MAAM,SAAS,SAAS,eAAe,MAAM,SAAS,iBAAiB,UAAU,KAAA,CAAS,IAAI,CAAC;CACvH,MAAM,aAAa,IAAI,KAAK,MAAM,WAAW,CAAC,EAAA,CAAG,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC,QAAQ,SAAyB,QAAQ,IAAI,CAAC,CAAC;CACzH,MAAM,UAAU,SAAoE,OAAO,SAAS,WAAW,OAAQ,KAAK,QAAQ,KAAK;CAMzI,MAAM,kBAAkB,gBACrB,QAAQ,QAAQ,IAAI,SAAS,MAAM,IAAI,CAAC,CACxC,SAAS,QAAQ;EAChB,IAAI,CAAC,MAAM,QAAQ,IAAI,IAAI,GACzB,OAAO,OAAO,IAAI,SAAS,YAAY,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG;EAE7E,MAAM,OAAO,IAAI,KAAK,QAAQ,SAAS,CAAC,WAAW,IAAI,OAAO,IAAI,CAAC,CAAC;EACpE,IAAI,CAAC,KAAK,QAAQ,OAAO,CAAC;EAC1B,OAAO,CAAC,KAAK,WAAW,IAAI,KAAK,SAAS,MAAM;GAAE,GAAG;GAAK,MAAM;EAAK,CAAC;CACxE,CAAC;CACH,MAAM,kBAAkB,MAAM,SAAS,SAAS,eAAe,MAAM,OAAO,IAAI,CAAC;CAEjF,OAAO;EACL,MAAM;EACN,GAAG;EACH,IAAI,KAAK,UAAU,MAAM,MAAM,KAAK;EACpC,MAAM,YAAY,MAAM,QAAQ;EAChC;EACA,SAAS;EACT,SAAS;EACT,SAAS;EACT,MAAM,MAAM,QAAS,CAAC;CACxB;AACF"}
@@ -1,155 +0,0 @@
1
- const require_utils = require("./utils-C8bWAzhv.cjs");
2
- let node_crypto = require("node:crypto");
3
- let node_path = require("node:path");
4
- node_path = require_utils.__toESM(node_path, 1);
5
- //#region ../../internals/utils/src/fs.ts
6
- /**
7
- * Strips the file extension from a path or file name.
8
- * Only removes the last `.ext` segment when the dot is not part of a directory name.
9
- *
10
- * @example
11
- * trimExtName('petStore.ts') // 'petStore'
12
- * trimExtName('/src/models/pet.ts') // '/src/models/pet'
13
- * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
14
- * trimExtName('noExtension') // 'noExtension'
15
- */
16
- function trimExtName(text) {
17
- const dotIndex = text.lastIndexOf(".");
18
- if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
19
- return text;
20
- }
21
- //#endregion
22
- //#region src/factory.ts
23
- var factory_exports = /* @__PURE__ */ require_utils.__exportAll({
24
- createArrowFunction: () => require_utils.createArrowFunction,
25
- createBreak: () => require_utils.createBreak,
26
- createConst: () => require_utils.createConst,
27
- createContent: () => require_utils.createContent,
28
- createDiscriminantNode: () => require_utils.createDiscriminantNode,
29
- createExport: () => require_utils.createExport,
30
- createFile: () => createFile,
31
- createFunction: () => require_utils.createFunction,
32
- createFunctionParameter: () => require_utils.createFunctionParameter,
33
- createFunctionParameters: () => require_utils.createFunctionParameters,
34
- createImport: () => require_utils.createImport,
35
- createIndexedAccessType: () => require_utils.createIndexedAccessType,
36
- createInput: () => require_utils.createInput,
37
- createJsx: () => require_utils.createJsx,
38
- createObjectBindingPattern: () => require_utils.createObjectBindingPattern,
39
- createOperation: () => require_utils.createOperation,
40
- createOperationParams: () => require_utils.createOperationParams,
41
- createOutput: () => require_utils.createOutput,
42
- createParameter: () => require_utils.createParameter,
43
- createProperty: () => require_utils.createProperty,
44
- createRequestBody: () => require_utils.createRequestBody,
45
- createResponse: () => require_utils.createResponse,
46
- createSchema: () => require_utils.createSchema,
47
- createSource: () => require_utils.createSource,
48
- createText: () => require_utils.createText,
49
- createType: () => require_utils.createType,
50
- createTypeLiteral: () => require_utils.createTypeLiteral,
51
- update: () => update
52
- });
53
- /**
54
- * Identity-preserving node update: returns `node` unchanged when every field in
55
- * `changes` already equals (by reference) the current value, otherwise a new node
56
- * with the changes applied.
57
- *
58
- * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the
59
- * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and
60
- * downstream passes can detect "nothing changed" by identity. Comparison is
61
- * shallow: a structurally-equal but newly-allocated array/object counts as a change.
62
- *
63
- * @example
64
- * ```ts
65
- * update(node, { name: node.name }) // -> same `node` reference
66
- * update(node, { name: 'renamed' }) // -> new node, `name` replaced
67
- * ```
68
- */
69
- function update(node, changes) {
70
- for (const key in changes) if (changes[key] !== node[key]) return {
71
- ...node,
72
- ...changes
73
- };
74
- return node;
75
- }
76
- /**
77
- * Creates a fully resolved `FileNode` from a file input descriptor.
78
- *
79
- * Computes:
80
- * - `id` SHA256 hash of the file path
81
- * - `name` `baseName` without extension
82
- * - `extname` extension extracted from `baseName`
83
- *
84
- * Deduplicates:
85
- * - `sources` via `combineSources`
86
- * - `exports` via `combineExports`
87
- * - `imports` via `combineImports` (also filters unused imports)
88
- *
89
- * @throws {Error} when `baseName` has no extension.
90
- *
91
- * @example
92
- * ```ts
93
- * const file = createFile({
94
- * baseName: 'petStore.ts',
95
- * path: 'src/models/petStore.ts',
96
- * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
97
- * imports: [createImport({ name: ['z'], path: 'zod' })],
98
- * exports: [createExport({ name: ['Pet'], path: './petStore' })],
99
- * })
100
- * // file.id = SHA256 hash of 'src/models/petStore.ts'
101
- * // file.name = 'petStore'
102
- * // file.extname = '.ts'
103
- * ```
104
- */
105
- function createFile(input) {
106
- const extname = node_path.default.extname(input.baseName) || (input.baseName.startsWith(".") ? input.baseName : "");
107
- if (!extname) throw new Error(`No extname found for ${input.baseName}`);
108
- const source = (input.sources ?? []).flatMap((item) => item.nodes ?? []).map((node) => require_utils.extractStringsFromNodes([node])).filter(Boolean).join("\n\n");
109
- const resolvedExports = input.exports?.length ? require_utils.combineExports(input.exports) : [];
110
- const combinedImports = input.imports?.length ? require_utils.combineImports(input.imports, resolvedExports, source || void 0) : [];
111
- const localNames = new Set((input.sources ?? []).map((item) => item.name).filter((name) => Boolean(name)));
112
- const nameOf = (item) => typeof item === "string" ? item : item.name ?? item.propertyName;
113
- const resolvedImports = combinedImports.filter((imp) => imp.path !== input.path).flatMap((imp) => {
114
- if (!Array.isArray(imp.name)) return typeof imp.name === "string" && localNames.has(imp.name) ? [] : [imp];
115
- const kept = imp.name.filter((item) => !localNames.has(nameOf(item)));
116
- if (!kept.length) return [];
117
- return [kept.length === imp.name.length ? imp : {
118
- ...imp,
119
- name: kept
120
- }];
121
- });
122
- const resolvedSources = input.sources?.length ? require_utils.combineSources(input.sources) : [];
123
- return {
124
- kind: "File",
125
- ...input,
126
- id: (0, node_crypto.hash)("sha256", input.path, "hex"),
127
- name: trimExtName(input.baseName),
128
- extname,
129
- imports: resolvedImports,
130
- exports: resolvedExports,
131
- sources: resolvedSources,
132
- meta: input.meta ?? {}
133
- };
134
- }
135
- //#endregion
136
- Object.defineProperty(exports, "createFile", {
137
- enumerable: true,
138
- get: function() {
139
- return createFile;
140
- }
141
- });
142
- Object.defineProperty(exports, "factory_exports", {
143
- enumerable: true,
144
- get: function() {
145
- return factory_exports;
146
- }
147
- });
148
- Object.defineProperty(exports, "update", {
149
- enumerable: true,
150
- get: function() {
151
- return update;
152
- }
153
- });
154
-
155
- //# sourceMappingURL=factory-JN-Ylfl6.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory-JN-Ylfl6.cjs","names":["path","extractStringsFromNodes","combineExports","combineImports","combineSources"],"sources":["../../../internals/utils/src/fs.ts","../src/factory.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname, join, posix, resolve } from 'node:path'\nimport { camelCase } from './casing.ts'\nimport { runtime } from './runtime.ts'\n\n/**\n * Walks up the directory tree from `cwd` (defaults to `process.cwd()`) and\n * returns the absolute path of the nearest `package.json`, or `null` when none\n * is found before reaching the filesystem root.\n *\n * @example\n * ```ts\n * const pkgPath = findPackageJSON('/home/user/project/src') // '/home/user/project/package.json'\n * ```\n */\nexport function findPackageJSON(cwd?: string): string | null {\n let dir = cwd ? resolve(cwd) : process.cwd()\n while (true) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) return pkgPath\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\n/**\n * Converts all backslashes to forward slashes.\n * Extended-length Windows paths (`\\\\?\\...`) are left unchanged.\n */\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Resolves to `true` when the file or directory at `path` exists.\n * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.\n *\n * @example\n * ```ts\n * if (await exists('./kubb.config.ts')) {\n * const content = await read('./kubb.config.ts')\n * }\n * ```\n */\nexport async function exists(path: string): Promise<boolean> {\n if (runtime.isBun) {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\n/**\n * Reads the file at `path` as a UTF-8 string.\n * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.\n *\n * @example\n * ```ts\n * const source = await read('./src/Pet.ts')\n * ```\n */\nexport async function read(path: string): Promise<string> {\n if (runtime.isBun) {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\ntype WriteOptions = {\n /**\n * When `true`, re-reads the file immediately after writing and throws if the\n * content does not match — useful for catching write failures on unreliable file systems.\n */\n sanity?: boolean\n}\n\n/**\n * Writes `data` to `path`, trimming leading/trailing whitespace before saving.\n * Skips the write when the trimmed content is empty or identical to what is already on disk.\n * Creates any missing parent directories automatically.\n * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.\n *\n * @example\n * ```ts\n * await write('./src/Pet.ts', source) // writes and returns trimmed content\n * await write('./src/Pet.ts', source) // null — file unchanged\n * await write('./src/Pet.ts', ' ') // null — empty content skipped\n * ```\n */\nexport async function write(path: string, data: string, options: WriteOptions = {}): Promise<string | null> {\n const trimmed = data.trim()\n if (trimmed === '') return null\n\n const resolved = resolve(path)\n\n if (runtime.isBun) {\n const file = Bun.file(resolved)\n const oldContent = (await file.exists()) ? await file.text() : null\n if (oldContent === trimmed) return null\n await Bun.write(resolved, trimmed)\n return trimmed\n }\n\n try {\n const oldContent = await readFile(resolved, { encoding: 'utf-8' })\n if (oldContent === trimmed) return null\n } catch {\n /* file doesn't exist yet */\n }\n\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, trimmed, { encoding: 'utf-8' })\n\n if (options.sanity) {\n const savedData = await readFile(resolved, { encoding: 'utf-8' })\n if (savedData !== trimmed) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n return savedData\n }\n\n return trimmed\n}\n\n/**\n * Recursively removes `path`. Silently succeeds when `path` does not exist.\n *\n * @example\n * ```ts\n * await clean('./dist')\n * ```\n */\nexport async function clean(path: string): Promise<void> {\n return rm(path, { recursive: true, force: true })\n}\n\n/**\n * Converts a filesystem path to use POSIX (`/`) separators.\n *\n * Most of the codebase compares and composes paths as strings (prefix matching, joining for\n * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated\n * paths, but on Windows it returns `\\`-separated paths, which breaks every such comparison.\n *\n * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the\n * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is\n * exercisable from POSIX CI.\n *\n * @example\n * toPosixPath('C:\\\\repo\\\\src\\\\pet.ts') // 'C:/repo/src/pet.ts'\n */\nexport function toPosixPath(filePath: string): string {\n return filePath.replaceAll('\\\\', '/')\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = camelCase): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : camelCase(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { hash } from 'node:crypto'\nimport path from 'node:path'\nimport { trimExtName } from '@internals/utils'\nimport type { FileNode, Node } from './nodes/index.ts'\nimport { combineExports, combineImports, combineSources } from './utils/ast.ts'\nimport { extractStringsFromNodes } from './utils/extractStringsFromNodes.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createImport, createSource } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\nexport { createDiscriminantNode, createOperationParams } from './utils/ast.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the\n * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is\n * shallow: a structurally-equal but newly-allocated array/object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\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({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ 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 */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const rawExtname = path.extname(input.baseName)\n // Handle dotfile basename like '.ts' where path.extname returns ''\n const extname = (rawExtname || (input.baseName.startsWith('.') ? input.baseName : '')) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const source = (input.sources ?? [])\n .flatMap((item) => item.nodes ?? [])\n .map((node) => extractStringsFromNodes([node]))\n .filter(Boolean)\n .join('\\n\\n')\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const combinedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || undefined) : []\n const localNames = new Set((input.sources ?? []).map((item) => item.name).filter((name): name is string => Boolean(name)))\n const nameOf = (item: string | { propertyName: string; name?: string }): string => (typeof item === 'string' ? item : (item.name ?? item.propertyName))\n // Drop self-imports. Consolidating output (`mode: 'file'`) can place a symbol's\n // definition and a cross-file import of it in the same file. The first pass catches imports that\n // resolve to this file's own path. The second drops imports of names the file already defines,\n // the case consolidation produces when the import path no longer matches `input.path`. Sources\n // stay intact, so the local definition remains. Bare specifiers like `'zod'` never match a path.\n const resolvedImports = combinedImports\n .filter((imp) => imp.path !== input.path)\n .flatMap((imp) => {\n if (!Array.isArray(imp.name)) {\n return typeof imp.name === 'string' && localNames.has(imp.name) ? [] : [imp]\n }\n const kept = imp.name.filter((item) => !localNames.has(nameOf(item)))\n if (!kept.length) return []\n return [kept.length === imp.name.length ? imp : { ...imp, name: kept }]\n })\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n return {\n kind: 'File',\n ...input,\n id: hash('sha256', input.path, 'hex'),\n name: trimExtName(input.baseName),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,\n sources: resolvedSources,\n meta: input.meta ?? ({} as TMeta),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8LA,SAAgB,YAAY,MAAsB;CAChD,MAAM,WAAW,KAAK,YAAY,GAAG;CACrC,IAAI,WAAW,KAAK,CAAC,KAAK,SAAS,KAAK,QAAQ,GAC9C,OAAO,KAAK,MAAM,GAAG,QAAQ;CAE/B,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5JA,SAAgB,OAAuB,MAAS,SAAwB;CACtE,KAAK,MAAM,OAAO,SAChB,IAAI,QAAQ,SAAS,KAAK,MACxB,OAAO;EAAE,GAAG;EAAM,GAAG;CAAQ;CAIjC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,WAA0C,OAA6C;CAGrG,MAAM,UAFaA,UAAAA,QAAK,QAAQ,MAAM,QAEZ,MAAM,MAAM,SAAS,WAAW,GAAG,IAAI,MAAM,WAAW;CAClF,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,wBAAwB,MAAM,UAAU;CAG1D,MAAM,UAAU,MAAM,WAAW,CAAC,EAAA,CAC/B,SAAS,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CACnC,KAAK,SAASC,cAAAA,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAC9C,OAAO,OAAO,CAAC,CACf,KAAK,MAAM;CACd,MAAM,kBAAkB,MAAM,SAAS,SAASC,cAAAA,eAAe,MAAM,OAAO,IAAI,CAAC;CACjF,MAAM,kBAAkB,MAAM,SAAS,SAASC,cAAAA,eAAe,MAAM,SAAS,iBAAiB,UAAU,KAAA,CAAS,IAAI,CAAC;CACvH,MAAM,aAAa,IAAI,KAAK,MAAM,WAAW,CAAC,EAAA,CAAG,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC,QAAQ,SAAyB,QAAQ,IAAI,CAAC,CAAC;CACzH,MAAM,UAAU,SAAoE,OAAO,SAAS,WAAW,OAAQ,KAAK,QAAQ,KAAK;CAMzI,MAAM,kBAAkB,gBACrB,QAAQ,QAAQ,IAAI,SAAS,MAAM,IAAI,CAAC,CACxC,SAAS,QAAQ;EAChB,IAAI,CAAC,MAAM,QAAQ,IAAI,IAAI,GACzB,OAAO,OAAO,IAAI,SAAS,YAAY,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG;EAE7E,MAAM,OAAO,IAAI,KAAK,QAAQ,SAAS,CAAC,WAAW,IAAI,OAAO,IAAI,CAAC,CAAC;EACpE,IAAI,CAAC,KAAK,QAAQ,OAAO,CAAC;EAC1B,OAAO,CAAC,KAAK,WAAW,IAAI,KAAK,SAAS,MAAM;GAAE,GAAG;GAAK,MAAM;EAAK,CAAC;CACxE,CAAC;CACH,MAAM,kBAAkB,MAAM,SAAS,SAASC,cAAAA,eAAe,MAAM,OAAO,IAAI,CAAC;CAEjF,OAAO;EACL,MAAM;EACN,GAAG;EACH,KAAA,GAAA,YAAA,KAAA,CAAS,UAAU,MAAM,MAAM,KAAK;EACpC,MAAM,YAAY,MAAM,QAAQ;EAChC;EACA,SAAS;EACT,SAAS;EACT,SAAS;EACT,MAAM,MAAM,QAAS,CAAC;CACxB;AACF"}