@kubb/core 5.12.4 → 5.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -45,7 +45,7 @@ unstorage_drivers_fs = __toESM(unstorage_drivers_fs, 1);
|
|
|
45
45
|
let node_url = require("node:url");
|
|
46
46
|
let node_module = require("node:module");
|
|
47
47
|
//#region package.json
|
|
48
|
-
var version = "5.12.
|
|
48
|
+
var version = "5.12.6";
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region ../../internals/utils/src/casing.ts
|
|
51
51
|
/**
|
|
@@ -55,12 +55,23 @@ var version = "5.12.4";
|
|
|
55
55
|
*
|
|
56
56
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
57
57
|
*/
|
|
58
|
-
function
|
|
58
|
+
function convert(text, pascal) {
|
|
59
59
|
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
60
60
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
61
61
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
62
62
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
63
63
|
}
|
|
64
|
+
const cache = /* @__PURE__ */ new Map();
|
|
65
|
+
const cacheLimit = 1e4;
|
|
66
|
+
function toCamelOrPascal(text, pascal) {
|
|
67
|
+
const key = `${pascal ? "P" : "c"}${text}`;
|
|
68
|
+
const cached = cache.get(key);
|
|
69
|
+
if (cached !== void 0) return cached;
|
|
70
|
+
const result = convert(text, pascal);
|
|
71
|
+
if (cache.size >= cacheLimit) cache.clear();
|
|
72
|
+
cache.set(key, result);
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
64
75
|
/**
|
|
65
76
|
* Converts `text` to camelCase.
|
|
66
77
|
*
|
|
@@ -2306,6 +2317,7 @@ function createProgress(files, config, hooks) {
|
|
|
2306
2317
|
*/
|
|
2307
2318
|
var FileManager = class {
|
|
2308
2319
|
#cache = /* @__PURE__ */ new Map();
|
|
2320
|
+
#pending = /* @__PURE__ */ new Set();
|
|
2309
2321
|
#sorted = null;
|
|
2310
2322
|
add(...files) {
|
|
2311
2323
|
return this.#store(files, false);
|
|
@@ -2319,20 +2331,35 @@ var FileManager = class {
|
|
|
2319
2331
|
var _usingCtx$2 = _usingCtx();
|
|
2320
2332
|
if (!result) return;
|
|
2321
2333
|
if (Array.isArray(result)) {
|
|
2322
|
-
this
|
|
2334
|
+
this.#defer(result);
|
|
2323
2335
|
return;
|
|
2324
2336
|
}
|
|
2325
2337
|
if (!renderer) return;
|
|
2326
2338
|
const instance = _usingCtx$2.u(renderer());
|
|
2327
2339
|
await instance.render(result);
|
|
2328
|
-
this
|
|
2340
|
+
this.#defer(instance.files);
|
|
2329
2341
|
} catch (_) {
|
|
2330
2342
|
_usingCtx$2.e = _;
|
|
2331
2343
|
} finally {
|
|
2332
2344
|
_usingCtx$2.d();
|
|
2333
2345
|
}
|
|
2334
2346
|
}
|
|
2347
|
+
/** Upserts without normalizing: the raw merge waits in `#pending` until the file is read. */
|
|
2348
|
+
#defer(files) {
|
|
2349
|
+
for (const file of files) {
|
|
2350
|
+
const existing = this.#cache.get(file.path);
|
|
2351
|
+
this.#cache.set(file.path, existing ? mergeFile(existing, file) : file);
|
|
2352
|
+
this.#pending.add(file.path);
|
|
2353
|
+
}
|
|
2354
|
+
if (files.length > 0) this.#sorted = null;
|
|
2355
|
+
}
|
|
2356
|
+
/** Normalizes the pending raw merges, so every entry in `#cache` is a `createFile` result. */
|
|
2357
|
+
#flush() {
|
|
2358
|
+
for (const path of this.#pending) this.#cache.set(path, _kubb_ast.ast.factory.createFile(this.#cache.get(path)));
|
|
2359
|
+
this.#pending.clear();
|
|
2360
|
+
}
|
|
2335
2361
|
#store(files, mergeExisting) {
|
|
2362
|
+
this.#flush();
|
|
2336
2363
|
const batch = /* @__PURE__ */ new Set();
|
|
2337
2364
|
const resolved = files.map((file) => {
|
|
2338
2365
|
const existing = this.#cache.get(file.path);
|
|
@@ -2349,6 +2376,7 @@ var FileManager = class {
|
|
|
2349
2376
|
*/
|
|
2350
2377
|
dispose() {
|
|
2351
2378
|
this.#cache.clear();
|
|
2379
|
+
this.#pending.clear();
|
|
2352
2380
|
this.#sorted = null;
|
|
2353
2381
|
}
|
|
2354
2382
|
/**
|
|
@@ -2356,6 +2384,7 @@ var FileManager = class {
|
|
|
2356
2384
|
* last within a length bucket). Returns a cached view, do not mutate.
|
|
2357
2385
|
*/
|
|
2358
2386
|
get files() {
|
|
2387
|
+
this.#flush();
|
|
2359
2388
|
return this.#sorted ??= [...this.#cache.values()].sort(compareFiles);
|
|
2360
2389
|
}
|
|
2361
2390
|
/**
|