@kubb/core 4.28.0 → 4.29.0

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.
Files changed (66) hide show
  1. package/dist/{chunk-C1_xRkKa.cjs → chunk-CNbaEX1y.cjs} +1 -1
  2. package/dist/{chunk-iVr_oF3V.js → chunk-DKWOrOAv.js} +1 -1
  3. package/dist/fs.cjs +8 -7
  4. package/dist/fs.d.ts +1 -1
  5. package/dist/fs.js +1 -1
  6. package/dist/{getBarrelFiles-gRyVPFBP.js → getBarrelFiles-BBDOJ2lV.js} +20 -20
  7. package/dist/getBarrelFiles-BBDOJ2lV.js.map +1 -0
  8. package/dist/{getBarrelFiles-DCNjiX2W.cjs → getBarrelFiles-BttXy8Sp.cjs} +22 -28
  9. package/dist/getBarrelFiles-BttXy8Sp.cjs.map +1 -0
  10. package/dist/{getBarrelFiles-CHL9_Obd.d.ts → getBarrelFiles-C7gz90HF.d.ts} +5 -8
  11. package/dist/{getBarrelFiles-CmpI3rrq.d.cts → getBarrelFiles-DAhlPFXC.d.ts} +5 -8
  12. package/dist/hooks.cjs +2 -1
  13. package/dist/hooks.cjs.map +1 -1
  14. package/dist/hooks.d.ts +2 -2
  15. package/dist/hooks.js +1 -1
  16. package/dist/index.cjs +33 -211
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +5 -8
  19. package/dist/index.js +26 -202
  20. package/dist/index.js.map +1 -1
  21. package/dist/{transformers-B8kXgG3q.cjs → toRegExp-DGgAWZ_m.cjs} +15 -117
  22. package/dist/toRegExp-DGgAWZ_m.cjs.map +1 -0
  23. package/dist/{transformers-8ju9ixkG.js → toRegExp-DdJ1Kgbf.js} +16 -112
  24. package/dist/toRegExp-DdJ1Kgbf.js.map +1 -0
  25. package/dist/transformers.cjs +45 -36
  26. package/dist/transformers.cjs.map +1 -0
  27. package/dist/transformers.d.ts +2 -6
  28. package/dist/transformers.js +26 -2
  29. package/dist/transformers.js.map +1 -0
  30. package/dist/{types-Cn3Gwsf3.d.ts → types-CiePC9Y3.d.ts} +6 -11
  31. package/dist/{types-ulibr7zw.d.cts → types-Ciz0gIX7.d.ts} +6 -11
  32. package/dist/utils.cjs +36 -20
  33. package/dist/utils.cjs.map +1 -1
  34. package/dist/utils.d.ts +8 -5
  35. package/dist/utils.js +34 -20
  36. package/dist/utils.js.map +1 -1
  37. package/dist/write-CwpeNfTd.cjs +108 -0
  38. package/dist/write-CwpeNfTd.cjs.map +1 -0
  39. package/dist/write-DiGboRXI.js +72 -0
  40. package/dist/write-DiGboRXI.js.map +1 -0
  41. package/package.json +22 -27
  42. package/src/PackageManager.ts +3 -3
  43. package/src/fs/clean.ts +2 -2
  44. package/src/fs/exists.ts +10 -30
  45. package/src/fs/read.ts +7 -30
  46. package/src/fs/write.ts +38 -55
  47. package/src/transformers/casing.ts +22 -4
  48. package/src/transformers/index.ts +0 -7
  49. package/src/utils/FunctionParams.ts +5 -18
  50. package/src/utils/formatters.ts +2 -2
  51. package/src/utils/index.ts +1 -0
  52. package/src/utils/linters.ts +2 -2
  53. package/src/utils/tokenize.ts +23 -0
  54. package/dist/fs-Parec-wn.js +0 -105
  55. package/dist/fs-Parec-wn.js.map +0 -1
  56. package/dist/fs-jxNCXQUq.cjs +0 -141
  57. package/dist/fs-jxNCXQUq.cjs.map +0 -1
  58. package/dist/fs.d.cts +0 -23
  59. package/dist/getBarrelFiles-DCNjiX2W.cjs.map +0 -1
  60. package/dist/getBarrelFiles-gRyVPFBP.js.map +0 -1
  61. package/dist/hooks.d.cts +0 -15
  62. package/dist/index.d.cts +0 -119
  63. package/dist/transformers-8ju9ixkG.js.map +0 -1
  64. package/dist/transformers-B8kXgG3q.cjs.map +0 -1
  65. package/dist/transformers.d.cts +0 -112
  66. package/dist/utils.d.cts +0 -287
