@kubb/core 5.12.3 → 5.12.5
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.5";
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region ../../internals/utils/src/casing.ts
|
|
51
51
|
/**
|
|
@@ -55,12 +55,23 @@ var version = "5.12.3";
|
|
|
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
|
*
|
|
@@ -1540,7 +1551,11 @@ async function resolvePublicFetchConfig(repo, signal) {
|
|
|
1540
1551
|
addresses
|
|
1541
1552
|
});
|
|
1542
1553
|
}
|
|
1543
|
-
/**
|
|
1554
|
+
/**
|
|
1555
|
+
* The `GIT_CONFIG_*` pair that sends an `Authorization` header to `repo`'s origin, numbered after
|
|
1556
|
+
* the pairs already in `env`, so the token stays out of the process arguments. Throws
|
|
1557
|
+
* `KUBB_GIT_INPUT_FAILED` for a value with a line break, which would add another header.
|
|
1558
|
+
*/
|
|
1544
1559
|
function gitAuthEnv(env, { repo, authorization }) {
|
|
1545
1560
|
if (/[\r\n]/.test(authorization) || !URL.canParse(repo)) throw gitError("The authorization for a git `input` must be one line, for an https repository.");
|
|
1546
1561
|
const index = Math.max(0, Number.parseInt(env.GIT_CONFIG_COUNT ?? "", 10) || 0);
|
|
@@ -2302,6 +2317,7 @@ function createProgress(files, config, hooks) {
|
|
|
2302
2317
|
*/
|
|
2303
2318
|
var FileManager = class {
|
|
2304
2319
|
#cache = /* @__PURE__ */ new Map();
|
|
2320
|
+
#pending = /* @__PURE__ */ new Set();
|
|
2305
2321
|
#sorted = null;
|
|
2306
2322
|
add(...files) {
|
|
2307
2323
|
return this.#store(files, false);
|
|
@@ -2315,20 +2331,35 @@ var FileManager = class {
|
|
|
2315
2331
|
var _usingCtx$2 = _usingCtx();
|
|
2316
2332
|
if (!result) return;
|
|
2317
2333
|
if (Array.isArray(result)) {
|
|
2318
|
-
this
|
|
2334
|
+
this.#defer(result);
|
|
2319
2335
|
return;
|
|
2320
2336
|
}
|
|
2321
2337
|
if (!renderer) return;
|
|
2322
2338
|
const instance = _usingCtx$2.u(renderer());
|
|
2323
2339
|
await instance.render(result);
|
|
2324
|
-
this
|
|
2340
|
+
this.#defer(instance.files);
|
|
2325
2341
|
} catch (_) {
|
|
2326
2342
|
_usingCtx$2.e = _;
|
|
2327
2343
|
} finally {
|
|
2328
2344
|
_usingCtx$2.d();
|
|
2329
2345
|
}
|
|
2330
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
|
+
}
|
|
2331
2361
|
#store(files, mergeExisting) {
|
|
2362
|
+
this.#flush();
|
|
2332
2363
|
const batch = /* @__PURE__ */ new Set();
|
|
2333
2364
|
const resolved = files.map((file) => {
|
|
2334
2365
|
const existing = this.#cache.get(file.path);
|
|
@@ -2345,6 +2376,7 @@ var FileManager = class {
|
|
|
2345
2376
|
*/
|
|
2346
2377
|
dispose() {
|
|
2347
2378
|
this.#cache.clear();
|
|
2379
|
+
this.#pending.clear();
|
|
2348
2380
|
this.#sorted = null;
|
|
2349
2381
|
}
|
|
2350
2382
|
/**
|
|
@@ -2352,6 +2384,7 @@ var FileManager = class {
|
|
|
2352
2384
|
* last within a length bucket). Returns a cached view, do not mutate.
|
|
2353
2385
|
*/
|
|
2354
2386
|
get files() {
|
|
2387
|
+
this.#flush();
|
|
2355
2388
|
return this.#sorted ??= [...this.#cache.values()].sort(compareFiles);
|
|
2356
2389
|
}
|
|
2357
2390
|
/**
|