@kubb/fabric-core 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/{types-lS0JaZqX.d.cts → KubbFile-BrN7Wwp6.d.cts} +3 -3
  2. package/dist/{types-BY5X8xoR.d.ts → KubbFile-BzVkcu9M.d.ts} +3 -3
  3. package/dist/createFileParser-BD8yn0LT.cjs +14 -0
  4. package/dist/createFileParser-BD8yn0LT.cjs.map +1 -0
  5. package/dist/createFileParser-Cix3AMLd.js +8 -0
  6. package/dist/createFileParser-Cix3AMLd.js.map +1 -0
  7. package/dist/default-DCpuPmrL.js +10 -0
  8. package/dist/default-DCpuPmrL.js.map +1 -0
  9. package/dist/default-DNBu_jsL.cjs +15 -0
  10. package/dist/default-DNBu_jsL.cjs.map +1 -0
  11. package/dist/defineApp-CZYKsxTp.d.ts +95 -0
  12. package/dist/defineApp-c9lWJ96_.d.cts +95 -0
  13. package/dist/index.cjs +146 -87
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +13 -60
  16. package/dist/index.d.ts +13 -60
  17. package/dist/index.js +136 -76
  18. package/dist/index.js.map +1 -1
  19. package/dist/parsers/default.cjs +4 -0
  20. package/dist/parsers/default.d.cts +8 -0
  21. package/dist/parsers/default.d.ts +8 -0
  22. package/dist/parsers/default.js +4 -0
  23. package/dist/parsers/tsx.cjs +4 -2
  24. package/dist/parsers/tsx.d.cts +3 -3
  25. package/dist/parsers/tsx.d.ts +3 -3
  26. package/dist/parsers/tsx.js +3 -1
  27. package/dist/parsers/typescript.cjs +6 -5
  28. package/dist/parsers/typescript.d.cts +3 -3
  29. package/dist/parsers/typescript.d.ts +3 -3
  30. package/dist/parsers/typescript.js +2 -1
  31. package/dist/tsx-BSUaIML3.cjs +16 -0
  32. package/dist/tsx-BSUaIML3.cjs.map +1 -0
  33. package/dist/tsx-DBAk9dqS.js +11 -0
  34. package/dist/tsx-DBAk9dqS.js.map +1 -0
  35. package/dist/types-CkbelZaS.d.ts +15 -0
  36. package/dist/types-GueHciQ3.d.cts +15 -0
  37. package/dist/types.cjs +12 -0
  38. package/dist/types.cjs.map +1 -0
  39. package/dist/types.d.cts +3 -0
  40. package/dist/types.d.ts +3 -0
  41. package/dist/types.js +6 -0
  42. package/dist/types.js.map +1 -0
  43. package/dist/{parser-CWB_OBtr.js → typescript-C60gWBu8.js} +4 -34
  44. package/dist/typescript-C60gWBu8.js.map +1 -0
  45. package/dist/{parser-QF8j8-pj.cjs → typescript-Z90jN87k.cjs} +5 -47
  46. package/dist/typescript-Z90jN87k.cjs.map +1 -0
  47. package/package.json +15 -1
  48. package/src/FileManager.ts +21 -200
  49. package/src/FileProcessor.ts +86 -0
  50. package/src/KubbFile.ts +132 -0
  51. package/src/createFile.ts +167 -0
  52. package/src/defineApp.ts +6 -6
  53. package/src/index.ts +4 -2
  54. package/src/parsers/createFileParser.ts +5 -0
  55. package/src/parsers/default.ts +7 -0
  56. package/src/parsers/tsx.ts +1 -1
  57. package/src/parsers/types.ts +12 -0
  58. package/src/parsers/typescript.ts +1 -1
  59. package/src/types.ts +2 -132
  60. package/src/utils/EventEmitter.ts +23 -0
  61. package/dist/parser-Bck6QDwN.d.cts +0 -15
  62. package/dist/parser-CRl-iUw1.d.ts +0 -15
  63. package/dist/parser-CWB_OBtr.js.map +0 -1
  64. package/dist/parser-QF8j8-pj.cjs.map +0 -1
  65. package/src/parsers/parser.ts +0 -56
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["resolvedFiles: Array<KubbFile.ResolvedFile>","path","name","createApp","app: App","options"],"sources":["../src/utils/Cache.ts","../src/FileManager.ts","../src/defineApp.ts","../src/createApp.ts","../src/types.ts"],"sourcesContent":["export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import pLimit from 'p-limit'\n\nimport type * as KubbFile from './types.ts'\nimport { parseFile } from './parsers/parser.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName, write } from './fs.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { orderBy } from 'natural-orderby'\nimport { isDeepEqual, uniqueBy } from 'remeda'\n\ntype WriteFilesProps = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #limit = pLimit(100)\n\n constructor() {\n return this\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (const file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n return resolvedFiles\n }\n\n flush() {\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n }\n\n clear(): void {\n this.#cache.clear()\n }\n\n getFiles(): Array<KubbFile.ResolvedFile> {\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files = keys.map((key) => this.#cache.get(key))\n\n return files.filter(Boolean)\n }\n\n async processFiles({ dryRun, extension }: WriteFilesProps): Promise<Array<KubbFile.ResolvedFile>> {\n const files = this.getFiles()\n\n const promises = files.map((resolvedFile) => {\n return this.#limit(async () => {\n const extname = extension ? extension[resolvedFile.extname] || undefined : resolvedFile.extname\n\n if (!dryRun) {\n const source = await parseFile(resolvedFile, { extname })\n\n await write(resolvedFile.path, source, { sanity: false })\n }\n })\n })\n\n await Promise.all(promises)\n\n return files\n }\n}\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: hashObject({ path: file.path }),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n","import type * as KubbFile from './types.ts'\nimport { FileManager } from './FileManager.ts'\nimport { isPromise } from 'remeda'\n\nconst isFunction = (val: unknown): val is Function => typeof val === 'function'\n\ntype Component = any\n\ntype PluginInstallFunction<Options = any[]> = Options extends unknown[] ? (app: App, ...options: Options) => any : (app: App, options: Options) => any\n\nexport type ObjectPlugin<Options = any[]> = {\n install: PluginInstallFunction<Options>\n}\nexport type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> & Partial<ObjectPlugin<Options>>\n\ntype AppRenderer = {\n render(): Promise<void> | void\n renderToString(): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\nexport type AppContext<TOptions = unknown> = {\n options?: TOptions\n fileManager: FileManager\n addFile(...files: Array<KubbFile.File>): Promise<void>\n files: Array<KubbFile.ResolvedFile>\n clear: () => void\n}\n\ntype RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer\n\ntype Plugin<Options = any[], P extends unknown[] = Options extends unknown[] ? Options : [Options]> = FunctionPlugin<P> | ObjectPlugin<P>\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nexport interface App {\n _component: Component\n render(): Promise<void>\n renderToString(): Promise<string>\n getFiles(): Promise<Array<KubbFile.ResolvedFile>>\n use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this\n write(options?: WriteOptions): Promise<void>\n addFile(...files: Array<KubbFile.File>): Promise<void>\n waitUntilExit(): Promise<void>\n}\n\nexport type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App\n\nexport function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext> {\n function createApp(rootComponent: Component, options?: TContext['options']): App {\n const installedPlugins = new WeakSet()\n const fileManager = new FileManager()\n const context = {\n options,\n fileManager,\n async addFile(...newFiles) {\n await fileManager.add(...newFiles)\n },\n clear() {\n context.fileManager.clear()\n },\n get files() {\n return fileManager.getFiles()\n },\n } as TContext\n\n const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)\n\n const app: App = {\n _component: rootComponent,\n async render() {\n if (isPromise(render)) {\n await render()\n } else {\n render()\n }\n },\n async renderToString() {\n return renderToString()\n },\n async getFiles() {\n return fileManager.getFiles()\n },\n waitUntilExit,\n addFile: context.addFile,\n async write(\n options = {\n extension: { '.ts': '.ts' },\n dryRun: false,\n },\n ) {\n await fileManager.processFiles({\n extension: options.extension,\n dryRun: options.dryRun,\n })\n },\n use(plugin: Plugin, ...options: any[]) {\n if (installedPlugins.has(plugin)) {\n console.warn('Plugin has already been applied to target app.')\n } else if (plugin && isFunction(plugin.install)) {\n installedPlugins.add(plugin)\n plugin.install(app, ...options)\n } else if (isFunction(plugin)) {\n installedPlugins.add(plugin)\n plugin(app, ...options)\n }\n\n return app\n },\n }\n\n return app\n }\n\n return createApp\n}\n","import { defineApp } from './defineApp.ts'\n\nexport const createApp = defineApp(() => {\n return {\n async render() {\n throw new Error('Method not implemented')\n },\n async renderToString() {\n throw new Error('Method not implemented')\n },\n async waitUntilExit() {\n throw new Error('Method not implemented')\n },\n }\n})\n","type BasePath<T extends string = string> = `${T}/`\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name:\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n\n isNameSpace?: boolean\n /**\n * When root is set it will get the path with relative getRelativePath(root, path).\n */\n root?: string\n}\n\nexport type Source = {\n name?: string\n value?: string\n isTypeOnly?: boolean\n /**\n * Has const or type 'export'\n * @default false\n */\n isExportable?: boolean\n /**\n * When set, barrel generation will add this\n * @default false\n */\n isIndexable?: boolean\n}\n\nexport type Export = {\n /**\n * Export name to be used.\n * @example [\"useState\"]\n * @example \"React\"\n */\n name?: string | Array<string>\n /**\n * Path for the import.\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.\n */\n asAlias?: boolean\n}\n\nexport type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\nexport type Mode = 'single' | 'split'\n\n/**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\nexport type BaseName = `${string}.${string}`\n\n/**\n * Path will be full qualified path to a specified file\n */\nexport type Path = string\n\nexport type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`\n\nexport type OptionalPath = Path | undefined | null\n\nexport type File<TMeta extends object = object> = {\n /**\n * Name to be used to create the path\n * Based on UNIX basename, `${name}.extname`\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: BaseName\n /**\n * Path will be full qualified path to a specified file\n */\n path: AdvancedPath<BaseName> | Path\n sources: Array<Source>\n imports?: Array<Import>\n exports?: Array<Export>\n /**\n * Use extra meta, this is getting used to generate the barrel/index files.\n */\n meta?: TMeta\n banner?: string\n footer?: string\n}\n\nexport type ResolvedImport = Import\n\nexport type ResolvedExport = Export\n\nexport type ResolvedFile<TMeta extends object = object> = File<TMeta> & {\n /**\n * @default hash\n */\n id: string\n /**\n * Contains the first part of the baseName, generated based on baseName\n * @link https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n extname: Extname\n imports: Array<ResolvedImport>\n exports: Array<ResolvedExport>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAsB;;4DACV,IAAI,KAAgB;;CAE9B,IAAI,KAAuB;;AACzB,6DAAO,KAAY,CAAC,IAAI,IAAI,+DAAI;;CAGlC,IAAI,KAAa,OAAgB;AAC/B,uCAAY,CAAC,IAAI,KAAK,MAAM;;CAG9B,OAAO,KAAmB;AACxB,uCAAY,CAAC,OAAO,IAAI;;CAG1B,QAAc;AACZ,uCAAY,CAAC,OAAO;;CAGtB,OAAiB;AACf,SAAO,CAAC,mCAAG,KAAY,CAAC,MAAM,CAAC;;CAGjC,SAAmB;AACjB,SAAO,CAAC,mCAAG,KAAY,CAAC,QAAQ,CAAC;;CAGnC,QAAc;;;;;;;ACXhB,IAAa,cAAb,MAAyB;CAIvB,cAAc;2CAHL,IAAI,OAA8B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rD,UAAU,WAAW,OAAO,QAAQ,EAAE;AAC/C,sBAAiB,IAAI,OAAO;AAC5B,YAAO,QAAQ,KAAK,GAAGA,UAAQ;eACtB,WAAW,OAAO,EAAE;AAC7B,sBAAiB,IAAI,OAAO;AAC5B,YAAO,KAAK,GAAGA,UAAQ;;AAGzB,WAAO;;GAEV;AAED,SAAO;;AAGT,QAAOF;;;;;ACnHT,MAAa,YAAY,gBAAgB;AACvC,QAAO;EACL,MAAM,SAAS;AACb,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,iBAAiB;AACrB,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,gBAAgB;AACpB,SAAM,IAAI,MAAM,yBAAyB;;EAE5C;EACD"}
1
+ {"version":3,"file":"index.js","names":["name","EventEmitter","NodeEventEmitter","parsers: Record<KubbFile.Extname, Parser<any>>","EventEmitter","resolvedFiles: Array<KubbFile.ResolvedFile>","path","createApp","app: App","options"],"sources":["../src/utils/Cache.ts","../src/createFile.ts","../src/utils/EventEmitter.ts","../src/FileProcessor.ts","../src/FileManager.ts","../src/defineApp.ts","../src/createApp.ts"],"sourcesContent":["export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { trimExtName } from './fs.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { isDeepEqual, uniqueBy } from 'remeda'\nimport { orderBy } from 'natural-orderby'\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: hashObject({ path: file.path }),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\n\nexport class EventEmitter<TEvents extends Record<string, any>> {\n constructor(maxListener = 100) {\n this.#emitter.setMaxListeners(maxListener)\n }\n #emitter = new NodeEventEmitter()\n\n emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void {\n this.#emitter.emit(eventName, ...(eventArg as any))\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { write } from './fs.ts'\nimport pLimit from 'p-limit'\nimport type { Parser } from './parsers/types.ts'\nimport { typeScriptParser } from './parsers/typescript.ts'\nimport { tsxParser } from './parsers/tsx.ts'\nimport { defaultParser } from './parsers/default.ts'\n\ntype FileProcessorEvents = {\n start: [{ files: KubbFile.ResolvedFile[] }]\n finish: [{ files: KubbFile.ResolvedFile[] }]\n 'file:start': [{ file: KubbFile.ResolvedFile }]\n 'file:finish': [{ file: KubbFile.ResolvedFile }]\n}\n\nexport type ProcessFilesProps = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\ntype GetSourceOptions = {\n extname?: KubbFile.Extname\n}\n\nasync function getParser<TMeta extends object = object>(extname: KubbFile.Extname | undefined): Promise<Parser<TMeta>> {\n const parsers: Record<KubbFile.Extname, Parser<any>> = {\n '.ts': typeScriptParser,\n '.js': typeScriptParser,\n '.jsx': tsxParser,\n '.tsx': tsxParser,\n '.json': defaultParser,\n }\n\n if (!extname) {\n return defaultParser\n }\n\n const parser = parsers[extname]\n\n if (!parser) {\n console.warn(`[parser] No parser found for ${extname}, default parser will be used`)\n }\n\n return parser || defaultParser\n}\n\nexport async function parseFile(file: KubbFile.ResolvedFile, { extname }: GetSourceOptions = {}): Promise<string> {\n const parser = await getParser(file.extname)\n\n return parser.print(file, { extname })\n}\n\nexport class FileProcessor extends EventEmitter<FileProcessorEvents> {\n #limit = pLimit(100)\n\n constructor(maxListener = 1000) {\n super(maxListener)\n return this\n }\n\n async run(files: Array<KubbFile.ResolvedFile>, { dryRun, extension }: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n this.emit('start', { files })\n\n const promises = files.map((resolvedFile) =>\n this.#limit(async () => {\n const extname = extension?.[resolvedFile.extname] || undefined\n\n this.emit('file:start', { file: resolvedFile })\n\n if (!dryRun) {\n const source = await parseFile(resolvedFile, { extname })\n await write(resolvedFile.path, source, { sanity: false })\n }\n\n this.emit('file:finish', { file: resolvedFile })\n }),\n )\n\n await Promise.all(promises)\n\n this.emit('finish', { files })\n\n return files\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName } from './fs.ts'\nimport { orderBy } from 'natural-orderby'\nimport { createFile } from './createFile.ts'\nimport { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #processor = new FileProcessor()\n\n constructor() {\n return this\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (const file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n return resolvedFiles\n }\n\n flush() {\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n }\n\n clear(): void {\n this.#cache.clear()\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files = keys.map((key) => this.#cache.get(key))\n\n return files.filter(Boolean)\n }\n\n get processor() {\n const files = this.files\n const processor = this.#processor\n\n return {\n async run(options: ProcessFilesProps) {\n return processor.run(files, options)\n },\n }\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { FileManager } from './FileManager.ts'\nimport { isPromise } from 'remeda'\n\nconst isFunction = (val: unknown): val is Function => typeof val === 'function'\n\ntype Component = any\n\ntype PluginInstallFunction<Options = any[]> = Options extends unknown[] ? (app: App, ...options: Options) => any : (app: App, options: Options) => any\n\nexport type ObjectPlugin<Options = any[]> = {\n install: PluginInstallFunction<Options>\n}\nexport type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> & Partial<ObjectPlugin<Options>>\n\ntype AppRenderer = {\n render(): Promise<void> | void\n renderToString(): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\nexport type AppContext<TOptions = unknown> = {\n options?: TOptions\n fileManager: FileManager\n addFile(...files: Array<KubbFile.File>): Promise<void>\n files: Array<KubbFile.ResolvedFile>\n clear: () => void\n}\n\ntype RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer\n\ntype Plugin<Options = any[], P extends unknown[] = Options extends unknown[] ? Options : [Options]> = FunctionPlugin<P> | ObjectPlugin<P>\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nexport interface App {\n _component: Component\n render(): Promise<void>\n renderToString(): Promise<string>\n files: Array<KubbFile.ResolvedFile>\n use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this\n write(options?: WriteOptions): Promise<void>\n addFile(...files: Array<KubbFile.File>): Promise<void>\n waitUntilExit(): Promise<void>\n}\n\nexport type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App\n\nexport function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext> {\n function createApp(rootComponent: Component, options?: TContext['options']): App {\n const installedPlugins = new WeakSet()\n const fileManager = new FileManager()\n const context = {\n options,\n fileManager,\n async addFile(...newFiles) {\n await fileManager.add(...newFiles)\n },\n clear() {\n context.fileManager.clear()\n },\n get files() {\n return fileManager.files\n },\n } as TContext\n\n const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)\n\n const app: App = {\n _component: rootComponent,\n async render() {\n if (isPromise(render)) {\n await render()\n } else {\n render()\n }\n },\n async renderToString() {\n return renderToString()\n },\n get files() {\n return fileManager.files\n },\n waitUntilExit,\n addFile: context.addFile,\n async write(\n options = {\n extension: { '.ts': '.ts' },\n dryRun: false,\n },\n ) {\n await fileManager.processor.run({\n extension: options.extension,\n dryRun: options.dryRun,\n })\n },\n use(plugin: Plugin, ...options: any[]) {\n if (installedPlugins.has(plugin)) {\n console.warn('Plugin has already been applied to target app.')\n } else if (plugin && isFunction(plugin.install)) {\n installedPlugins.add(plugin)\n plugin.install(app, ...options)\n } else if (isFunction(plugin)) {\n installedPlugins.add(plugin)\n plugin(app, ...options)\n }\n\n return app\n },\n }\n\n return app\n }\n\n return createApp\n}\n","import { defineApp } from './defineApp.ts'\n\nexport const createApp = defineApp(() => {\n return {\n async render() {\n throw new Error('Method not implemented')\n },\n async renderToString() {\n throw new Error('Method not implemented')\n },\n async waitUntilExit() {\n throw new Error('Method not implemented')\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAsB;;4DACV,IAAI,KAAgB;;CAE9B,IAAI,KAAuB;;AACzB,6DAAO,KAAY,CAAC,IAAI,IAAI,+DAAI;;CAGlC,IAAI,KAAa,OAAgB;AAC/B,uCAAY,CAAC,IAAI,KAAK,MAAM;;CAG9B,OAAO,KAAmB;AACxB,uCAAY,CAAC,OAAO,IAAI;;CAG1B,QAAc;AACZ,uCAAY,CAAC,OAAO;;CAGtB,OAAiB;AACf,SAAO,CAAC,mCAAG,KAAY,CAAC,MAAM,CAAC;;CAGjC,SAAmB;AACjB,SAAO,CAAC,mCAAG,KAAY,CAAC,QAAQ,CAAC;;CAGnC,QAAc;;;;;ACpBhB,SAAS,WAAW,KAAsC;CACxD,MAAM,MAAM,KAAK,UAAU,KAAK,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC;AACxD,QAAO,WAAW,SAAS,CAAC,OAAO,IAAI,CAAC,OAAO,MAAM;;AAGvD,SAAgB,eAAe,SAAyD;AACtF,QAAO,SAAS,UAAU,QAAQ;EAAC,IAAI;EAAM,IAAI;EAAc,IAAI;EAAW,CAAU;;AAG1F,SAAgB,eAAe,SAAyD;AACtF,QAAO,QAAQ,SAAS;GACrB,MAAM,CAAC,CAAC,MAAM,QAA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MAAM,yBAAyB;;EAE3C,MAAM,gBAAgB;AACpB,SAAM,IAAI,MAAM,yBAAyB;;EAE5C;EACD"}
@@ -0,0 +1,4 @@
1
+ require('../createFileParser-BD8yn0LT.cjs');
2
+ const require_default = require('../default-DNBu_jsL.cjs');
3
+
4
+ exports.defaultParser = require_default.defaultParser;
@@ -0,0 +1,8 @@
1
+ import "../KubbFile-BrN7Wwp6.cjs";
2
+ import { t as Parser } from "../types-GueHciQ3.cjs";
3
+
4
+ //#region src/parsers/default.d.ts
5
+ declare const defaultParser: Parser<object>;
6
+ //#endregion
7
+ export { defaultParser };
8
+ //# sourceMappingURL=default.d.cts.map
@@ -0,0 +1,8 @@
1
+ import "../KubbFile-BzVkcu9M.js";
2
+ import { t as Parser } from "../types-CkbelZaS.js";
3
+
4
+ //#region src/parsers/default.d.ts
5
+ declare const defaultParser: Parser<object>;
6
+ //#endregion
7
+ export { defaultParser };
8
+ //# sourceMappingURL=default.d.ts.map
@@ -0,0 +1,4 @@
1
+ import "../createFileParser-Cix3AMLd.js";
2
+ import { t as defaultParser } from "../default-DCpuPmrL.js";
3
+
4
+ export { defaultParser };
@@ -1,3 +1,5 @@
1
- const require_parser = require('../parser-QF8j8-pj.cjs');
1
+ require('../typescript-Z90jN87k.cjs');
2
+ require('../createFileParser-BD8yn0LT.cjs');
3
+ const require_tsx = require('../tsx-BSUaIML3.cjs');
2
4
 
3
- exports.tsxParser = require_parser.tsxParser;
5
+ exports.tsxParser = require_tsx.tsxParser;
@@ -1,8 +1,8 @@
1
- import "../types-lS0JaZqX.cjs";
2
- import { t as ParserModule } from "../parser-Bck6QDwN.cjs";
1
+ import "../KubbFile-BrN7Wwp6.cjs";
2
+ import { t as Parser } from "../types-GueHciQ3.cjs";
3
3
 
4
4
  //#region src/parsers/tsx.d.ts
5
- declare const tsxParser: ParserModule<object>;
5
+ declare const tsxParser: Parser<object>;
6
6
  //#endregion
7
7
  export { tsxParser };
8
8
  //# sourceMappingURL=tsx.d.cts.map
@@ -1,8 +1,8 @@
1
- import "../types-BY5X8xoR.js";
2
- import { t as ParserModule } from "../parser-CRl-iUw1.js";
1
+ import "../KubbFile-BzVkcu9M.js";
2
+ import { t as Parser } from "../types-CkbelZaS.js";
3
3
 
4
4
  //#region src/parsers/tsx.d.ts
5
- declare const tsxParser: ParserModule<object>;
5
+ declare const tsxParser: Parser<object>;
6
6
  //#endregion
7
7
  export { tsxParser };
8
8
  //# sourceMappingURL=tsx.d.ts.map
@@ -1,3 +1,5 @@
1
- import { n as tsxParser } from "../parser-CWB_OBtr.js";
1
+ import "../typescript-C60gWBu8.js";
2
+ import "../createFileParser-Cix3AMLd.js";
3
+ import { t as tsxParser } from "../tsx-DBAk9dqS.js";
2
4
 
3
5
  export { tsxParser };
@@ -1,6 +1,7 @@
1
- const require_parser = require('../parser-QF8j8-pj.cjs');
1
+ const require_typescript = require('../typescript-Z90jN87k.cjs');
2
+ require('../createFileParser-BD8yn0LT.cjs');
2
3
 
3
- exports.createExport = require_parser.createExport;
4
- exports.createImport = require_parser.createImport;
5
- exports.print = require_parser.print;
6
- exports.typeScriptParser = require_parser.typeScriptParser;
4
+ exports.createExport = require_typescript.createExport;
5
+ exports.createImport = require_typescript.createImport;
6
+ exports.print = require_typescript.print;
7
+ exports.typeScriptParser = require_typescript.typeScriptParser;
@@ -1,5 +1,5 @@
1
- import "../types-lS0JaZqX.cjs";
2
- import { t as ParserModule } from "../parser-Bck6QDwN.cjs";
1
+ import "../KubbFile-BrN7Wwp6.cjs";
2
+ import { t as Parser } from "../types-GueHciQ3.cjs";
3
3
  import ts from "typescript";
4
4
 
5
5
  //#region src/parsers/typescript.d.ts
@@ -45,7 +45,7 @@ declare function createExport({
45
45
  isTypeOnly?: boolean;
46
46
  name?: string | Array<ts.Identifier | string>;
47
47
  }): ts.ExportDeclaration;
48
- declare const typeScriptParser: ParserModule<object>;
48
+ declare const typeScriptParser: Parser<object>;
49
49
  //#endregion
50
50
  export { createExport, createImport, print, typeScriptParser };
51
51
  //# sourceMappingURL=typescript.d.cts.map
@@ -1,5 +1,5 @@
1
- import "../types-BY5X8xoR.js";
2
- import { t as ParserModule } from "../parser-CRl-iUw1.js";
1
+ import "../KubbFile-BzVkcu9M.js";
2
+ import { t as Parser } from "../types-CkbelZaS.js";
3
3
  import ts from "typescript";
4
4
 
5
5
  //#region src/parsers/typescript.d.ts
@@ -45,7 +45,7 @@ declare function createExport({
45
45
  isTypeOnly?: boolean;
46
46
  name?: string | Array<ts.Identifier | string>;
47
47
  }): ts.ExportDeclaration;
48
- declare const typeScriptParser: ParserModule<object>;
48
+ declare const typeScriptParser: Parser<object>;
49
49
  //#endregion
50
50
  export { createExport, createImport, print, typeScriptParser };
51
51
  //# sourceMappingURL=typescript.d.ts.map
@@ -1,3 +1,4 @@
1
- import { a as print, i as createImport, o as typeScriptParser, r as createExport } from "../parser-CWB_OBtr.js";
1
+ import { i as typeScriptParser, n as createImport, r as print, t as createExport } from "../typescript-C60gWBu8.js";
2
+ import "../createFileParser-Cix3AMLd.js";
2
3
 
3
4
  export { createExport, createImport, print, typeScriptParser };
@@ -0,0 +1,16 @@
1
+ const require_typescript = require('./typescript-Z90jN87k.cjs');
2
+ const require_createFileParser = require('./createFileParser-BD8yn0LT.cjs');
3
+
4
+ //#region src/parsers/tsx.ts
5
+ const tsxParser = require_createFileParser.createFileParser({ async print(file, options = { extname: ".tsx" }) {
6
+ return require_typescript.typeScriptParser.print(file, options);
7
+ } });
8
+
9
+ //#endregion
10
+ Object.defineProperty(exports, 'tsxParser', {
11
+ enumerable: true,
12
+ get: function () {
13
+ return tsxParser;
14
+ }
15
+ });
16
+ //# sourceMappingURL=tsx-BSUaIML3.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsx-BSUaIML3.cjs","names":["createFileParser","typeScriptParser"],"sources":["../src/parsers/tsx.ts"],"sourcesContent":["import { typeScriptParser } from './typescript.ts'\nimport { createFileParser } from './createFileParser.ts'\n\nexport const tsxParser = createFileParser({\n async print(file, options = { extname: '.tsx' }) {\n return typeScriptParser.print(file, options)\n },\n})\n"],"mappings":";;;;AAGA,MAAa,YAAYA,0CAAiB,EACxC,MAAM,MAAM,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAE;AAC/C,QAAOC,oCAAiB,MAAM,MAAM,QAAQ;GAE/C,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { i as typeScriptParser } from "./typescript-C60gWBu8.js";
2
+ import { t as createFileParser } from "./createFileParser-Cix3AMLd.js";
3
+
4
+ //#region src/parsers/tsx.ts
5
+ const tsxParser = createFileParser({ async print(file, options = { extname: ".tsx" }) {
6
+ return typeScriptParser.print(file, options);
7
+ } });
8
+
9
+ //#endregion
10
+ export { tsxParser as t };
11
+ //# sourceMappingURL=tsx-DBAk9dqS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsx-DBAk9dqS.js","names":[],"sources":["../src/parsers/tsx.ts"],"sourcesContent":["import { typeScriptParser } from './typescript.ts'\nimport { createFileParser } from './createFileParser.ts'\n\nexport const tsxParser = createFileParser({\n async print(file, options = { extname: '.tsx' }) {\n return typeScriptParser.print(file, options)\n },\n})\n"],"mappings":";;;;AAGA,MAAa,YAAY,iBAAiB,EACxC,MAAM,MAAM,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAE;AAC/C,QAAO,iBAAiB,MAAM,MAAM,QAAQ;GAE/C,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { a as ResolvedFile, t as Extname } from "./KubbFile-BzVkcu9M.js";
2
+
3
+ //#region src/parsers/types.d.ts
4
+ type PrintOptions = {
5
+ extname?: Extname;
6
+ };
7
+ type Parser<TMeta extends object = object> = {
8
+ /**
9
+ * Convert a file to string
10
+ */
11
+ print: (file: ResolvedFile<TMeta>, options: PrintOptions) => Promise<string>;
12
+ };
13
+ //#endregion
14
+ export { Parser as t };
15
+ //# sourceMappingURL=types-CkbelZaS.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { a as ResolvedFile, t as Extname } from "./KubbFile-BrN7Wwp6.cjs";
2
+
3
+ //#region src/parsers/types.d.ts
4
+ type PrintOptions = {
5
+ extname?: Extname;
6
+ };
7
+ type Parser<TMeta extends object = object> = {
8
+ /**
9
+ * Convert a file to string
10
+ */
11
+ print: (file: ResolvedFile<TMeta>, options: PrintOptions) => Promise<string>;
12
+ };
13
+ //#endregion
14
+ export { Parser as t };
15
+ //# sourceMappingURL=types-GueHciQ3.d.cts.map
package/dist/types.cjs ADDED
@@ -0,0 +1,12 @@
1
+
2
+ //#region src/KubbFile.ts
3
+ var KubbFile_exports = {};
4
+
5
+ //#endregion
6
+ Object.defineProperty(exports, 'KubbFile', {
7
+ enumerable: true,
8
+ get: function () {
9
+ return KubbFile_exports;
10
+ }
11
+ });
12
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../src/KubbFile.ts"],"sourcesContent":["type BasePath<T extends string = string> = `${T}/`\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name:\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n\n isNameSpace?: boolean\n /**\n * When root is set it will get the path with relative getRelativePath(root, path).\n */\n root?: string\n}\n\nexport type Source = {\n name?: string\n value?: string\n isTypeOnly?: boolean\n /**\n * Has const or type 'export'\n * @default false\n */\n isExportable?: boolean\n /**\n * When set, barrel generation will add this\n * @default false\n */\n isIndexable?: boolean\n}\n\nexport type Export = {\n /**\n * Export name to be used.\n * @example [\"useState\"]\n * @example \"React\"\n */\n name?: string | Array<string>\n /**\n * Path for the import.\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.\n */\n asAlias?: boolean\n}\n\nexport type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\nexport type Mode = 'single' | 'split'\n\n/**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\nexport type BaseName = `${string}.${string}`\n\n/**\n * Path will be full qualified path to a specified file\n */\nexport type Path = string\n\nexport type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`\n\nexport type OptionalPath = Path | undefined | null\n\nexport type File<TMeta extends object = object> = {\n /**\n * Name to be used to create the path\n * Based on UNIX basename, `${name}.extname`\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: BaseName\n /**\n * Path will be full qualified path to a specified file\n */\n path: AdvancedPath<BaseName> | Path\n sources: Array<Source>\n imports?: Array<Import>\n exports?: Array<Export>\n /**\n * Use extra meta, this is getting used to generate the barrel/index files.\n */\n meta?: TMeta\n banner?: string\n footer?: string\n}\n\nexport type ResolvedImport = Import\n\nexport type ResolvedExport = Export\n\nexport type ResolvedFile<TMeta extends object = object> = File<TMeta> & {\n /**\n * @default hash\n */\n id: string\n /**\n * Contains the first part of the baseName, generated based on baseName\n * @link https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n extname: Extname\n imports: Array<ResolvedImport>\n exports: Array<ResolvedExport>\n}\n"],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { r as KubbFile_d_exports } from "./KubbFile-BrN7Wwp6.cjs";
2
+ import { n as AppContext, r as DefineApp, t as App } from "./defineApp-c9lWJ96_.cjs";
3
+ export { type App, type AppContext, type DefineApp, KubbFile_d_exports as KubbFile };
@@ -0,0 +1,3 @@
1
+ import { r as KubbFile_d_exports } from "./KubbFile-BzVkcu9M.js";
2
+ import { n as AppContext, r as DefineApp, t as App } from "./defineApp-CZYKsxTp.js";
3
+ export { type App, type AppContext, type DefineApp, KubbFile_d_exports as KubbFile };
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ //#region src/KubbFile.ts
2
+ var KubbFile_exports = {};
3
+
4
+ //#endregion
5
+ export { KubbFile_exports as KubbFile };
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/KubbFile.ts"],"sourcesContent":["type BasePath<T extends string = string> = `${T}/`\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name:\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n\n isNameSpace?: boolean\n /**\n * When root is set it will get the path with relative getRelativePath(root, path).\n */\n root?: string\n}\n\nexport type Source = {\n name?: string\n value?: string\n isTypeOnly?: boolean\n /**\n * Has const or type 'export'\n * @default false\n */\n isExportable?: boolean\n /**\n * When set, barrel generation will add this\n * @default false\n */\n isIndexable?: boolean\n}\n\nexport type Export = {\n /**\n * Export name to be used.\n * @example [\"useState\"]\n * @example \"React\"\n */\n name?: string | Array<string>\n /**\n * Path for the import.\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.\n */\n asAlias?: boolean\n}\n\nexport type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\nexport type Mode = 'single' | 'split'\n\n/**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\nexport type BaseName = `${string}.${string}`\n\n/**\n * Path will be full qualified path to a specified file\n */\nexport type Path = string\n\nexport type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`\n\nexport type OptionalPath = Path | undefined | null\n\nexport type File<TMeta extends object = object> = {\n /**\n * Name to be used to create the path\n * Based on UNIX basename, `${name}.extname`\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: BaseName\n /**\n * Path will be full qualified path to a specified file\n */\n path: AdvancedPath<BaseName> | Path\n sources: Array<Source>\n imports?: Array<Import>\n exports?: Array<Export>\n /**\n * Use extra meta, this is getting used to generate the barrel/index files.\n */\n meta?: TMeta\n banner?: string\n footer?: string\n}\n\nexport type ResolvedImport = Import\n\nexport type ResolvedExport = Export\n\nexport type ResolvedFile<TMeta extends object = object> = File<TMeta> & {\n /**\n * @default hash\n */\n id: string\n /**\n * Contains the first part of the baseName, generated based on baseName\n * @link https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n extname: Extname\n imports: Array<ResolvedImport>\n exports: Array<ResolvedExport>\n}\n"],"mappings":""}
@@ -1,7 +1,8 @@
1
- import ts from "typescript";
1
+ import { t as createFileParser } from "./createFileParser-Cix3AMLd.js";
2
2
  import path, { normalize, relative, resolve } from "node:path";
3
3
  import fs from "fs-extra";
4
4
  import { switcher } from "js-runtime";
5
+ import ts from "typescript";
5
6
 
6
7
  //#region src/fs.ts
7
8
  async function write(path$1, data, options = {}) {
@@ -145,36 +146,5 @@ const typeScriptParser = createFileParser({ async print(file, options = { extnam
145
146
  } });
146
147
 
147
148
  //#endregion
148
- //#region src/parsers/tsx.ts
149
- const tsxParser = createFileParser({ async print(file, options = { extname: ".tsx" }) {
150
- return typeScriptParser.print(file, options);
151
- } });
152
-
153
- //#endregion
154
- //#region src/parsers/parser.ts
155
- function createFileParser(parser) {
156
- return parser;
157
- }
158
- const defaultParser = createFileParser({ async print(file) {
159
- return file.sources.map((item) => item.value).join("\n\n");
160
- } });
161
- const parsers = {
162
- ".ts": typeScriptParser,
163
- ".js": typeScriptParser,
164
- ".jsx": tsxParser,
165
- ".tsx": tsxParser,
166
- ".json": defaultParser
167
- };
168
- async function parseFile(file, { extname } = {}) {
169
- async function getFileParser(extname$1) {
170
- if (!extname$1) return defaultParser;
171
- const parser = parsers[extname$1];
172
- if (!parser) console.warn(`[parser] No parser found for ${extname$1}, default parser will be used`);
173
- return parser || defaultParser;
174
- }
175
- return (await getFileParser(file.extname)).print(file, { extname });
176
- }
177
-
178
- //#endregion
179
- export { print as a, write as c, createImport as i, tsxParser as n, typeScriptParser as o, createExport as r, trimExtName as s, parseFile as t };
180
- //# sourceMappingURL=parser-CWB_OBtr.js.map
149
+ export { trimExtName as a, typeScriptParser as i, createImport as n, write as o, print as r, createExport as t };
150
+ //# sourceMappingURL=typescript-C60gWBu8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-C60gWBu8.js","names":["path","data","output: string","path","importPropertyName: ts.Identifier | undefined","importName: ts.NamedImportBindings | undefined"],"sources":["../src/fs.ts","../src/parsers/typescript.ts"],"sourcesContent":["import { normalize, relative, resolve } from 'node:path'\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\ntype Options = { sanity?: boolean }\n\nexport async function write(path: string, data: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return switcher(\n {\n node: async (path: string, data: string, { sanity }: Options) => {\n try {\n const oldContent = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data, { encoding: 'utf-8' })\n\n if (sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n },\n bun: async (path: string, data: string, { sanity }: Options) => {\n try {\n await Bun.write(resolve(path), data)\n\n if (sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${path.length}]:\\n${path}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n } catch (e) {\n console.error(e)\n }\n },\n },\n 'node',\n )(path, data.trim(), options)\n}\n\nexport async function read(path: string): Promise<string> {\n return switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n )(path)\n}\n\nexport function readSync(path: string): string {\n return switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n )(path)\n}\n\nexport async function exists(path: string): Promise<boolean> {\n return switcher(\n {\n node: async (path: string) => {\n return fs.pathExists(path)\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.exists()\n },\n },\n 'node',\n )(path)\n}\n\nexport function existsSync(path: string): boolean {\n return switcher(\n {\n node: (path: string) => {\n return fs.pathExistsSync(path)\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n )(path)\n}\n\nexport async function clean(path: string): Promise<void> {\n return fs.remove(path)\n}\n\nexport async function unlink(path: string): Promise<void> {\n return fs.unlink(path)\n}\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): 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 = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n","import ts from 'typescript'\nimport { getRelativePath, trimExtName } from '../fs.ts'\nimport path from 'node:path'\nimport { createFileParser } from './createFileParser.ts'\n\nconst { factory } = ts\n\ntype PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n}\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n * Ensures consistent output across environments.\n * Also works as a formatter when `source` is provided without `elements`.\n */\nexport function print(elements: Array<ts.Node> = [], { source = '', baseName = 'print.tsx', scriptKind = ts.ScriptKind.TSX }: PrintOptions = {}): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, true, scriptKind)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n let output: string\n\n if (elements.length > 0) {\n // Print only provided nodes\n const nodes = elements.filter(Boolean).sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0))\n output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n } else {\n // Format the whole file\n output = printer.printFile(sourceFile)\n }\n\n return restoreNewLines(output).replace(/\\r\\n/g, '\\n')\n}\n\nexport function createImport({\n name,\n path,\n root,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n root?: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n const resolvePath = root ? getRelativePath(root, path) : path\n\n if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n}\n\nexport function createExport({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport const typeScriptParser = createFileParser({\n async print(file, options = { extname: '.ts' }) {\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n\n const importNodes = file.imports\n .map((item) => {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n return createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n })\n })\n .filter(Boolean)\n\n const exportNodes = file.exports\n .map((item) => {\n const exportPath = item.path\n\n const hasExtname = !!path.extname(exportPath)\n\n return createExport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n })\n })\n .filter(Boolean)\n\n return [file.banner, print([...importNodes, ...exportNodes]), source, file.footer].join('\\n')\n },\n})\n"],"mappings":";;;;;;;AAMA,eAAsB,MAAM,QAAc,MAAc,UAAmB,EAAE,EAA+B;AAC1G,KAAI,KAAK,MAAM,KAAK,GAClB;AAEF,QAAO,SACL;EACE,MAAM,OAAO,QAAc,QAAc,EAAE,aAAsB;AAC/D,OAAI;IACF,MAAM,aAAa,MAAM,GAAG,SAAS,QAAQA,OAAK,EAAE,EAClD,UAAU,SACX,CAAC;AACF,iEAAI,WAAY,UAAU,uDAAKC,OAAM,UAAU,EAC7C;YAEK,MAAM;AAIf,SAAM,GAAG,WAAW,QAAQD,OAAK,EAAEC,QAAM,EAAE,UAAU,SAAS,CAAC;AAE/D,OAAI,QAAQ;IACV,MAAM,YAAY,MAAM,GAAG,SAAS,QAAQD,OAAK,EAAE,EACjD,UAAU,SACX,CAAC;AAEF,+DAAI,UAAW,UAAU,uDAAKC,OAAM,UAAU,EAC5C,OAAM,IAAI,MAAM,2BAA2BD,OAAK,WAAWC,OAAK,OAAO,MAAMA,OAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;A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,QAAQ,WAAW;AAE7C,SAAO,aAAa;GAClB,MAAM,KAAK;GACX,MAAM,QAAQ,WAAW,aAAa,GAAG,YAAY,WAAW,GAAG,QAAQ,YAAY,KAAK,OAAO,YAAY,WAAW,GAAG;GAC7H,YAAY,KAAK;GAClB,CAAC;GACF,CACD,OAAO,QAAQ;CAElB,MAAM,cAAc,KAAK,QACtB,KAAK,SAAS;EACb,MAAM,aAAa,KAAK;EAExB,MAAM,aAAa,CAAC,CAAC,KAAK,QAAQ,WAAW;AAE7C,SAAO,aAAa;GAClB,MAAM,KAAK;GACX,MAAM,QAAQ,WAAW,aAAa,GAAG,YAAY,KAAK,KAAK,GAAG,QAAQ,YAAY,YAAY,KAAK,KAAK;GAC5G,YAAY,KAAK;GACjB,SAAS,KAAK;GACf,CAAC;GACF,CACD,OAAO,QAAQ;AAElB,QAAO;EAAC,KAAK;EAAQ,MAAM,CAAC,GAAG,aAAa,GAAG,YAAY,CAAC;EAAE;EAAQ,KAAK;EAAO,CAAC,KAAK,KAAK;GAEhG,CAAC"}
@@ -21,14 +21,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- let typescript = require("typescript");
25
- typescript = __toESM(typescript);
24
+ const require_createFileParser = require('./createFileParser-BD8yn0LT.cjs');
26
25
  let node_path = require("node:path");
27
26
  node_path = __toESM(node_path);
28
27
  let fs_extra = require("fs-extra");
29
28
  fs_extra = __toESM(fs_extra);
30
29
  let js_runtime = require("js-runtime");
31
30
  js_runtime = __toESM(js_runtime);
31
+ let typescript = require("typescript");
32
+ typescript = __toESM(typescript);
32
33
 
33
34
  //#region src/fs.ts
34
35
  async function write(path$1, data, options = {}) {
@@ -142,7 +143,7 @@ function createExport({ path: path$1, asAlias, isTypeOnly = false, name }) {
142
143
  return factory.createExportSpecifier(false, void 0, typeof propertyName === "string" ? factory.createIdentifier(propertyName) : propertyName);
143
144
  })), factory.createStringLiteral(path$1), void 0);
