rolldown 0.10.2 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/bin/cli.js +1 -1
  2. package/dist/cjs/cli.cjs +772 -0
  3. package/dist/cjs/index.cjs +26 -0
  4. package/dist/cjs/parallel-plugin-worker.cjs +32 -0
  5. package/dist/{parallel-plugin.cjs → cjs/parallel-plugin.cjs} +2 -3
  6. package/dist/esm/cli.mjs +773 -0
  7. package/dist/esm/index.mjs +24 -0
  8. package/dist/esm/parallel-plugin-worker.mjs +33 -0
  9. package/dist/esm/parallel-plugin.mjs +9 -0
  10. package/dist/shared/chunk-WMSF1LUG.cjs +37 -0
  11. package/dist/shared/consola_36c0034f-ED9jtJgC.mjs +942 -0
  12. package/dist/shared/consola_36c0034f-RVbq7gBJ.cjs +945 -0
  13. package/dist/shared/prompt-Q6AgPcFh.cjs +859 -0
  14. package/dist/shared/prompt-uoOfg_gh.mjs +860 -0
  15. package/dist/shared/rolldown-7z0huS4W.mjs +49 -0
  16. package/dist/shared/rolldown-binding.wasi.cjs +26 -13
  17. package/dist/shared/rolldown-pt4wPK1i.cjs +48 -0
  18. package/dist/shared/utils_index-0Q22WhZL.cjs +5331 -0
  19. package/dist/shared/utils_index-Wfcc8MjH.mjs +5361 -0
  20. package/dist/shared/wasi-worker-browser.mjs +6 -7
  21. package/dist/shared/wasi-worker.mjs +5 -2
  22. package/package.json +52 -37
  23. package/dist/chunks/prompt.cjs +0 -443
  24. package/dist/chunks/prompt.cjs.map +0 -1
  25. package/dist/chunks/prompt.mjs +0 -436
  26. package/dist/chunks/prompt.mjs.map +0 -1
  27. package/dist/cli.cjs +0 -1961
  28. package/dist/cli.cjs.map +0 -1
  29. package/dist/cli.d.cts +0 -2
  30. package/dist/cli.d.mts +0 -2
  31. package/dist/cli.d.ts +0 -2
  32. package/dist/cli.mjs +0 -1939
  33. package/dist/cli.mjs.map +0 -1
  34. package/dist/index.cjs +0 -26
  35. package/dist/index.cjs.map +0 -1
  36. package/dist/index.d.cts +0 -66
  37. package/dist/index.d.mts +0 -66
  38. package/dist/index.d.ts +0 -66
  39. package/dist/index.mjs +0 -21
  40. package/dist/index.mjs.map +0 -1
  41. package/dist/parallel-plugin-worker.cjs +0 -34
  42. package/dist/parallel-plugin-worker.cjs.map +0 -1
  43. package/dist/parallel-plugin-worker.d.cts +0 -2
  44. package/dist/parallel-plugin-worker.d.mts +0 -2
  45. package/dist/parallel-plugin-worker.d.ts +0 -2
  46. package/dist/parallel-plugin-worker.mjs +0 -32
  47. package/dist/parallel-plugin-worker.mjs.map +0 -1
  48. package/dist/parallel-plugin.cjs.map +0 -1
  49. package/dist/parallel-plugin.d.cts +0 -12
  50. package/dist/parallel-plugin.d.mts +0 -12
  51. package/dist/parallel-plugin.d.ts +0 -12
  52. package/dist/parallel-plugin.mjs +0 -6
  53. package/dist/parallel-plugin.mjs.map +0 -1
  54. package/dist/shared/rolldown.1ea1dc1e.d.cts +0 -1160
  55. package/dist/shared/rolldown.1ea1dc1e.d.mts +0 -1160
  56. package/dist/shared/rolldown.1ea1dc1e.d.ts +0 -1160
  57. package/dist/shared/rolldown.4d4592d7.cjs +0 -348
  58. package/dist/shared/rolldown.4d4592d7.cjs.map +0 -1
  59. package/dist/shared/rolldown.65028ebe.cjs +0 -547
  60. package/dist/shared/rolldown.65028ebe.cjs.map +0 -1
  61. package/dist/shared/rolldown.7d1ce9fc.mjs +0 -546
  62. package/dist/shared/rolldown.7d1ce9fc.mjs.map +0 -1
  63. package/dist/shared/rolldown.b914368a.mjs +0 -340
  64. package/dist/shared/rolldown.b914368a.mjs.map +0 -1
