@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.
@@ -19,7 +19,7 @@ var __name = (target, value) => __defProp(target, "name", {
19
19
  });
20
20
  //#endregion
21
21
  //#region package.json
22
- var version = "5.12.3";
22
+ var version = "5.12.5";
23
23
  //#endregion
24
24
  //#region ../../internals/utils/src/casing.ts
25
25
  /**
@@ -29,12 +29,23 @@ var version = "5.12.3";
29
29
  *
30
30
  * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
31
31
  */
32
- function toCamelOrPascal(text, pascal) {
32
+ function convert(text, pascal) {
33
33
  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) => {
34
34
  if (word.length > 1 && word === word.toUpperCase()) return word;
35
35
  return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
36
36
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
37
37
  }
38
+ const cache = /* @__PURE__ */ new Map();
39
+ const cacheLimit = 1e4;
40
+ function toCamelOrPascal(text, pascal) {
41
+ const key = `${pascal ? "P" : "c"}${text}`;
42
+ const cached = cache.get(key);
43
+ if (cached !== void 0) return cached;
44
+ const result = convert(text, pascal);
45
+ if (cache.size >= cacheLimit) cache.clear();
46
+ cache.set(key, result);
47
+ return result;
48
+ }
38
49
  /**
39
50
  * Converts `text` to camelCase.
40
51
  *
@@ -1358,7 +1369,11 @@ async function resolvePublicFetchConfig(repo, signal) {
1358
1369
  addresses
1359
1370
  });
1360
1371
  }
1361
- /** Adds an `Authorization` header for `repo`'s origin as the `GIT_CONFIG_*` pair after those in `env`, keeping the token out of the arguments; throws on a line break. */
1372
+ /**
1373
+ * The `GIT_CONFIG_*` pair that sends an `Authorization` header to `repo`'s origin, numbered after
1374
+ * the pairs already in `env`, so the token stays out of the process arguments. Throws
1375
+ * `KUBB_GIT_INPUT_FAILED` for a value with a line break, which would add another header.
1376
+ */
1362
1377
  function gitAuthEnv(env, { repo, authorization }) {
1363
1378
  if (/[\r\n]/.test(authorization) || !URL.canParse(repo)) throw gitError("The authorization for a git `input` must be one line, for an https repository.");
1364
1379
  const index = Math.max(0, Number.parseInt(env.GIT_CONFIG_COUNT ?? "", 10) || 0);
@@ -2120,6 +2135,7 @@ function createProgress(files, config, hooks) {
2120
2135
  */
2121
2136
  var FileManager = class {
2122
2137
  #cache = /* @__PURE__ */ new Map();
2138
+ #pending = /* @__PURE__ */ new Set();
2123
2139
  #sorted = null;
2124
2140
  add(...files) {
2125
2141
  return this.#store(files, false);
@@ -2133,20 +2149,35 @@ var FileManager = class {
2133
2149
  var _usingCtx$1 = _usingCtx();
2134
2150
  if (!result) return;
2135
2151
  if (Array.isArray(result)) {
2136
- this.upsert(...result);
2152
+ this.#defer(result);
2137
2153
  return;
2138
2154
  }
2139
2155
  if (!renderer) return;
2140
2156
  const instance = _usingCtx$1.u(renderer());
2141
2157
  await instance.render(result);
2142
- this.upsert(...instance.files);
2158
+ this.#defer(instance.files);
2143
2159
  } catch (_) {
2144
2160
  _usingCtx$1.e = _;
2145
2161
  } finally {
2146
2162
  _usingCtx$1.d();
2147
2163
  }
2148
2164
  }
2165
+ /** Upserts without normalizing: the raw merge waits in `#pending` until the file is read. */
2166
+ #defer(files) {
2167
+ for (const file of files) {
2168
+ const existing = this.#cache.get(file.path);
2169
+ this.#cache.set(file.path, existing ? mergeFile(existing, file) : file);
2170
+ this.#pending.add(file.path);
2171
+ }
2172
+ if (files.length > 0) this.#sorted = null;
2173
+ }
2174
+ /** Normalizes the pending raw merges, so every entry in `#cache` is a `createFile` result. */
2175
+ #flush() {
2176
+ for (const path of this.#pending) this.#cache.set(path, ast.factory.createFile(this.#cache.get(path)));
2177
+ this.#pending.clear();
2178
+ }
2149
2179
  #store(files, mergeExisting) {
2180
+ this.#flush();
2150
2181
  const batch = /* @__PURE__ */ new Set();
2151
2182
  const resolved = files.map((file) => {
2152
2183
  const existing = this.#cache.get(file.path);
@@ -2163,6 +2194,7 @@ var FileManager = class {
2163
2194
  */
2164
2195
  dispose() {
2165
2196
  this.#cache.clear();
2197
+ this.#pending.clear();
2166
2198
  this.#sorted = null;
2167
2199
  }
2168
2200
  /**
@@ -2170,6 +2202,7 @@ var FileManager = class {
2170
2202
  * last within a length bucket). Returns a cached view, do not mutate.
2171
2203
  */
2172
2204
  get files() {
2205
+ this.#flush();
2173
2206
  return this.#sorted ??= [...this.#cache.values()].sort(compareFiles);
2174
2207
  }
2175
2208
  /**
@@ -3084,4 +3117,4 @@ var Hookable = class {
3084
3117
  //#endregion
3085
3118
  export { formatMs as A, toError as B, useConfig as C, defineExtension as D, checkCompatibility as E, listFiles as F, __name as H, read as I, rm$1 as L, inParallel as M, existsSync$1 as N, resolveMeta as O, isPathInside as P, write as R, tryUseKubb as S, useOptions as T, camelCase as V, kubbContext as _, FileManager as a, setOptions as b, Resolver as c, isPublicAddress as d, assertPluginOption as f, injectFile as g, addMacro as h, createNodeCache as i, getElapsedMs as j, Diagnostics as k, getInputKind as l, addGenerator as m, KubbDriver as n, _usingCtx as o, definePlugin as p, pluginNotFoundError as r, createResolver as s, Hookable as t, checkoutGitInput as u, requirePlugin as v, useKubb as w, setResolver as x, setMacros as y, writeRaw as z };
3086
3119
 
3087
- //# sourceMappingURL=Hookable-DPTq2eNO.js.map
3120
+ //# sourceMappingURL=Hookable-CZZ19wvm.js.map