@kubb/fabric-core 0.1.0 → 0.1.2
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-DZuROf6f.d.ts +292 -0
- package/dist/App-zyf9KG3p.d.cts +292 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/defineApp-D3B0bU-z.d.cts +14 -0
- package/dist/defineApp-DJVMk9lc.d.ts +14 -0
- package/dist/index.cjs +217 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +204 -63
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.cjs +5 -5
- package/dist/parsers/typescript.d.cts +3 -51
- package/dist/parsers/typescript.d.ts +3 -51
- package/dist/parsers/typescript.js +2 -2
- 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/{parser-CWB_OBtr.js → typescriptParser-BBGeFKlP.js} +51 -98
- package/dist/typescriptParser-BBGeFKlP.js.map +1 -0
- package/dist/typescriptParser-BBbbmG5W.cjs +171 -0
- package/dist/typescriptParser-BBbbmG5W.cjs.map +1 -0
- package/dist/typescriptParser-C-sBy1iR.d.cts +50 -0
- package/dist/typescriptParser-CtMmz0UV.d.ts +50 -0
- package/package.json +13 -6
- package/src/App.ts +91 -0
- package/src/FileManager.ts +14 -193
- package/src/FileProcessor.ts +89 -0
- package/src/createFile.ts +167 -0
- package/src/defineApp.ts +49 -74
- package/src/index.ts +3 -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 +22 -0
- 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/EventEmitter.ts +23 -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/defineApp-Bg7JewJQ.d.ts +0 -62
- package/dist/defineApp-DKW3IRO8.d.cts +0 -62
- package/dist/parser-CWB_OBtr.js.map +0 -1
- package/dist/parser-D64DdV1v.d.cts +0 -21
- package/dist/parser-QF8j8-pj.cjs +0 -260
- package/dist/parser-QF8j8-pj.cjs.map +0 -1
- package/dist/parser-yYqnryUV.d.ts +0 -21
- package/dist/parsers/tsx.cjs +0 -3
- package/dist/parsers/tsx.d.cts +0 -8
- package/dist/parsers/tsx.d.ts +0 -8
- package/dist/parsers/tsx.js +0 -3
- package/src/fs.ts +0 -167
- package/src/parsers/parser.ts +0 -56
- package/src/parsers/tsx.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { i as typescriptParser, o as trimExtName } from "./typescriptParser-BBGeFKlP.js";
|
|
2
|
+
import { n as defaultParser, t as tsxParser } from "./tsxParser-C741ZKCN.js";
|
|
5
3
|
import { orderBy } from "natural-orderby";
|
|
6
|
-
import {
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { isDeepEqual, isFunction, isPromise, uniqueBy } from "remeda";
|
|
7
|
+
import pLimit from "p-limit";
|
|
8
|
+
import { EventEmitter } from "node:events";
|
|
7
9
|
|
|
8
10
|
//#region \0@oxc-project+runtime@0.95.0/helpers/checkPrivateRedeclaration.js
|
|
9
11
|
function _checkPrivateRedeclaration(e, t) {
|
|
@@ -59,19 +61,11 @@ var Cache = class {
|
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
//#endregion
|
|
62
|
-
//#region src/
|
|
64
|
+
//#region src/createFile.ts
|
|
63
65
|
function hashObject(obj) {
|
|
64
66
|
const str = JSON.stringify(obj, Object.keys(obj).sort());
|
|
65
67
|
return createHash("sha256").update(str).digest("hex");
|
|
66
68
|
}
|
|
67
|
-
function mergeFile(a, b) {
|
|
68
|
-
return {
|
|
69
|
-
...a,
|
|
70
|
-
sources: [...a.sources || [], ...b.sources || []],
|
|
71
|
-
imports: [...a.imports || [], ...b.imports || []],
|
|
72
|
-
exports: [...a.exports || [], ...b.exports || []]
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
69
|
function combineSources(sources) {
|
|
76
70
|
return uniqueBy(sources, (obj) => [
|
|
77
71
|
obj.name,
|
|
@@ -158,12 +152,173 @@ function createFile(file) {
|
|
|
158
152
|
meta: file.meta || {}
|
|
159
153
|
};
|
|
160
154
|
}
|
|
161
|
-
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/utils/AsyncEventEmitter.ts
|
|
158
|
+
var _emitter = /* @__PURE__ */ new WeakMap();
|
|
159
|
+
var AsyncEventEmitter = class {
|
|
160
|
+
constructor(maxListener = 100) {
|
|
161
|
+
_classPrivateFieldInitSpec(this, _emitter, new EventEmitter());
|
|
162
|
+
_classPrivateFieldGet2(_emitter, this).setMaxListeners(maxListener);
|
|
163
|
+
}
|
|
164
|
+
async emit(eventName, ...eventArgs) {
|
|
165
|
+
const listeners = _classPrivateFieldGet2(_emitter, this).listeners(eventName);
|
|
166
|
+
if (listeners.length === 0) return;
|
|
167
|
+
await Promise.all(listeners.map(async (listener) => {
|
|
168
|
+
try {
|
|
169
|
+
return await listener(...eventArgs);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
console.error(`Error in async listener for "${eventName}":`, err);
|
|
172
|
+
}
|
|
173
|
+
}));
|
|
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 \0@oxc-project+runtime@0.95.0/helpers/classPrivateMethodInitSpec.js
|
|
188
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
189
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
|
|
194
|
+
function _typeof(o) {
|
|
195
|
+
"@babel/helpers - typeof";
|
|
196
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
197
|
+
return typeof o$1;
|
|
198
|
+
} : function(o$1) {
|
|
199
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
200
|
+
}, _typeof(o);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPrimitive.js
|
|
205
|
+
function toPrimitive(t, r) {
|
|
206
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
207
|
+
var e = t[Symbol.toPrimitive];
|
|
208
|
+
if (void 0 !== e) {
|
|
209
|
+
var i = e.call(t, r || "default");
|
|
210
|
+
if ("object" != _typeof(i)) return i;
|
|
211
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
212
|
+
}
|
|
213
|
+
return ("string" === r ? String : Number)(t);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPropertyKey.js
|
|
218
|
+
function toPropertyKey(t) {
|
|
219
|
+
var i = toPrimitive(t, "string");
|
|
220
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/defineProperty.js
|
|
225
|
+
function _defineProperty(e, r, t) {
|
|
226
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
227
|
+
value: t,
|
|
228
|
+
enumerable: !0,
|
|
229
|
+
configurable: !0,
|
|
230
|
+
writable: !0
|
|
231
|
+
}) : e[r] = t, e;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/FileProcessor.ts
|
|
162
236
|
var _limit = /* @__PURE__ */ new WeakMap();
|
|
237
|
+
var _FileProcessor_brand = /* @__PURE__ */ new WeakSet();
|
|
238
|
+
var FileProcessor = class {
|
|
239
|
+
constructor({ events = new AsyncEventEmitter() } = {}) {
|
|
240
|
+
_classPrivateMethodInitSpec(this, _FileProcessor_brand);
|
|
241
|
+
_classPrivateFieldInitSpec(this, _limit, pLimit(100));
|
|
242
|
+
_defineProperty(this, "events", void 0);
|
|
243
|
+
this.events = events;
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
async parse(file, { parsers = _get_defaultParser.call(_assertClassBrand(_FileProcessor_brand, this)), extname } = {}) {
|
|
247
|
+
if (!extname) {
|
|
248
|
+
console.warn("[parser] No extname found, default parser will be used");
|
|
249
|
+
return defaultParser.parse(file, { extname });
|
|
250
|
+
}
|
|
251
|
+
const parser = [...parsers].find((item) => {
|
|
252
|
+
var _item$extNames;
|
|
253
|
+
return (_item$extNames = item.extNames) === null || _item$extNames === void 0 ? void 0 : _item$extNames.includes(extname);
|
|
254
|
+
});
|
|
255
|
+
if (!parser) {
|
|
256
|
+
console.warn(`[parser] No parser found for ${extname}, default parser will be used`);
|
|
257
|
+
return defaultParser.parse(file, { extname });
|
|
258
|
+
}
|
|
259
|
+
return parser.parse(file, { extname });
|
|
260
|
+
}
|
|
261
|
+
async run(files, { parsers, dryRun, extension } = {}) {
|
|
262
|
+
await this.events.emit("process:start", { files });
|
|
263
|
+
let processed = 0;
|
|
264
|
+
const total = files.length;
|
|
265
|
+
const promises = files.map((resolvedFile, index) => _classPrivateFieldGet2(_limit, this).call(this, async () => {
|
|
266
|
+
const extname = (extension === null || extension === void 0 ? void 0 : extension[resolvedFile.extname]) || path.extname(resolvedFile.path);
|
|
267
|
+
await this.events.emit("file:start", {
|
|
268
|
+
file: resolvedFile,
|
|
269
|
+
index,
|
|
270
|
+
total
|
|
271
|
+
});
|
|
272
|
+
if (!dryRun) {
|
|
273
|
+
const source = await this.parse(resolvedFile, {
|
|
274
|
+
extname,
|
|
275
|
+
parsers
|
|
276
|
+
});
|
|
277
|
+
await this.events.emit("process:progress", {
|
|
278
|
+
file: resolvedFile,
|
|
279
|
+
source,
|
|
280
|
+
processed,
|
|
281
|
+
percentage: processed / total * 100,
|
|
282
|
+
total
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
await this.events.emit("file:end", {
|
|
286
|
+
file: resolvedFile,
|
|
287
|
+
index,
|
|
288
|
+
total
|
|
289
|
+
});
|
|
290
|
+
processed++;
|
|
291
|
+
}));
|
|
292
|
+
await Promise.all(promises);
|
|
293
|
+
await this.events.emit("process:end", { files });
|
|
294
|
+
return files;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
function _get_defaultParser() {
|
|
298
|
+
console.warn(`[parser] using default parsers, please consider using the "use" method to add custom parsers.`);
|
|
299
|
+
return new Set([
|
|
300
|
+
typescriptParser,
|
|
301
|
+
tsxParser,
|
|
302
|
+
defaultParser
|
|
303
|
+
]);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/FileManager.ts
|
|
308
|
+
function mergeFile(a, b) {
|
|
309
|
+
return {
|
|
310
|
+
...a,
|
|
311
|
+
sources: [...a.sources || [], ...b.sources || []],
|
|
312
|
+
imports: [...a.imports || [], ...b.imports || []],
|
|
313
|
+
exports: [...a.exports || [], ...b.exports || []]
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
var _cache = /* @__PURE__ */ new WeakMap();
|
|
163
317
|
var FileManager = class {
|
|
164
|
-
constructor() {
|
|
318
|
+
constructor({ events = new AsyncEventEmitter() } = {}) {
|
|
165
319
|
_classPrivateFieldInitSpec(this, _cache, new Cache());
|
|
166
|
-
|
|
320
|
+
_defineProperty(this, "processor", void 0);
|
|
321
|
+
this.processor = new FileProcessor({ events });
|
|
167
322
|
return this;
|
|
168
323
|
}
|
|
169
324
|
async add(...files) {
|
|
@@ -195,44 +350,28 @@ var FileManager = class {
|
|
|
195
350
|
clear() {
|
|
196
351
|
_classPrivateFieldGet2(_cache, this).clear();
|
|
197
352
|
}
|
|
198
|
-
|
|
353
|
+
get files() {
|
|
199
354
|
return orderBy(_classPrivateFieldGet2(_cache, this).keys(), [(v) => v.length, (v) => trimExtName(v).endsWith("index")]).map((key) => _classPrivateFieldGet2(_cache, this).get(key)).filter(Boolean);
|
|
200
355
|
}
|
|
201
|
-
async
|
|
202
|
-
|
|
203
|
-
const promises = files.map((resolvedFile) => {
|
|
204
|
-
return _classPrivateFieldGet2(_limit, this).call(this, async () => {
|
|
205
|
-
const extname = extension ? extension[resolvedFile.extname] || void 0 : resolvedFile.extname;
|
|
206
|
-
if (!dryRun) {
|
|
207
|
-
const source = await parseFile(resolvedFile, { extname });
|
|
208
|
-
await write(resolvedFile.path, source, { sanity: false });
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
await Promise.all(promises);
|
|
213
|
-
return files;
|
|
356
|
+
async write(options) {
|
|
357
|
+
return this.processor.run(this.files, options);
|
|
214
358
|
}
|
|
215
359
|
};
|
|
216
360
|
|
|
217
361
|
//#endregion
|
|
218
362
|
//#region src/defineApp.ts
|
|
219
|
-
const isFunction = (val) => typeof val === "function";
|
|
220
363
|
function defineApp(instance) {
|
|
221
364
|
function createApp$1(rootComponent, options) {
|
|
222
|
-
const
|
|
223
|
-
const
|
|
365
|
+
const events = new AsyncEventEmitter();
|
|
366
|
+
const installedPlugins = /* @__PURE__ */ new Set();
|
|
367
|
+
const installedParsers = /* @__PURE__ */ new Set();
|
|
368
|
+
const fileManager = new FileManager({ events });
|
|
224
369
|
const context = {
|
|
370
|
+
events,
|
|
225
371
|
options,
|
|
226
372
|
fileManager,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
},
|
|
230
|
-
clear() {
|
|
231
|
-
context.fileManager.clear();
|
|
232
|
-
},
|
|
233
|
-
get files() {
|
|
234
|
-
return fileManager.getFiles();
|
|
235
|
-
}
|
|
373
|
+
installedPlugins,
|
|
374
|
+
installedParsers
|
|
236
375
|
};
|
|
237
376
|
const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context);
|
|
238
377
|
const app = {
|
|
@@ -244,32 +383,34 @@ function defineApp(instance) {
|
|
|
244
383
|
async renderToString() {
|
|
245
384
|
return renderToString();
|
|
246
385
|
},
|
|
247
|
-
|
|
248
|
-
return fileManager.
|
|
386
|
+
get files() {
|
|
387
|
+
return fileManager.files;
|
|
249
388
|
},
|
|
250
389
|
waitUntilExit,
|
|
251
|
-
addFile
|
|
252
|
-
|
|
253
|
-
extension: { ".ts": ".ts" },
|
|
254
|
-
dryRun: false
|
|
255
|
-
}) {
|
|
256
|
-
await fileManager.processFiles({
|
|
257
|
-
extension: options$1.extension,
|
|
258
|
-
dryRun: options$1.dryRun
|
|
259
|
-
});
|
|
390
|
+
async addFile(...newFiles) {
|
|
391
|
+
await fileManager.add(...newFiles);
|
|
260
392
|
},
|
|
261
|
-
use(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
installedPlugins.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
393
|
+
use(pluginOrParser, ...options$1) {
|
|
394
|
+
const args = Array.isArray(options$1) ? options$1 : [options$1[0]];
|
|
395
|
+
if (pluginOrParser.type === "plugin") {
|
|
396
|
+
if (installedPlugins.has(pluginOrParser)) console.warn("Plugin has already been applied to target app.");
|
|
397
|
+
else installedPlugins.add(pluginOrParser);
|
|
398
|
+
if (pluginOrParser.override && isFunction(pluginOrParser.override)) {
|
|
399
|
+
const overrider = pluginOrParser.override;
|
|
400
|
+
const extraApp = overrider(app, context, ...args);
|
|
401
|
+
Object.assign(app, extraApp);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (pluginOrParser.type === "parser") if (installedParsers.has(pluginOrParser)) console.warn("Parser has already been applied to target app.");
|
|
405
|
+
else installedParsers.add(pluginOrParser);
|
|
406
|
+
if (pluginOrParser && isFunction(pluginOrParser.install)) {
|
|
407
|
+
const installer = pluginOrParser.install;
|
|
408
|
+
installer(app, context, ...args);
|
|
269
409
|
}
|
|
270
410
|
return app;
|
|
271
411
|
}
|
|
272
412
|
};
|
|
413
|
+
events.emit("start", { app });
|
|
273
414
|
return app;
|
|
274
415
|
}
|
|
275
416
|
return createApp$1;
|
|
@@ -292,5 +433,5 @@ const createApp = defineApp(() => {
|
|
|
292
433
|
});
|
|
293
434
|
|
|
294
435
|
//#endregion
|
|
295
|
-
export { FileManager, createApp,
|
|
436
|
+
export { FileManager, FileProcessor, createApp, createFile, defineApp };
|
|
296
437
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["name","resolvedFiles: Array<KubbFile.ResolvedFile>","path","createApp","app: App","options"],"sources":["../src/utils/Cache.ts","../src/FileManager.ts","../src/defineApp.ts","../src/createApp.ts"],"sourcesContent":["export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import pLimit from 'p-limit'\n\nimport type * as KubbFile from './KubbFile.ts'\nimport { parseFile } from './parsers/parser.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName, write } from './fs.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { orderBy } from 'natural-orderby'\nimport { isDeepEqual, uniqueBy } from 'remeda'\n\ntype WriteFilesProps = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: hashObject({ path: file.path }),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #limit = pLimit(100)\n\n constructor() {\n return this\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (const file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n return resolvedFiles\n }\n\n flush() {\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n }\n\n clear(): void {\n this.#cache.clear()\n }\n\n getFiles(): Array<KubbFile.ResolvedFile> {\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files = keys.map((key) => this.#cache.get(key))\n\n return files.filter(Boolean)\n }\n\n async processFiles({ dryRun, extension }: WriteFilesProps): Promise<Array<KubbFile.ResolvedFile>> {\n const files = this.getFiles()\n\n const promises = files.map((resolvedFile) => {\n return this.#limit(async () => {\n const extname = extension ? extension[resolvedFile.extname] || undefined : resolvedFile.extname\n\n if (!dryRun) {\n const source = await parseFile(resolvedFile, { extname })\n\n await write(resolvedFile.path, source, { sanity: false })\n }\n })\n })\n\n await Promise.all(promises)\n\n return files\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { FileManager } from './FileManager.ts'\nimport { isPromise } from 'remeda'\n\nconst isFunction = (val: unknown): val is Function => typeof val === 'function'\n\ntype Component = any\n\ntype PluginInstallFunction<Options = any[]> = Options extends unknown[] ? (app: App, ...options: Options) => any : (app: App, options: Options) => any\n\nexport type ObjectPlugin<Options = any[]> = {\n install: PluginInstallFunction<Options>\n}\nexport type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> & Partial<ObjectPlugin<Options>>\n\ntype AppRenderer = {\n render(): Promise<void> | void\n renderToString(): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\nexport type AppContext<TOptions = unknown> = {\n options?: TOptions\n fileManager: FileManager\n addFile(...files: Array<KubbFile.File>): Promise<void>\n files: Array<KubbFile.ResolvedFile>\n clear: () => void\n}\n\ntype RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer\n\ntype Plugin<Options = any[], P extends unknown[] = Options extends unknown[] ? Options : [Options]> = FunctionPlugin<P> | ObjectPlugin<P>\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\nexport interface App {\n _component: Component\n render(): Promise<void>\n renderToString(): Promise<string>\n getFiles(): Promise<Array<KubbFile.ResolvedFile>>\n use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this\n write(options?: WriteOptions): Promise<void>\n addFile(...files: Array<KubbFile.File>): Promise<void>\n waitUntilExit(): Promise<void>\n}\n\nexport type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App\n\nexport function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext> {\n function createApp(rootComponent: Component, options?: TContext['options']): App {\n const installedPlugins = new WeakSet()\n const fileManager = new FileManager()\n const context = {\n options,\n fileManager,\n async addFile(...newFiles) {\n await fileManager.add(...newFiles)\n },\n clear() {\n context.fileManager.clear()\n },\n get files() {\n return fileManager.getFiles()\n },\n } as TContext\n\n const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)\n\n const app: App = {\n _component: rootComponent,\n async render() {\n if (isPromise(render)) {\n await render()\n } else {\n render()\n }\n },\n async renderToString() {\n return renderToString()\n },\n async getFiles() {\n return fileManager.getFiles()\n },\n waitUntilExit,\n addFile: context.addFile,\n async write(\n options = {\n extension: { '.ts': '.ts' },\n dryRun: false,\n },\n ) {\n await fileManager.processFiles({\n extension: options.extension,\n dryRun: options.dryRun,\n })\n },\n use(plugin: Plugin, ...options: any[]) {\n if (installedPlugins.has(plugin)) {\n console.warn('Plugin has already been applied to target app.')\n } else if (plugin && isFunction(plugin.install)) {\n installedPlugins.add(plugin)\n plugin.install(app, ...options)\n } else if (isFunction(plugin)) {\n installedPlugins.add(plugin)\n plugin(app, ...options)\n }\n\n return app\n },\n }\n\n return app\n }\n\n return createApp\n}\n","import { defineApp } from './defineApp.ts'\n\nexport const createApp = defineApp(() => {\n return {\n async render() {\n throw new Error('Method not implemented')\n },\n async renderToString() {\n throw new Error('Method not implemented')\n },\n async waitUntilExit() {\n throw new Error('Method not implemented')\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAsB;;4DACV,IAAI,KAAgB;;CAE9B,IAAI,KAAuB;;AACzB,6DAAO,KAAY,CAAC,IAAI,IAAI,+DAAI;;CAGlC,IAAI,KAAa,OAAgB;AAC/B,uCAAY,CAAC,IAAI,KAAK,MAAM;;CAG9B,OAAO,KAAmB;AACxB,uCAAY,CAAC,OAAO,IAAI;;CAG1B,QAAc;AACZ,uCAAY,CAAC,OAAO;;CAGtB,OAAiB;AACf,SAAO,CAAC,mCAAG,KAAY,CAAC,MAAM,CAAC;;CAGjC,SAAmB;AACjB,SAAO,CAAC,mCAAG,KAAY,CAAC,QAAQ,CAAC;;CAGnC,QAAc;;;;;ACXhB,SAAS,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AiB,IAAI,OAAO,CAC9B,SAAQ,KAAK,iDAAiD;aACrD,UAAU,WAAW,OAAO,QAAQ,EAAE;AAC/C,sBAAiB,IAAI,OAAO;AAC5B,YAAO,QAAQ,KAAK,GAAGA,UAAQ;eACtB,WAAW,OAAO,EAAE;AAC7B,sBAAiB,IAAI,OAAO;AAC5B,YAAO,KAAK,GAAGA,UAAQ;;AAGzB,WAAO;;GAEV;AAED,SAAO;;AAGT,QAAOF;;;;;ACnHT,MAAa,YAAY,gBAAgB;AACvC,QAAO;EACL,MAAM,SAAS;AACb,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,iBAAiB;AACrB,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,gBAAgB;AACpB,SAAM,IAAI,MAAM,yBAAyB;;EAE5C;EACD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["name","NodeEventEmitter","resolvedFiles: Array<KubbFile.ResolvedFile>","path","createApp","options"],"sources":["../src/utils/Cache.ts","../src/createFile.ts","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/FileManager.ts","../src/defineApp.ts","../src/createApp.ts"],"sourcesContent":["export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { isDeepEqual, uniqueBy } from 'remeda'\nimport { orderBy } from 'natural-orderby'\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: hashObject({ path: file.path }),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\n\nexport class AsyncEventEmitter<TEvents extends Record<string, any>> {\n constructor(maxListener = 100) {\n this.#emitter.setMaxListeners(maxListener)\n }\n #emitter = new NodeEventEmitter()\n\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<(...args: TEvents[TEventName]) => any>\n\n if (listeners.length === 0) {\n return undefined\n }\n\n await Promise.all(\n listeners.map(async (listener) => {\n try {\n return await listener(...eventArgs)\n } catch (err) {\n console.error(`Error in async listener for \"${eventName}\":`, err)\n }\n }),\n )\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport pLimit from 'p-limit'\nimport path from 'node:path'\n\nimport type { Parser } from './parsers/types.ts'\nimport { defaultParser } from './parsers/defaultParser.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport type { AppEvents } from './App.ts'\nimport { typescriptParser } from './parsers/typescriptParser.ts'\nimport { tsxParser } from './parsers/tsxParser.ts'\n\nexport type ProcessFilesProps = {\n parsers?: Set<Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n}\n\ntype GetParseOptions = {\n parsers?: Set<Parser>\n extname?: KubbFile.Extname\n}\n\ntype Options = {\n events?: AsyncEventEmitter<AppEvents>\n}\n\nexport class FileProcessor {\n #limit = pLimit(100)\n events: AsyncEventEmitter<AppEvents>\n\n constructor({ events = new AsyncEventEmitter<AppEvents>() }: Options = {}) {\n this.events = events\n\n return this\n }\n\n get #defaultParser(): Set<Parser> {\n console.warn(`[parser] using default parsers, please consider using the \"use\" method to add custom parsers.`)\n\n return new Set<Parser>([typescriptParser, tsxParser, defaultParser])\n }\n\n async parse(file: KubbFile.ResolvedFile, { parsers = this.#defaultParser, extname }: GetParseOptions = {}): Promise<string> {\n if (!extname) {\n console.warn('[parser] No extname found, default parser will be used')\n return defaultParser.parse(file, { extname })\n }\n\n const parser = [...parsers].find((item) => item.extNames?.includes(extname))\n\n if (!parser) {\n console.warn(`[parser] No parser found for ${extname}, default parser will be used`)\n\n return defaultParser.parse(file, { extname })\n }\n\n return parser.parse(file, { extname })\n }\n\n async run(files: Array<KubbFile.ResolvedFile>, { parsers, dryRun, extension }: ProcessFilesProps = {}): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('process:start', { files })\n\n let processed = 0\n const total = files.length\n\n const promises = files.map((resolvedFile, index) =>\n this.#limit(async () => {\n const extname = extension?.[resolvedFile.extname] || (path.extname(resolvedFile.path) as KubbFile.Extname)\n\n await this.events.emit('file:start', { file: resolvedFile, index, total })\n\n if (!dryRun) {\n const source = await this.parse(resolvedFile, { extname, parsers })\n await this.events.emit('process:progress', { file: resolvedFile, source, processed, percentage: (processed / total) * 100, total })\n }\n\n await this.events.emit('file:end', { file: resolvedFile, index, total })\n\n processed++\n }),\n )\n\n await Promise.all(promises)\n\n await this.events.emit('process:end', { files })\n\n return files\n }\n}\n","import type * as KubbFile from './KubbFile.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\nimport { orderBy } from 'natural-orderby'\nimport { createFile } from './createFile.ts'\nimport { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport type { AppEvents } from './App.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\ntype Options = {\n events?: AsyncEventEmitter<AppEvents>\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n processor: FileProcessor\n\n constructor({ events = new AsyncEventEmitter<AppEvents>() }: Options = {}) {\n this.processor = new FileProcessor({ events })\n return this\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (const file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n return resolvedFiles\n }\n\n flush() {\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n }\n\n clear(): void {\n this.#cache.clear()\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files = keys.map((key) => this.#cache.get(key))\n\n return files.filter(Boolean)\n }\n\n async write(options: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n return this.processor.run(this.files, options)\n }\n}\n","import { FileManager } from './FileManager.ts'\nimport { isFunction, isPromise } from 'remeda'\nimport type { Plugin } from './plugins/types.ts'\nimport type { Parser } from './parsers/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport type { App, AppContext, Component, AppEvents } from './App.ts'\n\ntype AppRenderer = {\n render(): Promise<void> | void\n renderToString(): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\ntype RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer\n\nexport type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App\n\nexport function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext> {\n function createApp(rootComponent: Component, options?: TContext['options']): App {\n const events = new AsyncEventEmitter<AppEvents>()\n const installedPlugins = new Set<Plugin>()\n const installedParsers = new Set<Parser>()\n const fileManager = new FileManager({ events })\n const context = {\n events,\n options,\n fileManager,\n installedPlugins,\n installedParsers,\n } as TContext\n\n const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)\n\n const app = {\n _component: rootComponent,\n async render() {\n if (isPromise(render)) {\n await render()\n } else {\n render()\n }\n },\n async renderToString() {\n return renderToString()\n },\n get files() {\n return fileManager.files\n },\n waitUntilExit,\n async addFile(...newFiles) {\n await fileManager.add(...newFiles)\n },\n use(pluginOrParser, ...options) {\n const args = Array.isArray(options) ? options : [options[0]]\n\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn('Plugin has already been applied to target app.')\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (pluginOrParser.override && isFunction(pluginOrParser.override)) {\n const overrider = pluginOrParser.override\n\n const extraApp = (overrider as any)(app, context, ...args)\n Object.assign(app, extraApp)\n }\n }\n if (pluginOrParser.type === 'parser') {\n if (installedParsers.has(pluginOrParser)) {\n console.warn('Parser has already been applied to target app.')\n } else {\n installedParsers.add(pluginOrParser)\n }\n }\n\n if (pluginOrParser && isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n ;(installer as any)(app, context, ...args)\n }\n\n return app\n },\n } as App\n\n events.emit('start', { app })\n\n return app\n }\n\n return createApp\n}\n","import { defineApp } from './defineApp.ts'\n\nexport const createApp = defineApp(() => {\n return {\n async render() {\n throw new Error('Method not implemented')\n },\n async renderToString() {\n throw new Error('Method not implemented')\n },\n async waitUntilExit() {\n throw new Error('Method not implemented')\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAsB;;4DACV,IAAI,KAAgB;;CAE9B,IAAI,KAAuB;;AACzB,6DAAO,KAAY,CAAC,IAAI,IAAI,+DAAI;;CAGlC,IAAI,KAAa,OAAgB;AAC/B,uCAAY,CAAC,IAAI,KAAK,MAAM;;CAG9B,OAAO,KAAmB;AACxB,uCAAY,CAAC,OAAO,IAAI;;CAG1B,QAAc;AACZ,uCAAY,CAAC,OAAO;;CAGtB,OAAiB;AACf,SAAO,CAAC,mCAAG,KAAY,CAAC,MAAM,CAAC;;CAGjC,SAAmB;AACjB,SAAO,CAAC,mCAAG,KAAY,CAAC,QAAQ,CAAC;;CAGnC,QAAc;;;;;ACpBhB,SAAS,WAAW,KAAsC;CACxD,MAAM,MAAM,KAAK,UAAU,KAAK,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC;AACxD,QAAO,WAAW,SAAS,CAAC,OAAO,IAAI,CAAC,OAAO,MAAM;;AAGvD,SAAgB,eAAe,SAAyD;AACtF,QAAO,SAAS,UAAU,QAAQ;EAAC,IAAI;EAAM,IAAI;EAAc,IAAI;EAAW,CAAU;;AAG1F,SAAgB,eAAe,SAAyD;AACtF,QAAO,QAAQ,SAAS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AQ,GAAG,UAAU;AACzB,UAAM,YAAY,IAAI,GAAG,SAAS;;GAEpC,IAAI,gBAAgB,GAAGC,WAAS;IAC9B,MAAM,OAAO,MAAM,QAAQA,UAAQ,GAAGA,YAAU,CAACA,UAAQ,GAAG;AAE5D,QAAI,eAAe,SAAS,UAAU;AACpC,SAAI,iBAAiB,IAAI,eAAe,CACtC,SAAQ,KAAK,iDAAiD;SAE9D,kBAAiB,IAAI,eAAe;AAGtC,SAAI,eAAe,YAAY,WAAW,eAAe,SAAS,EAAE;MAClE,MAAM,YAAY,eAAe;MAEjC,MAAM,WAAY,UAAkB,KAAK,SAAS,GAAG,KAAK;AAC1D,aAAO,OAAO,KAAK,SAAS;;;AAGhC,QAAI,eAAe,SAAS,SAC1B,KAAI,iBAAiB,IAAI,eAAe,CACtC,SAAQ,KAAK,iDAAiD;QAE9D,kBAAiB,IAAI,eAAe;AAIxC,QAAI,kBAAkB,WAAW,eAAe,QAAQ,EAAE;KACxD,MAAM,YAAY,eAAe;AAEhC,KAAC,UAAkB,KAAK,SAAS,GAAG,KAAK;;AAG5C,WAAO;;GAEV;AAED,SAAO,KAAK,SAAS,EAAE,KAAK,CAAC;AAE7B,SAAO;;AAGT,QAAOD;;;;;AC1FT,MAAa,YAAY,gBAAgB;AACvC,QAAO;EACL,MAAM,SAAS;AACb,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,iBAAiB;AACrB,SAAM,IAAI,MAAM,yBAAyB;;EAE3C,MAAM,gBAAgB;AACpB,SAAM,IAAI,MAAM,yBAAyB;;EAE5C;EACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_typescriptParser = require('../typescriptParser-BBbbmG5W.cjs');
|
|
2
2
|
|
|
3
|
-
exports.createExport =
|
|
4
|
-
exports.createImport =
|
|
5
|
-
exports.print =
|
|
6
|
-
exports.
|
|
3
|
+
exports.createExport = require_typescriptParser.createExport;
|
|
4
|
+
exports.createImport = require_typescriptParser.createImport;
|
|
5
|
+
exports.print = require_typescriptParser.print;
|
|
6
|
+
exports.typescriptParser = require_typescriptParser.typescriptParser;
|
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import { t as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#region src/parsers/typescript.d.ts
|
|
6
|
-
type PrintOptions = {
|
|
7
|
-
source?: string;
|
|
8
|
-
baseName?: string;
|
|
9
|
-
scriptKind?: ts.ScriptKind;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
|
|
13
|
-
* Ensures consistent output across environments.
|
|
14
|
-
* Also works as a formatter when `source` is provided without `elements`.
|
|
15
|
-
*/
|
|
16
|
-
declare function print(elements?: Array<ts.Node>, {
|
|
17
|
-
source,
|
|
18
|
-
baseName,
|
|
19
|
-
scriptKind
|
|
20
|
-
}?: PrintOptions): string;
|
|
21
|
-
declare function createImport({
|
|
22
|
-
name,
|
|
23
|
-
path,
|
|
24
|
-
root,
|
|
25
|
-
isTypeOnly,
|
|
26
|
-
isNameSpace
|
|
27
|
-
}: {
|
|
28
|
-
name: string | Array<string | {
|
|
29
|
-
propertyName: string;
|
|
30
|
-
name?: string;
|
|
31
|
-
}>;
|
|
32
|
-
path: string;
|
|
33
|
-
root?: string;
|
|
34
|
-
isTypeOnly?: boolean;
|
|
35
|
-
isNameSpace?: boolean;
|
|
36
|
-
}): ts.ImportDeclaration;
|
|
37
|
-
declare function createExport({
|
|
38
|
-
path,
|
|
39
|
-
asAlias,
|
|
40
|
-
isTypeOnly,
|
|
41
|
-
name
|
|
42
|
-
}: {
|
|
43
|
-
path: string;
|
|
44
|
-
asAlias?: boolean;
|
|
45
|
-
isTypeOnly?: boolean;
|
|
46
|
-
name?: string | Array<ts.Identifier | string>;
|
|
47
|
-
}): ts.ExportDeclaration;
|
|
48
|
-
declare const typeScriptParser: ParserModule<object>;
|
|
49
|
-
//#endregion
|
|
50
|
-
export { createExport, createImport, print, typeScriptParser };
|
|
51
|
-
//# sourceMappingURL=typescript.d.cts.map
|
|
1
|
+
import "../App-zyf9KG3p.cjs";
|
|
2
|
+
import { i as typescriptParser, n as createImport, r as print, t as createExport } from "../typescriptParser-C-sBy1iR.cjs";
|
|
3
|
+
export { createExport, createImport, print, typescriptParser };
|
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import { t as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#region src/parsers/typescript.d.ts
|
|
6
|
-
type PrintOptions = {
|
|
7
|
-
source?: string;
|
|
8
|
-
baseName?: string;
|
|
9
|
-
scriptKind?: ts.ScriptKind;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
|
|
13
|
-
* Ensures consistent output across environments.
|
|
14
|
-
* Also works as a formatter when `source` is provided without `elements`.
|
|
15
|
-
*/
|
|
16
|
-
declare function print(elements?: Array<ts.Node>, {
|
|
17
|
-
source,
|
|
18
|
-
baseName,
|
|
19
|
-
scriptKind
|
|
20
|
-
}?: PrintOptions): string;
|
|
21
|
-
declare function createImport({
|
|
22
|
-
name,
|
|
23
|
-
path,
|
|
24
|
-
root,
|
|
25
|
-
isTypeOnly,
|
|
26
|
-
isNameSpace
|
|
27
|
-
}: {
|
|
28
|
-
name: string | Array<string | {
|
|
29
|
-
propertyName: string;
|
|
30
|
-
name?: string;
|
|
31
|
-
}>;
|
|
32
|
-
path: string;
|
|
33
|
-
root?: string;
|
|
34
|
-
isTypeOnly?: boolean;
|
|
35
|
-
isNameSpace?: boolean;
|
|
36
|
-
}): ts.ImportDeclaration;
|
|
37
|
-
declare function createExport({
|
|
38
|
-
path,
|
|
39
|
-
asAlias,
|
|
40
|
-
isTypeOnly,
|
|
41
|
-
name
|
|
42
|
-
}: {
|
|
43
|
-
path: string;
|
|
44
|
-
asAlias?: boolean;
|
|
45
|
-
isTypeOnly?: boolean;
|
|
46
|
-
name?: string | Array<ts.Identifier | string>;
|
|
47
|
-
}): ts.ExportDeclaration;
|
|
48
|
-
declare const typeScriptParser: ParserModule<object>;
|
|
49
|
-
//#endregion
|
|
50
|
-
export { createExport, createImport, print, typeScriptParser };
|
|
51
|
-
//# sourceMappingURL=typescript.d.ts.map
|
|
1
|
+
import "../App-DZuROf6f.js";
|
|
2
|
+
import { i as typescriptParser, n as createImport, r as print, t as createExport } from "../typescriptParser-CtMmz0UV.js";
|
|
3
|
+
export { createExport, createImport, print, typescriptParser };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as typescriptParser, n as createImport, r as print, t as createExport } from "../typescriptParser-BBGeFKlP.js";
|
|
2
2
|
|
|
3
|
-
export { createExport, createImport, print,
|
|
3
|
+
export { createExport, createImport, print, typescriptParser };
|
package/dist/parsers.cjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_typescriptParser = require('./typescriptParser-BBbbmG5W.cjs');
|
|
2
|
+
const require_tsxParser = require('./tsxParser-HDf_3TMc.cjs');
|
|
3
|
+
|
|
4
|
+
exports.createParser = require_typescriptParser.createParser;
|
|
5
|
+
exports.defaultParser = require_tsxParser.defaultParser;
|
|
6
|
+
exports.tsxParser = require_tsxParser.tsxParser;
|
|
7
|
+
exports.typescriptParser = require_typescriptParser.typescriptParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { o as Parser, s as UserParser } from "./App-zyf9KG3p.cjs";
|
|
2
|
+
import { i as typescriptParser } from "./typescriptParser-C-sBy1iR.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/parsers/createParser.d.ts
|
|
5
|
+
declare function createParser<TOptions = any[], TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/parsers/defaultParser.d.ts
|
|
8
|
+
declare const defaultParser: Parser<[], any>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/parsers/tsxParser.d.ts
|
|
11
|
+
declare const tsxParser: Parser<[], any>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createParser, defaultParser, tsxParser, typescriptParser };
|
|
14
|
+
//# sourceMappingURL=parsers.d.cts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { o as Parser, s as UserParser } from "./App-DZuROf6f.js";
|
|
2
|
+
import { i as typescriptParser } from "./typescriptParser-CtMmz0UV.js";
|
|
3
|
+
|
|
4
|
+
//#region src/parsers/createParser.d.ts
|
|
5
|
+
declare function createParser<TOptions = any[], TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/parsers/defaultParser.d.ts
|
|
8
|
+
declare const defaultParser: Parser<[], any>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/parsers/tsxParser.d.ts
|
|
11
|
+
declare const tsxParser: Parser<[], any>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createParser, defaultParser, tsxParser, typescriptParser };
|
|
14
|
+
//# sourceMappingURL=parsers.d.ts.map
|
package/dist/parsers.js
ADDED