@kubb/fabric-core 0.0.0-canary-20260111130736 → 0.0.0-canary-20260113205926
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-CDFwTDyP.d.ts → Fabric-4XbXcu8_.d.cts} +4 -118
- package/dist/{Fabric-BXYWK9V4.d.cts → Fabric-BTRMItqi.d.ts} +4 -118
- package/dist/FileCollector-8RJHS5I3.d.ts +26 -0
- package/dist/FileCollector-lJGpddxr.d.cts +26 -0
- package/dist/KubbFile-BqiYGIzl.d.cts +118 -0
- package/dist/KubbFile-DSLdZhaI.d.ts +118 -0
- package/dist/classPrivateFieldSet2-DrVq6yr-.cjs +62 -0
- package/dist/classPrivateFieldSet2-Dy82u8wh.js +32 -0
- package/dist/{defaultParser-DPHcM2NR.js → defaultParser-CQ-4-EIF.js} +2 -2
- package/dist/{defaultParser-DPHcM2NR.js.map → defaultParser-CQ-4-EIF.js.map} +1 -1
- package/dist/{defineParser-Bxv4mb-N.js → defineParser-_trfFm28.js} +1 -1
- package/dist/{defineParser-Bxv4mb-N.js.map → defineParser-_trfFm28.js.map} +1 -1
- package/dist/{defineProperty-hUmuXj5B.cjs → defineProperty-BAD-J6vV.cjs} +5 -66
- package/dist/{defineProperty-hUmuXj5B.cjs.map → defineProperty-BAD-J6vV.cjs.map} +1 -1
- package/dist/{defineProperty-CS9Uk_6Q.js → defineProperty-DMYokRGX.js} +7 -38
- package/dist/{defineProperty-CS9Uk_6Q.js.map → defineProperty-DMYokRGX.js.map} +1 -1
- package/dist/{getRelativePath-DayVrg5k.js → getRelativePath-CHV9GNVv.js} +1 -1
- package/dist/{getRelativePath-DayVrg5k.js.map → getRelativePath-CHV9GNVv.js.map} +1 -1
- package/dist/{getRelativePath-CLj7Ou6d.cjs → getRelativePath-CMRL1NPO.cjs} +1 -1
- package/dist/{getRelativePath-CLj7Ou6d.cjs.map → getRelativePath-CMRL1NPO.cjs.map} +1 -1
- package/dist/index.cjs +173 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +105 -3
- package/dist/index.d.ts +105 -3
- package/dist/index.js +126 -5
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.cjs +1 -1
- package/dist/parsers/typescript.d.cts +1 -1
- package/dist/parsers/typescript.d.ts +1 -1
- package/dist/parsers/typescript.js +3 -3
- package/dist/parsers.d.cts +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/parsers.js +2 -2
- package/dist/plugins.cjs +10 -9
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +2 -1
- package/dist/plugins.d.ts +2 -1
- package/dist/plugins.js +3 -2
- package/dist/plugins.js.map +1 -1
- package/dist/{trimExtName-Dq2Z7SCT.js → trimExtName-C94zbVlg.js} +1 -1
- package/dist/{trimExtName-Dq2Z7SCT.js.map → trimExtName-C94zbVlg.js.map} +1 -1
- package/dist/types.d.cts +2 -1
- package/dist/types.d.ts +2 -1
- package/dist/utils.cjs +52 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +14 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +51 -0
- package/dist/utils.js.map +1 -0
- package/package.json +8 -1
- package/src/composables/useApp.ts +15 -0
- package/src/composables/useContext.ts +16 -0
- package/src/composables/useFile.ts +16 -0
- package/src/composables/useLifecycle.ts +13 -0
- package/src/context.ts +82 -0
- package/src/contexts/AppContext.ts +11 -0
- package/src/contexts/FileCollectorContext.ts +18 -0
- package/src/contexts/RootContext.ts +12 -0
- package/src/index.ts +10 -0
- package/src/utils/FileCollector.ts +30 -0
- package/src/utils/createJSDoc.ts +15 -0
- package/src/utils/index.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,109 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as ResolvedFile, n as File } from "./KubbFile-DSLdZhaI.js";
|
|
2
|
+
import { t as FileCollector } from "./FileCollector-8RJHS5I3.js";
|
|
3
|
+
import { a as FabricOptions, c as FileManager, l as FileProcessor, n as FabricConfig, t as Fabric } from "./Fabric-BTRMItqi.js";
|
|
2
4
|
|
|
5
|
+
//#region src/context.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Context type that carries type information about its value
|
|
8
|
+
* This is a branded symbol type that enables type-safe context usage
|
|
9
|
+
*/
|
|
10
|
+
type Context<T> = symbol & {
|
|
11
|
+
readonly __type: T;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Provides a value to descendant components (Vue 3 style)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const ThemeKey = Symbol('theme')
|
|
19
|
+
* provide(ThemeKey, { color: 'blue' })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function provide<T>(key: symbol | Context<T>, value: T): void;
|
|
23
|
+
/**
|
|
24
|
+
* Injects a value provided by an ancestor component (Vue 3 style)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const theme = inject(ThemeKey, { color: 'default' })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function inject<T>(key: symbol | Context<T>, defaultValue?: T): T;
|
|
32
|
+
/**
|
|
33
|
+
* Unprovides a value (for cleanup)
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
declare function unprovide<T>(key: symbol | Context<T>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a context key with a default value (React-style compatibility)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const ThemeContext = createContext({ color: 'blue' })
|
|
43
|
+
* // ThemeContext is now typed as Context<{ color: string }>
|
|
44
|
+
* const theme = useContext(ThemeContext) // theme is { color: string }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/contexts/AppContext.d.ts
|
|
50
|
+
type AppContextProps<TMeta = unknown> = {
|
|
51
|
+
/**
|
|
52
|
+
* Exit (unmount)
|
|
53
|
+
*/
|
|
54
|
+
readonly exit: (error?: Error) => void;
|
|
55
|
+
readonly meta: TMeta;
|
|
56
|
+
};
|
|
57
|
+
declare const AppContext: Context<AppContextProps<unknown> | undefined>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/composables/useApp.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* `useApp` will return the current App with meta and exit function.
|
|
62
|
+
*/
|
|
63
|
+
declare function useApp<TMeta = unknown>(): AppContextProps<TMeta>;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/composables/useContext.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* React-style alias for inject
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const theme = useContext(ThemeContext) // type is inferred from ThemeContext
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function useContext<T>(key: Context<T>): T;
|
|
75
|
+
declare function useContext<T>(key: Context<T>, defaultValue: T): T;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/composables/useFile.d.ts
|
|
78
|
+
/**
|
|
79
|
+
* `useFile` will return the current FileCollector for registering files.
|
|
80
|
+
*/
|
|
81
|
+
declare function useFile(): FileCollector;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/composables/useLifecycle.d.ts
|
|
84
|
+
/**
|
|
85
|
+
* `useLifecycle` will return some helpers to exit/restart the generation.
|
|
86
|
+
*/
|
|
87
|
+
declare function useLifecycle(): {
|
|
88
|
+
exit: (error?: Error) => void;
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/contexts/FileCollectorContext.d.ts
|
|
92
|
+
/**
|
|
93
|
+
* Context for collecting files - provided by createFsxFabric
|
|
94
|
+
*/
|
|
95
|
+
declare const FileCollectorContext: Context<FileCollector | null>;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/contexts/RootContext.d.ts
|
|
98
|
+
type RootContextProps = {
|
|
99
|
+
/**
|
|
100
|
+
* Exit (unmount) the whole app.
|
|
101
|
+
*/
|
|
102
|
+
readonly exit: (error?: Error) => void;
|
|
103
|
+
};
|
|
104
|
+
declare const RootContext: Context<RootContextProps>;
|
|
105
|
+
//#endregion
|
|
3
106
|
//#region src/createFabric.d.ts
|
|
4
|
-
|
|
5
107
|
/**
|
|
6
108
|
* Creates a new Fabric instance
|
|
7
109
|
*
|
|
@@ -17,5 +119,5 @@ declare function createFabric<T extends FabricOptions>(config?: FabricConfig<T>)
|
|
|
17
119
|
*/
|
|
18
120
|
declare function createFile<TMeta extends object = object>(file: File<TMeta>): ResolvedFile<TMeta>;
|
|
19
121
|
//#endregion
|
|
20
|
-
export { type Fabric, FileManager, FileProcessor, createFabric, createFile };
|
|
122
|
+
export { AppContext, type Context, type Fabric, FileCollectorContext, FileManager, FileProcessor, RootContext, createContext, createFabric, createFile, inject, provide, unprovide, useApp, useContext, useFile, useLifecycle };
|
|
21
123
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as trimExtName } from "./trimExtName-
|
|
3
|
-
import { t as defaultParser } from "./defaultParser-
|
|
1
|
+
import { n as createFile, t as _defineProperty } from "./defineProperty-DMYokRGX.js";
|
|
2
|
+
import { t as trimExtName } from "./trimExtName-C94zbVlg.js";
|
|
3
|
+
import { t as defaultParser } from "./defaultParser-CQ-4-EIF.js";
|
|
4
|
+
import { a as _checkPrivateRedeclaration, i as _classPrivateFieldInitSpec, n as _classPrivateFieldGet2, r as _assertClassBrand, t as _classPrivateFieldSet2 } from "./classPrivateFieldSet2-Dy82u8wh.js";
|
|
4
5
|
import { orderBy } from "natural-orderby";
|
|
5
6
|
import pLimit from "p-limit";
|
|
6
7
|
import { EventEmitter } from "node:events";
|
|
7
8
|
|
|
8
|
-
//#region
|
|
9
|
+
//#region src/context.ts
|
|
10
|
+
/**
|
|
11
|
+
* Context stack for tracking the current context values
|
|
12
|
+
*
|
|
13
|
+
* Note: This uses a global Map for simplicity in code generation scenarios.
|
|
14
|
+
* For concurrent runtime execution, consider using AsyncLocalStorage or
|
|
15
|
+
* instance-based context management.
|
|
16
|
+
*/
|
|
17
|
+
const contextStack = /* @__PURE__ */ new Map();
|
|
18
|
+
const contextDefaults = /* @__PURE__ */ new Map();
|
|
19
|
+
/**
|
|
20
|
+
* Provides a value to descendant components (Vue 3 style)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const ThemeKey = Symbol('theme')
|
|
25
|
+
* provide(ThemeKey, { color: 'blue' })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function provide(key, value) {
|
|
29
|
+
if (!contextStack.has(key)) contextStack.set(key, []);
|
|
30
|
+
contextStack.get(key).push(value);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Injects a value provided by an ancestor component (Vue 3 style)
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const theme = inject(ThemeKey, { color: 'default' })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function inject(key, defaultValue) {
|
|
41
|
+
const stack = contextStack.get(key);
|
|
42
|
+
if (!stack || stack.length === 0) {
|
|
43
|
+
if (defaultValue !== void 0) return defaultValue;
|
|
44
|
+
const storedDefault = contextDefaults.get(key);
|
|
45
|
+
if (storedDefault !== void 0) return storedDefault;
|
|
46
|
+
throw new Error(`No value provided for key: ${key.toString()}`);
|
|
47
|
+
}
|
|
48
|
+
return stack[stack.length - 1];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Unprovides a value (for cleanup)
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
function unprovide(key) {
|
|
55
|
+
const stack = contextStack.get(key);
|
|
56
|
+
if (stack && stack.length > 0) stack.pop();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a context key with a default value (React-style compatibility)
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const ThemeContext = createContext({ color: 'blue' })
|
|
64
|
+
* // ThemeContext is now typed as Context<{ color: string }>
|
|
65
|
+
* const theme = useContext(ThemeContext) // theme is { color: string }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
function createContext(defaultValue) {
|
|
69
|
+
const key = Symbol("context");
|
|
70
|
+
contextDefaults.set(key, defaultValue);
|
|
71
|
+
return key;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/contexts/AppContext.ts
|
|
76
|
+
const AppContext = createContext(void 0);
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/composables/useApp.ts
|
|
80
|
+
/**
|
|
81
|
+
* `useApp` will return the current App with meta and exit function.
|
|
82
|
+
*/
|
|
83
|
+
function useApp() {
|
|
84
|
+
const app = inject(AppContext, void 0);
|
|
85
|
+
if (!app) throw new Error("App context should be provided");
|
|
86
|
+
return app;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/composables/useContext.ts
|
|
91
|
+
function useContext(key, defaultValue) {
|
|
92
|
+
return inject(key, defaultValue);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/contexts/FileCollectorContext.ts
|
|
97
|
+
/**
|
|
98
|
+
* Context for collecting files - provided by createFsxFabric
|
|
99
|
+
*/
|
|
100
|
+
const FileCollectorContext = createContext(null);
|
|
101
|
+
const CurrentFileContext = createContext(null);
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/composables/useFile.ts
|
|
105
|
+
/**
|
|
106
|
+
* `useFile` will return the current FileCollector for registering files.
|
|
107
|
+
*/
|
|
108
|
+
function useFile() {
|
|
109
|
+
const collector = inject(FileCollectorContext, null);
|
|
110
|
+
if (!collector) throw new Error("No FileCollector found in context. Make sure you are using a Fabric that provides a FileCollector.");
|
|
111
|
+
return collector;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/contexts/RootContext.ts
|
|
116
|
+
const RootContext = createContext({ exit: () => {} });
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/composables/useLifecycle.ts
|
|
120
|
+
/**
|
|
121
|
+
* `useLifecycle` will return some helpers to exit/restart the generation.
|
|
122
|
+
*/
|
|
123
|
+
function useLifecycle() {
|
|
124
|
+
const { exit } = inject(RootContext, { exit: () => {} });
|
|
125
|
+
return { exit };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.2/node_modules/remeda/dist/isFunction.js
|
|
9
130
|
const e = (e$1) => typeof e$1 == `function`;
|
|
10
131
|
|
|
11
132
|
//#endregion
|
|
@@ -331,5 +452,5 @@ function createFabric(config = { mode: "sequential" }) {
|
|
|
331
452
|
}
|
|
332
453
|
|
|
333
454
|
//#endregion
|
|
334
|
-
export { FileManager, FileProcessor, createFabric, createFile };
|
|
455
|
+
export { AppContext, FileCollectorContext, FileManager, FileProcessor, RootContext, createContext, createFabric, createFile, inject, provide, unprovide, useApp, useContext, useFile, useLifecycle };
|
|
335
456
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["e","NodeEventEmitter","errors: Error[]","resolvedFiles: Array<KubbFile.ResolvedFile>","files: Array<KubbFile.ResolvedFile>","context: FabricContext<T>","fabric: Fabric<T>","isFunction"],"sources":["../../../node_modules/.pnpm/remeda@2.33.1/node_modules/remeda/dist/isFunction.js","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.ts","../src/createFabric.ts"],"sourcesContent":["const e=e=>typeof e==`function`;export{e as isFunction};\n//# sourceMappingURL=isFunction.js.map","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport type { FabricMode } from '../Fabric.ts'\n\ntype Options = {\n mode?: FabricMode\n maxListener?: number\n}\n\nexport class AsyncEventEmitter<TEvents extends Record<string, any>> {\n constructor({ maxListener = 100, mode = 'sequential' }: Options = {}) {\n this.#emitter.setMaxListeners(maxListener)\n this.#mode = mode\n }\n\n #emitter = new NodeEventEmitter()\n #mode: FabricMode\n\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<(...args: TEvents[TEventName]) => any>\n\n if (listeners.length === 0) {\n return\n }\n\n const errors: Error[] = []\n\n if (this.#mode === 'sequential') {\n // Run listeners one by one, in order\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n }\n } else {\n // Run all listeners concurrently\n const promises = listeners.map(async (listener) => {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n })\n await Promise.all(promises)\n }\n\n if (errors.length === 1) {\n throw errors[0]\n }\n\n if (errors.length > 1) {\n throw new AggregateError(errors, `Errors in async listeners for \"${eventName}\"`)\n }\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void {\n const wrapper = (...args: TEvents[TEventName]) => {\n this.off(eventName, wrapper)\n handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import pLimit from 'p-limit'\nimport type { FabricEvents, FabricMode } from './Fabric.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { defaultParser } from './parsers/defaultParser.ts'\nimport type { Parser } from './parsers/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\nexport type ProcessFilesProps = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n /**\n * @default 'sequential'\n */\n mode?: FabricMode\n}\n\ntype GetParseOptions = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileProcessor {\n #limit = pLimit(100)\n events: AsyncEventEmitter<FabricEvents>\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.events = events\n\n return this\n }\n\n async parse(file: KubbFile.ResolvedFile, { parsers, extension }: GetParseOptions = {}): Promise<string> {\n const parseExtName = extension?.[file.extname] || undefined\n\n if (!parsers) {\n console.warn('No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.')\n\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n if (!file.extname) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n const parser = parsers.get(file.extname)\n\n if (!parser) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n return parser.parse(file, { extname: parseExtName })\n }\n\n async run(\n files: Array<KubbFile.ResolvedFile>,\n { parsers, mode = 'sequential', dryRun, extension }: ProcessFilesProps = {},\n ): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:processing:start', files)\n\n const total = files.length\n let processed = 0\n\n const processOne = async (resolvedFile: KubbFile.ResolvedFile, index: number) => {\n await this.events.emit('file:processing:start', resolvedFile, index, total)\n\n const source = dryRun ? undefined : await this.parse(resolvedFile, { extension, parsers })\n\n const currentProcessed = ++processed\n const percentage = (currentProcessed / total) * 100\n\n await this.events.emit('file:processing:update', {\n file: resolvedFile,\n source,\n processed: currentProcessed,\n percentage,\n total,\n })\n\n await this.events.emit('file:processing:end', resolvedFile, index, total)\n }\n\n if (mode === 'sequential') {\n async function* asyncFiles() {\n for (let index = 0; index < files.length; index++) {\n yield [files[index], index] as const\n }\n }\n\n for await (const [file, index] of asyncFiles()) {\n if (file) {\n await processOne(file, index)\n }\n }\n } else {\n const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)))\n await Promise.all(promises)\n }\n\n await this.events.emit('files:processing:end', files)\n\n return files\n }\n}\n","export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import { orderBy } from 'natural-orderby'\nimport { createFile } from './createFile.ts'\nimport type { FabricEvents } from './Fabric.ts'\nimport { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #filesCache: Array<KubbFile.ResolvedFile> | null = null\n events: AsyncEventEmitter<FabricEvents>\n processor: FileProcessor\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.processor = new FileProcessor({ events })\n\n this.events = events\n return this\n }\n\n #resolvePath(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:path', file)\n\n return file\n }\n\n #resolveName(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:name', file)\n\n return file\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const resolvedFile = createFile(file)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', resolvedFiles)\n\n return resolvedFiles\n }\n\n async upsert(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', resolvedFiles)\n\n return resolvedFiles\n }\n\n flush() {\n this.#filesCache = null\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n this.#filesCache = null\n }\n\n clear(): void {\n this.#cache.clear()\n this.#filesCache = null\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files: Array<KubbFile.ResolvedFile> = []\n\n for (const key of keys) {\n const file = this.#cache.get(key)\n if (file) {\n files.push(file)\n }\n }\n\n this.#filesCache = files\n\n return files\n }\n\n //TODO add test and check if write of FileManager contains the newly added file\n async write(options: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:writing:start', this.files)\n\n const resolvedFiles = await this.processor.run(this.files, options)\n\n this.clear()\n\n await this.events.emit('files:writing:end', resolvedFiles)\n\n return resolvedFiles\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance\n *\n * @example\n * const fabric = createFabric()\n * fabric.use(myPlugin())\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAAA,MAAM,KAAE,QAAG,OAAOA,OAAG;;;;;;ACQrB,IAAa,oBAAb,MAAoE;CAClE,YAAY,EAAE,cAAc,KAAK,OAAO,iBAA0B,EAAE,EAAE;6CAK3D,IAAIC,cAAkB;;AAJ/B,wCAAa,CAAC,gBAAgB,YAAY;AAC1C,sCAAa,KAAI;;CAMnB,MAAM,KAAgD,WAAuB,GAAG,WAA+C;EAC7H,MAAM,6C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Array<KubbFile.ResolvedFile>","context: FabricContext<T>","fabric: Fabric<T>","isFunction"],"sources":["../src/context.ts","../src/contexts/AppContext.ts","../src/composables/useApp.ts","../src/composables/useContext.ts","../src/contexts/FileCollectorContext.ts","../src/composables/useFile.ts","../src/contexts/RootContext.ts","../src/composables/useLifecycle.ts","../../../node_modules/.pnpm/remeda@2.33.2/node_modules/remeda/dist/isFunction.js","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.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 { createContext } from '../context.ts'\n\nexport type AppContextProps<TMeta = unknown> = {\n /**\n * Exit (unmount)\n */\n readonly exit: (error?: Error) => void\n readonly meta: TMeta\n}\n\nexport const AppContext = createContext<AppContextProps | undefined>(undefined)\n","import { inject } from '../context.ts'\nimport { AppContext, type AppContextProps } from '../contexts/AppContext.ts'\n\n/**\n * `useApp` will return the current App with meta and exit function.\n */\nexport function useApp<TMeta = unknown>(): AppContextProps<TMeta> {\n const app = inject(AppContext, undefined)\n\n if (!app) {\n throw new Error('App context should be provided')\n }\n\n return app as AppContextProps<TMeta>\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>(key: Context<T>, defaultValue: T): T\nexport function useContext<T>(key: Context<T>, defaultValue?: T): T {\n return inject(key, defaultValue)\n}\n","import { createContext } from '../context.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport type { FileCollector } from '../utils/FileCollector.ts'\n\n/**\n * Context for collecting files - provided by createFsxFabric\n */\nexport const FileCollectorContext = createContext<FileCollector | null>(null)\n\n/**\n * Context for the current file being processed\n */\ntype CurrentFileContext = {\n sources: KubbFile.Source[]\n imports: KubbFile.Import[]\n exports: KubbFile.Export[]\n}\nexport const CurrentFileContext = createContext<CurrentFileContext | null>(null)\n","import { inject } from '../context.ts'\nimport { FileCollectorContext } from '../contexts/FileCollectorContext.ts'\nimport type { FileCollector } from '../utils/FileCollector.ts'\n\n/**\n * `useFile` will return the current FileCollector for registering files.\n */\nexport function useFile(): FileCollector {\n const collector = inject(FileCollectorContext, null)\n\n if (!collector) {\n throw new Error('No FileCollector found in context. Make sure you are using a Fabric that provides a FileCollector.')\n }\n\n return collector\n}\n","import { createContext } from '../context.ts'\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n","import { inject } from '../context.ts'\nimport { RootContext } from '../contexts/RootContext.ts'\n\n/**\n * `useLifecycle` will return some helpers to exit/restart the generation.\n */\nexport function useLifecycle() {\n const { exit } = inject(RootContext, { exit: () => {} })\n\n return {\n exit,\n }\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 async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const resolvedFile = createFile(file)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', resolvedFiles)\n\n return resolvedFiles\n }\n\n async upsert(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', resolvedFiles)\n\n return resolvedFiles\n }\n\n flush() {\n this.#filesCache = null\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n this.#filesCache = null\n }\n\n clear(): void {\n this.#cache.clear()\n this.#filesCache = null\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files: Array<KubbFile.ResolvedFile> = []\n\n for (const key of keys) {\n const file = this.#cache.get(key)\n if (file) {\n files.push(file)\n }\n }\n\n this.#filesCache = files\n\n return files\n }\n\n //TODO add test and check if write of FileManager contains the newly added file\n async write(options: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:writing:start', this.files)\n\n const resolvedFiles = await this.processor.run(this.files, options)\n\n this.clear()\n\n await this.events.emit('files:writing:end', resolvedFiles)\n\n return resolvedFiles\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance\n *\n * @example\n * const fabric = createFabric()\n * fabric.use(myPlugin())\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"x_google_ignoreList":[8],"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,MAAM,OAAO,UAAU;AAC7B,iBAAgB,IAAI,KAAK,aAAa;AAEtC,QAAO;;;;;ACtET,MAAa,aAAa,cAA2C,OAAU;;;;;;;ACJ/E,SAAgB,SAAkD;CAChE,MAAM,MAAM,OAAO,YAAY,OAAU;AAEzC,KAAI,CAAC,IACH,OAAM,IAAI,MAAM,iCAAiC;AAGnD,QAAO;;;;;ACAT,SAAgB,WAAc,KAAiB,cAAqB;AAClE,QAAO,OAAO,KAAK,aAAa;;;;;;;;ACPlC,MAAa,uBAAuB,cA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,SAAS,UAAU;AACpC,QAAI,qBAAqB,IAAI,eAAe,KAAK,CAC/C,SAAQ,KAAK,WAAW,eAAe,KAAK,oBAAoB;QAEhE,sBAAqB,IAAI,eAAe,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,6 +1,6 @@
|
|
|
1
1
|
const require_trimExtName = require('../trimExtName-DaBSwMN-.cjs');
|
|
2
2
|
const require_defineParser = require('../defineParser-DODGK4rM.cjs');
|
|
3
|
-
const require_getRelativePath = require('../getRelativePath-
|
|
3
|
+
const require_getRelativePath = require('../getRelativePath-CMRL1NPO.cjs');
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_trimExtName.__toESM(node_path);
|
|
6
6
|
let typescript = require("typescript");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as trimExtName } from "../trimExtName-
|
|
2
|
-
import { t as defineParser } from "../defineParser-
|
|
3
|
-
import { t as getRelativePath } from "../getRelativePath-
|
|
1
|
+
import { t as trimExtName } from "../trimExtName-C94zbVlg.js";
|
|
2
|
+
import { t as defineParser } from "../defineParser-_trfFm28.js";
|
|
3
|
+
import { t as getRelativePath } from "../getRelativePath-CHV9GNVv.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
|
package/dist/parsers.d.cts
CHANGED
package/dist/parsers.d.ts
CHANGED
package/dist/parsers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as defineParser } from "./defineParser-
|
|
2
|
-
import { t as defaultParser } from "./defaultParser-
|
|
1
|
+
import { t as defineParser } from "./defineParser-_trfFm28.js";
|
|
2
|
+
import { t as defaultParser } from "./defaultParser-CQ-4-EIF.js";
|
|
3
3
|
import { typescriptParser } from "./parsers/typescript.js";
|
|
4
4
|
|
|
5
5
|
//#region src/parsers/tsxParser.ts
|
package/dist/plugins.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_trimExtName = require('./trimExtName-DaBSwMN-.cjs');
|
|
2
|
-
const require_defineProperty = require('./defineProperty-
|
|
3
|
-
const
|
|
2
|
+
const require_defineProperty = require('./defineProperty-BAD-J6vV.cjs');
|
|
3
|
+
const require_classPrivateFieldSet2 = require('./classPrivateFieldSet2-DrVq6yr-.cjs');
|
|
4
|
+
const require_getRelativePath = require('./getRelativePath-CMRL1NPO.cjs');
|
|
4
5
|
let node_path = require("node:path");
|
|
5
6
|
node_path = require_trimExtName.__toESM(node_path);
|
|
6
7
|
let fs_extra = require("fs-extra");
|
|
@@ -24,23 +25,23 @@ var TreeNode = class TreeNode {
|
|
|
24
25
|
require_defineProperty._defineProperty(this, "data", void 0);
|
|
25
26
|
require_defineProperty._defineProperty(this, "parent", void 0);
|
|
26
27
|
require_defineProperty._defineProperty(this, "children", []);
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _childrenMap, /* @__PURE__ */ new Map());
|
|
29
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _cachedLeaves, void 0);
|
|
29
30
|
this.data = data;
|
|
30
31
|
this.parent = parent;
|
|
31
32
|
}
|
|
32
33
|
addChild(data) {
|
|
33
34
|
const child = new TreeNode(data, this);
|
|
34
35
|
this.children.push(child);
|
|
35
|
-
if (typeof data === "object" && data !== null && "name" in data)
|
|
36
|
-
|
|
36
|
+
if (typeof data === "object" && data !== null && "name" in data) require_classPrivateFieldSet2._classPrivateFieldGet2(_childrenMap, this).set(data.name, child);
|
|
37
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_cachedLeaves, this, void 0);
|
|
37
38
|
return child;
|
|
38
39
|
}
|
|
39
40
|
getChildByName(name) {
|
|
40
|
-
return
|
|
41
|
+
return require_classPrivateFieldSet2._classPrivateFieldGet2(_childrenMap, this).get(name);
|
|
41
42
|
}
|
|
42
43
|
get leaves() {
|
|
43
|
-
if (
|
|
44
|
+
if (require_classPrivateFieldSet2._classPrivateFieldGet2(_cachedLeaves, this)) return require_classPrivateFieldSet2._classPrivateFieldGet2(_cachedLeaves, this);
|
|
44
45
|
if (this.children.length === 0) return [this];
|
|
45
46
|
const result = [];
|
|
46
47
|
const stack = [...this.children];
|
|
@@ -52,7 +53,7 @@ var TreeNode = class TreeNode {
|
|
|
52
53
|
if (node.children.length > 0) stack.push(...node.children);
|
|
53
54
|
else result.push(node);
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_cachedLeaves, this, result);
|
|
56
57
|
return result;
|
|
57
58
|
}
|
|
58
59
|
forEach(callback) {
|