@kubb/fabric-core 0.15.1 → 0.15.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["TreeNode","path","createFile","getRelativePath","#options","onProcessExit","TreeNode","Root","#renderPromise","clack"],"sources":["../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/plugins/fsxPlugin/Runtime.ts","../src/plugins/fsxPlugin/fsxPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type { Plugin, UserPlugin } from './types.ts'\n\n/**\n * Defines a Fabric plugin with type safety.\n *\n * Use this function to create plugins that hook into Fabric's lifecycle\n * events and extend its functionality.\n *\n * @param plugin - The plugin configuration object\n * @returns A typed plugin ready to use with Fabric\n *\n * @example\n * ```ts\n * import { definePlugin } from '@kubb/fabric-core'\n *\n * export const myPlugin = definePlugin({\n * name: 'my-plugin',\n * async setup(fabric) {\n * fabric.context.on('write:start', (files) => {\n * console.log(`Writing ${files.length} files`)\n * })\n * }\n * })\n * ```\n */\nexport function definePlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport path from 'node:path'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const indexableSourcesMap = new Map<KubbFile.File, Array<KubbFile.Source>>()\n\n for (const file of files) {\n const indexableSources: Array<KubbFile.Source> = []\n for (const source of file.sources || []) {\n if (source.isIndexable && source.name) {\n indexableSources.push(source)\n }\n }\n if (indexableSources.length > 0) {\n indexableSourcesMap.set(file, indexableSources)\n }\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n imports: [],\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n for (const leaf of node.leaves) {\n const file = leaf.data.file\n if (!file || !file.path) {\n continue\n }\n\n const indexableSources = indexableSourcesMap.get(file)\n if (!indexableSources) {\n continue\n }\n\n for (const source of indexableSources) {\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile.exports!.push({\n name: [source.name!],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name!,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n }\n }\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = definePlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n ctx.on('files:writing:start', async (files) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await ctx.fileManager.add(...barrelFiles)\n })\n },\n inject(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles: Array<KubbFile.ResolvedFile> = []\n for (const file of ctx.files) {\n for (const source of file.sources) {\n if (source.isIndexable) {\n barrelFiles.push(file)\n\n break\n }\n }\n }\n\n const fileTypeCache = new Map<KubbFile.ResolvedFile, boolean>()\n for (const file of barrelFiles) {\n fileTypeCache.set(\n file,\n file.sources.every((source) => source.isTypeOnly),\n )\n }\n\n const exports: Array<KubbFile.Export> = []\n for (const file of barrelFiles) {\n const containsOnlyTypes = fileTypeCache.get(file) ?? false\n\n for (const source of file.sources) {\n if (!file.path || !source.isIndexable) {\n continue\n }\n\n exports.push({\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export)\n }\n }\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n imports: [],\n exports,\n sources: [],\n })\n\n await ctx.addFile(entryFile)\n\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n dryRun: options.dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { rmSync } from 'node:fs'\nimport { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.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[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await 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 mkdir(dirname(resolve(path)), { recursive: true })\n await writeFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await 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\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fs',\n install(ctx, options = {}) {\n if (options.clean) {\n rmSync(options.clean.path, { recursive: true, force: true })\n }\n\n ctx.on('file:processing:update', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(ctx, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n extension: options.extension,\n dryRun,\n parsers: ctx.installedParsers,\n })\n\n await ctx.emit('lifecycle:end')\n },\n }\n },\n})\n","import { Root } from '../../components/Root.ts'\nimport type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport type { FileManager } from '../../FileManager.ts'\nimport { onProcessExit } from '../../utils/onProcessExit.ts'\nimport { TreeNode } from '../../utils/TreeNode.ts'\n\ntype Options = {\n fileManager: FileManager\n treeNode?: TreeNode<ComponentNode>\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n exitPromise?: Promise<void>\n\n constructor(options: Options) {\n this.#options = options\n\n // Unmount when process exits\n this.unsubscribeExit = onProcessExit((code) => {\n this.unmount(code)\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n #renderPromise: Promise<void> = Promise.resolve()\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n\n onError(error: Error): void {\n throw error\n }\n\n onExit(error?: Error): void {\n setTimeout(() => {\n this.unmount(error)\n }, 0)\n }\n\n async render(node: FabricElement): Promise<string> {\n const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })\n\n const props = {\n fileManager: this.fileManager,\n treeNode,\n onExit: this.onExit.bind(this),\n onError: this.onError.bind(this),\n }\n\n try {\n treeNode.data.props = props\n\n const element = Root({ ...props, children: node })\n\n await this.#renderPromise\n\n return element()?.toString() || ''\n } catch (e) {\n props.onError(e as Error)\n return ''\n }\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.unsubscribeExit()\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport { definePlugin } from '../../plugins/definePlugin.ts'\nimport type { TreeNode } from '../../utils/TreeNode.ts'\nimport { Runtime } from './Runtime.ts'\n\nexport type Options = {\n treeNode?: TreeNode<ComponentNode>\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const fsxPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fsx',\n install() {},\n inject(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(Fabric) {\n await ctx.emit('lifecycle:start')\n return runtime.render(Fabric)\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n },\n }\n },\n})\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst DEFAULT_PROGRESS_BAR_SIZE = 30\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { progress = true } = options\n\n const state = {\n spinner: clack.spinner(),\n isSpinning: false,\n progressBar: undefined as ReturnType<typeof clack.progress> | undefined,\n }\n\n function formatPath(path: string) {\n return relative(process.cwd(), path)\n }\n\n ctx.on('lifecycle:start', async () => {\n clack.intro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'Starting run')}`)\n })\n\n ctx.on('lifecycle:render', async () => {\n clack.log.info(`${styleText('blue', 'ℹ')} Rendering application graph`)\n })\n\n ctx.on('files:added', async (files) => {\n if (!files.length) {\n return\n }\n\n clack.log.info(`${styleText('blue', 'ℹ')} Queued ${pluralize('file', files.length)}`)\n })\n\n ctx.on('file:resolve:path', async (file) => {\n clack.log.step(`Resolving path for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('file:resolve:name', async (file) => {\n clack.log.step(`Resolving name for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('files:processing:start', async (files) => {\n clack.log.step(`Processing ${styleText('green', pluralize('file', files.length))}`)\n\n if (progress) {\n state.progressBar = clack.progress({\n style: 'block',\n max: files.length,\n size: DEFAULT_PROGRESS_BAR_SIZE,\n })\n state.progressBar.start(`Processing ${files.length} files`)\n }\n })\n\n ctx.on('file:processing:start', async (file, index, total) => {\n if (!state.progressBar) {\n clack.log.step(`Processing ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n if (state.progressBar) {\n // undefined = auto-increment by 1\n state.progressBar.advance(undefined, `Writing ${formatPath(file.path)}`)\n } else {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n clack.log.step(`Progress ${styleText('green', `${formattedPercentage}%`)} ${styleText('dim', `(${processed}/${total})`)} → ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:end', async (file, index, total) => {\n if (state.progressBar) {\n state.progressBar.message(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n } else {\n clack.log.success(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('files:processing:end', async (files) => {\n if (state.progressBar) {\n state.progressBar.stop(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n state.progressBar = undefined\n } else {\n clack.log.success(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n if (state.progressBar) {\n state.progressBar.stop()\n state.progressBar = undefined\n }\n\n clack.outro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'completed')}`)\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,aACd,QACgC;AAChC,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;ACeH,SAAgB,eAAe,EAAE,OAAO,MAAM,QAAqD;AAEjG,KAAI,SAAS,eAAe,SAAS,MACnC,QAAO,EAAE;CAGX,MAAM,sCAAsB,IAAI,KAA4C;AAE5E,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,mBAA2C,EAAE;AACnD,OAAK,MAAM,UAAU,KAAK,WAAW,EAAE,CACrC,KAAI,OAAO,eAAe,OAAO,KAC/B,kBAAiB,KAAK,OAAO;AAGjC,MAAI,iBAAiB,SAAS,EAC5B,qBAAoB,IAAI,MAAM,iBAAiB;;CAInD,MAAM,8BAAc,IAAI,KAAmC;CAC3D,MAAM,yBAAS,IAAI,KAAiC;CAEpD,MAAM,WAAWA,sBAAAA,SAAS,UAAU,OAAO,KAAK;AAEhD,KAA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AY,KAAK,IAAA,GAAA,UAAA,WAAa,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;AACjG,UAAM,cAAc,KAAA;SAEpB,gBAAM,IAAI,QAAQ,IAAA,GAAA,UAAA,WAAa,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;IAE9F;AAEF,MAAI,GAAG,iBAAiB,YAAY;AAClC,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,KAAA;;AAGtB,kBAAM,MAAM,IAAA,GAAA,UAAA,WAAa,QAAQ,SAAS,CAAC,IAAA,GAAA,UAAA,WAAa,OAAO,YAAY,GAAG;IAC9E;;CAEL,CAAC"}
1
+ {"version":3,"file":"plugins.cjs","names":["TreeNode","path","createFile","getRelativePath","#options","onProcessExit","TreeNode","Root","#renderPromise","clack"],"sources":["../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/plugins/fsxPlugin/Runtime.ts","../src/plugins/fsxPlugin/fsxPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type { Plugin, UserPlugin } from './types.ts'\n\n/**\n * Defines a Fabric plugin with type safety.\n *\n * Use this function to create plugins that hook into Fabric's lifecycle\n * events and extend its functionality.\n *\n * @param plugin - The plugin configuration object\n * @returns A typed plugin ready to use with Fabric\n *\n * @example\n * ```ts\n * import { definePlugin } from '@kubb/fabric-core'\n *\n * export const myPlugin = definePlugin({\n * name: 'my-plugin',\n * async setup(fabric) {\n * fabric.context.on('write:start', (files) => {\n * console.log(`Writing ${files.length} files`)\n * })\n * }\n * })\n * ```\n */\nexport function definePlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport path from 'node:path'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../FabricFile.ts'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const indexableSourcesMap = new Map<KubbFile.File, Array<KubbFile.Source>>()\n\n for (const file of files) {\n const indexableSources: Array<KubbFile.Source> = []\n for (const source of file.sources || []) {\n if (source.isIndexable && source.name) {\n indexableSources.push(source)\n }\n }\n if (indexableSources.length > 0) {\n indexableSourcesMap.set(file, indexableSources)\n }\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n imports: [],\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n for (const leaf of node.leaves) {\n const file = leaf.data.file\n if (!file || !file.path) {\n continue\n }\n\n const indexableSources = indexableSourcesMap.get(file)\n if (!indexableSources) {\n continue\n }\n\n for (const source of indexableSources) {\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile.exports!.push({\n name: [source.name!],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name!,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n }\n }\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = definePlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n ctx.on('files:writing:start', async (files) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await ctx.fileManager.add(...barrelFiles)\n })\n },\n inject(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles: Array<KubbFile.ResolvedFile> = []\n for (const file of ctx.files) {\n for (const source of file.sources) {\n if (source.isIndexable) {\n barrelFiles.push(file)\n\n break\n }\n }\n }\n\n const fileTypeCache = new Map<KubbFile.ResolvedFile, boolean>()\n for (const file of barrelFiles) {\n fileTypeCache.set(\n file,\n file.sources.every((source) => source.isTypeOnly),\n )\n }\n\n const exports: Array<KubbFile.Export> = []\n for (const file of barrelFiles) {\n const containsOnlyTypes = fileTypeCache.get(file) ?? false\n\n for (const source of file.sources) {\n if (!file.path || !source.isIndexable) {\n continue\n }\n\n exports.push({\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export)\n }\n }\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n imports: [],\n exports,\n sources: [],\n })\n\n await ctx.addFile(entryFile)\n\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n dryRun: options.dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { rmSync } from 'node:fs'\nimport { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport type * as KubbFile from '../FabricFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.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[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await 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 mkdir(dirname(resolve(path)), { recursive: true })\n await writeFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await 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\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fs',\n install(ctx, options = {}) {\n if (options.clean) {\n rmSync(options.clean.path, { recursive: true, force: true })\n }\n\n ctx.on('file:processing:update', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(ctx, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n extension: options.extension,\n dryRun,\n parsers: ctx.installedParsers,\n })\n\n await ctx.emit('lifecycle:end')\n },\n }\n },\n})\n","import { Root } from '../../components/Root.ts'\nimport type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport type { FileManager } from '../../FileManager.ts'\nimport { onProcessExit } from '../../utils/onProcessExit.ts'\nimport { TreeNode } from '../../utils/TreeNode.ts'\n\ntype Options = {\n fileManager: FileManager\n treeNode?: TreeNode<ComponentNode>\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n exitPromise?: Promise<void>\n\n constructor(options: Options) {\n this.#options = options\n\n // Unmount when process exits\n this.unsubscribeExit = onProcessExit((code) => {\n this.unmount(code)\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n #renderPromise: Promise<void> = Promise.resolve()\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n\n onError(error: Error): void {\n throw error\n }\n\n onExit(error?: Error): void {\n setTimeout(() => {\n this.unmount(error)\n }, 0)\n }\n\n async render(node: FabricElement): Promise<string> {\n const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })\n\n const props = {\n fileManager: this.fileManager,\n treeNode,\n onExit: this.onExit.bind(this),\n onError: this.onError.bind(this),\n }\n\n try {\n treeNode.data.props = props\n\n const element = Root({ ...props, children: node })\n\n await this.#renderPromise\n\n return element()?.toString() || ''\n } catch (e) {\n props.onError(e as Error)\n return ''\n }\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.unsubscribeExit()\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport { definePlugin } from '../../plugins/definePlugin.ts'\nimport type { TreeNode } from '../../utils/TreeNode.ts'\nimport { Runtime } from './Runtime.ts'\n\nexport type Options = {\n treeNode?: TreeNode<ComponentNode>\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const fsxPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fsx',\n install() {},\n inject(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(Fabric) {\n await ctx.emit('lifecycle:start')\n return runtime.render(Fabric)\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n },\n }\n },\n})\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst DEFAULT_PROGRESS_BAR_SIZE = 30\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { progress = true } = options\n\n const state = {\n spinner: clack.spinner(),\n isSpinning: false,\n progressBar: undefined as ReturnType<typeof clack.progress> | undefined,\n }\n\n function formatPath(path: string) {\n return relative(process.cwd(), path)\n }\n\n ctx.on('lifecycle:start', async () => {\n clack.intro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'Starting run')}`)\n })\n\n ctx.on('lifecycle:render', async () => {\n clack.log.info(`${styleText('blue', 'ℹ')} Rendering application graph`)\n })\n\n ctx.on('files:added', async (files) => {\n if (!files.length) {\n return\n }\n\n clack.log.info(`${styleText('blue', 'ℹ')} Queued ${pluralize('file', files.length)}`)\n })\n\n ctx.on('file:resolve:path', async (file) => {\n clack.log.step(`Resolving path for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('file:resolve:name', async (file) => {\n clack.log.step(`Resolving name for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('files:processing:start', async (files) => {\n clack.log.step(`Processing ${styleText('green', pluralize('file', files.length))}`)\n\n if (progress) {\n state.progressBar = clack.progress({\n style: 'block',\n max: files.length,\n size: DEFAULT_PROGRESS_BAR_SIZE,\n })\n state.progressBar.start(`Processing ${files.length} files`)\n }\n })\n\n ctx.on('file:processing:start', async (file, index, total) => {\n if (!state.progressBar) {\n clack.log.step(`Processing ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n if (state.progressBar) {\n // undefined = auto-increment by 1\n state.progressBar.advance(undefined, `Writing ${formatPath(file.path)}`)\n } else {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n clack.log.step(`Progress ${styleText('green', `${formattedPercentage}%`)} ${styleText('dim', `(${processed}/${total})`)} → ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:end', async (file, index, total) => {\n if (state.progressBar) {\n state.progressBar.message(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n } else {\n clack.log.success(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('files:processing:end', async (files) => {\n if (state.progressBar) {\n state.progressBar.stop(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n state.progressBar = undefined\n } else {\n clack.log.success(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n if (state.progressBar) {\n state.progressBar.stop()\n state.progressBar = undefined\n }\n\n clack.outro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'completed')}`)\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,aACd,QACgC;AAChC,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;ACeH,SAAgB,eAAe,EAAE,OAAO,MAAM,QAAqD;AAEjG,KAAI,SAAS,eAAe,SAAS,MACnC,QAAO,EAAE;CAGX,MAAM,sCAAsB,IAAI,KAA4C;AAE5E,MAAK,MAAM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AAO,IAAI,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,KAAK,KAAK,GAAG;OAExI,gBAAM,IAAI,QAAQ,IAAA,GAAA,UAAA,WAAa,SAAS,IAAI,CAAC,aAAA,GAAA,UAAA,WAAsB,OAAO,IAAI,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,KAAK,KAAK,GAAG;IAElI;AAEF,MAAI,GAAG,wBAAwB,OAAO,UAAU;AAC9C,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,KAAK,IAAA,GAAA,UAAA,WAAa,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;AACjG,UAAM,cAAc,KAAA;SAEpB,gBAAM,IAAI,QAAQ,IAAA,GAAA,UAAA,WAAa,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;IAE9F;AAEF,MAAI,GAAG,iBAAiB,YAAY;AAClC,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,KAAA;;AAGtB,kBAAM,MAAM,IAAA,GAAA,UAAA,WAAa,QAAQ,SAAS,CAAC,IAAA,GAAA,UAAA,WAAa,OAAO,YAAY,GAAG;IAC9E;;CAEL,CAAC"}
package/dist/plugins.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as __name } from "./chunk-O_arW02_.js";
2
- import { E as Extname, a as FabricElement, l as Plugin, u as UserPlugin } from "./Fabric-CFkgoZwY.js";
3
- import { r as TreeNode, t as ComponentNode } from "./useNodeTree-Wc1WxA05.js";
2
+ import { E as Extname, a as FabricElement, l as Plugin, u as UserPlugin } from "./Fabric-BY54T8Wd.js";
3
+ import { r as TreeNode, t as ComponentNode } from "./useNodeTree-BYgBDQH2.js";
4
4
 
