@kubb/fabric-core 0.11.7 → 0.12.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-BoTE1-WX.d.cts → Fabric-BbVC650D.d.cts} +86 -15
- package/dist/{Fabric-CWquRFa2.d.ts → Fabric-eh92yS1R.d.ts} +86 -15
- package/dist/Root-BT59jU0W.js +931 -0
- package/dist/Root-BT59jU0W.js.map +1 -0
- package/dist/Root-SC_lWG_q.cjs +1057 -0
- package/dist/Root-SC_lWG_q.cjs.map +1 -0
- package/dist/{defaultParser-CFIT3sEE.cjs → defaultParser-2ym3KiZd.cjs} +3 -4
- package/dist/{defaultParser-CFIT3sEE.cjs.map → defaultParser-2ym3KiZd.cjs.map} +1 -1
- package/dist/{defaultParser-DZ2kzujH.js → defaultParser-DDFR9BTS.js} +2 -2
- package/dist/{defaultParser-DZ2kzujH.js.map → defaultParser-DDFR9BTS.js.map} +1 -1
- package/dist/{getRelativePath-y7WcYR5C.js → getRelativePath-COUEoqbz.js} +11 -2
- package/dist/getRelativePath-COUEoqbz.js.map +1 -0
- package/dist/{getRelativePath-BllDunh0.cjs → getRelativePath-jYLCpluV.cjs} +16 -1
- package/dist/getRelativePath-jYLCpluV.cjs.map +1 -0
- package/dist/index.cjs +129 -448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -90
- package/dist/index.d.ts +54 -90
- package/dist/index.js +92 -416
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.cjs +7 -107
- package/dist/parsers/typescript.d.cts +1 -1
- package/dist/parsers/typescript.d.ts +1 -1
- package/dist/parsers/typescript.js +2 -101
- package/dist/parsers.cjs +7 -8
- package/dist/parsers.cjs.map +1 -1
- package/dist/parsers.d.cts +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/parsers.js +3 -3
- package/dist/plugins.cjs +103 -9
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +32 -9
- package/dist/plugins.d.ts +32 -9
- package/dist/plugins.js +96 -3
- package/dist/plugins.js.map +1 -1
- package/dist/types-BI7rICUP.d.cts +31 -0
- package/dist/types-DpITKjSb.d.ts +32 -0
- package/dist/types.cjs +6 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +4 -3
- package/dist/types.d.ts +4 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/typescriptParser-DyosyI_A.js +101 -0
- package/dist/typescriptParser-DyosyI_A.js.map +1 -0
- package/dist/typescriptParser-qjzb2pIh.cjs +137 -0
- package/dist/typescriptParser-qjzb2pIh.cjs.map +1 -0
- package/dist/{TreeNode-DomNP5og.d.cts → useNodeTree-CmXKaRqq.d.cts} +10 -3
- package/dist/{TreeNode-C1VnIF0o.d.ts → useNodeTree-DUdlgys5.d.ts} +10 -3
- package/package.json +3 -2
- package/src/Fabric.ts +13 -5
- package/src/KubbFile.ts +3 -11
- package/src/components/App.ts +6 -5
- package/src/components/Br.ts +11 -0
- package/src/components/Const.ts +6 -5
- package/src/components/Dedent.ts +10 -0
- package/src/components/File.ts +21 -16
- package/src/components/Function.ts +17 -13
- package/src/components/Indent.ts +7 -0
- package/src/components/Root.ts +6 -5
- package/src/components/Type.ts +6 -5
- package/src/components/__snapshots__/arrow_function_with_generics.ts +3 -3
- package/src/components/__snapshots__/async_arrow_function.ts +3 -3
- package/src/components/__snapshots__/async_function.ts +2 -2
- package/src/components/__snapshots__/async_function_with_Promise_return_type.ts +2 -2
- package/src/components/__snapshots__/basic_arrow_function.ts +3 -3
- package/src/components/__snapshots__/basic_export.ts +1 -0
- package/src/components/__snapshots__/basic_function.ts +2 -2
- package/src/components/__snapshots__/basic_import.ts +1 -0
- package/src/components/__snapshots__/default_exported_arrow_function.ts +3 -3
- package/src/components/__snapshots__/default_exported_function.ts +2 -2
- package/src/components/__snapshots__/exported_arrow_function.ts +3 -3
- package/src/components/__snapshots__/exported_function.ts +2 -2
- package/src/components/__snapshots__/function_with_JSDoc.ts +2 -2
- package/src/components/__snapshots__/function_with_generics.ts +2 -2
- package/src/components/__snapshots__/function_with_parameters.ts +2 -2
- package/src/components/__snapshots__/function_with_return_type.ts +2 -2
- package/src/components/__snapshots__/matches_with_root_import.ts +1 -0
- package/src/components/__snapshots__/named_export.ts +1 -0
- package/src/components/__snapshots__/named_export_(object_advanced).ts +1 -0
- package/src/components/__snapshots__/named_import.ts +1 -0
- package/src/components/__snapshots__/named_import_(object).ts +1 -0
- package/src/components/__snapshots__/named_import_(object_advanced).ts +1 -0
- package/src/components/__snapshots__/named_typed_export.ts +1 -0
- package/src/components/__snapshots__/named_typed_import.ts +1 -0
- package/src/components/__snapshots__/typed_export.ts +1 -0
- package/src/components/__snapshots__/typed_import.ts +1 -0
- package/src/contexts/RenderContext.ts +13 -0
- package/src/createComponent.ts +34 -0
- package/src/index.ts +9 -9
- package/src/intrinsic.ts +143 -0
- package/src/plugins/fsxPlugin/Runtime.ts +96 -0
- package/src/plugins/fsxPlugin/fsxPlugin.ts +45 -0
- package/src/plugins/index.ts +1 -0
- package/src/types.ts +4 -1
- package/dist/TreeNode-CC3a0Bae.js +0 -447
- package/dist/TreeNode-CC3a0Bae.js.map +0 -1
- package/dist/TreeNode-CFchatCw.cjs +0 -494
- package/dist/TreeNode-CFchatCw.cjs.map +0 -1
- package/dist/defineParser-CVCxqqzB.cjs +0 -18
- package/dist/defineParser-CVCxqqzB.cjs.map +0 -1
- package/dist/defineParser-Lco7nlj0.js +0 -13
- package/dist/defineParser-Lco7nlj0.js.map +0 -1
- package/dist/getRelativePath-BllDunh0.cjs.map +0 -1
- package/dist/getRelativePath-y7WcYR5C.js.map +0 -1
- package/dist/parsers/typescript.cjs.map +0 -1
- package/dist/parsers/typescript.js.map +0 -1
- package/dist/types-DYepTJ6F.d.cts +0 -82
- package/dist/types-yNaQHNUB.d.ts +0 -83
- package/src/components/Text.ts +0 -27
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["e","NodeEventEmitter","e","isFunction"],"sources":["../src/context.ts","../src/composables/useContext.ts","../src/contexts/NodeTreeContext.ts","../src/composables/useNodeTree.ts","../src/contexts/AppContext.ts","../../../node_modules/.pnpm/remeda@2.33.4/node_modules/remeda/dist/isFunction.js","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.ts","../src/contexts/RootContext.ts","../src/components/Text.ts","../src/components/App.ts","../src/utils/createJSDoc.ts","../src/components/Const.ts","../src/contexts/FileContext.ts","../src/composables/useFile.ts","../src/composables/useFileManager.ts","../src/components/File.ts","../src/components/Function.ts","../src/components/Root.ts","../src/components/Type.ts","../src/composables/useApp.ts","../src/composables/useLifecycle.ts","../src/createFabric.ts"],"sourcesContent":["/**\n * Context type that carries type information about its value\n * This is a branded symbol type that enables type-safe context usage\n */\nexport type Context<T> = symbol & { readonly __type: T }\n\n/**\n * Context stack for tracking the current context values\n *\n * Note: This uses a global Map for simplicity in code generation scenarios.\n * For concurrent runtime execution, consider using AsyncLocalStorage or\n * instance-based context management.\n */\nconst contextStack = new Map<symbol, unknown[]>()\nconst contextDefaults = new Map<symbol, unknown>()\n\n/**\n * Provides a value to descendant components (Vue 3 style)\n *\n * @example\n * ```ts\n * const ThemeKey = Symbol('theme')\n * provide(ThemeKey, { color: 'blue' })\n * ```\n */\nexport function provide<T>(key: symbol | Context<T>, value: T): void {\n if (!contextStack.has(key)) {\n contextStack.set(key, [])\n }\n contextStack.get(key)!.push(value)\n}\n\n/**\n * Injects a value provided by an ancestor component (Vue 3 style)\n *\n * @example\n * ```ts\n * const theme = inject(ThemeKey, { color: 'default' })\n * ```\n */\nexport function inject<T>(key: symbol | Context<T>, defaultValue?: T): T {\n const stack = contextStack.get(key)\n if (!stack || stack.length === 0) {\n if (defaultValue !== undefined) {\n return defaultValue\n }\n const storedDefault = contextDefaults.get(key)\n if (storedDefault !== undefined) {\n return storedDefault as T\n }\n throw new Error(`No value provided for key: ${key.toString()}`)\n }\n return stack[stack.length - 1] as T\n}\n\n/**\n * Unprovides a value (for cleanup)\n * @internal\n */\nexport function unprovide<T>(key: symbol | Context<T>): void {\n const stack = contextStack.get(key)\n if (stack && stack.length > 0) {\n stack.pop()\n }\n}\n\n/**\n * Creates a context key with a default value (React-style compatibility)\n *\n * @example\n * ```ts\n * const ThemeContext = createContext({ color: 'blue' })\n * // ThemeContext is now typed as Context<{ color: string }>\n * const theme = useContext(ThemeContext) // theme is { color: string }\n * ```\n */\nexport function createContext<T>(defaultValue: T): Context<T> {\n const key = Symbol('context') as Context<T>\n contextDefaults.set(key, defaultValue)\n\n return key\n}\n","import type { Context } from '../context.ts'\nimport { inject } from '../context.ts'\n\n/**\n * React-style alias for inject\n *\n * @example\n * ```ts\n * const theme = useContext(ThemeContext) // type is inferred from ThemeContext\n * ```\n */\nexport function useContext<T>(key: Context<T>): T\nexport function useContext<T, TValue = T>(key: Context<T>, defaultValue: TValue): NonNullable<T> | TValue\nexport function useContext<T>(key: Context<T>, defaultValue?: T): T {\n return inject(key, defaultValue)\n}\n","import type { ComponentNode } from '../composables/useNodeTree.ts'\nimport { createContext } from '../context.ts'\nimport type { TreeNode } from '../utils/TreeNode.ts'\n\n/**\n * Context for having the current NodeTree\n */\nexport const NodeTreeContext = createContext<TreeNode<ComponentNode> | null>(null)\n","import { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { TreeNode } from '../utils/TreeNode.ts'\nimport { useContext } from './useContext.ts'\n\nexport type ComponentNode = {\n type: string\n props: Record<string, unknown>\n}\n\nexport function useNodeTree(): TreeNode<ComponentNode> | null {\n return useContext(NodeTreeContext)\n}\n","import { createContext } from '../context.ts'\n\nexport type AppContextProps<TMeta extends object = object> = {\n /**\n * Exit (unmount)\n */\n exit: (error?: Error) => void\n meta: TMeta\n}\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const AppContext = createContext<AppContextProps>({\n exit: () => {},\n meta: {},\n})\n","const e=e=>typeof e==`function`;export{e as isFunction};\n//# sourceMappingURL=isFunction.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 add(...files: Array<KubbFile.File>): Array<KubbFile.ResolvedFile> {\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 this.events.emit('files:added', resolvedFiles)\n\n return resolvedFiles\n }\n\n upsert(...files: Array<KubbFile.File>): Array<KubbFile.ResolvedFile> {\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 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 type { ComponentNode } from '../composables/useNodeTree.ts'\nimport { createContext } from '../context.ts'\nimport { FileManager } from '../FileManager.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole app.\n */\n exit: (error?: Error) => void\n /**\n * TreeNode representing the tree structure of the app.\n */\n treeNode: TreeNode<ComponentNode>\n /**\n * FileManager instance for managing files within the app.\n */\n fileManager: FileManager\n}\n\n/**\n * Context providing root-level functionalities such as exit hook, tree node structure, and file management.\n * Define in the `render` helper of the runtime.\n */\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n treeNode: new TreeNode({ type: 'Root', props: {} }),\n fileManager: new FileManager(),\n})\n","type Props = {\n /**\n * Children nodes.\n */\n children?: string | (() => string | Array<string> | undefined)\n}\n\n/**\n * Generates a text node from string or function returning string/array of strings.\n */\nexport function Text({ children }: Props): string {\n if (!children) {\n return ''\n }\n\n if (typeof children === 'string') {\n return children\n }\n\n const value = children()\n\n if (Array.isArray(value)) {\n return value.join('\\n')\n }\n\n return value || ''\n}\n","import { useContext } from '../composables/useContext.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { AppContext } from '../contexts/AppContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { RootContext } from '../contexts/RootContext.ts'\nimport { Text } from './Text.ts'\n\nexport type AppProps<TMeta extends Object = Object> = {\n /**\n * Metadata associated with the App.\n */\n meta?: TMeta\n /**\n * Children nodes.\n */\n children?: string | (() => string | Array<string>)\n}\n\n/**\n * App container containing the AppContext carrying `meta` and an `exit` hook.\n */\nexport function App<TMeta extends Object = Object>({ children, ...props }: AppProps<TMeta>): string {\n const { meta = {} } = props\n\n const { exit } = useContext(RootContext)\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'App', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n provide(AppContext, { exit, meta })\n\n return Text({ children })\n}\n\nApp.displayName = 'KubbApp'\n","/**\n * Create JSDoc comment block from comments array\n */\nexport function createJSDoc({ comments }: { comments: string[] }): string {\n if (!comments || comments.length === 0) return ''\n\n const lines = comments\n .flatMap((c) => String(c ?? '').split(/\\r?\\n/))\n .map((l) => l.replace(/\\*\\//g, '*\\\\/').replace(/\\r/g, ''))\n .filter((l) => l.trim().length > 0)\n\n if (lines.length === 0) return ''\n\n return ['/**', ...lines.map((l) => ` * ${l}`), ' */'].join('\\n')\n}\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Text } from './Text.ts'\n\nexport type ConstProps = {\n /**\n * Name of the const\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Type to make the const being typed\n */\n type?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Use of `const` assertions\n */\n asConst?: boolean\n /**\n * Children nodes.\n */\n children?: string\n}\n\n/**\n * Generates a TypeScript constant declaration.\n */\nexport function Const({ children, ...props }: ConstProps): string {\n const { name, export: canExport, type, JSDoc, asConst } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Const', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `const ${name}`\n\n if (type) {\n result += `: ${type}`\n }\n\n result += ` = ${children ? children : ''}`\n\n if (asConst) {\n result += ' as const'\n }\n\n return Text({ children: result })\n}\n\nConst.displayName = 'KubbConst'\n","import { createContext } from '../context.ts'\nimport type * as KubbFile from '../KubbFile.ts'\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const FileContext = createContext<KubbFile.ResolvedFile | null>(null)\n","import { FileContext } from '../contexts/FileContext.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * `useFile` will return the current FileCollector for registering files.\n *\n * Throws when no FileCollector is present in context — ensure a Fabric that\n * provides a FileCollector is mounted before calling this hook.\n */\nexport function useFile(): KubbFile.ResolvedFile | null {\n return useContext(FileContext)\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport type { FileManager } from '../FileManager.ts'\nimport { useContext } from './useContext.ts'\n\nexport function useFileManager(): FileManager {\n const { fileManager } = useContext(RootContext)\n\n return fileManager\n}\n","import { useFile } from '../composables/useFile.ts'\nimport { useFileManager } from '../composables/useFileManager.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { FileContext } from '../contexts/FileContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { KubbFile } from '../types.ts'\nimport { Text } from './Text.ts'\n\nexport type FileProps<TMeta extends object = object> = {\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 */\n baseName: KubbFile.BaseName\n /**\n * Path will be full qualified path to a specified file.\n */\n path: KubbFile.Path\n meta?: TMeta\n banner?: string\n footer?: string\n /**\n * Children nodes.\n */\n children?: string | (() => string | Array<string>)\n}\n\n/**\n * Adds files to the FileManager\n */\nexport function File<TMeta extends object = object>({ children, ...props }: FileProps<TMeta>): string {\n const { baseName, path, meta = {}, footer, banner } = props\n\n const fileManager = useFileManager()\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'File', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const file: KubbFile.File = {\n baseName,\n path,\n meta,\n banner,\n footer,\n sources: [],\n imports: [],\n exports: [],\n }\n\n const [resolvedFile] = fileManager.add(file)\n provide(FileContext, resolvedFile)\n\n return Text({ children })\n}\n\ntype FileSourceProps = Omit<KubbFile.Source, 'value'> & {\n /**\n * Children nodes.\n */\n children?: string | (() => string | Array<string>)\n}\n\n/**\n * FileSource - for adding source code to a file\n *\n * Returns the provided children string so the fsx renderer can collect it.\n */\nexport function FileSource({ children, ...props }: FileSourceProps): string {\n const { name, isExportable, isIndexable, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileSource', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.sources.push({\n name,\n isExportable,\n isIndexable,\n isTypeOnly,\n value: Text({ children }),\n })\n }\n\n return Text({ children })\n}\n\nexport type FileExportProps = KubbFile.Export\n\n/**\n * FileExport - for adding exports to a file\n *\n * No-op function used by renderers to record exports.\n */\nexport function FileExport(props: FileExportProps): string {\n const { name, path, isTypeOnly, asAlias } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileExport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.exports.push({\n name,\n path,\n asAlias,\n isTypeOnly,\n })\n }\n\n return Text({ children: '' })\n}\n\nexport type FileImportProps = KubbFile.Import\n\n/**\n * FileImport - for adding imports to a file\n *\n * No-op function used by renderers to record imports.\n */\nexport function FileImport(props: FileImportProps): string {\n const { name, path, root, isNameSpace, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileImport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.imports.push({\n name,\n path,\n root,\n isNameSpace,\n isTypeOnly,\n })\n }\n\n return Text({ children: '' })\n}\n\nFile.Source = FileSource\nFile.Import = FileImport\nFile.Export = FileExport\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Text } from './Text.ts'\n\ntype Props = {\n /**\n * Name of the function.\n */\n name: string\n /**\n * Add default when export is being used\n */\n default?: boolean\n /**\n * Parameters/options/props that need to be used.\n */\n params?: string\n /**\n * Does this function need to be exported.\n */\n export?: boolean\n /**\n * Does the function has async/promise behaviour.\n * This will also add `Promise<returnType>` as the returnType.\n */\n async?: boolean\n /**\n * Generics that needs to be added for TypeScript.\n */\n generics?: string | string[]\n /**\n * ReturnType(see async for adding Promise type).\n */\n returnType?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Children nodes.\n */\n children?: string\n}\n\n/**\n * Generates a TypeScript function declaration.\n */\nexport function Function({ children, ...props }: Props): string {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Function', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n if (async) {\n parts.push('async ')\n }\n\n parts.push(`function ${name}`)\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n parts.push(' {')\n\n if (children) {\n return Text({ children: `${parts.join('')}${' '}${'\\n'}${children}${' '}${'\\n'}}` })\n }\n\n return Text({ children: `${parts.join('')}}` })\n}\n\nFunction.displayName = 'KubbFunction'\n\ntype ArrowFunctionProps = Props & {\n /**\n * Create Arrow function in one line\n */\n singleLine?: boolean\n}\n\n/**\n * ArrowFunction\n *\n * Builds an arrow function declaration string for the fsx renderer. Supports\n * the same options as `Function`. Use `singleLine` to produce a one-line\n * arrow expression.\n */\nfunction ArrowFunction({ children, ...props }: ArrowFunctionProps): string {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'ArrowFunction', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n parts.push(`const ${name} = `)\n\n if (async) {\n parts.push('async ')\n }\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n if (singleLine) {\n parts.push(` => ${children || ''}\\n`)\n return Text({ children: parts.join('') })\n }\n\n if (children) {\n return Text({ children: `${parts.join('')} => {${' '}${'\\n'}${children}${' '}${'\\n'}}${'\\n'}` })\n }\n\n return Text({ children: `${parts.join('')} => {}\\n` })\n}\n\nArrowFunction.displayName = 'KubbArrowFunction'\nFunction.Arrow = ArrowFunction\n","import type { ComponentNode } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { RootContext } from '../contexts/RootContext.ts'\nimport type { FileManager } from '../FileManager.ts'\nimport type { TreeNode } from '../utils/TreeNode.ts'\nimport { Text } from './Text.ts'\n\nexport type RootProps = {\n /**\n * Exit (unmount) the whole app.\n */\n onExit: (error?: Error) => void\n /**\n * Error hook receiving runtime exceptions.\n */\n onError: (error: Error) => void\n /**\n * TreeNode representing the tree structure of the app.\n */\n treeNode: TreeNode<ComponentNode>\n /**\n * FileManager instance for managing files within the app.\n */\n fileManager: FileManager\n /**\n * Children nodes.\n */\n children?: string | (() => string | Array<string> | undefined)\n}\n\n/**\n * This component provides the root behavior for the Fabric runtime.\n */\nexport function Root({ onError, onExit, treeNode, fileManager, children }: RootProps): string {\n provide(RootContext, { exit: onExit, treeNode, fileManager })\n provide(NodeTreeContext, treeNode)\n\n try {\n return Text({ children })\n } catch (e) {\n if (e instanceof Error) {\n onError?.(e)\n }\n return ''\n }\n}\n\nRoot.displayName = 'KubbRoot'\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Text } from './Text.ts'\n\nexport type TypeProps = {\n /**\n * Name of the type, this needs to start with a capital letter.\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Children nodes.\n */\n children?: string\n}\n\n/**\n * Generates a TypeScript type declaration.\n */\nexport function Type({ children, ...props }: TypeProps): string {\n const { name, export: canExport, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Type', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (name.charAt(0).toUpperCase() !== name.charAt(0)) {\n throw new Error('Name should start with a capital letter (see TypeScript types)')\n }\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `type ${name} = ${children || ''}`\n\n return Text({ children: result })\n}\n\nType.displayName = 'KubbType'\n","import { AppContext, type AppContextProps } from '../contexts/AppContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * `useApp` will return the current App with meta and exit function.\n *\n * Throws an error when there is no AppContext available.\n */\nexport function useApp<TMeta extends object = object>(): AppContextProps<TMeta> {\n return useContext(AppContext) as AppContextProps<TMeta>\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * `useLifecycle` will return some helpers to exit/restart the generation.\n *\n * This hook reads the RootContext and exposes lifecycle helpers (like `exit`)\n * for consumers to programmatically stop generation or perform teardown.\n */\nexport function useLifecycle() {\n const { exit } = useContext(RootContext)\n\n return {\n exit,\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 },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KAAK;AAG/C,QAAI,eAAe,SACjB,MAAK,MAAM,WAAW,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
|
+
{"version":3,"file":"index.js","names":["e","isFunction"],"sources":["../src/composables/useContext.ts","../src/composables/useNodeTree.ts","../src/contexts/AppContext.ts","../../../node_modules/.pnpm/remeda@2.33.4/node_modules/remeda/dist/isFunction.js","../src/components/App.ts","../src/components/Br.ts","../src/utils/createJSDoc.ts","../src/components/Const.ts","../src/components/Dedent.ts","../src/contexts/FileContext.ts","../src/composables/useFile.ts","../src/composables/useFileManager.ts","../src/components/File.ts","../src/components/Indent.ts","../src/components/Function.ts","../src/components/Type.ts","../src/composables/useApp.ts","../src/composables/useLifecycle.ts","../src/createFabric.ts"],"sourcesContent":["import type { Context } from '../context.ts'\nimport { inject } from '../context.ts'\n\n/**\n * React-style alias for inject\n *\n * @example\n * ```ts\n * const theme = useContext(ThemeContext) // type is inferred from ThemeContext\n * ```\n */\nexport function useContext<T>(key: Context<T>): T\nexport function useContext<T, TValue = T>(key: Context<T>, defaultValue: TValue): NonNullable<T> | TValue\nexport function useContext<T>(key: Context<T>, defaultValue?: T): T {\n return inject(key, defaultValue)\n}\n","import { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { TreeNode } from '../utils/TreeNode.ts'\nimport { useContext } from './useContext.ts'\n\nexport type ComponentNode = {\n type: string\n props: Record<string, unknown>\n}\n\nexport function useNodeTree(): TreeNode<ComponentNode> | null {\n return useContext(NodeTreeContext)\n}\n","import { createContext } from '../context.ts'\n\nexport type AppContextProps<TMeta extends object = object> = {\n /**\n * Exit (unmount)\n */\n exit: (error?: Error) => void\n meta: TMeta\n}\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const AppContext = createContext<AppContextProps>({\n exit: () => {},\n meta: {},\n})\n","const e=e=>typeof e==`function`;export{e as isFunction};\n//# sourceMappingURL=isFunction.js.map","import { useContext } from '../composables/useContext.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { AppContext } from '../contexts/AppContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { RootContext } from '../contexts/RootContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\n\nexport type AppProps<TMeta extends Object = Object> = {\n /**\n * Metadata associated with the App.\n */\n meta?: TMeta\n /**\n * Children nodes.\n */\n children?: FabricNode\n}\n\n/**\n * App container containing the AppContext carrying `meta` and an `exit` hook.\n */\nexport const App = createComponent('App', ({ children, ...props }: AppProps) => {\n const { meta = {} } = props\n\n const { exit } = useContext(RootContext)\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'App', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n provide(AppContext, { exit, meta })\n\n return children\n})\n\nApp.displayName = 'KubbApp'\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Generates a line break in the output.\n */\nexport const Br = createComponent('br', () => {\n return createIntrinsic('br')\n})\n\nBr.displayName = 'Br'\n","/**\n * Create JSDoc comment block from comments array\n */\nexport function createJSDoc({ comments }: { comments: string[] }): string {\n if (!comments || comments.length === 0) return ''\n\n const lines = comments\n .flatMap((c) => String(c ?? '').split(/\\r?\\n/))\n .map((l) => l.replace(/\\*\\//g, '*\\\\/').replace(/\\r/g, ''))\n .filter((l) => l.trim().length > 0)\n\n if (lines.length === 0) return ''\n\n return ['/**', ...lines.map((l) => ` * ${l}`), ' */'].join('\\n')\n}\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\nexport type ConstProps = {\n /**\n * Name of the const\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Type to make the const being typed\n */\n type?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Use of `const` assertions\n */\n asConst?: boolean\n /**\n * Children nodes.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript constant declaration.\n */\nexport const Const = createComponent('Const', ({ children, ...props }: ConstProps) => {\n const { name, export: canExport, type, JSDoc, asConst } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Const', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `const ${name}`\n\n if (type) {\n result += `: ${type}`\n }\n\n result += ` = ${children ? children : ''}`\n\n if (asConst) {\n result += ' as const'\n }\n\n return result\n})\n\nConst.displayName = 'KubbConst'\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Dedent component for reducing indentation level in rendered output.\n */\nexport const Dedent = createComponent('dedent', () => {\n return createIntrinsic('dedent')\n})\nDedent.displayName = 'Dedent'\n","import { createContext } from '../context.ts'\nimport type * as KubbFile from '../KubbFile.ts'\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const FileContext = createContext<KubbFile.ResolvedFile | null>(null)\n","import { FileContext } from '../contexts/FileContext.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * `useFile` will return the current FileCollector for registering files.\n *\n * Throws when no FileCollector is present in context — ensure a Fabric that\n * provides a FileCollector is mounted before calling this hook.\n */\nexport function useFile(): KubbFile.ResolvedFile | null {\n return useContext(FileContext)\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport type { FileManager } from '../FileManager.ts'\nimport { useContext } from './useContext.ts'\n\nexport function useFileManager(): FileManager {\n const { fileManager } = useContext(RootContext)\n\n return fileManager\n}\n","import { useFile } from '../composables/useFile.ts'\nimport { useFileManager } from '../composables/useFileManager.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { FileContext } from '../contexts/FileContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { type ComponentBuilder, createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport { renderIntrinsic } from '../intrinsic.ts'\nimport { createExport, createImport, print } from '../parsers/typescriptParser.ts'\nimport type { KubbFile } from '../types.ts'\n\nexport type FileProps<TMeta extends object = object> = {\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 */\n baseName: KubbFile.BaseName\n /**\n * Path will be full qualified path to a specified file.\n */\n path: KubbFile.Path\n meta?: TMeta\n banner?: string\n footer?: string\n /**\n * Children nodes.\n */\n children?: FabricNode\n}\n\n/**\n * Adds files to the FileManager\n */\nexport const File = createComponent('File', ({ children, ...props }: FileProps) => {\n const { baseName, path, meta = {}, footer, banner } = props\n\n const fileManager = useFileManager()\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'File', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const file: KubbFile.File = {\n baseName,\n path,\n meta,\n banner,\n footer,\n sources: [],\n imports: [],\n exports: [],\n }\n\n const [resolvedFile] = fileManager.add(file)\n provide(FileContext, resolvedFile)\n\n return children\n}) as ComponentBuilder<FileProps<object>> & { Source: typeof FileSource; Import: typeof FileImport; Export: typeof FileExport }\n\ntype FileSourceProps = Omit<KubbFile.Source, 'value'> & {\n /**\n * Children nodes.\n */\n children?: FabricNode\n}\n\n/**\n * FileSource - for adding source code to a file\n *\n * Returns the provided children string so the fsx renderer can collect it.\n */\nexport const FileSource = createComponent('FileSource', ({ children, ...props }: FileSourceProps) => {\n const { name, isExportable, isIndexable, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileSource', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const value = renderIntrinsic(children)\n\n if (file) {\n file.sources.push({\n name,\n isExportable,\n isIndexable,\n isTypeOnly,\n value,\n })\n }\n\n return value\n})\n\nexport type FileExportProps = KubbFile.Export\n\n/**\n * FileExport - for adding exports to a file\n *\n * No-op function used by renderers to record exports.\n */\nexport const FileExport = createComponent('FileExport', (props: FileExportProps) => {\n const { name, path, isTypeOnly, asAlias } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileExport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.exports.push({\n name,\n path,\n asAlias,\n isTypeOnly,\n })\n }\n\n return print(createExport({ name, path, isTypeOnly, asAlias }))\n})\n\nexport type FileImportProps = KubbFile.Import\n\n/**\n * FileImport - for adding imports to a file\n *\n * No-op function used by renderers to record imports.\n */\nexport const FileImport = createComponent('FileImport', (props: FileImportProps) => {\n const { name, path, root, isNameSpace, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileImport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.imports.push({\n name,\n path,\n root,\n isNameSpace,\n isTypeOnly,\n })\n }\n\n return print(createImport({ name, path, root, isNameSpace, isTypeOnly }))\n})\n\nFile.Source = FileSource\nFile.Import = FileImport\nFile.Export = FileExport\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\nexport const Indent = createComponent('indent', () => {\n return createIntrinsic('indent')\n})\nIndent.displayName = 'Indent'\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { type ComponentBuilder, createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Br } from './Br.ts'\nimport { Dedent } from './Dedent.ts'\nimport { Indent } from './Indent.ts'\n\ntype FunctionProps = {\n /**\n * Name of the function.\n */\n name: string\n /**\n * Add default when export is being used\n */\n default?: boolean\n /**\n * Parameters/options/props that need to be used.\n */\n params?: string\n /**\n * Does this function need to be exported.\n */\n export?: boolean\n /**\n * Does the function has async/promise behaviour.\n * This will also add `Promise<returnType>` as the returnType.\n */\n async?: boolean\n /**\n * Generics that needs to be added for TypeScript.\n */\n generics?: string | string[]\n /**\n * ReturnType(see async for adding Promise type).\n */\n returnType?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Children nodes.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript function declaration.\n */\nexport const Function = createComponent('Function', ({ children, ...props }: FunctionProps) => {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Function', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n if (async) {\n parts.push('async ')\n }\n\n parts.push(`function ${name}`)\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n parts.push(' {')\n\n if (children) {\n return [parts.join(''), Br(), Indent(), children, Br(), Dedent(), '}']\n }\n\n return [parts.join(''), '}']\n}) as ComponentBuilder<FunctionProps> & { Arrow: typeof ArrowFunction }\n\nFunction.displayName = 'KubbFunction'\n\ntype ArrowFunctionProps = FunctionProps & {\n /**\n * Create Arrow function in one line\n */\n singleLine?: boolean\n}\n\n/**\n * ArrowFunction\n *\n * Builds an arrow function declaration string for the fsx renderer. Supports\n * the same options as `Function`. Use `singleLine` to produce a one-line\n * arrow expression.\n */\nconst ArrowFunction = createComponent('ArrowFunction', ({ children, ...props }: ArrowFunctionProps) => {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'ArrowFunction', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n parts.push(`const ${name} = `)\n\n if (async) {\n parts.push('async ')\n }\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n if (singleLine) {\n parts.push(` => ${children || ''}\\n`)\n return parts.join('')\n }\n\n if (children) {\n return [parts.join(''), ' => {', Br(), Indent(), children, Br(), Dedent(), '}']\n }\n\n return [parts.join(''), ' => {}']\n})\n\nArrowFunction.displayName = 'KubbArrowFunction'\nFunction.Arrow = ArrowFunction\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\nexport type TypeProps = {\n /**\n * Name of the type, this needs to start with a capital letter.\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Children nodes.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript type declaration.\n */\nexport const Type = createComponent('Type', ({ children, ...props }: TypeProps) => {\n const { name, export: canExport, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Type', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (name.charAt(0).toUpperCase() !== name.charAt(0)) {\n throw new Error('Name should start with a capital letter (see TypeScript types)')\n }\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `type ${name} = ${children || ''}`\n\n return result\n})\n\nType.displayName = 'KubbType'\n","import { AppContext, type AppContextProps } from '../contexts/AppContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * `useApp` will return the current App with meta and exit function.\n *\n * Throws an error when there is no AppContext available.\n */\nexport function useApp<TMeta extends object = object>(): AppContextProps<TMeta> {\n return useContext(AppContext) as AppContextProps<TMeta>\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * `useLifecycle` will return some helpers to exit/restart the generation.\n *\n * This hook reads the RootContext and exposes lifecycle helpers (like `exit`)\n * for consumers to programmatically stop generation or perform teardown.\n */\nexport function useLifecycle() {\n const { exit } = useContext(RootContext)\n\n return {\n exit,\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":[3],"mappings":";;;;;;AAaA,SAAgB,WAAc,KAAiB,cAAqB;AAClE,QAAO,OAAO,KAAK,aAAa;;;;;ACLlC,SAAgB,cAA8C;AAC5D,QAAO,WAAW,gBAAgB;;;;;;;;;ACIpC,MAAa,aAAa,cAA+B;CACvD,YAAY;CACZ,MAAM,EAAE;CACT,CAAC;;;;ACjBF,MAAM,KAAE,QAAG,OAAOA,OAAG;;;;;;;ACuBrB,MAAa,MAAM,gBAAgB,QAAQ,EAAE,UAAU,GAAG,YAAsB;CAC9E,MAAM,EAAE,OAAO,EAAE,KAAK;CAEtB,MAAM,EAAE,SAAS,WAAW,YAAY;CAExC,MAAM,WAAW,aAAa;AAE9B,KAAI,SAGF,SAAQ,iBAFU,SAAS,SAAS;EAAE,MAAM;EAAO;EAAO,CAAC,CAExB;AAGrC,SAAQ,YAAY;EAAE;EAAM;EAAM,CAAC;AAEnC,QAAO;EACP;AAEF,IAAI,cAAc;;;;;;;ACnClB,MAAa,KAAK,gBAAgB,YAAY;AAC5C,QAAO,gBAAgB,KAAK;EAC5B;AAEF,GAAG,cAAc;;;;;;;ACPjB,SAAgB,YAAY,EAAE,YAA4C;AACxE,KAAI,CAAC,YAAY,SAAS,WAAW,EAAG,QAAO;CAE/C,M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
|
-
const require_defineParser = require('../defineParser-CVCxqqzB.cjs');
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
node_path = require_getRelativePath.__toESM(node_path);
|
|
5
|
-
let typescript = require("typescript");
|
|
6
|
-
typescript = require_getRelativePath.__toESM(typescript);
|
|
1
|
+
const require_typescriptParser = require('../typescriptParser-qjzb2pIh.cjs');
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function validateNodes(...nodes) {
|
|
15
|
-
for (const node of nodes) {
|
|
16
|
-
if (!node) throw new Error("Attempted to print undefined or null TypeScript node");
|
|
17
|
-
if (node.kind === typescript.default.SyntaxKind.Unknown) throw new Error(`Invalid TypeScript AST node detected with SyntaxKind.Unknown. This typically indicates a schema pattern that couldn't be properly converted to TypeScript. Node: ${JSON.stringify(node, null, 2)}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
|
|
22
|
-
*/
|
|
23
|
-
function print(...elements) {
|
|
24
|
-
const sourceFile = typescript.default.createSourceFile("print.tsx", "", typescript.default.ScriptTarget.ES2022, true, typescript.default.ScriptKind.TSX);
|
|
25
|
-
const printer = typescript.default.createPrinter({
|
|
26
|
-
omitTrailingSemicolon: true,
|
|
27
|
-
newLine: typescript.default.NewLineKind.LineFeed,
|
|
28
|
-
removeComments: false,
|
|
29
|
-
noEmitHelpers: true
|
|
30
|
-
});
|
|
31
|
-
for (const node of elements) if (node.kind === typescript.default.SyntaxKind.Unknown) console.error("⚠️ Unknown node found:", node);
|
|
32
|
-
return printer.printList(typescript.default.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile).replace(/\r\n/g, "\n");
|
|
33
|
-
}
|
|
34
|
-
function safePrint(...elements) {
|
|
35
|
-
validateNodes(...elements);
|
|
36
|
-
return print(...elements);
|
|
37
|
-
}
|
|
38
|
-
function createImport({ name, path: path$1, root, isTypeOnly = false, isNameSpace = false }) {
|
|
39
|
-
const resolvePath = root ? require_getRelativePath.getRelativePath(root, path$1) : path$1;
|
|
40
|
-
if (!Array.isArray(name)) {
|
|
41
|
-
if (isNameSpace) return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamespaceImport(factory.createIdentifier(name))), factory.createStringLiteral(resolvePath), void 0);
|
|
42
|
-
return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, factory.createIdentifier(name), void 0), factory.createStringLiteral(resolvePath), void 0);
|
|
43
|
-
}
|
|
44
|
-
const specifiers = name.map((item) => {
|
|
45
|
-
if (typeof item === "object") {
|
|
46
|
-
const { propertyName, name: alias } = item;
|
|
47
|
-
return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias !== null && alias !== void 0 ? alias : propertyName));
|
|
48
|
-
}
|
|
49
|
-
return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
|
|
50
|
-
});
|
|
51
|
-
return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamedImports(specifiers)), factory.createStringLiteral(resolvePath), void 0);
|
|
52
|
-
}
|
|
53
|
-
function createExport({ path: path$1, asAlias, isTypeOnly = false, name }) {
|
|
54
|
-
if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
|
|
55
|
-
if (!Array.isArray(name)) {
|
|
56
|
-
const parsedName = (name === null || name === void 0 ? void 0 : name.match(/^\d/)) ? `_${name === null || name === void 0 ? void 0 : name.slice(1)}` : name;
|
|
57
|
-
return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path$1), void 0);
|
|
58
|
-
}
|
|
59
|
-
return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName) => {
|
|
60
|
-
return factory.createExportSpecifier(false, void 0, typeof propertyName === "string" ? factory.createIdentifier(propertyName) : propertyName);
|
|
61
|
-
})), factory.createStringLiteral(path$1), void 0);
|
|
62
|
-
}
|
|
63
|
-
const typescriptParser = require_defineParser.defineParser({
|
|
64
|
-
name: "typescript",
|
|
65
|
-
extNames: [".ts", ".js"],
|
|
66
|
-
install() {},
|
|
67
|
-
async parse(file, options = { extname: ".ts" }) {
|
|
68
|
-
const sourceParts = [];
|
|
69
|
-
for (const item of file.sources) if (item.value) sourceParts.push(item.value);
|
|
70
|
-
const source = sourceParts.join("\n\n");
|
|
71
|
-
const importNodes = [];
|
|
72
|
-
for (const item of file.imports) {
|
|
73
|
-
const importPath = item.root ? require_getRelativePath.getRelativePath(item.root, item.path) : item.path;
|
|
74
|
-
const hasExtname = !!node_path.default.extname(importPath);
|
|
75
|
-
importNodes.push(createImport({
|
|
76
|
-
name: item.name,
|
|
77
|
-
path: options.extname && hasExtname ? `${require_getRelativePath.trimExtName(importPath)}${options.extname}` : item.root ? require_getRelativePath.trimExtName(importPath) : importPath,
|
|
78
|
-
isTypeOnly: item.isTypeOnly
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
const exportNodes = [];
|
|
82
|
-
for (const item of file.exports) {
|
|
83
|
-
const exportPath = item.path;
|
|
84
|
-
const hasExtname = !!node_path.default.extname(exportPath);
|
|
85
|
-
exportNodes.push(createExport({
|
|
86
|
-
name: item.name,
|
|
87
|
-
path: options.extname && hasExtname ? `${require_getRelativePath.trimExtName(item.path)}${options.extname}` : require_getRelativePath.trimExtName(item.path),
|
|
88
|
-
isTypeOnly: item.isTypeOnly,
|
|
89
|
-
asAlias: item.asAlias
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
return [
|
|
93
|
-
file.banner,
|
|
94
|
-
print(...importNodes, ...exportNodes),
|
|
95
|
-
source,
|
|
96
|
-
file.footer
|
|
97
|
-
].filter((segment) => segment != null).join("\n");
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
//#endregion
|
|
102
|
-
exports.createExport = createExport;
|
|
103
|
-
exports.createImport = createImport;
|
|
104
|
-
exports.print = print;
|
|
105
|
-
exports.safePrint = safePrint;
|
|
106
|
-
exports.typescriptParser = typescriptParser;
|
|
107
|
-
exports.validateNodes = validateNodes;
|
|
108
|
-
//# sourceMappingURL=typescript.cjs.map
|
|
3
|
+
exports.createExport = require_typescriptParser.createExport;
|
|
4
|
+
exports.createImport = require_typescriptParser.createImport;
|
|
5
|
+
exports.print = require_typescriptParser.print;
|
|
6
|
+
exports.safePrint = require_typescriptParser.safePrint;
|
|
7
|
+
exports.typescriptParser = require_typescriptParser.typescriptParser;
|
|
8
|
+
exports.validateNodes = require_typescriptParser.validateNodes;
|
|
@@ -1,102 +1,3 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { n as trimExtName, t as getRelativePath } from "../getRelativePath-y7WcYR5C.js";
|
|
3
|
-
import { t as defineParser } from "../defineParser-Lco7nlj0.js";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import ts from "typescript";
|
|
1
|
+
import { a as typescriptParser, i as safePrint, n as createImport, o as validateNodes, r as print, t as createExport } from "../typescriptParser-DyosyI_A.js";
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
const { factory } = ts;
|
|
9
|
-
/**
|
|
10
|
-
* Validates TypeScript AST nodes before printing to catch invalid nodes early.
|
|
11
|
-
* Throws an error if any node has SyntaxKind.Unknown which would cause the TypeScript printer to crash.
|
|
12
|
-
*/
|
|
13
|
-
function validateNodes(...nodes) {
|
|
14
|
-
for (const node of nodes) {
|
|
15
|
-
if (!node) throw new Error("Attempted to print undefined or null TypeScript node");
|
|
16
|
-
if (node.kind === ts.SyntaxKind.Unknown) throw new Error(`Invalid TypeScript AST node detected with SyntaxKind.Unknown. This typically indicates a schema pattern that couldn't be properly converted to TypeScript. Node: ${JSON.stringify(node, null, 2)}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
|
|
21
|
-
*/
|
|
22
|
-
function print(...elements) {
|
|
23
|
-
const sourceFile = ts.createSourceFile("print.tsx", "", ts.ScriptTarget.ES2022, true, ts.ScriptKind.TSX);
|
|
24
|
-
const printer = ts.createPrinter({
|
|
25
|
-
omitTrailingSemicolon: true,
|
|
26
|
-
newLine: ts.NewLineKind.LineFeed,
|
|
27
|
-
removeComments: false,
|
|
28
|
-
noEmitHelpers: true
|
|
29
|
-
});
|
|
30
|
-
for (const node of elements) if (node.kind === ts.SyntaxKind.Unknown) console.error("⚠️ Unknown node found:", node);
|
|
31
|
-
return printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile).replace(/\r\n/g, "\n");
|
|
32
|
-
}
|
|
33
|
-
function safePrint(...elements) {
|
|
34
|
-
validateNodes(...elements);
|
|
35
|
-
return print(...elements);
|
|
36
|
-
}
|
|
37
|
-
function createImport({ name, path: path$1, root, isTypeOnly = false, isNameSpace = false }) {
|
|
38
|
-
const resolvePath = root ? getRelativePath(root, path$1) : path$1;
|
|
39
|
-
if (!Array.isArray(name)) {
|
|
40
|
-
if (isNameSpace) return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamespaceImport(factory.createIdentifier(name))), factory.createStringLiteral(resolvePath), void 0);
|
|
41
|
-
return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, factory.createIdentifier(name), void 0), factory.createStringLiteral(resolvePath), void 0);
|
|
42
|
-
}
|
|
43
|
-
const specifiers = name.map((item) => {
|
|
44
|
-
if (typeof item === "object") {
|
|
45
|
-
const { propertyName, name: alias } = item;
|
|
46
|
-
return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias !== null && alias !== void 0 ? alias : propertyName));
|
|
47
|
-
}
|
|
48
|
-
return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
|
|
49
|
-
});
|
|
50
|
-
return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamedImports(specifiers)), factory.createStringLiteral(resolvePath), void 0);
|
|
51
|
-
}
|
|
52
|
-
function createExport({ path: path$1, asAlias, isTypeOnly = false, name }) {
|
|
53
|
-
if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
|
|
54
|
-
if (!Array.isArray(name)) {
|
|
55
|
-
const parsedName = (name === null || name === void 0 ? void 0 : name.match(/^\d/)) ? `_${name === null || name === void 0 ? void 0 : name.slice(1)}` : name;
|
|
56
|
-
return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path$1), void 0);
|
|
57
|
-
}
|
|
58
|
-
return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName) => {
|
|
59
|
-
return factory.createExportSpecifier(false, void 0, typeof propertyName === "string" ? factory.createIdentifier(propertyName) : propertyName);
|
|
60
|
-
})), factory.createStringLiteral(path$1), void 0);
|
|
61
|
-
}
|
|
62
|
-
const typescriptParser = defineParser({
|
|
63
|
-
name: "typescript",
|
|
64
|
-
extNames: [".ts", ".js"],
|
|
65
|
-
install() {},
|
|
66
|
-
async parse(file, options = { extname: ".ts" }) {
|
|
67
|
-
const sourceParts = [];
|
|
68
|
-
for (const item of file.sources) if (item.value) sourceParts.push(item.value);
|
|
69
|
-
const source = sourceParts.join("\n\n");
|
|
70
|
-
const importNodes = [];
|
|
71
|
-
for (const item of file.imports) {
|
|
72
|
-
const importPath = item.root ? getRelativePath(item.root, item.path) : item.path;
|
|
73
|
-
const hasExtname = !!path.extname(importPath);
|
|
74
|
-
importNodes.push(createImport({
|
|
75
|
-
name: item.name,
|
|
76
|
-
path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,
|
|
77
|
-
isTypeOnly: item.isTypeOnly
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
80
|
-
const exportNodes = [];
|
|
81
|
-
for (const item of file.exports) {
|
|
82
|
-
const exportPath = item.path;
|
|
83
|
-
const hasExtname = !!path.extname(exportPath);
|
|
84
|
-
exportNodes.push(createExport({
|
|
85
|
-
name: item.name,
|
|
86
|
-
path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),
|
|
87
|
-
isTypeOnly: item.isTypeOnly,
|
|
88
|
-
asAlias: item.asAlias
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
return [
|
|
92
|
-
file.banner,
|
|
93
|
-
print(...importNodes, ...exportNodes),
|
|
94
|
-
source,
|
|
95
|
-
file.footer
|
|
96
|
-
].filter((segment) => segment != null).join("\n");
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
//#endregion
|
|
101
|
-
export { createExport, createImport, print, safePrint, typescriptParser, validateNodes };
|
|
102
|
-
//# sourceMappingURL=typescript.js.map
|
|
3
|
+
export { createExport, createImport, print, safePrint, typescriptParser, validateNodes };
|
package/dist/parsers.cjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
const require_getRelativePath = require('./getRelativePath-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_parsers_typescript = require('./parsers/typescript.cjs');
|
|
1
|
+
const require_getRelativePath = require('./getRelativePath-jYLCpluV.cjs');
|
|
2
|
+
const require_defaultParser = require('./defaultParser-2ym3KiZd.cjs');
|
|
3
|
+
const require_typescriptParser = require('./typescriptParser-qjzb2pIh.cjs');
|
|
5
4
|
|
|
6
5
|
//#region src/parsers/tsxParser.ts
|
|
7
|
-
const tsxParser =
|
|
6
|
+
const tsxParser = require_getRelativePath.defineParser({
|
|
8
7
|
name: "tsx",
|
|
9
8
|
extNames: [".tsx", ".jsx"],
|
|
10
9
|
install() {},
|
|
11
10
|
async parse(file, options = { extname: ".tsx" }) {
|
|
12
|
-
return
|
|
11
|
+
return require_typescriptParser.typescriptParser.parse(file, options);
|
|
13
12
|
}
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
//#endregion
|
|
17
16
|
exports.defaultParser = require_defaultParser.defaultParser;
|
|
18
|
-
exports.defineParser =
|
|
17
|
+
exports.defineParser = require_getRelativePath.defineParser;
|
|
19
18
|
exports.tsxParser = tsxParser;
|
|
20
|
-
exports.typescriptParser =
|
|
19
|
+
exports.typescriptParser = require_typescriptParser.typescriptParser;
|
|
21
20
|
//# sourceMappingURL=parsers.cjs.map
|
package/dist/parsers.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.cjs","names":["defineParser","typescriptParser"],"sources":["../src/parsers/tsxParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\nimport { typescriptParser } from './typescriptParser.ts'\n\nexport const tsxParser = defineParser({\n name: 'tsx',\n extNames: ['.tsx', '.jsx'],\n install() {},\n async parse(file, options = { extname: '.tsx' }) {\n return typescriptParser.parse(file, options)\n },\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parsers.cjs","names":["defineParser","typescriptParser"],"sources":["../src/parsers/tsxParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\nimport { typescriptParser } from './typescriptParser.ts'\n\nexport const tsxParser = defineParser({\n name: 'tsx',\n extNames: ['.tsx', '.jsx'],\n install() {},\n async parse(file, options = { extname: '.tsx' }) {\n return typescriptParser.parse(file, options)\n },\n})\n"],"mappings":";;;;;AAGA,MAAa,YAAYA,qCAAa;CACpC,MAAM;CACN,UAAU,CAAC,QAAQ,OAAO;CAC1B,UAAU;CACV,MAAM,MAAM,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAE;AAC/C,SAAOC,0CAAiB,MAAM,MAAM,QAAQ;;CAE/C,CAAC"}
|
package/dist/parsers.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as UserParser, N as __name, S as Parser } from "./Fabric-BbVC650D.cjs";
|
|
2
2
|
import { typescriptParser } from "./parsers/typescript.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/parsers/defaultParser.d.ts
|
package/dist/parsers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-8X4u0d05.js";
|
|
2
|
-
import {
|
|
2
|
+
import { C as UserParser, S as Parser } from "./Fabric-eh92yS1R.js";
|
|
3
3
|
import { typescriptParser } from "./parsers/typescript.js";
|
|
4
4
|
|
|
5
5
|
//#region src/parsers/defaultParser.d.ts
|
package/dist/parsers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-8X4u0d05.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as defaultParser } from "./defaultParser-
|
|
4
|
-
import { typescriptParser } from "./
|
|
2
|
+
import { n as defineParser } from "./getRelativePath-COUEoqbz.js";
|
|
3
|
+
import { t as defaultParser } from "./defaultParser-DDFR9BTS.js";
|
|
4
|
+
import { a as typescriptParser } from "./typescriptParser-DyosyI_A.js";
|
|
5
5
|
|
|
6
6
|
//#region src/parsers/tsxParser.ts
|
|
7
7
|
const tsxParser = defineParser({
|