@@ -1,5 +1,5 @@
1
- import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { E as PossiblePromise, S as UserConfig, f as Plugin, o as InputPath, t as BarrelType } from "./types-Cn3Gwsf3.js";
1
+ import { t as __name } from "./chunk-cy2TeOE5.cjs";
2
+ import { E as PossiblePromise, S as UserConfig, f as Plugin, o as InputPath, t as BarrelType } from "./types-Ciz0gIX7.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/config.d.ts
@@ -7,9 +7,7 @@ import { KubbFile } from "@kubb/fabric-core/types";
7
7
  * CLI options derived from command-line flags.
8
8
  */
9
9
  type CLIOptions = {
10
- /** Path to `kubb.config.js` */
11
- config?: string;
12
- /** Enable watch mode for input files */
10
+ /** Path to `kubb.config.js` */config?: string; /** Enable watch mode for input files */
13
11
  watch?: boolean;
14
12
  /**
15
13
  * Logging verbosity for CLI usage.
@@ -19,8 +17,7 @@ type CLIOptions = {
19
17
  * - `debug`: include detailed plugin lifecycle logs
20
18
  * @default 'silent'
21
19
  */
22
- logLevel?: 'silent' | 'info' | 'debug';
23
- /** Run Kubb with Bun */
20
+ logLevel?: 'silent' | 'info' | 'debug'; /** Run Kubb with Bun */
24
21
  bun?: boolean;
25
22
  };
26
23
  /**
@@ -73,4 +70,4 @@ declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
73
70
  }: AddIndexesProps): Promise<KubbFile.File[]>;
74
71
  //#endregion
75
72
  export { isInputPath as a, defineConfig as i, getBarrelFiles as n, CLIOptions as r, FileMetaBase as t };
76
- //# sourceMappingURL=getBarrelFiles-CHL9_Obd.d.ts.map
73
+ //# sourceMappingURL=getBarrelFiles-C7gz90HF.d.ts.map
@@ -1,5 +1,5 @@
1
- import { t as __name } from "./chunk-DlpkT3g-.cjs";
2
- import { E as PossiblePromise, S as UserConfig, f as Plugin, o as InputPath, t as BarrelType } from "./types-ulibr7zw.cjs";
1
+ import { t as __name } from "./chunk-DKWOrOAv.js";
2
+ import { E as PossiblePromise, S as UserConfig, f as Plugin, o as InputPath, t as BarrelType } from "./types-CiePC9Y3.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/config.d.ts
@@ -7,9 +7,7 @@ import { KubbFile } from "@kubb/fabric-core/types";
7
7
  * CLI options derived from command-line flags.
8
8
  */
9
9
  type CLIOptions = {
10
- /** Path to `kubb.config.js` */
11
- config?: string;
12
- /** Enable watch mode for input files */
10
+ /** Path to `kubb.config.js` */config?: string; /** Enable watch mode for input files */
13
11
  watch?: boolean;
14
12
  /**
15
13
  * Logging verbosity for CLI usage.
@@ -19,8 +17,7 @@ type CLIOptions = {
19
17
  * - `debug`: include detailed plugin lifecycle logs
20
18
  * @default 'silent'
21
19
  */
22
- logLevel?: 'silent' | 'info' | 'debug';
23
- /** Run Kubb with Bun */
20
+ logLevel?: 'silent' | 'info' | 'debug'; /** Run Kubb with Bun */
24
21
  bun?: boolean;
25
22
  };
