@kubb/fabric-core 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/createFileParser-BD8yn0LT.cjs +14 -0
- package/dist/createFileParser-BD8yn0LT.cjs.map +1 -0
- package/dist/createFileParser-Cix3AMLd.js +8 -0
- package/dist/createFileParser-Cix3AMLd.js.map +1 -0
- package/dist/default-DCpuPmrL.js +10 -0
- package/dist/default-DCpuPmrL.js.map +1 -0
- package/dist/default-DNBu_jsL.cjs +15 -0
- package/dist/default-DNBu_jsL.cjs.map +1 -0
- package/dist/defineApp-CZYKsxTp.d.ts +95 -0
- package/dist/defineApp-c9lWJ96_.d.cts +95 -0
- package/dist/index.cjs +146 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -60
- package/dist/index.d.ts +13 -60
- package/dist/index.js +136 -76
- package/dist/index.js.map +1 -1
- package/dist/parsers/default.cjs +4 -0
- package/dist/parsers/default.d.cts +8 -0
- package/dist/parsers/default.d.ts +8 -0
- package/dist/parsers/default.js +4 -0
- package/dist/parsers/tsx.cjs +4 -2
- package/dist/parsers/tsx.d.cts +3 -3
- package/dist/parsers/tsx.d.ts +3 -3
- package/dist/parsers/tsx.js +3 -1
- package/dist/parsers/typescript.cjs +6 -5
- package/dist/parsers/typescript.d.cts +3 -3
- package/dist/parsers/typescript.d.ts +3 -3
- package/dist/parsers/typescript.js +2 -1
- package/dist/tsx-BSUaIML3.cjs +16 -0
- package/dist/tsx-BSUaIML3.cjs.map +1 -0
- package/dist/tsx-DBAk9dqS.js +11 -0
- package/dist/tsx-DBAk9dqS.js.map +1 -0
- package/dist/types-CkbelZaS.d.ts +15 -0
- package/dist/types-GueHciQ3.d.cts +15 -0
- 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/dist/{parser-CWB_OBtr.js → typescript-C60gWBu8.js} +4 -34
- package/dist/typescript-C60gWBu8.js.map +1 -0
- package/dist/{parser-QF8j8-pj.cjs → typescript-Z90jN87k.cjs} +5 -47
- package/dist/typescript-Z90jN87k.cjs.map +1 -0
- package/package.json +15 -1
- package/src/FileManager.ts +21 -200
- package/src/FileProcessor.ts +86 -0
- package/src/KubbFile.ts +132 -0
- package/src/createFile.ts +167 -0
- package/src/defineApp.ts +6 -6
- package/src/index.ts +4 -2
- package/src/parsers/createFileParser.ts +5 -0
- package/src/parsers/default.ts +7 -0
- package/src/parsers/tsx.ts +1 -1
- package/src/parsers/types.ts +12 -0
- package/src/parsers/typescript.ts +1 -1
- package/src/types.ts +2 -132
- package/src/utils/EventEmitter.ts +23 -0
- package/dist/parser-Bck6QDwN.d.cts +0 -15
- package/dist/parser-CRl-iUw1.d.ts +0 -15
- package/dist/parser-CWB_OBtr.js.map +0 -1
- package/dist/parser-QF8j8-pj.cjs.map +0 -1
- package/src/parsers/parser.ts +0 -56
|
@@ -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,14 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/parsers/createFileParser.ts
|
|
3
|
+
function createFileParser(parser) {
|
|
4
|
+
return parser;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
Object.defineProperty(exports, 'createFileParser', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return createFileParser;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=createFileParser-BD8yn0LT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileParser-BD8yn0LT.cjs","names":[],"sources":["../src/parsers/createFileParser.ts"],"sourcesContent":["import type { Parser } from './types.ts'\n\nexport function createFileParser<TMeta extends object = object>(parser: Parser<TMeta>): Parser<TMeta> {\n return parser\n}\n"],"mappings":";;AAEA,SAAgB,iBAAgD,QAAsC;AACpG,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileParser-Cix3AMLd.js","names":[],"sources":["../src/parsers/createFileParser.ts"],"sourcesContent":["import type { Parser } from './types.ts'\n\nexport function createFileParser<TMeta extends object = object>(parser: Parser<TMeta>): Parser<TMeta> {\n return parser\n}\n"],"mappings":";AAEA,SAAgB,iBAAgD,QAAsC;AACpG,QAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as createFileParser } from "./createFileParser-Cix3AMLd.js";
|
|
2
|
+
|
|
3
|
+
//#region src/parsers/default.ts
|
|
4
|
+
const defaultParser = createFileParser({ async print(file) {
|
|
5
|
+
return file.sources.map((item) => item.value).join("\n\n");
|
|
6
|
+
} });
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { defaultParser as t };
|
|
10
|
+
//# sourceMappingURL=default-DCpuPmrL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-DCpuPmrL.js","names":[],"sources":["../src/parsers/default.ts"],"sourcesContent":["import { createFileParser } from './createFileParser.ts'\n\nexport const defaultParser = createFileParser({\n async print(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgB,iBAAiB,EAC5C,MAAM,MAAM,MAAM;AAChB,QAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;GAE7D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const require_createFileParser = require('./createFileParser-BD8yn0LT.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/parsers/default.ts
|
|
4
|
+
const defaultParser = require_createFileParser.createFileParser({ async print(file) {
|
|
5
|
+
return file.sources.map((item) => item.value).join("\n\n");
|
|
6
|
+
} });
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
Object.defineProperty(exports, 'defaultParser', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return defaultParser;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=default-DNBu_jsL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-DNBu_jsL.cjs","names":["createFileParser"],"sources":["../src/parsers/default.ts"],"sourcesContent":["import { createFileParser } from './createFileParser.ts'\n\nexport const defaultParser = createFileParser({\n async print(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgBA,0CAAiB,EAC5C,MAAM,MAAM,MAAM;AAChB,QAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;GAE7D,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { a as ResolvedFile, i as Path, n as File, t as Extname } from "./KubbFile-BzVkcu9M.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/EventEmitter.d.ts
|
|
4
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(maxListener?: number);
|
|
7
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
8
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
9
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
10
|
+
removeAll(): void;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/FileProcessor.d.ts
|
|
14
|
+
type FileProcessorEvents = {
|
|
15
|
+
start: [{
|
|
16
|
+
files: ResolvedFile[];
|
|
17
|
+
}];
|
|
18
|
+
finish: [{
|
|
19
|
+
files: ResolvedFile[];
|
|
20
|
+
}];
|
|
21
|
+
'file:start': [{
|
|
22
|
+
file: ResolvedFile;
|
|
23
|
+
}];
|
|
24
|
+
'file:finish': [{
|
|
25
|
+
file: ResolvedFile;
|
|
26
|
+
}];
|
|
27
|
+
};
|
|
28
|
+
type ProcessFilesProps = {
|
|
29
|
+
extension?: Record<Extname, Extname | ''>;
|
|
30
|
+
dryRun?: boolean;
|
|
31
|
+
};
|
|
32
|
+
declare class FileProcessor extends EventEmitter<FileProcessorEvents> {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(maxListener?: number);
|
|
35
|
+
run(files: Array<ResolvedFile>, {
|
|
36
|
+
dryRun,
|
|
37
|
+
extension
|
|
38
|
+
}: ProcessFilesProps): Promise<ResolvedFile[]>;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/FileManager.d.ts
|
|
42
|
+
declare class FileManager {
|
|
43
|
+
#private;
|
|
44
|
+
constructor();
|
|
45
|
+
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
46
|
+
flush(): void;
|
|
47
|
+
getByPath(path: Path): ResolvedFile | null;
|
|
48
|
+
deleteByPath(path: Path): void;
|
|
49
|
+
clear(): void;
|
|
50
|
+
get files(): Array<ResolvedFile>;
|
|
51
|
+
get processor(): {
|
|
52
|
+
run(options: ProcessFilesProps): Promise<ResolvedFile<object>[]>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/defineApp.d.ts
|
|
57
|
+
type Component = any;
|
|
58
|
+
type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App, ...options: Options$1) => any : (app: App, options: Options$1) => any;
|
|
59
|
+
type ObjectPlugin<Options$1 = any[]> = {
|
|
60
|
+
install: PluginInstallFunction<Options$1>;
|
|
61
|
+
};
|
|
62
|
+
type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
|
|
63
|
+
type AppRenderer = {
|
|
64
|
+
render(): Promise<void> | void;
|
|
65
|
+
renderToString(): Promise<string> | string;
|
|
66
|
+
waitUntilExit(): Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
type AppContext<TOptions = unknown> = {
|
|
69
|
+
options?: TOptions;
|
|
70
|
+
fileManager: FileManager;
|
|
71
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
72
|
+
files: Array<ResolvedFile>;
|
|
73
|
+
clear: () => void;
|
|
74
|
+
};
|
|
75
|
+
type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
|
|
76
|
+
type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
|
|
77
|
+
type WriteOptions = {
|
|
78
|
+
extension?: Record<Extname, Extname | ''>;
|
|
79
|
+
dryRun?: boolean;
|
|
80
|
+
};
|
|
81
|
+
interface App {
|
|
82
|
+
_component: Component;
|
|
83
|
+
render(): Promise<void>;
|
|
84
|
+
renderToString(): Promise<string>;
|
|
85
|
+
files: Array<ResolvedFile>;
|
|
86
|
+
use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
|
|
87
|
+
write(options?: WriteOptions): Promise<void>;
|
|
88
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
89
|
+
waitUntilExit(): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
|
|
92
|
+
declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { FileManager as a, defineApp as i, AppContext as n, FileProcessor as o, DefineApp as r, App as t };
|
|
95
|
+
//# sourceMappingURL=defineApp-CZYKsxTp.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { a as ResolvedFile, i as Path, n as File, t as Extname } from "./KubbFile-BrN7Wwp6.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/EventEmitter.d.ts
|
|
4
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(maxListener?: number);
|
|
7
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
8
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
9
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
10
|
+
removeAll(): void;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/FileProcessor.d.ts
|
|
14
|
+
type FileProcessorEvents = {
|
|
15
|
+
start: [{
|
|
16
|
+
files: ResolvedFile[];
|
|
17
|
+
}];
|
|
18
|
+
finish: [{
|
|
19
|
+
files: ResolvedFile[];
|
|
20
|
+
}];
|
|
21
|
+
'file:start': [{
|
|
22
|
+
file: ResolvedFile;
|
|
23
|
+
}];
|
|
24
|
+
'file:finish': [{
|
|
25
|
+
file: ResolvedFile;
|
|
26
|
+
}];
|
|
27
|
+
};
|
|
28
|
+
type ProcessFilesProps = {
|
|
29
|
+
extension?: Record<Extname, Extname | ''>;
|
|
30
|
+
dryRun?: boolean;
|
|
31
|
+
};
|
|
32
|
+
declare class FileProcessor extends EventEmitter<FileProcessorEvents> {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(maxListener?: number);
|
|
35
|
+
run(files: Array<ResolvedFile>, {
|
|
36
|
+
dryRun,
|
|
37
|
+
extension
|
|
38
|
+
}: ProcessFilesProps): Promise<ResolvedFile[]>;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/FileManager.d.ts
|
|
42
|
+
declare class FileManager {
|
|
43
|
+
#private;
|
|
44
|
+
constructor();
|
|
45
|
+
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
46
|
+
flush(): void;
|
|
47
|
+
getByPath(path: Path): ResolvedFile | null;
|
|
48
|
+
deleteByPath(path: Path): void;
|
|
49
|
+
clear(): void;
|
|
50
|
+
get files(): Array<ResolvedFile>;
|
|
51
|
+
get processor(): {
|
|
52
|
+
run(options: ProcessFilesProps): Promise<ResolvedFile<object>[]>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/defineApp.d.ts
|
|
57
|
+
type Component = any;
|
|
58
|
+
type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App, ...options: Options$1) => any : (app: App, options: Options$1) => any;
|
|
59
|
+
type ObjectPlugin<Options$1 = any[]> = {
|
|
60
|
+
install: PluginInstallFunction<Options$1>;
|
|
61
|
+
};
|
|
62
|
+
type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
|
|
63
|
+
type AppRenderer = {
|
|
64
|
+
render(): Promise<void> | void;
|
|
65
|
+
renderToString(): Promise<string> | string;
|
|
66
|
+
waitUntilExit(): Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
type AppContext<TOptions = unknown> = {
|
|
69
|
+
options?: TOptions;
|
|
70
|
+
fileManager: FileManager;
|
|
71
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
72
|
+
files: Array<ResolvedFile>;
|
|
73
|
+
clear: () => void;
|
|
74
|
+
};
|
|
75
|
+
type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
|
|
76
|
+
type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
|
|
77
|
+
type WriteOptions = {
|
|
78
|
+
extension?: Record<Extname, Extname | ''>;
|
|
79
|
+
dryRun?: boolean;
|
|
80
|
+
};
|
|
81
|
+
interface App {
|
|
82
|
+
_component: Component;
|
|
83
|
+
render(): Promise<void>;
|
|
84
|
+
renderToString(): Promise<string>;
|
|
85
|
+
files: Array<ResolvedFile>;
|
|
86
|
+
use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
|
|
87
|
+
write(options?: WriteOptions): Promise<void>;
|
|
88
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
89
|
+
waitUntilExit(): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
|
|
92
|
+
declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { FileManager as a, defineApp as i, AppContext as n, FileProcessor as o, DefineApp as r, App as t };
|
|
95
|
+
//# sourceMappingURL=defineApp-c9lWJ96_.d.cts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const require_typescript = require('./typescript-Z90jN87k.cjs');
|
|
2
|
+
const require_createFileParser = require('./createFileParser-BD8yn0LT.cjs');
|
|
3
|
+
const require_tsx = require('./tsx-BSUaIML3.cjs');
|
|
4
|
+
const require_default = require('./default-DNBu_jsL.cjs');
|
|
4
5
|
let node_path = require("node:path");
|
|
5
|
-
node_path =
|
|
6
|
-
let node_crypto = require("node:crypto");
|
|
7
|
-
node_crypto = require_parser.__toESM(node_crypto);
|
|
6
|
+
node_path = require_typescript.__toESM(node_path);
|
|
8
7
|
let natural_orderby = require("natural-orderby");
|
|
9
|
-
natural_orderby =
|
|
8
|
+
natural_orderby = require_typescript.__toESM(natural_orderby);
|
|
9
|
+
let node_crypto = require("node:crypto");
|
|
10
|
+
node_crypto = require_typescript.__toESM(node_crypto);
|
|
10
11
|
let remeda = require("remeda");
|
|
11
|
-
remeda =
|
|
12
|
+
remeda = require_typescript.__toESM(remeda);
|
|
13
|
+
let node_events = require("node:events");
|
|
14
|
+
node_events = require_typescript.__toESM(node_events);
|
|
15
|
+
let p_limit = require("p-limit");
|
|
16
|
+
p_limit = require_typescript.__toESM(p_limit);
|
|
12
17
|
|
|
13
18
|
//#region \0@oxc-project+runtime@0.95.0/helpers/checkPrivateRedeclaration.js
|
|
14
19
|
function _checkPrivateRedeclaration(e, t) {
|
|
@@ -64,74 +69,11 @@ var Cache = class {
|
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
//#endregion
|
|
67
|
-
//#region src/
|
|
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
|
-
};
|
|
72
|
+
//#region src/createFile.ts
|
|
123
73
|
function hashObject(obj) {
|
|
124
74
|
const str = JSON.stringify(obj, Object.keys(obj).sort());
|
|
125
75
|
return (0, node_crypto.createHash)("sha256").update(str).digest("hex");
|
|
126
76
|
}
|
|
127
|
-
function mergeFile(a, b) {
|
|
128
|
-
return {
|
|
129
|
-
...a,
|
|
130
|
-
sources: [...a.sources || [], ...b.sources || []],
|
|
131
|
-
imports: [...a.imports || [], ...b.imports || []],
|
|
132
|
-
exports: [...a.exports || [], ...b.exports || []]
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
77
|
function combineSources(sources) {
|
|
136
78
|
return (0, remeda.uniqueBy)(sources, (obj) => [
|
|
137
79
|
obj.name,
|
|
@@ -210,7 +152,7 @@ function createFile(file) {
|
|
|
210
152
|
return {
|
|
211
153
|
...file,
|
|
212
154
|
id: hashObject({ path: file.path }),
|
|
213
|
-
name:
|
|
155
|
+
name: require_typescript.trimExtName(file.baseName),
|
|
214
156
|
extname,
|
|
215
157
|
imports,
|
|
216
158
|
exports: exports$1,
|
|
@@ -219,6 +161,129 @@ function createFile(file) {
|
|
|
219
161
|
};
|
|
220
162
|
}
|
|
221
163
|
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/utils/EventEmitter.ts
|
|
166
|
+
var _emitter = /* @__PURE__ */ new WeakMap();
|
|
167
|
+
var EventEmitter = class {
|
|
168
|
+
constructor(maxListener = 100) {
|
|
169
|
+
_classPrivateFieldInitSpec(this, _emitter, new node_events.EventEmitter());
|
|
170
|
+
_classPrivateFieldGet2(_emitter, this).setMaxListeners(maxListener);
|
|
171
|
+
}
|
|
172
|
+
emit(eventName, ...eventArg) {
|
|
173
|
+
_classPrivateFieldGet2(_emitter, this).emit(eventName, ...eventArg);
|
|
174
|
+
}
|
|
175
|
+
on(eventName, handler) {
|
|
176
|
+
_classPrivateFieldGet2(_emitter, this).on(eventName, handler);
|
|
177
|
+
}
|
|
178
|
+
off(eventName, handler) {
|
|
179
|
+
_classPrivateFieldGet2(_emitter, this).off(eventName, handler);
|
|
180
|
+
}
|
|
181
|
+
removeAll() {
|
|
182
|
+
_classPrivateFieldGet2(_emitter, this).removeAllListeners();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/FileProcessor.ts
|
|
188
|
+
async function getParser(extname) {
|
|
189
|
+
const parsers = {
|
|
190
|
+
".ts": require_typescript.typeScriptParser,
|
|
191
|
+
".js": require_typescript.typeScriptParser,
|
|
192
|
+
".jsx": require_tsx.tsxParser,
|
|
193
|
+
".tsx": require_tsx.tsxParser,
|
|
194
|
+
".json": require_default.defaultParser
|
|
195
|
+
};
|
|
196
|
+
if (!extname) return require_default.defaultParser;
|
|
197
|
+
const parser = parsers[extname];
|
|
198
|
+
if (!parser) console.warn(`[parser] No parser found for ${extname}, default parser will be used`);
|
|
199
|
+
return parser || require_default.defaultParser;
|
|
200
|
+
}
|
|
201
|
+
async function parseFile(file, { extname } = {}) {
|
|
202
|
+
return (await getParser(file.extname)).print(file, { extname });
|
|
203
|
+
}
|
|
204
|
+
var _limit = /* @__PURE__ */ new WeakMap();
|
|
205
|
+
var FileProcessor = class extends EventEmitter {
|
|
206
|
+
constructor(maxListener = 1e3) {
|
|
207
|
+
super(maxListener);
|
|
208
|
+
_classPrivateFieldInitSpec(this, _limit, (0, p_limit.default)(100));
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
async run(files, { dryRun, extension }) {
|
|
212
|
+
this.emit("start", { files });
|
|
213
|
+
const promises = files.map((resolvedFile) => _classPrivateFieldGet2(_limit, this).call(this, async () => {
|
|
214
|
+
const extname = (extension === null || extension === void 0 ? void 0 : extension[resolvedFile.extname]) || void 0;
|
|
215
|
+
this.emit("file:start", { file: resolvedFile });
|
|
216
|
+
if (!dryRun) {
|
|
217
|
+
const source = await parseFile(resolvedFile, { extname });
|
|
218
|
+
await require_typescript.write(resolvedFile.path, source, { sanity: false });
|
|
219
|
+
}
|
|
220
|
+
this.emit("file:finish", { file: resolvedFile });
|
|
221
|
+
}));
|
|
222
|
+
await Promise.all(promises);
|
|
223
|
+
this.emit("finish", { files });
|
|
224
|
+
return files;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/FileManager.ts
|
|
230
|
+
function mergeFile(a, b) {
|
|
231
|
+
return {
|
|
232
|
+
...a,
|
|
233
|
+
sources: [...a.sources || [], ...b.sources || []],
|
|
234
|
+
imports: [...a.imports || [], ...b.imports || []],
|
|
235
|
+
exports: [...a.exports || [], ...b.exports || []]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
var _cache = /* @__PURE__ */ new WeakMap();
|
|
239
|
+
var _processor = /* @__PURE__ */ new WeakMap();
|
|
240
|
+
var FileManager = class {
|
|
241
|
+
constructor() {
|
|
242
|
+
_classPrivateFieldInitSpec(this, _cache, new Cache());
|
|
243
|
+
_classPrivateFieldInitSpec(this, _processor, new FileProcessor());
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
async add(...files) {
|
|
247
|
+
const resolvedFiles = [];
|
|
248
|
+
const mergedFiles = /* @__PURE__ */ new Map();
|
|
249
|
+
files.forEach((file) => {
|
|
250
|
+
const existing = mergedFiles.get(file.path);
|
|
251
|
+
if (existing) mergedFiles.set(file.path, mergeFile(existing, file));
|
|
252
|
+
else mergedFiles.set(file.path, file);
|
|
253
|
+
});
|
|
254
|
+
for (const file of mergedFiles.values()) {
|
|
255
|
+
const existing = _classPrivateFieldGet2(_cache, this).get(file.path);
|
|
256
|
+
const resolvedFile = createFile(existing ? mergeFile(existing, file) : file);
|
|
257
|
+
_classPrivateFieldGet2(_cache, this).set(resolvedFile.path, resolvedFile);
|
|
258
|
+
this.flush();
|
|
259
|
+
resolvedFiles.push(resolvedFile);
|
|
260
|
+
}
|
|
261
|
+
return resolvedFiles;
|
|
262
|
+
}
|
|
263
|
+
flush() {
|
|
264
|
+
_classPrivateFieldGet2(_cache, this).flush();
|
|
265
|
+
}
|
|
266
|
+
getByPath(path$1) {
|
|
267
|
+
return _classPrivateFieldGet2(_cache, this).get(path$1);
|
|
268
|
+
}
|
|
269
|
+
deleteByPath(path$1) {
|
|
270
|
+
_classPrivateFieldGet2(_cache, this).delete(path$1);
|
|
271
|
+
}
|
|
272
|
+
clear() {
|
|
273
|
+
_classPrivateFieldGet2(_cache, this).clear();
|
|
274
|
+
}
|
|
275
|
+
get files() {
|
|
276
|
+
return (0, natural_orderby.orderBy)(_classPrivateFieldGet2(_cache, this).keys(), [(v) => v.length, (v) => require_typescript.trimExtName(v).endsWith("index")]).map((key) => _classPrivateFieldGet2(_cache, this).get(key)).filter(Boolean);
|
|
277
|
+
}
|
|
278
|
+
get processor() {
|
|
279
|
+
const files = this.files;
|
|
280
|
+
const processor = _classPrivateFieldGet2(_processor, this);
|
|
281
|
+
return { async run(options) {
|
|
282
|
+
return processor.run(files, options);
|
|
283
|
+
} };
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
222
287
|
//#endregion
|
|
223
288
|
//#region src/defineApp.ts
|
|
224
289
|
const isFunction = (val) => typeof val === "function";
|
|
@@ -236,7 +301,7 @@ function defineApp(instance) {
|
|
|
236
301
|
context.fileManager.clear();
|
|
237
302
|
},
|
|
238
303
|
get files() {
|
|
239
|
-
return fileManager.
|
|
304
|
+
return fileManager.files;
|
|
240
305
|
}
|
|
241
306
|
};
|
|
242
307
|
const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context);
|
|
@@ -249,8 +314,8 @@ function defineApp(instance) {
|
|
|
249
314
|
async renderToString() {
|
|
250
315
|
return renderToString();
|
|
251
316
|
},
|
|
252
|
-
|
|
253
|
-
return fileManager.
|
|
317
|
+
get files() {
|
|
318
|
+
return fileManager.files;
|
|
254
319
|
},
|
|
255
320
|
waitUntilExit,
|
|
256
321
|
addFile: context.addFile,
|
|
@@ -258,7 +323,7 @@ function defineApp(instance) {
|
|
|
258
323
|
extension: { ".ts": ".ts" },
|
|
259
324
|
dryRun: false
|
|
260
325
|
}) {
|
|
261
|
-
await fileManager.
|
|
326
|
+
await fileManager.processor.run({
|
|
262
327
|
extension: options$1.extension,
|
|
263
328
|
dryRun: options$1.dryRun
|
|
264
329
|
});
|
|
@@ -297,16 +362,10 @@ const createApp = defineApp(() => {
|
|
|
297
362
|
});
|
|
298
363
|
|
|
299
364
|
//#endregion
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
//#endregion
|
|
304
|
-
Object.defineProperty(exports, 'KubbFile', {
|
|
305
|
-
enumerable: true,
|
|
306
|
-
get: function () {
|
|
307
|
-
return types_exports;
|
|
308
|
-
}
|
|
309
|
-
});
|
|
365
|
+
exports.FileManager = FileManager;
|
|
366
|
+
exports.FileProcessor = FileProcessor;
|
|
310
367
|
exports.createApp = createApp;
|
|
368
|
+
exports.createFile = createFile;
|
|
369
|
+
exports.createFileParser = require_createFileParser.createFileParser;
|
|
311
370
|
exports.defineApp = defineApp;
|
|
312
371
|
//# sourceMappingURL=index.cjs.map
|