@kubb/fabric-core 0.6.0 → 0.7.0
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.
- package/dist/{Fabric-CEVrEuYU.d.ts → Fabric-BXYWK9V4.d.cts} +11 -59
- package/dist/{Fabric-CVnHPMqM.d.cts → Fabric-CDFwTDyP.d.ts} +11 -59
- package/dist/index.cjs +10 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -18
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.d.cts +2 -2
- package/dist/parsers/typescript.d.ts +2 -2
- package/dist/parsers.d.cts +2 -2
- package/dist/parsers.d.ts +2 -2
- package/dist/plugins.cjs +11 -11
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +11 -11
- package/dist/plugins.js.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{typescriptParser-9jJzfPj-.d.ts → typescriptParser-CPUUUA9z.d.ts} +2 -2
- package/dist/{typescriptParser-DCFNN4BL.d.cts → typescriptParser-H0FvAP4t.d.cts} +2 -2
- package/package.json +1 -1
- package/src/Fabric.ts +10 -34
- package/src/FileManager.ts +6 -6
- package/src/FileProcessor.ts +4 -4
- package/src/plugins/barrelPlugin.ts +2 -2
- package/src/plugins/graphPlugin.ts +1 -1
- package/src/plugins/loggerPlugin.ts +9 -9
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["e","NodeEventEmitter","errors: Error[]","resolvedFiles: Array<KubbFile.ResolvedFile>","files: Array<KubbFile.ResolvedFile>","context: FabricContext<T>","fabric: Fabric<T>","isFunction"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/isFunction-BJjFuZR7.js","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.ts","../src/createFabric.ts"],"sourcesContent":["const e=e=>typeof e==`function`;export{e as isFunction};\n//# sourceMappingURL=isFunction-BJjFuZR7.js.map","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport type { FabricMode } from '../Fabric.ts'\n\ntype Options = {\n mode?: FabricMode\n maxListener?: number\n}\n\nexport class AsyncEventEmitter<TEvents extends Record<string, any>> {\n constructor({ maxListener = 100, mode = 'sequential' }: Options = {}) {\n this.#emitter.setMaxListeners(maxListener)\n this.#mode = mode\n }\n\n #emitter = new NodeEventEmitter()\n #mode: FabricMode\n\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<(...args: TEvents[TEventName]) => any>\n\n if (listeners.length === 0) {\n return\n }\n\n const errors: Error[] = []\n\n if (this.#mode === 'sequential') {\n // Run listeners one by one, in order\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n }\n } else {\n // Run all listeners concurrently\n const promises = listeners.map(async (listener) => {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n })\n await Promise.all(promises)\n }\n\n if (errors.length === 1) {\n throw errors[0]\n }\n\n if (errors.length > 1) {\n throw new AggregateError(errors, `Errors in async listeners for \"${eventName}\"`)\n }\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void {\n const wrapper = (...args: TEvents[TEventName]) => {\n this.off(eventName, wrapper)\n handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import pLimit from 'p-limit'\nimport type { FabricEvents, FabricMode } from './Fabric.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { defaultParser } from './parsers/defaultParser.ts'\nimport type { Parser } from './parsers/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\nexport type ProcessFilesProps = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n /**\n * @default 'sequential'\n */\n mode?: FabricMode\n}\n\ntype GetParseOptions = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileProcessor {\n #limit = pLimit(100)\n events: AsyncEventEmitter<FabricEvents>\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.events = events\n\n return this\n }\n\n async parse(file: KubbFile.ResolvedFile, { parsers, extension }: GetParseOptions = {}): Promise<string> {\n const parseExtName = extension?.[file.extname] || undefined\n\n if (!parsers) {\n console.warn('No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.')\n\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n if (!file.extname) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n const parser = parsers.get(file.extname)\n\n if (!parser) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n return parser.parse(file, { extname: parseExtName })\n }\n\n async run(\n files: Array<KubbFile.ResolvedFile>,\n { parsers, mode = 'sequential', dryRun, extension }: ProcessFilesProps = {},\n ): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:processing:start', { files })\n\n const total = files.length\n let processed = 0\n\n const processOne = async (resolvedFile: KubbFile.ResolvedFile, index: number) => {\n await this.events.emit('file:processing:start', { file: resolvedFile, index, total })\n\n const source = dryRun ? undefined : await this.parse(resolvedFile, { extension, parsers })\n\n const currentProcessed = ++processed\n const percentage = (currentProcessed / total) * 100\n\n await this.events.emit('file:processing:update', {\n file: resolvedFile,\n source,\n processed: currentProcessed,\n percentage,\n total,\n })\n\n await this.events.emit('file:processing:end', { file: resolvedFile, index, total })\n }\n\n if (mode === 'sequential') {\n async function* asyncFiles() {\n for (let index = 0; index < files.length; index++) {\n yield [files[index], index] as const\n }\n }\n\n for await (const [file, index] of asyncFiles()) {\n if (file) {\n await processOne(file, index)\n }\n }\n } else {\n const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)))\n await Promise.all(promises)\n }\n\n await this.events.emit('files:processing:end', { files })\n\n return files\n }\n}\n","export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import { orderBy } from 'natural-orderby'\nimport { createFile } from './createFile.ts'\nimport type { FabricEvents } from './Fabric.ts'\nimport { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #filesCache: Array<KubbFile.ResolvedFile> | null = null\n events: AsyncEventEmitter<FabricEvents>\n processor: FileProcessor\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.processor = new FileProcessor({ events })\n\n this.events = events\n return this\n }\n\n #resolvePath(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:path', { file })\n\n return file\n }\n\n #resolveName(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:name', { file })\n\n return file\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const resolvedFile = createFile(file)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', { files: resolvedFiles })\n\n return resolvedFiles\n }\n\n async upsert(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', { files: resolvedFiles })\n\n return resolvedFiles\n }\n\n flush() {\n this.#filesCache = null\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n this.#filesCache = null\n }\n\n clear(): void {\n this.#cache.clear()\n this.#filesCache = null\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files: Array<KubbFile.ResolvedFile> = []\n\n for (const key of keys) {\n const file = this.#cache.get(key)\n if (file) {\n files.push(file)\n }\n }\n\n this.#filesCache = files\n\n return files\n }\n\n //TODO add test and check if write of FileManager contains the newly added file\n async write(options: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:writing:start', { files: this.files })\n\n const resolvedFiles = await this.processor.run(this.files, options)\n\n this.clear()\n\n await this.events.emit('files:writing:end', { files: resolvedFiles })\n\n return resolvedFiles\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance\n *\n * @example\n * const fabric = createFabric()\n * fabric.use(myPlugin())\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;AAAA,MAAM,KAAE,QAAG,OAAOA,OAAG;;;;;;ACQrB,IAAa,oBAAb,MAAoE;CAClE,YAAY,EAAE,cAAc,KAAK,OAAO,iBAA0B,EAAE,EAAE;6CAK3D,IAAIC,cAAkB;;AAJ/B,wCAAa,CAAC,gBAAgB,YAA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AAe;;;AAKnD,OAAIA,EAAW,eAAe,QAAQ,EAAE;IACtC,MAAM,YAAY,eAAe;AAEjC,UAAO,UAAkB,SAAS,GAAG,QAAQ;;AAG/C,UAAO;;EAEV;AAED,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["e","NodeEventEmitter","errors: Error[]","resolvedFiles: Array<KubbFile.ResolvedFile>","files: Array<KubbFile.ResolvedFile>","context: FabricContext<T>","fabric: Fabric<T>","isFunction"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/isFunction-BJjFuZR7.js","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.ts","../src/createFabric.ts"],"sourcesContent":["const e=e=>typeof e==`function`;export{e as isFunction};\n//# sourceMappingURL=isFunction-BJjFuZR7.js.map","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport type { FabricMode } from '../Fabric.ts'\n\ntype Options = {\n mode?: FabricMode\n maxListener?: number\n}\n\nexport class AsyncEventEmitter<TEvents extends Record<string, any>> {\n constructor({ maxListener = 100, mode = 'sequential' }: Options = {}) {\n this.#emitter.setMaxListeners(maxListener)\n this.#mode = mode\n }\n\n #emitter = new NodeEventEmitter()\n #mode: FabricMode\n\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<(...args: TEvents[TEventName]) => any>\n\n if (listeners.length === 0) {\n return\n }\n\n const errors: Error[] = []\n\n if (this.#mode === 'sequential') {\n // Run listeners one by one, in order\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n }\n } else {\n // Run all listeners concurrently\n const promises = listeners.map(async (listener) => {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n })\n await Promise.all(promises)\n }\n\n if (errors.length === 1) {\n throw errors[0]\n }\n\n if (errors.length > 1) {\n throw new AggregateError(errors, `Errors in async listeners for \"${eventName}\"`)\n }\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void {\n const wrapper = (...args: TEvents[TEventName]) => {\n this.off(eventName, wrapper)\n handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import pLimit from 'p-limit'\nimport type { FabricEvents, FabricMode } from './Fabric.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { defaultParser } from './parsers/defaultParser.ts'\nimport type { Parser } from './parsers/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\nexport type ProcessFilesProps = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n /**\n * @default 'sequential'\n */\n mode?: FabricMode\n}\n\ntype GetParseOptions = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileProcessor {\n #limit = pLimit(100)\n events: AsyncEventEmitter<FabricEvents>\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.events = events\n\n return this\n }\n\n async parse(file: KubbFile.ResolvedFile, { parsers, extension }: GetParseOptions = {}): Promise<string> {\n const parseExtName = extension?.[file.extname] || undefined\n\n if (!parsers) {\n console.warn('No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.')\n\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n if (!file.extname) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n const parser = parsers.get(file.extname)\n\n if (!parser) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n return parser.parse(file, { extname: parseExtName })\n }\n\n async run(\n files: Array<KubbFile.ResolvedFile>,\n { parsers, mode = 'sequential', dryRun, extension }: ProcessFilesProps = {},\n ): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:processing:start', files)\n\n const total = files.length\n let processed = 0\n\n const processOne = async (resolvedFile: KubbFile.ResolvedFile, index: number) => {\n await this.events.emit('file:processing:start', resolvedFile, index, total)\n\n const source = dryRun ? undefined : await this.parse(resolvedFile, { extension, parsers })\n\n const currentProcessed = ++processed\n const percentage = (currentProcessed / total) * 100\n\n await this.events.emit('file:processing:update', {\n file: resolvedFile,\n source,\n processed: currentProcessed,\n percentage,\n total,\n })\n\n await this.events.emit('file:processing:end', resolvedFile, index, total)\n }\n\n if (mode === 'sequential') {\n async function* asyncFiles() {\n for (let index = 0; index < files.length; index++) {\n yield [files[index], index] as const\n }\n }\n\n for await (const [file, index] of asyncFiles()) {\n if (file) {\n await processOne(file, index)\n }\n }\n } else {\n const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)))\n await Promise.all(promises)\n }\n\n await this.events.emit('files:processing:end', files)\n\n return files\n }\n}\n","export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import { orderBy } from 'natural-orderby'\nimport { createFile } from './createFile.ts'\nimport type { FabricEvents } from './Fabric.ts'\nimport { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #filesCache: Array<KubbFile.ResolvedFile> | null = null\n events: AsyncEventEmitter<FabricEvents>\n processor: FileProcessor\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.processor = new FileProcessor({ events })\n\n this.events = events\n return this\n }\n\n #resolvePath(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:path', file)\n\n return file\n }\n\n #resolveName(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:name', file)\n\n return file\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const resolvedFile = createFile(file)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', resolvedFiles)\n\n return resolvedFiles\n }\n\n async upsert(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', resolvedFiles)\n\n return resolvedFiles\n }\n\n flush() {\n this.#filesCache = null\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n this.#filesCache = null\n }\n\n clear(): void {\n this.#cache.clear()\n this.#filesCache = null\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files: Array<KubbFile.ResolvedFile> = []\n\n for (const key of keys) {\n const file = this.#cache.get(key)\n if (file) {\n files.push(file)\n }\n }\n\n this.#filesCache = files\n\n return files\n }\n\n //TODO add test and check if write of FileManager contains the newly added file\n async write(options: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:writing:start', this.files)\n\n const resolvedFiles = await this.processor.run(this.files, options)\n\n this.clear()\n\n await this.events.emit('files:writing:end', resolvedFiles)\n\n return resolvedFiles\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance\n *\n * @example\n * const fabric = createFabric()\n * fabric.use(myPlugin())\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;AAAA,MAAM,KAAE,QAAG,OAAOA,OAAG;;;;;;ACQrB,IAAa,oBAAb,MAAoE;CAClE,YAAY,EAAE,cAAc,KAAK,OAAO,iBAA0B,EAAE,EAAE;6CAK3D,IAAIC,cAAkB;;AAJ/B,wCAAa,CAAC,gBAAgB,YAAY;AAC1C,sCAAa,KAAI;;CAMnB,MAAM,KAAgD,WAAuB,GAAG,WAA+C;EAC7H,MAAM,6CAAY,KAAa,CAAC,UAAU,UAAU;AAEpD,MAAI,UAAU,WAAW,EACvB;EAGF,MAAMC,SAAkB,EAAE;AAE1B,oCAAI,KAAU,KAAK,aAEjB,MAAK,MAAM,YAAY,UACrB,KAAI;AACF,SAAM,SAAS,GAAG,UAAU;WACrB,KAAK;GACZ,MAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC;AACjE,UAAO,KAAK,MAAM;;OAGjB;GAEL,MAAM,WAAW,UAAU,IAAI,OAAO,aAAa;AACjD,QAAI;AACF,WAAM,SAAS,GAAG,UAAU;aACrB,KAAK;KACZ,MAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC;AACjE,YAAO,KAAK,MAAM;;KAEpB;AACF,SAAM,QAAQ,IAAI,SAAS;;AAG7B,MAAI,OAAO,WAAW,EACpB,OAAM,OAAO;AAGf,MAAI,OAAO,SAAS,EAClB,OAAM,IAAI,eAAe,QAAQ,kCAAkC,UAAU,GAAG;;CAIpF,GAA8C,WAAuB,SAA2D;AAC9H,wCAAa,CAAC,GAAG,WAAW,QAAe;;CAG7C,OAAkD,WAAuB,SAA4D;EACnI,MAAM,WAAW,GAAG,SAA8B;AAChD,QAAK,IAAI,WAAW,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AAW,eAAe,UAAU;KAC7C,MAAM,WAAW,iBAAiB,IAAI,QAAQ;AAC9C,SAAI,YAAY,SAAS,SAAS,eAAe,KAC/C,SAAQ,KAAK,WAAW,eAAe,KAAK,0BAA0B,SAAS,KAAK,mBAAmB,QAAQ,IAAI;AAErH,sBAAiB,IAAI,SAAS,eAAe;;;AAKnD,OAAIA,EAAW,eAAe,QAAQ,EAAE;IACtC,MAAM,YAAY,eAAe;AAEjC,UAAO,UAAkB,SAAS,GAAG,QAAQ;;AAG/C,UAAO;;EAEV;AAED,QAAO"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../Fabric-
|
|
2
|
-
import { i as typescriptParser, n as createImport, r as print, t as createExport } from "../typescriptParser-
|
|
1
|
+
import "../Fabric-BXYWK9V4.cjs";
|
|
2
|
+
import { i as typescriptParser, n as createImport, r as print, t as createExport } from "../typescriptParser-H0FvAP4t.cjs";
|
|
3
3
|
export { createExport, createImport, print, typescriptParser };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../Fabric-
|
|
2
|
-
import { i as typescriptParser, n as createImport, r as print, t as createExport } from "../typescriptParser-
|
|
1
|
+
import "../Fabric-CDFwTDyP.js";
|
|
2
|
+
import { i as typescriptParser, n as createImport, r as print, t as createExport } from "../typescriptParser-CPUUUA9z.js";
|
|
3
3
|
export { createExport, createImport, print, typescriptParser };
|
package/dist/parsers.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as UserParser, u as Parser } from "./Fabric-
|
|
2
|
-
import { i as typescriptParser } from "./typescriptParser-
|
|
1
|
+
import { d as UserParser, u as Parser } from "./Fabric-BXYWK9V4.cjs";
|
|
2
|
+
import { i as typescriptParser } from "./typescriptParser-H0FvAP4t.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/parsers/defaultParser.d.ts
|
|
5
5
|
declare const defaultParser: Parser<[], any>;
|
package/dist/parsers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as UserParser, u as Parser } from "./Fabric-
|
|
2
|
-
import { i as typescriptParser } from "./typescriptParser-
|
|
1
|
+
import { d as UserParser, u as Parser } from "./Fabric-CDFwTDyP.js";
|
|
2
|
+
import { i as typescriptParser } from "./typescriptParser-CPUUUA9z.js";
|
|
3
3
|
|
|
4
4
|
//#region src/parsers/defaultParser.d.ts
|
|
5
5
|
declare const defaultParser: Parser<[], any>;
|
package/dist/plugins.cjs
CHANGED
|
@@ -211,7 +211,7 @@ const barrelPlugin = definePlugin({
|
|
|
211
211
|
install(ctx, options) {
|
|
212
212
|
if (!options) throw new Error("Barrel plugin requires options.root and options.mode");
|
|
213
213
|
if (!options.mode) return;
|
|
214
|
-
ctx.on("files:writing:start", async (
|
|
214
|
+
ctx.on("files:writing:start", async (files) => {
|
|
215
215
|
const root = options.root;
|
|
216
216
|
const barrelFiles = getBarrelFiles({
|
|
217
217
|
files,
|
|
@@ -400,7 +400,7 @@ const graphPlugin = definePlugin({
|
|
|
400
400
|
name: "graph",
|
|
401
401
|
install(ctx, options) {
|
|
402
402
|
if (!options) throw new Error("Graph plugin requires options.root and options.mode");
|
|
403
|
-
ctx.on("files:writing:start", async (
|
|
403
|
+
ctx.on("files:writing:start", async (files) => {
|
|
404
404
|
const root = options.root;
|
|
405
405
|
const graph = getGraph({
|
|
406
406
|
files,
|
|
@@ -508,20 +508,20 @@ const loggerPlugin = definePlugin({
|
|
|
508
508
|
logger.info("Rendering application graph");
|
|
509
509
|
broadcast("lifecycle:render", { timestamp: Date.now() });
|
|
510
510
|
});
|
|
511
|
-
ctx.on("files:added", async (
|
|
511
|
+
ctx.on("files:added", async (files) => {
|
|
512
512
|
if (!files.length) return;
|
|
513
513
|
logger.info(`Queued ${pluralize("file", files.length)}`);
|
|
514
514
|
broadcast("files:added", { files: files.map(serializeFile) });
|
|
515
515
|
});
|
|
516
|
-
ctx.on("file:resolve:path", async (
|
|
516
|
+
ctx.on("file:resolve:path", async (file) => {
|
|
517
517
|
logger.info(`Resolving path for ${formatPath(file.path)}`);
|
|
518
518
|
broadcast("file:resolve:path", { file: serializeFile(file) });
|
|
519
519
|
});
|
|
520
|
-
ctx.on("file:resolve:name", async (
|
|
520
|
+
ctx.on("file:resolve:name", async (file) => {
|
|
521
521
|
logger.info(`Resolving name for ${formatPath(file.path)}`);
|
|
522
522
|
broadcast("file:resolve:name", { file: serializeFile(file) });
|
|
523
523
|
});
|
|
524
|
-
ctx.on("files:processing:start", async (
|
|
524
|
+
ctx.on("files:processing:start", async (files) => {
|
|
525
525
|
logger.start(`Processing ${pluralize("file", files.length)}`);
|
|
526
526
|
broadcast("files:processing:start", {
|
|
527
527
|
total: files.length,
|
|
@@ -532,7 +532,7 @@ const loggerPlugin = definePlugin({
|
|
|
532
532
|
progressBar.start(files.length, 0, { message: "Starting..." });
|
|
533
533
|
}
|
|
534
534
|
});
|
|
535
|
-
ctx.on("file:processing:start", async (
|
|
535
|
+
ctx.on("file:processing:start", async (file, index, total) => {
|
|
536
536
|
logger.info(`Processing [${index + 1}/${total}] ${formatPath(file.path)}`);
|
|
537
537
|
broadcast("file:processing:start", {
|
|
538
538
|
index,
|
|
@@ -551,7 +551,7 @@ const loggerPlugin = definePlugin({
|
|
|
551
551
|
});
|
|
552
552
|
if (progressBar) progressBar.increment(1, { message: `Writing ${formatPath(file.path)}` });
|
|
553
553
|
});
|
|
554
|
-
ctx.on("file:processing:end", async (
|
|
554
|
+
ctx.on("file:processing:end", async (file, index, total) => {
|
|
555
555
|
logger.success(`Finished [${index + 1}/${total}] ${formatPath(file.path)}`);
|
|
556
556
|
broadcast("file:processing:end", {
|
|
557
557
|
index,
|
|
@@ -559,15 +559,15 @@ const loggerPlugin = definePlugin({
|
|
|
559
559
|
file: serializeFile(file)
|
|
560
560
|
});
|
|
561
561
|
});
|
|
562
|
-
ctx.on("files:writing:start", async (
|
|
562
|
+
ctx.on("files:writing:start", async (files) => {
|
|
563
563
|
logger.start(`Writing ${pluralize("file", files.length)} to disk`);
|
|
564
564
|
broadcast("files:writing:start", { files: files.map(serializeFile) });
|
|
565
565
|
});
|
|
566
|
-
ctx.on("files:writing:end", async (
|
|
566
|
+
ctx.on("files:writing:end", async (files) => {
|
|
567
567
|
logger.success(`Written ${pluralize("file", files.length)} to disk`);
|
|
568
568
|
broadcast("files:writing:end", { files: files.map(serializeFile) });
|
|
569
569
|
});
|
|
570
|
-
ctx.on("files:processing:end", async (
|
|
570
|
+
ctx.on("files:processing:end", async (files) => {
|
|
571
571
|
logger.success(`Processed ${pluralize("file", files.length)}`);
|
|
572
572
|
broadcast("files:processing:end", {
|
|
573
573
|
total: files.length,
|
package/dist/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["result: Array<TreeNode<TData>>","stack: Array<TreeNode<TData>>","nodes: Array<{ id: string; label: string }>","edges: Array<{ from: string; to: string }>","stack: Array<TreeNode<BarrelData>>","filteredFiles: Array<KubbFile.File>","indexableSources: Array<KubbFile.Source>","path","createFile","getRelativePath","barrelFiles: Array<KubbFile.ResolvedFile>","exports: Array<KubbFile.Export>","path","fs","path","http","createFile","path","SingleBar","Presets","server: http.Server | undefined","wss: WebSocketServer | undefined","broadcast: Broadcast","WebSocket","http","WebSocketServer","path","closures: Array<Promise<void>>","resolve"],"sources":["../src/utils/TreeNode.ts","../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/utils/open.ts","../src/plugins/graphPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type * as KubbFile from '../KubbFile.ts'\n\ntype BarrelData = {\n file?: KubbFile.File\n path: string\n name: string\n}\n\nexport type Graph = {\n nodes: Array<{ id: string; label: string }>\n edges: Array<{ from: string; to: string }>\n}\n\nexport class TreeNode<TData = unknown> {\n data: TData\n parent?: TreeNode<TData>\n children: Array<TreeNode<TData>> = []\n #childrenMap = new Map<string, TreeNode<TData>>()\n #cachedLeaves?: Array<TreeNode<TData>>\n\n constructor(data: TData, parent?: TreeNode<TData>) {\n this.data = data\n this.parent = parent\n }\n\n addChild(data: TData): TreeNode<TData> {\n const child = new TreeNode(data, this)\n this.children.push(child)\n // Update Map if data has a name property (for BarrelData)\n if (typeof data === 'object' && data !== null && 'name' in data) {\n this.#childrenMap.set((data as { name: string }).name, child)\n }\n this.#cachedLeaves = undefined // invalidate cached leaves\n return child\n }\n\n getChildByName(name: string): TreeNode<TData> | undefined {\n return this.#childrenMap.get(name)\n }\n\n get leaves(): Array<TreeNode<TData>> {\n if (this.#cachedLeaves) return this.#cachedLeaves\n if (this.children.length === 0) return [this]\n\n const result: Array<TreeNode<TData>> = []\n const stack: Array<TreeNode<TData>> = [...this.children]\n const visited = new Set<TreeNode<TData>>()\n\n while (stack.length > 0) {\n const node = stack.pop()!\n if (visited.has(node)) {\n continue\n }\n visited.add(node)\n\n if (node.children.length > 0) {\n stack.push(...node.children)\n } else {\n result.push(node)\n }\n }\n\n this.#cachedLeaves = result\n return result\n }\n\n forEach(callback: (node: TreeNode<TData>) => void): this {\n const stack: Array<TreeNode<TData>> = [this]\n\n for (let i = 0; i < stack.length; i++) {\n const node = stack[i]!\n callback(node)\n\n if (node.children.length > 0) {\n stack.push(...node.children)\n }\n }\n\n return this\n }\n\n findDeep(predicate: (node: TreeNode<TData>) => boolean): TreeNode<TData> | undefined {\n for (const leaf of this.leaves) {\n if (predicate(leaf)) return leaf\n }\n return undefined\n }\n\n static toGraph(root: TreeNode<BarrelData>): Graph {\n const nodes: Array<{ id: string; label: string }> = []\n const edges: Array<{ from: string; to: string }> = []\n\n const stack: Array<TreeNode<BarrelData>> = [root]\n\n for (let i = 0; i < stack.length; i++) {\n const node = stack[i]!\n\n nodes.push({\n id: node.data.path,\n label: node.data.name,\n })\n\n const children = node.children\n if (children.length > 0) {\n for (let j = 0, len = children.length; j < len; j++) {\n const child = children[j]!\n edges.push({\n from: node.data.path,\n to: child.data.path,\n })\n stack.push(child)\n }\n }\n }\n\n return { nodes, edges }\n }\n\n static fromFiles(files: Array<KubbFile.File>, rootFolder = ''): TreeNode<BarrelData> | null {\n const normalizePath = (p: string): string => p.replace(/\\\\/g, '/')\n const normalizedRoot = normalizePath(rootFolder)\n const rootPrefix = normalizedRoot.endsWith('/') ? normalizedRoot : `${normalizedRoot}/`\n\n const normalizedPaths = new Map<KubbFile.File, string>()\n const filteredFiles: Array<KubbFile.File> = []\n for (const file of files) {\n const filePath = normalizedPaths.get(file) ?? normalizePath(file.path)\n normalizedPaths.set(file, filePath)\n if (!filePath.endsWith('.json') && (!rootFolder || filePath.startsWith(rootPrefix))) {\n filteredFiles.push(file)\n }\n }\n\n if (filteredFiles.length === 0) {\n return null\n }\n\n const treeNode = new TreeNode<BarrelData>({\n name: rootFolder || '',\n path: rootFolder || '',\n file: undefined,\n })\n\n for (const file of filteredFiles) {\n const filePath = normalizedPaths.get(file)!\n const relPath = filePath.slice(rootPrefix.length)\n const parts = relPath.split('/')\n\n let current = treeNode\n let currentPath = rootFolder\n\n for (const [index, part] of parts.entries()) {\n const isLast = index === parts.length - 1\n currentPath += (currentPath.endsWith('/') ? '' : '/') + part\n\n let next = current.getChildByName(part)\n\n if (!next) {\n next = current.addChild({\n name: part,\n path: currentPath,\n file: isLast ? file : undefined,\n })\n }\n\n current = next\n }\n }\n\n return treeNode\n }\n}\n","import type { Plugin, UserPlugin } from './types.ts'\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 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 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 { resolve } from 'node:path'\nimport fs from 'fs-extra'\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 fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n}\n\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 fs.removeSync(options.clean.path)\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 }\n },\n})\n","import { spawn } from 'node:child_process'\n\nconst spawnBin = (bin: string, args: string[]): Promise<boolean> => {\n return new Promise((resolve) => {\n const process = spawn(bin, args, {\n detached: true,\n shell: false,\n windowsHide: true,\n })\n\n process.on('close', (code) => {\n resolve(!code)\n })\n })\n}\n\ntype Options = {\n app?: string\n}\n\nexport async function open(path: string, options?: Options): Promise<boolean> {\n const app = options?.app\n\n if (process.platform === 'win32') {\n return spawnBin('cmd.exe', ['/c', 'start', app || '', path.replace(/[&^]/g, '^$&')])\n }\n\n if (process.platform === 'linux') {\n return spawnBin(app || 'xdg-open', [path])\n }\n if (process.platform === 'darwin') {\n return spawnBin('open', app ? ['-a', app, path] : [path])\n }\n\n throw new Error(`Unsupported platform, could not open \"${path}\"`)\n}\n","import http from 'node:http'\nimport type { AddressInfo } from 'node:net'\nimport path from 'node:path'\nimport handler from 'serve-handler'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { open } from '../utils/open.ts'\nimport { type Graph, TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n root: string\n /**\n * @default false\n */\n open?: boolean\n}\n\ntype GetGraphOptions = {\n files: KubbFile.File[]\n root: string\n}\n\nexport function getGraph({ files, root }: GetGraphOptions): Graph | undefined {\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return undefined\n }\n\n return TreeNode.toGraph(treeNode)\n}\nconst html = `\n <!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>File Graph</title>\n <script type=\"module\">\n import { Network } from 'https://cdn.jsdelivr.net/npm/vis-network/standalone/esm/vis-network.min.js'\n\n async function main() {\n const res = await fetch('./graph.json')\n const { nodes, edges } = await res.json()\n const container = document.getElementById('graph')\n\n const network = new Network(\n container,\n { nodes, edges },\n {\n layout: { hierarchical: { direction: 'UD', sortMethod: 'directed' } },\n nodes: { shape: 'box', font: { face: 'monospace' } },\n edges: { arrows: 'to' },\n physics: false,\n },\n )\n }\n\n main()\n </script>\n <style>\n html, body, #graph { height: 100%; margin: 0; }\n </style>\n </head>\n <body>\n <div id=\"graph\"></div>\n </body>\n</html>\n`\n\nasync function serve(root: string) {\n const server = http.createServer((req, res) => {\n return handler(req, res, {\n public: root,\n cleanUrls: true,\n })\n })\n\n server.listen(0, async () => {\n const { port } = server.address() as AddressInfo\n console.log(`Running on http://localhost:${port}/graph.html`)\n\n await open(`http://localhost:${port}/graph.html`)\n })\n}\n\nexport const graphPlugin = definePlugin<Options>({\n name: 'graph',\n install(ctx, options) {\n if (!options) {\n throw new Error('Graph plugin requires options.root and options.mode')\n }\n\n ctx.on('files:writing:start', async ({ files }) => {\n const root = options.root\n\n const graph = getGraph({ files, root })\n\n if (!graph) {\n return undefined\n }\n\n const graphFile = createFile({\n baseName: 'graph.json',\n path: path.join(root, 'graph.json'),\n sources: [\n {\n name: 'graph',\n value: JSON.stringify(graph, null, 2),\n },\n ],\n })\n\n const graphHtmlFile = createFile({\n baseName: 'graph.html',\n path: path.join(root, 'graph.html'),\n sources: [\n {\n name: 'graph',\n value: html,\n },\n ],\n })\n\n await ctx.addFile(graphFile, graphHtmlFile)\n\n if (options.open) {\n await serve(root)\n }\n })\n },\n})\n","import http from 'node:http'\nimport type { AddressInfo } from 'node:net'\nimport { relative } from 'node:path'\nimport { Presets, SingleBar } from 'cli-progress'\nimport { createConsola, type LogLevel } from 'consola'\nimport { WebSocket, WebSocketServer } from 'ws'\nimport type { FabricEvents } from '../Fabric.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Broadcast = <T = unknown>(event: keyof FabricEvents | string, payload: T) => void\ntype WebSocketOptions = {\n /**\n * Hostname to bind the websocket server to.\n * @default '127.0.0.1'\n */\n host?: string\n /**\n * Port to bind the websocket server to.\n * @default 0 (random available port)\n */\n port?: number\n}\n\ntype Options = {\n /**\n * Explicit consola log level.\n */\n level?: LogLevel\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n /**\n * Toggle or configure the websocket broadcast server.\n * When `true`, a websocket server is started on an ephemeral port.\n * When `false`, websocket support is disabled.\n * When providing an object, the server uses the supplied host and port.\n * @default true\n */\n websocket?: boolean | WebSocketOptions\n}\n\nfunction normalizeAddress(address: AddressInfo): {\n host: string\n port: number\n} {\n const host = address.address === '::' ? '127.0.0.1' : address.address\n\n return { host, port: address.port }\n}\n\nfunction serializeFile(file: KubbFile.File | KubbFile.ResolvedFile) {\n return {\n path: file.path,\n baseName: file.baseName,\n name: 'name' in file ? file.name : undefined,\n extname: 'extname' in file ? file.extname : undefined,\n }\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst defaultTag = 'Fabric'\n\nconst createProgressBar = () =>\n new SingleBar(\n {\n format: '{bar} {percentage}% | {value}/{total} | {message}',\n barCompleteChar: '█',\n barIncompleteChar: '░',\n hideCursor: true,\n clearOnComplete: true,\n },\n Presets.shades_grey,\n )\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { level, websocket = true, progress = true } = options\n\n const logger = createConsola(level !== undefined ? { level } : {}).withTag(defaultTag)\n\n const progressBar = progress ? createProgressBar() : undefined\n\n let server: http.Server | undefined\n let wss: WebSocketServer | undefined\n\n const broadcast: Broadcast = (event, payload) => {\n if (!wss) {\n return\n }\n\n const message = JSON.stringify({ event, payload })\n\n for (const client of wss.clients) {\n if (client.readyState === WebSocket.OPEN) {\n client.send(message)\n }\n }\n }\n\n if (websocket) {\n const { host = '127.0.0.1', port = 0 } = typeof websocket === 'boolean' ? {} : websocket\n\n server = http.createServer()\n wss = new WebSocketServer({ server })\n\n server.listen(port, host, () => {\n const addressInfo = server?.address()\n\n if (addressInfo && typeof addressInfo === 'object') {\n const { host: resolvedHost, port: resolvedPort } = normalizeAddress(addressInfo)\n const url = `ws://${resolvedHost}:${resolvedPort}`\n\n logger.info(`Logger websocket listening on ${url}`)\n broadcast('websocket:ready', { url })\n }\n })\n\n wss.on('connection', (socket) => {\n logger.info('Logger websocket client connected')\n socket.send(\n JSON.stringify({\n event: 'welcome',\n payload: {\n message: 'Connected to Fabric log stream',\n timestamp: Date.now(),\n },\n }),\n )\n })\n\n wss.on('error', (error) => {\n logger.error('Logger websocket error', error)\n })\n }\n\n const formatPath = (path: string) => relative(process.cwd(), path)\n\n ctx.on('lifecycle:start', async () => {\n logger.start('Starting Fabric run')\n broadcast('lifecycle:start', { timestamp: Date.now() })\n })\n\n ctx.on('lifecycle:render', async () => {\n logger.info('Rendering application graph')\n broadcast('lifecycle:render', { timestamp: Date.now() })\n })\n\n ctx.on('files:added', async ({ files }) => {\n if (!files.length) {\n return\n }\n\n logger.info(`Queued ${pluralize('file', files.length)}`)\n broadcast('files:added', {\n files: files.map(serializeFile),\n })\n })\n\n ctx.on('file:resolve:path', async ({ file }) => {\n logger.info(`Resolving path for ${formatPath(file.path)}`)\n broadcast('file:resolve:path', { file: serializeFile(file) })\n })\n\n ctx.on('file:resolve:name', async ({ file }) => {\n logger.info(`Resolving name for ${formatPath(file.path)}`)\n broadcast('file:resolve:name', { file: serializeFile(file) })\n })\n\n ctx.on('files:processing:start', async ({ files }) => {\n logger.start(`Processing ${pluralize('file', files.length)}`)\n broadcast('files:processing:start', {\n total: files.length,\n timestamp: Date.now(),\n })\n\n if (progressBar) {\n logger.pauseLogs()\n progressBar.start(files.length, 0, { message: 'Starting...' })\n }\n })\n\n ctx.on('file:processing:start', async ({ file, index, total }) => {\n logger.info(`Processing [${index + 1}/${total}] ${formatPath(file.path)}`)\n broadcast('file:processing:start', {\n index,\n total,\n file: serializeFile(file),\n })\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n\n logger.info(`Progress ${formattedPercentage}% (${processed}/${total}) → ${formatPath(file.path)}`)\n broadcast('file:processing:update', {\n processed,\n total,\n percentage,\n file: serializeFile(file),\n })\n\n if (progressBar) {\n progressBar.increment(1, {\n message: `Writing ${formatPath(file.path)}`,\n })\n }\n })\n\n ctx.on('file:processing:end', async ({ file, index, total }) => {\n logger.success(`Finished [${index + 1}/${total}] ${formatPath(file.path)}`)\n broadcast('file:processing:end', {\n index,\n total,\n file: serializeFile(file),\n })\n })\n\n ctx.on('files:writing:start', async ({ files }) => {\n logger.start(`Writing ${pluralize('file', files.length)} to disk`)\n broadcast('files:writing:start', {\n files: files.map(serializeFile),\n })\n })\n\n ctx.on('files:writing:end', async ({ files }) => {\n logger.success(`Written ${pluralize('file', files.length)} to disk`)\n broadcast('files:writing:end', {\n files: files.map(serializeFile),\n })\n })\n\n ctx.on('files:processing:end', async ({ files }) => {\n logger.success(`Processed ${pluralize('file', files.length)}`)\n broadcast('files:processing:end', {\n total: files.length,\n timestamp: Date.now(),\n })\n\n if (progressBar) {\n progressBar.update(files.length, { message: 'Done ✅' })\n progressBar.stop()\n\n logger.resumeLogs()\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n logger.success('Fabric run completed')\n broadcast('lifecycle:end', { timestamp: Date.now() })\n\n if (progressBar) {\n progressBar.stop()\n logger.resumeLogs()\n }\n\n const closures: Array<Promise<void>> = []\n\n if (wss) {\n const wsServer = wss\n\n closures.push(\n new Promise((resolve) => {\n for (const client of wsServer.clients) {\n client.close()\n }\n wsServer.close(() => resolve())\n }),\n )\n }\n\n if (server) {\n const httpServer = server\n\n closures.push(\n new Promise((resolve) => {\n httpServer.close(() => resolve())\n }),\n )\n }\n\n if (closures.length) {\n await Promise.allSettled(closures)\n logger.info('Logger websocket closed')\n }\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,IAAa,WAAb,MAAa,SAA0B;CAOrC,YAAY,MAAa,QAA0B;+CANnD;+CACA;+CACA,YAAmC,EAAE;wFACtB,IAAI,KAA8B;;AAI/C,OAAK,OAAO;AACZ,OAAK,SAAS;;CAGhB,SAAS,MAA8B;EACrC,MAAM,QAAQ,IAAI,SAAS,MAAM,KAAK;AACtC,OAAK,SAAS,KAAK,MAAM;AAEzB,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,KACzD,kEAAiB,CAAC,IAAK,KAA0B,MAAM,MAAM;AAE/D,qEAAqB,OAAS;AAC9B,SAAO;;CAGT,eAAe,MAA2C;AACxD,qEAAO,KAAiB,CAAC,IAAI,KAAK;;CAGpC,IAAI,SAAiC;AACnC,mEAAI,KAAkB,CAAE,qEAAO,KAAkB;AACjD,MAAI,KAAK,SAAS,WAAW,EAAG,QAAO,CAAC,KAAK;EAE7C,MAAMA,SAAiC,EAAE;EACzC,MAAMC,QAAgC,CAAC,GAAG,KAAK,SAAS;EACxD,MAAM,0BAAU,IAAI,KAAsB;AAE1C,SAAO,MAAM,SAAS,GAAG;GACvB,MAAM,OAAO,MAAM,KAAK;AACxB,OAAI,QAAQ,IAAI,KAAK,CACnB;AAEF,WAAQ,IAAI,KAA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{ id: string; label: string }>","edges: Array<{ from: string; to: string }>","stack: Array<TreeNode<BarrelData>>","filteredFiles: Array<KubbFile.File>","indexableSources: Array<KubbFile.Source>","path","createFile","getRelativePath","barrelFiles: Array<KubbFile.ResolvedFile>","exports: Array<KubbFile.Export>","path","fs","path","http","createFile","path","SingleBar","Presets","server: http.Server | undefined","wss: WebSocketServer | undefined","broadcast: Broadcast","WebSocket","http","WebSocketServer","path","closures: Array<Promise<void>>","resolve"],"sources":["../src/utils/TreeNode.ts","../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/utils/open.ts","../src/plugins/graphPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type * as KubbFile from '../KubbFile.ts'\n\ntype BarrelData = {\n file?: KubbFile.File\n path: string\n name: string\n}\n\nexport type Graph = {\n nodes: Array<{ id: string; label: string }>\n edges: Array<{ from: string; to: string }>\n}\n\nexport class TreeNode<TData = unknown> {\n data: TData\n parent?: TreeNode<TData>\n children: Array<TreeNode<TData>> = []\n #childrenMap = new Map<string, TreeNode<TData>>()\n #cachedLeaves?: Array<TreeNode<TData>>\n\n constructor(data: TData, parent?: TreeNode<TData>) {\n this.data = data\n this.parent = parent\n }\n\n addChild(data: TData): TreeNode<TData> {\n const child = new TreeNode(data, this)\n this.children.push(child)\n // Update Map if data has a name property (for BarrelData)\n if (typeof data === 'object' && data !== null && 'name' in data) {\n this.#childrenMap.set((data as { name: string }).name, child)\n }\n this.#cachedLeaves = undefined // invalidate cached leaves\n return child\n }\n\n getChildByName(name: string): TreeNode<TData> | undefined {\n return this.#childrenMap.get(name)\n }\n\n get leaves(): Array<TreeNode<TData>> {\n if (this.#cachedLeaves) return this.#cachedLeaves\n if (this.children.length === 0) return [this]\n\n const result: Array<TreeNode<TData>> = []\n const stack: Array<TreeNode<TData>> = [...this.children]\n const visited = new Set<TreeNode<TData>>()\n\n while (stack.length > 0) {\n const node = stack.pop()!\n if (visited.has(node)) {\n continue\n }\n visited.add(node)\n\n if (node.children.length > 0) {\n stack.push(...node.children)\n } else {\n result.push(node)\n }\n }\n\n this.#cachedLeaves = result\n return result\n }\n\n forEach(callback: (node: TreeNode<TData>) => void): this {\n const stack: Array<TreeNode<TData>> = [this]\n\n for (let i = 0; i < stack.length; i++) {\n const node = stack[i]!\n callback(node)\n\n if (node.children.length > 0) {\n stack.push(...node.children)\n }\n }\n\n return this\n }\n\n findDeep(predicate: (node: TreeNode<TData>) => boolean): TreeNode<TData> | undefined {\n for (const leaf of this.leaves) {\n if (predicate(leaf)) return leaf\n }\n return undefined\n }\n\n static toGraph(root: TreeNode<BarrelData>): Graph {\n const nodes: Array<{ id: string; label: string }> = []\n const edges: Array<{ from: string; to: string }> = []\n\n const stack: Array<TreeNode<BarrelData>> = [root]\n\n for (let i = 0; i < stack.length; i++) {\n const node = stack[i]!\n\n nodes.push({\n id: node.data.path,\n label: node.data.name,\n })\n\n const children = node.children\n if (children.length > 0) {\n for (let j = 0, len = children.length; j < len; j++) {\n const child = children[j]!\n edges.push({\n from: node.data.path,\n to: child.data.path,\n })\n stack.push(child)\n }\n }\n }\n\n return { nodes, edges }\n }\n\n static fromFiles(files: Array<KubbFile.File>, rootFolder = ''): TreeNode<BarrelData> | null {\n const normalizePath = (p: string): string => p.replace(/\\\\/g, '/')\n const normalizedRoot = normalizePath(rootFolder)\n const rootPrefix = normalizedRoot.endsWith('/') ? normalizedRoot : `${normalizedRoot}/`\n\n const normalizedPaths = new Map<KubbFile.File, string>()\n const filteredFiles: Array<KubbFile.File> = []\n for (const file of files) {\n const filePath = normalizedPaths.get(file) ?? normalizePath(file.path)\n normalizedPaths.set(file, filePath)\n if (!filePath.endsWith('.json') && (!rootFolder || filePath.startsWith(rootPrefix))) {\n filteredFiles.push(file)\n }\n }\n\n if (filteredFiles.length === 0) {\n return null\n }\n\n const treeNode = new TreeNode<BarrelData>({\n name: rootFolder || '',\n path: rootFolder || '',\n file: undefined,\n })\n\n for (const file of filteredFiles) {\n const filePath = normalizedPaths.get(file)!\n const relPath = filePath.slice(rootPrefix.length)\n const parts = relPath.split('/')\n\n let current = treeNode\n let currentPath = rootFolder\n\n for (const [index, part] of parts.entries()) {\n const isLast = index === parts.length - 1\n currentPath += (currentPath.endsWith('/') ? '' : '/') + part\n\n let next = current.getChildByName(part)\n\n if (!next) {\n next = current.addChild({\n name: part,\n path: currentPath,\n file: isLast ? file : undefined,\n })\n }\n\n current = next\n }\n }\n\n return treeNode\n }\n}\n","import type { Plugin, UserPlugin } from './types.ts'\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 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 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 { resolve } from 'node:path'\nimport fs from 'fs-extra'\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 fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n}\n\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 fs.removeSync(options.clean.path)\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 }\n },\n})\n","import { spawn } from 'node:child_process'\n\nconst spawnBin = (bin: string, args: string[]): Promise<boolean> => {\n return new Promise((resolve) => {\n const process = spawn(bin, args, {\n detached: true,\n shell: false,\n windowsHide: true,\n })\n\n process.on('close', (code) => {\n resolve(!code)\n })\n })\n}\n\ntype Options = {\n app?: string\n}\n\nexport async function open(path: string, options?: Options): Promise<boolean> {\n const app = options?.app\n\n if (process.platform === 'win32') {\n return spawnBin('cmd.exe', ['/c', 'start', app || '', path.replace(/[&^]/g, '^$&')])\n }\n\n if (process.platform === 'linux') {\n return spawnBin(app || 'xdg-open', [path])\n }\n if (process.platform === 'darwin') {\n return spawnBin('open', app ? ['-a', app, path] : [path])\n }\n\n throw new Error(`Unsupported platform, could not open \"${path}\"`)\n}\n","import http from 'node:http'\nimport type { AddressInfo } from 'node:net'\nimport path from 'node:path'\nimport handler from 'serve-handler'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { open } from '../utils/open.ts'\nimport { type Graph, TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n root: string\n /**\n * @default false\n */\n open?: boolean\n}\n\ntype GetGraphOptions = {\n files: KubbFile.File[]\n root: string\n}\n\nexport function getGraph({ files, root }: GetGraphOptions): Graph | undefined {\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return undefined\n }\n\n return TreeNode.toGraph(treeNode)\n}\nconst html = `\n <!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>File Graph</title>\n <script type=\"module\">\n import { Network } from 'https://cdn.jsdelivr.net/npm/vis-network/standalone/esm/vis-network.min.js'\n\n async function main() {\n const res = await fetch('./graph.json')\n const { nodes, edges } = await res.json()\n const container = document.getElementById('graph')\n\n const network = new Network(\n container,\n { nodes, edges },\n {\n layout: { hierarchical: { direction: 'UD', sortMethod: 'directed' } },\n nodes: { shape: 'box', font: { face: 'monospace' } },\n edges: { arrows: 'to' },\n physics: false,\n },\n )\n }\n\n main()\n </script>\n <style>\n html, body, #graph { height: 100%; margin: 0; }\n </style>\n </head>\n <body>\n <div id=\"graph\"></div>\n </body>\n</html>\n`\n\nasync function serve(root: string) {\n const server = http.createServer((req, res) => {\n return handler(req, res, {\n public: root,\n cleanUrls: true,\n })\n })\n\n server.listen(0, async () => {\n const { port } = server.address() as AddressInfo\n console.log(`Running on http://localhost:${port}/graph.html`)\n\n await open(`http://localhost:${port}/graph.html`)\n })\n}\n\nexport const graphPlugin = definePlugin<Options>({\n name: 'graph',\n install(ctx, options) {\n if (!options) {\n throw new Error('Graph plugin requires options.root and options.mode')\n }\n\n ctx.on('files:writing:start', async (files) => {\n const root = options.root\n\n const graph = getGraph({ files, root })\n\n if (!graph) {\n return undefined\n }\n\n const graphFile = createFile({\n baseName: 'graph.json',\n path: path.join(root, 'graph.json'),\n sources: [\n {\n name: 'graph',\n value: JSON.stringify(graph, null, 2),\n },\n ],\n })\n\n const graphHtmlFile = createFile({\n baseName: 'graph.html',\n path: path.join(root, 'graph.html'),\n sources: [\n {\n name: 'graph',\n value: html,\n },\n ],\n })\n\n await ctx.addFile(graphFile, graphHtmlFile)\n\n if (options.open) {\n await serve(root)\n }\n })\n },\n})\n","import http from 'node:http'\nimport type { AddressInfo } from 'node:net'\nimport { relative } from 'node:path'\nimport { Presets, SingleBar } from 'cli-progress'\nimport { createConsola, type LogLevel } from 'consola'\nimport { WebSocket, WebSocketServer } from 'ws'\nimport type { FabricEvents } from '../Fabric.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Broadcast = <T = unknown>(event: keyof FabricEvents | string, payload: T) => void\ntype WebSocketOptions = {\n /**\n * Hostname to bind the websocket server to.\n * @default '127.0.0.1'\n */\n host?: string\n /**\n * Port to bind the websocket server to.\n * @default 0 (random available port)\n */\n port?: number\n}\n\ntype Options = {\n /**\n * Explicit consola log level.\n */\n level?: LogLevel\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n /**\n * Toggle or configure the websocket broadcast server.\n * When `true`, a websocket server is started on an ephemeral port.\n * When `false`, websocket support is disabled.\n * When providing an object, the server uses the supplied host and port.\n * @default true\n */\n websocket?: boolean | WebSocketOptions\n}\n\nfunction normalizeAddress(address: AddressInfo): {\n host: string\n port: number\n} {\n const host = address.address === '::' ? '127.0.0.1' : address.address\n\n return { host, port: address.port }\n}\n\nfunction serializeFile(file: KubbFile.File | KubbFile.ResolvedFile) {\n return {\n path: file.path,\n baseName: file.baseName,\n name: 'name' in file ? file.name : undefined,\n extname: 'extname' in file ? file.extname : undefined,\n }\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst defaultTag = 'Fabric'\n\nconst createProgressBar = () =>\n new SingleBar(\n {\n format: '{bar} {percentage}% | {value}/{total} | {message}',\n barCompleteChar: '█',\n barIncompleteChar: '░',\n hideCursor: true,\n clearOnComplete: true,\n },\n Presets.shades_grey,\n )\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { level, websocket = true, progress = true } = options\n\n const logger = createConsola(level !== undefined ? { level } : {}).withTag(defaultTag)\n\n const progressBar = progress ? createProgressBar() : undefined\n\n let server: http.Server | undefined\n let wss: WebSocketServer | undefined\n\n const broadcast: Broadcast = (event, payload) => {\n if (!wss) {\n return\n }\n\n const message = JSON.stringify({ event, payload })\n\n for (const client of wss.clients) {\n if (client.readyState === WebSocket.OPEN) {\n client.send(message)\n }\n }\n }\n\n if (websocket) {\n const { host = '127.0.0.1', port = 0 } = typeof websocket === 'boolean' ? {} : websocket\n\n server = http.createServer()\n wss = new WebSocketServer({ server })\n\n server.listen(port, host, () => {\n const addressInfo = server?.address()\n\n if (addressInfo && typeof addressInfo === 'object') {\n const { host: resolvedHost, port: resolvedPort } = normalizeAddress(addressInfo)\n const url = `ws://${resolvedHost}:${resolvedPort}`\n\n logger.info(`Logger websocket listening on ${url}`)\n broadcast('websocket:ready', { url })\n }\n })\n\n wss.on('connection', (socket) => {\n logger.info('Logger websocket client connected')\n socket.send(\n JSON.stringify({\n event: 'welcome',\n payload: {\n message: 'Connected to Fabric log stream',\n timestamp: Date.now(),\n },\n }),\n )\n })\n\n wss.on('error', (error) => {\n logger.error('Logger websocket error', error)\n })\n }\n\n const formatPath = (path: string) => relative(process.cwd(), path)\n\n ctx.on('lifecycle:start', async () => {\n logger.start('Starting Fabric run')\n broadcast('lifecycle:start', { timestamp: Date.now() })\n })\n\n ctx.on('lifecycle:render', async () => {\n logger.info('Rendering application graph')\n broadcast('lifecycle:render', { timestamp: Date.now() })\n })\n\n ctx.on('files:added', async (files) => {\n if (!files.length) {\n return\n }\n\n logger.info(`Queued ${pluralize('file', files.length)}`)\n broadcast('files:added', {\n files: files.map(serializeFile),\n })\n })\n\n ctx.on('file:resolve:path', async (file) => {\n logger.info(`Resolving path for ${formatPath(file.path)}`)\n broadcast('file:resolve:path', { file: serializeFile(file) })\n })\n\n ctx.on('file:resolve:name', async (file) => {\n logger.info(`Resolving name for ${formatPath(file.path)}`)\n broadcast('file:resolve:name', { file: serializeFile(file) })\n })\n\n ctx.on('files:processing:start', async (files) => {\n logger.start(`Processing ${pluralize('file', files.length)}`)\n broadcast('files:processing:start', {\n total: files.length,\n timestamp: Date.now(),\n })\n\n if (progressBar) {\n logger.pauseLogs()\n progressBar.start(files.length, 0, { message: 'Starting...' })\n }\n })\n\n ctx.on('file:processing:start', async (file, index, total) => {\n logger.info(`Processing [${index + 1}/${total}] ${formatPath(file.path)}`)\n broadcast('file:processing:start', {\n index,\n total,\n file: serializeFile(file),\n })\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n\n logger.info(`Progress ${formattedPercentage}% (${processed}/${total}) → ${formatPath(file.path)}`)\n broadcast('file:processing:update', {\n processed,\n total,\n percentage,\n file: serializeFile(file),\n })\n\n if (progressBar) {\n progressBar.increment(1, {\n message: `Writing ${formatPath(file.path)}`,\n })\n }\n })\n\n ctx.on('file:processing:end', async (file, index, total) => {\n logger.success(`Finished [${index + 1}/${total}] ${formatPath(file.path)}`)\n broadcast('file:processing:end', {\n index,\n total,\n file: serializeFile(file),\n })\n })\n\n ctx.on('files:writing:start', async (files) => {\n logger.start(`Writing ${pluralize('file', files.length)} to disk`)\n broadcast('files:writing:start', {\n files: files.map(serializeFile),\n })\n })\n\n ctx.on('files:writing:end', async (files) => {\n logger.success(`Written ${pluralize('file', files.length)} to disk`)\n broadcast('files:writing:end', {\n files: files.map(serializeFile),\n })\n })\n\n ctx.on('files:processing:end', async (files) => {\n logger.success(`Processed ${pluralize('file', files.length)}`)\n broadcast('files:processing:end', {\n total: files.length,\n timestamp: Date.now(),\n })\n\n if (progressBar) {\n progressBar.update(files.length, { message: 'Done ✅' })\n progressBar.stop()\n\n logger.resumeLogs()\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n logger.success('Fabric run completed')\n broadcast('lifecycle:end', { timestamp: Date.now() })\n\n if (progressBar) {\n progressBar.stop()\n logger.resumeLogs()\n }\n\n const closures: Array<Promise<void>> = []\n\n if (wss) {\n const wsServer = wss\n\n closures.push(\n new Promise((resolve) => {\n for (const client of wsServer.clients) {\n client.close()\n }\n wsServer.close(() => resolve())\n }),\n )\n }\n\n if (server) {\n const httpServer = server\n\n closures.push(\n new Promise((resolve) => {\n httpServer.close(() => resolve())\n }),\n )\n }\n\n if (closures.length) {\n await Promise.allSettled(closures)\n logger.info('Logger websocket closed')\n }\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,IAAa,WAAb,MAAa,SAA0B;CAOrC,YAAY,MAAa,QAA0B;+CANnD;+CACA;+CACA,YAAmC,EAAE;wFACtB,IAAI,KAA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,aAAU,iBAAiB,EAAE,WAAW,KAAK,KAAK,EAAE,CAAC;AAErD,OAAI,aAAa;AACf,gBAAY,MAAM;AAClB,WAAO,YAAY;;GAGrB,MAAMC,WAAiC,EAAE;AAEzC,OAAI,KAAK;IACP,MAAM,WAAW;AAEjB,aAAS,KACP,IAAI,SAAS,cAAY;AACvB,UAAK,MAAM,UAAU,SAAS,QAC5B,QAAO,OAAO;AAEhB,cAAS,YAAYC,WAAS,CAAC;MAC/B,CACH;;AAGH,OAAI,QAAQ;IACV,MAAM,aAAa;AAEnB,aAAS,KACP,IAAI,SAAS,cAAY;AACvB,gBAAW,YAAYA,WAAS,CAAC;MACjC,CACH;;AAGH,OAAI,SAAS,QAAQ;AACnB,UAAM,QAAQ,WAAW,SAAS;AAClC,WAAO,KAAK,0BAA0B;;IAExC;;CAEL,CAAC"}
|
package/dist/plugins.d.cts
CHANGED
package/dist/plugins.d.ts
CHANGED
package/dist/plugins.js
CHANGED
|
@@ -207,7 +207,7 @@ const barrelPlugin = definePlugin({
|
|
|
207
207
|
install(ctx, options) {
|
|
208
208
|
if (!options) throw new Error("Barrel plugin requires options.root and options.mode");
|
|
209
209
|
if (!options.mode) return;
|
|
210
|
-
ctx.on("files:writing:start", async (
|
|
210
|
+
ctx.on("files:writing:start", async (files) => {
|
|
211
211
|
const root = options.root;
|
|
212
212
|
const barrelFiles = getBarrelFiles({
|
|
213
213
|
files,
|
|
@@ -396,7 +396,7 @@ const graphPlugin = definePlugin({
|
|
|
396
396
|
name: "graph",
|
|
397
397
|
install(ctx, options) {
|
|
398
398
|
if (!options) throw new Error("Graph plugin requires options.root and options.mode");
|
|
399
|
-
ctx.on("files:writing:start", async (
|
|
399
|
+
ctx.on("files:writing:start", async (files) => {
|
|
400
400
|
const root = options.root;
|
|
401
401
|
const graph = getGraph({
|
|
402
402
|
files,
|
|
@@ -504,20 +504,20 @@ const loggerPlugin = definePlugin({
|
|
|
504
504
|
logger.info("Rendering application graph");
|
|
505
505
|
broadcast("lifecycle:render", { timestamp: Date.now() });
|
|
506
506
|
});
|
|
507
|
-
ctx.on("files:added", async (
|
|
507
|
+
ctx.on("files:added", async (files) => {
|
|
508
508
|
if (!files.length) return;
|
|
509
509
|
logger.info(`Queued ${pluralize("file", files.length)}`);
|
|
510
510
|
broadcast("files:added", { files: files.map(serializeFile) });
|
|
511
511
|
});
|
|
512
|
-
ctx.on("file:resolve:path", async (
|
|
512
|
+
ctx.on("file:resolve:path", async (file) => {
|
|
513
513
|
logger.info(`Resolving path for ${formatPath(file.path)}`);
|
|
514
514
|
broadcast("file:resolve:path", { file: serializeFile(file) });
|
|
515
515
|
});
|
|
516
|
-
ctx.on("file:resolve:name", async (
|
|
516
|
+
ctx.on("file:resolve:name", async (file) => {
|
|
517
517
|
logger.info(`Resolving name for ${formatPath(file.path)}`);
|
|
518
518
|
broadcast("file:resolve:name", { file: serializeFile(file) });
|
|
519
519
|
});
|
|
520
|
-
ctx.on("files:processing:start", async (
|
|
520
|
+
ctx.on("files:processing:start", async (files) => {
|
|
521
521
|
logger.start(`Processing ${pluralize("file", files.length)}`);
|
|
522
522
|
broadcast("files:processing:start", {
|
|
523
523
|
total: files.length,
|
|
@@ -528,7 +528,7 @@ const loggerPlugin = definePlugin({
|
|
|
528
528
|
progressBar.start(files.length, 0, { message: "Starting..." });
|
|
529
529
|
}
|
|
530
530
|
});
|
|
531
|
-
ctx.on("file:processing:start", async (
|
|
531
|
+
ctx.on("file:processing:start", async (file, index, total) => {
|
|
532
532
|
logger.info(`Processing [${index + 1}/${total}] ${formatPath(file.path)}`);
|
|
533
533
|
broadcast("file:processing:start", {
|
|
534
534
|
index,
|
|
@@ -547,7 +547,7 @@ const loggerPlugin = definePlugin({
|
|
|
547
547
|
});
|
|
548
548
|
if (progressBar) progressBar.increment(1, { message: `Writing ${formatPath(file.path)}` });
|
|
549
549
|
});
|
|
550
|
-
ctx.on("file:processing:end", async (
|
|
550
|
+
ctx.on("file:processing:end", async (file, index, total) => {
|
|
551
551
|
logger.success(`Finished [${index + 1}/${total}] ${formatPath(file.path)}`);
|
|
552
552
|
broadcast("file:processing:end", {
|
|
553
553
|
index,
|
|
@@ -555,15 +555,15 @@ const loggerPlugin = definePlugin({
|
|
|
555
555
|
file: serializeFile(file)
|
|
556
556
|
});
|
|
557
557
|
});
|
|
558
|
-
ctx.on("files:writing:start", async (
|
|
558
|
+
ctx.on("files:writing:start", async (files) => {
|
|
559
559
|
logger.start(`Writing ${pluralize("file", files.length)} to disk`);
|
|
560
560
|
broadcast("files:writing:start", { files: files.map(serializeFile) });
|
|
561
561
|
});
|
|
562
|
-
ctx.on("files:writing:end", async (
|
|
562
|
+
ctx.on("files:writing:end", async (files) => {
|
|
563
563
|
logger.success(`Written ${pluralize("file", files.length)} to disk`);
|
|
564
564
|
broadcast("files:writing:end", { files: files.map(serializeFile) });
|
|
565
565
|
});
|
|
566
|
-
ctx.on("files:processing:end", async (
|
|
566
|
+
ctx.on("files:processing:end", async (files) => {
|
|
567
567
|
logger.success(`Processed ${pluralize("file", files.length)}`);
|
|
568
568
|
broadcast("files:processing:end", {
|
|
569
569
|
total: files.length,
|