144
145
  }
145
- const typeScriptParser = createFileParser({ async print(file, options = { extname: ".ts" }) {
146
+ const typeScriptParser = require_createFileParser.createFileParser({ async print(file, options = { extname: ".ts" }) {
146
147
  const source = file.sources.map((item) => item.value).join("\n\n");
147
148
  const importNodes = file.imports.map((item) => {
148
149
  const importPath = item.root ? getRelativePath(item.root, item.path) : item.path;
@@ -171,37 +172,6 @@ const typeScriptParser = createFileParser({ async print(file, options = { extnam
171
172
  ].join("\n");
172
173
  } });
173
174
 
174
- //#endregion
175
- //#region src/parsers/tsx.ts
176
- const tsxParser = createFileParser({ async print(file, options = { extname: ".tsx" }) {
177
- return typeScriptParser.print(file, options);
178
- } });
179
-
180
- //#endregion
181
- //#region src/parsers/parser.ts
182
- function createFileParser(parser) {
183
- return parser;
184
- }
185
- const defaultParser = createFileParser({ async print(file) {
186
- return file.sources.map((item) => item.value).join("\n\n");
187
- } });
188
- const parsers = {
189
- ".ts": typeScriptParser,
190
- ".js": typeScriptParser,
191
- ".jsx": tsxParser,
192
- ".tsx": tsxParser,
193
- ".json": defaultParser
194
- };
195
- async function parseFile(file, { extname } = {}) {
196
- async function getFileParser(extname$1) {
197
- if (!extname$1) return defaultParser;
198
- const parser = parsers[extname$1];
199
- if (!parser) console.warn(`[parser] No parser found for ${extname$1}, default parser will be used`);
200
- return parser || defaultParser;
201
- }
202
- return (await getFileParser(file.extname)).print(file, { extname });
203
- }
204
-
205
175
  //#endregion
206
176
  Object.defineProperty(exports, '__toESM', {
207
177
  enumerable: true,
@@ -221,12 +191,6 @@ Object.defineProperty(exports, 'createImport', {
221
191
  return createImport;
222
192
  }
223
193
  });
224
- Object.defineProperty(exports, 'parseFile', {
225
- enumerable: true,
226
- get: function () {
227
- return parseFile;
228
- }
229
- });
230
194
  Object.defineProperty(exports, 'print', {
231
195
  enumerable: true,
232
196
  get: function () {
@@ -239,12 +203,6 @@ Object.defineProperty(exports, 'trimExtName', {
239
203
  return trimExtName;
240
204
  }
241
205
  });
242
- Object.defineProperty(exports, 'tsxParser', {
243
- enumerable: true,
244
- get: function () {
245
- return tsxParser;
246
- }
247
- });
248
206
  Object.defineProperty(exports, 'typeScriptParser', {
249
207
  enumerable: true,
250
208
  get: function () {
@@ -257,4 +215,4 @@ Object.defineProperty(exports, 'write', {
257
215
  return write;
258
216
  }
259
217
  });
260
- //# sourceMappingURL=parser-QF8j8-pj.cjs.map
218
+ //# sourceMappingURL=typescript-Z90jN87k.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-Z90jN87k.cjs","names":["fs","path","data","ts","output: string","path","importPropertyName: ts.Identifier | undefined","importName: ts.NamedImportBindings | undefined","createFileParser"],"sources":["../src/fs.ts","../src/parsers/typescript.ts"],"sourcesContent":["import { normalize, relative, resolve } from 'node:path'\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\ntype Options = { sanity?: boolean }\n\nexport async function write(path: string, data: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return switcher(\n {\n node: async (path: string, data: string, { sanity }: Options) => {\n try {\n const oldContent = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data, { encoding: 'utf-8' })\n\n if (sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n },\n bun: async (path: string, data: string, { sanity }: Options) => {\n try {\n await Bun.write(resolve(path), data)\n\n if (sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${path.length}]:\\n${path}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n } catch (e) {\n console.error(e)\n }\n },\n },\n 'node',\n )(path, data.trim(), options)\n}\n\nexport async function read(path: string): Promise<string> {\n return switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n )(path)\n}\n\nexport function readSync(path: string): string {\n return switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n )(path)\n}\n\nexport async function exists(path: string): Promise<boolean> {\n return switcher(\n {\n node: async (path: string) => {\n return fs.pathExists(path)\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.exists()\n },\n },\n 'node',\n )(path)\n}\n\nexport function existsSync(path: string): boolean {\n return switcher(\n {\n node: (path: string) => {\n return fs.pathExistsSync(path)\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n )(path)\n}\n\nexport async function clean(path: string): Promise<void> {\n return fs.remove(path)\n}\n\nexport async function unlink(path: string): Promise<void> {\n return fs.unlink(path)\n}\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): 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 = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n","import ts from 'typescript'\nimport { getRelativePath, trimExtName } from '../fs.ts'\nimport path from 'node:path'\nimport { createFileParser } from './createFileParser.ts'\n\nconst { factory } = ts\n\ntype PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n}\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n * Ensures consistent output across environments.\n * Also works as a formatter when `source` is provided without `elements`.\n */\nexport function print(elements: Array<ts.Node> = [], { source = '', baseName = 'print.tsx', scriptKind = ts.ScriptKind.TSX }: PrintOptions = {}): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, true, scriptKind)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n let output: string\n\n if (elements.length > 0) {\n // Print only provided nodes\n const nodes = elements.filter(Boolean).sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0))\n output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n } else {\n // Format the whole file\n output = printer.printFile(sourceFile)\n }\n\n return restoreNewLines(output).replace(/\\r\\n/g, '\\n')\n}\n\nexport function createImport({\n name,\n path,\n root,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n root?: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n const resolvePath = root ? getRelativePath(root, path) : path\n\n if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n}\n\nexport function createExport({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport const typeScriptParser = createFileParser({\n async print(file, options = { extname: '.ts' }) {\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n\n const importNodes = file.imports\n .map((item) => {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n return createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n })\n })\n .filter(Boolean)\n\n const exportNodes = file.exports\n .map((item) => {\n const exportPath = item.path\n\n const hasExtname = !!path.extname(exportPath)\n\n return createExport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n })\n })\n .filter(Boolean)\n\n return [file.banner, print([...importNodes, ...exportNodes]), source, file.footer].join('\\n')\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,eAAsB,MAAM,QAAc,MAAc,UAAmB,EAAE,EAA+B;AAC1G,KAAI,KAAK,MAAM,KAAK,GAClB;AAEF,iCACE;EACE,MAAM,OAAO,QAAc,QAAc,EAAE,aAAsB;AAC/D,OAAI;IACF,MAAM,aAAa,MAAMA,iBAAG,gCAAiBC,OAAK,EAAE,EAClD,UAAU,SACX,CAAC;AACF,iEAAI,WAAY,UAAU,uDAAKC,OAAM,UAAU,EAC7C;YAEK,MAAM;AAIf,SAAMF,iBAAG,kCAAmBC,OAAK,EAAEC,QAAM,EAAE,UAAU,SAAS,CAAC;AAE/D,OAAI,QAAQ;IACV,MAAM,YAAY,MAAMF,iBAAG,gCAAiBC,OAAK,EAAE,EACjD,UAAU,SACX,CAAC;AAEF,+DAAI,UAAW,UAAU,uDAAKC,OAAM,UAAU,EAC5C,OAAM,IAAI,MAAM,2BAA2BD,OAAK,WAAWC,OAAK,OAAO,MAAMA,OAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;AAGrI,WAAO;;AAGT,UAAOA;;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