@kubb/core 3.0.0-alpha.1 → 3.0.0-alpha.10
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/{FileManager-EVJig-LT.d.ts → FileManager-BbUCeEyv.d.cts} +108 -94
- package/dist/{FileManager-DSLZ6ps7.d.cts → FileManager-CpuFz6eH.d.ts} +108 -94
- package/dist/chunk-2EU7DMPM.js +97 -0
- package/dist/chunk-2EU7DMPM.js.map +1 -0
- package/dist/chunk-5E2I6KH4.cjs +1071 -0
- package/dist/chunk-5E2I6KH4.cjs.map +1 -0
- package/dist/{chunk-67C6RBGQ.cjs → chunk-A6PCLWEY.cjs} +5 -5
- package/dist/{chunk-67C6RBGQ.cjs.map → chunk-A6PCLWEY.cjs.map} +1 -1
- package/dist/chunk-DID47EQD.cjs +102 -0
- package/dist/chunk-DID47EQD.cjs.map +1 -0
- package/dist/chunk-HBQM723K.js +1063 -0
- package/dist/chunk-HBQM723K.js.map +1 -0
- package/dist/chunk-L6YLVCKM.js +929 -0
- package/dist/chunk-L6YLVCKM.js.map +1 -0
- package/dist/{chunk-LM2YQC3T.cjs → chunk-M7NLNCSM.cjs} +71 -38
- package/dist/chunk-M7NLNCSM.cjs.map +1 -0
- package/dist/{chunk-3OXCZ5DJ.js → chunk-MU3CBCQT.js} +59 -35
- package/dist/chunk-MU3CBCQT.js.map +1 -0
- package/dist/chunk-NB4JMN75.cjs +1548 -0
- package/dist/chunk-NB4JMN75.cjs.map +1 -0
- package/dist/{chunk-XCPFG6DO.cjs → chunk-SEH6NUCX.cjs} +4 -28
- package/dist/chunk-SEH6NUCX.cjs.map +1 -0
- package/dist/index.cjs +496 -552
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -19
- package/dist/index.d.ts +6 -19
- package/dist/index.js +438 -492
- package/dist/index.js.map +1 -1
- package/dist/{logger-DChjnJMn.d.cts → logger-DvbHXjIO.d.cts} +29 -19
- package/dist/{logger-DChjnJMn.d.ts → logger-DvbHXjIO.d.ts} +29 -19
- package/dist/logger.cjs +4 -5
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +1 -2
- package/dist/logger.d.ts +1 -2
- package/dist/logger.js +2 -4
- package/dist/mocks.cjs +25 -19
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +6 -9
- package/dist/mocks.d.ts +6 -9
- package/dist/mocks.js +21 -16
- package/dist/mocks.js.map +1 -1
- package/dist/prompt-DVQN7JTN.cjs +760 -0
- package/dist/prompt-DVQN7JTN.cjs.map +1 -0
- package/dist/prompt-WQQUN22Z.js +754 -0
- package/dist/prompt-WQQUN22Z.js.map +1 -0
- package/dist/transformers.cjs +198 -42
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.d.cts +1 -3
- package/dist/transformers.d.ts +1 -3
- package/dist/transformers.js +155 -14
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +12 -4
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +31 -3
- package/dist/utils.d.ts +31 -3
- package/dist/utils.js +11 -4
- package/package.json +10 -10
- package/src/BarrelManager.ts +93 -107
- package/src/{Generator.ts → BaseGenerator.ts} +1 -1
- package/src/FileManager.ts +198 -297
- package/src/PackageManager.ts +1 -1
- package/src/PluginManager.ts +152 -101
- package/src/__snapshots__/barrel.json +91 -0
- package/src/__snapshots__/grouped.json +114 -0
- package/src/__snapshots__/ordered.json +62 -0
- package/src/build.ts +86 -171
- package/src/errors.ts +0 -11
- package/src/index.ts +1 -2
- package/src/logger.ts +76 -34
- package/src/plugin.ts +3 -3
- package/src/transformers/index.ts +2 -3
- package/src/transformers/trim.ts +0 -4
- package/src/types.ts +35 -35
- package/src/utils/TreeNode.ts +132 -50
- package/src/utils/executeStrategies.ts +1 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/parser.ts +157 -0
- package/dist/chunk-3OXCZ5DJ.js.map +0 -1
- package/dist/chunk-5JZNFPUP.js +0 -309
- package/dist/chunk-5JZNFPUP.js.map +0 -1
- package/dist/chunk-ADC5UNZ5.cjs +0 -1227
- package/dist/chunk-ADC5UNZ5.cjs.map +0 -1
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-HMLY7DHA.js.map +0 -1
- package/dist/chunk-JKZG2IJR.js +0 -283
- package/dist/chunk-JKZG2IJR.js.map +0 -1
- package/dist/chunk-LM2YQC3T.cjs.map +0 -1
- package/dist/chunk-PZT4CTBV.cjs +0 -299
- package/dist/chunk-PZT4CTBV.cjs.map +0 -1
- package/dist/chunk-SA2GZKXS.js +0 -596
- package/dist/chunk-SA2GZKXS.js.map +0 -1
- package/dist/chunk-XCPFG6DO.cjs.map +0 -1
- package/dist/chunk-YTSNYMHW.cjs +0 -320
- package/dist/chunk-YTSNYMHW.cjs.map +0 -1
- package/schema.json +0 -86
- package/src/utils/getParser.ts +0 -17
package/dist/index.cjs
CHANGED
|
@@ -1,48 +1,37 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
|
+
var _chunkDID47EQDcjs = require('./chunk-DID47EQD.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
7
|
+
var _chunkM7NLNCSMcjs = require('./chunk-M7NLNCSM.cjs');
|
|
6
8
|
|
|
7
|
-
var _chunkLM2YQC3Tcjs = require('./chunk-LM2YQC3T.cjs');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
var _chunkADC5UNZ5cjs = require('./chunk-ADC5UNZ5.cjs');
|
|
12
12
|
|
|
13
|
+
var _chunkNB4JMN75cjs = require('./chunk-NB4JMN75.cjs');
|
|
14
|
+
require('./chunk-A6PCLWEY.cjs');
|
|
15
|
+
require('./chunk-5E2I6KH4.cjs');
|
|
13
16
|
|
|
14
|
-
var _chunkPZT4CTBVcjs = require('./chunk-PZT4CTBV.cjs');
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunkYTSNYMHWcjs = require('./chunk-YTSNYMHW.cjs');
|
|
19
|
-
require('./chunk-67C6RBGQ.cjs');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var _chunkXCPFG6DOcjs = require('./chunk-XCPFG6DO.cjs');
|
|
18
|
+
var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
31
|
-
|
|
21
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
32
22
|
|
|
33
23
|
// src/build.ts
|
|
34
|
-
|
|
24
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
35
25
|
var _fs = require('@kubb/fs');
|
|
36
26
|
|
|
37
27
|
// src/PluginManager.ts
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
40
29
|
|
|
41
30
|
// src/PromiseManager.ts
|
|
42
|
-
|
|
31
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
43
32
|
|
|
44
33
|
// src/utils/executeStrategies.ts
|
|
45
|
-
|
|
34
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
46
35
|
function hookSeq(promises) {
|
|
47
36
|
return promises.filter(Boolean).reduce(
|
|
48
37
|
(promise, func) => {
|
|
@@ -77,11 +66,10 @@ function hookParallel(promises) {
|
|
|
77
66
|
}
|
|
78
67
|
|
|
79
68
|
// src/PromiseManager.ts
|
|
80
|
-
var _options;
|
|
81
69
|
var PromiseManager = class {
|
|
70
|
+
#options = {};
|
|
82
71
|
constructor(options = {}) {
|
|
83
|
-
|
|
84
|
-
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options, options);
|
|
72
|
+
this.#options = options;
|
|
85
73
|
return this;
|
|
86
74
|
}
|
|
87
75
|
run(strategy, promises) {
|
|
@@ -89,7 +77,7 @@ var PromiseManager = class {
|
|
|
89
77
|
return hookSeq(promises);
|
|
90
78
|
}
|
|
91
79
|
if (strategy === "first") {
|
|
92
|
-
return hookFirst(promises,
|
|
80
|
+
return hookFirst(promises, this.#options.nullCheck);
|
|
93
81
|
}
|
|
94
82
|
if (strategy === "parallel") {
|
|
95
83
|
return hookParallel(promises);
|
|
@@ -97,31 +85,24 @@ var PromiseManager = class {
|
|
|
97
85
|
throw new Error(`${strategy} not implemented`);
|
|
98
86
|
}
|
|
99
87
|
};
|
|
100
|
-
_options = new WeakMap();
|
|
101
88
|
function isPromise(result) {
|
|
102
|
-
return !!result && typeof _optionalChain([result, 'optionalAccess',
|
|
89
|
+
return !!result && typeof _optionalChain([result, 'optionalAccess', _ => _.then]) === "function";
|
|
103
90
|
}
|
|
104
91
|
function isPromiseRejectedResult(result) {
|
|
105
92
|
return result.status === "rejected";
|
|
106
93
|
}
|
|
107
94
|
|
|
108
95
|
// src/errors.ts
|
|
109
|
-
|
|
110
|
-
var Warning = class extends Error {
|
|
111
|
-
constructor(message, options) {
|
|
112
|
-
super(message, { cause: _optionalChain([options, 'optionalAccess', _3 => _3.cause]) });
|
|
113
|
-
this.name = "Warning";
|
|
114
|
-
}
|
|
115
|
-
};
|
|
96
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
116
97
|
var ValidationPluginError = class extends Error {
|
|
117
98
|
};
|
|
118
99
|
|
|
119
100
|
// src/plugin.ts
|
|
120
|
-
|
|
121
|
-
var
|
|
101
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
102
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
122
103
|
|
|
123
104
|
// src/utils/cache.ts
|
|
124
|
-
|
|
105
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
125
106
|
function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
126
107
|
return {
|
|
127
108
|
set(id, value) {
|
|
@@ -161,7 +142,7 @@ var pluginCore = createPlugin((options) => {
|
|
|
161
142
|
name: "core",
|
|
162
143
|
options,
|
|
163
144
|
key: ["core"],
|
|
164
|
-
|
|
145
|
+
context() {
|
|
165
146
|
return {
|
|
166
147
|
get config() {
|
|
167
148
|
return options.config;
|
|
@@ -188,8 +169,8 @@ var pluginCore = createPlugin((options) => {
|
|
|
188
169
|
};
|
|
189
170
|
},
|
|
190
171
|
resolvePath(baseName) {
|
|
191
|
-
const root =
|
|
192
|
-
return
|
|
172
|
+
const root = _path2.default.resolve(options.config.root, options.config.output.path);
|
|
173
|
+
return _path2.default.resolve(root, baseName);
|
|
193
174
|
},
|
|
194
175
|
resolveName(name) {
|
|
195
176
|
return name;
|
|
@@ -198,74 +179,25 @@ var pluginCore = createPlugin((options) => {
|
|
|
198
179
|
});
|
|
199
180
|
|
|
200
181
|
// src/PluginManager.ts
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
pluginKey: params.pluginKey,
|
|
214
|
-
hookName: "resolvePath",
|
|
215
|
-
parameters: [params.baseName, params.mode, params.options]
|
|
216
|
-
});
|
|
217
|
-
if (paths && _optionalChain([paths, 'optionalAccess', _4 => _4.length]) > 1) {
|
|
218
|
-
this.logger.emit("debug", [
|
|
219
|
-
`Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
220
|
-
|
|
221
|
-
Paths: ${JSON.stringify(paths, void 0, 2)}
|
|
222
|
-
|
|
223
|
-
Falling back on the first item.
|
|
224
|
-
`
|
|
225
|
-
]);
|
|
226
|
-
}
|
|
227
|
-
return _optionalChain([paths, 'optionalAccess', _5 => _5.at, 'call', _6 => _6(0)]);
|
|
228
|
-
}
|
|
229
|
-
return this.hookFirstSync({
|
|
230
|
-
hookName: "resolvePath",
|
|
231
|
-
parameters: [params.baseName, params.mode, params.options]
|
|
232
|
-
}).result;
|
|
233
|
-
};
|
|
234
|
-
this.resolveName = (params) => {
|
|
235
|
-
if (params.pluginKey) {
|
|
236
|
-
const names = this.hookForPluginSync({
|
|
237
|
-
pluginKey: params.pluginKey,
|
|
238
|
-
hookName: "resolveName",
|
|
239
|
-
parameters: [params.name, params.type]
|
|
240
|
-
});
|
|
241
|
-
if (names && _optionalChain([names, 'optionalAccess', _7 => _7.length]) > 1) {
|
|
242
|
-
this.logger.emit("debug", [
|
|
243
|
-
`Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
244
|
-
|
|
245
|
-
Names: ${JSON.stringify(names, void 0, 2)}
|
|
246
|
-
|
|
247
|
-
Falling back on the first item.
|
|
248
|
-
`
|
|
249
|
-
]);
|
|
250
|
-
}
|
|
251
|
-
return _chunkPZT4CTBVcjs.transformReservedWord.call(void 0, _optionalChain([names, 'optionalAccess', _8 => _8.at, 'call', _9 => _9(0)]) || params.name);
|
|
252
|
-
}
|
|
253
|
-
const name = this.hookFirstSync({
|
|
254
|
-
hookName: "resolveName",
|
|
255
|
-
parameters: [params.name, params.type]
|
|
256
|
-
}).result;
|
|
257
|
-
return _chunkPZT4CTBVcjs.transformReservedWord.call(void 0, name);
|
|
258
|
-
};
|
|
182
|
+
var PluginManager = (_class = class {
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
__init() {this.events = new (0, _chunkM7NLNCSMcjs.EventEmitter)()}
|
|
186
|
+
|
|
187
|
+
__init2() {this.executed = []}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
#core;
|
|
191
|
+
#usedPluginNames = {};
|
|
192
|
+
#promiseManager;
|
|
193
|
+
constructor(config, options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
259
194
|
this.config = config;
|
|
195
|
+
this.options = options;
|
|
260
196
|
this.logger = options.logger;
|
|
261
|
-
this.
|
|
262
|
-
this
|
|
263
|
-
|
|
264
|
-
queue: this.queue
|
|
197
|
+
this.fileManager = new (0, _chunkNB4JMN75cjs.FileManager)();
|
|
198
|
+
this.#promiseManager = new PromiseManager({
|
|
199
|
+
nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _8 => _8.result])
|
|
265
200
|
});
|
|
266
|
-
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _promiseManager, new PromiseManager({
|
|
267
|
-
nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _10 => _10.result])
|
|
268
|
-
}));
|
|
269
201
|
const plugins = config.plugins || [];
|
|
270
202
|
const core = pluginCore({
|
|
271
203
|
config,
|
|
@@ -274,34 +206,89 @@ Falling back on the first item.
|
|
|
274
206
|
fileManager: this.fileManager,
|
|
275
207
|
resolvePath: this.resolvePath.bind(this),
|
|
276
208
|
resolveName: this.resolveName.bind(this),
|
|
277
|
-
getPlugins:
|
|
209
|
+
getPlugins: this.#getSortedPlugins.bind(this)
|
|
278
210
|
});
|
|
279
|
-
|
|
280
|
-
this.plugins = [
|
|
281
|
-
return
|
|
211
|
+
this.#core = this.#parse(core, this, core.context.call(null));
|
|
212
|
+
this.plugins = [this.#core, ...plugins].map((plugin) => {
|
|
213
|
+
return this.#parse(plugin, this, this.#core.context);
|
|
282
214
|
});
|
|
283
215
|
return this;
|
|
284
216
|
}
|
|
285
217
|
getFile({ name, mode, extName, pluginKey, options }) {
|
|
286
|
-
let source = "";
|
|
287
218
|
const baseName = `${name}${extName}`;
|
|
288
219
|
const path4 = this.resolvePath({ baseName, mode, pluginKey, options });
|
|
289
220
|
if (!path4) {
|
|
290
221
|
throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
|
|
291
222
|
}
|
|
292
|
-
try {
|
|
293
|
-
source = _fs.readSync.call(void 0, path4);
|
|
294
|
-
} catch (_e) {
|
|
295
|
-
}
|
|
296
223
|
return {
|
|
297
224
|
path: path4,
|
|
298
225
|
baseName,
|
|
299
226
|
meta: {
|
|
300
227
|
pluginKey
|
|
301
228
|
},
|
|
302
|
-
|
|
229
|
+
sources: []
|
|
303
230
|
};
|
|
304
231
|
}
|
|
232
|
+
__init3() {this.resolvePath = (params) => {
|
|
233
|
+
if (params.pluginKey) {
|
|
234
|
+
const paths = this.hookForPluginSync({
|
|
235
|
+
pluginKey: params.pluginKey,
|
|
236
|
+
hookName: "resolvePath",
|
|
237
|
+
parameters: [params.baseName, params.mode, params.options],
|
|
238
|
+
message: `Resolving path '${params.baseName}'`
|
|
239
|
+
});
|
|
240
|
+
if (paths && _optionalChain([paths, 'optionalAccess', _9 => _9.length]) > 1) {
|
|
241
|
+
this.logger.emit("debug", {
|
|
242
|
+
date: /* @__PURE__ */ new Date(),
|
|
243
|
+
logs: [
|
|
244
|
+
`Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
245
|
+
|
|
246
|
+
Paths: ${JSON.stringify(paths, void 0, 2)}
|
|
247
|
+
|
|
248
|
+
Falling back on the first item.
|
|
249
|
+
`
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return _optionalChain([paths, 'optionalAccess', _10 => _10.at, 'call', _11 => _11(0)]);
|
|
254
|
+
}
|
|
255
|
+
return this.hookFirstSync({
|
|
256
|
+
hookName: "resolvePath",
|
|
257
|
+
parameters: [params.baseName, params.mode, params.options],
|
|
258
|
+
message: `Resolving path '${params.baseName}'`
|
|
259
|
+
}).result;
|
|
260
|
+
}}
|
|
261
|
+
//TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path
|
|
262
|
+
__init4() {this.resolveName = (params) => {
|
|
263
|
+
if (params.pluginKey) {
|
|
264
|
+
const names = this.hookForPluginSync({
|
|
265
|
+
pluginKey: params.pluginKey,
|
|
266
|
+
hookName: "resolveName",
|
|
267
|
+
parameters: [params.name, params.type],
|
|
268
|
+
message: `Resolving name '${params.name}' and type '${params.type}'`
|
|
269
|
+
});
|
|
270
|
+
if (names && _optionalChain([names, 'optionalAccess', _12 => _12.length]) > 1) {
|
|
271
|
+
this.logger.emit("debug", {
|
|
272
|
+
date: /* @__PURE__ */ new Date(),
|
|
273
|
+
logs: [
|
|
274
|
+
`Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
275
|
+
|
|
276
|
+
Names: ${JSON.stringify(names, void 0, 2)}
|
|
277
|
+
|
|
278
|
+
Falling back on the first item.
|
|
279
|
+
`
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return _chunkDID47EQDcjs.transformReservedWord.call(void 0, _optionalChain([names, 'optionalAccess', _13 => _13.at, 'call', _14 => _14(0)]) || params.name);
|
|
284
|
+
}
|
|
285
|
+
const name = this.hookFirstSync({
|
|
286
|
+
hookName: "resolveName",
|
|
287
|
+
parameters: [params.name, params.type],
|
|
288
|
+
message: `Resolving name '${params.name}' and type '${params.type}'`
|
|
289
|
+
}).result;
|
|
290
|
+
return _chunkDID47EQDcjs.transformReservedWord.call(void 0, name);
|
|
291
|
+
}}
|
|
305
292
|
/**
|
|
306
293
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
307
294
|
*/
|
|
@@ -311,21 +298,26 @@ Falling back on the first item.
|
|
|
311
298
|
/**
|
|
312
299
|
* Run a specific hookName for plugin x.
|
|
313
300
|
*/
|
|
314
|
-
hookForPlugin({
|
|
301
|
+
async hookForPlugin({
|
|
315
302
|
pluginKey,
|
|
316
303
|
hookName,
|
|
317
|
-
parameters
|
|
304
|
+
parameters,
|
|
305
|
+
message
|
|
318
306
|
}) {
|
|
319
307
|
const plugins = this.getPluginsByKey(hookName, pluginKey);
|
|
308
|
+
this.logger.emit("progress_start", { id: hookName, size: plugins.length, message: "Running plugins..." });
|
|
320
309
|
const promises = plugins.map((plugin) => {
|
|
321
|
-
return
|
|
310
|
+
return this.#execute({
|
|
322
311
|
strategy: "hookFirst",
|
|
323
312
|
hookName,
|
|
324
313
|
parameters,
|
|
325
|
-
plugin
|
|
314
|
+
plugin,
|
|
315
|
+
message
|
|
326
316
|
});
|
|
327
317
|
}).filter(Boolean);
|
|
328
|
-
|
|
318
|
+
const items = await Promise.all(promises);
|
|
319
|
+
this.logger.emit("progress_stop", { id: hookName });
|
|
320
|
+
return items;
|
|
329
321
|
}
|
|
330
322
|
/**
|
|
331
323
|
* Run a specific hookName for plugin x.
|
|
@@ -333,17 +325,20 @@ Falling back on the first item.
|
|
|
333
325
|
hookForPluginSync({
|
|
334
326
|
pluginKey,
|
|
335
327
|
hookName,
|
|
336
|
-
parameters
|
|
328
|
+
parameters,
|
|
329
|
+
message
|
|
337
330
|
}) {
|
|
338
331
|
const plugins = this.getPluginsByKey(hookName, pluginKey);
|
|
339
|
-
|
|
340
|
-
return
|
|
332
|
+
const result = plugins.map((plugin) => {
|
|
333
|
+
return this.#executeSync({
|
|
341
334
|
strategy: "hookFirst",
|
|
342
335
|
hookName,
|
|
343
336
|
parameters,
|
|
344
|
-
plugin
|
|
337
|
+
plugin,
|
|
338
|
+
message
|
|
345
339
|
});
|
|
346
340
|
}).filter(Boolean);
|
|
341
|
+
return result;
|
|
347
342
|
}
|
|
348
343
|
/**
|
|
349
344
|
* First non-null result stops and will return it's value.
|
|
@@ -351,17 +346,21 @@ Falling back on the first item.
|
|
|
351
346
|
async hookFirst({
|
|
352
347
|
hookName,
|
|
353
348
|
parameters,
|
|
354
|
-
skipped
|
|
349
|
+
skipped,
|
|
350
|
+
message
|
|
355
351
|
}) {
|
|
356
|
-
const
|
|
352
|
+
const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
|
|
357
353
|
return skipped ? skipped.has(plugin) : true;
|
|
358
|
-
})
|
|
354
|
+
});
|
|
355
|
+
this.logger.emit("progress_start", { id: hookName, size: plugins.length });
|
|
356
|
+
const promises = plugins.map((plugin) => {
|
|
359
357
|
return async () => {
|
|
360
|
-
const value = await
|
|
358
|
+
const value = await this.#execute({
|
|
361
359
|
strategy: "hookFirst",
|
|
362
360
|
hookName,
|
|
363
361
|
parameters,
|
|
364
|
-
plugin
|
|
362
|
+
plugin,
|
|
363
|
+
message
|
|
365
364
|
});
|
|
366
365
|
return Promise.resolve({
|
|
367
366
|
plugin,
|
|
@@ -369,7 +368,9 @@ Falling back on the first item.
|
|
|
369
368
|
});
|
|
370
369
|
};
|
|
371
370
|
});
|
|
372
|
-
|
|
371
|
+
const result = await this.#promiseManager.run("first", promises);
|
|
372
|
+
this.logger.emit("progress_stop", { id: hookName });
|
|
373
|
+
return result;
|
|
373
374
|
}
|
|
374
375
|
/**
|
|
375
376
|
* First non-null result stops and will return it's value.
|
|
@@ -377,23 +378,25 @@ Falling back on the first item.
|
|
|
377
378
|
hookFirstSync({
|
|
378
379
|
hookName,
|
|
379
380
|
parameters,
|
|
380
|
-
skipped
|
|
381
|
+
skipped,
|
|
382
|
+
message
|
|
381
383
|
}) {
|
|
382
384
|
let parseResult = null;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
385
|
+
const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
|
|
386
|
+
return skipped ? skipped.has(plugin) : true;
|
|
387
|
+
});
|
|
388
|
+
for (const plugin of plugins) {
|
|
387
389
|
parseResult = {
|
|
388
|
-
result:
|
|
390
|
+
result: this.#executeSync({
|
|
389
391
|
strategy: "hookFirst",
|
|
390
392
|
hookName,
|
|
391
393
|
parameters,
|
|
392
|
-
plugin
|
|
394
|
+
plugin,
|
|
395
|
+
message
|
|
393
396
|
}),
|
|
394
397
|
plugin
|
|
395
398
|
};
|
|
396
|
-
if (_optionalChain([parseResult, 'optionalAccess',
|
|
399
|
+
if (_optionalChain([parseResult, 'optionalAccess', _15 => _15.result]) != null) {
|
|
397
400
|
break;
|
|
398
401
|
}
|
|
399
402
|
}
|
|
@@ -404,23 +407,28 @@ Falling back on the first item.
|
|
|
404
407
|
*/
|
|
405
408
|
async hookParallel({
|
|
406
409
|
hookName,
|
|
407
|
-
parameters
|
|
410
|
+
parameters,
|
|
411
|
+
message
|
|
408
412
|
}) {
|
|
409
|
-
const
|
|
410
|
-
|
|
413
|
+
const plugins = this.#getSortedPlugins(hookName);
|
|
414
|
+
this.logger.emit("progress_start", { id: hookName, size: plugins.length });
|
|
415
|
+
const promises = plugins.map((plugin) => {
|
|
416
|
+
return () => this.#execute({
|
|
411
417
|
strategy: "hookParallel",
|
|
412
418
|
hookName,
|
|
413
419
|
parameters,
|
|
414
|
-
plugin
|
|
420
|
+
plugin,
|
|
421
|
+
message
|
|
415
422
|
});
|
|
416
423
|
});
|
|
417
|
-
const results = await
|
|
424
|
+
const results = await this.#promiseManager.run("parallel", promises);
|
|
418
425
|
results.forEach((result, index) => {
|
|
419
426
|
if (isPromiseRejectedResult(result)) {
|
|
420
|
-
const plugin =
|
|
421
|
-
|
|
427
|
+
const plugin = this.#getSortedPlugins(hookName)[index];
|
|
428
|
+
this.#catcher(result.reason, plugin, hookName);
|
|
422
429
|
}
|
|
423
430
|
});
|
|
431
|
+
this.logger.emit("progress_stop", { id: hookName });
|
|
424
432
|
return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
425
433
|
}
|
|
426
434
|
/**
|
|
@@ -429,60 +437,226 @@ Falling back on the first item.
|
|
|
429
437
|
hookReduceArg0({
|
|
430
438
|
hookName,
|
|
431
439
|
parameters,
|
|
432
|
-
reduce
|
|
440
|
+
reduce,
|
|
441
|
+
message
|
|
433
442
|
}) {
|
|
434
443
|
const [argument0, ...rest] = parameters;
|
|
444
|
+
const plugins = this.#getSortedPlugins(hookName);
|
|
435
445
|
let promise = Promise.resolve(argument0);
|
|
436
|
-
for (const plugin of
|
|
446
|
+
for (const plugin of plugins) {
|
|
437
447
|
promise = promise.then((arg0) => {
|
|
438
|
-
const value =
|
|
448
|
+
const value = this.#execute({
|
|
439
449
|
strategy: "hookReduceArg0",
|
|
440
450
|
hookName,
|
|
441
451
|
parameters: [arg0, ...rest],
|
|
442
|
-
plugin
|
|
452
|
+
plugin,
|
|
453
|
+
message
|
|
443
454
|
});
|
|
444
455
|
return value;
|
|
445
|
-
}).then((result) => reduce.call(
|
|
456
|
+
}).then((result) => reduce.call(this.#core.context, argument0, result, plugin));
|
|
446
457
|
}
|
|
447
458
|
return promise;
|
|
448
459
|
}
|
|
449
460
|
/**
|
|
450
461
|
* Chains plugins
|
|
451
462
|
*/
|
|
452
|
-
async hookSeq({
|
|
453
|
-
|
|
454
|
-
|
|
463
|
+
async hookSeq({
|
|
464
|
+
hookName,
|
|
465
|
+
parameters,
|
|
466
|
+
message
|
|
467
|
+
}) {
|
|
468
|
+
const plugins = this.#getSortedPlugins(hookName);
|
|
469
|
+
this.logger.emit("progress_start", { id: hookName, size: plugins.length });
|
|
470
|
+
const promises = plugins.map((plugin) => {
|
|
471
|
+
return () => this.#execute({
|
|
455
472
|
strategy: "hookSeq",
|
|
456
473
|
hookName,
|
|
457
474
|
parameters,
|
|
458
|
-
plugin
|
|
475
|
+
plugin,
|
|
476
|
+
message
|
|
459
477
|
});
|
|
460
478
|
});
|
|
461
|
-
|
|
479
|
+
await this.#promiseManager.run("seq", promises);
|
|
480
|
+
this.logger.emit("progress_stop", { id: hookName });
|
|
481
|
+
}
|
|
482
|
+
#getSortedPlugins(hookName) {
|
|
483
|
+
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
484
|
+
if (hookName) {
|
|
485
|
+
return plugins.filter((item) => item[hookName]);
|
|
486
|
+
}
|
|
487
|
+
return plugins.map((plugin) => {
|
|
488
|
+
if (plugin.pre) {
|
|
489
|
+
const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName));
|
|
490
|
+
if (!isValid) {
|
|
491
|
+
throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return plugin;
|
|
495
|
+
}).sort((a, b) => {
|
|
496
|
+
if (_optionalChain([b, 'access', _16 => _16.pre, 'optionalAccess', _17 => _17.includes, 'call', _18 => _18(a.name)])) {
|
|
497
|
+
return 1;
|
|
498
|
+
}
|
|
499
|
+
if (_optionalChain([b, 'access', _19 => _19.post, 'optionalAccess', _20 => _20.includes, 'call', _21 => _21(a.name)])) {
|
|
500
|
+
return -1;
|
|
501
|
+
}
|
|
502
|
+
return 0;
|
|
503
|
+
});
|
|
462
504
|
}
|
|
463
505
|
getPluginsByKey(hookName, pluginKey) {
|
|
464
506
|
const plugins = [...this.plugins];
|
|
465
507
|
const [searchPluginName, searchIdentifier] = pluginKey;
|
|
466
508
|
const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
|
|
467
509
|
const [name, identifier] = item.key;
|
|
468
|
-
const identifierCheck = _optionalChain([identifier, 'optionalAccess',
|
|
510
|
+
const identifierCheck = _optionalChain([identifier, 'optionalAccess', _22 => _22.toString, 'call', _23 => _23()]) === _optionalChain([searchIdentifier, 'optionalAccess', _24 => _24.toString, 'call', _25 => _25()]);
|
|
469
511
|
const nameCheck = name === searchPluginName;
|
|
470
512
|
if (searchIdentifier) {
|
|
471
513
|
return identifierCheck && nameCheck;
|
|
472
514
|
}
|
|
473
515
|
return nameCheck;
|
|
474
516
|
});
|
|
475
|
-
if (!_optionalChain([pluginByPluginName, 'optionalAccess',
|
|
517
|
+
if (!_optionalChain([pluginByPluginName, 'optionalAccess', _26 => _26.length])) {
|
|
476
518
|
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
|
|
477
519
|
if (corePlugin) {
|
|
478
|
-
this.logger.emit("debug",
|
|
520
|
+
this.logger.emit("debug", {
|
|
521
|
+
date: /* @__PURE__ */ new Date(),
|
|
522
|
+
logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]
|
|
523
|
+
});
|
|
479
524
|
} else {
|
|
480
|
-
this.logger.emit("debug",
|
|
525
|
+
this.logger.emit("debug", {
|
|
526
|
+
date: /* @__PURE__ */ new Date(),
|
|
527
|
+
logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]
|
|
528
|
+
});
|
|
481
529
|
}
|
|
482
530
|
return corePlugin ? [corePlugin] : [];
|
|
483
531
|
}
|
|
484
532
|
return pluginByPluginName;
|
|
485
533
|
}
|
|
534
|
+
#addExecutedToCallStack(executer) {
|
|
535
|
+
if (executer) {
|
|
536
|
+
this.events.emit("executed", executer);
|
|
537
|
+
this.executed.push(executer);
|
|
538
|
+
this.logger.emit("progressed", { id: executer.hookName, message: `${executer.plugin.name}: ${executer.message}` });
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Run an async plugin hook and return the result.
|
|
543
|
+
* @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
|
|
544
|
+
* @param args Arguments passed to the plugin hook.
|
|
545
|
+
* @param plugin The actual pluginObject to run.
|
|
546
|
+
*/
|
|
547
|
+
// Implementation signature
|
|
548
|
+
#execute({
|
|
549
|
+
strategy,
|
|
550
|
+
hookName,
|
|
551
|
+
parameters,
|
|
552
|
+
plugin,
|
|
553
|
+
message
|
|
554
|
+
}) {
|
|
555
|
+
const hook = plugin[hookName];
|
|
556
|
+
let output;
|
|
557
|
+
if (!hook) {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
this.events.emit("executing", { strategy, hookName, parameters, plugin, message });
|
|
561
|
+
const promise = new Promise((resolve2) => {
|
|
562
|
+
resolve2(void 0);
|
|
563
|
+
});
|
|
564
|
+
const task = promise.then(() => {
|
|
565
|
+
if (typeof hook === "function") {
|
|
566
|
+
const possiblePromiseResult = hook.apply({ ...this.#core.context, plugin }, parameters);
|
|
567
|
+
if (isPromise(possiblePromiseResult)) {
|
|
568
|
+
return Promise.resolve(possiblePromiseResult);
|
|
569
|
+
}
|
|
570
|
+
return possiblePromiseResult;
|
|
571
|
+
}
|
|
572
|
+
return hook;
|
|
573
|
+
}).then((result) => {
|
|
574
|
+
output = result;
|
|
575
|
+
this.#addExecutedToCallStack({
|
|
576
|
+
parameters,
|
|
577
|
+
output,
|
|
578
|
+
strategy,
|
|
579
|
+
hookName,
|
|
580
|
+
plugin,
|
|
581
|
+
message
|
|
582
|
+
});
|
|
583
|
+
return result;
|
|
584
|
+
}).catch((e) => {
|
|
585
|
+
this.#catcher(e, plugin, hookName);
|
|
586
|
+
return null;
|
|
587
|
+
});
|
|
588
|
+
return task;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Run a sync plugin hook and return the result.
|
|
592
|
+
* @param hookName Name of the plugin hook. Must be in `PluginHooks`.
|
|
593
|
+
* @param args Arguments passed to the plugin hook.
|
|
594
|
+
* @param plugin The acutal plugin
|
|
595
|
+
* @param replaceContext When passed, the plugin context can be overridden.
|
|
596
|
+
*/
|
|
597
|
+
#executeSync({
|
|
598
|
+
strategy,
|
|
599
|
+
hookName,
|
|
600
|
+
parameters,
|
|
601
|
+
plugin,
|
|
602
|
+
message
|
|
603
|
+
}) {
|
|
604
|
+
const hook = plugin[hookName];
|
|
605
|
+
let output;
|
|
606
|
+
if (!hook) {
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
this.events.emit("executing", { strategy, hookName, parameters, plugin, message });
|
|
610
|
+
try {
|
|
611
|
+
if (typeof hook === "function") {
|
|
612
|
+
const fn = hook.apply({ ...this.#core.context, plugin }, parameters);
|
|
613
|
+
output = fn;
|
|
614
|
+
this.#addExecutedToCallStack({
|
|
615
|
+
parameters,
|
|
616
|
+
output,
|
|
617
|
+
strategy,
|
|
618
|
+
hookName,
|
|
619
|
+
plugin,
|
|
620
|
+
message
|
|
621
|
+
});
|
|
622
|
+
return fn;
|
|
623
|
+
}
|
|
624
|
+
output = hook;
|
|
625
|
+
this.#addExecutedToCallStack({
|
|
626
|
+
parameters,
|
|
627
|
+
output,
|
|
628
|
+
strategy,
|
|
629
|
+
hookName,
|
|
630
|
+
plugin,
|
|
631
|
+
message
|
|
632
|
+
});
|
|
633
|
+
return hook;
|
|
634
|
+
} catch (e) {
|
|
635
|
+
this.#catcher(e, plugin, hookName);
|
|
636
|
+
return null;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
#catcher(cause, plugin, hookName) {
|
|
640
|
+
const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _27 => _27.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
|
|
641
|
+
this.logger.emit("error", text, cause);
|
|
642
|
+
this.events.emit("error", cause);
|
|
643
|
+
}
|
|
644
|
+
#parse(plugin, pluginManager, context) {
|
|
645
|
+
const usedPluginNames = pluginManager.#usedPluginNames;
|
|
646
|
+
_chunkNB4JMN75cjs.setUniqueName.call(void 0, plugin.name, usedPluginNames);
|
|
647
|
+
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
648
|
+
if (plugin.context && typeof plugin.context === "function") {
|
|
649
|
+
return {
|
|
650
|
+
...plugin,
|
|
651
|
+
key,
|
|
652
|
+
context: plugin.context.call(context)
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
return {
|
|
656
|
+
...plugin,
|
|
657
|
+
key
|
|
658
|
+
};
|
|
659
|
+
}
|
|
486
660
|
static getDependedPlugins(plugins, dependedPluginNames) {
|
|
487
661
|
let pluginNames = [];
|
|
488
662
|
if (typeof dependedPluginNames === "string") {
|
|
@@ -499,161 +673,12 @@ Falling back on the first item.
|
|
|
499
673
|
});
|
|
500
674
|
}
|
|
501
675
|
static get hooks() {
|
|
502
|
-
return ["buildStart", "resolvePath", "resolveName", "
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
_core = new WeakMap();
|
|
506
|
-
_usedPluginNames = new WeakMap();
|
|
507
|
-
_promiseManager = new WeakMap();
|
|
508
|
-
_PluginManager_instances = new WeakSet();
|
|
509
|
-
getSortedPlugins_fn = function(hookName) {
|
|
510
|
-
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
511
|
-
if (hookName) {
|
|
512
|
-
if (this.logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
|
|
513
|
-
const containsHookName = plugins.some((item) => item[hookName]);
|
|
514
|
-
if (!containsHookName) {
|
|
515
|
-
this.logger.emit("warning", `No hook ${hookName} found`);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return plugins.filter((item) => item[hookName]);
|
|
676
|
+
return ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
519
677
|
}
|
|
520
|
-
|
|
521
|
-
if (plugin.pre) {
|
|
522
|
-
const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName));
|
|
523
|
-
if (!isValid) {
|
|
524
|
-
throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return plugin;
|
|
528
|
-
}).sort((a, b) => {
|
|
529
|
-
if (_optionalChain([b, 'access', _19 => _19.pre, 'optionalAccess', _20 => _20.includes, 'call', _21 => _21(a.name)])) {
|
|
530
|
-
return 1;
|
|
531
|
-
}
|
|
532
|
-
if (_optionalChain([b, 'access', _22 => _22.post, 'optionalAccess', _23 => _23.includes, 'call', _24 => _24(a.name)])) {
|
|
533
|
-
return -1;
|
|
534
|
-
}
|
|
535
|
-
return 0;
|
|
536
|
-
});
|
|
537
|
-
};
|
|
538
|
-
addExecutedToCallStack_fn = function(executer) {
|
|
539
|
-
if (executer) {
|
|
540
|
-
this.events.emit("executed", executer);
|
|
541
|
-
this.executed.push(executer);
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
/**
|
|
545
|
-
* Run an async plugin hook and return the result.
|
|
546
|
-
* @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
|
|
547
|
-
* @param args Arguments passed to the plugin hook.
|
|
548
|
-
* @param plugin The actual pluginObject to run.
|
|
549
|
-
*/
|
|
550
|
-
// Implementation signature
|
|
551
|
-
execute_fn = function({
|
|
552
|
-
strategy,
|
|
553
|
-
hookName,
|
|
554
|
-
parameters,
|
|
555
|
-
plugin
|
|
556
|
-
}) {
|
|
557
|
-
const hook = plugin[hookName];
|
|
558
|
-
let output;
|
|
559
|
-
if (!hook) {
|
|
560
|
-
return null;
|
|
561
|
-
}
|
|
562
|
-
this.events.emit("execute", { strategy, hookName, parameters, plugin });
|
|
563
|
-
const task = Promise.resolve().then(() => {
|
|
564
|
-
if (typeof hook === "function") {
|
|
565
|
-
const possiblePromiseResult = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).api, plugin }, parameters);
|
|
566
|
-
if (isPromise(possiblePromiseResult)) {
|
|
567
|
-
return Promise.resolve(possiblePromiseResult);
|
|
568
|
-
}
|
|
569
|
-
return possiblePromiseResult;
|
|
570
|
-
}
|
|
571
|
-
return hook;
|
|
572
|
-
}).then((result) => {
|
|
573
|
-
output = result;
|
|
574
|
-
_chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, addExecutedToCallStack_fn).call(this, {
|
|
575
|
-
parameters,
|
|
576
|
-
output,
|
|
577
|
-
strategy,
|
|
578
|
-
hookName,
|
|
579
|
-
plugin
|
|
580
|
-
});
|
|
581
|
-
return result;
|
|
582
|
-
}).catch((e) => {
|
|
583
|
-
_chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, catcher_fn).call(this, e, plugin, hookName);
|
|
584
|
-
return null;
|
|
585
|
-
});
|
|
586
|
-
return task;
|
|
587
|
-
};
|
|
588
|
-
/**
|
|
589
|
-
* Run a sync plugin hook and return the result.
|
|
590
|
-
* @param hookName Name of the plugin hook. Must be in `PluginHooks`.
|
|
591
|
-
* @param args Arguments passed to the plugin hook.
|
|
592
|
-
* @param plugin The acutal plugin
|
|
593
|
-
* @param replaceContext When passed, the plugin context can be overridden.
|
|
594
|
-
*/
|
|
595
|
-
executeSync_fn = function({
|
|
596
|
-
strategy,
|
|
597
|
-
hookName,
|
|
598
|
-
parameters,
|
|
599
|
-
plugin
|
|
600
|
-
}) {
|
|
601
|
-
const hook = plugin[hookName];
|
|
602
|
-
let output;
|
|
603
|
-
if (!hook) {
|
|
604
|
-
return null;
|
|
605
|
-
}
|
|
606
|
-
this.events.emit("execute", { strategy, hookName, parameters, plugin });
|
|
607
|
-
try {
|
|
608
|
-
if (typeof hook === "function") {
|
|
609
|
-
const fn = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).api, plugin }, parameters);
|
|
610
|
-
output = fn;
|
|
611
|
-
return fn;
|
|
612
|
-
}
|
|
613
|
-
output = hook;
|
|
614
|
-
_chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, addExecutedToCallStack_fn).call(this, {
|
|
615
|
-
parameters,
|
|
616
|
-
output,
|
|
617
|
-
strategy,
|
|
618
|
-
hookName,
|
|
619
|
-
plugin
|
|
620
|
-
});
|
|
621
|
-
return hook;
|
|
622
|
-
} catch (e) {
|
|
623
|
-
_chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, catcher_fn).call(this, e, plugin, hookName);
|
|
624
|
-
return null;
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
catcher_fn = function(cause, plugin, hookName) {
|
|
628
|
-
const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _25 => _25.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
|
|
629
|
-
this.logger.emit("error", text, cause);
|
|
630
|
-
this.events.emit("error", cause);
|
|
631
|
-
};
|
|
632
|
-
parse_fn = function(plugin, pluginManager, context) {
|
|
633
|
-
const usedPluginNames = _chunkXCPFG6DOcjs.__privateGet.call(void 0, pluginManager, _usedPluginNames);
|
|
634
|
-
_chunkYTSNYMHWcjs.setUniqueName.call(void 0, plugin.name, usedPluginNames);
|
|
635
|
-
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
636
|
-
if (!plugin.transform) {
|
|
637
|
-
plugin.transform = function transform(_path, code) {
|
|
638
|
-
return code;
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
if (plugin.api && typeof plugin.api === "function") {
|
|
642
|
-
const api = plugin.api.call(context);
|
|
643
|
-
return {
|
|
644
|
-
...plugin,
|
|
645
|
-
key,
|
|
646
|
-
api
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
return {
|
|
650
|
-
...plugin,
|
|
651
|
-
key
|
|
652
|
-
};
|
|
653
|
-
};
|
|
678
|
+
}, _class);
|
|
654
679
|
|
|
655
680
|
// src/config.ts
|
|
656
|
-
|
|
681
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
657
682
|
function defineConfig(options) {
|
|
658
683
|
return options;
|
|
659
684
|
}
|
|
@@ -662,284 +687,211 @@ function isInputPath(result) {
|
|
|
662
687
|
}
|
|
663
688
|
|
|
664
689
|
// src/build.ts
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}
|
|
690
|
+
|
|
691
|
+
|
|
668
692
|
async function setup(options) {
|
|
669
|
-
const { config, logger =
|
|
670
|
-
let count = 0;
|
|
693
|
+
const { config, logger = _chunkM7NLNCSMcjs.createLogger.call(void 0, ) } = options;
|
|
671
694
|
try {
|
|
672
|
-
if (isInputPath(config) && !new (0,
|
|
695
|
+
if (isInputPath(config) && !new (0, _chunkNB4JMN75cjs.URLPath)(config.input.path).isURL) {
|
|
673
696
|
await _fs.read.call(void 0, config.input.path);
|
|
674
697
|
}
|
|
675
698
|
} catch (e) {
|
|
676
699
|
if (isInputPath(config)) {
|
|
677
|
-
throw new Error(
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
cause: e
|
|
681
|
-
}
|
|
682
|
-
);
|
|
700
|
+
throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${config.input.path}`, {
|
|
701
|
+
cause: e
|
|
702
|
+
});
|
|
683
703
|
}
|
|
684
704
|
}
|
|
685
705
|
if (config.output.clean) {
|
|
686
706
|
await _fs.clean.call(void 0, config.output.path);
|
|
707
|
+
await _fs.clean.call(void 0, _path.join.call(void 0, config.root, ".kubb"));
|
|
687
708
|
}
|
|
688
|
-
|
|
689
|
-
const { path: path4 } = file;
|
|
690
|
-
let source = await _chunkADC5UNZ5cjs.FileManager.getSource(file);
|
|
691
|
-
const { result: loadedResult } = await pluginManager.hookFirst({
|
|
692
|
-
hookName: "load",
|
|
693
|
-
parameters: [path4]
|
|
694
|
-
});
|
|
695
|
-
if (loadedResult && isPromise(loadedResult)) {
|
|
696
|
-
source = await loadedResult;
|
|
697
|
-
}
|
|
698
|
-
if (loadedResult && !isPromise(loadedResult)) {
|
|
699
|
-
source = loadedResult;
|
|
700
|
-
}
|
|
701
|
-
if (source) {
|
|
702
|
-
source = await pluginManager.hookReduceArg0({
|
|
703
|
-
hookName: "transform",
|
|
704
|
-
parameters: [path4, source],
|
|
705
|
-
reduce: transformReducer
|
|
706
|
-
});
|
|
707
|
-
if (config.output.write || config.output.write === void 0) {
|
|
708
|
-
if (_optionalChain([file, 'access', _26 => _26.meta, 'optionalAccess', _27 => _27.pluginKey])) {
|
|
709
|
-
await pluginManager.hookForPlugin({
|
|
710
|
-
pluginKey: _optionalChain([file, 'access', _28 => _28.meta, 'optionalAccess', _29 => _29.pluginKey]),
|
|
711
|
-
hookName: "writeFile",
|
|
712
|
-
parameters: [path4, source]
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
await pluginManager.hookFirst({
|
|
716
|
-
hookName: "writeFile",
|
|
717
|
-
parameters: [path4, source]
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
return {
|
|
722
|
-
...file,
|
|
723
|
-
source: source || ""
|
|
724
|
-
};
|
|
725
|
-
};
|
|
726
|
-
const pluginManager = new PluginManager(config, { logger, task });
|
|
727
|
-
pluginManager.on("execute", (executer) => {
|
|
728
|
-
const { hookName, parameters, plugin } = executer;
|
|
729
|
-
if (hookName === "writeFile") {
|
|
730
|
-
const [code] = parameters;
|
|
731
|
-
logger.emit("debug", [`PluginKey ${_chunkLM2YQC3Tcjs.p.dim(JSON.stringify(plugin.key))}
|
|
732
|
-
with source
|
|
733
|
-
|
|
734
|
-
${code}`]);
|
|
735
|
-
}
|
|
736
|
-
});
|
|
737
|
-
pluginManager.queue.on("add", () => {
|
|
738
|
-
if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
if (count === 0) {
|
|
742
|
-
logger.emit("start", "\u{1F4BE} Writing");
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
pluginManager.queue.on("active", () => {
|
|
746
|
-
if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
if (logger.spinner && pluginManager.queue.size > 0) {
|
|
750
|
-
const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
|
|
751
|
-
logger.spinner.suffixText = _chunkLM2YQC3Tcjs.p.dim(text);
|
|
752
|
-
}
|
|
753
|
-
++count;
|
|
754
|
-
});
|
|
755
|
-
pluginManager.queue.on("completed", () => {
|
|
756
|
-
if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
if (logger.spinner) {
|
|
760
|
-
const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
|
|
761
|
-
logger.spinner.suffixText = _chunkLM2YQC3Tcjs.p.dim(text);
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
pluginManager.on("executed", (executer) => {
|
|
765
|
-
const { hookName, plugin, output, parameters } = executer;
|
|
766
|
-
const logs = [
|
|
767
|
-
`${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} Executing ${hookName}`,
|
|
768
|
-
parameters && `${_chunkLM2YQC3Tcjs.p.bgWhite("Parameters")} ${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
|
|
769
|
-
JSON.stringify(parameters, void 0, 2),
|
|
770
|
-
output && `${_chunkLM2YQC3Tcjs.p.bgWhite("Output")} ${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
|
|
771
|
-
output
|
|
772
|
-
].filter(Boolean);
|
|
773
|
-
logger.emit("debug", logs);
|
|
774
|
-
});
|
|
775
|
-
return pluginManager;
|
|
709
|
+
return new PluginManager(config, { logger });
|
|
776
710
|
}
|
|
777
711
|
async function build(options) {
|
|
778
|
-
const pluginManager = await
|
|
779
|
-
|
|
780
|
-
await pluginManager.hookParallel({
|
|
781
|
-
hookName: "buildStart",
|
|
782
|
-
parameters: [options.config]
|
|
783
|
-
});
|
|
784
|
-
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
785
|
-
if (logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
|
|
786
|
-
logger.emit("end", "\u{1F4BE} Writing completed");
|
|
787
|
-
}
|
|
788
|
-
const files = await Promise.all(
|
|
789
|
-
fileManager.files.map(async (file) => ({
|
|
790
|
-
...file,
|
|
791
|
-
source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
|
|
792
|
-
}))
|
|
793
|
-
);
|
|
712
|
+
const { files, pluginManager, error } = await safeBuild(options);
|
|
713
|
+
if (error) throw error;
|
|
794
714
|
return {
|
|
795
715
|
files,
|
|
796
|
-
pluginManager
|
|
716
|
+
pluginManager,
|
|
717
|
+
error
|
|
797
718
|
};
|
|
798
719
|
}
|
|
799
720
|
async function safeBuild(options) {
|
|
721
|
+
let files = [];
|
|
800
722
|
const pluginManager = await setup(options);
|
|
801
|
-
const { fileManager, logger } = pluginManager;
|
|
802
723
|
try {
|
|
724
|
+
pluginManager.events.on("executing", ({ plugin, message }) => {
|
|
725
|
+
pluginManager.logger.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Executing pluginKey ${_optionalChain([plugin, 'access', _28 => _28.key, 'optionalAccess', _29 => _29.join, 'call', _30 => _30(".")])} | ${message}`] });
|
|
726
|
+
});
|
|
727
|
+
pluginManager.events.on("executed", ({ plugin, message, output }) => {
|
|
728
|
+
pluginManager.logger.emit("debug", {
|
|
729
|
+
date: /* @__PURE__ */ new Date(),
|
|
730
|
+
logs: [`Executed pluginKey ${_optionalChain([plugin, 'access', _31 => _31.key, 'optionalAccess', _32 => _32.join, 'call', _33 => _33(".")])} | ${message} | ${JSON.stringify(output, void 0, 2)}`]
|
|
731
|
+
});
|
|
732
|
+
});
|
|
803
733
|
await pluginManager.hookParallel({
|
|
804
734
|
hookName: "buildStart",
|
|
805
|
-
parameters: [options.config]
|
|
735
|
+
parameters: [options.config],
|
|
736
|
+
message: "buildStart"
|
|
806
737
|
});
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
738
|
+
const root = _path.resolve.call(void 0, options.config.root);
|
|
739
|
+
const rootPath = _path.resolve.call(void 0, root, options.config.output.path, "index.ts");
|
|
740
|
+
const barrelFiles = pluginManager.fileManager.files.filter((file) => {
|
|
741
|
+
return file.sources.some((source) => source.isIndexable);
|
|
742
|
+
});
|
|
743
|
+
const rootFile = {
|
|
744
|
+
path: rootPath,
|
|
745
|
+
baseName: "index.ts",
|
|
746
|
+
exports: barrelFiles.flatMap((file) => {
|
|
747
|
+
return _optionalChain([file, 'access', _34 => _34.sources, 'optionalAccess', _35 => _35.map, 'call', _36 => _36((source) => {
|
|
748
|
+
if (!file.path || !source.isIndexable) {
|
|
749
|
+
return void 0;
|
|
750
|
+
}
|
|
751
|
+
const plugin = pluginManager.plugins.find((item) => {
|
|
752
|
+
const meta = file.meta;
|
|
753
|
+
return item.name === _optionalChain([meta, 'optionalAccess', _37 => _37.pluginKey, 'optionalAccess', _38 => _38[0]]);
|
|
754
|
+
});
|
|
755
|
+
if (_optionalChain([plugin, 'optionalAccess', _39 => _39.output, 'optionalAccess', _40 => _40.exportType]) === false) {
|
|
756
|
+
return void 0;
|
|
757
|
+
}
|
|
758
|
+
if (_chunkNB4JMN75cjs.FileManager.getMode(_optionalChain([plugin, 'optionalAccess', _41 => _41.output, 'optionalAccess', _42 => _42.path])) === "single") {
|
|
759
|
+
return void 0;
|
|
760
|
+
}
|
|
761
|
+
return {
|
|
762
|
+
name: options.config.output.exportType === "barrel" ? void 0 : [source.name],
|
|
763
|
+
path: _fs.getRelativePath.call(void 0, rootPath, file.path),
|
|
764
|
+
isTypeOnly: source.isTypeOnly
|
|
765
|
+
};
|
|
766
|
+
}), 'access', _43 => _43.filter, 'call', _44 => _44(Boolean)]);
|
|
767
|
+
}).filter(Boolean),
|
|
768
|
+
sources: [],
|
|
769
|
+
meta: {}
|
|
770
|
+
};
|
|
771
|
+
if (options.config.output.exportType) {
|
|
772
|
+
await pluginManager.fileManager.add(rootFile);
|
|
773
|
+
}
|
|
774
|
+
files = await _chunkNB4JMN75cjs.processFiles.call(void 0, {
|
|
775
|
+
config: options.config,
|
|
776
|
+
dryRun: !options.config.output.write,
|
|
777
|
+
files: pluginManager.fileManager.files,
|
|
778
|
+
logger: pluginManager.logger
|
|
779
|
+
});
|
|
780
|
+
await pluginManager.hookParallel({ hookName: "buildEnd", message: `Build stopped for ${options.config.name}` });
|
|
781
|
+
pluginManager.fileManager.clear();
|
|
811
782
|
} catch (e) {
|
|
812
|
-
const files2 = await Promise.all(
|
|
813
|
-
fileManager.files.map(async (file) => ({
|
|
814
|
-
...file,
|
|
815
|
-
source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
|
|
816
|
-
}))
|
|
817
|
-
);
|
|
818
783
|
return {
|
|
819
|
-
files:
|
|
784
|
+
files: [],
|
|
820
785
|
pluginManager,
|
|
821
786
|
error: e
|
|
822
787
|
};
|
|
823
788
|
}
|
|
824
|
-
const files = await Promise.all(
|
|
825
|
-
fileManager.files.map(async (file) => ({
|
|
826
|
-
...file,
|
|
827
|
-
source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
|
|
828
|
-
}))
|
|
829
|
-
);
|
|
830
789
|
return {
|
|
831
790
|
files,
|
|
832
791
|
pluginManager
|
|
833
792
|
};
|
|
834
793
|
}
|
|
835
794
|
|
|
836
|
-
// src/
|
|
837
|
-
|
|
838
|
-
var
|
|
839
|
-
|
|
795
|
+
// src/BaseGenerator.ts
|
|
796
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
797
|
+
var BaseGenerator = class {
|
|
798
|
+
#options = {};
|
|
799
|
+
#context = {};
|
|
840
800
|
constructor(options, context) {
|
|
841
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _options2, {});
|
|
842
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _context, {});
|
|
843
801
|
if (context) {
|
|
844
|
-
|
|
802
|
+
this.#context = context;
|
|
845
803
|
}
|
|
846
804
|
if (options) {
|
|
847
|
-
|
|
805
|
+
this.#options = options;
|
|
848
806
|
}
|
|
849
807
|
return this;
|
|
850
808
|
}
|
|
851
809
|
get options() {
|
|
852
|
-
return
|
|
810
|
+
return this.#options;
|
|
853
811
|
}
|
|
854
812
|
get context() {
|
|
855
|
-
return
|
|
813
|
+
return this.#context;
|
|
856
814
|
}
|
|
857
815
|
set options(options) {
|
|
858
|
-
|
|
816
|
+
this.#options = { ...this.#options, ...options };
|
|
859
817
|
}
|
|
860
818
|
};
|
|
861
|
-
_options2 = new WeakMap();
|
|
862
|
-
_context = new WeakMap();
|
|
863
819
|
|
|
864
820
|
// src/PackageManager.ts
|
|
865
|
-
|
|
821
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
866
822
|
var _module = require('module'); var _module2 = _interopRequireDefault(_module);
|
|
867
823
|
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
868
824
|
var _url = require('url');
|
|
869
825
|
|
|
870
826
|
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
871
|
-
|
|
827
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
872
828
|
|
|
873
829
|
|
|
874
830
|
// ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
|
875
|
-
|
|
831
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
876
832
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
877
833
|
|
|
878
834
|
var _fs3 = require('fs'); var _fs4 = _interopRequireDefault(_fs3);
|
|
879
835
|
|
|
880
836
|
|
|
881
837
|
// ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
882
|
-
|
|
838
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
883
839
|
|
|
884
840
|
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
885
|
-
|
|
841
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
886
842
|
|
|
887
843
|
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
888
|
-
|
|
844
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
889
845
|
var Node = class {
|
|
846
|
+
|
|
847
|
+
|
|
890
848
|
constructor(value) {
|
|
891
|
-
_chunkXCPFG6DOcjs.__publicField.call(void 0, this, "value");
|
|
892
|
-
_chunkXCPFG6DOcjs.__publicField.call(void 0, this, "next");
|
|
893
849
|
this.value = value;
|
|
894
850
|
}
|
|
895
851
|
};
|
|
896
|
-
var _head, _tail, _size;
|
|
897
852
|
var Queue = class {
|
|
853
|
+
#head;
|
|
854
|
+
#tail;
|
|
855
|
+
#size;
|
|
898
856
|
constructor() {
|
|
899
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _head);
|
|
900
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _tail);
|
|
901
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _size);
|
|
902
857
|
this.clear();
|
|
903
858
|
}
|
|
904
859
|
enqueue(value) {
|
|
905
860
|
const node = new Node(value);
|
|
906
|
-
if (
|
|
907
|
-
|
|
908
|
-
|
|
861
|
+
if (this.#head) {
|
|
862
|
+
this.#tail.next = node;
|
|
863
|
+
this.#tail = node;
|
|
909
864
|
} else {
|
|
910
|
-
|
|
911
|
-
|
|
865
|
+
this.#head = node;
|
|
866
|
+
this.#tail = node;
|
|
912
867
|
}
|
|
913
|
-
|
|
868
|
+
this.#size++;
|
|
914
869
|
}
|
|
915
870
|
dequeue() {
|
|
916
|
-
const current =
|
|
871
|
+
const current = this.#head;
|
|
917
872
|
if (!current) {
|
|
918
873
|
return;
|
|
919
874
|
}
|
|
920
|
-
|
|
921
|
-
|
|
875
|
+
this.#head = this.#head.next;
|
|
876
|
+
this.#size--;
|
|
922
877
|
return current.value;
|
|
923
878
|
}
|
|
924
879
|
clear() {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
880
|
+
this.#head = void 0;
|
|
881
|
+
this.#tail = void 0;
|
|
882
|
+
this.#size = 0;
|
|
928
883
|
}
|
|
929
884
|
get size() {
|
|
930
|
-
return
|
|
885
|
+
return this.#size;
|
|
931
886
|
}
|
|
932
887
|
*[Symbol.iterator]() {
|
|
933
|
-
let current =
|
|
888
|
+
let current = this.#head;
|
|
934
889
|
while (current) {
|
|
935
890
|
yield current.value;
|
|
936
891
|
current = current.next;
|
|
937
892
|
}
|
|
938
893
|
}
|
|
939
894
|
};
|
|
940
|
-
_head = new WeakMap();
|
|
941
|
-
_tail = new WeakMap();
|
|
942
|
-
_size = new WeakMap();
|
|
943
895
|
|
|
944
896
|
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
945
897
|
function pLimit(concurrency) {
|
|
@@ -954,18 +906,18 @@ function pLimit(concurrency) {
|
|
|
954
906
|
queue.dequeue()();
|
|
955
907
|
}
|
|
956
908
|
};
|
|
957
|
-
const run = async (fn,
|
|
909
|
+
const run = async (fn, resolve2, args) => {
|
|
958
910
|
activeCount++;
|
|
959
911
|
const result = (async () => fn(...args))();
|
|
960
|
-
|
|
912
|
+
resolve2(result);
|
|
961
913
|
try {
|
|
962
914
|
await result;
|
|
963
915
|
} catch (e2) {
|
|
964
916
|
}
|
|
965
917
|
next();
|
|
966
918
|
};
|
|
967
|
-
const enqueue = (fn,
|
|
968
|
-
queue.enqueue(run.bind(void 0, fn,
|
|
919
|
+
const enqueue = (fn, resolve2, args) => {
|
|
920
|
+
queue.enqueue(run.bind(void 0, fn, resolve2, args));
|
|
969
921
|
(async () => {
|
|
970
922
|
await Promise.resolve();
|
|
971
923
|
if (activeCount < concurrency && queue.size > 0) {
|
|
@@ -973,8 +925,8 @@ function pLimit(concurrency) {
|
|
|
973
925
|
}
|
|
974
926
|
})();
|
|
975
927
|
};
|
|
976
|
-
const generator = (fn, ...args) => new Promise((
|
|
977
|
-
enqueue(fn,
|
|
928
|
+
const generator = (fn, ...args) => new Promise((resolve2) => {
|
|
929
|
+
enqueue(fn, resolve2, args);
|
|
978
930
|
});
|
|
979
931
|
Object.defineProperties(generator, {
|
|
980
932
|
activeCount: {
|
|
@@ -1049,7 +1001,7 @@ async function locatePath(paths, {
|
|
|
1049
1001
|
const statFunction = allowSymlinks ? _fs3.promises.stat : _fs3.promises.lstat;
|
|
1050
1002
|
return pLocate(paths, async (path_) => {
|
|
1051
1003
|
try {
|
|
1052
|
-
const stat = await statFunction(
|
|
1004
|
+
const stat = await statFunction(_path2.default.resolve(cwd, path_));
|
|
1053
1005
|
return matchType(type, stat);
|
|
1054
1006
|
} catch (e3) {
|
|
1055
1007
|
return false;
|
|
@@ -1066,7 +1018,7 @@ function locatePathSync(paths, {
|
|
|
1066
1018
|
const statFunction = allowSymlinks ? _fs4.default.statSync : _fs4.default.lstatSync;
|
|
1067
1019
|
for (const path_ of paths) {
|
|
1068
1020
|
try {
|
|
1069
|
-
const stat = statFunction(
|
|
1021
|
+
const stat = statFunction(_path2.default.resolve(cwd, path_), {
|
|
1070
1022
|
throwIfNoEntry: false
|
|
1071
1023
|
});
|
|
1072
1024
|
if (!stat) {
|
|
@@ -1081,22 +1033,22 @@ function locatePathSync(paths, {
|
|
|
1081
1033
|
}
|
|
1082
1034
|
|
|
1083
1035
|
// ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
|
|
1084
|
-
|
|
1036
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
1085
1037
|
|
|
1086
1038
|
function toPath2(urlOrPath) {
|
|
1087
1039
|
return urlOrPath instanceof URL ? _url.fileURLToPath.call(void 0, urlOrPath) : urlOrPath;
|
|
1088
1040
|
}
|
|
1089
1041
|
|
|
1090
1042
|
// ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
|
|
1091
|
-
|
|
1043
|
+
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
1092
1044
|
|
|
1093
1045
|
|
|
1094
1046
|
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
1095
1047
|
var findUpStop = Symbol("findUpStop");
|
|
1096
1048
|
async function findUpMultiple(name, options = {}) {
|
|
1097
|
-
let directory =
|
|
1098
|
-
const { root } =
|
|
1099
|
-
const stopAt =
|
|
1049
|
+
let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
|
|
1050
|
+
const { root } = _path2.default.parse(directory);
|
|
1051
|
+
const stopAt = _path2.default.resolve(directory, toPath2(_nullishCoalesce(options.stopAt, () => ( root))));
|
|
1100
1052
|
const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
|
|
1101
1053
|
const paths = [name].flat();
|
|
1102
1054
|
const runMatcher = async (locateOptions) => {
|
|
@@ -1116,19 +1068,19 @@ async function findUpMultiple(name, options = {}) {
|
|
|
1116
1068
|
break;
|
|
1117
1069
|
}
|
|
1118
1070
|
if (foundPath) {
|
|
1119
|
-
matches.push(
|
|
1071
|
+
matches.push(_path2.default.resolve(directory, foundPath));
|
|
1120
1072
|
}
|
|
1121
1073
|
if (directory === stopAt || matches.length >= limit) {
|
|
1122
1074
|
break;
|
|
1123
1075
|
}
|
|
1124
|
-
directory =
|
|
1076
|
+
directory = _path2.default.dirname(directory);
|
|
1125
1077
|
}
|
|
1126
1078
|
return matches;
|
|
1127
1079
|
}
|
|
1128
1080
|
function findUpMultipleSync(name, options = {}) {
|
|
1129
|
-
let directory =
|
|
1130
|
-
const { root } =
|
|
1131
|
-
const stopAt =
|
|
1081
|
+
let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
|
|
1082
|
+
const { root } = _path2.default.parse(directory);
|
|
1083
|
+
const stopAt = _path2.default.resolve(directory, _nullishCoalesce(toPath2(options.stopAt), () => ( root)));
|
|
1132
1084
|
const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
|
|
1133
1085
|
const paths = [name].flat();
|
|
1134
1086
|
const runMatcher = (locateOptions) => {
|
|
@@ -1148,12 +1100,12 @@ function findUpMultipleSync(name, options = {}) {
|
|
|
1148
1100
|
break;
|
|
1149
1101
|
}
|
|
1150
1102
|
if (foundPath) {
|
|
1151
|
-
matches.push(
|
|
1103
|
+
matches.push(_path2.default.resolve(directory, foundPath));
|
|
1152
1104
|
}
|
|
1153
1105
|
if (directory === stopAt || matches.length >= limit) {
|
|
1154
1106
|
break;
|
|
1155
1107
|
}
|
|
1156
|
-
directory =
|
|
1108
|
+
directory = _path2.default.dirname(directory);
|
|
1157
1109
|
}
|
|
1158
1110
|
return matches;
|
|
1159
1111
|
}
|
|
@@ -1169,33 +1121,32 @@ function findUpSync(name, options = {}) {
|
|
|
1169
1121
|
// src/PackageManager.ts
|
|
1170
1122
|
var _semver = require('semver');
|
|
1171
1123
|
|
|
1172
|
-
var
|
|
1173
|
-
|
|
1124
|
+
var PackageManager = class _PackageManager {
|
|
1125
|
+
static #cache = {};
|
|
1126
|
+
#cwd;
|
|
1127
|
+
#SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
|
|
1174
1128
|
constructor(workspace) {
|
|
1175
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _PackageManager_instances);
|
|
1176
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _cwd);
|
|
1177
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _SLASHES, /* @__PURE__ */ new Set(["/", "\\"]));
|
|
1178
1129
|
if (workspace) {
|
|
1179
|
-
|
|
1130
|
+
this.#cwd = workspace;
|
|
1180
1131
|
}
|
|
1181
1132
|
return this;
|
|
1182
1133
|
}
|
|
1183
1134
|
set workspace(workspace) {
|
|
1184
|
-
|
|
1135
|
+
this.#cwd = workspace;
|
|
1185
1136
|
}
|
|
1186
1137
|
get workspace() {
|
|
1187
|
-
return
|
|
1138
|
+
return this.#cwd;
|
|
1188
1139
|
}
|
|
1189
1140
|
normalizeDirectory(directory) {
|
|
1190
|
-
if (!
|
|
1141
|
+
if (!this.#SLASHES.has(directory[directory.length - 1])) {
|
|
1191
1142
|
return `${directory}/`;
|
|
1192
1143
|
}
|
|
1193
1144
|
return directory;
|
|
1194
1145
|
}
|
|
1195
1146
|
getLocation(path4) {
|
|
1196
1147
|
let location = path4;
|
|
1197
|
-
if (
|
|
1198
|
-
const require2 = _module2.default.createRequire(this.normalizeDirectory(
|
|
1148
|
+
if (this.#cwd) {
|
|
1149
|
+
const require2 = _module2.default.createRequire(this.normalizeDirectory(this.#cwd));
|
|
1199
1150
|
location = require2.resolve(path4);
|
|
1200
1151
|
}
|
|
1201
1152
|
return location;
|
|
@@ -1207,15 +1158,15 @@ var _PackageManager = class _PackageManager {
|
|
|
1207
1158
|
location = _url.pathToFileURL.call(void 0, location).href;
|
|
1208
1159
|
}
|
|
1209
1160
|
const module = await Promise.resolve().then(() => _interopRequireWildcard(require(location)));
|
|
1210
|
-
return _nullishCoalesce(_optionalChain([module, 'optionalAccess',
|
|
1161
|
+
return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _45 => _45.default]), () => ( module));
|
|
1211
1162
|
} catch (e) {
|
|
1212
|
-
console.
|
|
1163
|
+
console.error(e);
|
|
1213
1164
|
return void 0;
|
|
1214
1165
|
}
|
|
1215
1166
|
}
|
|
1216
1167
|
async getPackageJSON() {
|
|
1217
1168
|
const pkgPath = await findUp(["package.json"], {
|
|
1218
|
-
cwd:
|
|
1169
|
+
cwd: this.#cwd
|
|
1219
1170
|
});
|
|
1220
1171
|
if (!pkgPath) {
|
|
1221
1172
|
return void 0;
|
|
@@ -1225,7 +1176,7 @@ var _PackageManager = class _PackageManager {
|
|
|
1225
1176
|
}
|
|
1226
1177
|
getPackageJSONSync() {
|
|
1227
1178
|
const pkgPath = findUpSync(["package.json"], {
|
|
1228
|
-
cwd:
|
|
1179
|
+
cwd: this.#cwd
|
|
1229
1180
|
});
|
|
1230
1181
|
if (!pkgPath) {
|
|
1231
1182
|
return void 0;
|
|
@@ -1234,27 +1185,38 @@ var _PackageManager = class _PackageManager {
|
|
|
1234
1185
|
return JSON.parse(json);
|
|
1235
1186
|
}
|
|
1236
1187
|
static setVersion(dependency, version) {
|
|
1237
|
-
|
|
1188
|
+
_PackageManager.#cache[dependency] = version;
|
|
1189
|
+
}
|
|
1190
|
+
#match(packageJSON, dependency) {
|
|
1191
|
+
const dependencies = {
|
|
1192
|
+
...packageJSON["dependencies"] || {},
|
|
1193
|
+
...packageJSON["devDependencies"] || {}
|
|
1194
|
+
};
|
|
1195
|
+
if (typeof dependency === "string" && dependencies[dependency]) {
|
|
1196
|
+
return dependencies[dependency];
|
|
1197
|
+
}
|
|
1198
|
+
const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency));
|
|
1199
|
+
return matchedDependency ? dependencies[matchedDependency] : void 0;
|
|
1238
1200
|
}
|
|
1239
1201
|
async getVersion(dependency) {
|
|
1240
|
-
if (typeof dependency === "string" &&
|
|
1241
|
-
return
|
|
1202
|
+
if (typeof dependency === "string" && _PackageManager.#cache[dependency]) {
|
|
1203
|
+
return _PackageManager.#cache[dependency];
|
|
1242
1204
|
}
|
|
1243
1205
|
const packageJSON = await this.getPackageJSON();
|
|
1244
1206
|
if (!packageJSON) {
|
|
1245
1207
|
return void 0;
|
|
1246
1208
|
}
|
|
1247
|
-
return
|
|
1209
|
+
return this.#match(packageJSON, dependency);
|
|
1248
1210
|
}
|
|
1249
1211
|
getVersionSync(dependency) {
|
|
1250
|
-
if (typeof dependency === "string" &&
|
|
1251
|
-
return
|
|
1212
|
+
if (typeof dependency === "string" && _PackageManager.#cache[dependency]) {
|
|
1213
|
+
return _PackageManager.#cache[dependency];
|
|
1252
1214
|
}
|
|
1253
1215
|
const packageJSON = this.getPackageJSONSync();
|
|
1254
1216
|
if (!packageJSON) {
|
|
1255
1217
|
return void 0;
|
|
1256
1218
|
}
|
|
1257
|
-
return
|
|
1219
|
+
return this.#match(packageJSON, dependency);
|
|
1258
1220
|
}
|
|
1259
1221
|
async isValid(dependency, version) {
|
|
1260
1222
|
const packageVersion = await this.getVersion(dependency);
|
|
@@ -1282,24 +1244,6 @@ var _PackageManager = class _PackageManager {
|
|
|
1282
1244
|
return _semver.satisfies.call(void 0, semVer, version);
|
|
1283
1245
|
}
|
|
1284
1246
|
};
|
|
1285
|
-
_cache = new WeakMap();
|
|
1286
|
-
_cwd = new WeakMap();
|
|
1287
|
-
_SLASHES = new WeakMap();
|
|
1288
|
-
_PackageManager_instances = new WeakSet();
|
|
1289
|
-
match_fn = function(packageJSON, dependency) {
|
|
1290
|
-
const dependencies = {
|
|
1291
|
-
...packageJSON["dependencies"] || {},
|
|
1292
|
-
...packageJSON["devDependencies"] || {}
|
|
1293
|
-
};
|
|
1294
|
-
if (typeof dependency === "string" && dependencies[dependency]) {
|
|
1295
|
-
return dependencies[dependency];
|
|
1296
|
-
}
|
|
1297
|
-
const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency));
|
|
1298
|
-
return matchedDependency ? dependencies[matchedDependency] : void 0;
|
|
1299
|
-
};
|
|
1300
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, _PackageManager, _cache, {});
|
|
1301
|
-
var PackageManager = _PackageManager;
|
|
1302
|
-
|
|
1303
1247
|
|
|
1304
1248
|
|
|
1305
1249
|
|
|
@@ -1312,5 +1256,5 @@ var PackageManager = _PackageManager;
|
|
|
1312
1256
|
|
|
1313
1257
|
|
|
1314
1258
|
|
|
1315
|
-
exports.
|
|
1259
|
+
exports.BaseGenerator = BaseGenerator; exports.FileManager = _chunkNB4JMN75cjs.FileManager; exports.PackageManager = PackageManager; exports.PluginManager = PluginManager; exports.PromiseManager = PromiseManager; exports.build = build; exports.createPlugin = createPlugin; exports.default = build; exports.defineConfig = defineConfig; exports.isInputPath = isInputPath; exports.safeBuild = safeBuild;
|
|
1316
1260
|
//# sourceMappingURL=index.cjs.map
|