@kubb/core 0.38.0 → 0.39.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 +7 -0
- package/dist/index.global.js +18 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,11 @@ type EmittedFile = {
|
|
|
202
202
|
source?: string;
|
|
203
203
|
options?: Record<string, any>;
|
|
204
204
|
};
|
|
205
|
+
type Import = {
|
|
206
|
+
name: string | string[];
|
|
207
|
+
path: string;
|
|
208
|
+
type?: boolean;
|
|
209
|
+
};
|
|
205
210
|
type File = {
|
|
206
211
|
/**
|
|
207
212
|
* Name to be used to dynamicly create the fileName(based on input.path)
|
|
@@ -212,6 +217,7 @@ type File = {
|
|
|
212
217
|
*/
|
|
213
218
|
path: string;
|
|
214
219
|
source: string;
|
|
220
|
+
imports?: Import[];
|
|
215
221
|
};
|
|
216
222
|
type UUID = string;
|
|
217
223
|
type CacheStore = {
|
|
@@ -242,6 +248,7 @@ declare class FileManager {
|
|
|
242
248
|
private getCountByStatus;
|
|
243
249
|
get files(): File[];
|
|
244
250
|
add(file: File): Promise<File>;
|
|
251
|
+
build(file: File): string;
|
|
245
252
|
addOrAppend(file: File): Promise<File>;
|
|
246
253
|
setStatus(id: UUID, status: Status): void;
|
|
247
254
|
get(id: UUID): File | undefined;
|
package/dist/index.global.js
CHANGED
|
@@ -16901,6 +16901,21 @@ var kubb = (function (exports) {
|
|
|
16901
16901
|
});
|
|
16902
16902
|
});
|
|
16903
16903
|
}
|
|
16904
|
+
build(file) {
|
|
16905
|
+
const importSource = file.imports?.reduce((prev, curr) => {
|
|
16906
|
+
if (Array.isArray(curr.name)) {
|
|
16907
|
+
return `${prev}
|
|
16908
|
+
import ${curr.type ? "type " : ""}{ ${curr.name.join(",")} } from "${curr.path}";`;
|
|
16909
|
+
}
|
|
16910
|
+
return `${prev}
|
|
16911
|
+
import ${curr.type ? "type " : ""}${curr.name} from "${curr.path}";`;
|
|
16912
|
+
}, "");
|
|
16913
|
+
if (importSource) {
|
|
16914
|
+
return `${importSource}
|
|
16915
|
+
${file.source}`;
|
|
16916
|
+
}
|
|
16917
|
+
return file.source;
|
|
16918
|
+
}
|
|
16904
16919
|
addOrAppend(file) {
|
|
16905
16920
|
const previousCache = this.getCacheByPath(file.path);
|
|
16906
16921
|
if (previousCache) {
|
|
@@ -16908,7 +16923,8 @@ var kubb = (function (exports) {
|
|
|
16908
16923
|
return this.add({
|
|
16909
16924
|
...file,
|
|
16910
16925
|
source: `${previousCache.file.source}
|
|
16911
|
-
${file.source}
|
|
16926
|
+
${file.source}`,
|
|
16927
|
+
imports: [...previousCache.file.imports || [], ...file.imports || []]
|
|
16912
16928
|
});
|
|
16913
16929
|
}
|
|
16914
16930
|
return this.add(file);
|
|
@@ -17244,7 +17260,7 @@ ${file.source}`
|
|
|
17244
17260
|
});
|
|
17245
17261
|
fileManager.events.onAdd(async (id, file) => {
|
|
17246
17262
|
const { path } = file;
|
|
17247
|
-
let
|
|
17263
|
+
let code = fileManager.build(file);
|
|
17248
17264
|
const loadedResult = await pluginManager.hookFirst("load", [path]);
|
|
17249
17265
|
if (loadedResult) {
|
|
17250
17266
|
code = loadedResult;
|