@kubb/core 5.6.2 → 5.6.3

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.
@@ -1,685 +0,0 @@
1
- import "./rolldown-runtime-C0LytTxp.js";
2
- import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
- import { dirname, isAbsolute, relative, resolve } from "node:path";
4
- import { ast, extractStringsFromNodes } from "@kubb/ast";
5
- import { EventEmitter } from "node:events";
6
- //#region ../../internals/utils/src/casing.ts
7
- /**
8
- * Shared implementation for camelCase and PascalCase conversion.
9
- * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
10
- * and capitalizes each word according to `pascal`.
11
- *
12
- * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
13
- */
14
- function toCamelOrPascal(text, pascal) {
15
- 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) => {
16
- if (word.length > 1 && word === word.toUpperCase()) return word;
17
- return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
18
- }).join("").replace(/[^a-zA-Z0-9]/g, "");
19
- }
20
- /**
21
- * Converts `text` to camelCase.
22
- *
23
- * @example Word boundaries
24
- * `camelCase('hello-world') // 'helloWorld'`
25
- *
26
- * @example With a prefix
27
- * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
28
- */
29
- function camelCase(text, { prefix = "", suffix = "" } = {}) {
30
- return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
31
- }
32
- //#endregion
33
- //#region ../../internals/utils/src/errors.ts
34
- /**
35
- * Coerces an unknown thrown value to an `Error` instance.
36
- * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
37
- *
38
- * @example
39
- * ```ts
40
- * try { ... } catch(err) {
41
- * throw new Error('Build failed', { cause: toError(err) })
42
- * }
43
- * ```
44
- */
45
- function toError(value) {
46
- return value instanceof Error ? value : new Error(String(value));
47
- }
48
- /**
49
- * Extracts a human-readable message from any thrown value.
50
- *
51
- * @example
52
- * ```ts
53
- * getErrorMessage(new Error('oops')) // 'oops'
54
- * getErrorMessage('plain string') // 'plain string'
55
- * ```
56
- */
57
- function getErrorMessage(value) {
58
- return value instanceof Error ? value.message : String(value);
59
- }
60
- //#endregion
61
- //#region ../../internals/utils/src/runtime.ts
62
- /**
63
- * Detects the JavaScript runtime executing the current process and exposes its name and version.
64
- *
65
- * Prefer the shared {@link runtime} instance over constructing your own.
66
- */
67
- var Runtime = class {
68
- /**
69
- * `true` when the current process is running under Bun.
70
- *
71
- * Detection keys off the global `Bun` object rather than `process.versions`,
72
- * because Bun polyfills `process.versions.node` for Node compatibility and would
73
- * otherwise look like Node.
74
- *
75
- * @example
76
- * ```ts
77
- * if (runtime.isBun) {
78
- * await Bun.write(path, data)
79
- * }
80
- * ```
81
- */
82
- get isBun() {
83
- return typeof Bun !== "undefined";
84
- }
85
- /**
86
- * `true` when the current process is running under Deno.
87
- */
88
- get isDeno() {
89
- return typeof globalThis.Deno !== "undefined";
90
- }
91
- /**
92
- * `true` when the current process is running under Node.
93
- *
94
- * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.
95
- */
96
- get isNode() {
97
- return !this.isBun && !this.isDeno && typeof process !== "undefined" && process.versions?.node != null;
98
- }
99
- /**
100
- * Name of the runtime executing the current process.
101
- *
102
- * @example
103
- * ```ts
104
- * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise
105
- * ```
106
- */
107
- get name() {
108
- if (this.isBun) return "bun";
109
- if (this.isDeno) return "deno";
110
- return "node";
111
- }
112
- /**
113
- * Version of the active runtime, or an empty string when it cannot be read.
114
- *
115
- * @example
116
- * ```ts
117
- * runtime.version // '1.3.11' under Bun, '22.22.2' under Node
118
- * ```
119
- */
120
- get version() {
121
- if (this.isBun) return process.versions.bun ?? "";
122
- if (this.isDeno) return globalThis.Deno?.version?.deno ?? "";
123
- return process.versions?.node ?? "";
124
- }
125
- };
126
- /**
127
- * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.
128
- */
129
- const runtime = new Runtime();
130
- //#endregion
131
- //#region ../../internals/utils/src/fs.ts
132
- /**
133
- * Resolves to `true` when the file or directory at `path` exists.
134
- * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.
135
- *
136
- * @example
137
- * ```ts
138
- * if (await exists('./kubb.config.ts')) {
139
- * const content = await read('./kubb.config.ts')
140
- * }
141
- * ```
142
- */
143
- async function exists(path) {
144
- if (runtime.isBun) return Bun.file(path).exists();
145
- return access(path).then(() => true, () => false);
146
- }
147
- /**
148
- * Reads the file at `path` as a UTF-8 string.
149
- * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.
150
- *
151
- * @example
152
- * ```ts
153
- * const source = await read('./src/Pet.ts')
154
- * ```
155
- */
156
- async function read(path) {
157
- if (runtime.isBun) return Bun.file(path).text();
158
- return readFile(path, { encoding: "utf8" });
159
- }
160
- /**
161
- * Whether `stored` already holds `source`, comparing on the trimmed text rather than the exact
162
- * bytes. Surrounding whitespace is what a formatter adds and what editors strip, and neither is a
163
- * reason to rewrite the file.
164
- *
165
- * Both sides are trimmed, so a storage that keeps bytes verbatim settles on the same answer as one
166
- * that normalizes what it stores. Trimming only `stored` would leave a source with leading
167
- * whitespace rewritten on every build, since the stored copy keeps the whitespace the comparison
168
- * has already dropped.
169
- */
170
- function matchesStored({ stored, source }) {
171
- return stored.trim() === source.trim();
172
- }
173
- /**
174
- * Writes `data` to `path`, trimming surrounding whitespace and ending the file with a single newline
175
- * the way prettier, biome, and oxfmt all do.
176
- * Skips the write when the trimmed content is empty, or when the file already holds that content.
177
- * Creates any missing parent directories automatically.
178
- * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.
179
- *
180
- * @example
181
- * ```ts
182
- * await write('./src/Pet.ts', source) // writes and returns the trimmed content plus a newline
183
- * await write('./src/Pet.ts', source) // null — file unchanged
184
- * await write('./src/Pet.ts', ' ') // null — empty content skipped
185
- * ```
186
- */
187
- async function write(path, data, options = {}) {
188
- const trimmed = data.trim();
189
- if (trimmed === "") return null;
190
- const content = `${trimmed}\n`;
191
- const resolved = resolve(path);
192
- let stored = options.stored;
193
- if (stored === void 0) {
194
- if (runtime.isBun) {
195
- const file = Bun.file(resolved);
196
- stored = await file.exists() ? await file.text() : null;
197
- } else try {
198
- stored = await readFile(resolved, { encoding: "utf-8" });
199
- } catch {
200
- stored = null;
201
- }
202
- }
203
- if (matchesStored({
204
- stored: stored ?? "",
205
- source: trimmed
206
- })) return null;
207
- if (runtime.isBun) {
208
- await Bun.write(resolved, content);
209
- return content;
210
- }
211
- try {
212
- await writeFile(resolved, content, { encoding: "utf-8" });
213
- } catch (error) {
214
- if (error.code !== "ENOENT") throw error;
215
- await mkdir(dirname(resolved), { recursive: true });
216
- await writeFile(resolved, content, { encoding: "utf-8" });
217
- }
218
- if (options.sanity) {
219
- const savedData = await readFile(resolved, { encoding: "utf-8" });
220
- if (savedData !== content) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
221
- return savedData;
222
- }
223
- return content;
224
- }
225
- /**
226
- * Recursively removes `path`. Silently succeeds when `path` does not exist.
227
- *
228
- * @example
229
- * ```ts
230
- * await clean('./dist')
231
- * ```
232
- */
233
- async function clean(path) {
234
- return rm(path, {
235
- recursive: true,
236
- force: true
237
- });
238
- }
239
- /**
240
- * Converts a filesystem path to use POSIX (`/`) separators.
241
- *
242
- * Most of the codebase compares and composes paths as strings (prefix matching, joining for
243
- * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated
244
- * paths, but on Windows it returns `\`-separated paths, which breaks every such comparison.
245
- *
246
- * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the
247
- * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is
248
- * exercisable from POSIX CI.
249
- *
250
- * @example
251
- * toPosixPath('C:\\repo\\src\\pet.ts') // 'C:/repo/src/pet.ts'
252
- */
253
- function toPosixPath(filePath) {
254
- return filePath.replaceAll("\\", "/");
255
- }
256
- /**
257
- * Resolves to `true` when `path` is `parent` itself or nested inside it. Both sides are resolved
258
- * to absolute paths first, so relative and `..`-containing inputs compare correctly.
259
- *
260
- * Guards a destructive or an out-of-tree operation: before wiping an output directory, check that
261
- * it does not contain the project root, and before loading a path a caller supplied, check that it
262
- * did not escape the directory it is allowed to read from.
263
- *
264
- * @example
265
- * isPathInside('./src/gen', '.') // true — nested inside the root
266
- * isPathInside('.', '.') // true — the same directory counts as inside
267
- * isPathInside('.', './src/gen') // false — the root is not inside its own output
268
- * isPathInside('../other', '.') // false — escapes the root
269
- */
270
- function isPathInside(path, parent) {
271
- const resolvedPath = resolve(path);
272
- const resolvedParent = resolve(parent);
273
- if (resolvedPath === resolvedParent) return true;
274
- const rel = relative(resolvedParent, resolvedPath);
275
- return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
276
- }
277
- //#endregion
278
- //#region ../../internals/utils/src/promise.ts
279
- /**
280
- * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each
281
- * takes the next item the moment it frees up instead of waiting for a batch to drain.
282
- *
283
- * @example
284
- * ```ts
285
- * await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })
286
- * ```
287
- */
288
- async function inParallel({ items, limit, run }) {
289
- const queue = items.entries();
290
- const worker = async () => {
291
- for (const [index, item] of queue) await run(item, index);
292
- };
293
- await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()));
294
- }
295
- //#endregion
296
- //#region src/Hookable.ts
297
- /**
298
- * Typed hook emitter that awaits all async listeners before resolving.
299
- * Wraps Node's `EventEmitter` with full TypeScript hook-map inference.
300
- *
301
- * @example
302
- * ```ts
303
- * const hooks = new Hookable<{ build: [name: string] }>()
304
- * hooks.hook('build', async (name) => { console.log(name) })
305
- * await hooks.callHook('build', 'petstore') // all listeners awaited
306
- * ```
307
- */
308
- var Hookable = class {
309
- /**
310
- * Maximum number of listeners per hook before Node emits a memory-leak warning.
311
- * @default 10
312
- */
313
- constructor(maxListener = 10) {
314
- this.#emitter.setMaxListeners(maxListener);
315
- }
316
- #emitter = new EventEmitter();
317
- /**
318
- * Calls `hookName` and awaits all registered listeners sequentially.
319
- * Throws if any listener rejects, wrapping the cause in an error that names the hook.
320
- *
321
- * @example
322
- * ```ts
323
- * await hooks.callHook('build', 'petstore')
324
- * ```
325
- */
326
- callHook(hookName, ...hookArgs) {
327
- const listeners = this.#emitter.listeners(hookName);
328
- if (listeners.length === 0) return;
329
- return this.#emitAll(hookName, listeners, hookArgs);
330
- }
331
- async #emitAll(hookName, listeners, hookArgs) {
332
- for (const listener of listeners) try {
333
- await listener(...hookArgs);
334
- } catch (err) {
335
- throw new Error(`Error in async listener for "${hookName}"`, { cause: toError(err) });
336
- }
337
- }
338
- /**
339
- * Registers a persistent listener for `hookName` and returns a function that removes it.
340
- *
341
- * @example
342
- * ```ts
343
- * const unhook = hooks.hook('build', async (name) => { console.log(name) })
344
- * unhook() // removes it
345
- * ```
346
- */
347
- hook(hookName, handler) {
348
- this.#emitter.on(hookName, handler);
349
- return () => this.removeHook(hookName, handler);
350
- }
351
- /**
352
- * Registers every handler in `configHooks` at once and returns a function that removes them
353
- * all. Undefined entries are skipped, so a partial hook object registers only its present keys.
354
- *
355
- * @example
356
- * ```ts
357
- * const unhook = hooks.addHooks({ build: onBuild, done: onDone })
358
- * unhook() // removes both
359
- * ```
360
- */
361
- addHooks(configHooks) {
362
- const unhooks = Object.keys(configHooks).filter((name) => configHooks[name]).map((name) => this.hook(name, configHooks[name]));
363
- return () => {
364
- for (const unhook of unhooks) unhook();
365
- };
366
- }
367
- /**
368
- * Removes a previously registered listener.
369
- *
370
- * @example
371
- * ```ts
372
- * hooks.removeHook('build', handler)
373
- * ```
374
- */
375
- removeHook(hookName, handler) {
376
- this.#emitter.off(hookName, handler);
377
- }
378
- /**
379
- * Returns the number of listeners registered for `hookName`.
380
- *
381
- * @example
382
- * ```ts
383
- * hooks.hook('build', handler)
384
- * hooks.listenerCount('build') // 1
385
- * ```
386
- */
387
- listenerCount(hookName) {
388
- return this.#emitter.listenerCount(hookName);
389
- }
390
- /**
391
- * Raises or lowers the per-hook listener ceiling before Node warns about a memory leak.
392
- * Set this above the expected listener count when many listeners attach by design.
393
- *
394
- * @example
395
- * ```ts
396
- * hooks.setMaxListeners(40)
397
- * ```
398
- */
399
- setMaxListeners(max) {
400
- this.#emitter.setMaxListeners(max);
401
- }
402
- /**
403
- * Removes all listeners from every hook channel.
404
- *
405
- * @example
406
- * ```ts
407
- * hooks.removeAllHooks()
408
- * ```
409
- */
410
- removeAllHooks() {
411
- this.#emitter.removeAllListeners();
412
- }
413
- };
414
- //#endregion
415
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/usingCtx.js
416
- function _usingCtx() {
417
- var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
418
- var n = Error();
419
- return n.name = "SuppressedError", n.error = r, n.suppressed = e, n;
420
- };
421
- var e = {};
422
- var n = [];
423
- function using(r, e) {
424
- if (null != e) {
425
- if (Object(e) !== e) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
426
- if (r) var o = e[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
427
- if (void 0 === o && (o = e[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r)) var t = o;
428
- if ("function" != typeof o) throw new TypeError("Object is not disposable.");
429
- t && (o = function o() {
430
- try {
431
- t.call(e);
432
- } catch (r) {
433
- return Promise.reject(r);
434
- }
435
- }), n.push({
436
- v: e,
437
- d: o,
438
- a: r
439
- });
440
- } else r && n.push({
441
- d: e,
442
- a: r
443
- });
444
- return e;
445
- }
446
- return {
447
- e,
448
- u: using.bind(null, !1),
449
- a: using.bind(null, !0),
450
- d: function d() {
451
- var o;
452
- var t = this.e;
453
- var s = 0;
454
- function next() {
455
- for (; o = n.pop();) try {
456
- if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
457
- if (o.d) {
458
- var r = o.d.call(o.v);
459
- if (o.a) return s |= 2, Promise.resolve(r).then(next, err);
460
- } else s |= 1;
461
- } catch (r) {
462
- return err(r);
463
- }
464
- if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
465
- if (t !== e) throw t;
466
- }
467
- function err(n) {
468
- return t = t !== e ? new r(n, t) : n, next();
469
- }
470
- return next();
471
- }
472
- };
473
- }
474
- function joinSources(file) {
475
- return file.sources.map((source) => extractStringsFromNodes(source.nodes)).filter(Boolean).join("\n\n");
476
- }
477
- /**
478
- * Reads a `copy` file and prints it through the parser's `copy` hook, or verbatim with `banner`/`footer` when there is none.
479
- */
480
- async function parseCopy(file, parser) {
481
- let content;
482
- try {
483
- content = await read(file.copy);
484
- } catch (err) {
485
- throw new Error(`[kubb] Could not copy file into output: ${file.copy}`, { cause: err });
486
- }
487
- if (parser?.copy) return parser.parse(ast.factory.createFile(parser.copy(file, content)));
488
- return [
489
- file.banner,
490
- content,
491
- file.footer
492
- ].filter((segment) => Boolean(segment)).map((segment) => segment.trimEnd()).join("\n");
493
- }
494
- function mergeFile(a, b) {
495
- return {
496
- ...a,
497
- banner: b.banner,
498
- footer: b.footer,
499
- copy: b.copy ?? a.copy,
500
- sources: a.sources.length ? b.sources.length ? [...a.sources, ...b.sources] : a.sources : b.sources,
501
- imports: a.imports.length ? b.imports.length ? [...a.imports, ...b.imports] : a.imports : b.imports,
502
- exports: a.exports.length ? b.exports.length ? [...a.exports, ...b.exports] : a.exports : b.exports
503
- };
504
- }
505
- function isIndexPath(path) {
506
- return path.endsWith("/index.ts") || path === "index.ts";
507
- }
508
- function compareFiles(a, b) {
509
- return a.path.length - b.path.length || Number(isIndexPath(a.path)) - Number(isIndexPath(b.path));
510
- }
511
- function isUnchanged({ stored, source, key, manifest }) {
512
- if (stored === null) return false;
513
- if (matchesStored({
514
- stored,
515
- source
516
- })) return true;
517
- return manifest?.isUpToDate({
518
- key,
519
- source,
520
- disk: stored
521
- }) ?? false;
522
- }
523
- /**
524
- * In-memory file store for generated files, and the writer that turns them into source
525
- * strings on `storage`. Files sharing a `path` are merged (sources/imports/exports
526
- * concatenated). The `files` getter is sorted by path length (barrel `index.ts` last
527
- * within a bucket).
528
- *
529
- * @example
530
- * ```ts
531
- * const manager = new FileManager()
532
- * manager.upsert(myFile)
533
- * manager.files // sorted view
534
- * await manager.write(manager.files, { storage: fsStorage() })
535
- * ```
536
- */
537
- var FileManager = class {
538
- hooks = new Hookable();
539
- #cache = /* @__PURE__ */ new Map();
540
- #sorted = null;
541
- add(...files) {
542
- return this.#store(files, false);
543
- }
544
- upsert(...files) {
545
- return this.#store(files, true);
546
- }
547
- /** Stores a generator result: a file array is upserted as is, an element renders through `renderer` first, falsy is a no-op. */
548
- async dispatch({ result, renderer }) {
549
- try {
550
- var _usingCtx$1 = _usingCtx();
551
- if (!result) return;
552
- if (Array.isArray(result)) {
553
- this.upsert(...result);
554
- return;
555
- }
556
- if (!renderer) return;
557
- const instance = _usingCtx$1.u(renderer());
558
- await instance.render(result);
559
- this.upsert(...instance.files);
560
- } catch (_) {
561
- _usingCtx$1.e = _;
562
- } finally {
563
- _usingCtx$1.d();
564
- }
565
- }
566
- #store(files, mergeExisting) {
567
- const batch = files.length > 1 ? this.#dedupe(files) : files;
568
- const resolved = [];
569
- for (const file of batch) {
570
- const existing = this.#cache.get(file.path);
571
- const merged = existing && mergeExisting ? ast.factory.createFile(mergeFile(existing, file)) : ast.factory.createFile(file);
572
- this.#cache.set(merged.path, merged);
573
- resolved.push(merged);
574
- }
575
- if (resolved.length > 0) this.#sorted = null;
576
- return resolved;
577
- }
578
- #dedupe(files) {
579
- const seen = /* @__PURE__ */ new Map();
580
- for (const file of files) {
581
- const prev = seen.get(file.path);
582
- seen.set(file.path, prev ? mergeFile(prev, file) : file);
583
- }
584
- return [...seen.values()];
585
- }
586
- /**
587
- * Releases all stored files and clears every `hooks` listener. Called by the core after
588
- * `kubb:build:end`.
589
- */
590
- dispose() {
591
- this.#cache.clear();
592
- this.#sorted = null;
593
- this.hooks.removeAllHooks();
594
- }
595
- /**
596
- * All stored files in stable sort order (shortest path first, barrel files
597
- * last within a length bucket). Returns a cached view, do not mutate.
598
- */
599
- get files() {
600
- return this.#sorted ??= [...this.#cache.values()].sort(compareFiles);
601
- }
602
- /**
603
- * Converts a file's AST sources (or its `copy` source) into the final on-disk string.
604
- */
605
- async parse(file, { parsers } = {}) {
606
- const parser = parsers?.get(file.extname);
607
- if (file.copy) return parseCopy(file, parser);
608
- if (!parser) return joinSources(file);
609
- return parser.parse(file);
610
- }
611
- /**
612
- * Parses and writes every file through a bounded pool of workers. A small spec runs all its files
613
- * at once; a spec with thousands of files keeps at most {@link FILE_CONCURRENCY} parsed sources in
614
- * memory rather than holding every source, while still overlapping each file's write with the
615
- * next file's parse. Each `update` carries the file's input position, so a consumer can present
616
- * the files in generation order even though they finish in whatever order they parse.
617
- *
618
- * A file the storage already holds is skipped, so a rebuild that generates identical output
619
- * writes nothing and leaves every mtime where it was.
620
- */
621
- async write(files, { storage, parsers, manifest, signal }) {
622
- if (files.length === 0) return;
623
- await this.hooks.callHook("start", files);
624
- const total = files.length;
625
- await inParallel({
626
- items: files,
627
- limit: 50,
628
- run: async (file, index) => {
629
- signal?.throwIfAborted();
630
- const source = await this.parse(file, { parsers });
631
- await this.hooks.callHook("update", {
632
- file,
633
- source,
634
- processed: index + 1,
635
- total,
636
- percentage: (index + 1) / total * 100
637
- });
638
- if (!source) return;
639
- signal?.throwIfAborted();
640
- const stored = await storage.readItem(file.path);
641
- if (isUnchanged({
642
- stored,
643
- source,
644
- key: file.path,
645
- manifest
646
- })) return;
647
- signal?.throwIfAborted();
648
- await storage.writeItem(file.path, source, { stored });
649
- manifest?.track({
650
- key: file.path,
651
- source
652
- });
653
- }
654
- });
655
- await this.hooks.callHook("end", files);
656
- }
657
- };
658
- //#endregion
659
- //#region src/nodeCache.ts
660
- /**
661
- * Builds an empty {@link NodeCache} backed by a plain `Map`. Called once per node in the generate
662
- * walk.
663
- */
664
- function createNodeCache() {
665
- const store = /* @__PURE__ */ new Map();
666
- return {
667
- readItem(key) {
668
- return store.get(key);
669
- },
670
- writeItem(key, value) {
671
- store.set(key, value);
672
- return value;
673
- },
674
- ensureItem(key, factory) {
675
- if (store.has(key)) return store.get(key);
676
- const value = factory();
677
- store.set(key, value);
678
- return value;
679
- }
680
- };
681
- }
682
- //#endregion
683
- export { inParallel as a, isPathInside as c, write as d, getErrorMessage as f, Hookable as i, read as l, camelCase as m, FileManager as n, clean as o, toError as p, _usingCtx as r, exists as s, createNodeCache as t, toPosixPath as u };
684
-
685
- //# sourceMappingURL=nodeCache-CumrOPh-.js.map