@kubb/fabric-core 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{types-lS0JaZqX.d.cts → KubbFile-BrN7Wwp6.d.cts} +3 -3
- package/dist/{types-BY5X8xoR.d.ts → KubbFile-BzVkcu9M.d.ts} +3 -3
- package/dist/defineApp-Bg7JewJQ.d.ts +62 -0
- package/dist/defineApp-DKW3IRO8.d.cts +62 -0
- package/dist/index.cjs +65 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -60
- package/dist/index.d.ts +5 -60
- package/dist/index.js +64 -67
- package/dist/index.js.map +1 -1
- package/dist/parser-CWB_OBtr.js.map +1 -1
- package/dist/parser-D64DdV1v.d.cts +21 -0
- package/dist/parser-QF8j8-pj.cjs.map +1 -1
- package/dist/parser-yYqnryUV.d.ts +21 -0
- package/dist/parsers/tsx.d.cts +2 -2
- package/dist/parsers/tsx.d.ts +2 -2
- package/dist/parsers/typescript.d.cts +2 -2
- package/dist/parsers/typescript.d.ts +2 -2
- package/dist/types.cjs +12 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +3 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +8 -1
- package/src/FileManager.ts +86 -86
- package/src/KubbFile.ts +132 -0
- package/src/defineApp.ts +24 -23
- package/src/index.ts +2 -2
- package/src/parsers/parser.ts +1 -1
- package/src/types.ts +2 -132
- package/dist/parser-Bck6QDwN.d.cts +0 -15
- package/dist/parser-CRl-iUw1.d.ts +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare namespace
|
|
1
|
+
declare namespace KubbFile_d_exports {
|
|
2
2
|
export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
|
|
3
3
|
}
|
|
4
4
|
type BasePath<T extends string = string> = `${T}/`;
|
|
@@ -115,5 +115,5 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
|
115
115
|
exports: Array<ResolvedExport>;
|
|
116
116
|
};
|
|
117
117
|
//#endregion
|
|
118
|
-
export {
|
|
119
|
-
//# sourceMappingURL=
|
|
118
|
+
export { ResolvedFile as a, Path as i, File as n, KubbFile_d_exports as r, Extname as t };
|
|
119
|
+
//# sourceMappingURL=KubbFile-BrN7Wwp6.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare namespace
|
|
1
|
+
declare namespace KubbFile_d_exports {
|
|
2
2
|
export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
|
|
3
3
|
}
|
|
4
4
|
type BasePath<T extends string = string> = `${T}/`;
|
|
@@ -115,5 +115,5 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
|
115
115
|
exports: Array<ResolvedExport>;
|
|
116
116
|
};
|
|
117
117
|
//#endregion
|
|
118
|
-
export {
|
|
119
|
-
//# sourceMappingURL=
|
|
118
|
+
export { ResolvedFile as a, Path as i, File as n, KubbFile_d_exports as r, Extname as t };
|
|
119
|
+
//# sourceMappingURL=KubbFile-BzVkcu9M.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { a as ResolvedFile, i as Path, n as File, t as Extname } from "./KubbFile-BzVkcu9M.js";
|
|
2
|
+
|
|
3
|
+
//#region src/FileManager.d.ts
|
|
4
|
+
type WriteFilesProps = {
|
|
5
|
+
extension?: Record<Extname, Extname | ''>;
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare class FileManager {
|
|
9
|
+
#private;
|
|
10
|
+
constructor();
|
|
11
|
+
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
12
|
+
flush(): void;
|
|
13
|
+
getByPath(path: Path): ResolvedFile | null;
|
|
14
|
+
deleteByPath(path: Path): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
getFiles(): Array<ResolvedFile>;
|
|
17
|
+
processFiles({
|
|
18
|
+
dryRun,
|
|
19
|
+
extension
|
|
20
|
+
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/defineApp.d.ts
|
|
24
|
+
type Component = any;
|
|
25
|
+
type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App, ...options: Options$1) => any : (app: App, options: Options$1) => any;
|
|
26
|
+
type ObjectPlugin<Options$1 = any[]> = {
|
|
27
|
+
install: PluginInstallFunction<Options$1>;
|
|
28
|
+
};
|
|
29
|
+
type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
|
|
30
|
+
type AppRenderer = {
|
|
31
|
+
render(): Promise<void> | void;
|
|
32
|
+
renderToString(): Promise<string> | string;
|
|
33
|
+
waitUntilExit(): Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
type AppContext<TOptions = unknown> = {
|
|
36
|
+
options?: TOptions;
|
|
37
|
+
fileManager: FileManager;
|
|
38
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
39
|
+
files: Array<ResolvedFile>;
|
|
40
|
+
clear: () => void;
|
|
41
|
+
};
|
|
42
|
+
type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
|
|
43
|
+
type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
|
|
44
|
+
type WriteOptions = {
|
|
45
|
+
extension?: Record<Extname, Extname | ''>;
|
|
46
|
+
dryRun?: boolean;
|
|
47
|
+
};
|
|
48
|
+
interface App {
|
|
49
|
+
_component: Component;
|
|
50
|
+
render(): Promise<void>;
|
|
51
|
+
renderToString(): Promise<string>;
|
|
52
|
+
getFiles(): Promise<Array<ResolvedFile>>;
|
|
53
|
+
use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
|
|
54
|
+
write(options?: WriteOptions): Promise<void>;
|
|
55
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
56
|
+
waitUntilExit(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
|
|
59
|
+
declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { FileManager as a, defineApp as i, AppContext as n, DefineApp as r, App as t };
|
|
62
|
+
//# sourceMappingURL=defineApp-Bg7JewJQ.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { a as ResolvedFile, i as Path, n as File, t as Extname } from "./KubbFile-BrN7Wwp6.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/FileManager.d.ts
|
|
4
|
+
type WriteFilesProps = {
|
|
5
|
+
extension?: Record<Extname, Extname | ''>;
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare class FileManager {
|
|
9
|
+
#private;
|
|
10
|
+
constructor();
|
|
11
|
+
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
12
|
+
flush(): void;
|
|
13
|
+
getByPath(path: Path): ResolvedFile | null;
|
|
14
|
+
deleteByPath(path: Path): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
getFiles(): Array<ResolvedFile>;
|
|
17
|
+
processFiles({
|
|
18
|
+
dryRun,
|
|
19
|
+
extension
|
|
20
|
+
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/defineApp.d.ts
|
|
24
|
+
type Component = any;
|
|
25
|
+
type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App, ...options: Options$1) => any : (app: App, options: Options$1) => any;
|
|
26
|
+
type ObjectPlugin<Options$1 = any[]> = {
|
|
27
|
+
install: PluginInstallFunction<Options$1>;
|
|
28
|
+
};
|
|
29
|
+
type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
|
|
30
|
+
type AppRenderer = {
|
|
31
|
+
render(): Promise<void> | void;
|
|
32
|
+
renderToString(): Promise<string> | string;
|
|
33
|
+
waitUntilExit(): Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
type AppContext<TOptions = unknown> = {
|
|
36
|
+
options?: TOptions;
|
|
37
|
+
fileManager: FileManager;
|
|
38
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
39
|
+
files: Array<ResolvedFile>;
|
|
40
|
+
clear: () => void;
|
|
41
|
+
};
|
|
42
|
+
type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
|
|
43
|
+
type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
|
|
44
|
+
type WriteOptions = {
|
|
45
|
+
extension?: Record<Extname, Extname | ''>;
|
|
46
|
+
dryRun?: boolean;
|
|
47
|
+
};
|
|
48
|
+
interface App {
|
|
49
|
+
_component: Component;
|
|
50
|
+
render(): Promise<void>;
|
|
51
|
+
renderToString(): Promise<string>;
|
|
52
|
+
getFiles(): Promise<Array<ResolvedFile>>;
|
|
53
|
+
use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
|
|
54
|
+
write(options?: WriteOptions): Promise<void>;
|
|
55
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
56
|
+
waitUntilExit(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
|
|
59
|
+
declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { FileManager as a, defineApp as i, AppContext as n, DefineApp as r, App as t };
|
|
62
|
+
//# sourceMappingURL=defineApp-DKW3IRO8.d.cts.map
|
package/dist/index.cjs
CHANGED
|
@@ -65,61 +65,6 @@ var Cache = class {
|
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/FileManager.ts
|
|
68
|
-
var _cache = /* @__PURE__ */ new WeakMap();
|
|
69
|
-
var _limit = /* @__PURE__ */ new WeakMap();
|
|
70
|
-
var FileManager = class {
|
|
71
|
-
constructor() {
|
|
72
|
-
_classPrivateFieldInitSpec(this, _cache, new Cache());
|
|
73
|
-
_classPrivateFieldInitSpec(this, _limit, (0, p_limit.default)(100));
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
async add(...files) {
|
|
77
|
-
const resolvedFiles = [];
|
|
78
|
-
const mergedFiles = /* @__PURE__ */ new Map();
|
|
79
|
-
files.forEach((file) => {
|
|
80
|
-
const existing = mergedFiles.get(file.path);
|
|
81
|
-
if (existing) mergedFiles.set(file.path, mergeFile(existing, file));
|
|
82
|
-
else mergedFiles.set(file.path, file);
|
|
83
|
-
});
|
|
84
|
-
for (const file of mergedFiles.values()) {
|
|
85
|
-
const existing = _classPrivateFieldGet2(_cache, this).get(file.path);
|
|
86
|
-
const resolvedFile = createFile(existing ? mergeFile(existing, file) : file);
|
|
87
|
-
_classPrivateFieldGet2(_cache, this).set(resolvedFile.path, resolvedFile);
|
|
88
|
-
this.flush();
|
|
89
|
-
resolvedFiles.push(resolvedFile);
|
|
90
|
-
}
|
|
91
|
-
return resolvedFiles;
|
|
92
|
-
}
|
|
93
|
-
flush() {
|
|
94
|
-
_classPrivateFieldGet2(_cache, this).flush();
|
|
95
|
-
}
|
|
96
|
-
getByPath(path$1) {
|
|
97
|
-
return _classPrivateFieldGet2(_cache, this).get(path$1);
|
|
98
|
-
}
|
|
99
|
-
deleteByPath(path$1) {
|
|
100
|
-
_classPrivateFieldGet2(_cache, this).delete(path$1);
|
|
101
|
-
}
|
|
102
|
-
clear() {
|
|
103
|
-
_classPrivateFieldGet2(_cache, this).clear();
|
|
104
|
-
}
|
|
105
|
-
getFiles() {
|
|
106
|
-
return (0, natural_orderby.orderBy)(_classPrivateFieldGet2(_cache, this).keys(), [(v) => v.length, (v) => require_parser.trimExtName(v).endsWith("index")]).map((key) => _classPrivateFieldGet2(_cache, this).get(key)).filter(Boolean);
|
|
107
|
-
}
|
|
108
|
-
async processFiles({ dryRun, extension }) {
|
|
109
|
-
const files = this.getFiles();
|
|
110
|
-
const promises = files.map((resolvedFile) => {
|
|
111
|
-
return _classPrivateFieldGet2(_limit, this).call(this, async () => {
|
|
112
|
-
const extname = extension ? extension[resolvedFile.extname] || void 0 : resolvedFile.extname;
|
|
113
|
-
if (!dryRun) {
|
|
114
|
-
const source = await require_parser.parseFile(resolvedFile, { extname });
|
|
115
|
-
await require_parser.write(resolvedFile.path, source, { sanity: false });
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
await Promise.all(promises);
|
|
120
|
-
return files;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
68
|
function hashObject(obj) {
|
|
124
69
|
const str = JSON.stringify(obj, Object.keys(obj).sort());
|
|
125
70
|
return (0, node_crypto.createHash)("sha256").update(str).digest("hex");
|
|
@@ -218,18 +163,71 @@ function createFile(file) {
|
|
|
218
163
|
meta: file.meta || {}
|
|
219
164
|
};
|
|
220
165
|
}
|
|
166
|
+
var _cache = /* @__PURE__ */ new WeakMap();
|
|
167
|
+
var _limit = /* @__PURE__ */ new WeakMap();
|
|
168
|
+
var FileManager = class {
|
|
169
|
+
constructor() {
|
|
170
|
+
_classPrivateFieldInitSpec(this, _cache, new Cache());
|
|
171
|
+
_classPrivateFieldInitSpec(this, _limit, (0, p_limit.default)(100));
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
async add(...files) {
|
|
175
|
+
const resolvedFiles = [];
|
|
176
|
+
const mergedFiles = /* @__PURE__ */ new Map();
|
|
177
|
+
files.forEach((file) => {
|
|
178
|
+
const existing = mergedFiles.get(file.path);
|
|
179
|
+
if (existing) mergedFiles.set(file.path, mergeFile(existing, file));
|
|
180
|
+
else mergedFiles.set(file.path, file);
|
|
181
|
+
});
|
|
182
|
+
for (const file of mergedFiles.values()) {
|
|
183
|
+
const existing = _classPrivateFieldGet2(_cache, this).get(file.path);
|
|
184
|
+
const resolvedFile = createFile(existing ? mergeFile(existing, file) : file);
|
|
185
|
+
_classPrivateFieldGet2(_cache, this).set(resolvedFile.path, resolvedFile);
|
|
186
|
+
this.flush();
|
|
187
|
+
resolvedFiles.push(resolvedFile);
|
|
188
|
+
}
|
|
189
|
+
return resolvedFiles;
|
|
190
|
+
}
|
|
191
|
+
flush() {
|
|
192
|
+
_classPrivateFieldGet2(_cache, this).flush();
|
|
193
|
+
}
|
|
194
|
+
getByPath(path$1) {
|
|
195
|
+
return _classPrivateFieldGet2(_cache, this).get(path$1);
|
|
196
|
+
}
|
|
197
|
+
deleteByPath(path$1) {
|
|
198
|
+
_classPrivateFieldGet2(_cache, this).delete(path$1);
|
|
199
|
+
}
|
|
200
|
+
clear() {
|
|
201
|
+
_classPrivateFieldGet2(_cache, this).clear();
|
|
202
|
+
}
|
|
203
|
+
getFiles() {
|
|
204
|
+
return (0, natural_orderby.orderBy)(_classPrivateFieldGet2(_cache, this).keys(), [(v) => v.length, (v) => require_parser.trimExtName(v).endsWith("index")]).map((key) => _classPrivateFieldGet2(_cache, this).get(key)).filter(Boolean);
|
|
205
|
+
}
|
|
206
|
+
async processFiles({ dryRun, extension }) {
|
|
207
|
+
const files = this.getFiles();
|
|
208
|
+
const promises = files.map((resolvedFile) => {
|
|
209
|
+
return _classPrivateFieldGet2(_limit, this).call(this, async () => {
|
|
210
|
+
const extname = extension ? extension[resolvedFile.extname] || void 0 : resolvedFile.extname;
|
|
211
|
+
if (!dryRun) {
|
|
212
|
+
const source = await require_parser.parseFile(resolvedFile, { extname });
|
|
213
|
+
await require_parser.write(resolvedFile.path, source, { sanity: false });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
await Promise.all(promises);
|
|
218
|
+
return files;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
221
|
|
|
222
222
|
//#endregion
|
|
223
223
|
//#region src/defineApp.ts
|
|
224
224
|
const isFunction = (val) => typeof val === "function";
|
|
225
225
|
function defineApp(instance) {
|
|
226
|
-
function createApp$1(rootComponent, options
|
|
227
|
-
extension: { ".ts": ".ts" },
|
|
228
|
-
dryRun: false
|
|
229
|
-
}) {
|
|
226
|
+
function createApp$1(rootComponent, options) {
|
|
230
227
|
const installedPlugins = /* @__PURE__ */ new WeakSet();
|
|
231
228
|
const fileManager = new FileManager();
|
|
232
229
|
const context = {
|
|
230
|
+
options,
|
|
233
231
|
fileManager,
|
|
234
232
|
async addFile(...newFiles) {
|
|
235
233
|
await fileManager.add(...newFiles);
|
|
@@ -256,10 +254,13 @@ function defineApp(instance) {
|
|
|
256
254
|
},
|
|
257
255
|
waitUntilExit,
|
|
258
256
|
addFile: context.addFile,
|
|
259
|
-
async write(
|
|
257
|
+
async write(options$1 = {
|
|
258
|
+
extension: { ".ts": ".ts" },
|
|
259
|
+
dryRun: false
|
|
260
|
+
}) {
|
|
260
261
|
await fileManager.processFiles({
|
|
261
|
-
extension: options.extension,
|
|
262
|
-
dryRun: options.dryRun
|
|
262
|
+
extension: options$1.extension,
|
|
263
|
+
dryRun: options$1.dryRun
|
|
263
264
|
});
|
|
264
265
|
},
|
|
265
266
|
use(plugin, ...options$1) {
|
|
@@ -296,16 +297,8 @@ const createApp = defineApp(() => {
|
|
|
296
297
|
});
|
|
297
298
|
|
|
298
299
|
//#endregion
|
|
299
|
-
|
|
300
|
-
var types_exports = {};
|
|
301
|
-
|
|
302
|
-
//#endregion
|
|
303
|
-
Object.defineProperty(exports, 'KubbFile', {
|
|
304
|
-
enumerable: true,
|
|
305
|
-
get: function () {
|
|
306
|
-
return types_exports;
|
|
307
|
-
}
|
|
308
|
-
});
|
|
300
|
+
exports.FileManager = FileManager;
|
|
309
301
|
exports.createApp = createApp;
|
|
310
302
|
exports.defineApp = defineApp;
|
|
303
|
+
exports.parseFile = require_parser.parseFile;
|
|
311
304
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["resolvedFiles: Array<KubbFile.ResolvedFile>","path","trimExtName","parseFile","write","exports","name","createApp","context: AppContext","app: App<THostElement>","options"],"sources":["../src/utils/Cache.ts","../src/FileManager.ts","../src/defineApp.ts","../src/createApp.ts","../src/types.ts"],"sourcesContent":["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 pLimit from 'p-limit'\n\nimport type * as KubbFile from './types.ts'\nimport { parseFile } from './parsers/parser.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName, write } from './fs.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { orderBy } from 'natural-orderby'\nimport { isDeepEqual, uniqueBy } from 'remeda'\n\ntype WriteFilesProps = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #limit = pLimit(100)\n\n constructor() {\n return this\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 (const file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\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 return resolvedFiles\n }\n\n flush() {\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 }\n\n clear(): void {\n this.#cache.clear()\n }\n\n getFiles(): Array<KubbFile.ResolvedFile> {\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 = keys.map((key) => this.#cache.get(key))\n\n return files.filter(Boolean)\n }\n\n async processFiles({ dryRun, extension }: WriteFilesProps): Promise<Array<KubbFile.ResolvedFile>> {\n const files = this.getFiles()\n\n const promises = files.map((resolvedFile) => {\n return this.#limit(async () => {\n const extname = extension ? extension[resolvedFile.extname] || undefined : resolvedFile.extname\n\n if (!dryRun) {\n const source = await parseFile(resolvedFile, { extname })\n\n await write(resolvedFile.path, source, { sanity: false })\n }\n })\n })\n\n await Promise.all(promises)\n\n return files\n }\n}\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function 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\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\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 return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\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\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\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 prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\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\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\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: hashObject({ path: file.path }),\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 type * as KubbFile from './types.ts'\nimport { FileManager } from './FileManager.ts'\nimport { isPromise } from 'remeda'\n\nconst isFunction = (val: unknown): val is Function => typeof val === 'function'\n\ntype Component = any\n\ntype PluginInstallFunction<Options = any[]> = Options extends unknown[] ? (app: App, ...options: Options) => any : (app: App, options: Options) => any\n\nexport type ObjectPlugin<Options = any[]> = {\n install: PluginInstallFunction<Options>\n}\nexport type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> & Partial<ObjectPlugin<Options>>\n\ntype AppRenderer = {\n render(): Promise<void> | void\n renderToString(): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\nexport type AppContext = {\n fileManager: FileManager\n addFile(...files: Array<KubbFile.File>): Promise<void>\n files: Array<KubbFile.ResolvedFile>\n clear: () => void\n}\n\ntype RootRenderFunction<THostElement = unknown> = (this: AppContext, container: THostElement, context: AppContext) => AppRenderer\n\ntype Plugin<Options = any[], P extends unknown[] = Options extends unknown[] ? Options : [Options]> = FunctionPlugin<P> | ObjectPlugin<P>\n\nexport interface App<_THostElement = unknown> {\n _component: Component\n render(): Promise<void>\n renderToString(): Promise<string>\n getFiles(): Promise<Array<KubbFile.ResolvedFile>>\n use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this\n write(): Promise<void>\n addFile(...files: Array<KubbFile.File>): Promise<void>\n waitUntilExit(): Promise<void>\n}\n\ntype DefineOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nexport type DefineApp<THostElement> = (rootComponent?: Component, options?: DefineOptions) => App<THostElement>\n\nexport function defineApp<THostElement>(instance: RootRenderFunction<THostElement>): DefineApp<THostElement> {\n function createApp(\n rootComponent: Component,\n options: DefineOptions = {\n extension: { '.ts': '.ts' },\n dryRun: false,\n },\n ) {\n const installedPlugins = new WeakSet()\n const fileManager = new FileManager()\n const context: AppContext = {\n fileManager,\n async addFile(...newFiles) {\n await fileManager.add(...newFiles)\n },\n clear() {\n context.fileManager.clear()\n },\n get files() {\n return fileManager.getFiles()\n },\n }\n\n const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)\n\n const app: App<THostElement> = {\n _component: rootComponent,\n async render() {\n if (isPromise(render)) {\n await render()\n } else {\n render()\n }\n },\n async renderToString() {\n return renderToString()\n },\n async getFiles() {\n return fileManager.getFiles()\n },\n waitUntilExit,\n addFile: context.addFile,\n async write() {\n await fileManager.processFiles({\n extension: options.extension,\n dryRun: options.dryRun,\n })\n },\n use(plugin: Plugin, ...options: any[]) {\n if (installedPlugins.has(plugin)) {\n console.warn('Plugin has already been applied to target app.')\n } else if (plugin && isFunction(plugin.install)) {\n installedPlugins.add(plugin)\n plugin.install(app, ...options)\n } else if (isFunction(plugin)) {\n installedPlugins.add(plugin)\n plugin(app, ...options)\n }\n\n return app\n },\n }\n\n return app\n }\n\n return createApp\n}\n","import { defineApp } from './defineApp.ts'\n\nexport const createApp = defineApp(() => {\n return {\n async render() {\n throw new Error('Method not implemented')\n },\n async renderToString() {\n throw new Error('Method not implemented')\n },\n async waitUntilExit() {\n throw new Error('Method not implemented')\n },\n }\n})\n","type BasePath<T extends string = string> = `${T}/`\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name:\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n\n isNameSpace?: boolean\n /**\n * When root is set it will get the path with relative getRelativePath(root, path).\n */\n root?: string\n}\n\nexport type Source = {\n name?: string\n value?: string\n isTypeOnly?: boolean\n /**\n * Has const or type 'export'\n * @default false\n */\n isExportable?: boolean\n /**\n * When set, barrel generation will add this\n * @default false\n */\n isIndexable?: boolean\n}\n\nexport type Export = {\n /**\n * Export name to be used.\n * @example [\"useState\"]\n * @example \"React\"\n */\n name?: string | Array<string>\n /**\n * Path for the import.\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.\n */\n asAlias?: boolean\n}\n\nexport type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\nexport type Mode = 'single' | 'split'\n\n/**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\nexport type BaseName = `${string}.${string}`\n\n/**\n * Path will be full qualified path to a specified file\n */\nexport type Path = string\n\nexport type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`\n\nexport type OptionalPath = Path | undefined | null\n\nexport type File<TMeta extends object = object> = {\n /**\n * Name to be used to create the path\n * Based on UNIX basename, `${name}.extname`\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: BaseName\n /**\n * Path will be full qualified path to a specified file\n */\n path: AdvancedPath<BaseName> | Path\n sources: Array<Source>\n imports?: Array<Import>\n exports?: Array<Export>\n /**\n * Use extra meta, this is getting used to generate the barrel/index files.\n */\n meta?: TMeta\n banner?: string\n footer?: string\n}\n\nexport type ResolvedImport = Import\n\nexport type ResolvedExport = Export\n\nexport type ResolvedFile<TMeta extends object = object> = File<TMeta> & {\n /**\n * @default hash\n */\n id: string\n /**\n * Contains the first part of the baseName, generated based on baseName\n * @link https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n extname: Extname\n imports: Array<ResolvedImport>\n exports: Array<ResolvedExport>\n}\n"],"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AED,MAAM,EAAE,QAAQ,gBAAgB,kBAAkB,SAAS,KAAK,SAAS,eAAe,QAAQ;EAEhG,MAAMC,MAAyB;GAC7B,YAAY;GACZ,MAAM,SAAS;AACb,8BAAc,OAAO,CACnB,OAAM,QAAQ;QAEd,SAAQ;;GAGZ,MAAM,iBAAiB;AACrB,WAAO,gBAAgB;;GAEzB,MAAM,WAAW;AACf,WAAO,YAAY,UAAU;;GAE/B;GACA,SAAS,QAAQ;GACjB,MAAM,QAAQ;AACZ,UAAM,YAAY,aAAa;KAC7B,WAAW,QAAQ;KACnB,QAAQ,QAAQ;KACjB,CAAC;;GAEJ,IAAI,QAAgB,GAAGC,WAAgB;AACrC,QAAI,iBAAiB,IAAI,OAAO,CAC9B,SAAQ,KAAK,iDAAiD;aACrD,UAAU,WAAW,OAAO,QAAQ,EAAE;AAC/C,sBAAiB,IAAI,OAAO;AAC5B,YAAO,QAAQ,KAAK,GAAGA,UAAQ;eACtB,WAAW,OAAO,EAAE;AAC7B,sBAAiB,IAAI,OAAO;AAC5B,YAAO,KAAK,GAAGA,UAAQ;;AAGzB,WAAO;;GAEV;AAED,SAAO;;AAGT,QAAOH;;;;;AClHT,MAAa,YAAY,gBAAgB;AACvC,QAAO;EACL,MAAM,SAAS;AACb,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,iBAAiB;AACrB,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,gBAAgB;AACpB,SAAM,IAAI,MAAM,yBAAyB;;EAE5C;EACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["exports","name","path","trimExtName","resolvedFiles: Array<KubbFile.ResolvedFile>","parseFile","write","createApp","app: App","options"],"sources":["../src/utils/Cache.ts","../src/FileManager.ts","../src/defineApp.ts","../src/createApp.ts"],"sourcesContent":["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 pLimit from 'p-limit'\n\nimport type * as KubbFile from './KubbFile.ts'\nimport { parseFile } from './parsers/parser.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName, write } from './fs.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { orderBy } from 'natural-orderby'\nimport { isDeepEqual, uniqueBy } from 'remeda'\n\ntype WriteFilesProps = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function 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\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\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 return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\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\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\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 prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\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\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\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: hashObject({ path: file.path }),\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\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #limit = pLimit(100)\n\n constructor() {\n return this\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 (const file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\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 return resolvedFiles\n }\n\n flush() {\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 }\n\n clear(): void {\n this.#cache.clear()\n }\n\n getFiles(): Array<KubbFile.ResolvedFile> {\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 = keys.map((key) => this.#cache.get(key))\n\n return files.filter(Boolean)\n }\n\n async processFiles({ dryRun, extension }: WriteFilesProps): Promise<Array<KubbFile.ResolvedFile>> {\n const files = this.getFiles()\n\n const promises = files.map((resolvedFile) => {\n return this.#limit(async () => {\n const extname = extension ? extension[resolvedFile.extname] || undefined : resolvedFile.extname\n\n if (!dryRun) {\n const source = await parseFile(resolvedFile, { extname })\n\n await write(resolvedFile.path, source, { sanity: false })\n }\n })\n })\n\n await Promise.all(promises)\n\n return files\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { FileManager } from './FileManager.ts'\nimport { isPromise } from 'remeda'\n\nconst isFunction = (val: unknown): val is Function => typeof val === 'function'\n\ntype Component = any\n\ntype PluginInstallFunction<Options = any[]> = Options extends unknown[] ? (app: App, ...options: Options) => any : (app: App, options: Options) => any\n\nexport type ObjectPlugin<Options = any[]> = {\n install: PluginInstallFunction<Options>\n}\nexport type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> & Partial<ObjectPlugin<Options>>\n\ntype AppRenderer = {\n render(): Promise<void> | void\n renderToString(): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\nexport type AppContext<TOptions = unknown> = {\n options?: TOptions\n fileManager: FileManager\n addFile(...files: Array<KubbFile.File>): Promise<void>\n files: Array<KubbFile.ResolvedFile>\n clear: () => void\n}\n\ntype RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer\n\ntype Plugin<Options = any[], P extends unknown[] = Options extends unknown[] ? Options : [Options]> = FunctionPlugin<P> | ObjectPlugin<P>\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nexport interface App {\n _component: Component\n render(): Promise<void>\n renderToString(): Promise<string>\n getFiles(): Promise<Array<KubbFile.ResolvedFile>>\n use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this\n write(options?: WriteOptions): Promise<void>\n addFile(...files: Array<KubbFile.File>): Promise<void>\n waitUntilExit(): Promise<void>\n}\n\nexport type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App\n\nexport function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext> {\n function createApp(rootComponent: Component, options?: TContext['options']): App {\n const installedPlugins = new WeakSet()\n const fileManager = new FileManager()\n const context = {\n options,\n fileManager,\n async addFile(...newFiles) {\n await fileManager.add(...newFiles)\n },\n clear() {\n context.fileManager.clear()\n },\n get files() {\n return fileManager.getFiles()\n },\n } as TContext\n\n const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)\n\n const app: App = {\n _component: rootComponent,\n async render() {\n if (isPromise(render)) {\n await render()\n } else {\n render()\n }\n },\n async renderToString() {\n return renderToString()\n },\n async getFiles() {\n return fileManager.getFiles()\n },\n waitUntilExit,\n addFile: context.addFile,\n async write(\n options = {\n extension: { '.ts': '.ts' },\n dryRun: false,\n },\n ) {\n await fileManager.processFiles({\n extension: options.extension,\n dryRun: options.dryRun,\n })\n },\n use(plugin: Plugin, ...options: any[]) {\n if (installedPlugins.has(plugin)) {\n console.warn('Plugin has already been applied to target app.')\n } else if (plugin && isFunction(plugin.install)) {\n installedPlugins.add(plugin)\n plugin.install(app, ...options)\n } else if (isFunction(plugin)) {\n installedPlugins.add(plugin)\n plugin(app, ...options)\n }\n\n return app\n },\n }\n\n return app\n }\n\n return createApp\n}\n","import { defineApp } from './defineApp.ts'\n\nexport const createApp = defineApp(() => {\n return {\n async render() {\n throw new Error('Method not implemented')\n },\n async renderToString() {\n throw new Error('Method not implemented')\n },\n async waitUntilExit() {\n throw new Error('Method not implemented')\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAsB;;4DACV,IAAI,KAAgB;;CAE9B,IAAI,KAAuB;;AACzB,6DAAO,KAAY,CAAC,IAAI,IAAI,+DAAI;;CAGlC,IAAI,KAAa,OAAgB;AAC/B,uCAAY,CAAC,IAAI,KAAK,MAAM;;CAG9B,OAAO,KAAmB;AACxB,uCAAY,CAAC,OAAO,IAAI;;CAG1B,QAAc;AACZ,uCAAY,CAAC,OAAO;;CAGtB,OAAiB;AACf,SAAO,CAAC,mCAAG,KAAY,CAAC,MAAM,CAAC;;CAGjC,SAAmB;AACjB,SAAO,CAAC,mCAAG,KAAY,CAAC,QAAQ,CAAC;;CAGnC,QAAc;;;;;ACXhB,SAAS,WAAW,KAAsC;CACxD,MAAM,MAAM,KAAK,UAAU,KAAK,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC;AACxD,oCAAkB,SAAS,CAAC,OAAO,IAAI,CAAC,OAAO,MAAM;;AAGvD,SAAgB,UAAyC,GAAyB,GAA+C;AAC/H,QAAO;EACL,GAAG;EACH,SAAS,CAAC,GAAI,EAAE,WAAW,EAAE,EAAG,GAAI,EAAE,WAAW,EAAE,CAAE;EACrD,SAAS,CAAC,GAAI,EAAE,WAAW,EAAE,E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BAAyB;;EAE3C,MAAM,iBAAiB;AACrB,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,gBAAgB;AACpB,SAAM,IAAI,MAAM,yBAAyB;;EAE5C;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,64 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./KubbFile-BrN7Wwp6.cjs";
|
|
2
|
+
import { a as FileManager, i as defineApp, n as AppContext, r as DefineApp } from "./defineApp-DKW3IRO8.cjs";
|
|
3
|
+
import { n as parseFile } from "./parser-D64DdV1v.cjs";
|
|
2
4
|
|
|
3
|
-
//#region src/FileManager.d.ts
|
|
4
|
-
type WriteFilesProps = {
|
|
5
|
-
extension?: Record<Extname, Extname | ''>;
|
|
6
|
-
dryRun?: boolean;
|
|
7
|
-
};
|
|
8
|
-
declare class FileManager {
|
|
9
|
-
#private;
|
|
10
|
-
constructor();
|
|
11
|
-
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
12
|
-
flush(): void;
|
|
13
|
-
getByPath(path: Path): ResolvedFile | null;
|
|
14
|
-
deleteByPath(path: Path): void;
|
|
15
|
-
clear(): void;
|
|
16
|
-
getFiles(): Array<ResolvedFile>;
|
|
17
|
-
processFiles({
|
|
18
|
-
dryRun,
|
|
19
|
-
extension
|
|
20
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/defineApp.d.ts
|
|
24
|
-
type Component = any;
|
|
25
|
-
type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App, ...options: Options$1) => any : (app: App, options: Options$1) => any;
|
|
26
|
-
type ObjectPlugin<Options$1 = any[]> = {
|
|
27
|
-
install: PluginInstallFunction<Options$1>;
|
|
28
|
-
};
|
|
29
|
-
type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
|
|
30
|
-
type AppRenderer = {
|
|
31
|
-
render(): Promise<void> | void;
|
|
32
|
-
renderToString(): Promise<string> | string;
|
|
33
|
-
waitUntilExit(): Promise<void>;
|
|
34
|
-
};
|
|
35
|
-
type AppContext = {
|
|
36
|
-
fileManager: FileManager;
|
|
37
|
-
addFile(...files: Array<File>): Promise<void>;
|
|
38
|
-
files: Array<ResolvedFile>;
|
|
39
|
-
clear: () => void;
|
|
40
|
-
};
|
|
41
|
-
type RootRenderFunction<THostElement = unknown> = (this: AppContext, container: THostElement, context: AppContext) => AppRenderer;
|
|
42
|
-
type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
|
|
43
|
-
interface App<_THostElement = unknown> {
|
|
44
|
-
_component: Component;
|
|
45
|
-
render(): Promise<void>;
|
|
46
|
-
renderToString(): Promise<string>;
|
|
47
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
48
|
-
use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
|
|
49
|
-
write(): Promise<void>;
|
|
50
|
-
addFile(...files: Array<File>): Promise<void>;
|
|
51
|
-
waitUntilExit(): Promise<void>;
|
|
52
|
-
}
|
|
53
|
-
type DefineOptions = {
|
|
54
|
-
extension?: Record<Extname, Extname | ''>;
|
|
55
|
-
dryRun?: boolean;
|
|
56
|
-
};
|
|
57
|
-
type DefineApp<THostElement> = (rootComponent?: Component, options?: DefineOptions) => App<THostElement>;
|
|
58
|
-
declare function defineApp<THostElement>(instance: RootRenderFunction<THostElement>): DefineApp<THostElement>;
|
|
59
|
-
//#endregion
|
|
60
5
|
//#region src/createApp.d.ts
|
|
61
|
-
declare const createApp: DefineApp<unknown
|
|
6
|
+
declare const createApp: DefineApp<AppContext<unknown>>;
|
|
62
7
|
//#endregion
|
|
63
|
-
export {
|
|
8
|
+
export { FileManager, createApp, defineApp, parseFile };
|
|
64
9
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,64 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./KubbFile-BzVkcu9M.js";
|
|
2
|
+
import { a as FileManager, i as defineApp, n as AppContext, r as DefineApp } from "./defineApp-Bg7JewJQ.js";
|
|
3
|
+
import { n as parseFile } from "./parser-yYqnryUV.js";
|
|
2
4
|
|
|
3
|
-
//#region src/FileManager.d.ts
|
|
4
|
-
type WriteFilesProps = {
|
|
5
|
-
extension?: Record<Extname, Extname | ''>;
|
|
6
|
-
dryRun?: boolean;
|
|
7
|
-
};
|
|
8
|
-
declare class FileManager {
|
|
9
|
-
#private;
|
|
10
|
-
constructor();
|
|
11
|
-
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
12
|
-
flush(): void;
|
|
13
|
-
getByPath(path: Path): ResolvedFile | null;
|
|
14
|
-
deleteByPath(path: Path): void;
|
|
15
|
-
clear(): void;
|
|
16
|
-
getFiles(): Array<ResolvedFile>;
|
|
17
|
-
processFiles({
|
|
18
|
-
dryRun,
|
|
19
|
-
extension
|
|
20
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/defineApp.d.ts
|
|
24
|
-
type Component = any;
|
|
25
|
-
type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App, ...options: Options$1) => any : (app: App, options: Options$1) => any;
|
|
26
|
-
type ObjectPlugin<Options$1 = any[]> = {
|
|
27
|
-
install: PluginInstallFunction<Options$1>;
|
|
28
|
-
};
|
|
29
|
-
type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
|
|
30
|
-
type AppRenderer = {
|
|
31
|
-
render(): Promise<void> | void;
|
|
32
|
-
renderToString(): Promise<string> | string;
|
|
33
|
-
waitUntilExit(): Promise<void>;
|
|
34
|
-
};
|
|
35
|
-
type AppContext = {
|
|
36
|
-
fileManager: FileManager;
|
|
37
|
-
addFile(...files: Array<File>): Promise<void>;
|
|
38
|
-
files: Array<ResolvedFile>;
|
|
39
|
-
clear: () => void;
|
|
40
|
-
};
|
|
41
|
-
type RootRenderFunction<THostElement = unknown> = (this: AppContext, container: THostElement, context: AppContext) => AppRenderer;
|
|
42
|
-
type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
|
|
43
|
-
interface App<_THostElement = unknown> {
|
|
44
|
-
_component: Component;
|
|
45
|
-
render(): Promise<void>;
|
|
46
|
-
renderToString(): Promise<string>;
|
|
47
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
48
|
-
use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
|
|
49
|
-
write(): Promise<void>;
|
|
50
|
-
addFile(...files: Array<File>): Promise<void>;
|
|
51
|
-
waitUntilExit(): Promise<void>;
|
|
52
|
-
}
|
|
53
|
-
type DefineOptions = {
|
|
54
|
-
extension?: Record<Extname, Extname | ''>;
|
|
55
|
-
dryRun?: boolean;
|
|
56
|
-
};
|
|
57
|
-
type DefineApp<THostElement> = (rootComponent?: Component, options?: DefineOptions) => App<THostElement>;
|
|
58
|
-
declare function defineApp<THostElement>(instance: RootRenderFunction<THostElement>): DefineApp<THostElement>;
|
|
59
|
-
//#endregion
|
|
60
5
|
//#region src/createApp.d.ts
|
|
61
|
-
declare const createApp: DefineApp<unknown
|
|
6
|
+
declare const createApp: DefineApp<AppContext<unknown>>;
|
|
62
7
|
//#endregion
|
|
63
|
-
export {
|
|
8
|
+
export { FileManager, createApp, defineApp, parseFile };
|
|
64
9
|
//# sourceMappingURL=index.d.ts.map
|