@kubb/fabric-core 0.0.0-canary-20251022200241 → 0.0.0-canary-20251023132618
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 → App-BaOaS0oU.d.ts} +19 -17
- package/dist/{App-DoQNlnGL.d.cts → App-kfFIExH4.d.cts} +19 -17
- package/dist/createParser-B_RpW6sx.js +17 -0
- package/dist/createParser-B_RpW6sx.js.map +1 -0
- package/dist/createParser-DZB5qExa.cjs +29 -0
- package/dist/createParser-DZB5qExa.cjs.map +1 -0
- package/dist/defaultParser-Dl-OrbH1.cjs +20 -0
- package/dist/defaultParser-Dl-OrbH1.cjs.map +1 -0
- package/dist/defaultParser-vwyTb1XT.js +15 -0
- package/dist/defaultParser-vwyTb1XT.js.map +1 -0
- package/dist/index-B4UcK65Y.d.ts +18 -0
- package/dist/index-C-k1b344.d.cts +18 -0
- package/dist/index.cjs +36 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -14
- package/dist/index.d.ts +3 -14
- package/dist/index.js +30 -60
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.cjs +2 -1
- package/dist/parsers/typescript.d.cts +2 -2
- package/dist/parsers/typescript.d.ts +2 -2
- package/dist/parsers/typescript.js +2 -1
- package/dist/parsers.cjs +19 -6
- package/dist/parsers.cjs.map +1 -0
- package/dist/parsers.d.cts +2 -2
- package/dist/parsers.d.ts +2 -2
- package/dist/parsers.js +16 -3
- package/dist/parsers.js.map +1 -0
- package/dist/plugins.cjs +5 -5
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +16 -8
- package/dist/plugins.d.ts +16 -8
- package/dist/plugins.js +5 -5
- package/dist/plugins.js.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/{typescriptParser-BBGeFKlP.js → typescriptParser-CrzOv_Aw.js} +3 -17
- package/dist/typescriptParser-CrzOv_Aw.js.map +1 -0
- package/dist/{typescriptParser-DOD1_QTe.d.cts → typescriptParser-DpZnax-m.d.cts} +2 -2
- package/dist/{typescriptParser-BBbbmG5W.cjs → typescriptParser-JawJ8wET.cjs} +5 -31
- package/dist/{typescriptParser-BBGeFKlP.js.map → typescriptParser-JawJ8wET.cjs.map} +1 -1
- package/dist/{typescriptParser-C9WJrwRd.d.ts → typescriptParser-ouLUNUEs.d.ts} +2 -2
- package/package.json +1 -1
- package/src/App.ts +15 -12
- package/src/FileProcessor.ts +13 -12
- package/src/createApp.ts +1 -13
- package/src/defineApp.ts +19 -32
- package/src/plugins/fsPlugin.ts +26 -12
- package/src/plugins/types.ts +2 -2
- package/dist/defineApp-C6WnoREI.d.ts +0 -14
- package/dist/defineApp-D1-njmtr.d.cts +0 -14
- package/dist/tsxParser-C741ZKCN.js +0 -26
- package/dist/tsxParser-C741ZKCN.js.map +0 -1
- package/dist/tsxParser-HDf_3TMc.cjs +0 -37
- package/dist/tsxParser-HDf_3TMc.cjs.map +0 -1
- package/dist/typescriptParser-BBbbmG5W.cjs.map +0 -1
|
@@ -116,37 +116,37 @@ type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
|
|
|
116
116
|
};
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/plugins/types.d.ts
|
|
119
|
-
type Plugin<TOptions
|
|
119
|
+
type Plugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = {
|
|
120
120
|
name: string;
|
|
121
121
|
type: 'plugin';
|
|
122
122
|
scope?: 'write' | 'read' | (string & {});
|
|
123
|
-
install: Install<TOptions
|
|
123
|
+
install: Install<TOptions> | Promise<Install<TOptions>>;
|
|
124
124
|
/**
|
|
125
125
|
* Runtime app overrides or extensions.
|
|
126
126
|
* Merged into the app instance after install.
|
|
127
127
|
*/
|
|
128
|
-
|
|
128
|
+
inject?: Inject<TOptions, TAppExtension$1>;
|
|
129
129
|
};
|
|
130
|
-
type UserPlugin<TOptions
|
|
130
|
+
type UserPlugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region src/parsers/types.d.ts
|
|
133
133
|
type PrintOptions = {
|
|
134
134
|
extname?: Extname;
|
|
135
135
|
};
|
|
136
|
-
type Parser<TOptions
|
|
136
|
+
type Parser<TOptions = any[], TMeta$1 extends object = any> = {
|
|
137
137
|
name: string;
|
|
138
138
|
type: 'parser';
|
|
139
139
|
/**
|
|
140
140
|
* Undefined is being used for the defaultParser
|
|
141
141
|
*/
|
|
142
142
|
extNames: Array<Extname> | undefined;
|
|
143
|
-
install: Install<TOptions
|
|
143
|
+
install: Install<TOptions>;
|
|
144
144
|
/**
|
|
145
145
|
* Convert a file to string
|
|
146
146
|
*/
|
|
147
147
|
parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
|
|
148
148
|
};
|
|
149
|
-
type UserParser<TOptions
|
|
149
|
+
type UserParser<TOptions = any[], TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/utils/AsyncEventEmitter.d.ts
|
|
152
152
|
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
@@ -208,6 +208,11 @@ declare class FileManager {
|
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region src/App.d.ts
|
|
211
|
+
declare global {
|
|
212
|
+
namespace Kubb {
|
|
213
|
+
interface App {}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
211
216
|
type Component = any;
|
|
212
217
|
type AppEvents = {
|
|
213
218
|
/**
|
|
@@ -268,25 +273,22 @@ type AppEvents = {
|
|
|
268
273
|
files: ResolvedFile[];
|
|
269
274
|
}];
|
|
270
275
|
};
|
|
271
|
-
type AppContext<TOptions
|
|
272
|
-
options?: TOptions
|
|
276
|
+
type AppContext<TOptions = unknown> = {
|
|
277
|
+
options?: TOptions;
|
|
273
278
|
events: AsyncEventEmitter<AppEvents>;
|
|
274
279
|
fileManager: FileManager;
|
|
275
280
|
installedPlugins: Set<Plugin>;
|
|
276
281
|
installedParsers: Set<Parser>;
|
|
277
282
|
};
|
|
278
|
-
type Install<TOptions
|
|
279
|
-
type
|
|
280
|
-
interface App {
|
|
281
|
-
|
|
282
|
-
render(): Promise<void>;
|
|
283
|
-
renderToString(): Promise<string>;
|
|
283
|
+
type Install<TOptions = any[] | object | undefined> = TOptions extends any[] ? (app: App, ...options: TOptions) => void : TOptions extends object ? (app: App, options?: TOptions) => void : (app: App) => void;
|
|
284
|
+
type Inject<TOptions = any[] | object | undefined, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : TOptions extends object ? (app: App, options?: TOptions) => Partial<TAppExtension$1> : (app: App) => Partial<TAppExtension$1>;
|
|
285
|
+
interface App<TOptions = unknown> extends Kubb.App {
|
|
286
|
+
context: AppContext<TOptions>;
|
|
284
287
|
files: Array<ResolvedFile>;
|
|
285
288
|
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
289
|
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
290
|
addFile(...files: Array<File>): Promise<void>;
|
|
288
|
-
waitUntilExit(): Promise<void>;
|
|
289
291
|
}
|
|
290
292
|
//#endregion
|
|
291
293
|
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-
|
|
294
|
+
//# sourceMappingURL=App-BaOaS0oU.d.ts.map
|
|
@@ -116,37 +116,37 @@ type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
|
|
|
116
116
|
};
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/plugins/types.d.ts
|
|
119
|
-
type Plugin<TOptions
|
|
119
|
+
type Plugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = {
|
|
120
120
|
name: string;
|
|
121
121
|
type: 'plugin';
|
|
122
122
|
scope?: 'write' | 'read' | (string & {});
|
|
123
|
-
install: Install<TOptions
|
|
123
|
+
install: Install<TOptions> | Promise<Install<TOptions>>;
|
|
124
124
|
/**
|
|
125
125
|
* Runtime app overrides or extensions.
|
|
126
126
|
* Merged into the app instance after install.
|
|
127
127
|
*/
|
|
128
|
-
|
|
128
|
+
inject?: Inject<TOptions, TAppExtension$1>;
|
|
129
129
|
};
|
|
130
|
-
type UserPlugin<TOptions
|
|
130
|
+
type UserPlugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region src/parsers/types.d.ts
|
|
133
133
|
type PrintOptions = {
|
|
134
134
|
extname?: Extname;
|
|
135
135
|
};
|
|
136
|
-
type Parser<TOptions
|
|
136
|
+
type Parser<TOptions = any[], TMeta$1 extends object = any> = {
|
|
137
137
|
name: string;
|
|
138
138
|
type: 'parser';
|
|
139
139
|
/**
|
|
140
140
|
* Undefined is being used for the defaultParser
|
|
141
141
|
*/
|
|
142
142
|
extNames: Array<Extname> | undefined;
|
|
143
|
-
install: Install<TOptions
|
|
143
|
+
install: Install<TOptions>;
|
|
144
144
|
/**
|
|
145
145
|
* Convert a file to string
|
|
146
146
|
*/
|
|
147
147
|
parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
|
|
148
148
|
};
|
|
149
|
-
type UserParser<TOptions
|
|
149
|
+
type UserParser<TOptions = any[], TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/utils/AsyncEventEmitter.d.ts
|
|
152
152
|
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
@@ -208,6 +208,11 @@ declare class FileManager {
|
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region src/App.d.ts
|
|
211
|
+
declare global {
|
|
212
|
+
namespace Kubb {
|
|
213
|
+
interface App {}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
211
216
|
type Component = any;
|
|
212
217
|
type AppEvents = {
|
|
213
218
|
/**
|
|
@@ -268,25 +273,22 @@ type AppEvents = {
|
|
|
268
273
|
files: ResolvedFile[];
|
|
269
274
|
}];
|
|
270
275
|
};
|
|
271
|
-
type AppContext<TOptions
|
|
272
|
-
options?: TOptions
|
|
276
|
+
type AppContext<TOptions = unknown> = {
|
|
277
|
+
options?: TOptions;
|
|
273
278
|
events: AsyncEventEmitter<AppEvents>;
|
|
274
279
|
fileManager: FileManager;
|
|
275
280
|
installedPlugins: Set<Plugin>;
|
|
276
281
|
installedParsers: Set<Parser>;
|
|
277
282
|
};
|
|
278
|
-
type Install<TOptions
|
|
279
|
-
type
|
|
280
|
-
interface App {
|
|
281
|
-
|
|
282
|
-
render(): Promise<void>;
|
|
283
|
-
renderToString(): Promise<string>;
|
|
283
|
+
type Install<TOptions = any[] | object | undefined> = TOptions extends any[] ? (app: App, ...options: TOptions) => void : TOptions extends object ? (app: App, options?: TOptions) => void : (app: App) => void;
|
|
284
|
+
type Inject<TOptions = any[] | object | undefined, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : TOptions extends object ? (app: App, options?: TOptions) => Partial<TAppExtension$1> : (app: App) => Partial<TAppExtension$1>;
|
|
285
|
+
interface App<TOptions = unknown> extends Kubb.App {
|
|
286
|
+
context: AppContext<TOptions>;
|
|
284
287
|
files: Array<ResolvedFile>;
|
|
285
288
|
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
289
|
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
290
|
addFile(...files: Array<File>): Promise<void>;
|
|
288
|
-
waitUntilExit(): Promise<void>;
|
|
289
291
|
}
|
|
290
292
|
//#endregion
|
|
291
293
|
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-
|
|
294
|
+
//# sourceMappingURL=App-kfFIExH4.d.cts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/utils/trimExtName.ts
|
|
2
|
+
function trimExtName(text) {
|
|
3
|
+
return text.replace(/\.[^/.]+$/, "");
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/parsers/createParser.ts
|
|
8
|
+
function createParser(parser) {
|
|
9
|
+
return {
|
|
10
|
+
type: "parser",
|
|
11
|
+
...parser
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { trimExtName as n, createParser as t };
|
|
17
|
+
//# sourceMappingURL=createParser-B_RpW6sx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createParser-B_RpW6sx.js","names":[],"sources":["../src/utils/trimExtName.ts","../src/parsers/createParser.ts"],"sourcesContent":["export function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import type { Parser, UserParser } from './types.ts'\n\nexport function createParser<TOptions = any[], TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n"],"mappings":";AAAA,SAAgB,YAAY,MAAsB;AAChD,QAAO,KAAK,QAAQ,aAAa,GAAG;;;;;ACCtC,SAAgB,aAA2D,QAA8D;AACvI,QAAO;EACL,MAAM;EACN,GAAG;EACJ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/trimExtName.ts
|
|
3
|
+
function trimExtName(text) {
|
|
4
|
+
return text.replace(/\.[^/.]+$/, "");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/parsers/createParser.ts
|
|
9
|
+
function createParser(parser) {
|
|
10
|
+
return {
|
|
11
|
+
type: "parser",
|
|
12
|
+
...parser
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
Object.defineProperty(exports, 'createParser', {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return createParser;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, 'trimExtName', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return trimExtName;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=createParser-DZB5qExa.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createParser-DZB5qExa.cjs","names":[],"sources":["../src/utils/trimExtName.ts","../src/parsers/createParser.ts"],"sourcesContent":["export function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import type { Parser, UserParser } from './types.ts'\n\nexport function createParser<TOptions = any[], TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n"],"mappings":";;AAAA,SAAgB,YAAY,MAAsB;AAChD,QAAO,KAAK,QAAQ,aAAa,GAAG;;;;;ACCtC,SAAgB,aAA2D,QAA8D;AACvI,QAAO;EACL,MAAM;EACN,GAAG;EACJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_createParser = require('./createParser-DZB5qExa.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/parsers/defaultParser.ts
|
|
4
|
+
const defaultParser = require_createParser.createParser({
|
|
5
|
+
name: "default",
|
|
6
|
+
extNames: [".json"],
|
|
7
|
+
install() {},
|
|
8
|
+
async parse(file) {
|
|
9
|
+
return file.sources.map((item) => item.value).join("\n\n");
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
Object.defineProperty(exports, 'defaultParser', {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return defaultParser;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=defaultParser-Dl-OrbH1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultParser-Dl-OrbH1.cjs","names":["createParser"],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { createParser } from './createParser.ts'\n\nexport const defaultParser = createParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgBA,kCAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as createParser } from "./createParser-B_RpW6sx.js";
|
|
2
|
+
|
|
3
|
+
//#region src/parsers/defaultParser.ts
|
|
4
|
+
const defaultParser = createParser({
|
|
5
|
+
name: "default",
|
|
6
|
+
extNames: [".json"],
|
|
7
|
+
install() {},
|
|
8
|
+
async parse(file) {
|
|
9
|
+
return file.sources.map((item) => item.value).join("\n\n");
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { defaultParser as t };
|
|
15
|
+
//# sourceMappingURL=defaultParser-vwyTb1XT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultParser-vwyTb1XT.js","names":[],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { createParser } from './createParser.ts'\n\nexport const defaultParser = createParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgB,aAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { d as File, p as ResolvedFile, r as Component, t as App } from "./App-BaOaS0oU.js";
|
|
2
|
+
|
|
3
|
+
//#region src/defineApp.d.ts
|
|
4
|
+
type RootRenderFunction<TApp extends App> = (app: TApp) => void | Promise<void>;
|
|
5
|
+
type DefineApp<TOptions> = (rootComponent?: Component, options?: TOptions) => App;
|
|
6
|
+
declare function defineApp<TOptions = unknown>(instance?: RootRenderFunction<App<TOptions>>): DefineApp<TOptions>;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/createApp.d.ts
|
|
9
|
+
declare const createApp: DefineApp<unknown>;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/createFile.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Helper to create a file with name and id set
|
|
14
|
+
*/
|
|
15
|
+
declare function createFile<TMeta extends object = object>(file: File<TMeta>): ResolvedFile<TMeta>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { defineApp as i, createApp as n, DefineApp as r, createFile as t };
|
|
18
|
+
//# sourceMappingURL=index-B4UcK65Y.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { d as File, p as ResolvedFile, r as Component, t as App } from "./App-kfFIExH4.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/defineApp.d.ts
|
|
4
|
+
type RootRenderFunction<TApp extends App> = (app: TApp) => void | Promise<void>;
|
|
5
|
+
type DefineApp<TOptions> = (rootComponent?: Component, options?: TOptions) => App;
|
|
6
|
+
declare function defineApp<TOptions = unknown>(instance?: RootRenderFunction<App<TOptions>>): DefineApp<TOptions>;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/createApp.d.ts
|
|
9
|
+
declare const createApp: DefineApp<unknown>;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/createFile.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Helper to create a file with name and id set
|
|
14
|
+
*/
|
|
15
|
+
declare function createFile<TMeta extends object = object>(file: File<TMeta>): ResolvedFile<TMeta>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { defineApp as i, createApp as n, DefineApp as r, createFile as t };
|
|
18
|
+
//# sourceMappingURL=index-C-k1b344.d.cts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_createParser = require('./createParser-DZB5qExa.cjs');
|
|
3
|
+
const require_defaultParser = require('./defaultParser-Dl-OrbH1.cjs');
|
|
4
4
|
let natural_orderby = require("natural-orderby");
|
|
5
5
|
natural_orderby = require_chunk.__toESM(natural_orderby);
|
|
6
6
|
let node_crypto = require("node:crypto");
|
|
@@ -151,7 +151,7 @@ function createFile(file) {
|
|
|
151
151
|
return {
|
|
152
152
|
...file,
|
|
153
153
|
id: hashObject({ path: file.path }),
|
|
154
|
-
name:
|
|
154
|
+
name: require_createParser.trimExtName(file.baseName),
|
|
155
155
|
extname,
|
|
156
156
|
imports,
|
|
157
157
|
exports: exports$1,
|
|
@@ -190,12 +190,6 @@ var AsyncEventEmitter = class {
|
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateMethodInitSpec.js
|
|
195
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
196
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
193
|
//#endregion
|
|
200
194
|
//#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
|
|
201
195
|
function _typeof(o) {
|
|
@@ -241,24 +235,25 @@ function _defineProperty(e, r, t) {
|
|
|
241
235
|
//#endregion
|
|
242
236
|
//#region src/FileProcessor.ts
|
|
243
237
|
var _limit = /* @__PURE__ */ new WeakMap();
|
|
244
|
-
var _FileProcessor_brand = /* @__PURE__ */ new WeakSet();
|
|
245
238
|
var FileProcessor = class {
|
|
246
239
|
constructor({ events = new AsyncEventEmitter() } = {}) {
|
|
247
|
-
_classPrivateMethodInitSpec(this, _FileProcessor_brand);
|
|
248
240
|
_classPrivateFieldInitSpec(this, _limit, (0, p_limit.default)(100));
|
|
249
241
|
_defineProperty(this, "events", void 0);
|
|
250
242
|
this.events = events;
|
|
251
243
|
return this;
|
|
252
244
|
}
|
|
253
|
-
async parse(file, { parsers =
|
|
254
|
-
const extname = node_path.default.extname(file.path);
|
|
245
|
+
async parse(file, { parsers = /* @__PURE__ */ new Set(), extension } = {}) {
|
|
255
246
|
const parseExtName = (extension === null || extension === void 0 ? void 0 : extension[file.extname]) || void 0;
|
|
256
|
-
if (!extname) return
|
|
257
|
-
|
|
247
|
+
if (!file.extname) return require_defaultParser.defaultParser.parse(file, { extname: parseExtName });
|
|
248
|
+
let parser;
|
|
249
|
+
for (const item of parsers) {
|
|
258
250
|
var _item$extNames;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
251
|
+
if ((_item$extNames = item.extNames) === null || _item$extNames === void 0 ? void 0 : _item$extNames.includes(file.extname)) {
|
|
252
|
+
parser = item;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (!parser) return require_defaultParser.defaultParser.parse(file, { extname: parseExtName });
|
|
262
257
|
return parser.parse(file, { extname: parseExtName });
|
|
263
258
|
}
|
|
264
259
|
async run(files, { parsers, dryRun, extension } = {}) {
|
|
@@ -276,11 +271,14 @@ var FileProcessor = class {
|
|
|
276
271
|
extension,
|
|
277
272
|
parsers
|
|
278
273
|
});
|
|
274
|
+
const nextProcessed = processed + 1;
|
|
275
|
+
const percentage = nextProcessed / total * 100;
|
|
276
|
+
processed = nextProcessed;
|
|
279
277
|
await this.events.emit("process:progress", {
|
|
280
278
|
file: resolvedFile,
|
|
281
279
|
source,
|
|
282
280
|
processed,
|
|
283
|
-
percentage
|
|
281
|
+
percentage,
|
|
284
282
|
total
|
|
285
283
|
});
|
|
286
284
|
}
|
|
@@ -296,13 +294,6 @@ var FileProcessor = class {
|
|
|
296
294
|
return files;
|
|
297
295
|
}
|
|
298
296
|
};
|
|
299
|
-
function _get_defaultParser() {
|
|
300
|
-
return new Set([
|
|
301
|
-
require_typescriptParser.typescriptParser,
|
|
302
|
-
require_tsxParser.tsxParser,
|
|
303
|
-
require_tsxParser.defaultParser
|
|
304
|
-
]);
|
|
305
|
-
}
|
|
306
297
|
|
|
307
298
|
//#endregion
|
|
308
299
|
//#region src/FileManager.ts
|
|
@@ -342,17 +333,17 @@ var FileManager = class {
|
|
|
342
333
|
flush() {
|
|
343
334
|
_classPrivateFieldGet2(_cache, this).flush();
|
|
344
335
|
}
|
|
345
|
-
getByPath(path$
|
|
346
|
-
return _classPrivateFieldGet2(_cache, this).get(path$
|
|
336
|
+
getByPath(path$1) {
|
|
337
|
+
return _classPrivateFieldGet2(_cache, this).get(path$1);
|
|
347
338
|
}
|
|
348
|
-
deleteByPath(path$
|
|
349
|
-
_classPrivateFieldGet2(_cache, this).delete(path$
|
|
339
|
+
deleteByPath(path$1) {
|
|
340
|
+
_classPrivateFieldGet2(_cache, this).delete(path$1);
|
|
350
341
|
}
|
|
351
342
|
clear() {
|
|
352
343
|
_classPrivateFieldGet2(_cache, this).clear();
|
|
353
344
|
}
|
|
354
345
|
get files() {
|
|
355
|
-
return (0, natural_orderby.orderBy)(_classPrivateFieldGet2(_cache, this).keys(), [(v) => v.length, (v) =>
|
|
346
|
+
return (0, natural_orderby.orderBy)(_classPrivateFieldGet2(_cache, this).keys(), [(v) => v.length, (v) => require_createParser.trimExtName(v).endsWith("index")]).map((key) => _classPrivateFieldGet2(_cache, this).get(key)).filter(Boolean);
|
|
356
347
|
}
|
|
357
348
|
async write(options) {
|
|
358
349
|
return this.processor.run(this.files, options);
|
|
@@ -362,43 +353,33 @@ var FileManager = class {
|
|
|
362
353
|
//#endregion
|
|
363
354
|
//#region src/defineApp.ts
|
|
364
355
|
function defineApp(instance) {
|
|
365
|
-
function createApp$1(
|
|
356
|
+
function createApp$1(options) {
|
|
366
357
|
const events = new AsyncEventEmitter();
|
|
367
358
|
const installedPlugins = /* @__PURE__ */ new Set();
|
|
368
359
|
const installedParsers = /* @__PURE__ */ new Set();
|
|
369
360
|
const fileManager = new FileManager({ events });
|
|
370
|
-
const context = {
|
|
371
|
-
events,
|
|
372
|
-
options,
|
|
373
|
-
fileManager,
|
|
374
|
-
installedPlugins,
|
|
375
|
-
installedParsers
|
|
376
|
-
};
|
|
377
|
-
const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context);
|
|
378
361
|
const app = {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return renderToString();
|
|
362
|
+
context: {
|
|
363
|
+
events,
|
|
364
|
+
options,
|
|
365
|
+
fileManager,
|
|
366
|
+
installedPlugins,
|
|
367
|
+
installedParsers
|
|
386
368
|
},
|
|
387
369
|
get files() {
|
|
388
370
|
return fileManager.files;
|
|
389
371
|
},
|
|
390
|
-
waitUntilExit,
|
|
391
372
|
async addFile(...newFiles) {
|
|
392
373
|
await fileManager.add(...newFiles);
|
|
393
374
|
},
|
|
394
375
|
use(pluginOrParser, ...options$1) {
|
|
395
|
-
const args =
|
|
376
|
+
const args = options$1;
|
|
396
377
|
if (pluginOrParser.type === "plugin") {
|
|
397
378
|
if (installedPlugins.has(pluginOrParser)) console.warn("Plugin has already been applied to target app.");
|
|
398
379
|
else installedPlugins.add(pluginOrParser);
|
|
399
|
-
if (pluginOrParser.
|
|
400
|
-
const
|
|
401
|
-
const extraApp =
|
|
380
|
+
if (pluginOrParser.inject && (0, remeda.isFunction)(pluginOrParser.inject)) {
|
|
381
|
+
const injecter = pluginOrParser.inject;
|
|
382
|
+
const extraApp = injecter(app, ...args);
|
|
402
383
|
Object.assign(app, extraApp);
|
|
403
384
|
}
|
|
404
385
|
}
|
|
@@ -406,12 +387,13 @@ function defineApp(instance) {
|
|
|
406
387
|
else installedParsers.add(pluginOrParser);
|
|
407
388
|
if (pluginOrParser && (0, remeda.isFunction)(pluginOrParser.install)) {
|
|
408
389
|
const installer = pluginOrParser.install;
|
|
409
|
-
installer(app,
|
|
390
|
+
installer(app, ...args);
|
|
410
391
|
}
|
|
411
392
|
return app;
|
|
412
393
|
}
|
|
413
394
|
};
|
|
414
395
|
events.emit("start", { app });
|
|
396
|
+
if (instance) instance(app);
|
|
415
397
|
return app;
|
|
416
398
|
}
|
|
417
399
|
return createApp$1;
|
|
@@ -419,19 +401,7 @@ function defineApp(instance) {
|
|
|
419
401
|
|
|
420
402
|
//#endregion
|
|
421
403
|
//#region src/createApp.ts
|
|
422
|
-
const createApp = defineApp(
|
|
423
|
-
return {
|
|
424
|
-
async render() {
|
|
425
|
-
throw new Error("Method not implemented");
|
|
426
|
-
},
|
|
427
|
-
async renderToString() {
|
|
428
|
-
throw new Error("Method not implemented");
|
|
429
|
-
},
|
|
430
|
-
async waitUntilExit() {
|
|
431
|
-
throw new Error("Method not implemented");
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
});
|
|
404
|
+
const createApp = defineApp();
|
|
435
405
|
|
|
436
406
|
//#endregion
|
|
437
407
|
exports.FileManager = FileManager;
|