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