@kubb/fabric-core 0.12.11 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{Fabric-CrRJykMN.d.ts → Fabric-CE-4sqCG.d.ts} +1 -4
- package/dist/{Fabric-DMmgrLto.d.cts → Fabric-efyCO1t7.d.ts} +2 -2
- package/dist/{RootContext-Cf7WJM7r.d.cts → RootContext-BgiMS39h.d.ts} +3 -3
- package/dist/{RootContext-CvaGJ-4g.d.ts → RootContext-CA-zkTEp.d.ts} +3 -4
- package/dist/{chunk-BVHe6Par.js → chunk-BYypO7fO.js} +1 -5
- package/dist/{chunk-DVipidnM.cjs → chunk-uaV2rQ02.cjs} +0 -10
- package/dist/{defaultParser-BK-zOanQ.cjs → defaultParser-BAgmtMo_.cjs} +2 -3
- package/dist/{defaultParser-BK-zOanQ.cjs.map → defaultParser-BAgmtMo_.cjs.map} +1 -1
- package/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
- package/dist/{defaultParser-BD_N68Bo.js.map → defaultParser-C1atU7yU.js.map} +1 -1
- package/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
- package/dist/{getRelativePath-C4Au07ON.js.map → getRelativePath-BcieQL5M.js.map} +1 -1
- package/dist/{getRelativePath-DpbA6qm5.cjs → getRelativePath-DVG8dIzW.cjs} +2 -2
- package/dist/{getRelativePath-DpbA6qm5.cjs.map → getRelativePath-DVG8dIzW.cjs.map} +1 -1
- package/dist/index.cjs +62 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/{Root-CKos-Ahf.cjs → onProcessExit-B7_bTfyR.cjs} +115 -213
- package/dist/onProcessExit-B7_bTfyR.cjs.map +1 -0
- package/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
- package/dist/onProcessExit-CF200hsz.js.map +1 -0
- package/dist/parsers/typescript.cjs +4 -4
- package/dist/parsers/typescript.cjs.map +1 -1
- package/dist/parsers/typescript.d.ts +1 -2
- package/dist/parsers/typescript.js +3 -4
- package/dist/parsers/typescript.js.map +1 -1
- package/dist/parsers.cjs +2 -3
- package/dist/parsers.cjs.map +1 -1
- package/dist/parsers.d.ts +1 -2
- package/dist/parsers.js +2 -3
- package/dist/parsers.js.map +1 -1
- package/dist/plugins.cjs +61 -305
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.ts +9 -40
- package/dist/plugins.js +58 -298
- package/dist/plugins.js.map +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.ts +3 -4
- package/dist/types.js +1 -1
- package/dist/{useNodeTree-CgEKFUV-.d.cts → useNodeTree-BpHR6gQx.d.ts} +2 -2
- package/dist/{useNodeTree-CamNuFQP.d.ts → useNodeTree-DuQ5Df0t.d.ts} +2 -3
- package/package.json +8 -18
- package/src/FileManager.ts +6 -2
- package/src/createFile.ts +12 -9
- package/src/index.ts +3 -2
- package/src/plugins/fsPlugin.ts +8 -6
- package/src/plugins/fsxPlugin/Runtime.ts +4 -7
- package/src/plugins/index.ts +0 -1
- package/src/plugins/loggerPlugin.ts +15 -192
- package/src/utils/onProcessExit.ts +35 -0
- package/dist/Root-BQX3eHqb.js.map +0 -1
- package/dist/Root-CKos-Ahf.cjs.map +0 -1
- package/dist/index.d.cts +0 -595
- package/dist/parsers/typescript.d.cts +0 -45
- package/dist/parsers.d.cts +0 -37
- package/dist/plugins.d.cts +0 -149
- package/dist/types.d.cts +0 -11
- package/src/plugins/graphPlugin.ts +0 -136
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onProcessExit-B7_bTfyR.cjs","names":["path","trimExtName","#emitter","#mode","NodeEventEmitter","defaultParser","#limit","#buffer","#resolveName","#resolvePath","#cache","#filesCache","trimExtName","#childrenMap","#cachedLeaves"],"sources":["../src/context.ts","../src/contexts/NodeTreeContext.ts","../src/createFile.ts","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.ts","../src/utils/TreeNode.ts","../src/contexts/RootContext.ts","../src/contexts/RenderContext.ts","../src/intrinsic.ts","../src/createComponent.ts","../src/components/Root.ts","../src/utils/onProcessExit.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 { 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 { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { sortBy, uniqueBy } from 'remeda'\nimport type * as KubbFile from './KubbFile.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => {\n // For named sources, deduplicate by name, isExportable, and isTypeOnly\n // For unnamed sources, include the value to avoid deduplicating different code blocks\n // If both name and value are undefined, use an empty string as the unique identifier\n const uniqueId = obj.name ?? obj.value ?? ''\n const isExportable = obj.isExportable ?? false\n const isTypeOnly = obj.isTypeOnly ?? false\n return `${uniqueId}:${isExportable}:${isTypeOnly}`\n })\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n const sorted = sortBy(\n exports,\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n // join with null byte — can't appear in identifiers, so avoids collisions between e.g. ['a','b'] and ['a,b']\n (v) => (Array.isArray(v.name) ? [...v.name].sort().join('\\0') : (v.name ?? '')),\n )\n\n const prev: Array<KubbFile.Export> = []\n // Map to track items by path for O(1) lookup\n const pathMap = new Map<string, KubbFile.Export>()\n // Map to track unique items by path+name+isTypeOnly+asAlias\n const uniqueMap = new Map<string, KubbFile.Export>()\n\n for (const curr of sorted) {\n const name = curr.name\n const pathKey = curr.path\n const prevByPath = pathMap.get(pathKey)\n\n // Create unique key for path+name+isTypeOnly\n const nameKey = Array.isArray(name) ? JSON.stringify(name) : name || ''\n const pathNameTypeKey = `${pathKey}:${nameKey}:${curr.isTypeOnly}`\n\n // Create unique key for path+name+isTypeOnly+asAlias\n const uniqueKey = `${pathNameTypeKey}:${curr.asAlias || ''}`\n const uniquePrev = uniqueMap.get(uniqueKey)\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n continue\n }\n\n if (!prevByPath) {\n const newItem = {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n }\n prev.push(newItem)\n pathMap.set(pathKey, newItem)\n uniqueMap.set(uniqueKey, newItem)\n continue\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n continue\n }\n\n prev.push(curr)\n uniqueMap.set(uniqueKey, curr)\n }\n\n return prev\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n const exportedNameLookup = new Set<string>()\n for (const item of exports) {\n const { name } = item\n if (!name) {\n continue\n }\n\n if (Array.isArray(name)) {\n for (const value of name) {\n if (value) {\n exportedNameLookup.add(value)\n }\n }\n continue\n }\n\n exportedNameLookup.add(name)\n }\n\n const usageCache = new Map<string, boolean>()\n const hasImportInSource = (importName: string): boolean => {\n if (!source) {\n return true\n }\n\n const cached = usageCache.get(importName)\n if (cached !== undefined) {\n return cached\n }\n\n const isUsed = source.includes(importName) || exportedNameLookup.has(importName)\n usageCache.set(importName, isUsed)\n\n return isUsed\n }\n\n const sorted = sortBy(\n imports,\n (v) => Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n // join with null byte — can't appear in identifiers, so avoids collisions between e.g. ['a','b'] and ['a,b']\n (v) => (Array.isArray(v.name) ? [...v.name].sort().join('\\0') : (v.name ?? '')),\n )\n\n const prev: Array<KubbFile.Import> = []\n // Map to track items by path+isTypeOnly for O(1) lookup\n const pathTypeMap = new Map<string, KubbFile.Import>()\n // Map to track unique items by path+name+isTypeOnly\n const uniqueMap = new Map<string, KubbFile.Import>()\n\n for (const curr of sorted) {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n continue\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const pathTypeKey = `${curr.path}:${curr.isTypeOnly}`\n const prevByPath = pathTypeMap.get(pathTypeKey)\n\n // Create key for name comparison\n const nameKey = Array.isArray(name) ? JSON.stringify(name) : name || ''\n const pathNameTypeKey = `${curr.path}:${nameKey}:${curr.isTypeOnly}`\n const uniquePrev = uniqueMap.get(pathNameTypeKey)\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n continue\n }\n\n // new item, append name\n if (!prevByPath) {\n const newItem = {\n ...curr,\n name,\n }\n prev.push(newItem)\n pathTypeMap.set(pathTypeKey, newItem)\n uniqueMap.set(pathNameTypeKey, newItem)\n continue\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n continue\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n continue\n }\n\n prev.push(curr)\n uniqueMap.set(pathNameTypeKey, curr)\n }\n\n return prev\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: createHash('sha256').update(file.path).digest('hex'),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\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 { sortBy } from 'remeda'\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 = sortBy(\n cachedKeys,\n (v) => v.length,\n (v) => trimExtName(v).endsWith('index'),\n )\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 * 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 { 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","import { createContext } from '../context.ts'\n\nexport type RenderContextProps = {\n indentLevel: number\n indentSize: number\n currentLineLength: number\n shouldBreak: boolean\n}\n\n/**\n * Provides a context for tracking rendering state such as indentation and line length.\n */\nexport const RenderContext = createContext<RenderContextProps>({ indentLevel: 0, indentSize: 2, currentLineLength: 0, shouldBreak: false })\n","import { inject, provide } from './context.ts'\nimport { RenderContext, type RenderContextProps } from './contexts/RenderContext.ts'\nimport type { FabricElement, FabricNode } from './Fabric.ts'\n\ntype IntrinsicType =\n | 'br' // Line break - adds newline with current indentation\n | 'indent' // Increase indentation level\n | 'dedent' // Decrease indentation level\n\nexport type Intrinsic = {\n type: IntrinsicType\n __intrinsic: true\n}\n\nfunction isFabricElement<TProps extends object = object>(value: any): value is FabricElement<TProps> {\n return typeof value === 'function' && 'type' in value && 'component' in value\n}\n\n/**\n * Type guard to check if a value is an intrinsic element\n */\nexport function isIntrinsic(value: any): value is Intrinsic {\n return value && typeof value === 'object' && value.__intrinsic === true\n}\n\n/**\n * Render a single intrinsic node\n */\nfunction renderIntrinsicNode(node: Intrinsic, renderContext: RenderContextProps): string {\n switch (node.type) {\n case 'br':\n renderContext.currentLineLength = 0\n return '\\n'\n\n case 'indent':\n renderContext.indentLevel++\n return ''\n\n case 'dedent':\n renderContext.indentLevel = Math.max(0, renderContext.indentLevel - 1)\n return ''\n\n default:\n return ''\n }\n}\n\n/**\n * Helper: render a plain string while applying current indentation at the\n * start of each logical line. This ensures `${indent}` intrinsics affect\n * subsequent string content.\n */\nexport function renderIndent(content: string, renderContext: RenderContextProps): string {\n if (content.length === 0) {\n return ''\n }\n\n const indentStr = ' '.repeat(renderContext.indentLevel * renderContext.indentSize)\n const lines = content.split('\\n')\n let out = ''\n\n for (const [i, line] of lines.entries()) {\n if (renderContext.currentLineLength === 0 && line.length > 0) {\n // At start of a (logical) line: prefix indentation\n out += indentStr + line\n renderContext.currentLineLength = indentStr.length + line.length\n } else {\n out += line\n renderContext.currentLineLength += line.length\n }\n\n // If not the last line, add newline and reset line length so next line gets indentation\n if (i !== lines.length - 1) {\n out += '\\n'\n renderContext.currentLineLength = 0\n }\n }\n\n return out\n}\n\nexport function renderIntrinsic(children: FabricNode, context?: RenderContextProps): string {\n const renderContext = context || inject(RenderContext)\n\n provide(RenderContext, renderContext)\n\n if (!children) {\n return ''\n }\n\n if (isFabricElement(children)) {\n try {\n // FabricElements are already wrapped in transform by createComponent\n // Just call them and return the result (which is already a string)\n const result = children()\n return renderIntrinsic(result)\n } catch {\n return ''\n }\n }\n\n if (Array.isArray(children)) {\n return children.map((child) => renderIntrinsic(child)).join('')\n }\n\n if (isIntrinsic(children)) {\n // Render intrinsic node(s) using the shared render context\n return renderIntrinsicNode(children, renderContext)\n }\n\n if (typeof children === 'function') {\n return renderIntrinsic(children())\n }\n\n if (typeof children === 'string') {\n return renderIndent(children, renderContext)\n }\n\n if (typeof children === 'number') {\n return renderIndent(String(children), renderContext)\n }\n\n if (typeof children === 'boolean') {\n return renderIndent(children ? 'true' : 'false', renderContext)\n }\n\n // Fallback for FabricElement/object-like values\n try {\n return renderIndent(children, renderContext)\n } catch {\n return ''\n }\n}\n\n/**\n * Create an intrinsic element\n */\nexport function createIntrinsic(type: IntrinsicType): Intrinsic {\n return {\n type,\n __intrinsic: true,\n }\n}\n","import type { FabricComponent, FabricElement, FabricNode } from './Fabric.ts'\nimport { renderIntrinsic } from './intrinsic.ts'\n\ntype MakeChildrenOptional<T extends object> = T extends { children?: any } ? Omit<T, 'children'> & Partial<Pick<T, 'children'>> : T\n\nexport type ComponentBuilder<T extends object> = {\n (...args: unknown extends T ? [] : {} extends Omit<T, 'children'> ? [props?: MakeChildrenOptional<T>] : [props: MakeChildrenOptional<T>]): FabricComponent<T>\n displayName?: string | undefined\n}\n\nexport function createComponent<TProps extends object>(type: string, Component: (props: TProps) => FabricNode): ComponentBuilder<TProps> {\n return (...args) => {\n const fn: FabricComponent<TProps> = (() => renderIntrinsic(Component(args[0] as TProps) as FabricNode)) as any\n fn.component = Component\n fn.props = args[0]! as TProps\n fn.type = type\n fn.children = (...children: Array<FabricNode>) => {\n const propsWithChildren = {\n ...(args[0] ?? {}),\n children() {\n return renderIntrinsic(children)\n },\n } as unknown as TProps\n\n const fnChild = (() => renderIntrinsic(Component(propsWithChildren) as FabricNode)) as FabricElement<TProps>\n fnChild.component = Component\n fnChild.props = args[0]! as TProps\n fnChild.type = type\n return fnChild\n }\n\n return fn\n }\n}\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 { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport type { FileManager } from '../FileManager.ts'\nimport type { TreeNode } from '../utils/TreeNode.ts'\n\nexport type RootProps = {\n /**\n * Callback to exit the Fabric application.\n *\n * Call this to stop rendering and clean up resources.\n */\n onExit: (error?: Error) => void\n /**\n * Error handler for runtime exceptions.\n *\n * Receives errors thrown during component rendering.\n */\n onError: (error: Error) => void\n /**\n * Tree structure representing the component hierarchy.\n *\n * Used internally for tracking component relationships.\n */\n treeNode: TreeNode<ComponentNode>\n /**\n * FileManager instance for file operations.\n *\n * Manages all files created during rendering.\n */\n fileManager: FileManager\n /**\n * Child components.\n */\n children?: FabricNode\n}\n\n/**\n * Root component providing core Fabric runtime context.\n *\n * This component is typically used internally by the Fabric renderer.\n * It provides the root context including FileManager, error handling,\n * and lifecycle management.\n *\n * @example\n * ```tsx\n * <Root\n * onExit={(error) => process.exit(error ? 1 : 0)}\n * onError={(error) => console.error(error)}\n * treeNode={treeNode}\n * fileManager={fileManager}\n * >\n * <App>\n * Your components here\n * </App>\n * </Root>\n * ```\n */\nexport const Root = createComponent('Root', ({ onError, onExit, treeNode, fileManager, children }: RootProps) => {\n provide(RootContext, { exit: onExit, treeNode, fileManager })\n provide(NodeTreeContext, treeNode)\n\n try {\n return children\n } catch (e) {\n if (e instanceof Error) {\n onError?.(e)\n }\n return ''\n }\n})\n\nRoot.displayName = 'Root'\n","const SIGNALS: NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGHUP']\n\n/**\n * Register a callback to run when the process exits (via exit event or common signals).\n * Returns an unsubscribe function.\n */\nexport function onProcessExit(callback: (code: number | null) => void): () => void {\n const exitHandler = (code: number) => callback(code)\n\n const signalHandlers = new Map<NodeJS.Signals, () => void>()\n\n for (const signal of SIGNALS) {\n const handler = () => {\n unsubscribe()\n try {\n callback(null)\n } finally {\n process.kill(process.pid, signal)\n }\n }\n signalHandlers.set(signal, handler)\n process.on(signal, handler)\n }\n\n process.on('exit', exitHandler)\n\n function unsubscribe() {\n process.removeListener('exit', exitHandler)\n for (const [signal, handler] of signalHandlers) {\n process.removeListener(signal, handler)\n }\n }\n\n return unsubscribe\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,MAAM,+BAAe,IAAI,KAAwB;AACjD,MAAM,kCAAkB,IAAI,KAAsB;;;;;;;;;;AAWlD,SAAgB,QAAW,KAA0B,OAAgB;AACnE,KAAI,CAAC,aAAa,IAAI,IAAI,CACxB,cAAa,IAAI,KAAK,EAAE,CAAC;AAE3B,cAAa,IAAI,IAAI,CAAE,KAAK,MAAM;;;;;;;;;;AAWpC,SAAgB,OAAU,KAA0B,cAAqB;CACvE,MAAM,QAAQ,aAAa,IAAI,IAAI;AACnC,KAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAChC,MAAI,iBAAiB,OACnB,QAAO;EAET,MAAM,gBAAgB,gBAAgB,IAAI,IAAI;AAC9C,MAAI,kBAAkB,OACpB,QAAO;AAET,QAAM,IAAI,MAAM,8BAA8B,IAAI,UAAU,GAAG;;AAEjE,QAAO,MAAM,MAAM,SAAS;;;;;;AAO9B,SAAgB,UAAa,KAAgC;CAC3D,MAAM,QAAQ,aAAa,IAAI,IAAI;AACnC,KAAI,SAAS,MAAM,SAAS,EAC1B,OAAM,KAAK;;;;;;;;;;;;AAcf,SAAgB,cAAiB,cAA6B;CAC5D,MAAM,MAA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
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { orderBy } from "natural-orderby";
|
|
1
|
+
import { r as trimExtName } from "./getRelativePath-BcieQL5M.js";
|
|
2
|
+
import { t as defaultParser } from "./defaultParser-C1atU7yU.js";
|
|
3
|
+
import { sortBy, uniqueBy } from "remeda";
|
|
5
4
|
import { createHash } from "node:crypto";
|
|
6
5
|
import path from "node:path";
|
|
7
|
-
import { uniqueBy } from "remeda";
|
|
8
6
|
import pLimit from "p-limit";
|
|
9
7
|
import { EventEmitter } from "node:events";
|
|
10
8
|
|
|
@@ -84,21 +82,11 @@ const NodeTreeContext = createContext(null);
|
|
|
84
82
|
//#region src/createFile.ts
|
|
85
83
|
function combineSources(sources) {
|
|
86
84
|
return uniqueBy(sources, (obj) => {
|
|
87
|
-
|
|
88
|
-
var _obj$name;
|
|
89
|
-
var _obj$isExportable;
|
|
90
|
-
var _obj$isTypeOnly;
|
|
91
|
-
return `${(_ref = (_obj$name = obj.name) !== null && _obj$name !== void 0 ? _obj$name : obj.value) !== null && _ref !== void 0 ? _ref : ""}:${(_obj$isExportable = obj.isExportable) !== null && _obj$isExportable !== void 0 ? _obj$isExportable : false}:${(_obj$isTypeOnly = obj.isTypeOnly) !== null && _obj$isTypeOnly !== void 0 ? _obj$isTypeOnly : false}`;
|
|
85
|
+
return `${obj.name ?? obj.value ?? ""}:${obj.isExportable ?? false}:${obj.isTypeOnly ?? false}`;
|
|
92
86
|
});
|
|
93
87
|
}
|
|
94
88
|
function combineExports(exports) {
|
|
95
|
-
const sorted =
|
|
96
|
-
(v) => !!Array.isArray(v.name),
|
|
97
|
-
(v) => !v.isTypeOnly,
|
|
98
|
-
(v) => v.path,
|
|
99
|
-
(v) => !!v.name,
|
|
100
|
-
(v) => Array.isArray(v.name) ? orderBy(v.name) : v.name
|
|
101
|
-
]);
|
|
89
|
+
const sorted = sortBy(exports, (v) => !!Array.isArray(v.name), (v) => !v.isTypeOnly, (v) => v.path, (v) => !!v.name, (v) => Array.isArray(v.name) ? [...v.name].sort().join("\0") : v.name ?? "");
|
|
102
90
|
const prev = [];
|
|
103
91
|
const pathMap = /* @__PURE__ */ new Map();
|
|
104
92
|
const uniqueMap = /* @__PURE__ */ new Map();
|
|
@@ -107,7 +95,7 @@ function combineExports(exports) {
|
|
|
107
95
|
const pathKey = curr.path;
|
|
108
96
|
const prevByPath = pathMap.get(pathKey);
|
|
109
97
|
const uniqueKey = `${`${pathKey}:${Array.isArray(name) ? JSON.stringify(name) : name || ""}:${curr.isTypeOnly}`}:${curr.asAlias || ""}`;
|
|
110
|
-
if (uniqueMap.get(uniqueKey) || Array.isArray(name) && !name.length ||
|
|
98
|
+
if (uniqueMap.get(uniqueKey) || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) continue;
|
|
111
99
|
if (!prevByPath) {
|
|
112
100
|
const newItem = {
|
|
113
101
|
...curr,
|
|
@@ -147,13 +135,7 @@ function combineImports(imports, exports, source) {
|
|
|
147
135
|
usageCache.set(importName, isUsed);
|
|
148
136
|
return isUsed;
|
|
149
137
|
};
|
|
150
|
-
const sorted =
|
|
151
|
-
(v) => !!Array.isArray(v.name),
|
|
152
|
-
(v) => !v.isTypeOnly,
|
|
153
|
-
(v) => v.path,
|
|
154
|
-
(v) => !!v.name,
|
|
155
|
-
(v) => Array.isArray(v.name) ? orderBy(v.name) : v.name
|
|
156
|
-
]);
|
|
138
|
+
const sorted = sortBy(imports, (v) => Array.isArray(v.name), (v) => !v.isTypeOnly, (v) => v.path, (v) => !!v.name, (v) => Array.isArray(v.name) ? [...v.name].sort().join("\0") : v.name ?? "");
|
|
157
139
|
const prev = [];
|
|
158
140
|
const pathTypeMap = /* @__PURE__ */ new Map();
|
|
159
141
|
const uniqueMap = /* @__PURE__ */ new Map();
|
|
@@ -190,15 +172,12 @@ function combineImports(imports, exports, source) {
|
|
|
190
172
|
* Helper to create a file with name and id set
|
|
191
173
|
*/
|
|
192
174
|
function createFile(file) {
|
|
193
|
-
var _file$exports;
|
|
194
|
-
var _file$imports;
|
|
195
|
-
var _file$sources;
|
|
196
175
|
const extname = path.extname(file.baseName);
|
|
197
176
|
if (!extname) throw new Error(`No extname found for ${file.baseName}`);
|
|
198
177
|
const source = file.sources.map((item) => item.value).join("\n\n");
|
|
199
|
-
const exports =
|
|
200
|
-
const imports =
|
|
201
|
-
const sources =
|
|
178
|
+
const exports = file.exports?.length ? combineExports(file.exports) : [];
|
|
179
|
+
const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : [];
|
|
180
|
+
const sources = file.sources?.length ? combineSources(file.sources) : [];
|
|
202
181
|
return {
|
|
203
182
|
...file,
|
|
204
183
|
id: createHash("sha256").update(file.path).digest("hex"),
|
|
@@ -211,53 +190,20 @@ function createFile(file) {
|
|
|
211
190
|
};
|
|
212
191
|
}
|
|
213
192
|
|
|
214
|
-
//#endregion
|
|
215
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/checkPrivateRedeclaration.js
|
|
216
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
217
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldInitSpec.js
|
|
222
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
223
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
//#endregion
|
|
227
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/assertClassBrand.js
|
|
228
|
-
function _assertClassBrand(e, t, n) {
|
|
229
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
230
|
-
throw new TypeError("Private element is not present on this object");
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldGet2.js
|
|
235
|
-
function _classPrivateFieldGet2(s, a) {
|
|
236
|
-
return s.get(_assertClassBrand(s, a));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
//#endregion
|
|
240
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldSet2.js
|
|
241
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
242
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
193
|
//#endregion
|
|
246
194
|
//#region src/utils/AsyncEventEmitter.ts
|
|
247
|
-
var _emitter = /* @__PURE__ */ new WeakMap();
|
|
248
|
-
var _mode = /* @__PURE__ */ new WeakMap();
|
|
249
195
|
var AsyncEventEmitter = class {
|
|
250
196
|
constructor({ maxListener = 100, mode = "sequential" } = {}) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
_classPrivateFieldGet2(_emitter, this).setMaxListeners(maxListener);
|
|
254
|
-
_classPrivateFieldSet2(_mode, this, mode);
|
|
197
|
+
this.#emitter.setMaxListeners(maxListener);
|
|
198
|
+
this.#mode = mode;
|
|
255
199
|
}
|
|
200
|
+
#emitter = new EventEmitter();
|
|
201
|
+
#mode;
|
|
256
202
|
async emit(eventName, ...eventArgs) {
|
|
257
|
-
const listeners =
|
|
203
|
+
const listeners = this.#emitter.listeners(eventName);
|
|
258
204
|
if (listeners.length === 0) return;
|
|
259
205
|
const errors = [];
|
|
260
|
-
if (
|
|
206
|
+
if (this.#mode === "sequential") for (const listener of listeners) try {
|
|
261
207
|
await listener(...eventArgs);
|
|
262
208
|
} catch (err) {
|
|
263
209
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
@@ -278,7 +224,7 @@ var AsyncEventEmitter = class {
|
|
|
278
224
|
if (errors.length > 1) throw new AggregateError(errors, `Errors in async listeners for "${eventName}"`);
|
|
279
225
|
}
|
|
280
226
|
on(eventName, handler) {
|
|
281
|
-
|
|
227
|
+
this.#emitter.on(eventName, handler);
|
|
282
228
|
}
|
|
283
229
|
onOnce(eventName, handler) {
|
|
284
230
|
const wrapper = (...args) => {
|
|
@@ -288,67 +234,24 @@ var AsyncEventEmitter = class {
|
|
|
288
234
|
this.on(eventName, wrapper);
|
|
289
235
|
}
|
|
290
236
|
off(eventName, handler) {
|
|
291
|
-
|
|
237
|
+
this.#emitter.off(eventName, handler);
|
|
292
238
|
}
|
|
293
239
|
removeAll() {
|
|
294
|
-
|
|
240
|
+
this.#emitter.removeAllListeners();
|
|
295
241
|
}
|
|
296
242
|
};
|
|
297
243
|
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/typeof.js
|
|
300
|
-
function _typeof(o) {
|
|
301
|
-
"@babel/helpers - typeof";
|
|
302
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
303
|
-
return typeof o;
|
|
304
|
-
} : function(o) {
|
|
305
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
306
|
-
}, _typeof(o);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/toPrimitive.js
|
|
311
|
-
function toPrimitive(t, r) {
|
|
312
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
313
|
-
var e = t[Symbol.toPrimitive];
|
|
314
|
-
if (void 0 !== e) {
|
|
315
|
-
var i = e.call(t, r || "default");
|
|
316
|
-
if ("object" != _typeof(i)) return i;
|
|
317
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
318
|
-
}
|
|
319
|
-
return ("string" === r ? String : Number)(t);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/toPropertyKey.js
|
|
324
|
-
function toPropertyKey(t) {
|
|
325
|
-
var i = toPrimitive(t, "string");
|
|
326
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
//#endregion
|
|
330
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/defineProperty.js
|
|
331
|
-
function _defineProperty(e, r, t) {
|
|
332
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
333
|
-
value: t,
|
|
334
|
-
enumerable: !0,
|
|
335
|
-
configurable: !0,
|
|
336
|
-
writable: !0
|
|
337
|
-
}) : e[r] = t, e;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
244
|
//#endregion
|
|
341
245
|
//#region src/FileProcessor.ts
|
|
342
|
-
var _limit = /* @__PURE__ */ new WeakMap();
|
|
343
246
|
var FileProcessor = class {
|
|
247
|
+
#limit = pLimit(100);
|
|
248
|
+
events;
|
|
344
249
|
constructor({ events = new AsyncEventEmitter() } = {}) {
|
|
345
|
-
_classPrivateFieldInitSpec(this, _limit, pLimit(100));
|
|
346
|
-
_defineProperty(this, "events", void 0);
|
|
347
250
|
this.events = events;
|
|
348
251
|
return this;
|
|
349
252
|
}
|
|
350
253
|
async parse(file, { parsers, extension } = {}) {
|
|
351
|
-
const parseExtName =
|
|
254
|
+
const parseExtName = extension?.[file.extname] || void 0;
|
|
352
255
|
if (!parsers) {
|
|
353
256
|
console.warn("No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.");
|
|
354
257
|
return defaultParser.parse(file, { extname: parseExtName });
|
|
@@ -385,7 +288,7 @@ var FileProcessor = class {
|
|
|
385
288
|
}
|
|
386
289
|
for await (const [file, index] of asyncFiles()) if (file) await processOne(file, index);
|
|
387
290
|
} else {
|
|
388
|
-
const promises = files.map((resolvedFile, index) =>
|
|
291
|
+
const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)));
|
|
389
292
|
await Promise.all(promises);
|
|
390
293
|
}
|
|
391
294
|
await this.events.emit("files:processing:end", files);
|
|
@@ -395,39 +298,29 @@ var FileProcessor = class {
|
|
|
395
298
|
|
|
396
299
|
//#endregion
|
|
397
300
|
//#region src/utils/Cache.ts
|
|
398
|
-
var _buffer = /* @__PURE__ */ new WeakMap();
|
|
399
301
|
var Cache = class {
|
|
400
|
-
|
|
401
|
-
_classPrivateFieldInitSpec(this, _buffer, /* @__PURE__ */ new Map());
|
|
402
|
-
}
|
|
302
|
+
#buffer = /* @__PURE__ */ new Map();
|
|
403
303
|
get(key) {
|
|
404
|
-
|
|
405
|
-
return (_this$buffer$get = _classPrivateFieldGet2(_buffer, this).get(key)) !== null && _this$buffer$get !== void 0 ? _this$buffer$get : null;
|
|
304
|
+
return this.#buffer.get(key) ?? null;
|
|
406
305
|
}
|
|
407
306
|
set(key, value) {
|
|
408
|
-
|
|
307
|
+
this.#buffer.set(key, value);
|
|
409
308
|
}
|
|
410
309
|
delete(key) {
|
|
411
|
-
|
|
310
|
+
this.#buffer.delete(key);
|
|
412
311
|
}
|
|
413
312
|
clear() {
|
|
414
|
-
|
|
313
|
+
this.#buffer.clear();
|
|
415
314
|
}
|
|
416
315
|
keys() {
|
|
417
|
-
return [...
|
|
316
|
+
return [...this.#buffer.keys()];
|
|
418
317
|
}
|
|
419
318
|
values() {
|
|
420
|
-
return [...
|
|
319
|
+
return [...this.#buffer.values()];
|
|
421
320
|
}
|
|
422
321
|
flush() {}
|
|
423
322
|
};
|
|
424
323
|
|
|
425
|
-
//#endregion
|
|
426
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateMethodInitSpec.js
|
|
427
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
428
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
324
|
//#endregion
|
|
432
325
|
//#region src/FileManager.ts
|
|
433
326
|
function mergeFile(a, b) {
|
|
@@ -438,20 +331,24 @@ function mergeFile(a, b) {
|
|
|
438
331
|
exports: [...a.exports || [], ...b.exports || []]
|
|
439
332
|
};
|
|
440
333
|
}
|
|
441
|
-
var _cache = /* @__PURE__ */ new WeakMap();
|
|
442
|
-
var _filesCache = /* @__PURE__ */ new WeakMap();
|
|
443
|
-
var _FileManager_brand = /* @__PURE__ */ new WeakSet();
|
|
444
334
|
var FileManager = class {
|
|
335
|
+
#cache = new Cache();
|
|
336
|
+
#filesCache = null;
|
|
337
|
+
events;
|
|
338
|
+
processor;
|
|
445
339
|
constructor({ events = new AsyncEventEmitter() } = {}) {
|
|
446
|
-
_classPrivateMethodInitSpec(this, _FileManager_brand);
|
|
447
|
-
_classPrivateFieldInitSpec(this, _cache, new Cache());
|
|
448
|
-
_classPrivateFieldInitSpec(this, _filesCache, null);
|
|
449
|
-
_defineProperty(this, "events", void 0);
|
|
450
|
-
_defineProperty(this, "processor", void 0);
|
|
451
340
|
this.processor = new FileProcessor({ events });
|
|
452
341
|
this.events = events;
|
|
453
342
|
return this;
|
|
454
343
|
}
|
|
344
|
+
#resolvePath(file) {
|
|
345
|
+
this.events.emit("file:resolve:path", file);
|
|
346
|
+
return file;
|
|
347
|
+
}
|
|
348
|
+
#resolveName(file) {
|
|
349
|
+
this.events.emit("file:resolve:name", file);
|
|
350
|
+
return file;
|
|
351
|
+
}
|
|
455
352
|
add(...files) {
|
|
456
353
|
const resolvedFiles = [];
|
|
457
354
|
const mergedFiles = /* @__PURE__ */ new Map();
|
|
@@ -461,10 +358,10 @@ var FileManager = class {
|
|
|
461
358
|
else mergedFiles.set(file.path, file);
|
|
462
359
|
});
|
|
463
360
|
for (let file of mergedFiles.values()) {
|
|
464
|
-
file =
|
|
465
|
-
file =
|
|
361
|
+
file = this.#resolveName(file);
|
|
362
|
+
file = this.#resolvePath(file);
|
|
466
363
|
const resolvedFile = createFile(file);
|
|
467
|
-
|
|
364
|
+
this.#cache.set(resolvedFile.path, resolvedFile);
|
|
468
365
|
this.flush();
|
|
469
366
|
resolvedFiles.push(resolvedFile);
|
|
470
367
|
}
|
|
@@ -480,11 +377,11 @@ var FileManager = class {
|
|
|
480
377
|
else mergedFiles.set(file.path, file);
|
|
481
378
|
});
|
|
482
379
|
for (let file of mergedFiles.values()) {
|
|
483
|
-
const existing =
|
|
484
|
-
file =
|
|
485
|
-
file =
|
|
380
|
+
const existing = this.#cache.get(file.path);
|
|
381
|
+
file = this.#resolveName(file);
|
|
382
|
+
file = this.#resolvePath(file);
|
|
486
383
|
const resolvedFile = createFile(existing ? mergeFile(existing, file) : file);
|
|
487
|
-
|
|
384
|
+
this.#cache.set(resolvedFile.path, resolvedFile);
|
|
488
385
|
this.flush();
|
|
489
386
|
resolvedFiles.push(resolvedFile);
|
|
490
387
|
}
|
|
@@ -492,29 +389,29 @@ var FileManager = class {
|
|
|
492
389
|
return resolvedFiles;
|
|
493
390
|
}
|
|
494
391
|
flush() {
|
|
495
|
-
|
|
496
|
-
|
|
392
|
+
this.#filesCache = null;
|
|
393
|
+
this.#cache.flush();
|
|
497
394
|
}
|
|
498
395
|
getByPath(path) {
|
|
499
|
-
return
|
|
396
|
+
return this.#cache.get(path);
|
|
500
397
|
}
|
|
501
398
|
deleteByPath(path) {
|
|
502
|
-
|
|
503
|
-
|
|
399
|
+
this.#cache.delete(path);
|
|
400
|
+
this.#filesCache = null;
|
|
504
401
|
}
|
|
505
402
|
clear() {
|
|
506
|
-
|
|
507
|
-
|
|
403
|
+
this.#cache.clear();
|
|
404
|
+
this.#filesCache = null;
|
|
508
405
|
}
|
|
509
406
|
get files() {
|
|
510
|
-
if (
|
|
511
|
-
const keys =
|
|
407
|
+
if (this.#filesCache) return this.#filesCache;
|
|
408
|
+
const keys = sortBy(this.#cache.keys(), (v) => v.length, (v) => trimExtName(v).endsWith("index"));
|
|
512
409
|
const files = [];
|
|
513
410
|
for (const key of keys) {
|
|
514
|
-
const file =
|
|
411
|
+
const file = this.#cache.get(key);
|
|
515
412
|
if (file) files.push(file);
|
|
516
413
|
}
|
|
517
|
-
|
|
414
|
+
this.#filesCache = files;
|
|
518
415
|
return files;
|
|
519
416
|
}
|
|
520
417
|
async write(options) {
|
|
@@ -525,41 +422,31 @@ var FileManager = class {
|
|
|
525
422
|
return resolvedFiles;
|
|
526
423
|
}
|
|
527
424
|
};
|
|
528
|
-
function _resolvePath(file) {
|
|
529
|
-
this.events.emit("file:resolve:path", file);
|
|
530
|
-
return file;
|
|
531
|
-
}
|
|
532
|
-
function _resolveName(file) {
|
|
533
|
-
this.events.emit("file:resolve:name", file);
|
|
534
|
-
return file;
|
|
535
|
-
}
|
|
536
425
|
|
|
537
426
|
//#endregion
|
|
538
427
|
//#region src/utils/TreeNode.ts
|
|
539
|
-
var _childrenMap = /* @__PURE__ */ new WeakMap();
|
|
540
|
-
var _cachedLeaves = /* @__PURE__ */ new WeakMap();
|
|
541
428
|
var TreeNode = class TreeNode {
|
|
429
|
+
data;
|
|
430
|
+
parent;
|
|
431
|
+
children = [];
|
|
432
|
+
#childrenMap = /* @__PURE__ */ new Map();
|
|
433
|
+
#cachedLeaves;
|
|
542
434
|
constructor(data, parent) {
|
|
543
|
-
_defineProperty(this, "data", void 0);
|
|
544
|
-
_defineProperty(this, "parent", void 0);
|
|
545
|
-
_defineProperty(this, "children", []);
|
|
546
|
-
_classPrivateFieldInitSpec(this, _childrenMap, /* @__PURE__ */ new Map());
|
|
547
|
-
_classPrivateFieldInitSpec(this, _cachedLeaves, void 0);
|
|
548
435
|
this.data = data;
|
|
549
436
|
this.parent = parent;
|
|
550
437
|
}
|
|
551
438
|
addChild(data) {
|
|
552
439
|
const child = new TreeNode(data, this);
|
|
553
440
|
this.children.push(child);
|
|
554
|
-
if (typeof data === "object" && data !== null && "name" in data)
|
|
555
|
-
|
|
441
|
+
if (typeof data === "object" && data !== null && "name" in data) this.#childrenMap.set(data.name, child);
|
|
442
|
+
this.#cachedLeaves = void 0;
|
|
556
443
|
return child;
|
|
557
444
|
}
|
|
558
445
|
getChildByName(name) {
|
|
559
|
-
return
|
|
446
|
+
return this.#childrenMap.get(name);
|
|
560
447
|
}
|
|
561
448
|
get leaves() {
|
|
562
|
-
if (
|
|
449
|
+
if (this.#cachedLeaves) return this.#cachedLeaves;
|
|
563
450
|
if (this.children.length === 0) return [this];
|
|
564
451
|
const result = [];
|
|
565
452
|
const stack = [...this.children];
|
|
@@ -571,7 +458,7 @@ var TreeNode = class TreeNode {
|
|
|
571
458
|
if (node.children.length > 0) stack.push(...node.children);
|
|
572
459
|
else result.push(node);
|
|
573
460
|
}
|
|
574
|
-
|
|
461
|
+
this.#cachedLeaves = result;
|
|
575
462
|
return result;
|
|
576
463
|
}
|
|
577
464
|
forEach(callback) {
|
|
@@ -618,8 +505,7 @@ var TreeNode = class TreeNode {
|
|
|
618
505
|
const normalizedPaths = /* @__PURE__ */ new Map();
|
|
619
506
|
const filteredFiles = [];
|
|
620
507
|
for (const file of files) {
|
|
621
|
-
|
|
622
|
-
const filePath = (_normalizedPaths$get = normalizedPaths.get(file)) !== null && _normalizedPaths$get !== void 0 ? _normalizedPaths$get : normalizePath(file.path);
|
|
508
|
+
const filePath = normalizedPaths.get(file) ?? normalizePath(file.path);
|
|
623
509
|
normalizedPaths.set(file, filePath);
|
|
624
510
|
if (!filePath.endsWith(".json") && (!rootFolder || filePath.startsWith(rootPrefix))) filteredFiles.push(file);
|
|
625
511
|
}
|
|
@@ -769,9 +655,8 @@ function createComponent(type, Component) {
|
|
|
769
655
|
fn.props = args[0];
|
|
770
656
|
fn.type = type;
|
|
771
657
|
fn.children = (...children) => {
|
|
772
|
-
var _args$;
|
|
773
658
|
const propsWithChildren = {
|
|
774
|
-
...
|
|
659
|
+
...args[0] ?? {},
|
|
775
660
|
children() {
|
|
776
661
|
return renderIntrinsic(children);
|
|
777
662
|
}
|
|
@@ -819,12 +704,46 @@ const Root = createComponent("Root", ({ onError, onExit, treeNode, fileManager,
|
|
|
819
704
|
try {
|
|
820
705
|
return children;
|
|
821
706
|
} catch (e) {
|
|
822
|
-
if (e instanceof Error) onError
|
|
707
|
+
if (e instanceof Error) onError?.(e);
|
|
823
708
|
return "";
|
|
824
709
|
}
|
|
825
710
|
});
|
|
826
711
|
Root.displayName = "Root";
|
|
827
712
|
|
|
828
713
|
//#endregion
|
|
829
|
-
|
|
830
|
-
|
|
714
|
+
//#region src/utils/onProcessExit.ts
|
|
715
|
+
const SIGNALS = [
|
|
716
|
+
"SIGINT",
|
|
717
|
+
"SIGTERM",
|
|
718
|
+
"SIGHUP"
|
|
719
|
+
];
|
|
720
|
+
/**
|
|
721
|
+
* Register a callback to run when the process exits (via exit event or common signals).
|
|
722
|
+
* Returns an unsubscribe function.
|
|
723
|
+
*/
|
|
724
|
+
function onProcessExit(callback) {
|
|
725
|
+
const exitHandler = (code) => callback(code);
|
|
726
|
+
const signalHandlers = /* @__PURE__ */ new Map();
|
|
727
|
+
for (const signal of SIGNALS) {
|
|
728
|
+
const handler = () => {
|
|
729
|
+
unsubscribe();
|
|
730
|
+
try {
|
|
731
|
+
callback(null);
|
|
732
|
+
} finally {
|
|
733
|
+
process.kill(process.pid, signal);
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
signalHandlers.set(signal, handler);
|
|
737
|
+
process.on(signal, handler);
|
|
738
|
+
}
|
|
739
|
+
process.on("exit", exitHandler);
|
|
740
|
+
function unsubscribe() {
|
|
741
|
+
process.removeListener("exit", exitHandler);
|
|
742
|
+
for (const [signal, handler] of signalHandlers) process.removeListener(signal, handler);
|
|
743
|
+
}
|
|
744
|
+
return unsubscribe;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
//#endregion
|
|
748
|
+
export { provide as _, renderIndent as a, RootContext as c, FileProcessor as d, AsyncEventEmitter as f, inject as g, createContext as h, createIntrinsic as i, TreeNode as l, NodeTreeContext as m, Root as n, renderIntrinsic as o, createFile as p, createComponent as r, RenderContext as s, onProcessExit as t, FileManager as u, unprovide as v };
|
|
749
|
+
//# sourceMappingURL=onProcessExit-CF200hsz.js.map
|