26
23
  /**
@@ -73,4 +70,4 @@ declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
73
70
  }: AddIndexesProps): Promise<KubbFile.File[]>;
74
71
  //#endregion
75
72
  export { isInputPath as a, defineConfig as i, getBarrelFiles as n, CLIOptions as r, FileMetaBase as t };
76
- //# sourceMappingURL=getBarrelFiles-CmpI3rrq.d.cts.map
73
+ //# sourceMappingURL=getBarrelFiles-DAhlPFXC.d.ts.map
package/dist/hooks.cjs CHANGED
@@ -1,4 +1,5 @@
1
- const require_chunk = require('./chunk-C1_xRkKa.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_chunk = require('./chunk-CNbaEX1y.cjs');
2
3
  let _kubb_react_fabric = require("@kubb/react-fabric");
3
4
 
4
5
  //#region src/hooks/useMode.ts
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;;AAGA,SAAgB,UAAyB;CACvC,MAAM,EAAE,yCAA0C;AAElD,QAAO,KAAK;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,yCAA+C;AAEvD,QAAO,KAAK;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,yCAAmD;AAE3D,QAAO,KAAK"}
1
+ {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;;;AAGA,SAAgB,UAAyB;CACvC,MAAM,EAAE,yCAA0C;AAElD,QAAO,KAAK;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,yCAA+C;AAEvD,QAAO,KAAK;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,yCAAmD;AAE3D,QAAO,KAAK"}
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { O as PluginManager, f as Plugin, m as PluginFactoryOptions } from "./types-Cn3Gwsf3.js";
1
+ import { t as __name } from "./chunk-cy2TeOE5.cjs";
2
+ import { O as PluginManager, f as Plugin, m as PluginFactoryOptions } from "./types-Ciz0gIX7.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/hooks/useMode.d.ts
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as __name } from "./chunk-iVr_oF3V.js";
1
+ import { t as __name } from "./chunk-DKWOrOAv.js";
2
2
  import { useApp } from "@kubb/react-fabric";
3
3
 
4
4
  //#region src/hooks/useMode.ts
package/dist/index.cjs CHANGED
@@ -1,22 +1,19 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_chunk = require('./chunk-C1_xRkKa.cjs');
3
- const require_getBarrelFiles = require('./getBarrelFiles-DCNjiX2W.cjs');
4
- const require_fs = require('./fs-jxNCXQUq.cjs');
5
- require('./transformers-B8kXgG3q.cjs');
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_chunk = require('./chunk-CNbaEX1y.cjs');
3
+ const require_getBarrelFiles = require('./getBarrelFiles-BttXy8Sp.cjs');
4
+ const require_write = require('./write-CwpeNfTd.cjs');
6
5
  let node_path = require("node:path");
7
- node_path = require_chunk.__toESM(node_path);
8
6
  let _kubb_react_fabric = require("@kubb/react-fabric");
9
7
  let _kubb_react_fabric_parsers = require("@kubb/react-fabric/parsers");
10
8
  let _kubb_react_fabric_plugins = require("@kubb/react-fabric/plugins");
11
9
  let node_process = require("node:process");
12
- node_process = require_chunk.__toESM(node_process);
13
10
  let node_module = require("node:module");
14
11
  node_module = require_chunk.__toESM(node_module);
15
12
  let node_os = require("node:os");
16
13
  node_os = require_chunk.__toESM(node_os);
17
14
  let node_url = require("node:url");
18
- let node_fs = require("node:fs");
19
- node_fs = require_chunk.__toESM(node_fs);
15
+ let empathic_package = require("empathic/package");
16
+ empathic_package = require_chunk.__toESM(empathic_package);
20
17
  let semver = require("semver");
21
18
 
22
19
  //#region src/BaseGenerator.ts
@@ -74,7 +71,7 @@ function isInputPath(config) {
74
71
 
75
72
  //#endregion
76
73
  //#region package.json
77
- var version = "4.28.0";
74
+ var version = "4.29.0";
78
75
 
79
76
  //#endregion
80
77
  //#region src/utils/diagnostics.ts
@@ -116,7 +113,7 @@ async function setup(options) {
116
113
  });
117
114
  try {
118
115
  if (isInputPath(userConfig) && !new require_getBarrelFiles.URLPath(userConfig.input.path).isURL) {
119
- await require_fs.exists(userConfig.input.path);
116
+ await require_write.exists(userConfig.input.path);
120
117
  await events.emit("debug", {
121
118
  date: /* @__PURE__ */ new Date(),
122
119
  logs: [`✓ Input file validated: ${userConfig.input.path}`]
@@ -145,7 +142,7 @@ async function setup(options) {
145
142
  date: /* @__PURE__ */ new Date(),
146
143
  logs: ["Cleaning output directories", ` • Output: ${definedConfig.output.path}`]
147
144
  });