@@ -0,0 +1,772 @@
1
+ const { __commonJSMin, __export, __toESM } = require("../shared/chunk-WMSF1LUG.cjs");
2
+ const { arraify } = require("../shared/utils_index-0Q22WhZL.cjs");
3
+ const { rolldown } = require("../shared/rolldown-pt4wPK1i.cjs");
4
+ const { colors, consola, createConsola } = require("../shared/consola_36c0034f-RVbq7gBJ.cjs");
5
+ const { pathToFileURL } = __toESM(require("node:url"));
6
+ const { default: nodePath } = __toESM(require("node:path"));
7
+ const { default: process$1, env } = __toESM(require("node:process"));
8
+ require("node:util");
9
+ require("node:tty");
10
+ const { performance } = __toESM(require("node:perf_hooks"));
11
+ const tty = __toESM(require("tty"));
12
+
13
+ // ../../node_modules/.pnpm/mri@1.2.0/node_modules/mri/lib/index.js
14
+ var require_lib_index = __commonJSMin((exports, module) => {
15
+ function toArr$1(any) {
16
+ return any == null ? [] : Array.isArray(any) ? any : [any];
17
+ }
18
+ function toVal$1(out, key, val, opts) {
19
+ var x, old = out[key], nxt = ! ! ~opts.string.indexOf(key) ? val == null || val === true ? '' : String(val) : typeof val === 'boolean' ? val : ! ! ~opts.boolean.indexOf(key) ? val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val), ! !val) : (x = +val,x * 0 === 0) ? x : val;
20
+ (out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
21
+ }
22
+ module.exports = function(args, opts) {
23
+ args = args || [];
24
+ opts = opts || {};
25
+ var k, arr, arg, name, val, out = {
26
+ _:[]
27
+ };
28
+ var i = 0, j = 0, idx = 0, len = args.length;
29
+ const alibi = opts.alias !== void 0;
30
+ const strict = opts.unknown !== void 0;
31
+ const defaults = opts.default !== void 0;
32
+ opts.alias = opts.alias || {};
33
+ (opts.string = toArr$1(opts.string));
34
+ (opts.boolean = toArr$1(opts.boolean));
35
+ if (alibi) {
36
+ for (k in opts.alias) {
37
+ arr = opts.alias[k] = toArr$1(opts.alias[k]);
38
+ for (i = 0; i < arr.length; i++) {
39
+ (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
40
+ }
41
+ }
42
+ }
43
+ for (i = opts.boolean.length; i-- > 0; ) {
44
+ arr = opts.alias[opts.boolean[i]] || [];
45
+ for (j = arr.length; j-- > 0; ) opts.boolean.push(arr[j]);
46
+ }
47
+ for (i = opts.string.length; i-- > 0; ) {
48
+ arr = opts.alias[opts.string[i]] || [];
49
+ for (j = arr.length; j-- > 0; ) opts.string.push(arr[j]);
50
+ }
51
+ if (defaults) {
52
+ for (k in opts.default) {
53
+ name = typeof opts.default[k];
54
+ arr = opts.alias[k] = opts.alias[k] || [];
55
+ if (opts[name] !== void 0) {
56
+ opts[name].push(k);
57
+ for (i = 0; i < arr.length; i++) {
58
+ opts[name].push(arr[i]);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ const keys = strict ? Object.keys(opts.alias) : [];
64
+ for (i = 0; i < len; i++) {
65
+ arg = args[i];
66
+ if (arg === '--') {
67
+ out._ = out._.concat(args.slice( ++i));
68
+ break;
69
+ }
70
+ for (j = 0; j < arg.length; j++) {
71
+ if (arg.charCodeAt(j) !== 45) break;
72
+
73
+ }
74
+ if (j === 0) {
75
+ out._.push(arg);
76
+ } else if (arg.substring(j, j + 3) === 'no-') {
77
+ name = arg.substring(j + 3);
78
+ if (strict && ! ~keys.indexOf(name)) {
79
+ return opts.unknown(arg);
80
+ }
81
+ (out[name] = false);
82
+ } else {
83
+ for (idx = j + 1; idx < arg.length; idx++) {
84
+ if (arg.charCodeAt(idx) === 61) break;
85
+
86
+ }
87
+ name = arg.substring(j, idx);
88
+ val = arg.substring( ++idx) || i + 1 === len || ('' + args[i + 1]).charCodeAt(0) === 45 || args[ ++i];
89
+ arr = j === 2 ? [name] : name;
90
+ for (idx = 0; idx < arr.length; idx++) {
91
+ name = arr[idx];
92
+ if (strict && ! ~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
93
+
94
+ toVal$1(out, name, idx + 1 < arr.length || val, opts);
95
+ }
96
+ }
97
+ }
98
+ if (defaults) {
99
+ for (k in opts.default) {
100
+ if (out[k] === void 0) {
101
+ (out[k] = opts.default[k]);
102
+ }
103
+ }
104
+ }
105
+ if (alibi) {
106
+ for (k in out) {
107
+ arr = opts.alias[k] || [];
108
+ while(arr.length > 0) {
109
+ (out[arr.shift()] = out[k]);
110
+ }
111
+ }
112
+ }
113
+ return out;
114
+ };
115
+ });
116
+
117
+ // ../../node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs
118
+ function toArray(val) {
119
+ if (Array.isArray(val)) {
120
+ return val;
121
+ }
122
+ return val === void 0 ? [] : [val];
123
+ }
124
+ function formatLineColumns(lines, linePrefix='') {
125
+ const maxLengh = [];
126
+ for (const line of lines) {
127
+ for (const [i,element] of line.entries()) {
128
+ maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
129
+ }
130
+ }
131
+ return lines.map(l => l.map((c, i) => linePrefix + c[i === 0 ? 'padStart' : 'padEnd'](maxLengh[i])).join(' ')).join('\n');
132
+ }
133
+ function resolveValue(input) {
134
+ return typeof input === 'function' ? input() : input;
135
+ }
136
+ class CLIError extends Error {
137
+ constructor(message, code){
138
+ super(message);
139
+ this.code = code;
140
+ this.name = 'CLIError';
141
+ }
142
+ }
143
+ const NUMBER_CHAR_RE = /\d/;
144
+ const STR_SPLITTERS = ['-', '_', '/', '.'];
145
+ function isUppercase(char='') {
146
+ if (NUMBER_CHAR_RE.test(char)) {
147
+ return void 0;
148
+ }
149
+ return char !== char.toLowerCase();
150
+ }
151
+ function splitByCase(str, separators) {
152
+ const splitters = separators ?? STR_SPLITTERS;
153
+ const parts = [];
154
+ if ( !str || typeof str !== 'string') {
155
+ return parts;
156
+ }
157
+ let buff = '';
158
+ let previousUpper;
159
+ let previousSplitter;
160
+ for (const char of str) {
161
+ const isSplitter = splitters.includes(char);
162
+ if (isSplitter === true) {
163
+ parts.push(buff);
164
+ buff = '';
165
+ previousUpper = void 0;
166
+ continue;
167
+ }
168
+ const isUpper = isUppercase(char);
169
+ if (previousSplitter === false) {
170
+ if (previousUpper === false && isUpper === true) {
171
+ parts.push(buff);
172
+ buff = char;
173
+ previousUpper = isUpper;
174
+ continue;
175
+ }
176
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
177
+ const lastChar = buff.at( -1);
178
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
179
+ buff = lastChar + char;
180
+ previousUpper = isUpper;
181
+ continue;
182
+ }
183
+ }
184
+ buff += char;
185
+ previousUpper = isUpper;
186
+ previousSplitter = isSplitter;
187
+ }
188
+ parts.push(buff);
189
+ return parts;
190
+ }
191
+ function upperFirst(str) {
192
+ return str ? str[0].toUpperCase() + str.slice(1) : '';
193
+ }
194
+ function lowerFirst(str) {
195
+ return str ? str[0].toLowerCase() + str.slice(1) : '';
196
+ }
197
+ function pascalCase(str, opts) {
198
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map(p => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join('') : '';
199
+ }
200
+ function camelCase(str, opts) {
201
+ return lowerFirst(pascalCase(str || '', opts));
202
+ }
203
+ function kebabCase(str, joiner) {
204
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map(p => p.toLowerCase()).join(joiner ?? '-') : '';
205
+ }
206
+ function toArr(any) {
207
+ return any == void 0 ? [] : Array.isArray(any) ? any : [any];
208
+ }
209
+ function toVal(out, key, val, opts) {
210
+ let x;
211
+ const old = out[key];
212
+ const nxt = ~opts.string.indexOf(key) ? val == void 0 || val === true ? '' : String(val) : typeof val === 'boolean' ? val : ~opts.boolean.indexOf(key) ? val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val), ! !val) : (x = +val,x * 0 === 0) ? x : val;
213
+ (out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
214
+ }
215
+ function parseRawArgs(args=[], opts={}) {
216
+ let k;
217
+ let arr;
218
+ let arg;
219
+ let name;
220
+ let val;
221
+ const out = {
222
+ _:[]
223
+ };
224
+ let i = 0;
225
+ let j = 0;
226
+ let idx = 0;
227
+ const len = args.length;
228
+ const alibi = opts.alias !== void 0;
229
+ const strict = opts.unknown !== void 0;
230
+ const defaults = opts.default !== void 0;
231
+ opts.alias = opts.alias || {};
232
+ (opts.string = toArr(opts.string));
233
+ (opts.boolean = toArr(opts.boolean));
234
+ if (alibi) {
235
+ for (k in opts.alias) {
236
+ arr = opts.alias[k] = toArr(opts.alias[k]);
237
+ for (i = 0; i < arr.length; i++) {
238
+ (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
239
+ }
240
+ }
241
+ }
242
+ for (i = opts.boolean.length; i-- > 0; ) {
243
+ arr = opts.alias[opts.boolean[i]] || [];
244
+ for (j = arr.length; j-- > 0; ) {
245
+ opts.boolean.push(arr[j]);
246
+ }
247
+ }
248
+ for (i = opts.string.length; i-- > 0; ) {
249
+ arr = opts.alias[opts.string[i]] || [];
250
+ for (j = arr.length; j-- > 0; ) {
251
+ opts.string.push(arr[j]);
252
+ }
253
+ }
254
+ if (defaults) {
255
+ for (k in opts.default) {
256
+ name = typeof opts.default[k];
257
+ arr = opts.alias[k] = opts.alias[k] || [];
258
+ if (opts[name] !== void 0) {
259
+ opts[name].push(k);
260
+ for (i = 0; i < arr.length; i++) {
261
+ opts[name].push(arr[i]);
262
+ }
263
+ }
264
+ }
265
+ }
266
+ const keys = strict ? Object.keys(opts.alias) : [];
267
+ for (i = 0; i < len; i++) {
268
+ arg = args[i];
269
+ if (arg === '--') {
270
+ out._ = out._.concat(args.slice( ++i));
271
+ break;
272
+ }
273
+ for (j = 0; j < arg.length; j++) {
274
+ if (arg.charCodeAt(j) !== 45) {
275
+ break;
276
+ }
277
+ }
278
+ if (j === 0) {
279
+ out._.push(arg);
280
+ } else if (arg.substring(j, j + 3) === 'no-') {
281
+ name = arg.slice(Math.max(0, j + 3));
282
+ if (strict && ! ~keys.indexOf(name)) {
283
+ return opts.unknown(arg);
284
+ }
285
+ (out[name] = false);
286
+ } else {
287
+ for (idx = j + 1; idx < arg.length; idx++) {
288
+ if (arg.charCodeAt(idx) === 61) {
289
+ break;
290
+ }
291
+ }
292
+ name = arg.substring(j, idx);
293
+ val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ('' + args[i + 1]).charCodeAt(0) === 45 || args[ ++i];
294
+ arr = j === 2 ? [name] : name;
295
+ for (idx = 0; idx < arr.length; idx++) {
296
+ name = arr[idx];
297
+ if (strict && ! ~keys.indexOf(name)) {
298
+ return opts.unknown('-'.repeat(j) + name);
299
+ }
300
+ toVal(out, name, idx + 1 < arr.length || val, opts);
301
+ }
302
+ }
303
+ }
304
+ if (defaults) {
305
+ for (k in opts.default) {
306
+ if (out[k] === void 0) {
307
+ (out[k] = opts.default[k]);
308
+ }
309
+ }
310
+ }
311
+ if (alibi) {
312
+ for (k in out) {
313
+ arr = opts.alias[k] || [];
314
+ while(arr.length > 0) {
315
+ (out[arr.shift()] = out[k]);
316
+ }
317
+ }
318
+ }
319
+ return out;
320
+ }
321
+ function parseArgs$1(rawArgs, argsDef) {
322
+ const parseOptions = {
323
+ boolean:[],
324
+ string:[],
325
+ mixed:[],
326
+ alias:{},
327
+ default:{}
328
+ };
329
+ const args = resolveArgs(argsDef);
330
+ for (const arg of args) {
331
+ if (arg.type === 'positional') {
332
+ continue;
333
+ }
334
+ if (arg.type === 'string') {
335
+ parseOptions.string.push(arg.name);
336
+ } else if (arg.type === 'boolean') {
337
+ parseOptions.boolean.push(arg.name);
338
+ }
339
+ if (arg.default !== void 0) {
340
+ parseOptions.default[arg.name] = arg.default;
341
+ }
342
+ if (arg.alias) {
343
+ parseOptions.alias[arg.name] = arg.alias;
344
+ }
345
+ }
346
+ const parsed = parseRawArgs(rawArgs, parseOptions);
347
+ const [...positionalArguments] = parsed._;
348
+ const parsedArgsProxy = new Proxy(parsed, {
349
+ get(target, prop){
350
+ return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
351
+ }
352
+ });
353
+ for (const [,arg] of args.entries()) {
354
+ if (arg.type === 'positional') {
355
+ const nextPositionalArgument = positionalArguments.shift();
356
+ if (nextPositionalArgument !== void 0) {
357
+ parsedArgsProxy[arg.name] = nextPositionalArgument;
358
+ } else if (arg.default === void 0 && arg.required !== false) {
359
+ throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, 'EARG');
360
+ } else {
361
+ parsedArgsProxy[arg.name] = arg.default;
362
+ }
363
+ } else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
364
+ throw new CLIError(`Missing required argument: --${arg.name}`, 'EARG');
365
+ }
366
+ }
367
+ return parsedArgsProxy;
368
+ }
369
+ function resolveArgs(argsDef) {
370
+ const args = [];
371
+ for (const [name,argDef] of Object.entries(argsDef || {})) {
372
+ args.push({
373
+ ...argDef,
374
+ name,
375
+ alias:toArray(argDef.alias)
376
+ });
377
+ }
378
+ return args;
379
+ }
380
+ function defineCommand(def) {
381
+ return def;
382
+ }
383
+ async function runCommand(cmd, opts) {
384
+ const cmdArgs = await resolveValue(cmd.args || {});
385
+ const parsedArgs = parseArgs$1(opts.rawArgs, cmdArgs);
386
+ const context = {
387
+ rawArgs:opts.rawArgs,
388
+ args:parsedArgs,
389
+ data:opts.data,
390
+ cmd
391
+ };
392
+ if (typeof cmd.setup === 'function') {
393
+ await cmd.setup(context);
394
+ }
395
+ let result;
396
+ try{
397
+ const subCommands = await resolveValue(cmd.subCommands);
398
+ if (subCommands && Object.keys(subCommands).length > 0) {
399
+ const subCommandArgIndex = opts.rawArgs.findIndex(arg => !arg.startsWith('-'));
400
+ const subCommandName = opts.rawArgs[subCommandArgIndex];
401
+ if (subCommandName) {
402
+ if ( !subCommands[subCommandName]) {
403
+ throw new CLIError(`Unknown command \`${subCommandName}\``, 'E_UNKNOWN_COMMAND');
404
+ }
405
+ const subCommand = await resolveValue(subCommands[subCommandName]);
406
+ if (subCommand) {
407
+ await runCommand(subCommand, {
408
+ rawArgs:opts.rawArgs.slice(subCommandArgIndex + 1)
409
+ });
410
+ }
411
+ } else if ( !cmd.run) {
412
+ throw new CLIError(`No command specified.`, 'E_NO_COMMAND');
413
+ }
414
+ }
415
+ if (typeof cmd.run === 'function') {
416
+ result = await cmd.run(context);
417
+ }
418
+ }finally{
419
+ if (typeof cmd.cleanup === 'function') {
420
+ await cmd.cleanup(context);
421
+ }
422
+ } return {
423
+ result
424
+ };
425
+ }
426
+ async function resolveSubCommand(cmd, rawArgs, parent) {
427
+ const subCommands = await resolveValue(cmd.subCommands);
428
+ if (subCommands && Object.keys(subCommands).length > 0) {
429
+ const subCommandArgIndex = rawArgs.findIndex(arg => !arg.startsWith('-'));
430
+ const subCommandName = rawArgs[subCommandArgIndex];
431
+ const subCommand = await resolveValue(subCommands[subCommandName]);
432
+ if (subCommand) {
433
+ return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
434
+ }
435
+ }
436
+ return [cmd, parent];
437
+ }
438
+ async function showUsage(cmd, parent) {
439
+ try{
440
+ consola.log(await renderUsage(cmd, parent) + '\n');
441
+ }catch(error){
442
+ consola.error(error);
443
+ }}
444
+ async function renderUsage(cmd, parent) {
445
+ const cmdMeta = await resolveValue(cmd.meta || {});
446
+ const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
447
+ const parentMeta = await resolveValue(parent?.meta || {});
448
+ const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ''}` + (cmdMeta.name || process.argv[1]);
449
+ const argLines = [];
450
+ const posLines = [];
451
+ const commandsLines = [];
452
+ const usageLine = [];
453
+ for (const arg of cmdArgs) {
454
+ if (arg.type === 'positional') {
455
+ const name = arg.name.toUpperCase();
456
+ const isRequired = arg.required !== false && arg.default === void 0;
457
+ const defaultHint = arg.default ? `="${arg.default}"` : '';
458
+ posLines.push(['`' + name + defaultHint + '`', arg.description || '', arg.valueHint ? `<${arg.valueHint}>` : '']);
459
+ usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
460
+ } else {
461
+ const isRequired = arg.required === true && arg.default === void 0;
462
+ const argStr = (arg.type === 'boolean' && arg.default === true ? [...(arg.alias || []).map(a => `--no-${a}`), `--no-${arg.name}`].join(', ') : [...(arg.alias || []).map(a => `-${a}`), `--${arg.name}`].join(', ')) + (arg.type === 'string' && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ''}"`}` : '');
463
+ argLines.push(['`' + argStr + (isRequired ? ' (required)' : '') + '`', arg.description || '']);
464
+ if (isRequired) {
465
+ usageLine.push(argStr);
466
+ }
467
+ }
468
+ }
469
+ if (cmd.subCommands) {
470
+ const commandNames = [];
471
+ const subCommands = await resolveValue(cmd.subCommands);
472
+ for (const [name,sub] of Object.entries(subCommands)) {
473
+ const subCmd = await resolveValue(sub);
474
+ const meta = await resolveValue(subCmd?.meta);
475
+ commandsLines.push([`\`${name}\``, meta?.description || '']);
476
+ commandNames.push(name);
477
+ }
478
+ usageLine.push(commandNames.join('|'));
479
+ }
480
+ const usageLines = [];
481
+ const version$1 = cmdMeta.version || parentMeta.version;
482
+ usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version$1 ? ` v${version$1}` : '')})`), '');
483
+ const hasOptions = argLines.length > 0 || posLines.length > 0;
484
+ usageLines.push(`${colors.underline(colors.bold('USAGE'))} \`${commandName}${hasOptions ? ' [OPTIONS]' : ''} ${usageLine.join(' ')}\``, '');
485
+ if (posLines.length > 0) {
486
+ usageLines.push(colors.underline(colors.bold('ARGUMENTS')), '');
487
+ usageLines.push(formatLineColumns(posLines, ' '));
488
+ usageLines.push('');
489
+ }
490
+ if (argLines.length > 0) {
491
+ usageLines.push(colors.underline(colors.bold('OPTIONS')), '');
492
+ usageLines.push(formatLineColumns(argLines, ' '));
493
+ usageLines.push('');
494
+ }
495
+ if (commandsLines.length > 0) {
496
+ usageLines.push(colors.underline(colors.bold('COMMANDS')), '');
497
+ usageLines.push(formatLineColumns(commandsLines, ' '));
498
+ usageLines.push('', `Use \`${commandName} <command> --help\` for more information about a command.`);
499
+ }
500
+ return usageLines.filter(l => typeof l === 'string').join('\n');
501
+ }
502
+ async function runMain(cmd, opts={}) {
503
+ const rawArgs = opts.rawArgs || process.argv.slice(2);
504
+ const showUsage$1 = opts.showUsage || showUsage;
505
+ try{
506
+ if (rawArgs.includes('--help') || rawArgs.includes('-h')) {
507
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
508
+ process.exit(0);
509
+ } else if (rawArgs.length === 1 && rawArgs[0] === '--version') {
510
+ const meta = typeof cmd.meta === 'function' ? await cmd.meta() : await cmd.meta;
511
+ if ( !meta?.version) {
512
+ throw new CLIError('No version specified', 'E_NO_VERSION');
513
+ }
514
+ consola.log(meta.version);
515
+ } else {
516
+ await runCommand(cmd, {
517
+ rawArgs
518
+ });
519
+ }
520
+ }catch(error){
521
+ const isCLIError = error instanceof CLIError;
522
+ if ( !isCLIError) {
523
+ consola.error(error, '\n');
524
+ }
525
+ if (isCLIError) {
526
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
527
+ }
528
+ consola.error(error.message);
529
+ process.exit(1);
530
+ }}
531
+
532
+ // src/cli/utils.ts
533
+ const logger = createConsola({
534
+ formatOptions:{
535
+ date:false
536
+ }
537
+ });
538
+ async function ensureConfig(configPath) {
539
+ if ( !isSupportedFormat(configPath)) {
540
+ throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(',')}\` but got \`${nodePath.extname(configPath)}\``);
541
+ }
542
+ const fileUrl = pathToFileURL(configPath).toString();
543
+ const configExports = await import(fileUrl);
544
+ return configExports.default;
545
+ }
546
+ const SUPPORTED_CONFIG_FORMATS = ['.js', '.mjs', '.cjs'];
547
+ function isSupportedFormat(configPath) {
548
+ const ext = nodePath.extname(configPath);
549
+ return SUPPORTED_CONFIG_FORMATS.includes(ext);
550
+ }
551
+
552
+ // ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
553
+ const {env:env$1={}, argv=[], platform=''} = typeof process === 'undefined' ? {} : process;
554
+ const isDisabled = 'NO_COLOR'in env$1 || argv.includes('--no-color');
555
+ const isForced = 'FORCE_COLOR'in env$1 || argv.includes('--color');
556
+ const isWindows = platform === 'win32';
557
+ const isDumbTerminal = env$1.TERM === 'dumb';
558
+ const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
559
+ const isCI = 'CI'in env$1 && ('GITHUB_ACTIONS'in env$1 || 'GITLAB_CI'in env$1 || 'CIRCLECI'in env$1);
560
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
561
+ const replaceClose = (index, string, close, replace, head=string.substring(0, index) + replace, tail=string.substring(index + close.length), next=tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
562
+ const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
563
+ const filterEmpty = (open, close, replace=open, at=open.length + 1) => string => string || !(string === '' || string === undefined) ? clearBleed(('' + string).indexOf(close, at), string, open, close, replace) : '';
564
+ const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
565
+ const colors$1 = {
566
+ reset:init(0, 0),
567
+ bold:init(1, 22, '\x1B[22m\x1B[1m'),
568
+ dim:init(2, 22, '\x1B[22m\x1B[2m'),
569
+ italic:init(3, 23),
570
+ underline:init(4, 24),
571
+ inverse:init(7, 27),
572
+ hidden:init(8, 28),
573
+ strikethrough:init(9, 29),
574
+ black:init(30, 39),
575
+ red:init(31, 39),
576
+ green:init(32, 39),
577
+ yellow:init(33, 39),
578
+ blue:init(34, 39),
579
+ magenta:init(35, 39),
580
+ cyan:init(36, 39),
581
+ white:init(37, 39),
582
+ gray:init(90, 39),
583
+ bgBlack:init(40, 49),
584
+ bgRed:init(41, 49),
585
+ bgGreen:init(42, 49),
586
+ bgYellow:init(43, 49),
587
+ bgBlue:init(44, 49),
588
+ bgMagenta:init(45, 49),
589
+ bgCyan:init(46, 49),
590
+ bgWhite:init(47, 49),
591
+ blackBright:init(90, 39),
592
+ redBright:init(91, 39),
593
+ greenBright:init(92, 39),
594
+ yellowBright:init(93, 39),
595
+ blueBright:init(94, 39),
596
+ magentaBright:init(95, 39),
597
+ cyanBright:init(96, 39),
598
+ whiteBright:init(97, 39),
599
+ bgBlackBright:init(100, 49),
600
+ bgRedBright:init(101, 49),
601
+ bgGreenBright:init(102, 49),
602
+ bgYellowBright:init(103, 49),
603
+ bgBlueBright:init(104, 49),
604
+ bgMagentaBright:init(105, 49),
605
+ bgCyanBright:init(106, 49),
606
+ bgWhiteBright:init(107, 49)
607
+ };
608
+ const createColors = ({useColor=isColorSupported}={}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
609
+ ...colors$2,
610
+ [key]:String
611
+ }), {});
612
+ const {reset, bold:bold$1, dim:dim$1, italic, underline:underline$1, inverse, hidden, strikethrough, black, red:red$1, green:green$1, yellow:yellow$1, blue, magenta, cyan:cyan$1, white, gray:gray$1, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright} = createColors();
613
+
614
+ // src/cli/colors.ts
615
+ var colors_ns = {};
616
+ __export(colors_ns, {
617
+ bold:() => bold,
618
+ cyan:() => cyan,
619
+ dim:() => dim,
620
+ gray:() => gray,
621
+ green:() => green,
622
+ red:() => red,
623
+ underline:() => underline,
624
+ yellow:() => yellow
625
+ });
626
+ const {bold, cyan, dim, gray, green, red, underline, yellow} = createColors({
627
+ useColor:env.FORCE_COLOR !== '0' && !env.NO_COLOR
628
+ });
629
+
630
+ // src/cli/commands/bundle.ts
631
+ async function bundle(configPath) {
632
+ const config = await ensureConfig(configPath);
633
+ if ( !config) {
634
+ logger.error(`No configuration found at ${config}`);
635
+ process.exit(1);
636
+ }
637
+ const configList = arraify(config);
638
+ for (const config2 of configList) {
639
+ await bundleInner(config2);
640
+ }
641
+ }
642
+ async function bundleInner(options) {
643
+ const startTime = performance.now();
644
+ const build = await rolldown(options);
645
+ const bundleOutput = await build.write(options?.output);
646
+ const endTime = performance.now();
647
+ printBundleOutputPretty(bundleOutput);
648
+ logger.log(``);
649
+ logger.success(`Finished in ${colors_ns.bold((endTime - startTime).toFixed(2))} ms`);
650
+ }
651
+ function printBundleOutputPretty(output) {
652
+ const outputEntries = collectOutputEntries(output.output);
653
+ const outputLayoutSizes = collectOutputLayoutAdjustmentSizes(outputEntries);
654
+ printOutputEntries(outputEntries, outputLayoutSizes, '<DIR>');
655
+ }
656
+ function collectOutputEntries(output) {
657
+ return output.map(chunk => ({
658
+ type:chunk.type,
659
+ fileName:chunk.fileName,
660
+ size:chunk.type === 'chunk' ? chunk.code.length : chunk.source.length
661
+ }));
662
+ }
663
+ function collectOutputLayoutAdjustmentSizes(entries) {
664
+ let longest = 0;
665
+ let biggestSize = 0;
666
+ for (const entry of entries) {
667
+ if (entry.fileName.length > longest) {
668
+ longest = entry.fileName.length;
669
+ }
670
+ if (entry.size > biggestSize) {
671
+ biggestSize = entry.size;
672
+ }
673
+ }
674
+ const sizePad = displaySize(biggestSize).length;
675
+ return {
676
+ longest,
677
+ biggestSize,
678
+ sizePad
679
+ };
680
+ }
681
+ const numberFormatter = new Intl.NumberFormat('en', {
682
+ maximumFractionDigits:2,
683
+ minimumFractionDigits:2
684
+ });
685
+ function displaySize(bytes) {
686
+ return `${numberFormatter.format(bytes / 1e3)} kB`;
687
+ }
688
+ const CHUNK_GROUPS = [{
689
+ type:'asset',
690
+ color:'green'
691
+ }, {
692
+ type:'chunk',
693
+ color:'cyan'
694
+ }];
695
+ function printOutputEntries(entries, sizeAdjustment, distPath) {
696
+ for (const group of CHUNK_GROUPS) {
697
+ const filtered = entries.filter(e => e.type === group.type);
698
+ if ( !filtered.length) {
699
+ continue;
700
+ }
701
+ for (const entry of filtered.sort((a, z) => a.size - z.size)) {
702
+ let log = colors_ns.dim(withTrailingSlash(distPath));
703
+ log += colors_ns[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
704
+ log += colors_ns.dim(entry.type);
705
+ log += colors_ns.dim(` \u2502 size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
706
+ logger.log(log);
707
+ }
708
+ }
709
+ }
710
+ function withTrailingSlash(path) {
711
+ if (path[path.length - 1] !== '/') {
712
+ return `${path}/`;
713
+ }
714
+ return path;
715
+ }
716
+
717
+ // package.json
718
+ const version = '0.10.3';
719
+ const description = 'Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.';
720
+ const keywords = ['webpack', 'parcel', 'esbuild', 'rollup', 'bundler', 'rolldown'];
721
+ const files = ['bin', 'cli', 'dist', '!dist/*.node'];
722
+ const napi = {
723
+ 'binaryName':'rolldown-binding',
724
+ 'packageName':'@rolldown/binding',
725
+ 'targets':['x86_64-apple-darwin', 'x86_64-pc-windows-msvc', 'x86_64-unknown-linux-gnu', 'x86_64-unknown-linux-musl', 'i686-pc-windows-msvc', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', 'aarch64-apple-darwin', 'aarch64-unknown-linux-musl', 'aarch64-pc-windows-msvc', 'wasm32-wasip1-threads'],
726
+ 'wasm':{
727
+ 'initialMemory':16384,
728
+ 'browser':{
729
+ 'fs':true
730
+ }
731
+ },
732
+ 'dtsHeader':'type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\n'
733
+ };
734
+
735
+ // src/cli/constants.ts
736
+ const DEFAULT_CONFIG_FILENAME = 'rolldown.config.js';
737
+
738
+ // src/cli/index.ts
739
+ var import_lib_index = __toESM(require_lib_index());
740
+ const main = defineCommand({
741
+ meta:{
742
+ name:'rolldown',
743
+ version,
744
+ description
745
+ },
746
+ args:{
747
+ config:{
748
+ type:'string',
749
+ alias:'c',
750
+ description:'Use this config file (if argument is used but value is unspecified, defaults to `rolldown.config.js`)'
751
+ },
752
+ help:{
753
+ type:'boolean',
754
+ alias:'h',
755
+ description:'Show this help message'
756
+ }
757
+ },
758
+ async run(_ctx){
759
+ const parsedArgs = (0,import_lib_index.default)(process$1.argv.slice(2));
760
+ let argConfig = parsedArgs.c || parsedArgs.config;
761
+ if (argConfig) {
762
+ if (argConfig == true) {
763
+ argConfig = DEFAULT_CONFIG_FILENAME;
764
+ }
765
+ await bundle(argConfig);
766
+ process$1.exit(0);
767
+ return;
768
+ }
769
+ showUsage(main);
770
+ }
771
+ });
772
+ runMain(main);