@kubb/fabric-core 0.1.1 → 0.1.3
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/App-DUFbq4lD.d.ts +292 -0
- package/dist/App-DoQNlnGL.d.cts +292 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/defineApp-C6WnoREI.d.ts +14 -0
- package/dist/defineApp-D1-njmtr.d.cts +14 -0
- package/dist/index.cjs +159 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +148 -77
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.cjs +5 -6
- package/dist/parsers/typescript.d.cts +3 -51
- package/dist/parsers/typescript.d.ts +3 -51
- package/dist/parsers/typescript.js +2 -3
- package/dist/parsers.cjs +7 -0
- package/dist/parsers.d.cts +14 -0
- package/dist/parsers.d.ts +14 -0
- package/dist/parsers.js +4 -0
- package/dist/plugins.cjs +76 -0
- package/dist/plugins.cjs.map +1 -0
- package/dist/plugins.d.cts +28 -0
- package/dist/plugins.d.ts +28 -0
- package/dist/plugins.js +71 -0
- package/dist/plugins.js.map +1 -0
- package/dist/tsxParser-C741ZKCN.js +26 -0
- package/dist/tsxParser-C741ZKCN.js.map +1 -0
- package/dist/tsxParser-HDf_3TMc.cjs +37 -0
- package/dist/tsxParser-HDf_3TMc.cjs.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/{typescript-C60gWBu8.js → typescriptParser-BBGeFKlP.js} +52 -69
- package/dist/typescriptParser-BBGeFKlP.js.map +1 -0
- package/dist/{typescript-Z90jN87k.cjs → typescriptParser-BBbbmG5W.cjs} +61 -108
- package/dist/typescriptParser-BBbbmG5W.cjs.map +1 -0
- package/dist/typescriptParser-C9WJrwRd.d.ts +50 -0
- package/dist/typescriptParser-DOD1_QTe.d.cts +50 -0
- package/package.json +13 -13
- package/src/App.ts +91 -0
- package/src/FileManager.ts +12 -12
- package/src/FileProcessor.ts +48 -49
- package/src/createFile.ts +1 -1
- package/src/defineApp.ts +47 -72
- package/src/index.ts +1 -1
- package/src/parsers/createParser.ts +8 -0
- package/src/parsers/defaultParser.ts +10 -0
- package/src/parsers/index.ts +5 -0
- package/src/parsers/tsxParser.ts +11 -0
- package/src/parsers/types.ts +12 -2
- package/src/parsers/{typescript.ts → typescriptParser.ts} +8 -4
- package/src/plugins/createPlugin.ts +10 -0
- package/src/plugins/fsPlugin.ts +112 -0
- package/src/plugins/index.ts +3 -0
- package/src/plugins/types.ts +15 -0
- package/src/types.ts +4 -1
- package/src/utils/AsyncEventEmitter.ts +37 -0
- package/src/utils/getRelativePath.ts +32 -0
- package/src/utils/trimExtName.ts +3 -0
- package/dist/KubbFile-BrN7Wwp6.d.cts +0 -119
- package/dist/KubbFile-BzVkcu9M.d.ts +0 -119
- package/dist/createFileParser-BD8yn0LT.cjs +0 -14
- package/dist/createFileParser-BD8yn0LT.cjs.map +0 -1
- package/dist/createFileParser-Cix3AMLd.js +0 -8
- package/dist/createFileParser-Cix3AMLd.js.map +0 -1
- package/dist/default-DCpuPmrL.js +0 -10
- package/dist/default-DCpuPmrL.js.map +0 -1
- package/dist/default-DNBu_jsL.cjs +0 -15
- package/dist/default-DNBu_jsL.cjs.map +0 -1
- package/dist/defineApp-CZYKsxTp.d.ts +0 -95
- package/dist/defineApp-c9lWJ96_.d.cts +0 -95
- package/dist/parsers/default.cjs +0 -4
- package/dist/parsers/default.d.cts +0 -8
- package/dist/parsers/default.d.ts +0 -8
- package/dist/parsers/default.js +0 -4
- package/dist/parsers/tsx.cjs +0 -5
- package/dist/parsers/tsx.d.cts +0 -8
- package/dist/parsers/tsx.d.ts +0 -8
- package/dist/parsers/tsx.js +0 -5
- package/dist/tsx-BSUaIML3.cjs +0 -16
- package/dist/tsx-BSUaIML3.cjs.map +0 -1
- package/dist/tsx-DBAk9dqS.js +0 -11
- package/dist/tsx-DBAk9dqS.js.map +0 -1
- package/dist/types-CkbelZaS.d.ts +0 -15
- package/dist/types-GueHciQ3.d.cts +0 -15
- package/dist/typescript-C60gWBu8.js.map +0 -1
- package/dist/typescript-Z90jN87k.cjs.map +0 -1
- package/src/fs.ts +0 -167
- package/src/parsers/createFileParser.ts +0 -5
- package/src/parsers/default.ts +0 -7
- package/src/parsers/tsx.ts +0 -8
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
declare namespace KubbFile_d_exports {
|
|
2
|
+
export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
|
|
3
|
+
}
|
|
4
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
5
|
+
type Import = {
|
|
6
|
+
/**
|
|
7
|
+
* Import name to be used
|
|
8
|
+
* @example ["useState"]
|
|
9
|
+
* @example "React"
|
|
10
|
+
*/
|
|
11
|
+
name: string | Array<string | {
|
|
12
|
+
propertyName: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Path for the import
|
|
17
|
+
* @example '@kubb/core'
|
|
18
|
+
*/
|
|
19
|
+
path: string;
|
|
20
|
+
/**
|
|
21
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
22
|
+
*/
|
|
23
|
+
isTypeOnly?: boolean;
|
|
24
|
+
isNameSpace?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
27
|
+
*/
|
|
28
|
+
root?: string;
|
|
29
|
+
};
|
|
30
|
+
type Source = {
|
|
31
|
+
name?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
isTypeOnly?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Has const or type 'export'
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
isExportable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* When set, barrel generation will add this
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
isIndexable?: boolean;
|
|
44
|
+
};
|
|
45
|
+
type Export = {
|
|
46
|
+
/**
|
|
47
|
+
* Export name to be used.
|
|
48
|
+
* @example ["useState"]
|
|
49
|
+
* @example "React"
|
|
50
|
+
*/
|
|
51
|
+
name?: string | Array<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Path for the import.
|
|
54
|
+
* @example '@kubb/core'
|
|
55
|
+
*/
|
|
56
|
+
path: string;
|
|
57
|
+
/**
|
|
58
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
59
|
+
*/
|
|
60
|
+
isTypeOnly?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
63
|
+
*/
|
|
64
|
+
asAlias?: boolean;
|
|
65
|
+
};
|
|
66
|
+
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
67
|
+
type Mode = 'single' | 'split';
|
|
68
|
+
/**
|
|
69
|
+
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
70
|
+
* Based on UNIX basename
|
|
71
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
72
|
+
*/
|
|
73
|
+
type BaseName = `${string}.${string}`;
|
|
74
|
+
/**
|
|
75
|
+
* Path will be full qualified path to a specified file
|
|
76
|
+
*/
|
|
77
|
+
type Path = string;
|
|
78
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
79
|
+
type OptionalPath = Path | undefined | null;
|
|
80
|
+
type File<TMeta$1 extends object = object> = {
|
|
81
|
+
/**
|
|
82
|
+
* Name to be used to create the path
|
|
83
|
+
* Based on UNIX basename, `${name}.extname`
|
|
84
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
85
|
+
*/
|
|
86
|
+
baseName: BaseName;
|
|
87
|
+
/**
|
|
88
|
+
* Path will be full qualified path to a specified file
|
|
89
|
+
*/
|
|
90
|
+
path: AdvancedPath<BaseName> | Path;
|
|
91
|
+
sources: Array<Source>;
|
|
92
|
+
imports?: Array<Import>;
|
|
93
|
+
exports?: Array<Export>;
|
|
94
|
+
/**
|
|
95
|
+
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
96
|
+
*/
|
|
97
|
+
meta?: TMeta$1;
|
|
98
|
+
banner?: string;
|
|
99
|
+
footer?: string;
|
|
100
|
+
};
|
|
101
|
+
type ResolvedImport = Import;
|
|
102
|
+
type ResolvedExport = Export;
|
|
103
|
+
type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
|
|
104
|
+
/**
|
|
105
|
+
* @default hash
|
|
106
|
+
*/
|
|
107
|
+
id: string;
|
|
108
|
+
/**
|
|
109
|
+
* Contains the first part of the baseName, generated based on baseName
|
|
110
|
+
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
111
|
+
*/
|
|
112
|
+
name: string;
|
|
113
|
+
extname: Extname;
|
|
114
|
+
imports: Array<ResolvedImport>;
|
|
115
|
+
exports: Array<ResolvedExport>;
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/plugins/types.d.ts
|
|
119
|
+
type Plugin<TOptions$1 = any[], TAppExtension$1 extends Record<string, any> = {}> = {
|
|
120
|
+
name: string;
|
|
121
|
+
type: 'plugin';
|
|
122
|
+
scope?: 'write' | 'read' | (string & {});
|
|
123
|
+
install: Install<TOptions$1> | Promise<Install<TOptions$1>>;
|
|
124
|
+
/**
|
|
125
|
+
* Runtime app overrides or extensions.
|
|
126
|
+
* Merged into the app instance after install.
|
|
127
|
+
*/
|
|
128
|
+
override?: Override<TOptions$1, TAppExtension$1>;
|
|
129
|
+
};
|
|
130
|
+
type UserPlugin<TOptions$1 = any[], TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions$1, TAppExtension$1>, 'type'>;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/parsers/types.d.ts
|
|
133
|
+
type PrintOptions = {
|
|
134
|
+
extname?: Extname;
|
|
135
|
+
};
|
|
136
|
+
type Parser<TOptions$1 = any[], TMeta$1 extends object = any> = {
|
|
137
|
+
name: string;
|
|
138
|
+
type: 'parser';
|
|
139
|
+
/**
|
|
140
|
+
* Undefined is being used for the defaultParser
|
|
141
|
+
*/
|
|
142
|
+
extNames: Array<Extname> | undefined;
|
|
143
|
+
install: Install<TOptions$1>;
|
|
144
|
+
/**
|
|
145
|
+
* Convert a file to string
|
|
146
|
+
*/
|
|
147
|
+
parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
|
|
148
|
+
};
|
|
149
|
+
type UserParser<TOptions$1 = any[], TMeta$1 extends object = any> = Omit<Parser<TOptions$1, TMeta$1>, 'type'>;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/utils/AsyncEventEmitter.d.ts
|
|
152
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
153
|
+
#private;
|
|
154
|
+
constructor(maxListener?: number);
|
|
155
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
156
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
157
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
158
|
+
removeAll(): void;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/FileProcessor.d.ts
|
|
162
|
+
type ProcessFilesProps = {
|
|
163
|
+
parsers?: Set<Parser>;
|
|
164
|
+
extension?: Record<Extname, Extname | ''>;
|
|
165
|
+
dryRun?: boolean;
|
|
166
|
+
};
|
|
167
|
+
type GetParseOptions = {
|
|
168
|
+
parsers?: Set<Parser>;
|
|
169
|
+
extension?: Record<Extname, Extname | ''>;
|
|
170
|
+
};
|
|
171
|
+
type Options$1 = {
|
|
172
|
+
events?: AsyncEventEmitter<AppEvents>;
|
|
173
|
+
};
|
|
174
|
+
declare class FileProcessor {
|
|
175
|
+
#private;
|
|
176
|
+
events: AsyncEventEmitter<AppEvents>;
|
|
177
|
+
constructor({
|
|
178
|
+
events
|
|
179
|
+
}?: Options$1);
|
|
180
|
+
parse(file: ResolvedFile, {
|
|
181
|
+
parsers,
|
|
182
|
+
extension
|
|
183
|
+
}?: GetParseOptions): Promise<string>;
|
|
184
|
+
run(files: Array<ResolvedFile>, {
|
|
185
|
+
parsers,
|
|
186
|
+
dryRun,
|
|
187
|
+
extension
|
|
188
|
+
}?: ProcessFilesProps): Promise<ResolvedFile[]>;
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/FileManager.d.ts
|
|
192
|
+
type Options = {
|
|
193
|
+
events?: AsyncEventEmitter<AppEvents>;
|
|
194
|
+
};
|
|
195
|
+
declare class FileManager {
|
|
196
|
+
#private;
|
|
197
|
+
processor: FileProcessor;
|
|
198
|
+
constructor({
|
|
199
|
+
events
|
|
200
|
+
}?: Options);
|
|
201
|
+
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
202
|
+
flush(): void;
|
|
203
|
+
getByPath(path: Path): ResolvedFile | null;
|
|
204
|
+
deleteByPath(path: Path): void;
|
|
205
|
+
clear(): void;
|
|
206
|
+
get files(): Array<ResolvedFile>;
|
|
207
|
+
write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/App.d.ts
|
|
211
|
+
type Component = any;
|
|
212
|
+
type AppEvents = {
|
|
213
|
+
/**
|
|
214
|
+
* Called in the beginning of the app lifecycle.
|
|
215
|
+
*/
|
|
216
|
+
start: [{
|
|
217
|
+
app: App;
|
|
218
|
+
}];
|
|
219
|
+
/**
|
|
220
|
+
* Called in the end of the app lifecycle.
|
|
221
|
+
*/
|
|
222
|
+
end: [{
|
|
223
|
+
app: App;
|
|
224
|
+
}];
|
|
225
|
+
/**
|
|
226
|
+
* Called when being rendered
|
|
227
|
+
*/
|
|
228
|
+
render: [{
|
|
229
|
+
app: App;
|
|
230
|
+
}];
|
|
231
|
+
/**
|
|
232
|
+
* Called once before processing any files.
|
|
233
|
+
*/
|
|
234
|
+
'process:start': [{
|
|
235
|
+
files: ResolvedFile[];
|
|
236
|
+
}];
|
|
237
|
+
/**
|
|
238
|
+
* Called for each file when processing begins.
|
|
239
|
+
*/
|
|
240
|
+
'file:start': [{
|
|
241
|
+
file: ResolvedFile;
|
|
242
|
+
index: number;
|
|
243
|
+
total: number;
|
|
244
|
+
}];
|
|
245
|
+
/**
|
|
246
|
+
* Called for each file when processing finishes.
|
|
247
|
+
*/
|
|
248
|
+
'file:end': [{
|
|
249
|
+
file: ResolvedFile;
|
|
250
|
+
index: number;
|
|
251
|
+
total: number;
|
|
252
|
+
}];
|
|
253
|
+
/**
|
|
254
|
+
* Called periodically (or after each file) to indicate progress.
|
|
255
|
+
* Useful for progress bars or logging.
|
|
256
|
+
*/
|
|
257
|
+
'process:progress': [{
|
|
258
|
+
processed: number;
|
|
259
|
+
total: number;
|
|
260
|
+
percentage: number;
|
|
261
|
+
source: string;
|
|
262
|
+
file: ResolvedFile;
|
|
263
|
+
}];
|
|
264
|
+
/**
|
|
265
|
+
* Called once all files have been processed successfully.
|
|
266
|
+
*/
|
|
267
|
+
'process:end': [{
|
|
268
|
+
files: ResolvedFile[];
|
|
269
|
+
}];
|
|
270
|
+
};
|
|
271
|
+
type AppContext<TOptions$1 = unknown> = {
|
|
272
|
+
options?: TOptions$1;
|
|
273
|
+
events: AsyncEventEmitter<AppEvents>;
|
|
274
|
+
fileManager: FileManager;
|
|
275
|
+
installedPlugins: Set<Plugin>;
|
|
276
|
+
installedParsers: Set<Parser>;
|
|
277
|
+
};
|
|
278
|
+
type Install<TOptions$1 = any[] | object | undefined> = TOptions$1 extends any[] ? (app: App, context: AppContext, ...options: TOptions$1) => void : TOptions$1 extends object ? (app: App, context: AppContext, options?: TOptions$1) => void : (app: App, context: AppContext) => void;
|
|
279
|
+
type Override<TOptions$1 = any[] | object | undefined, TAppExtension$1 extends Record<string, any> = {}> = TOptions$1 extends any[] ? (app: App, context: AppContext, ...options: TOptions$1) => Partial<TAppExtension$1> : TOptions$1 extends object ? (app: App, context: AppContext, options?: TOptions$1) => Partial<TAppExtension$1> : (app: App, context: AppContext) => Partial<TAppExtension$1>;
|
|
280
|
+
interface App {
|
|
281
|
+
_component: Component;
|
|
282
|
+
render(): Promise<void>;
|
|
283
|
+
renderToString(): Promise<string>;
|
|
284
|
+
files: Array<ResolvedFile>;
|
|
285
|
+
use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>, ...options: TOptions extends any[] ? NoInfer<TOptions> : [NoInfer<TOptions>]): this & TAppExtension;
|
|
286
|
+
use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>): this & TAppExtension;
|
|
287
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
288
|
+
waitUntilExit(): Promise<void>;
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
export { FileProcessor as a, Plugin as c, File as d, KubbFile_d_exports as f, FileManager as i, UserPlugin as l, AppContext as n, Parser as o, ResolvedFile as p, Component as r, UserParser as s, App as t, Extname as u };
|
|
292
|
+
//# sourceMappingURL=App-DUFbq4lD.d.ts.map
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
declare namespace KubbFile_d_exports {
|
|
2
|
+
export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
|
|
3
|
+
}
|
|
4
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
5
|
+
type Import = {
|
|
6
|
+
/**
|
|
7
|
+
* Import name to be used
|
|
8
|
+
* @example ["useState"]
|
|
9
|
+
* @example "React"
|
|
10
|
+
*/
|
|
11
|
+
name: string | Array<string | {
|
|
12
|
+
propertyName: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Path for the import
|
|
17
|
+
* @example '@kubb/core'
|
|
18
|
+
*/
|
|
19
|
+
path: string;
|
|
20
|
+
/**
|
|
21
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
22
|
+
*/
|
|
23
|
+
isTypeOnly?: boolean;
|
|
24
|
+
isNameSpace?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
27
|
+
*/
|
|
28
|
+
root?: string;
|
|
29
|
+
};
|
|
30
|
+
type Source = {
|
|
31
|
+
name?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
isTypeOnly?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Has const or type 'export'
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
isExportable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* When set, barrel generation will add this
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
isIndexable?: boolean;
|
|
44
|
+
};
|
|
45
|
+
type Export = {
|
|
46
|
+
/**
|
|
47
|
+
* Export name to be used.
|
|
48
|
+
* @example ["useState"]
|
|
49
|
+
* @example "React"
|
|
50
|
+
*/
|
|
51
|
+
name?: string | Array<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Path for the import.
|
|
54
|
+
* @example '@kubb/core'
|
|
55
|
+
*/
|
|
56
|
+
path: string;
|
|
57
|
+
/**
|
|
58
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
59
|
+
*/
|
|
60
|
+
isTypeOnly?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
63
|
+
*/
|
|
64
|
+
asAlias?: boolean;
|
|
65
|
+
};
|
|
66
|
+
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
67
|
+
type Mode = 'single' | 'split';
|
|
68
|
+
/**
|
|
69
|
+
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
70
|
+
* Based on UNIX basename
|
|
71
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
72
|
+
*/
|
|
73
|
+
type BaseName = `${string}.${string}`;
|
|
74
|
+
/**
|
|
75
|
+
* Path will be full qualified path to a specified file
|
|
76
|
+
*/
|
|
77
|
+
type Path = string;
|
|
78
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
79
|
+
type OptionalPath = Path | undefined | null;
|
|
80
|
+
type File<TMeta$1 extends object = object> = {
|
|
81
|
+
/**
|
|
82
|
+
* Name to be used to create the path
|
|
83
|
+
* Based on UNIX basename, `${name}.extname`
|
|
84
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
85
|
+
*/
|
|
86
|
+
baseName: BaseName;
|
|
87
|
+
/**
|
|
88
|
+
* Path will be full qualified path to a specified file
|
|
89
|
+
*/
|
|
90
|
+
path: AdvancedPath<BaseName> | Path;
|
|
91
|
+
sources: Array<Source>;
|
|
92
|
+
imports?: Array<Import>;
|
|
93
|
+
exports?: Array<Export>;
|
|
94
|
+
/**
|
|
95
|
+
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
96
|
+
*/
|
|
97
|
+
meta?: TMeta$1;
|
|
98
|
+
banner?: string;
|
|
99
|
+
footer?: string;
|
|
100
|
+
};
|
|
101
|
+
type ResolvedImport = Import;
|
|
102
|
+
type ResolvedExport = Export;
|
|
103
|
+
type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
|
|
104
|
+
/**
|
|
105
|
+
* @default hash
|
|
106
|
+
*/
|
|
107
|
+
id: string;
|
|
108
|
+
/**
|
|
109
|
+
* Contains the first part of the baseName, generated based on baseName
|
|
110
|
+
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
111
|
+
*/
|
|
112
|
+
name: string;
|
|
113
|
+
extname: Extname;
|
|
114
|
+
imports: Array<ResolvedImport>;
|
|
115
|
+
exports: Array<ResolvedExport>;
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/plugins/types.d.ts
|
|
119
|
+
type Plugin<TOptions$1 = any[], TAppExtension$1 extends Record<string, any> = {}> = {
|
|
120
|
+
name: string;
|
|
121
|
+
type: 'plugin';
|
|
122
|
+
scope?: 'write' | 'read' | (string & {});
|
|
123
|
+
install: Install<TOptions$1> | Promise<Install<TOptions$1>>;
|
|
124
|
+
/**
|
|
125
|
+
* Runtime app overrides or extensions.
|
|
126
|
+
* Merged into the app instance after install.
|
|
127
|
+
*/
|
|
128
|
+
override?: Override<TOptions$1, TAppExtension$1>;
|
|
129
|
+
};
|
|
130
|
+
type UserPlugin<TOptions$1 = any[], TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions$1, TAppExtension$1>, 'type'>;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/parsers/types.d.ts
|
|
133
|
+
type PrintOptions = {
|
|
134
|
+
extname?: Extname;
|
|
135
|
+
};
|
|
136
|
+
type Parser<TOptions$1 = any[], TMeta$1 extends object = any> = {
|
|
137
|
+
name: string;
|
|
138
|
+
type: 'parser';
|
|
139
|
+
/**
|
|
140
|
+
* Undefined is being used for the defaultParser
|
|
141
|
+
*/
|
|
142
|
+
extNames: Array<Extname> | undefined;
|
|
143
|
+
install: Install<TOptions$1>;
|
|
144
|
+
/**
|
|
145
|
+
* Convert a file to string
|
|
146
|
+
*/
|
|
147
|
+
parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
|
|
148
|
+
};
|
|
149
|
+
type UserParser<TOptions$1 = any[], TMeta$1 extends object = any> = Omit<Parser<TOptions$1, TMeta$1>, 'type'>;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/utils/AsyncEventEmitter.d.ts
|
|
152
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
153
|
+
#private;
|
|
154
|
+
constructor(maxListener?: number);
|
|
155
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
156
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
157
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
158
|
+
removeAll(): void;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/FileProcessor.d.ts
|
|
162
|
+
type ProcessFilesProps = {
|
|
163
|
+
parsers?: Set<Parser>;
|
|
164
|
+
extension?: Record<Extname, Extname | ''>;
|
|
165
|
+
dryRun?: boolean;
|
|
166
|
+
};
|
|
167
|
+
type GetParseOptions = {
|
|
168
|
+
parsers?: Set<Parser>;
|
|
169
|
+
extension?: Record<Extname, Extname | ''>;
|
|
170
|
+
};
|
|
171
|
+
type Options$1 = {
|
|
172
|
+
events?: AsyncEventEmitter<AppEvents>;
|
|
173
|
+
};
|
|
174
|
+
declare class FileProcessor {
|
|
175
|
+
#private;
|
|
176
|
+
events: AsyncEventEmitter<AppEvents>;
|
|
177
|
+
constructor({
|
|
178
|
+
events
|
|
179
|
+
}?: Options$1);
|
|
180
|
+
parse(file: ResolvedFile, {
|
|
181
|
+
parsers,
|
|
182
|
+
extension
|
|
183
|
+
}?: GetParseOptions): Promise<string>;
|
|
184
|
+
run(files: Array<ResolvedFile>, {
|
|
185
|
+
parsers,
|
|
186
|
+
dryRun,
|
|
187
|
+
extension
|
|
188
|
+
}?: ProcessFilesProps): Promise<ResolvedFile[]>;
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/FileManager.d.ts
|
|
192
|
+
type Options = {
|
|
193
|
+
events?: AsyncEventEmitter<AppEvents>;
|
|
194
|
+
};
|
|
195
|
+
declare class FileManager {
|
|
196
|
+
#private;
|
|
197
|
+
processor: FileProcessor;
|
|
198
|
+
constructor({
|
|
199
|
+
events
|
|
200
|
+
}?: Options);
|
|
201
|
+
add(...files: Array<File>): Promise<ResolvedFile<object>[]>;
|
|
202
|
+
flush(): void;
|
|
203
|
+
getByPath(path: Path): ResolvedFile | null;
|
|
204
|
+
deleteByPath(path: Path): void;
|
|
205
|
+
clear(): void;
|
|
206
|
+
get files(): Array<ResolvedFile>;
|
|
207
|
+
write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/App.d.ts
|
|
211
|
+
type Component = any;
|
|
212
|
+
type AppEvents = {
|
|
213
|
+
/**
|
|
214
|
+
* Called in the beginning of the app lifecycle.
|
|
215
|
+
*/
|
|
216
|
+
start: [{
|
|
217
|
+
app: App;
|
|
218
|
+
}];
|
|
219
|
+
/**
|
|
220
|
+
* Called in the end of the app lifecycle.
|
|
221
|
+
*/
|
|
222
|
+
end: [{
|
|
223
|
+
app: App;
|
|
224
|
+
}];
|
|
225
|
+
/**
|
|
226
|
+
* Called when being rendered
|
|
227
|
+
*/
|
|
228
|
+
render: [{
|
|
229
|
+
app: App;
|
|
230
|
+
}];
|
|
231
|
+
/**
|
|
232
|
+
* Called once before processing any files.
|
|
233
|
+
*/
|
|
234
|
+
'process:start': [{
|
|
235
|
+
files: ResolvedFile[];
|
|
236
|
+
}];
|
|
237
|
+
/**
|
|
238
|
+
* Called for each file when processing begins.
|
|
239
|
+
*/
|
|
240
|
+
'file:start': [{
|
|
241
|
+
file: ResolvedFile;
|
|
242
|
+
index: number;
|
|
243
|
+
total: number;
|
|
244
|
+
}];
|
|
245
|
+
/**
|
|
246
|
+
* Called for each file when processing finishes.
|
|
247
|
+
*/
|
|
248
|
+
'file:end': [{
|
|
249
|
+
file: ResolvedFile;
|
|
250
|
+
index: number;
|
|
251
|
+
total: number;
|
|
252
|
+
}];
|
|
253
|
+
/**
|
|
254
|
+
* Called periodically (or after each file) to indicate progress.
|
|
255
|
+
* Useful for progress bars or logging.
|
|
256
|
+
*/
|
|
257
|
+
'process:progress': [{
|
|
258
|
+
processed: number;
|
|
259
|
+
total: number;
|
|
260
|
+
percentage: number;
|
|
261
|
+
source: string;
|
|
262
|
+
file: ResolvedFile;
|
|
263
|
+
}];
|
|
264
|
+
/**
|
|
265
|
+
* Called once all files have been processed successfully.
|
|
266
|
+
*/
|
|
267
|
+
'process:end': [{
|
|
268
|
+
files: ResolvedFile[];
|
|
269
|
+
}];
|
|
270
|
+
};
|
|
271
|
+
type AppContext<TOptions$1 = unknown> = {
|
|
272
|
+
options?: TOptions$1;
|
|
273
|
+
events: AsyncEventEmitter<AppEvents>;
|
|
274
|
+
fileManager: FileManager;
|
|
275
|
+
installedPlugins: Set<Plugin>;
|
|
276
|
+
installedParsers: Set<Parser>;
|
|
277
|
+
};
|
|
278
|
+
type Install<TOptions$1 = any[] | object | undefined> = TOptions$1 extends any[] ? (app: App, context: AppContext, ...options: TOptions$1) => void : TOptions$1 extends object ? (app: App, context: AppContext, options?: TOptions$1) => void : (app: App, context: AppContext) => void;
|
|
279
|
+
type Override<TOptions$1 = any[] | object | undefined, TAppExtension$1 extends Record<string, any> = {}> = TOptions$1 extends any[] ? (app: App, context: AppContext, ...options: TOptions$1) => Partial<TAppExtension$1> : TOptions$1 extends object ? (app: App, context: AppContext, options?: TOptions$1) => Partial<TAppExtension$1> : (app: App, context: AppContext) => Partial<TAppExtension$1>;
|
|
280
|
+
interface App {
|
|
281
|
+
_component: Component;
|
|
282
|
+
render(): Promise<void>;
|
|
283
|
+
renderToString(): Promise<string>;
|
|
284
|
+
files: Array<ResolvedFile>;
|
|
285
|
+
use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>, ...options: TOptions extends any[] ? NoInfer<TOptions> : [NoInfer<TOptions>]): this & TAppExtension;
|
|
286
|
+
use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>): this & TAppExtension;
|
|
287
|
+
addFile(...files: Array<File>): Promise<void>;
|
|
288
|
+
waitUntilExit(): Promise<void>;
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
export { FileProcessor as a, Plugin as c, File as d, KubbFile_d_exports as f, FileManager as i, UserPlugin as l, AppContext as n, Parser as o, ResolvedFile as p, Component as r, UserParser as s, App as t, Extname as u };
|
|
292
|
+
//# sourceMappingURL=App-DoQNlnGL.d.cts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as AppContext, r as Component, t as App } from "./App-DUFbq4lD.js";
|
|
2
|
+
|
|
3
|
+
//#region src/defineApp.d.ts
|
|
4
|
+
type AppRenderer = {
|
|
5
|
+
render(): Promise<void> | void;
|
|
6
|
+
renderToString(): Promise<string> | string;
|
|
7
|
+
waitUntilExit(): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
|
|
10
|
+
type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
|
|
11
|
+
declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { defineApp as n, DefineApp as t };
|
|
14
|
+
//# sourceMappingURL=defineApp-C6WnoREI.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as AppContext, r as Component, t as App } from "./App-DoQNlnGL.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/defineApp.d.ts
|
|
4
|
+
type AppRenderer = {
|
|
5
|
+
render(): Promise<void> | void;
|
|
6
|
+
renderToString(): Promise<string> | string;
|
|
7
|
+
waitUntilExit(): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
|
|
10
|
+
type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
|
|
11
|
+
declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { defineApp as n, DefineApp as t };
|
|
14
|
+
//# sourceMappingURL=defineApp-D1-njmtr.d.cts.map
|