5
5
  //#region src/plugins/barrelPlugin.d.ts
6
6
  type Mode = 'all' | 'named' | 'propagate' | false;
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","names":["#options","#renderPromise"],"sources":["../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/plugins/fsxPlugin/Runtime.ts","../src/plugins/fsxPlugin/fsxPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type { Plugin, UserPlugin } from './types.ts'\n\n/**\n * Defines a Fabric plugin with type safety.\n *\n * Use this function to create plugins that hook into Fabric's lifecycle\n * events and extend its functionality.\n *\n * @param plugin - The plugin configuration object\n * @returns A typed plugin ready to use with Fabric\n *\n * @example\n * ```ts\n * import { definePlugin } from '@kubb/fabric-core'\n *\n * export const myPlugin = definePlugin({\n * name: 'my-plugin',\n * async setup(fabric) {\n * fabric.context.on('write:start', (files) => {\n * console.log(`Writing ${files.length} files`)\n * })\n * }\n * })\n * ```\n */\nexport function definePlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport path from 'node:path'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const indexableSourcesMap = new Map<KubbFile.File, Array<KubbFile.Source>>()\n\n for (const file of files) {\n const indexableSources: Array<KubbFile.Source> = []\n for (const source of file.sources || []) {\n if (source.isIndexable && source.name) {\n indexableSources.push(source)\n }\n }\n if (indexableSources.length > 0) {\n indexableSourcesMap.set(file, indexableSources)\n }\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n imports: [],\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n for (const leaf of node.leaves) {\n const file = leaf.data.file\n if (!file || !file.path) {\n continue\n }\n\n const indexableSources = indexableSourcesMap.get(file)\n if (!indexableSources) {\n continue\n }\n\n for (const source of indexableSources) {\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile.exports!.push({\n name: [source.name!],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name!,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n }\n }\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = definePlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n ctx.on('files:writing:start', async (files) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await ctx.fileManager.add(...barrelFiles)\n })\n },\n inject(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles: Array<KubbFile.ResolvedFile> = []\n for (const file of ctx.files) {\n for (const source of file.sources) {\n if (source.isIndexable) {\n barrelFiles.push(file)\n\n break\n }\n }\n }\n\n const fileTypeCache = new Map<KubbFile.ResolvedFile, boolean>()\n for (const file of barrelFiles) {\n fileTypeCache.set(\n file,\n file.sources.every((source) => source.isTypeOnly),\n )\n }\n\n const exports: Array<KubbFile.Export> = []\n for (const file of barrelFiles) {\n const containsOnlyTypes = fileTypeCache.get(file) ?? false\n\n for (const source of file.sources) {\n if (!file.path || !source.isIndexable) {\n continue\n }\n\n exports.push({\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export)\n }\n }\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n imports: [],\n exports,\n sources: [],\n })\n\n await ctx.addFile(entryFile)\n\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n dryRun: options.dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { rmSync } from 'node:fs'\nimport { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.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[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await 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 mkdir(dirname(resolve(path)), { recursive: true })\n await writeFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await 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\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fs',\n install(ctx, options = {}) {\n if (options.clean) {\n rmSync(options.clean.path, { recursive: true, force: true })\n }\n\n ctx.on('file:processing:update', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(ctx, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n extension: options.extension,\n dryRun,\n parsers: ctx.installedParsers,\n })\n\n await ctx.emit('lifecycle:end')\n },\n }\n },\n})\n","import { Root } from '../../components/Root.ts'\nimport type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport type { FileManager } from '../../FileManager.ts'\nimport { onProcessExit } from '../../utils/onProcessExit.ts'\nimport { TreeNode } from '../../utils/TreeNode.ts'\n\ntype Options = {\n fileManager: FileManager\n treeNode?: TreeNode<ComponentNode>\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n exitPromise?: Promise<void>\n\n constructor(options: Options) {\n this.#options = options\n\n // Unmount when process exits\n this.unsubscribeExit = onProcessExit((code) => {\n this.unmount(code)\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n #renderPromise: Promise<void> = Promise.resolve()\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n\n onError(error: Error): void {\n throw error\n }\n\n onExit(error?: Error): void {\n setTimeout(() => {\n this.unmount(error)\n }, 0)\n }\n\n async render(node: FabricElement): Promise<string> {\n const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })\n\n const props = {\n fileManager: this.fileManager,\n treeNode,\n onExit: this.onExit.bind(this),\n onError: this.onError.bind(this),\n }\n\n try {\n treeNode.data.props = props\n\n const element = Root({ ...props, children: node })\n\n await this.#renderPromise\n\n return element()?.toString() || ''\n } catch (e) {\n props.onError(e as Error)\n return ''\n }\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.unsubscribeExit()\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport { definePlugin } from '../../plugins/definePlugin.ts'\nimport type { TreeNode } from '../../utils/TreeNode.ts'\nimport { Runtime } from './Runtime.ts'\n\nexport type Options = {\n treeNode?: TreeNode<ComponentNode>\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const fsxPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fsx',\n install() {},\n inject(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(Fabric) {\n await ctx.emit('lifecycle:start')\n return runtime.render(Fabric)\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n },\n }\n },\n})\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst DEFAULT_PROGRESS_BAR_SIZE = 30\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { progress = true } = options\n\n const state = {\n spinner: clack.spinner(),\n isSpinning: false,\n progressBar: undefined as ReturnType<typeof clack.progress> | undefined,\n }\n\n function formatPath(path: string) {\n return relative(process.cwd(), path)\n }\n\n ctx.on('lifecycle:start', async () => {\n clack.intro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'Starting run')}`)\n })\n\n ctx.on('lifecycle:render', async () => {\n clack.log.info(`${styleText('blue', 'ℹ')} Rendering application graph`)\n })\n\n ctx.on('files:added', async (files) => {\n if (!files.length) {\n return\n }\n\n clack.log.info(`${styleText('blue', 'ℹ')} Queued ${pluralize('file', files.length)}`)\n })\n\n ctx.on('file:resolve:path', async (file) => {\n clack.log.step(`Resolving path for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('file:resolve:name', async (file) => {\n clack.log.step(`Resolving name for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('files:processing:start', async (files) => {\n clack.log.step(`Processing ${styleText('green', pluralize('file', files.length))}`)\n\n if (progress) {\n state.progressBar = clack.progress({\n style: 'block',\n max: files.length,\n size: DEFAULT_PROGRESS_BAR_SIZE,\n })\n state.progressBar.start(`Processing ${files.length} files`)\n }\n })\n\n ctx.on('file:processing:start', async (file, index, total) => {\n if (!state.progressBar) {\n clack.log.step(`Processing ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n if (state.progressBar) {\n // undefined = auto-increment by 1\n state.progressBar.advance(undefined, `Writing ${formatPath(file.path)}`)\n } else {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n clack.log.step(`Progress ${styleText('green', `${formattedPercentage}%`)} ${styleText('dim', `(${processed}/${total})`)} → ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:end', async (file, index, total) => {\n if (state.progressBar) {\n state.progressBar.message(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n } else {\n clack.log.success(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('files:processing:end', async (files) => {\n if (state.progressBar) {\n state.progressBar.stop(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n state.progressBar = undefined\n } else {\n clack.log.success(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n if (state.progressBar) {\n state.progressBar.stop()\n state.progressBar = undefined\n }\n\n clack.outro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'completed')}`)\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,aACd,QACgC;AAChC,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;ACeH,SAAgB,eAAe,EAAE,OAAO,MAAM,QAAqD;AAEjG,KAAI,SAAS,eAAe,SAAS,MACnC,QAAO,EAAE;CAGX,MAAM,sCAAsB,IAAI,KAA4C;AAE5E,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,mBAA2C,EAAE;AACnD,OAAK,MAAM,UAAU,KAAK,WAAW,EAAE,CACrC,KAAI,OAAO,eAAe,OAAO,KAC/B,kBAAiB,KAAK,OAAO;AAGjC,MAAI,iBAAiB,SAAS,EAC5B,qBAAoB,IAAI,MAAM,iBAAiB;;CAInD,MAAM,8BAAc,IAAI,KAAmC;CAC3D,MAAM,yBAAS,IAAI,KAAiC;CAEpD,MAAM,WAAW,SAAS,UAAU,OAAO,KAAK;AAEhD,KAAI,CAAC,SACH,QAAO,EAAE;AAGX,UAAS,SAAS,SAAS;AAEzB,MAAI,CAAC,MAAM,YAAY,CAAC,KAAK,QAAQ,KAAK,KACxC;EAGF,MAAM,aAAa,KAAK,OAAO,KAAK;EACpC,MAAM,aAAa,KAAK,KAAK,YAAY,WAAW;EAEpD,IAAI,aAAa,YAAY,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AY,UAAU,SAAS,GAAG,oBAAoB,GAAG,CAAC,GAAG,UAAU,OAAO,IAAI,UAAU,GAAG,MAAM,GAAG,CAAC,KAAK,WAAW,KAAK,KAAK,GAAG;;IAEvJ;AAEF,MAAI,GAAG,uBAAuB,OAAO,MAAM,OAAO,UAAU;AAC1D,OAAI,MAAM,YACR,OAAM,YAAY,QAAQ,GAAG,UAAU,SAAS,IAAI,CAAC,YAAY,UAAU,OAAO,IAAI,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,KAAK,KAAK,GAAG;OAExI,OAAM,IAAI,QAAQ,GAAG,UAAU,SAAS,IAAI,CAAC,YAAY,UAAU,OAAO,IAAI,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,KAAK,KAAK,GAAG;IAElI;AAEF,MAAI,GAAG,wBAAwB,OAAO,UAAU;AAC9C,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,KAAK,GAAG,UAAU,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;AACjG,UAAM,cAAc,KAAA;SAEpB,OAAM,IAAI,QAAQ,GAAG,UAAU,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;IAE9F;AAEF,MAAI,GAAG,iBAAiB,YAAY;AAClC,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,KAAA;;AAGtB,SAAM,MAAM,GAAG,UAAU,QAAQ,SAAS,CAAC,GAAG,UAAU,OAAO,YAAY,GAAG;IAC9E;;CAEL,CAAC"}
1
+ {"version":3,"file":"plugins.js","names":["#options","#renderPromise"],"sources":["../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/plugins/fsxPlugin/Runtime.ts","../src/plugins/fsxPlugin/fsxPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type { Plugin, UserPlugin } from './types.ts'\n\n/**\n * Defines a Fabric plugin with type safety.\n *\n * Use this function to create plugins that hook into Fabric's lifecycle\n * events and extend its functionality.\n *\n * @param plugin - The plugin configuration object\n * @returns A typed plugin ready to use with Fabric\n *\n * @example\n * ```ts\n * import { definePlugin } from '@kubb/fabric-core'\n *\n * export const myPlugin = definePlugin({\n * name: 'my-plugin',\n * async setup(fabric) {\n * fabric.context.on('write:start', (files) => {\n * console.log(`Writing ${files.length} files`)\n * })\n * }\n * })\n * ```\n */\nexport function definePlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport path from 'node:path'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../FabricFile.ts'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const indexableSourcesMap = new Map<KubbFile.File, Array<KubbFile.Source>>()\n\n for (const file of files) {\n const indexableSources: Array<KubbFile.Source> = []\n for (const source of file.sources || []) {\n if (source.isIndexable && source.name) {\n indexableSources.push(source)\n }\n }\n if (indexableSources.length > 0) {\n indexableSourcesMap.set(file, indexableSources)\n }\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n imports: [],\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n for (const leaf of node.leaves) {\n const file = leaf.data.file\n if (!file || !file.path) {\n continue\n }\n\n const indexableSources = indexableSourcesMap.get(file)\n if (!indexableSources) {\n continue\n }\n\n for (const source of indexableSources) {\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile.exports!.push({\n name: [source.name!],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name!,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n }\n }\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = definePlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n ctx.on('files:writing:start', async (files) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await ctx.fileManager.add(...barrelFiles)\n })\n },\n inject(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles: Array<KubbFile.ResolvedFile> = []\n for (const file of ctx.files) {\n for (const source of file.sources) {\n if (source.isIndexable) {\n barrelFiles.push(file)\n\n break\n }\n }\n }\n\n const fileTypeCache = new Map<KubbFile.ResolvedFile, boolean>()\n for (const file of barrelFiles) {\n fileTypeCache.set(\n file,\n file.sources.every((source) => source.isTypeOnly),\n )\n }\n\n const exports: Array<KubbFile.Export> = []\n for (const file of barrelFiles) {\n const containsOnlyTypes = fileTypeCache.get(file) ?? false\n\n for (const source of file.sources) {\n if (!file.path || !source.isIndexable) {\n continue\n }\n\n exports.push({\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export)\n }\n }\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n imports: [],\n exports,\n sources: [],\n })\n\n await ctx.addFile(entryFile)\n\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n dryRun: options.dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { rmSync } from 'node:fs'\nimport { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport type * as KubbFile from '../FabricFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.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[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await 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 mkdir(dirname(resolve(path)), { recursive: true })\n await writeFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await 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\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fs',\n install(ctx, options = {}) {\n if (options.clean) {\n rmSync(options.clean.path, { recursive: true, force: true })\n }\n\n ctx.on('file:processing:update', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(ctx, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n extension: options.extension,\n dryRun,\n parsers: ctx.installedParsers,\n })\n\n await ctx.emit('lifecycle:end')\n },\n }\n },\n})\n","import { Root } from '../../components/Root.ts'\nimport type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport type { FileManager } from '../../FileManager.ts'\nimport { onProcessExit } from '../../utils/onProcessExit.ts'\nimport { TreeNode } from '../../utils/TreeNode.ts'\n\ntype Options = {\n fileManager: FileManager\n treeNode?: TreeNode<ComponentNode>\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n exitPromise?: Promise<void>\n\n constructor(options: Options) {\n this.#options = options\n\n // Unmount when process exits\n this.unsubscribeExit = onProcessExit((code) => {\n this.unmount(code)\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n #renderPromise: Promise<void> = Promise.resolve()\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n\n onError(error: Error): void {\n throw error\n }\n\n onExit(error?: Error): void {\n setTimeout(() => {\n this.unmount(error)\n }, 0)\n }\n\n async render(node: FabricElement): Promise<string> {\n const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })\n\n const props = {\n fileManager: this.fileManager,\n treeNode,\n onExit: this.onExit.bind(this),\n onError: this.onError.bind(this),\n }\n\n try {\n treeNode.data.props = props\n\n const element = Root({ ...props, children: node })\n\n await this.#renderPromise\n\n return element()?.toString() || ''\n } catch (e) {\n props.onError(e as Error)\n return ''\n }\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.unsubscribeExit()\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport { definePlugin } from '../../plugins/definePlugin.ts'\nimport type { TreeNode } from '../../utils/TreeNode.ts'\nimport { Runtime } from './Runtime.ts'\n\nexport type Options = {\n treeNode?: TreeNode<ComponentNode>\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(Fabric: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const fsxPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fsx',\n install() {},\n inject(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(Fabric) {\n await ctx.emit('lifecycle:start')\n return runtime.render(Fabric)\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n },\n }\n },\n})\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst DEFAULT_PROGRESS_BAR_SIZE = 30\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { progress = true } = options\n\n const state = {\n spinner: clack.spinner(),\n isSpinning: false,\n progressBar: undefined as ReturnType<typeof clack.progress> | undefined,\n }\n\n function formatPath(path: string) {\n return relative(process.cwd(), path)\n }\n\n ctx.on('lifecycle:start', async () => {\n clack.intro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'Starting run')}`)\n })\n\n ctx.on('lifecycle:render', async () => {\n clack.log.info(`${styleText('blue', 'ℹ')} Rendering application graph`)\n })\n\n ctx.on('files:added', async (files) => {\n if (!files.length) {\n return\n }\n\n clack.log.info(`${styleText('blue', 'ℹ')} Queued ${pluralize('file', files.length)}`)\n })\n\n ctx.on('file:resolve:path', async (file) => {\n clack.log.step(`Resolving path for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('file:resolve:name', async (file) => {\n clack.log.step(`Resolving name for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('files:processing:start', async (files) => {\n clack.log.step(`Processing ${styleText('green', pluralize('file', files.length))}`)\n\n if (progress) {\n state.progressBar = clack.progress({\n style: 'block',\n max: files.length,\n size: DEFAULT_PROGRESS_BAR_SIZE,\n })\n state.progressBar.start(`Processing ${files.length} files`)\n }\n })\n\n ctx.on('file:processing:start', async (file, index, total) => {\n if (!state.progressBar) {\n clack.log.step(`Processing ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n if (state.progressBar) {\n // undefined = auto-increment by 1\n state.progressBar.advance(undefined, `Writing ${formatPath(file.path)}`)\n } else {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n clack.log.step(`Progress ${styleText('green', `${formattedPercentage}%`)} ${styleText('dim', `(${processed}/${total})`)} → ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:end', async (file, index, total) => {\n if (state.progressBar) {\n state.progressBar.message(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n } else {\n clack.log.success(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('files:processing:end', async (files) => {\n if (state.progressBar) {\n state.progressBar.stop(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n state.progressBar = undefined\n } else {\n clack.log.success(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n if (state.progressBar) {\n state.progressBar.stop()\n state.progressBar = undefined\n }\n\n clack.outro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'completed')}`)\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,aACd,QACgC;AAChC,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;ACeH,SAAgB,eAAe,EAAE,OAAO,MAAM,QAAqD;AAEjG,KAAI,SAAS,eAAe,SAAS,MACnC,QAAO,EAAE;CAGX,MAAM,sCAAsB,IAAI,KAA4C;AAE5E,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,mBAA2C,EAAE;AACnD,OAAK,MAAM,UAAU,KAAK,WAAW,EAAE,CACrC,KAAI,OAAO,eAAe,OAAO,KAC/B,kBAAiB,KAAK,OAAO;AAGjC,MAAI,iBAAiB,SAAS,EAC5B,qBAAoB,IAAI,MAAM,iBAAiB;;CAInD,MAAM,8BAAc,IAAI,KAAmC;CAC3D,MAAM,yBAAS,IAAI,KAAiC;CAEpD,MAAM,WAAW,SAAS,UAAU,OAAO,KAAK;AAEhD,KAAI,CAAC,SACH,QAAO,EAAE;AAGX,UAAS,SAAS,SAAS;AAEzB,MAAI,CAAC,MAAM,YAAY,CAAC,KAAK,QAAQ,KAAK,KACxC;EAGF,MAAM,aAAa,KAAK,OAAO,KAAK;EACpC,MAAM,aAAa,KAAK,KAAK,YAAY,WAAW;EAEpD,IAAI,aAAa,YAAY,IAAI,WAAW;AAC5C,MAAI,CAAC,YAAY;AACf,gBAAa,WAAW;IACtB,MAAM;IACN,UAAU;IACV,SAAS,EAAE;IACX,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;AACF,eAAY,IAAI,YAAY,WAAW;AACvC,UAAO,IAAI,4BAAY,IAAI,KAAa,CAA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OAAM,YAAY,QAAQ,GAAG,UAAU,SAAS,IAAI,CAAC,YAAY,UAAU,OAAO,IAAI,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,KAAK,KAAK,GAAG;OAExI,OAAM,IAAI,QAAQ,GAAG,UAAU,SAAS,IAAI,CAAC,YAAY,UAAU,OAAO,IAAI,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,KAAK,KAAK,GAAG;IAElI;AAEF,MAAI,GAAG,wBAAwB,OAAO,UAAU;AAC9C,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,KAAK,GAAG,UAAU,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;AACjG,UAAM,cAAc,KAAA;SAEpB,OAAM,IAAI,QAAQ,GAAG,UAAU,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;IAE9F;AAEF,MAAI,GAAG,iBAAiB,YAAY;AAClC,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,KAAA;;AAGtB,SAAM,MAAM,GAAG,UAAU,QAAQ,SAAS,CAAC,GAAG,UAAU,OAAO,YAAY,GAAG;IAC9E;;CAEL,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { n as __name } from "./chunk-O_arW02_.js";
2
- import { b as FileManager, h as Context } from "./Fabric-CFkgoZwY.js";
3
- import { r as TreeNode, t as ComponentNode } from "./useNodeTree-Wc1WxA05.js";
2
+ import { b as FileManager, h as Context } from "./Fabric-BY54T8Wd.js";
3
+ import { r as TreeNode, t as ComponentNode } from "./useNodeTree-BYgBDQH2.js";
4
4
 
5
5
  //#region src/contexts/RootContext.d.ts
6
6
  type RootContextProps = {
@@ -29,4 +29,4 @@ type JSDoc = {
29
29
  };
30
30
  //#endregion
31
31
  export { RootContext as n, RootContextProps as r, JSDoc as t };
32
- //# sourceMappingURL=types-BwR3_cUx.d.ts.map
32
+ //# sourceMappingURL=types-DTmub6D9.d.ts.map
package/dist/types.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/KubbFile.ts
3
- var KubbFile_exports = /* @__PURE__ */ require("./chunk-MlS0t1Af.cjs").__exportAll({});
2
+ //#region src/FabricFile.ts
3
+ var FabricFile_exports = /* @__PURE__ */ require("./chunk-MlS0t1Af.cjs").__exportAll({});
4
4
  //#endregion
5
5
  Object.defineProperty(exports, "FabricFile", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return KubbFile_exports;
8
+ return FabricFile_exports;
9
9
  }
10
10
  });
11
11
  Object.defineProperty(exports, "KubbFile", {
12
12
  enumerable: true,
13
13
  get: function() {
14
- return KubbFile_exports;
14
+ return FabricFile_exports;
15
15
  }
16
16
  });
17
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../src/KubbFile.ts"],"sourcesContent":["type ImportName =\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name: ImportName\n\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add type-only import prefix.\n * - `true` generates `import type { Type } from './path'`\n * - `false` generates `import { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n\n /**\n * Import entire module as namespace.\n * - `true` generates `import * as Name from './path'`\n * - `false` generates standard import\n * @default false\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 /**\n * Make this source a type-only export.\n * - `true` marks source as type export\n * - `false` marks source as value export\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Include export keyword in source.\n * - `true` generates exportable const or type\n * - `false` generates internal declaration\n * @default false\n */\n isExportable?: boolean\n /**\n * Include in barrel file generation.\n * - `true` adds to barrel exports\n * - `false` excludes from barrel exports\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-only export prefix.\n * - `true` generates `export type { Type } from './path'`\n * - `false` generates `export { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Export as aliased namespace.\n * - `true` generates `export * as aliasName from './path'`\n * - `false` generates standard export\n * @default false\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 dynamically 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 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: 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 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<Import>\n exports: Array<Export>\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../src/FabricFile.ts"],"sourcesContent":["type ImportName =\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name: ImportName\n\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add type-only import prefix.\n * - `true` generates `import type { Type } from './path'`\n * - `false` generates `import { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n\n /**\n * Import entire module as namespace.\n * - `true` generates `import * as Name from './path'`\n * - `false` generates standard import\n * @default false\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 /**\n * Make this source a type-only export.\n * - `true` marks source as type export\n * - `false` marks source as value export\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Include export keyword in source.\n * - `true` generates exportable const or type\n * - `false` generates internal declaration\n * @default false\n */\n isExportable?: boolean\n /**\n * Include in barrel file generation.\n * - `true` adds to barrel exports\n * - `false` excludes from barrel exports\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-only export prefix.\n * - `true` generates `export type { Type } from './path'`\n * - `false` generates `export { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Export as aliased namespace.\n * - `true` generates `export * as aliasName from './path'`\n * - `false` generates standard export\n * @default false\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 dynamically 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 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: 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 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<Import>\n exports: Array<Export>\n}\n"],"mappings":""}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as FabricOptions, h as Context, i as FabricContext, k as KubbFile_d_exports, m as RenderContextProps, o as FabricMode, r as FabricConfig, t as Fabric } from "./Fabric-CFkgoZwY.js";
2
- import { t as ComponentNode } from "./useNodeTree-Wc1WxA05.js";
3
- import { r as RootContextProps, t as JSDoc } from "./types-BwR3_cUx.js";
4
- export { ComponentNode, Context, Fabric, FabricConfig, FabricContext, KubbFile_d_exports as FabricFile, KubbFile_d_exports as KubbFile, FabricMode, FabricOptions, JSDoc, RenderContextProps, RootContextProps };
1
+ import { D as FabricFile_d_exports, c as FabricOptions, h as Context, i as FabricContext, m as RenderContextProps, o as FabricMode, r as FabricConfig, t as Fabric } from "./Fabric-BY54T8Wd.js";
2
+ import { t as ComponentNode } from "./useNodeTree-BYgBDQH2.js";
3
+ import { r as RootContextProps, t as JSDoc } from "./types-DTmub6D9.js";
4
+ export { ComponentNode, Context, Fabric, FabricConfig, FabricContext, FabricFile_d_exports as FabricFile, FabricFile_d_exports as KubbFile, FabricMode, FabricOptions, JSDoc, RenderContextProps, RootContextProps };
package/dist/types.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./chunk-O_arW02_.js";
2
- //#region src/KubbFile.ts
3
- var KubbFile_exports = /* @__PURE__ */ __exportAll({});
2
+ //#region src/FabricFile.ts
3
+ var FabricFile_exports = /* @__PURE__ */ __exportAll({});
4
4
  //#endregion
5
- export { KubbFile_exports as FabricFile, KubbFile_exports as KubbFile };
5
+ export { FabricFile_exports as FabricFile, FabricFile_exports as KubbFile };
6
6
 
7
7
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/KubbFile.ts"],"sourcesContent":["type ImportName =\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name: ImportName\n\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add type-only import prefix.\n * - `true` generates `import type { Type } from './path'`\n * - `false` generates `import { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n\n /**\n * Import entire module as namespace.\n * - `true` generates `import * as Name from './path'`\n * - `false` generates standard import\n * @default false\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 /**\n * Make this source a type-only export.\n * - `true` marks source as type export\n * - `false` marks source as value export\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Include export keyword in source.\n * - `true` generates exportable const or type\n * - `false` generates internal declaration\n * @default false\n */\n isExportable?: boolean\n /**\n * Include in barrel file generation.\n * - `true` adds to barrel exports\n * - `false` excludes from barrel exports\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-only export prefix.\n * - `true` generates `export type { Type } from './path'`\n * - `false` generates `export { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Export as aliased namespace.\n * - `true` generates `export * as aliasName from './path'`\n * - `false` generates standard export\n * @default false\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 dynamically 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 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: 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 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<Import>\n exports: Array<Export>\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/FabricFile.ts"],"sourcesContent":["type ImportName =\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name: ImportName\n\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add type-only import prefix.\n * - `true` generates `import type { Type } from './path'`\n * - `false` generates `import { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n\n /**\n * Import entire module as namespace.\n * - `true` generates `import * as Name from './path'`\n * - `false` generates standard import\n * @default false\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 /**\n * Make this source a type-only export.\n * - `true` marks source as type export\n * - `false` marks source as value export\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Include export keyword in source.\n * - `true` generates exportable const or type\n * - `false` generates internal declaration\n * @default false\n */\n isExportable?: boolean\n /**\n * Include in barrel file generation.\n * - `true` adds to barrel exports\n * - `false` excludes from barrel exports\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-only export prefix.\n * - `true` generates `export type { Type } from './path'`\n * - `false` generates `export { Type } from './path'`\n * @default false\n */\n isTypeOnly?: boolean\n /**\n * Export as aliased namespace.\n * - `true` generates `export * as aliasName from './path'`\n * - `false` generates standard export\n * @default false\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 dynamically 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 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: 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 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<Import>\n exports: Array<Export>\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import { n as __name } from "./chunk-O_arW02_.js";
2
- import { D as File } from "./Fabric-CFkgoZwY.js";
2
+ import { O as File } from "./Fabric-BY54T8Wd.js";
3
3
 
4
4
  //#region src/utils/TreeNode.d.ts
5
5
  type BarrelData = {
@@ -56,4 +56,4 @@ type ComponentNode = {
56
56
  declare function useNodeTree(): TreeNode<ComponentNode> | null;
57
57
  //#endregion
58
58
  export { useNodeTree as n, TreeNode as r, ComponentNode as t };
59
- //# sourceMappingURL=useNodeTree-Wc1WxA05.d.ts.map
59
+ //# sourceMappingURL=useNodeTree-BYgBDQH2.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/fabric-core",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "Core functionality for Kubb's fabric - A language-agnostic toolkit providing the foundation for plugin-based code generation with TypeScript support",
5
5
  "keywords": [
6
6
  "codegen",
package/src/Fabric.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import type * as KubbFile from './FabricFile.ts'
1
2
  import type { FileManager } from './FileManager.ts'
2
3
  import type { Intrinsic } from './intrinsic.ts'
3
- import type * as KubbFile from './KubbFile.ts'
4
4
  import type { Parser } from './parsers/types.ts'
5
5
  import type { Plugin } from './plugins/types.ts'
6
6
  import type { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
@@ -1,8 +1,8 @@
1
1
  import { sortBy } from 'remeda'
2
2
  import { createFile } from './createFile.ts'
3
3
  import type { FabricEvents } from './Fabric.ts'
4
+ import type * as KubbFile from './FabricFile.ts'
4
5
  import { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'
5
- import type * as KubbFile from './KubbFile.ts'
6
6
  import { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
7
7
  import { Cache } from './utils/Cache.ts'
8
8
  import { trimExtName } from './utils/trimExtName.ts'
@@ -1,6 +1,6 @@
1
1
  import pLimit from 'p-limit'
2
2
  import type { FabricEvents, FabricMode } from './Fabric.ts'
3
- import type * as KubbFile from './KubbFile.ts'
3
+ import type * as KubbFile from './FabricFile.ts'
4
4
  import { defaultParser } from './parsers/defaultParser.ts'
5
5
  import type { Parser } from './parsers/types.ts'
6
6
  import { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
@@ -1,5 +1,5 @@
1
1
  import { FileContext } from '../contexts/FileContext.ts'
2
- import type * as KubbFile from '../KubbFile.ts'
2
+ import type * as KubbFile from '../FabricFile.ts'
3
3
  import { useContext } from './useContext.ts'
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { createContext } from '../context.ts'
2
- import type * as KubbFile from '../KubbFile.ts'
2
+ import type * as KubbFile from '../FabricFile.ts'
3
3
 
4
4
  /**
5
5
  * Provides app-level metadata and lifecycle hooks (like `exit`) to
@@ -1,7 +1,7 @@
1
1
  import { isFunction } from 'remeda'
2
2
  import type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'
3
+ import type * as KubbFile from './FabricFile.ts'
3
4
  import { FileManager } from './FileManager.ts'
4
- import type * as KubbFile from './KubbFile.ts'
5
5
  import type { Parser } from './parsers/types.ts'
6
6
  import type { Plugin } from './plugins/types.ts'
7
7
  import { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
package/src/createFile.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto'
2
2
  import path from 'node:path'
3
3
  import { sortBy, uniqueBy } from 'remeda'
4
- import type * as KubbFile from './KubbFile.ts'
4
+ import type * as KubbFile from './FabricFile.ts'
5
5
  import { trimExtName } from './utils/trimExtName.ts'
6
6
 
7
7
  export function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {
@@ -1,5 +1,5 @@
1
1
  import type { Install } from '../Fabric.ts'
2
- import type * as KubbFile from '../KubbFile.ts'
2
+ import type * as KubbFile from '../FabricFile.ts'
3
3
 
4
4
  type PrintOptions = {
5
5
  extname?: KubbFile.Extname
@@ -2,7 +2,7 @@
2
2
 
3
3
  import path from 'node:path'
4
4
  import { createFile } from '../createFile.ts'
5
- import type * as KubbFile from '../KubbFile.ts'
5
+ import type * as KubbFile from '../FabricFile.ts'
6
6
  import { getRelativePath } from '../utils/getRelativePath.ts'
7
7
  import { TreeNode } from '../utils/TreeNode.ts'
8
8
  import { definePlugin } from './definePlugin.ts'
@@ -1,7 +1,7 @@
1
1
  import { rmSync } from 'node:fs'
2
2
  import { mkdir, readFile, writeFile } from 'node:fs/promises'
3
3
  import { dirname, resolve } from 'node:path'
4
- import type * as KubbFile from '../KubbFile.ts'
4
+ import type * as KubbFile from '../FabricFile.ts'
5
5
  import { definePlugin } from './definePlugin.ts'
6
6
 
7
7
  type WriteOptions = {
package/src/types.ts CHANGED
@@ -9,5 +9,5 @@ export type { Context } from './context.ts'
9
9
  export type { RenderContextProps } from './contexts/RenderContext.ts'
10
10
  export type { RootContextProps } from './contexts/RootContext.ts'
11
11
  export type { Fabric } from './Fabric.ts'
12
- export * as KubbFile from './KubbFile.ts'
13
- export * as FabricFile from './KubbFile.ts'
12
+ export * as KubbFile from './FabricFile.ts'
13
+ export * as FabricFile from './FabricFile.ts'
@@ -1,4 +1,4 @@
1
- import type * as KubbFile from '../KubbFile.ts'
1
+ import type * as KubbFile from '../FabricFile.ts'
2
2
 
3
3
  type BarrelData = {
4
4
  file?: KubbFile.File
File without changes