@kubb/core 1.15.0-canary.20231026T131818 → 1.15.0-canary.20231026T182312

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
@@ -56,6 +56,8 @@ var os__default = /*#__PURE__*/_interopDefault(os);
56
56
  var process__default = /*#__PURE__*/_interopDefault(process);
57
57
  var fs3__default = /*#__PURE__*/_interopDefault(fs3);
58
58
 
59
+ var __defProp = Object.defineProperty;
60
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
59
61
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
60
62
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
61
63
  }) : x)(function(x) {
@@ -63,6 +65,40 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
63
65
  return require.apply(this, arguments);
64
66
  throw Error('Dynamic require of "' + x + '" is not supported');
65
67
  });
68
+ var __publicField = (obj, key, value) => {
69
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
70
+ return value;
71
+ };
72
+ var __accessCheck = (obj, member, msg) => {
73
+ if (!member.has(obj))
74
+ throw TypeError("Cannot " + msg);
75
+ };
76
+ var __privateGet = (obj, member, getter) => {
77
+ __accessCheck(obj, member, "read from private field");
78
+ return getter ? getter.call(obj) : member.get(obj);
79
+ };
80
+ var __privateAdd = (obj, member, value) => {
81
+ if (member.has(obj))
82
+ throw TypeError("Cannot add the same private member more than once");
83
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
84
+ };
85
+ var __privateSet = (obj, member, value, setter) => {
86
+ __accessCheck(obj, member, "write to private field");
87
+ setter ? setter.call(obj, value) : member.set(obj, value);
88
+ return value;
89
+ };
90
+ var __privateWrapper = (obj, member, setter, getter) => ({
91
+ set _(value) {
92
+ __privateSet(obj, member, value, setter);
93
+ },
94
+ get _() {
95
+ return __privateGet(obj, member, getter);
96
+ }
97
+ });
98
+ var __privateMethod = (obj, member, method) => {
99
+ __accessCheck(obj, member, "access private method");
100
+ return method;
101
+ };
66
102
  async function clean(path5) {
67
103
  return fs2.remove(path5);
68
104
  }
@@ -161,7 +197,6 @@ async function read(path5) {
161
197
  return reader(path5);
162
198
  }