148
- await require_fs.clean(definedConfig.output.path);
145
+ await require_write.clean(definedConfig.output.path);
149
146
  }
150
147
  const fabric = (0, _kubb_react_fabric.createFabric)();
151
148
  fabric.use(_kubb_react_fabric_plugins.fsPlugin);
@@ -165,7 +162,7 @@ async function setup(options) {
165
162
  source
166
163
  });
167
164
  if (source) {
168
- if (definedConfig.output.write) await require_fs.write(file.path, source, { sanity: false });
165
+ if (definedConfig.output.write) await require_write.write(file.path, source, { sanity: false });
169
166
  sources.set(file.path, source);
170
167
  }
171
168
  });
@@ -199,7 +196,7 @@ async function build(options, overrides) {
199
196
  const { fabric, files, pluginManager, failedPlugins, pluginTimings, error, sources } = await safeBuild(options, overrides);
200
197
  if (error) throw error;
201
198
  if (failedPlugins.size > 0) {
202
- const errors = [...failedPlugins].map(({ error: error$1 }) => error$1);
199
+ const errors = [...failedPlugins].map(({ error }) => error);
203
200
  throw new require_getBarrelFiles.BuildError(`Build Error with ${failedPlugins.size} failed plugins`, { errors });
204
201
  }
205
202
  return {
@@ -296,7 +293,7 @@ async function safeBuild(options, overrides) {
296
293
  if (!pluginOptions || pluginOptions?.output?.barrelType === false) return;
297
294
  return {
298
295
  name: config.output.barrelType === "all" ? void 0 : [source.name],
299
- path: require_fs.getRelativePath(rootPath, file.path),
296
+ path: require_write.getRelativePath(rootPath, file.path),
300
297
  isTypeOnly: config.output.barrelType === "all" ? containsOnlyTypes : source.isTypeOnly
301
298
  };
302
299
  }).filter(Boolean);
@@ -345,183 +342,8 @@ function defineLogger(logger) {
345
342
  /**
346
343
  * Wraps a plugin builder to make the options parameter optional.
347
344
  */
348
- function definePlugin(build$1) {
349
- return (options) => build$1(options ?? {});
350
- }
351
-
352
- //#endregion
353
- //#region ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
354
- function pLimit(concurrency) {
355
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) throw new TypeError("Expected `concurrency` to be a number from 1 and up");
356
- const queue = new require_getBarrelFiles.Queue();
357
- let activeCount = 0;
358
- const next = () => {
359
- activeCount--;
360
- if (queue.size > 0) queue.dequeue()();
361
- };
362
- const run = async (fn, resolve$1, args) => {
363
- activeCount++;
364
- const result = (async () => fn(...args))();
365
- resolve$1(result);
366
- try {
367
- await result;
368
- } catch {}
369
- next();
370
- };
371
- const enqueue = (fn, resolve$1, args) => {
372
- queue.enqueue(run.bind(void 0, fn, resolve$1, args));
373
- (async () => {
374
- await Promise.resolve();
375
- if (activeCount < concurrency && queue.size > 0) queue.dequeue()();
376
- })();
377
- };
378
- const generator = (fn, ...args) => new Promise((resolve$1) => {
379
- enqueue(fn, resolve$1, args);
380
- });
381
- Object.defineProperties(generator, {
382
- activeCount: { get: () => activeCount },
383
- pendingCount: { get: () => queue.size },
384
- clearQueue: { value: () => {
385
- queue.clear();
386
- } }
387
- });
388
- return generator;
389
- }
390
-
391
- //#endregion
392
- //#region ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
393
- var EndError = class extends Error {
394
- constructor(value) {
395
- super();
396
- this.value = value;
397
- }
398
- };
399
- const testElement = async (element, tester) => tester(await element);
400
- const finder = async (element) => {
401
- const values = await Promise.all(element);
402
- if (values[1] === true) throw new EndError(values[0]);
403
- return false;
404
- };
405
- async function pLocate(iterable, tester, { concurrency = Number.POSITIVE_INFINITY, preserveOrder = true } = {}) {
406
- const limit = pLimit(concurrency);
407
- const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
408
- const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
409
- try {
410
- await Promise.all(items.map((element) => checkLimit(finder, element)));
411
- } catch (error) {
412
- if (error instanceof EndError) return error.value;
413
- throw error;
414
- }
415
- }
416
-
417
- //#endregion
418
- //#region ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
419
- const typeMappings = {
420
- directory: "isDirectory",
421
- file: "isFile"
422
- };
423
- function checkType(type) {
424
- if (Object.hasOwnProperty.call(typeMappings, type)) return;
425
- throw new Error(`Invalid type specified: ${type}`);
426
- }
427
- const matchType = (type, stat) => stat[typeMappings[type]]();
428
- const toPath$1 = /* @__PURE__ */ require_chunk.__name((urlOrPath) => urlOrPath instanceof URL ? (0, node_url.fileURLToPath)(urlOrPath) : urlOrPath, "toPath");
429
- async function locatePath(paths, { cwd = node_process.default.cwd(), type = "file", allowSymlinks = true, concurrency, preserveOrder } = {}) {
430
- checkType(type);
431
- cwd = toPath$1(cwd);
432
- const statFunction = allowSymlinks ? node_fs.promises.stat : node_fs.promises.lstat;
433
- return pLocate(paths, async (path_) => {
434
- try {
435
- return matchType(type, await statFunction(node_path.default.resolve(cwd, path_)));
436
- } catch {
437
- return false;
438
- }
439
- }, {
440
- concurrency,
441
- preserveOrder
442
- });
443
- }
444
- function locatePathSync(paths, { cwd = node_process.default.cwd(), type = "file", allowSymlinks = true } = {}) {
445
- checkType(type);
446
- cwd = toPath$1(cwd);
447
- const statFunction = allowSymlinks ? node_fs.default.statSync : node_fs.default.lstatSync;
448
- for (const path_ of paths) try {
449
- const stat = statFunction(node_path.default.resolve(cwd, path_), { throwIfNoEntry: false });
450
- if (!stat) continue;
451
- if (matchType(type, stat)) return path_;
452
- } catch {}
453
- }
454
-
455
- //#endregion
456
- //#region ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
457
- function toPath(urlOrPath) {
458
- return urlOrPath instanceof URL ? (0, node_url.fileURLToPath)(urlOrPath) : urlOrPath;
459
- }
460
-
461
- //#endregion
462
- //#region ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
463
- const findUpStop = Symbol("findUpStop");
464
- async function findUpMultiple(name, options = {}) {
465
- let directory = node_path.default.resolve(toPath(options.cwd) ?? "");
466
- const { root } = node_path.default.parse(directory);
467
- const stopAt = node_path.default.resolve(directory, toPath(options.stopAt ?? root));
468
- const limit = options.limit ?? Number.POSITIVE_INFINITY;
469
- const paths = [name].flat();
470
- const runMatcher = async (locateOptions) => {
471
- if (typeof name !== "function") return locatePath(paths, locateOptions);
472
- const foundPath = await name(locateOptions.cwd);
473
- if (typeof foundPath === "string") return locatePath([foundPath], locateOptions);
474
- return foundPath;
475
- };
476
- const matches = [];
477
- while (true) {
478
- const foundPath = await runMatcher({
479
- ...options,
480
- cwd: directory
481
- });
482
- if (foundPath === findUpStop) break;
483
- if (foundPath) matches.push(node_path.default.resolve(directory, foundPath));
484
- if (directory === stopAt || matches.length >= limit) break;
485
- directory = node_path.default.dirname(directory);
486
- }
487
- return matches;
488
- }
489
- function findUpMultipleSync(name, options = {}) {
490
- let directory = node_path.default.resolve(toPath(options.cwd) ?? "");
491
- const { root } = node_path.default.parse(directory);
492
- const stopAt = node_path.default.resolve(directory, toPath(options.stopAt) ?? root);
493
- const limit = options.limit ?? Number.POSITIVE_INFINITY;
494
- const paths = [name].flat();
495
- const runMatcher = (locateOptions) => {
496
- if (typeof name !== "function") return locatePathSync(paths, locateOptions);
497
- const foundPath = name(locateOptions.cwd);
498
- if (typeof foundPath === "string") return locatePathSync([foundPath], locateOptions);
499
- return foundPath;
500
- };
501
- const matches = [];
502
- while (true) {
503
- const foundPath = runMatcher({
504
- ...options,
505
- cwd: directory
506
- });
507
- if (foundPath === findUpStop) break;
508
- if (foundPath) matches.push(node_path.default.resolve(directory, foundPath));
509
- if (directory === stopAt || matches.length >= limit) break;
510
- directory = node_path.default.dirname(directory);
511
- }
512
- return matches;
513
- }
514
- async function findUp(name, options = {}) {
515
- return (await findUpMultiple(name, {
516
- ...options,
517
- limit: 1
518
- }))[0];
519
- }
520
- function findUpSync(name, options = {}) {
521
- return findUpMultipleSync(name, {
522
- ...options,
523
- limit: 1
524
- })[0];
345
+ function definePlugin(build) {
346
+ return (options) => build(options ?? {});
525
347
  }
526
348
 
527
349
  //#endregion
@@ -545,36 +367,36 @@ var PackageManager = class PackageManager {
545
367
  if (lastChar && !this.#SLASHES.has(lastChar)) return `${directory}/`;
546
368
  return directory;
547
369
  }
548
- getLocation(path$2) {
549
- let location = path$2;
550
- if (this.#cwd) location = node_module.default.createRequire(this.normalizeDirectory(this.#cwd)).resolve(path$2);
370
+ getLocation(path) {
371
+ let location = path;
372
+ if (this.#cwd) location = node_module.default.createRequire(this.normalizeDirectory(this.#cwd)).resolve(path);
551
373
  return location;
552
374
  }
553
- async import(path$2) {
375
+ async import(path) {
554
376
  try {
555
- let location = this.getLocation(path$2);
377
+ let location = this.getLocation(path);
556
378
  if (node_os.default.platform() === "win32") location = (0, node_url.pathToFileURL)(location).href;
557
- const module$1 = await import(location);
558
- return module$1?.default ?? module$1;
379
+ const module = await import(location);
380
+ return module?.default ?? module;
559
381
  } catch (error) {
560
382
  console.error(error);
561
383
  return;
562
384
  }
563
385
  }
564
386
  async getPackageJSON() {
565
- const pkgPath = await findUp(["package.json"], { cwd: this.#cwd });
387
+ const pkgPath = empathic_package.up({ cwd: this.#cwd });
566
388
  if (!pkgPath) return;
567
- const json = await require_fs.read(pkgPath);
389
+ const json = await require_write.read(pkgPath);
568
390
  return JSON.parse(json);
569
391
  }
570
392
  getPackageJSONSync() {
571
- const pkgPath = findUpSync(["package.json"], { cwd: this.#cwd });
393
+ const pkgPath = empathic_package.up({ cwd: this.#cwd });
572
394
  if (!pkgPath) return;
573
- const json = require_fs.readSync(pkgPath);
395
+ const json = require_write.readSync(pkgPath);
574
396
  return JSON.parse(json);
575
397
  }
576
- static setVersion(dependency, version$1) {
577
- PackageManager.#cache[dependency] = version$1;
398
+ static setVersion(dependency, version) {
399
+ PackageManager.#cache[dependency] = version;
578
400
  }
579
401
  #match(packageJSON, dependency) {
580
402
  const dependencies = {
@@ -597,21 +419,21 @@ var PackageManager = class PackageManager {
597
419
  if (!packageJSON) return;
598
420
  return this.#match(packageJSON, dependency);
599
421
  }
600
- async isValid(dependency, version$1) {
422
+ async isValid(dependency, version) {
601
423
  const packageVersion = await this.getVersion(dependency);
602
424
  if (!packageVersion) return false;
603
- if (packageVersion === version$1) return true;
425
+ if (packageVersion === version) return true;
604
426
  const semVer = (0, semver.coerce)(packageVersion);
605
427
  if (!semVer) return false;
606
- return (0, semver.satisfies)(semVer, version$1);
428
+ return (0, semver.satisfies)(semVer, version);
607
429
  }
608
- isValidSync(dependency, version$1) {
430
+ isValidSync(dependency, version) {
609
431
  const packageVersion = this.getVersionSync(dependency);
610
432
  if (!packageVersion) return false;
611
- if (packageVersion === version$1) return true;
433
+ if (packageVersion === version) return true;
612
434
  const semVer = (0, semver.coerce)(packageVersion);
613
435
  if (!semVer) return false;
614
- return (0, semver.satisfies)(semVer, version$1);
436
+ return (0, semver.satisfies)(semVer, version);
615
437
  }
616
438
  };
617
439