@kubb/core 0.41.0 → 0.42.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/index.d.ts +12 -2
- package/dist/index.global.js +29 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -183,7 +183,7 @@ declare const clean: (path: string) => Promise<unknown>;
|
|
|
183
183
|
|
|
184
184
|
declare const getRelativePath: (root?: string | null, file?: string | null) => string;
|
|
185
185
|
type PathMode = 'file' | 'directory';
|
|
186
|
-
declare const getPathMode: (path: string | undefined | null) => PathMode
|
|
186
|
+
declare const getPathMode: (path: string | undefined | null) => PathMode;
|
|
187
187
|
declare const read: (path: string) => Promise<string>;
|
|
188
188
|
|
|
189
189
|
type Import = {
|
|
@@ -233,8 +233,18 @@ declare class FileManager {
|
|
|
233
233
|
private getSource;
|
|
234
234
|
get files(): File[];
|
|
235
235
|
add(file: File): Promise<File>;
|
|
236
|
-
build(file: File): string;
|
|
237
236
|
addOrAppend(file: File): Promise<File>;
|
|
237
|
+
build(file: File): {
|
|
238
|
+
source: string;
|
|
239
|
+
fileName: string;
|
|
240
|
+
path: string;
|
|
241
|
+
imports?: {
|
|
242
|
+
name: string | string[];
|
|
243
|
+
path: string;
|
|
244
|
+
type?: boolean | undefined;
|
|
245
|
+
}[] | undefined;
|
|
246
|
+
};
|
|
247
|
+
combine(files: Array<File | null>): File[];
|
|
238
248
|
setStatus(id: UUID, status: Status): void;
|
|
239
249
|
get(id: UUID): File | undefined;
|
|
240
250
|
remove(id: UUID): void;
|
package/dist/index.global.js
CHANGED
|
@@ -16991,7 +16991,7 @@ var kubb = (function (exports) {
|
|
|
16991
16991
|
};
|
|
16992
16992
|
var getPathMode = (path) => {
|
|
16993
16993
|
if (!path) {
|
|
16994
|
-
return
|
|
16994
|
+
return "directory";
|
|
16995
16995
|
}
|
|
16996
16996
|
return import_path2.default.extname(path) ? "file" : "directory";
|
|
16997
16997
|
};
|
|
@@ -17204,6 +17204,9 @@ var kubb = (function (exports) {
|
|
|
17204
17204
|
return count;
|
|
17205
17205
|
}
|
|
17206
17206
|
getSource(file) {
|
|
17207
|
+
if (!file.fileName.endsWith(".ts")) {
|
|
17208
|
+
return file.source;
|
|
17209
|
+
}
|
|
17207
17210
|
const imports = [];
|
|
17208
17211
|
file.imports?.forEach((curr) => {
|
|
17209
17212
|
const exists = imports.find((imp) => imp.path === curr.path);
|
|
@@ -17247,9 +17250,6 @@ ${file.source}`;
|
|
|
17247
17250
|
});
|
|
17248
17251
|
});
|
|
17249
17252
|
}
|
|
17250
|
-
build(file) {
|
|
17251
|
-
return this.getSource(file);
|
|
17252
|
-
}
|
|
17253
17253
|
addOrAppend(file) {
|
|
17254
17254
|
const previousCache = this.getCacheByPath(file.path);
|
|
17255
17255
|
if (previousCache) {
|
|
@@ -17263,6 +17263,29 @@ ${file.source}`,
|
|
|
17263
17263
|
}
|
|
17264
17264
|
return this.add(file);
|
|
17265
17265
|
}
|
|
17266
|
+
build(file) {
|
|
17267
|
+
return {
|
|
17268
|
+
...file,
|
|
17269
|
+
source: this.getSource(file)
|
|
17270
|
+
};
|
|
17271
|
+
}
|
|
17272
|
+
combine(files) {
|
|
17273
|
+
return files.filter(Boolean).reduce((acc, curr) => {
|
|
17274
|
+
const prevIndex = acc.findIndex((item) => item.path === curr.path);
|
|
17275
|
+
if (prevIndex !== -1) {
|
|
17276
|
+
const prev = acc[prevIndex];
|
|
17277
|
+
acc[prevIndex] = {
|
|
17278
|
+
...curr,
|
|
17279
|
+
source: `${prev.source}
|
|
17280
|
+
${curr.source}`,
|
|
17281
|
+
imports: [...prev.imports || [], ...curr.imports || []]
|
|
17282
|
+
};
|
|
17283
|
+
} else {
|
|
17284
|
+
acc.push(curr);
|
|
17285
|
+
}
|
|
17286
|
+
return acc;
|
|
17287
|
+
}, []);
|
|
17288
|
+
}
|
|
17266
17289
|
setStatus(id, status) {
|
|
17267
17290
|
const cacheItem = this.getCache(id);
|
|
17268
17291
|
if (!cacheItem) {
|
|
@@ -17589,12 +17612,12 @@ ${file.source}`,
|
|
|
17589
17612
|
fileManager.events.onSuccess(async () => {
|
|
17590
17613
|
await pluginManager.hookParallel("buildEnd");
|
|
17591
17614
|
setTimeout(() => {
|
|
17592
|
-
done({ files: fileManager.files });
|
|
17615
|
+
done({ files: fileManager.files.map((file) => fileManager.build(file)) });
|
|
17593
17616
|
}, 1e3);
|
|
17594
17617
|
});
|
|
17595
17618
|
fileManager.events.onAdd(async (id, file) => {
|
|
17596
17619
|
const { path } = file;
|
|
17597
|
-
let code = fileManager.build(file);
|
|
17620
|
+
let { source: code } = fileManager.build(file);
|
|
17598
17621
|
const loadedResult = await pluginManager.hookFirst("load", [path]);
|
|
17599
17622
|
if (loadedResult) {
|
|
17600
17623
|
code = loadedResult;
|