163
199
  var URLPath = class {
164
- path;
165
200
  constructor(path5) {
166
201
  this.path = path5;
167
202
  return this;
@@ -512,10 +547,8 @@ async function write(data, path5) {
512
547
  return writer(path5, data.trim());
513
548
  }
514
549
  var TreeNode = class _TreeNode {
515
- data;
516
- parent;
517
- children = [];
518
550
  constructor(data, parent) {
551
+ this.children = [];
519
552
  this.data = data;
520
553
  this.parent = parent;
521
554
  return this;
@@ -600,14 +633,15 @@ var TreeNode = class _TreeNode {
600
633
  };
601
634
 
602
635
  // src/BarrelManager.ts
636
+ var _options;
603
637
  var BarrelManager = class {
604
- #options = {};
605
638
  constructor(options = {}) {
606
- this.#options = options;
639
+ __privateAdd(this, _options, {});
640
+ __privateSet(this, _options, options);
607
641
  return this;
608
642
  }
609
643
  getIndexes(root, extName) {
610
- const { treeNode = {}, isTypeOnly, filter, map, output, includeExt } = this.#options;
644
+ const { treeNode = {}, isTypeOnly, filter, map, output, includeExt } = __privateGet(this, _options);
611
645
  const extMapper = {
612
646
  ".ts": {
613
647
  extensions: /\.ts/,
@@ -676,50 +710,47 @@ var BarrelManager = class {
676
710
  return map ? filteredFiles.map(map) : filteredFiles;
677
711
  }
678
712
  };
713
+ _options = new WeakMap();
679
714
 
680
715
  // src/FileManager.ts
681
- var FileManager = class _FileManager {
682
- #cache = /* @__PURE__ */ new Map();
683
- #task;
684
- #isWriting = false;
685
- /**
686
- * Timeout between writes
687
- */
688
- #timeout = 0;
689
- #queue;
716
+ var _cache, _task, _isWriting, _timeout, _queue, _validate, validate_fn, _add, add_fn, _addOrAppend, addOrAppend_fn;
717
+ var _FileManager = class _FileManager {
690
718
  constructor(options) {
719
+ __privateAdd(this, _validate);
720
+ __privateAdd(this, _add);
721
+ __privateAdd(this, _addOrAppend);
722
+ __privateAdd(this, _cache, /* @__PURE__ */ new Map());
723
+ __privateAdd(this, _task, void 0);
724
+ __privateAdd(this, _isWriting, false);
725
+ /**
726
+ * Timeout between writes
727
+ */
728
+ __privateAdd(this, _timeout, 0);
729
+ __privateAdd(this, _queue, void 0);
691
730
  if (options) {
692
- this.#task = options.task;
693
- this.#queue = options.queue;
694
- this.#timeout = options.timeout || 0;
731
+ __privateSet(this, _task, options.task);
732
+ __privateSet(this, _queue, options.queue);
733
+ __privateSet(this, _timeout, options.timeout || 0);
695
734
  }
696
735
  return this;
697
736
  }
698
737
  get files() {
699
738
  const files = [];
700
- this.#cache.forEach((item) => {
739
+ __privateGet(this, _cache).forEach((item) => {
701
740
  files.push(...item.flat(1));
702
741
  });
703
742
  return files;
704
743
  }
705
744
  get isExecuting() {
706
- return this.#queue?.hasJobs ?? this.#isWriting ?? false;
707
- }
708
- #validate(file) {
709
- if (!file.validate) {
710
- return;
711
- }
712
- if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {
713
- throw new Error(`${file.path} should end with the baseName ${file.baseName}`);
714
- }
745
+ return __privateGet(this, _queue)?.hasJobs ?? __privateGet(this, _isWriting) ?? false;
715
746
  }
716
747
  async add(...files) {
717
748
  const promises = files.map((file) => {
718
- this.#validate(file);
749
+ __privateMethod(this, _validate, validate_fn).call(this, file);
719
750
  if (file.override) {
720
- return this.#add(file);
751
+ return __privateMethod(this, _add, add_fn).call(this, file);
721
752
  }
722
- return this.#addOrAppend(file);
753
+ return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, file);
723
754
  });
724
755
  const resolvedFiles = await Promise.all(promises);
725
756
  if (files.length > 1) {
@@ -727,36 +758,6 @@ var FileManager = class _FileManager {
727
758
  }
728
759
  return resolvedFiles[0];
729
760
  }
730
- async #add(file) {
731
- const controller = new AbortController();
732
- const resolvedFile = { id: crypto2__default.default.randomUUID(), ...file };
733
- this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
734
- if (this.#queue) {
735
- await this.#queue.run(
736
- async () => {
737
- return this.#task?.(resolvedFile);
738
- },
739
- { controller }
740
- );
741
- }
742
- return resolvedFile;
743
- }
744
- async #addOrAppend(file) {
745
- const previousCaches = this.#cache.get(file.path);
746
- const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
747
- if (previousCache) {
748
- this.#cache.delete(previousCache.path);
749
- return this.#add({
750
- ...file,
751
- source: previousCache.source && file.source ? `${previousCache.source}
752
- ${file.source}` : "",
753
- imports: [...previousCache.imports || [], ...file.imports || []],
754
- exports: [...previousCache.exports || [], ...file.exports || []],
755
- env: { ...previousCache.env || {}, ...file.env || {} }
756
- });
757
- }
758
- return this.#add(file);
759
- }
760
761
  async addIndexes({ root, extName = ".ts", meta, options = {} }) {
761
762
  const barrelManager = new BarrelManager(options);
762
763
  const files = barrelManager.getIndexes(root, extName);
@@ -765,7 +766,7 @@ ${file.source}` : "",
765
766
  }
766
767
  return await Promise.all(
767
768
  files.map((file) => {
768
- return this.#addOrAppend({
769
+ return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
769
770
  ...file,
770
771
  meta: meta ? meta : file.meta
771
772
  });
@@ -774,29 +775,29 @@ ${file.source}` : "",
774
775
  }
775
776
  getCacheByUUID(UUID) {
776
777
  let cache;
777
- this.#cache.forEach((files) => {
778
+ __privateGet(this, _cache).forEach((files) => {
778
779
  cache = files.find((item) => item.id === UUID);
779
780
  });
780
781
  return cache;
781
782
  }
782
783
  get(path5) {
783
- return this.#cache.get(path5);
784
+ return __privateGet(this, _cache).get(path5);
784
785
  }
785
786
  remove(path5) {
786
787
  const cacheItem = this.get(path5);
787
788
  if (!cacheItem) {
788
789
  return;
789
790
  }
790
- this.#cache.delete(path5);
791
+ __privateGet(this, _cache).delete(path5);
791
792
  }
792
793
  async write(...params) {
793
- if (!this.#isWriting) {
794
- this.#isWriting = true;
794
+ if (!__privateGet(this, _isWriting)) {
795
+ __privateSet(this, _isWriting, true);
795
796
  const text = await write(...params);
796
- this.#isWriting = false;
797
+ __privateSet(this, _isWriting, false);
797
798
  return text;
798
799
  }
799
- await timeout(this.#timeout);
800
+ await timeout(__privateGet(this, _timeout));
800
801
  return this.write(...params);
801
802
  }
802
803
  async read(...params) {
@@ -856,6 +857,54 @@ ${file.source}` : "",
856
857
  return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
857
858
  }
858
859
  };
860
+ _cache = new WeakMap();
861
+ _task = new WeakMap();
862
+ _isWriting = new WeakMap();
863
+ _timeout = new WeakMap();
864
+ _queue = new WeakMap();
865
+ _validate = new WeakSet();
866
+ validate_fn = function(file) {
867
+ if (!file.validate) {
868
+ return;
869
+ }
870
+ if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {
871
+ throw new Error(`${file.path} should end with the baseName ${file.baseName}`);
872
+ }
873
+ };
874
+ _add = new WeakSet();
875
+ add_fn = async function(file) {
876
+ const controller = new AbortController();
877
+ const resolvedFile = { id: crypto2__default.default.randomUUID(), ...file };
878
+ __privateGet(this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
879
+ if (__privateGet(this, _queue)) {
880
+ await __privateGet(this, _queue).run(
881
+ async () => {
882
+ var _a;
883
+ return (_a = __privateGet(this, _task)) == null ? void 0 : _a.call(this, resolvedFile);
884
+ },
885
+ { controller }
886
+ );
887
+ }
888
+ return resolvedFile;
889
+ };
890
+ _addOrAppend = new WeakSet();
891
+ addOrAppend_fn = async function(file) {
892
+ const previousCaches = __privateGet(this, _cache).get(file.path);
893
+ const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
894
+ if (previousCache) {
895
+ __privateGet(this, _cache).delete(previousCache.path);
896
+ return __privateMethod(this, _add, add_fn).call(this, {
897
+ ...file,
898
+ source: previousCache.source && file.source ? `${previousCache.source}
899
+ ${file.source}` : "",
900
+ imports: [...previousCache.imports || [], ...file.imports || []],
901
+ exports: [...previousCache.exports || [], ...file.exports || []],
902
+ env: { ...previousCache.env || {}, ...file.env || {} }
903
+ });
904
+ }
905
+ return __privateMethod(this, _add, add_fn).call(this, file);
906
+ };
907
+ var FileManager = _FileManager;
859
908
  function combineExports(exports) {
860
909
  const combinedExports = naturalOrderby.orderBy(exports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
861
910
  const name = curr.name;
@@ -951,86 +1000,95 @@ function getEnvSource(source, env) {
951
1000
  return prev;
952
1001
  }, source);
953
1002
  }
1003
+ var _emitter;
954
1004
  var EventEmitter = class {
955
1005
  constructor() {
956
- this.#emitter.setMaxListeners(100);
1006
+ __privateAdd(this, _emitter, new events.EventEmitter());
1007
+ __privateGet(this, _emitter).setMaxListeners(100);
957
1008
  }
958
- #emitter = new events.EventEmitter();
959
1009
  emit(eventName, ...eventArg) {
960
- this.#emitter.emit(eventName, ...eventArg);
1010
+ __privateGet(this, _emitter).emit(eventName, ...eventArg);
961
1011
  }
962
1012
  on(eventName, handler) {
963
- this.#emitter.on(eventName, handler);
1013
+ __privateGet(this, _emitter).on(eventName, handler);
964
1014
  }
965
1015
  off(eventName, handler) {
966
- this.#emitter.off(eventName, handler);
1016
+ __privateGet(this, _emitter).off(eventName, handler);
967
1017
  }
968
1018
  removeAll() {
969
- this.#emitter.removeAllListeners();
1019
+ __privateGet(this, _emitter).removeAllListeners();
970
1020
  }
971
1021
  };
1022
+ _emitter = new WeakMap();
1023
+ var _queue2, _workerCount, _maxParallel, _debug, _work, work_fn;
972
1024
  var Queue = class {
973
- #queue = [];
974
- eventEmitter = new EventEmitter();
975
- #workerCount = 0;
976
- #maxParallel;
977
- #debug = false;
978
1025
  constructor(maxParallel, debug = false) {
979
- this.#maxParallel = maxParallel;
980
- this.#debug = debug;
1026
+ __privateAdd(this, _work);
1027
+ __privateAdd(this, _queue2, []);
1028
+ this.eventEmitter = new EventEmitter();
1029
+ __privateAdd(this, _workerCount, 0);
1030
+ __privateAdd(this, _maxParallel, void 0);
1031
+ __privateAdd(this, _debug, false);
1032
+ __privateSet(this, _maxParallel, maxParallel);
1033
+ __privateSet(this, _debug, debug);
981
1034
  }
982
1035
  run(job, options = { controller: new AbortController(), name: crypto2__default.default.randomUUID(), description: "" }) {
983
1036
  return new Promise((resolve2, reject) => {
984
1037
  const item = { reject, resolve: resolve2, job, name: options.name, description: options.description || options.name };
985
1038
  options.controller?.signal.addEventListener("abort", () => {
986
- this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
1039
+ __privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
987
1040
  reject("Aborted");
988
1041
  });
989
- this.#queue.push(item);
990
- this.#work();
1042
+ __privateGet(this, _queue2).push(item);
1043
+ __privateMethod(this, _work, work_fn).call(this);
991
1044
  });
992
1045
  }
993
1046
  runSync(job, options = { controller: new AbortController(), name: crypto2__default.default.randomUUID(), description: "" }) {
994
1047
  new Promise((resolve2, reject) => {
995
1048
  const item = { reject, resolve: resolve2, job, name: options.name, description: options.description || options.name };
996
1049
  options.controller?.signal.addEventListener("abort", () => {
997
- this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
1050
+ __privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
998
1051
  });
999
- this.#queue.push(item);
1000
- this.#work();
1052
+ __privateGet(this, _queue2).push(item);
1053
+ __privateMethod(this, _work, work_fn).call(this);
1001
1054
  });
1002
1055
  }
1003
1056
  get hasJobs() {
1004
- return this.#workerCount > 0 || this.#queue.length > 0;
1057
+ return __privateGet(this, _workerCount) > 0 || __privateGet(this, _queue2).length > 0;
1005
1058
  }
1006
1059
  get count() {
1007
- return this.#workerCount;
1060
+ return __privateGet(this, _workerCount);
1008
1061
  }
1009
- #work() {
1010
- if (this.#workerCount >= this.#maxParallel) {
1011
- return;
1012
- }
1013
- this.#workerCount++;
1014
- let entry;
1015
- while (entry = this.#queue.shift()) {
1016
- const { reject, resolve: resolve2, job, name, description } = entry;
1017
- if (this.#debug) {
1018
- perf_hooks.performance.mark(name + "_start");
1062
+ };
1063
+ _queue2 = new WeakMap();
1064
+ _workerCount = new WeakMap();
1065
+ _maxParallel = new WeakMap();
1066
+ _debug = new WeakMap();
1067
+ _work = new WeakSet();
1068
+ work_fn = function() {
1069
+ if (__privateGet(this, _workerCount) >= __privateGet(this, _maxParallel)) {
1070
+ return;
1071
+ }
1072
+ __privateWrapper(this, _workerCount)._++;
1073
+ let entry;
1074
+ while (entry = __privateGet(this, _queue2).shift()) {
1075
+ const { reject, resolve: resolve2, job, name, description } = entry;
1076
+ if (__privateGet(this, _debug)) {
1077
+ perf_hooks.performance.mark(name + "_start");
1078
+ }
1079
+ job().then((result) => {
1080
+ this.eventEmitter.emit("jobDone", result);
1081
+ resolve2(result);
1082
+ if (__privateGet(this, _debug)) {
1083
+ perf_hooks.performance.mark(name + "_stop");
1084
+ perf_hooks.performance.measure(description, name + "_start", name + "_stop");
1019
1085
  }
1020
- job().then((result) => {
1021
- this.eventEmitter.emit("jobDone", result);
1022
- resolve2(result);
1023
- if (this.#debug) {
1024
- perf_hooks.performance.mark(name + "_stop");
1025
- perf_hooks.performance.measure(description, name + "_start", name + "_stop");
1026
- }
1027
- }).catch((err) => {
1028
- this.eventEmitter.emit("jobFailed", err);
1029
- reject(err);
1030
- });
1031
- }
1032
- this.#workerCount--;
1086
+ }).catch((err) => {
1087
+ this.eventEmitter.emit("jobFailed", err);
1088
+ reject(err);
1089
+ });
1033
1090
  }
1091
+ __privateWrapper(this, _workerCount)._--;
1034
1092
  };
1035
1093
 
1036
1094
  // src/utils/uniqueName.ts
@@ -1046,8 +1104,6 @@ function setUniqueName(originalName, data) {
1046
1104
 
1047
1105
  // src/errors.ts
1048
1106
  var PluginError = class extends Error {
1049
- pluginManager;
1050
- cause;
1051
1107
  constructor(message, options) {
1052
1108
  super(message, { cause: options.cause });
1053
1109
  this.name = "PluginError";
@@ -1056,10 +1112,9 @@ var PluginError = class extends Error {
1056
1112
  }
1057
1113
  };
1058
1114
  var ParallelPluginError = class extends Error {
1059
- errors = [];
1060
- pluginManager;
1061
1115
  constructor(message, options) {
1062
1116
  super(message, { cause: options.cause });
1117
+ this.errors = [];
1063
1118
  this.name = "ParallelPluginError";
1064
1119
  this.errors = options.errors;
1065
1120
  this.pluginManager = options.pluginManager;
@@ -1080,7 +1135,6 @@ var ParallelPluginError = class extends Error {
1080
1135
  }
1081
1136
  };
1082
1137
  var SummaryError = class extends Error {
1083
- summary;
1084
1138
  constructor(message, options) {
1085
1139
  super(message, { cause: options.cause });
1086
1140
  this.name = "SummaryError";
@@ -1193,10 +1247,11 @@ function hookSeq(promises) {
1193
1247
  }
1194
1248
 
1195
1249
  // src/PromiseManager.ts
1250
+ var _options2;
1196
1251
  var PromiseManager = class {
1197
- #options = {};
1198
1252
  constructor(options = {}) {
1199
- this.#options = options;
1253
+ __privateAdd(this, _options2, {});
1254
+ __privateSet(this, _options2, options);
1200
1255
  return this;
1201
1256
  }
1202
1257
  run(strategy, promises) {
@@ -1206,6 +1261,7 @@ var PromiseManager = class {
1206
1261
  throw new Error(`${strategy} not implemented`);
1207
1262
  }
1208
1263
  };
1264
+ _options2 = new WeakMap();
1209
1265
  function isPromise(result) {
1210
1266
  return !!result && typeof result?.then === "function";
1211
1267
  }
@@ -1214,21 +1270,81 @@ function isPromiseRejectedResult(result) {
1214
1270
  }
1215
1271
 
1216
1272
  // src/PluginManager.ts
1273
+ var _core, _usedPluginNames, _promiseManager, _getSortedPlugins, getSortedPlugins_fn, _addExecutedToCallStack, addExecutedToCallStack_fn, _execute, execute_fn, _executeSync, executeSync_fn, _catcher, catcher_fn, _parse, parse_fn;
1217
1274
  var PluginManager = class {
1218
- plugins;
1219
- fileManager;
1220
- eventEmitter = new EventEmitter();
1221
- queue;
1222
- executed = [];
1223
- logger;
1224
- #core;
1225
- #usedPluginNames = {};
1226
- #promiseManager;
1227
1275
  constructor(config, options) {
1276
+ __privateAdd(this, _getSortedPlugins);
1277
+ __privateAdd(this, _addExecutedToCallStack);
1278
+ /**
1279
+ * Run an async plugin hook and return the result.
1280
+ * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
1281
+ * @param args Arguments passed to the plugin hook.
1282
+ * @param plugin The actual pluginObject to run.
1283
+ */
1284
+ // Implementation signature
1285
+ __privateAdd(this, _execute);
1286
+ /**
1287
+ * Run a sync plugin hook and return the result.
1288
+ * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
1289
+ * @param args Arguments passed to the plugin hook.
1290
+ * @param plugin The acutal plugin
1291
+ * @param replaceContext When passed, the plugin context can be overridden.
1292
+ */
1293
+ __privateAdd(this, _executeSync);
1294
+ __privateAdd(this, _catcher);
1295
+ __privateAdd(this, _parse);
1296
+ this.eventEmitter = new EventEmitter();
1297
+ this.executed = [];
1298
+ __privateAdd(this, _core, void 0);
1299
+ __privateAdd(this, _usedPluginNames, {});
1300
+ __privateAdd(this, _promiseManager, void 0);
1301
+ this.resolvePath = (params) => {
1302
+ if (params.pluginKey) {
1303
+ const paths = this.hookForPluginSync({
1304
+ pluginKey: params.pluginKey,
1305
+ hookName: "resolvePath",
1306
+ parameters: [params.baseName, params.directory, params.options]
1307
+ });
1308
+ if (paths && paths?.length > 1) {
1309
+ throw new Error(
1310
+ `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1311
+
1312
+ Paths: ${JSON.stringify(paths, void 0, 2)}`
1313
+ );
1314
+ }
1315
+ return paths?.at(0);
1316
+ }
1317
+ return this.hookFirstSync({
1318
+ hookName: "resolvePath",
1319
+ parameters: [params.baseName, params.directory, params.options]
1320
+ }).result;
1321
+ };
1322
+ this.resolveName = (params) => {
1323
+ if (params.pluginKey) {
1324
+ const names = this.hookForPluginSync({
1325
+ pluginKey: params.pluginKey,
1326
+ hookName: "resolveName",
1327
+ parameters: [params.name, params.type]
1328
+ });
1329
+ if (names && names?.length > 1) {
1330
+ throw new Error(
1331
+ `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1332
+
1333
+ Names: ${JSON.stringify(names, void 0, 2)}`
1334
+ );
1335
+ }
1336
+ return transformReservedWord(names?.at(0) || params.name);
1337
+ }
1338
+ const name = this.hookFirstSync({
1339
+ hookName: "resolveName",
1340
+ parameters: [params.name, params.type]
1341
+ }).result;
1342
+ return transformReservedWord(name);
1343
+ };
1228
1344
  this.logger = options.logger;
1229
1345
  this.queue = new Queue(100, this.logger.logLevel === LogLevel.debug);
1230
1346
  this.fileManager = new FileManager({ task: options.task, queue: this.queue, timeout: options.writeTimeout });
1231
- this.#promiseManager = new PromiseManager();
1347
+ __privateSet(this, _promiseManager, new PromiseManager());
1232
1348
  const plugins = config.plugins || [];
1233
1349
  const core = definePlugin({
1234
1350
  config,
@@ -1237,57 +1353,14 @@ var PluginManager = class {
1237
1353
  fileManager: this.fileManager,
1238
1354
  resolvePath: this.resolvePath.bind(this),
1239
1355
  resolveName: this.resolveName.bind(this),
1240
- getPlugins: this.#getSortedPlugins.bind(this)
1356
+ getPlugins: __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).bind(this)
1241
1357
  });
1242
- this.#core = this.#parse(core, this, core.api.call(null));
1243
- this.plugins = [this.#core, ...plugins].map((plugin) => {
1244
- return this.#parse(plugin, this, this.#core.api);
1358
+ __privateSet(this, _core, __privateMethod(this, _parse, parse_fn).call(this, core, this, core.api.call(null)));
1359
+ this.plugins = [__privateGet(this, _core), ...plugins].map((plugin) => {
1360
+ return __privateMethod(this, _parse, parse_fn).call(this, plugin, this, __privateGet(this, _core).api);
1245
1361
  });
1246
1362
  return this;
1247
1363
  }
1248
- resolvePath = (params) => {
1249
- if (params.pluginKey) {
1250
- const paths = this.hookForPluginSync({
1251
- pluginKey: params.pluginKey,
1252
- hookName: "resolvePath",
1253
- parameters: [params.baseName, params.directory, params.options]
1254
- });
1255
- if (paths && paths?.length > 1) {
1256
- throw new Error(
1257
- `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1258
-
1259
- Paths: ${JSON.stringify(paths, void 0, 2)}`
1260
- );
1261
- }
1262
- return paths?.at(0);
1263
- }
1264
- return this.hookFirstSync({
1265
- hookName: "resolvePath",
1266
- parameters: [params.baseName, params.directory, params.options]
1267
- }).result;
1268
- };
1269
- resolveName = (params) => {
1270
- if (params.pluginKey) {
1271
- const names = this.hookForPluginSync({
1272
- pluginKey: params.pluginKey,
1273
- hookName: "resolveName",
1274
- parameters: [params.name, params.type]
1275
- });
1276
- if (names && names?.length > 1) {
1277
- throw new Error(
1278
- `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1279
-
1280
- Names: ${JSON.stringify(names, void 0, 2)}`
1281
- );
1282
- }
1283
- return transformReservedWord(names?.at(0) || params.name);
1284
- }
1285
- const name = this.hookFirstSync({
1286
- hookName: "resolveName",
1287
- parameters: [params.name, params.type]
1288
- }).result;
1289
- return transformReservedWord(name);
1290
- };
1291
1364
  on(eventName, handler) {
1292
1365
  this.eventEmitter.on(eventName, handler);
1293
1366
  }
@@ -1301,7 +1374,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1301
1374
  }) {
1302
1375
  const plugins = this.getPluginsByKey(hookName, pluginKey);
1303
1376
  const promises = plugins.map((plugin) => {
1304
- return this.#execute({
1377
+ return __privateMethod(this, _execute, execute_fn).call(this, {
1305
1378
  strategy: "hookFirst",
1306
1379
  hookName,
1307
1380
  parameters,
@@ -1317,7 +1390,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1317
1390
  }) {
1318
1391
  const plugins = this.getPluginsByKey(hookName, pluginKey);
1319
1392
  return plugins.map((plugin) => {
1320
- return this.#executeSync({
1393
+ return __privateMethod(this, _executeSync, executeSync_fn).call(this, {
1321
1394
  strategy: "hookFirst",
1322
1395
  hookName,
1323
1396
  parameters,
@@ -1334,7 +1407,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1334
1407
  skipped
1335
1408
  }) {
1336
1409
  let promise = Promise.resolve(null);
1337
- for (const plugin of this.#getSortedPlugins()) {
1410
+ for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1338
1411
  if (skipped && skipped.has(plugin)) {
1339
1412
  continue;
1340
1413
  }
@@ -1342,7 +1415,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1342
1415
  if (parseResult?.result != null) {
1343
1416
  return parseResult;
1344
1417
  }
1345
- const value = await this.#execute({
1418
+ const value = await __privateMethod(this, _execute, execute_fn).call(this, {
1346
1419
  strategy: "hookFirst",
1347
1420
  hookName,
1348
1421
  parameters,
@@ -1367,12 +1440,12 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1367
1440
  skipped
1368
1441
  }) {
1369
1442
  let parseResult = null;
1370
- for (const plugin of this.#getSortedPlugins()) {
1443
+ for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1371
1444
  if (skipped && skipped.has(plugin)) {
1372
1445
  continue;
1373
1446
  }
1374
1447
  parseResult = {
1375
- result: this.#executeSync({
1448
+ result: __privateMethod(this, _executeSync, executeSync_fn).call(this, {
1376
1449
  strategy: "hookFirst",
1377
1450
  hookName,
1378
1451
  parameters,
@@ -1394,8 +1467,8 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1394
1467
  parameters
1395
1468
  }) {
1396
1469
  const parallelPromises = [];
1397
- for (const plugin of this.#getSortedPlugins()) {
1398
- const promise = this.#execute({ strategy: "hookParallel", hookName, parameters, plugin });
1470
+ for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1471
+ const promise = __privateMethod(this, _execute, execute_fn).call(this, { strategy: "hookParallel", hookName, parameters, plugin });
1399
1472
  if (promise) {
1400
1473
  parallelPromises.push(promise);
1401
1474
  }
@@ -1422,16 +1495,16 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1422
1495
  }) {
1423
1496
  const [argument0, ...rest] = parameters;
1424
1497
  let promise = Promise.resolve(argument0);
1425
- for (const plugin of this.#getSortedPlugins()) {
1498
+ for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1426
1499
  promise = promise.then((arg0) => {
1427
- const value = this.#execute({
1500
+ const value = __privateMethod(this, _execute, execute_fn).call(this, {
1428
1501
  strategy: "hookReduceArg0",
1429
1502
  hookName,
1430
1503
  parameters: [arg0, ...rest],
1431
1504
  plugin
1432
1505
  });
1433
1506
  return value;
1434
- }).then((result) => reduce.call(this.#core.api, argument0, result, plugin));
1507
+ }).then((result) => reduce.call(__privateGet(this, _core).api, argument0, result, plugin));
1435
1508
  }
1436
1509
  return promise;
1437
1510
  }
@@ -1439,28 +1512,15 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1439
1512
  * Chains plugins
1440
1513
  */
1441
1514
  hookSeq({ hookName, parameters }) {
1442
- const promises = this.#getSortedPlugins().map((plugin) => {
1443
- return () => this.#execute({
1515
+ const promises = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
1516
+ return () => __privateMethod(this, _execute, execute_fn).call(this, {
1444
1517
  strategy: "hookSeq",
1445
1518
  hookName,
1446
1519
  parameters,
1447
1520
  plugin
1448
1521
  });
1449
1522
  });
1450
- return this.#promiseManager.run("seq", promises);
1451
- }
1452
- #getSortedPlugins(hookName) {
1453
- const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1454
- if (hookName) {
1455
- if (this.logger.logLevel === "info") {
1456
- const containsHookName = plugins.some((item) => item[hookName]);
1457
- if (!containsHookName) {
1458
- this.logger.warn(`No hook ${hookName} found`);
1459
- }
1460
- }
1461
- return plugins.filter((item) => item[hookName]);
1462
- }
1463
- return plugins;
1523
+ return __privateGet(this, _promiseManager).run("seq", promises);
1464
1524
  }
1465
1525
  getPluginsByKey(hookName, pluginKey) {
1466
1526
  const plugins = [...this.plugins];
@@ -1488,129 +1548,6 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1488
1548
  }
1489
1549
  return pluginByPluginName;
1490
1550
  }
1491
- #addExecutedToCallStack(executer) {
1492
- if (executer) {
1493
- this.eventEmitter.emit("executed", executer);
1494
- this.executed.push(executer);
1495
- }
1496
- }
1497
- /**
1498
- * Run an async plugin hook and return the result.
1499
- * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
1500
- * @param args Arguments passed to the plugin hook.
1501
- * @param plugin The actual pluginObject to run.
1502
- */
1503
- // Implementation signature
1504
- #execute({
1505
- strategy,
1506
- hookName,
1507
- parameters,
1508
- plugin
1509
- }) {
1510
- const hook = plugin[hookName];
1511
- let output;
1512
- if (!hook) {
1513
- return null;
1514
- }
1515
- this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1516
- const task = Promise.resolve().then(() => {
1517
- if (typeof hook === "function") {
1518
- const possiblePromiseResult = hook.apply({ ...this.#core.api, plugin }, parameters);
1519
- if (isPromise(possiblePromiseResult)) {
1520
- return Promise.resolve(possiblePromiseResult);
1521
- }
1522
- return possiblePromiseResult;
1523
- }
1524
- return hook;
1525
- }).then((result) => {
1526
- output = result;
1527
- return result;
1528
- }).catch((e) => {
1529
- this.#catcher(e, plugin, hookName);
1530
- return null;
1531
- }).finally(() => {
1532
- this.#addExecutedToCallStack({
1533
- parameters,
1534
- output,
1535
- strategy,
1536
- hookName,
1537
- plugin
1538
- });
1539
- });
1540
- return task;
1541
- }
1542
- /**
1543
- * Run a sync plugin hook and return the result.
1544
- * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
1545
- * @param args Arguments passed to the plugin hook.
1546
- * @param plugin The acutal plugin
1547
- * @param replaceContext When passed, the plugin context can be overridden.
1548
- */
1549
- #executeSync({
1550
- strategy,
1551
- hookName,
1552
- parameters,
1553
- plugin
1554
- }) {
1555
- const hook = plugin[hookName];
1556
- let output;
1557
- if (!hook) {
1558
- return null;
1559
- }
1560
- this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1561
- try {
1562
- if (typeof hook === "function") {
1563
- const fn = hook.apply({ ...this.#core.api, plugin }, parameters);
1564
- output = fn;
1565
- return fn;
1566
- }
1567
- output = hook;
1568
- return hook;
1569
- } catch (e) {
1570
- this.#catcher(e, plugin, hookName);
1571
- return null;
1572
- } finally {
1573
- this.#addExecutedToCallStack({
1574
- parameters,
1575
- output,
1576
- strategy,
1577
- hookName,
1578
- plugin
1579
- });
1580
- }
1581
- }
1582
- #catcher(e, plugin, hookName) {
1583
- const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
1584
- `;
1585
- const pluginError = new PluginError(text, { cause: e, pluginManager: this });
1586
- this.eventEmitter.emit("error", pluginError);
1587
- throw pluginError;
1588
- }
1589
- #parse(plugin, pluginManager, context) {
1590
- const usedPluginNames = pluginManager.#usedPluginNames;
1591
- setUniqueName(plugin.name, usedPluginNames);
1592
- const key = plugin.key || [plugin.kind, plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
1593
- if (plugin.name !== "core" && usedPluginNames[plugin.name] >= 2) {
1594
- pluginManager.logger.warn("Using multiple of the same plugin is an experimental feature");
1595
- }
1596
- if (!plugin.transform) {
1597
- plugin.transform = function transform(code) {
1598
- return code;
1599
- };
1600
- }
1601
- if (plugin.api && typeof plugin.api === "function") {
1602
- const api = plugin.api.call(context);
1603
- return {
1604
- ...plugin,
1605
- key,
1606
- api
1607
- };
1608
- }
1609
- return {
1610
- ...plugin,
1611
- key
1612
- };
1613
- }
1614
1551
  static getDependedPlugins(plugins, dependedPluginNames) {
1615
1552
  let pluginNames = [];
1616
1553
  if (typeof dependedPluginNames === "string") {
@@ -1631,6 +1568,137 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1631
1568
  return ["validate", "buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
1632
1569
  }
1633
1570
  };
1571
+ _core = new WeakMap();
1572
+ _usedPluginNames = new WeakMap();
1573
+ _promiseManager = new WeakMap();
1574
+ _getSortedPlugins = new WeakSet();
1575
+ getSortedPlugins_fn = function(hookName) {
1576
+ const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1577
+ if (hookName) {
1578
+ if (this.logger.logLevel === "info") {
1579
+ const containsHookName = plugins.some((item) => item[hookName]);
1580
+ if (!containsHookName) {
1581
+ this.logger.warn(`No hook ${hookName} found`);
1582
+ }
1583
+ }
1584
+ return plugins.filter((item) => item[hookName]);
1585
+ }
1586
+ return plugins;
1587
+ };
1588
+ _addExecutedToCallStack = new WeakSet();
1589
+ addExecutedToCallStack_fn = function(executer) {
1590
+ if (executer) {
1591
+ this.eventEmitter.emit("executed", executer);
1592
+ this.executed.push(executer);
1593
+ }
1594
+ };
1595
+ _execute = new WeakSet();
1596
+ execute_fn = function({
1597
+ strategy,
1598
+ hookName,
1599
+ parameters,
1600
+ plugin
1601
+ }) {
1602
+ const hook = plugin[hookName];
1603
+ let output;
1604
+ if (!hook) {
1605
+ return null;
1606
+ }
1607
+ this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1608
+ const task = Promise.resolve().then(() => {
1609
+ if (typeof hook === "function") {
1610
+ const possiblePromiseResult = hook.apply({ ...__privateGet(this, _core).api, plugin }, parameters);
1611
+ if (isPromise(possiblePromiseResult)) {
1612
+ return Promise.resolve(possiblePromiseResult);
1613
+ }
1614
+ return possiblePromiseResult;
1615
+ }
1616
+ return hook;
1617
+ }).then((result) => {
1618
+ output = result;
1619
+ return result;
1620
+ }).catch((e) => {
1621
+ __privateMethod(this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1622
+ return null;
1623
+ }).finally(() => {
1624
+ __privateMethod(this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1625
+ parameters,
1626
+ output,
1627
+ strategy,
1628
+ hookName,
1629
+ plugin
1630
+ });
1631
+ });
1632
+ return task;
1633
+ };
1634
+ _executeSync = new WeakSet();
1635
+ executeSync_fn = function({
1636
+ strategy,
1637
+ hookName,
1638
+ parameters,
1639
+ plugin
1640
+ }) {
1641
+ const hook = plugin[hookName];
1642
+ let output;
1643
+ if (!hook) {
1644
+ return null;
1645
+ }
1646
+ this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1647
+ try {
1648
+ if (typeof hook === "function") {
1649
+ const fn = hook.apply({ ...__privateGet(this, _core).api, plugin }, parameters);
1650
+ output = fn;
1651
+ return fn;
1652
+ }
1653
+ output = hook;
1654
+ return hook;
1655
+ } catch (e) {
1656
+ __privateMethod(this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1657
+ return null;
1658
+ } finally {
1659
+ __privateMethod(this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1660
+ parameters,
1661
+ output,
1662
+ strategy,
1663
+ hookName,
1664
+ plugin
1665
+ });
1666
+ }
1667
+ };
1668
+ _catcher = new WeakSet();
1669
+ catcher_fn = function(e, plugin, hookName) {
1670
+ const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
1671
+ `;
1672
+ const pluginError = new PluginError(text, { cause: e, pluginManager: this });
1673
+ this.eventEmitter.emit("error", pluginError);
1674
+ throw pluginError;
1675
+ };
1676
+ _parse = new WeakSet();
1677
+ parse_fn = function(plugin, pluginManager, context) {
1678
+ const usedPluginNames = __privateGet(pluginManager, _usedPluginNames);
1679
+ setUniqueName(plugin.name, usedPluginNames);
1680
+ const key = plugin.key || [plugin.kind, plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
1681
+ if (plugin.name !== "core" && usedPluginNames[plugin.name] >= 2) {
1682
+ pluginManager.logger.warn("Using multiple of the same plugin is an experimental feature");
1683
+ }
1684
+ if (!plugin.transform) {
1685
+ plugin.transform = function transform(code) {
1686
+ return code;
1687
+ };
1688
+ }
1689
+ if (plugin.api && typeof plugin.api === "function") {
1690
+ const api = plugin.api.call(context);
1691
+ return {
1692
+ ...plugin,
1693
+ key,
1694
+ api
1695
+ };
1696
+ }
1697
+ return {
1698
+ ...plugin,
1699
+ key
1700
+ };
1701
+ };
1634
1702
 
1635
1703
  // src/build.ts
1636
1704
  async function transformReducer(_previousCode, result, _plugin) {
@@ -1745,80 +1813,87 @@ ${code}`);
1745
1813
  }
1746
1814
 
1747
1815
  // src/Generator.ts
1816
+ var _options3, _context;
1748
1817
  var Generator = class {
1749
- #options = {};
1750
- #context = {};
1751
1818
  constructor(options, context) {
1819
+ __privateAdd(this, _options3, {});
1820
+ __privateAdd(this, _context, {});
1752
1821
  if (context) {
1753
- this.#context = context;
1822
+ __privateSet(this, _context, context);
1754
1823
  }
1755
1824
  if (options) {
1756
- this.#options = options;
1825
+ __privateSet(this, _options3, options);
1757
1826
  }
1758
1827
  return this;
1759
1828
  }
1760
1829
  get options() {
1761
- return this.#options;
1830
+ return __privateGet(this, _options3);
1762
1831
  }
1763
1832
  get context() {
1764
- return this.#context;
1833
+ return __privateGet(this, _context);
1765
1834
  }
1766
1835
  set options(options) {
1767
- this.#options = { ...this.#options, ...options };
1836
+ __privateSet(this, _options3, { ...__privateGet(this, _options3), ...options });
1768
1837
  }
1769
1838
  };
1839
+ _options3 = new WeakMap();
1840
+ _context = new WeakMap();
1770
1841
 
1771
1842
  // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
1772
1843
  var Node = class {
1773
- value;
1774
- next;
1775
1844
  constructor(value) {
1845
+ __publicField(this, "value");
1846
+ __publicField(this, "next");
1776
1847
  this.value = value;
1777
1848
  }
1778
1849
  };
1850
+ var _head, _tail, _size;
1779
1851
  var Queue2 = class {
1780
- #head;
1781
- #tail;
1782
- #size;
1783
1852
  constructor() {
1853
+ __privateAdd(this, _head, void 0);
1854
+ __privateAdd(this, _tail, void 0);
1855
+ __privateAdd(this, _size, void 0);
1784
1856
  this.clear();
1785
1857
  }
1786
1858
  enqueue(value) {
1787
1859
  const node = new Node(value);
1788
- if (this.#head) {
1789
- this.#tail.next = node;
1790
- this.#tail = node;
1860
+ if (__privateGet(this, _head)) {
1861
+ __privateGet(this, _tail).next = node;
1862
+ __privateSet(this, _tail, node);
1791
1863
  } else {
1792
- this.#head = node;
1793
- this.#tail = node;
1864
+ __privateSet(this, _head, node);
1865
+ __privateSet(this, _tail, node);
1794
1866
  }
1795
- this.#size++;
1867
+ __privateWrapper(this, _size)._++;
1796
1868
  }
1797
1869
  dequeue() {
1798
- const current = this.#head;
1870
+ const current = __privateGet(this, _head);
1799
1871
  if (!current) {
1800
1872
  return;
1801
1873
  }
1802
- this.#head = this.#head.next;
1803
- this.#size--;
1874
+ __privateSet(this, _head, __privateGet(this, _head).next);
1875
+ __privateWrapper(this, _size)._--;
1804
1876
  return current.value;
1805
1877
  }
1806
1878
  clear() {
1807
- this.#head = void 0;
1808
- this.#tail = void 0;
1809
- this.#size = 0;
1879
+ __privateSet(this, _head, void 0);
1880
+ __privateSet(this, _tail, void 0);
1881
+ __privateSet(this, _size, 0);
1810
1882
  }
1811
1883
  get size() {
1812
- return this.#size;
1884
+ return __privateGet(this, _size);
1813
1885
  }
1814
1886
  *[Symbol.iterator]() {
1815
- let current = this.#head;
1887
+ let current = __privateGet(this, _head);
1816
1888
  while (current) {
1817
1889
  yield current.value;
1818
1890
  current = current.next;
1819
1891
  }
1820
1892
  }
1821
1893
  };
1894
+ _head = new WeakMap();
1895
+ _tail = new WeakMap();
1896
+ _size = new WeakMap();
1822
1897
 
1823
1898
  // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
1824
1899
  function pLimit(concurrency) {
@@ -2034,32 +2109,32 @@ function findUpSync(name, options = {}) {
2034
2109
  const matches = findUpMultipleSync(name, { ...options, limit: 1 });
2035
2110
  return matches[0];
2036
2111
  }
2037
- var PackageManager = class _PackageManager {
2038
- static #cache = {};
2039
- #cwd;
2040
- #SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
2112
+ var _cache2, _cwd, _SLASHES;
2113
+ var _PackageManager = class _PackageManager {
2041
2114
  constructor(workspace) {
2115
+ __privateAdd(this, _cwd, void 0);
2116
+ __privateAdd(this, _SLASHES, /* @__PURE__ */ new Set(["/", "\\"]));
2042
2117
  if (workspace) {
2043
- this.#cwd = workspace;
2118
+ __privateSet(this, _cwd, workspace);
2044
2119
  }
2045
2120
  return this;
2046
2121
  }
2047
2122
  set workspace(workspace) {
2048
- this.#cwd = workspace;
2123
+ __privateSet(this, _cwd, workspace);
2049
2124
  }
2050
2125
  get workspace() {
2051
- return this.#cwd;
2126
+ return __privateGet(this, _cwd);
2052
2127
  }
2053
2128
  normalizeDirectory(directory) {
2054
- if (!this.#SLASHES.has(directory[directory.length - 1])) {
2129
+ if (!__privateGet(this, _SLASHES).has(directory[directory.length - 1])) {
2055
2130
  return `${directory}/`;
2056
2131
  }
2057
2132
  return directory;
2058
2133
  }
2059
2134
  getLocation(path5) {
2060
2135
  let location = path5;
2061
- if (this.#cwd) {
2062
- const require2 = mod__default.default.createRequire(this.normalizeDirectory(this.#cwd));
2136
+ if (__privateGet(this, _cwd)) {
2137
+ const require2 = mod__default.default.createRequire(this.normalizeDirectory(__privateGet(this, _cwd)));
2063
2138
  location = require2.resolve(path5);
2064
2139
  }
2065
2140
  return location;
@@ -2079,7 +2154,7 @@ var PackageManager = class _PackageManager {
2079
2154
  }
2080
2155
  async getPackageJSON() {
2081
2156
  const pkgPath = await findUp(["package.json"], {
2082
- cwd: this.#cwd
2157
+ cwd: __privateGet(this, _cwd)
2083
2158
  });
2084
2159
  if (!pkgPath) {
2085
2160
  return void 0;
@@ -2088,7 +2163,7 @@ var PackageManager = class _PackageManager {
2088
2163
  }
2089
2164
  getPackageJSONSync() {
2090
2165
  const pkgPath = findUpSync(["package.json"], {
2091
- cwd: this.#cwd
2166
+ cwd: __privateGet(this, _cwd)
2092
2167
  });
2093
2168
  if (!pkgPath) {
2094
2169
  return void 0;
@@ -2096,11 +2171,11 @@ var PackageManager = class _PackageManager {
2096
2171
  return __require(pkgPath);
2097
2172
  }
2098
2173
  static setVersion(dependency, version) {
2099
- _PackageManager.#cache[dependency] = version;
2174
+ __privateGet(_PackageManager, _cache2)[dependency] = version;
2100
2175
  }
2101
2176
  async getVersion(dependency) {
2102
- if (_PackageManager.#cache[dependency]) {
2103
- return _PackageManager.#cache[dependency];
2177
+ if (__privateGet(_PackageManager, _cache2)[dependency]) {
2178
+ return __privateGet(_PackageManager, _cache2)[dependency];
2104
2179
  }
2105
2180
  const packageJSON = await this.getPackageJSON();
2106
2181
  if (!packageJSON) {
@@ -2109,8 +2184,8 @@ var PackageManager = class _PackageManager {
2109
2184
  return packageJSON["dependencies"]?.[dependency] || packageJSON["devDependencies"]?.[dependency];
2110
2185
  }
2111
2186
  getVersionSync(dependency) {
2112
- if (_PackageManager.#cache[dependency]) {
2113
- return _PackageManager.#cache[dependency];
2187
+ if (__privateGet(_PackageManager, _cache2)[dependency]) {
2188
+ return __privateGet(_PackageManager, _cache2)[dependency];
2114
2189
  }
2115
2190
  const packageJSON = this.getPackageJSONSync();
2116
2191
  if (!packageJSON) {
@@ -2141,6 +2216,11 @@ var PackageManager = class _PackageManager {
2141
2216
  return semver.satisfies(semVer, version);
2142
2217
  }
2143
2218
  };
2219
+ _cache2 = new WeakMap();
2220
+ _cwd = new WeakMap();
2221
+ _SLASHES = new WeakMap();
2222
+ __privateAdd(_PackageManager, _cache2, {});
2223
+ var PackageManager = _PackageManager;
2144
2224
 
2145
2225
  // src/SchemaGenerator.ts
2146
2226
  var SchemaGenerator = class extends Generator {