@hot-updater/cloudflare 0.20.10 → 0.20.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -28,8 +28,6 @@ let __hot_updater_plugin_core = require("@hot-updater/plugin-core");
28
28
  __hot_updater_plugin_core = __toESM(__hot_updater_plugin_core);
29
29
  let cloudflare = require("cloudflare");
30
30
  cloudflare = __toESM(cloudflare);
31
- let path = require("path");
32
- path = __toESM(path);
33
31
  let node_url = require("node:url");
34
32
  node_url = __toESM(node_url);
35
33
  let node_child_process = require("node:child_process");
@@ -44,6 +42,8 @@ let node_tty = require("node:tty");
44
42
  node_tty = __toESM(node_tty);
45
43
  let node_path = require("node:path");
46
44
  node_path = __toESM(node_path);
45
+ let path = require("path");
46
+ path = __toESM(path);
47
47
  let node_timers_promises = require("node:timers/promises");
48
48
  node_timers_promises = __toESM(node_timers_promises);
49
49
  let node_os = require("node:os");
@@ -136,14 +136,13 @@ var require_error = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/pg-mi
136
136
  SQLParsingError$1.prototype.toString = function(level) {
137
137
  level = level > 0 ? parseInt(level) : 0;
138
138
  const gap = messageGap(level + 1);
139
- const lines = [
139
+ return [
140
140
  "SQLParsingError {",
141
141
  `${gap}code: parsingErrorCode.${errorMessages[this.code].name}`,
142
142
  `${gap}error: "${this.error}"`,
143
143
  `${gap}position: {line: ${this.position.line}, col: ${this.position.column}}`,
144
144
  `${messageGap(level)}}`
145
- ];
146
- return lines.join(EOL);
145
+ ].join(EOL);
147
146
  };
148
147
  addInspection(SQLParsingError$1.prototype, function() {
149
148
  return this.toString();
@@ -278,8 +277,7 @@ var require_parser = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/pg-m
278
277
  }
279
278
  }
280
279
  function throwError(code) {
281
- const position = getIndexPos(sql, idx);
282
- throw new SQLParsingError(code, position);
280
+ throw new SQLParsingError(code, getIndexPos(sql, idx));
283
281
  }
284
282
  }
285
283
  function isGap(s) {
@@ -320,9 +318,8 @@ function buildWhereClause(conditions) {
320
318
  clauses.push("platform = ?");
321
319
  params.push(conditions.platform);
322
320
  }
323
- const whereClause = clauses.length > 0 ? ` WHERE ${clauses.join(" AND ")}` : "";
324
321
  return {
325
- sql: whereClause,
322
+ sql: clauses.length > 0 ? ` WHERE ${clauses.join(" AND ")}` : "",
326
323
  params
327
324
  };
328
325
  }
@@ -347,13 +344,11 @@ const d1Database = (config, hooks) => {
347
344
  async function getTotalCount(context, conditions) {
348
345
  const { sql: whereClause, params } = buildWhereClause(conditions);
349
346
  const countSql = (0, import_lib.default)(`SELECT COUNT(*) as total FROM bundles${whereClause}`);
350
- const countResult = await context.cf.d1.database.query(config.databaseId, {
347
+ return (await resolvePage(await context.cf.d1.database.query(config.databaseId, {
351
348
  account_id: config.accountId,
352
349
  sql: countSql,
353
350
  params
354
- });
355
- const rows = await resolvePage(countResult);
356
- return rows[0]?.total || 0;
351
+ })))[0]?.total || 0;
357
352
  }
358
353
  async function getPaginatedBundles(context, conditions, limit, offset) {
359
354
  const { sql: whereClause, params } = buildWhereClause(conditions);
@@ -365,13 +360,11 @@ const d1Database = (config, hooks) => {
365
360
  OFFSET ?
366
361
  `);
367
362
  params.push(limit, offset);
368
- const result = await context.cf.d1.database.query(config.databaseId, {
363
+ return (await resolvePage(await context.cf.d1.database.query(config.databaseId, {
369
364
  account_id: config.accountId,
370
365
  sql,
371
366
  params
372
- });
373
- const rows = await resolvePage(result);
374
- return rows.map(transformRowToBundle);
367
+ }))).map(transformRowToBundle);
375
368
  }
376
369
  return (0, __hot_updater_plugin_core.createDatabasePlugin)("d1Database", {
377
370
  getContext: () => ({ cf: new cloudflare.default({ apiToken: config.cloudflareApiToken }) }),
@@ -380,12 +373,11 @@ const d1Database = (config, hooks) => {
380
373
  if (found) return found;
381
374
  const sql = (0, import_lib.default)(`
382
375
  SELECT * FROM bundles WHERE id = ? LIMIT 1`);
383
- const singlePage = await context.cf.d1.database.query(config.databaseId, {
376
+ const rows = await resolvePage(await context.cf.d1.database.query(config.databaseId, {
384
377
  account_id: config.accountId,
385
378
  sql,
386
379
  params: [bundleId]
387
- });
388
- const rows = await resolvePage(singlePage);
380
+ }));
389
381
  if (rows.length === 0) return null;
390
382
  return transformRowToBundle(rows[0]);
391
383
  },
@@ -393,11 +385,10 @@ const d1Database = (config, hooks) => {
393
385
  const { where = {}, limit, offset } = options;
394
386
  const totalCount = await getTotalCount(context, where);
395
387
  bundles = await getPaginatedBundles(context, where, limit, offset);
396
- const paginationOptions = {
388
+ const pagination = (0, __hot_updater_plugin_core.calculatePagination)(totalCount, {
397
389
  limit,
398
390
  offset
399
- };
400
- const pagination = (0, __hot_updater_plugin_core.calculatePagination)(totalCount, paginationOptions);
391
+ });
401
392
  return {
402
393
  data: bundles,
403
394
  pagination
@@ -407,13 +398,11 @@ const d1Database = (config, hooks) => {
407
398
  const sql = (0, import_lib.default)(`
408
399
  SELECT channel FROM bundles GROUP BY channel
409
400
  `);
410
- const singlePage = await context.cf.d1.database.query(config.databaseId, {
401
+ return (await resolvePage(await context.cf.d1.database.query(config.databaseId, {
411
402
  account_id: config.accountId,
412
403
  sql,
413
404
  params: []
414
- });
415
- const rows = await resolvePage(singlePage);
416
- return rows.map((row) => row.channel);
405
+ }))).map((row) => row.channel);
417
406
  },
418
407
  async commitBundle(context, { changedSets }) {
419
408
  if (changedSets.length === 0) return;
@@ -519,8 +508,7 @@ const stringToUint8Array = (string) => textEncoder$1.encode(string);
519
508
  const textDecoder = new TextDecoder();
520
509
  const uint8ArrayToString = (uint8Array) => textDecoder.decode(uint8Array);
521
510
  const joinToString = (uint8ArraysOrStrings, encoding) => {
522
- const strings = uint8ArraysToStrings(uint8ArraysOrStrings, encoding);
523
- return strings.join("");
511
+ return uint8ArraysToStrings(uint8ArraysOrStrings, encoding).join("");
524
512
  };
525
513
  const uint8ArraysToStrings = (uint8ArraysOrStrings, encoding) => {
526
514
  if (encoding === "utf8" && uint8ArraysOrStrings.every((uint8ArrayOrString) => typeof uint8ArrayOrString === "string")) return uint8ArraysOrStrings;
@@ -575,8 +563,7 @@ const parseTemplate = ({ templates, expressions, tokens, index, template }) => {
575
563
  const newTokens = concatTokens(tokens, nextTokens, leadingWhitespaces);
576
564
  if (index === expressions.length) return newTokens;
577
565
  const expression = expressions[index];
578
- const expressionTokens = Array.isArray(expression) ? expression.map((expression$1) => parseExpression(expression$1)) : [parseExpression(expression)];
579
- return concatTokens(newTokens, expressionTokens, trailingWhitespaces);
566
+ return concatTokens(newTokens, Array.isArray(expression) ? expression.map((expression$1) => parseExpression(expression$1)) : [parseExpression(expression)], trailingWhitespaces);
580
567
  };
581
568
  const splitByWhitespaces = (template, rawTemplate) => {
582
569
  if (rawTemplate.length === 0) return {
@@ -663,8 +650,7 @@ const normalizeFdSpecificOptions = (options) => {
663
650
  };
664
651
  const normalizeFdSpecificOption = (options, optionName) => {
665
652
  const optionBaseArray = Array.from({ length: getStdioLength(options) + 1 });
666
- const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);
667
- return addDefaultValue$1(optionArray, optionName);
653
+ return addDefaultValue$1(normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName), optionName);
668
654
  };
669
655
  const getStdioLength = ({ stdio }) => Array.isArray(stdio) ? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length) : STANDARD_STREAMS_ALIASES.length;
670
656
  const normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue) ? normalizeOptionObject(optionValue, optionArray, optionName) : optionArray.fill(optionValue);
@@ -694,12 +680,11 @@ const parseFd = (fdName) => {
694
680
  };
695
681
  const FD_REGEXP = /^fd(\d+)$/;
696
682
  const addDefaultValue$1 = (optionArray, optionName) => optionArray.map((optionValue) => optionValue === void 0 ? DEFAULT_OPTIONS[optionName] : optionValue);
697
- const verboseDefault = (0, node_util.debuglog)("execa").enabled ? "full" : "none";
698
683
  const DEFAULT_OPTIONS = {
699
684
  lines: false,
700
685
  buffer: true,
701
686
  maxBuffer: 1e3 * 1e3 * 100,
702
- verbose: verboseDefault,
687
+ verbose: (0, node_util.debuglog)("execa").enabled ? "full" : "none",
703
688
  stripFinalNewline: true
704
689
  };
705
690
  const FD_SPECIFIC_OPTIONS = [
@@ -732,11 +717,9 @@ const VERBOSE_VALUES = [
732
717
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/arguments/escape.js
733
718
  const joinCommand = (filePath, rawArguments) => {
734
719
  const fileAndArguments = [filePath, ...rawArguments];
735
- const command = fileAndArguments.join(" ");
736
- const escapedCommand = fileAndArguments.map((fileAndArgument) => quoteString(escapeControlCharacters(fileAndArgument))).join(" ");
737
720
  return {
738
- command,
739
- escapedCommand
721
+ command: fileAndArguments.join(" "),
722
+ escapedCommand: fileAndArguments.map((fileAndArgument) => quoteString(escapeControlCharacters(fileAndArgument))).join(" ")
740
723
  };
741
724
  };
742
725
  const escapeLines = (lines) => (0, node_util.stripVTControlCharacters)(lines).split("\n").map((line) => escapeControlCharacters(line)).join("\n");
@@ -1177,13 +1160,11 @@ const appendNewline = (printedLine) => printedLine.endsWith("\n") ? printedLine
1177
1160
  //#endregion
1178
1161
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/log.js
1179
1162
  const verboseLog = ({ type, verboseMessage, fdNumber, verboseInfo, result }) => {
1180
- const verboseObject = getVerboseObject({
1163
+ const finalLines = applyVerboseOnLines(getPrintedLines(verboseMessage, getVerboseObject({
1181
1164
  type,
1182
1165
  result,
1183
1166
  verboseInfo
1184
- });
1185
- const printedLines = getPrintedLines(verboseMessage, verboseObject);
1186
- const finalLines = applyVerboseOnLines(printedLines, verboseInfo, fdNumber);
1167
+ })), verboseInfo, fdNumber);
1187
1168
  if (finalLines !== "") console.warn(finalLines.slice(0, -1));
1188
1169
  };
1189
1170
  const getVerboseObject = ({ type, result, verboseInfo: { escapedCommand, commandId, rawOptions: { piped = false,...options } } }) => ({
@@ -1200,16 +1181,13 @@ const getPrintedLines = (verboseMessage, verboseObject) => verboseMessage.split(
1200
1181
  message
1201
1182
  }));
1202
1183
  const getPrintedLine = (verboseObject) => {
1203
- const verboseLine = defaultVerboseFunction(verboseObject);
1204
1184
  return {
1205
- verboseLine,
1185
+ verboseLine: defaultVerboseFunction(verboseObject),
1206
1186
  verboseObject
1207
1187
  };
1208
1188
  };
1209
1189
  const serializeVerboseMessage = (message) => {
1210
- const messageString = typeof message === "string" ? message : (0, node_util.inspect)(message);
1211
- const escapedMessage = escapeLines(messageString);
1212
- return escapedMessage.replaceAll(" ", " ".repeat(TAB_SIZE));
1190
+ return escapeLines(typeof message === "string" ? message : (0, node_util.inspect)(message)).replaceAll(" ", " ".repeat(TAB_SIZE));
1213
1191
  };
1214
1192
  const TAB_SIZE = 2;
1215
1193
 
@@ -1228,11 +1206,10 @@ const logCommand = (escapedCommand, verboseInfo) => {
1228
1206
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/info.js
1229
1207
  const getVerboseInfo = (verbose, escapedCommand, rawOptions) => {
1230
1208
  validateVerbose(verbose);
1231
- const commandId = getCommandId(verbose);
1232
1209
  return {
1233
1210
  verbose,
1234
1211
  escapedCommand,
1235
- commandId,
1212
+ commandId: getCommandId(verbose),
1236
1213
  rawOptions
1237
1214
  };
1238
1215
  };
@@ -1259,8 +1236,7 @@ const getDurationMs = (startTime) => Number(node_process.hrtime.bigint() - start
1259
1236
  const handleCommand = (filePath, rawArguments, rawOptions) => {
1260
1237
  const startTime = getStartTime();
1261
1238
  const { command, escapedCommand } = joinCommand(filePath, rawArguments);
1262
- const verbose = normalizeFdSpecificOption(rawOptions, "verbose");
1263
- const verboseInfo = getVerboseInfo(verbose, escapedCommand, { ...rawOptions });
1239
+ const verboseInfo = getVerboseInfo(normalizeFdSpecificOption(rawOptions, "verbose"), escapedCommand, { ...rawOptions });
1264
1240
  logCommand(escapedCommand, verboseInfo);
1265
1241
  return {
1266
1242
  command,
@@ -1328,8 +1304,7 @@ var require_mode = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/isexe@
1328
1304
  var g = parseInt("010", 8);
1329
1305
  var o$1 = parseInt("001", 8);
1330
1306
  var ug = u$1 | g;
1331
- var ret = mod & o$1 || mod & g && gid === myGid || mod & u$1 && uid === myUid || mod & ug && myUid === 0;
1332
- return ret;
1307
+ return mod & o$1 || mod & g && gid === myGid || mod & u$1 && uid === myUid || mod & ug && myUid === 0;
1333
1308
  }
1334
1309
  }) });
1335
1310
 
@@ -1411,8 +1386,7 @@ var require_which = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/which
1411
1386
  const ppRaw = pathEnv[i$1];
1412
1387
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
1413
1388
  const pCmd = path$9.join(pathPart, cmd);
1414
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
1415
- resolve(subStep(p, i$1, 0));
1389
+ resolve(subStep(!pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd, i$1, 0));
1416
1390
  });
1417
1391
  const subStep = (p, i$1, ii) => new Promise((resolve, reject) => {
1418
1392
  if (ii === pathExt.length) return resolve(step(i$1 + 1));
@@ -1437,8 +1411,7 @@ var require_which = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/which
1437
1411
  for (let j = 0; j < pathExt.length; j++) {
1438
1412
  const cur = p + pathExt[j];
1439
1413
  try {
1440
- const is = isexe.sync(cur, { pathExt: pathExtExe });
1441
- if (is) if (opt.all) found.push(cur);
1414
+ if (isexe.sync(cur, { pathExt: pathExtExe })) if (opt.all) found.push(cur);
1442
1415
  else return cur;
1443
1416
  } catch (ex) {}
1444
1417
  }
@@ -1456,8 +1429,7 @@ var require_which = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/which
1456
1429
  var require_path_key = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js": ((exports, module) => {
1457
1430
  const pathKey$1 = (options = {}) => {
1458
1431
  const environment = options.env || process.env;
1459
- const platform$1 = options.platform || process.platform;
1460
- if (platform$1 !== "win32") return "PATH";
1432
+ if ((options.platform || process.platform) !== "win32") return "PATH";
1461
1433
  return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
1462
1434
  };
1463
1435
  module.exports = pathKey$1;
@@ -1585,12 +1557,11 @@ var require_parse = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/cross
1585
1557
  parsed.command = path$7.normalize(parsed.command);
1586
1558
  parsed.command = escape.command(parsed.command);
1587
1559
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
1588
- const shellCommand = [parsed.command].concat(parsed.args).join(" ");
1589
1560
  parsed.args = [
1590
1561
  "/d",
1591
1562
  "/s",
1592
1563
  "/c",
1593
- `"${shellCommand}"`
1564
+ `"${[parsed.command].concat(parsed.args).join(" ")}"`
1594
1565
  ];
1595
1566
  parsed.command = process.env.comspec || "cmd.exe";
1596
1567
  parsed.options.windowsVerbatimArguments = true;
@@ -1743,9 +1714,7 @@ const npmRunPathEnv = ({ env = node_process.default.env,...options } = {}) => {
1743
1714
  //#endregion
1744
1715
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/return/final-error.js
1745
1716
  const getFinalError = (originalError, message, isSync) => {
1746
- const ErrorClass = isSync ? ExecaSyncError : ExecaError;
1747
- const options = originalError instanceof DiscardedError ? {} : { cause: originalError };
1748
- return new ErrorClass(message, options);
1717
+ return new (isSync ? ExecaSyncError : ExecaError)(message, originalError instanceof DiscardedError ? {} : { cause: originalError });
1749
1718
  };
1750
1719
  var DiscardedError = class extends Error {};
1751
1720
  const setErrorName = (ErrorClass, value) => {
@@ -2064,16 +2033,14 @@ const SIGNALS = [
2064
2033
  //#region ../../node_modules/.pnpm/human-signals@8.0.0/node_modules/human-signals/build/src/signals.js
2065
2034
  const getSignals = () => {
2066
2035
  const realtimeSignals = getRealtimeSignals();
2067
- const signals$1 = [...SIGNALS, ...realtimeSignals].map(normalizeSignal$1);
2068
- return signals$1;
2036
+ return [...SIGNALS, ...realtimeSignals].map(normalizeSignal$1);
2069
2037
  };
2070
2038
  const normalizeSignal$1 = ({ name, number: defaultNumber, description, action, forced = false, standard }) => {
2071
2039
  const { signals: { [name]: constantSignal } } = node_os.constants;
2072
2040
  const supported = constantSignal !== void 0;
2073
- const number = supported ? constantSignal : defaultNumber;
2074
2041
  return {
2075
2042
  name,
2076
- number,
2043
+ number: supported ? constantSignal : defaultNumber,
2077
2044
  description,
2078
2045
  supported,
2079
2046
  action,
@@ -2485,8 +2452,7 @@ const isConnected = (anyProcess) => {
2485
2452
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/ipc/strict.js
2486
2453
  const handleSendStrict = ({ anyProcess, channel, isSubprocess, message, strict }) => {
2487
2454
  if (!strict) return message;
2488
- const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
2489
- const hasListeners = hasMessageListeners(anyProcess, ipcEmitter);
2455
+ const hasListeners = hasMessageListeners(anyProcess, getIpcEmitter(anyProcess, channel, isSubprocess));
2490
2456
  return {
2491
2457
  id: count++,
2492
2458
  type: REQUEST_TYPE,
@@ -2559,11 +2525,9 @@ const RESPONSE_TYPE = "execa:ipc:response";
2559
2525
  const startSendMessage = (anyProcess, wrappedMessage, strict) => {
2560
2526
  if (!OUTGOING_MESSAGES.has(anyProcess)) OUTGOING_MESSAGES.set(anyProcess, /* @__PURE__ */ new Set());
2561
2527
  const outgoingMessages = OUTGOING_MESSAGES.get(anyProcess);
2562
- const onMessageSent = createDeferred();
2563
- const id = strict ? wrappedMessage.id : void 0;
2564
2528
  const outgoingMessage = {
2565
- onMessageSent,
2566
- id
2529
+ onMessageSent: createDeferred(),
2530
+ id: strict ? wrappedMessage.id : void 0
2567
2531
  };
2568
2532
  outgoingMessages.add(outgoingMessage);
2569
2533
  return {
@@ -2724,8 +2688,7 @@ const throwOnGracefulCancel = ({ subprocess, cancelSignal, gracefulCancel, force
2724
2688
  })] : [];
2725
2689
  const sendOnAbort = async ({ subprocess, cancelSignal, forceKillAfterDelay, context, controller: { signal } }) => {
2726
2690
  await onAbortedSignal(cancelSignal, signal);
2727
- const reason = getReason(cancelSignal);
2728
- await sendAbort(subprocess, reason);
2691
+ await sendAbort(subprocess, getReason(cancelSignal));
2729
2692
  killOnTimeout({
2730
2693
  kill: subprocess.kill,
2731
2694
  forceKillAfterDelay,
@@ -2899,8 +2862,7 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
2899
2862
  rawOptions.cwd = normalizeCwd(rawOptions.cwd);
2900
2863
  const [processedFile, processedArguments, processedOptions] = handleNodeOption(filePath, rawArguments, rawOptions);
2901
2864
  const { command: file, args: commandArguments, options: initialOptions } = import_cross_spawn.default._parse(processedFile, processedArguments, processedOptions);
2902
- const fdOptions = normalizeFdSpecificOptions(initialOptions);
2903
- const options = addDefaultOptions(fdOptions);
2865
+ const options = addDefaultOptions(normalizeFdSpecificOptions(initialOptions));
2904
2866
  validateTimeout(options);
2905
2867
  validateEncoding(options);
2906
2868
  validateIpcInputOption(options);
@@ -3057,7 +3019,7 @@ const u = Object.create(a, {
3057
3019
  }
3058
3020
  });
3059
3021
  function h({ preventCancel: r = !1 } = {}) {
3060
- const e = this.getReader(), t = new c(e, r), s = Object.create(u);
3022
+ const t = new c(this.getReader(), r), s = Object.create(u);
3061
3023
  return s[n] = t, s;
3062
3024
  }
3063
3025
 
@@ -3106,18 +3068,14 @@ const getStreamContents$1 = async (stream, { init, convertChunk, getSize, trunca
3106
3068
  const state = init();
3107
3069
  state.length = 0;
3108
3070
  try {
3109
- for await (const chunk of asyncIterable) {
3110
- const chunkType = getChunkType(chunk);
3111
- const convertedChunk = convertChunk[chunkType](chunk, state);
3112
- appendChunk({
3113
- convertedChunk,
3114
- state,
3115
- getSize,
3116
- truncateChunk,
3117
- addChunk,
3118
- maxBuffer
3119
- });
3120
- }
3071
+ for await (const chunk of asyncIterable) appendChunk({
3072
+ convertedChunk: convertChunk[getChunkType(chunk)](chunk, state),
3073
+ state,
3074
+ getSize,
3075
+ truncateChunk,
3076
+ addChunk,
3077
+ maxBuffer
3078
+ });
3121
3079
  appendFinalChunk({
3122
3080
  state,
3123
3081
  convertChunk,
@@ -3307,10 +3265,9 @@ const stringMethods = {
3307
3265
  const handleMaxBuffer = ({ error: error$1, stream, readableObjectMode, lines, encoding, fdNumber }) => {
3308
3266
  if (!(error$1 instanceof MaxBufferError)) throw error$1;
3309
3267
  if (fdNumber === "all") return error$1;
3310
- const unit = getMaxBufferUnit(readableObjectMode, lines, encoding);
3311
3268
  error$1.maxBufferInfo = {
3312
3269
  fdNumber,
3313
- unit
3270
+ unit: getMaxBufferUnit(readableObjectMode, lines, encoding)
3314
3271
  };
3315
3272
  stream.destroy();
3316
3273
  throw error$1;
@@ -3380,19 +3337,16 @@ const createMessages = ({ stdio, all, ipcOutput, originalError, signal, signalDe
3380
3337
  killSignal
3381
3338
  });
3382
3339
  const originalMessage = getOriginalMessage(originalError, cwd);
3383
- const suffix = originalMessage === void 0 ? "" : `\n${originalMessage}`;
3384
- const shortMessage = `${prefix}: ${escapedCommand}${suffix}`;
3385
- const messageStdio = all === void 0 ? [stdio[2], stdio[1]] : [all];
3386
- const message = [
3387
- shortMessage,
3388
- ...messageStdio,
3389
- ...stdio.slice(3),
3390
- ipcOutput.map((ipcMessage) => serializeIpcMessage(ipcMessage)).join("\n")
3391
- ].map((messagePart) => escapeLines(stripFinalNewline(serializeMessagePart(messagePart)))).filter(Boolean).join("\n\n");
3340
+ const shortMessage = `${prefix}: ${escapedCommand}${originalMessage === void 0 ? "" : `\n${originalMessage}`}`;
3392
3341
  return {
3393
3342
  originalMessage,
3394
3343
  shortMessage,
3395
- message
3344
+ message: [
3345
+ shortMessage,
3346
+ ...all === void 0 ? [stdio[2], stdio[1]] : [all],
3347
+ ...stdio.slice(3),
3348
+ ipcOutput.map((ipcMessage) => serializeIpcMessage(ipcMessage)).join("\n")
3349
+ ].map((messagePart) => escapeLines(stripFinalNewline(serializeMessagePart(messagePart)))).filter(Boolean).join("\n\n")
3396
3350
  };
3397
3351
  };
3398
3352
  const getErrorPrefix = ({ originalError, timedOut, timeout, isMaxBuffer, maxBuffer, errorCode, signal, signalDescription, exitCode, isCanceled, isGracefullyCanceled, isForcefullyTerminated, forceKillAfterDelay, killSignal }) => {
@@ -3413,8 +3367,7 @@ const getErrorPrefix = ({ originalError, timedOut, timeout, isMaxBuffer, maxBuff
3413
3367
  const getForcefulSuffix = (isForcefullyTerminated, forceKillAfterDelay) => isForcefullyTerminated ? ` and was forcefully terminated after ${forceKillAfterDelay} milliseconds` : "";
3414
3368
  const getOriginalMessage = (originalError, cwd) => {
3415
3369
  if (originalError instanceof DiscardedError) return;
3416
- const originalMessage = isExecaError(originalError) ? originalError.originalMessage : String(originalError?.message ?? originalError);
3417
- const escapedOriginalMessage = escapeLines(fixCwdError(originalMessage, cwd));
3370
+ const escapedOriginalMessage = escapeLines(fixCwdError(isExecaError(originalError) ? originalError.originalMessage : String(originalError?.message ?? originalError), cwd));
3418
3371
  return escapedOriginalMessage === "" ? void 0 : escapedOriginalMessage;
3419
3372
  };
3420
3373
  const serializeIpcMessage = (ipcMessage) => typeof ipcMessage === "string" ? ipcMessage : (0, node_util.inspect)(ipcMessage);
@@ -3536,11 +3489,10 @@ const omitUndefinedProperties = (result) => Object.fromEntries(Object.entries(re
3536
3489
  const normalizeExitPayload = (rawExitCode, rawSignal) => {
3537
3490
  const exitCode = rawExitCode === null ? void 0 : rawExitCode;
3538
3491
  const signal = rawSignal === null ? void 0 : rawSignal;
3539
- const signalDescription = signal === void 0 ? void 0 : getSignalDescription(rawSignal);
3540
3492
  return {
3541
3493
  exitCode,
3542
3494
  signal,
3543
- signalDescription
3495
+ signalDescription: signal === void 0 ? void 0 : getSignalDescription(rawSignal)
3544
3496
  };
3545
3497
  };
3546
3498
 
@@ -3605,8 +3557,7 @@ function prettyMilliseconds(milliseconds, options) {
3605
3557
  let result = [];
3606
3558
  const floorDecimals = (value, decimalDigits) => {
3607
3559
  const flooredInterimValue = Math.floor(value * 10 ** decimalDigits + SECOND_ROUNDING_EPSILON);
3608
- const flooredValue = Math.round(flooredInterimValue) / 10 ** decimalDigits;
3609
- return flooredValue.toFixed(decimalDigits);
3560
+ return (Math.round(flooredInterimValue) / 10 ** decimalDigits).toFixed(decimalDigits);
3610
3561
  };
3611
3562
  const add = (value, long, short, valueString) => {
3612
3563
  if ((result.length === 0 || !options.colonNotation) && isZero(value) && !(options.colonNotation && short === "m")) return;
@@ -3643,14 +3594,11 @@ function prettyMilliseconds(milliseconds, options) {
3643
3594
  } else {
3644
3595
  const millisecondsAndBelow = milliseconds$1 + microseconds / 1e3 + nanoseconds / 1e6;
3645
3596
  const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === "number" ? options.millisecondsDecimalDigits : 0;
3646
- const roundedMilliseconds = millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
3647
- const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : roundedMilliseconds;
3597
+ const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
3648
3598
  add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
3649
3599
  }
3650
3600
  } else {
3651
- const seconds = (isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60;
3652
- const secondsDecimalDigits = typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1;
3653
- const secondsFixed = floorDecimals(seconds, secondsDecimalDigits);
3601
+ const secondsFixed = floorDecimals((isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60, typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1);
3654
3602
  const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, "");
3655
3603
  add(Number.parseFloat(secondsString), "second", "s", secondsString);
3656
3604
  }
@@ -3679,10 +3627,9 @@ const logResult = (result, verboseInfo) => {
3679
3627
  logDuration(result, verboseInfo);
3680
3628
  };
3681
3629
  const logDuration = (result, verboseInfo) => {
3682
- const verboseMessage = `(done in ${prettyMilliseconds(result.durationMs)})`;
3683
3630
  verboseLog({
3684
3631
  type: "duration",
3685
- verboseMessage,
3632
+ verboseMessage: `(done in ${prettyMilliseconds(result.durationMs)})`,
3686
3633
  verboseInfo,
3687
3634
  result
3688
3635
  });
@@ -3809,18 +3756,16 @@ const TYPE_TO_MESSAGE = {
3809
3756
  const getTransformObjectModes = (objectMode, index, newTransforms, direction) => direction === "output" ? getOutputObjectModes(objectMode, index, newTransforms) : getInputObjectModes(objectMode, index, newTransforms);
3810
3757
  const getOutputObjectModes = (objectMode, index, newTransforms) => {
3811
3758
  const writableObjectMode = index !== 0 && newTransforms[index - 1].value.readableObjectMode;
3812
- const readableObjectMode = objectMode ?? writableObjectMode;
3813
3759
  return {
3814
3760
  writableObjectMode,
3815
- readableObjectMode
3761
+ readableObjectMode: objectMode ?? writableObjectMode
3816
3762
  };
3817
3763
  };
3818
3764
  const getInputObjectModes = (objectMode, index, newTransforms) => {
3819
3765
  const writableObjectMode = index === 0 ? objectMode === true : newTransforms[index - 1].value.readableObjectMode;
3820
- const readableObjectMode = index !== newTransforms.length - 1 && (objectMode ?? writableObjectMode);
3821
3766
  return {
3822
3767
  writableObjectMode,
3823
- readableObjectMode
3768
+ readableObjectMode: index !== newTransforms.length - 1 && (objectMode ?? writableObjectMode)
3824
3769
  };
3825
3770
  };
3826
3771
  const getFdObjectMode = (stdioItems, direction) => {
@@ -4129,8 +4074,7 @@ const validateDuplicateStreamSync = ({ otherStdioItems, type, value, optionName,
4129
4074
  const getDuplicateStreamInstance = ({ otherStdioItems, type, value, optionName, direction }) => {
4130
4075
  const duplicateStdioItems = otherStdioItems.filter((stdioItem) => hasSameValue(stdioItem, value));
4131
4076
  if (duplicateStdioItems.length === 0) return;
4132
- const differentStdioItem = duplicateStdioItems.find((stdioItem) => stdioItem.direction !== direction);
4133
- throwOnDuplicateStream(differentStdioItem, optionName, type);
4077
+ throwOnDuplicateStream(duplicateStdioItems.find((stdioItem) => stdioItem.direction !== direction), optionName, type);
4134
4078
  return direction === "output" ? duplicateStdioItems[0].stream : void 0;
4135
4079
  };
4136
4080
  const hasSameValue = ({ type, value }, secondValue) => {
@@ -4139,8 +4083,7 @@ const hasSameValue = ({ type, value }, secondValue) => {
4139
4083
  return value === secondValue;
4140
4084
  };
4141
4085
  const validateDuplicateTransform = ({ otherStdioItems, type, value, optionName }) => {
4142
- const duplicateStdioItem = otherStdioItems.find(({ value: { transform } }) => transform === value.transform);
4143
- throwOnDuplicateStream(duplicateStdioItem, optionName, type);
4086
+ throwOnDuplicateStream(otherStdioItems.find(({ value: { transform } }) => transform === value.transform), optionName, type);
4144
4087
  };
4145
4088
  const throwOnDuplicateStream = (stdioItem, optionName, type) => {
4146
4089
  if (stdioItem !== void 0) throw new TypeError(`The \`${stdioItem.optionName}\` and \`${optionName}\` options must not target ${TYPE_TO_MESSAGE[type]} that is the same.`);
@@ -4149,15 +4092,13 @@ const throwOnDuplicateStream = (stdioItem, optionName, type) => {
4149
4092
  //#endregion
4150
4093
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/stdio/handle.js
4151
4094
  const handleStdio = (addProperties$2, options, verboseInfo, isSync) => {
4152
- const stdio = normalizeStdioOption(options, verboseInfo, isSync);
4153
- const initialFileDescriptors = stdio.map((stdioOption, fdNumber) => getFileDescriptor({
4154
- stdioOption,
4155
- fdNumber,
4156
- options,
4157
- isSync
4158
- }));
4159
4095
  const fileDescriptors = getFinalFileDescriptors({
4160
- initialFileDescriptors,
4096
+ initialFileDescriptors: normalizeStdioOption(options, verboseInfo, isSync).map((stdioOption, fdNumber) => getFileDescriptor({
4097
+ stdioOption,
4098
+ fdNumber,
4099
+ options,
4100
+ isSync
4101
+ })),
4161
4102
  addProperties: addProperties$2,
4162
4103
  options,
4163
4104
  isSync
@@ -4174,14 +4115,13 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
4174
4115
  optionName
4175
4116
  });
4176
4117
  const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);
4177
- const stdioItems = initialStdioItems.map((stdioItem) => handleNativeStream({
4118
+ const normalizedStdioItems = normalizeTransforms(initialStdioItems.map((stdioItem) => handleNativeStream({
4178
4119
  stdioItem,
4179
4120
  isStdioArray,
4180
4121
  fdNumber,
4181
4122
  direction,
4182
4123
  isSync
4183
- }));
4184
- const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);
4124
+ })), optionName, direction, options);
4185
4125
  const objectMode = getFdObjectMode(normalizedStdioItems, direction);
4186
4126
  validateFileObjectMode(normalizedStdioItems, objectMode);
4187
4127
  return {
@@ -4191,9 +4131,7 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
4191
4131
  };
4192
4132
  };
4193
4133
  const initializeStdioItems = ({ stdioOption, fdNumber, options, optionName }) => {
4194
- const values = Array.isArray(stdioOption) ? stdioOption : [stdioOption];
4195
- const initialStdioItems = [...values.map((value) => initializeStdioItem(value, optionName)), ...handleInputOptions(options, fdNumber)];
4196
- const stdioItems = filterDuplicates(initialStdioItems);
4134
+ const stdioItems = filterDuplicates([...(Array.isArray(stdioOption) ? stdioOption : [stdioOption]).map((value) => initializeStdioItem(value, optionName)), ...handleInputOptions(options, fdNumber)]);
4197
4135
  const isStdioArray = stdioItems.length > 1;
4198
4136
  validateStdioArray(stdioItems, isStdioArray, optionName);
4199
4137
  validateStreams(stdioItems);
@@ -4243,18 +4181,17 @@ const getFinalFileDescriptors = ({ initialFileDescriptors, addProperties: addPro
4243
4181
  }
4244
4182
  };
4245
4183
  const getFinalFileDescriptor = ({ fileDescriptor: { direction, objectMode, stdioItems }, fileDescriptors, addProperties: addProperties$2, options, isSync }) => {
4246
- const finalStdioItems = stdioItems.map((stdioItem) => addStreamProperties({
4247
- stdioItem,
4248
- addProperties: addProperties$2,
4249
- direction,
4250
- options,
4251
- fileDescriptors,
4252
- isSync
4253
- }));
4254
4184
  return {
4255
4185
  direction,
4256
4186
  objectMode,
4257
- stdioItems: finalStdioItems
4187
+ stdioItems: stdioItems.map((stdioItem) => addStreamProperties({
4188
+ stdioItem,
4189
+ addProperties: addProperties$2,
4190
+ direction,
4191
+ options,
4192
+ fileDescriptors,
4193
+ isSync
4194
+ }))
4258
4195
  };
4259
4196
  };
4260
4197
  const addStreamProperties = ({ stdioItem, addProperties: addProperties$2, direction, options, fileDescriptors, isSync }) => {
@@ -4384,8 +4321,7 @@ const appendNewlineGenerator = function* ({ isWindowsNewline = false }, chunk) {
4384
4321
  yield chunk;
4385
4322
  return;
4386
4323
  }
4387
- const newline = isWindowsNewline ? windowsNewline : unixNewline;
4388
- yield concatBytes(chunk, newline);
4324
+ yield concatBytes(chunk, isWindowsNewline ? windowsNewline : unixNewline);
4389
4325
  };
4390
4326
  const concatString = (firstChunk, secondChunk) => `${firstChunk}${secondChunk}`;
4391
4327
  const linesStringInfo = {
@@ -4530,7 +4466,7 @@ const generatorToStream = ({ value, value: { transform, final, writableObjectMod
4530
4466
  const transformMethod = transformAsync ? pushChunks.bind(void 0, transformChunk, state) : pushChunksSync.bind(void 0, transformChunkSync);
4531
4467
  const finalMethod = transformAsync || finalAsync ? pushChunks.bind(void 0, finalChunks, state) : pushChunksSync.bind(void 0, finalChunksSync);
4532
4468
  const destroyMethod = transformAsync || finalAsync ? destroyTransform.bind(void 0, state) : void 0;
4533
- const stream = new node_stream.Transform({
4469
+ return { stream: new node_stream.Transform({
4534
4470
  writableObjectMode,
4535
4471
  writableHighWaterMark: (0, node_stream.getDefaultHighWaterMark)(writableObjectMode),
4536
4472
  readableObjectMode,
@@ -4546,16 +4482,12 @@ const generatorToStream = ({ value, value: { transform, final, writableObjectMod
4546
4482
  finalMethod([generators], this, done);
4547
4483
  },
4548
4484
  destroy: destroyMethod
4549
- });
4550
- return { stream };
4485
+ }) };
4551
4486
  };
4552
4487
  const runGeneratorsSync = (chunks, stdioItems, encoding, isInput) => {
4553
4488
  const generators = stdioItems.filter(({ type }) => type === "generator");
4554
4489
  const reversedGenerators = isInput ? generators.reverse() : generators;
4555
- for (const { value, optionName } of reversedGenerators) {
4556
- const generators$1 = addInternalGenerators(value, encoding, optionName);
4557
- chunks = runTransformSync(generators$1, chunks);
4558
- }
4490
+ for (const { value, optionName } of reversedGenerators) chunks = runTransformSync(addInternalGenerators(value, encoding, optionName), chunks);
4559
4491
  return chunks;
4560
4492
  };
4561
4493
  const addInternalGenerators = ({ transform, final, binary, writableObjectMode, readableObjectMode, preserveNewlines }, encoding, optionName) => {
@@ -4592,9 +4524,7 @@ const addInputOptionSync = (fileDescriptors, fdNumber, options) => {
4592
4524
  const [{ type, optionName }] = allStdioItems;
4593
4525
  throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);
4594
4526
  }
4595
- const allContents = allStdioItems.map(({ contents }) => contents);
4596
- const transformedContents = allContents.map((contents) => applySingleInputGeneratorsSync(contents, stdioItems));
4597
- options.input = joinToUint8Array(transformedContents);
4527
+ options.input = joinToUint8Array(allStdioItems.map(({ contents }) => contents).map((contents) => applySingleInputGeneratorsSync(contents, stdioItems)));
4598
4528
  };
4599
4529
  const applySingleInputGeneratorsSync = (contents, stdioItems) => {
4600
4530
  const newContents = runGeneratorsSync(contents, stdioItems, "utf8", true);
@@ -4619,10 +4549,9 @@ const logLinesSync = (linesArray, fdNumber, verboseInfo) => {
4619
4549
  };
4620
4550
  const isPipingStream = (stream) => stream._readableState.pipes.length > 0;
4621
4551
  const logLine = (line, fdNumber, verboseInfo) => {
4622
- const verboseMessage = serializeVerboseMessage(line);
4623
4552
  verboseLog({
4624
4553
  type: "output",
4625
- verboseMessage,
4554
+ verboseMessage: serializeVerboseMessage(line),
4626
4555
  fdNumber,
4627
4556
  verboseInfo
4628
4557
  });
@@ -4634,28 +4563,25 @@ const transformOutputSync = ({ fileDescriptors, syncResult: { output }, options,
4634
4563
  if (output === null) return { output: Array.from({ length: 3 }) };
4635
4564
  const state = {};
4636
4565
  const outputFiles = /* @__PURE__ */ new Set([]);
4637
- const transformedOutput = output.map((result, fdNumber) => transformOutputResultSync({
4638
- result,
4639
- fileDescriptors,
4640
- fdNumber,
4641
- state,
4642
- outputFiles,
4643
- isMaxBuffer,
4644
- verboseInfo
4645
- }, options));
4646
4566
  return {
4647
- output: transformedOutput,
4567
+ output: output.map((result, fdNumber) => transformOutputResultSync({
4568
+ result,
4569
+ fileDescriptors,
4570
+ fdNumber,
4571
+ state,
4572
+ outputFiles,
4573
+ isMaxBuffer,
4574
+ verboseInfo
4575
+ }, options)),
4648
4576
  ...state
4649
4577
  };
4650
4578
  };
4651
4579
  const transformOutputResultSync = ({ result, fileDescriptors, fdNumber, state, outputFiles, isMaxBuffer, verboseInfo }, { buffer, encoding, lines, stripFinalNewline: stripFinalNewline$1, maxBuffer }) => {
4652
4580
  if (result === null) return;
4653
- const truncatedResult = truncateMaxBufferSync(result, isMaxBuffer, maxBuffer);
4654
- const uint8ArrayResult = bufferToUint8Array(truncatedResult);
4581
+ const uint8ArrayResult = bufferToUint8Array(truncateMaxBufferSync(result, isMaxBuffer, maxBuffer));
4655
4582
  const { stdioItems, objectMode } = fileDescriptors[fdNumber];
4656
- const chunks = runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state);
4657
4583
  const { serializedResult, finalResult = serializedResult } = serializeChunks({
4658
- chunks,
4584
+ chunks: runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state),
4659
4585
  objectMode,
4660
4586
  encoding,
4661
4587
  lines,
@@ -4766,14 +4692,12 @@ const isFailedExit = (exitCode, signal) => exitCode !== 0 || signal !== null;
4766
4692
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/resolve/exit-sync.js
4767
4693
  const getExitResultSync = ({ error: error$1, status: exitCode, signal, output }, { maxBuffer }) => {
4768
4694
  const resultError = getResultError(error$1, exitCode, signal);
4769
- const timedOut = resultError?.code === "ETIMEDOUT";
4770
- const isMaxBuffer = isMaxBufferSync(resultError, output, maxBuffer);
4771
4695
  return {
4772
4696
  resultError,
4773
4697
  exitCode,
4774
4698
  signal,
4775
- timedOut,
4776
- isMaxBuffer
4699
+ timedOut: resultError?.code === "ETIMEDOUT",
4700
+ isMaxBuffer: isMaxBufferSync(resultError, output, maxBuffer)
4777
4701
  };
4778
4702
  };
4779
4703
  const getResultError = (error$1, exitCode, signal) => {
@@ -4785,7 +4709,7 @@ const getResultError = (error$1, exitCode, signal) => {
4785
4709
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/methods/main-sync.js
4786
4710
  const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
4787
4711
  const { file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors } = handleSyncArguments(rawFile, rawArguments, rawOptions);
4788
- const result = spawnSubprocessSync({
4712
+ return handleResult(spawnSubprocessSync({
4789
4713
  file,
4790
4714
  commandArguments,
4791
4715
  options,
@@ -4794,15 +4718,12 @@ const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
4794
4718
  verboseInfo,
4795
4719
  fileDescriptors,
4796
4720
  startTime
4797
- });
4798
- return handleResult(result, verboseInfo, options);
4721
+ }), verboseInfo, options);
4799
4722
  };
4800
4723
  const handleSyncArguments = (rawFile, rawArguments, rawOptions) => {
4801
4724
  const { command, escapedCommand, startTime, verboseInfo } = handleCommand(rawFile, rawArguments, rawOptions);
4802
- const syncOptions = normalizeSyncOptions(rawOptions);
4803
- const { file, commandArguments, options } = normalizeOptions(rawFile, rawArguments, syncOptions);
4725
+ const { file, commandArguments, options } = normalizeOptions(rawFile, rawArguments, normalizeSyncOptions(rawOptions));
4804
4726
  validateSyncOptions(options);
4805
- const fileDescriptors = handleStdioSync(options, verboseInfo);
4806
4727
  return {
4807
4728
  file,
4808
4729
  commandArguments,
@@ -4811,7 +4732,7 @@ const handleSyncArguments = (rawFile, rawArguments, rawOptions) => {
4811
4732
  startTime,
4812
4733
  verboseInfo,
4813
4734
  options,
4814
- fileDescriptors
4735
+ fileDescriptors: handleStdioSync(options, verboseInfo)
4815
4736
  };
4816
4737
  };
4817
4738
  const normalizeSyncOptions = (options) => options.node && !options.ipc ? {
@@ -4846,16 +4767,14 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
4846
4767
  isMaxBuffer,
4847
4768
  verboseInfo
4848
4769
  });
4849
- const stdio = output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber));
4850
- const all = stripNewline(getAllSync(output, options), options, "all");
4851
4770
  return getSyncResult({
4852
4771
  error: error$1,
4853
4772
  exitCode,
4854
4773
  signal,
4855
4774
  timedOut,
4856
4775
  isMaxBuffer,
4857
- stdio,
4858
- all,
4776
+ stdio: output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber)),
4777
+ all: stripNewline(getAllSync(output, options), options, "all"),
4859
4778
  options,
4860
4779
  command,
4861
4780
  escapedCommand,
@@ -4865,8 +4784,7 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
4865
4784
  const runSubprocessSync = ({ file, commandArguments, options, command, escapedCommand, fileDescriptors, startTime }) => {
4866
4785
  try {
4867
4786
  addInputOptionsSync(fileDescriptors, options);
4868
- const normalizedOptions = normalizeSpawnSyncOptions(options);
4869
- return (0, node_child_process.spawnSync)(file, commandArguments, normalizedOptions);
4787
+ return (0, node_child_process.spawnSync)(file, commandArguments, normalizeSpawnSyncOptions(options));
4870
4788
  } catch (error$1) {
4871
4789
  return makeEarlyError({
4872
4790
  error: error$1,
@@ -5084,19 +5002,17 @@ const handleEarlyError = ({ error: error$1, command, escapedCommand, fileDescrip
5084
5002
  writable,
5085
5003
  duplex
5086
5004
  });
5087
- const earlyError = makeEarlyError({
5088
- error: error$1,
5089
- command,
5090
- escapedCommand,
5091
- fileDescriptors,
5092
- options,
5093
- startTime,
5094
- isSync: false
5095
- });
5096
- const promise = handleDummyPromise(earlyError, verboseInfo, options);
5097
5005
  return {
5098
5006
  subprocess,
5099
- promise
5007
+ promise: handleDummyPromise(makeEarlyError({
5008
+ error: error$1,
5009
+ command,
5010
+ escapedCommand,
5011
+ fileDescriptors,
5012
+ options,
5013
+ startTime,
5014
+ isSync: false
5015
+ }), verboseInfo, options)
5100
5016
  };
5101
5017
  };
5102
5018
  const createDummyStreams = (subprocess, fileDescriptors) => {
@@ -5145,8 +5061,7 @@ const addProperties = {
5145
5061
  nodeStream: ({ value }) => ({ stream: value }),
5146
5062
  webTransform({ value: { transform, writableObjectMode, readableObjectMode } }) {
5147
5063
  const objectMode = writableObjectMode || readableObjectMode;
5148
- const stream = node_stream.Duplex.fromWeb(transform, { objectMode });
5149
- return { stream };
5064
+ return { stream: node_stream.Duplex.fromWeb(transform, { objectMode }) };
5150
5065
  },
5151
5066
  duplex: ({ value: { transform } }) => ({ stream: transform }),
5152
5067
  native() {}
@@ -5392,10 +5307,7 @@ const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {
5392
5307
  controller
5393
5308
  });
5394
5309
  }
5395
- for (const [outputStream, inputStreams] of pipeGroups.entries()) {
5396
- const inputStream = inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams);
5397
- pipeStreams(inputStream, outputStream);
5398
- }
5310
+ for (const [outputStream, inputStreams] of pipeGroups.entries()) pipeStreams(inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams), outputStream);
5399
5311
  };
5400
5312
  const pipeTransform = (subprocess, stream, direction, fdNumber) => {
5401
5313
  if (direction === "output") pipeStreams(subprocess.stdio[fdNumber], stream);
@@ -5657,10 +5569,9 @@ const normalizePipeArguments = ({ source, sourcePromise, boundOptions, createNes
5657
5569
  const getDestinationStream = (boundOptions, createNested, pipeArguments) => {
5658
5570
  try {
5659
5571
  const { destination, pipeOptions: { from, to, unpipeSignal } = {} } = getDestination(boundOptions, createNested, ...pipeArguments);
5660
- const destinationStream = getToStream(destination, to);
5661
5572
  return {
5662
5573
  destination,
5663
- destinationStream,
5574
+ destinationStream: getToStream(destination, to),
5664
5575
  from,
5665
5576
  unpipeSignal
5666
5577
  };
@@ -5669,19 +5580,15 @@ const getDestinationStream = (boundOptions, createNested, pipeArguments) => {
5669
5580
  }
5670
5581
  };
5671
5582
  const getDestination = (boundOptions, createNested, firstArgument, ...pipeArguments) => {
5672
- if (Array.isArray(firstArgument)) {
5673
- const destination = createNested(mapDestinationArguments, boundOptions)(firstArgument, ...pipeArguments);
5674
- return {
5675
- destination,
5676
- pipeOptions: boundOptions
5677
- };
5678
- }
5583
+ if (Array.isArray(firstArgument)) return {
5584
+ destination: createNested(mapDestinationArguments, boundOptions)(firstArgument, ...pipeArguments),
5585
+ pipeOptions: boundOptions
5586
+ };
5679
5587
  if (typeof firstArgument === "string" || firstArgument instanceof URL || isDenoExecPath(firstArgument)) {
5680
5588
  if (Object.keys(boundOptions).length > 0) throw new TypeError("Please use .pipe(\"file\", ..., options) or .pipe(execa(\"file\", ..., options)) instead of .pipe(options)(\"file\", ...).");
5681
5589
  const [rawFile, rawArguments, rawOptions] = normalizeParameters(firstArgument, ...pipeArguments);
5682
- const destination = createNested(mapDestinationArguments)(rawFile, rawArguments, rawOptions);
5683
5590
  return {
5684
- destination,
5591
+ destination: createNested(mapDestinationArguments)(rawFile, rawArguments, rawOptions),
5685
5592
  pipeOptions: rawOptions
5686
5593
  };
5687
5594
  }
@@ -5701,8 +5608,7 @@ const mapDestinationArguments = ({ options }) => ({ options: {
5701
5608
  } });
5702
5609
  const getSourceStream = (source, from) => {
5703
5610
  try {
5704
- const sourceStream = getFromStream(source, from);
5705
- return { sourceStream };
5611
+ return { sourceStream: getFromStream(source, from) };
5706
5612
  } catch (error$1) {
5707
5613
  return { sourceError: error$1 };
5708
5614
  }
@@ -5796,9 +5702,8 @@ const unpipeOnAbort = (unpipeSignal, unpipeContext) => unpipeSignal === void 0 ?
5796
5702
  const unpipeOnSignalAbort = async (unpipeSignal, { sourceStream, mergedStream, fileDescriptors, sourceOptions, startTime }) => {
5797
5703
  await (0, node_util.aborted)(unpipeSignal, sourceStream);
5798
5704
  await mergedStream.remove(sourceStream);
5799
- const error$1 = /* @__PURE__ */ new Error("Pipe canceled by `unpipeSignal` option.");
5800
5705
  throw createNonCommandError({
5801
- error: error$1,
5706
+ error: /* @__PURE__ */ new Error("Pipe canceled by `unpipeSignal` option."),
5802
5707
  fileDescriptors,
5803
5708
  sourceOptions,
5804
5709
  startTime
@@ -5901,13 +5806,12 @@ const stopReadingOnStreamEnd = async (onStreamEnd, controller, stream) => {
5901
5806
  }
5902
5807
  };
5903
5808
  const iterateOnStream = ({ stream, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines }) => {
5904
- const onStdoutChunk = (0, node_events.on)(stream, "data", {
5905
- signal: controller.signal,
5906
- highWaterMark: HIGH_WATER_MARK,
5907
- highWatermark: HIGH_WATER_MARK
5908
- });
5909
5809
  return iterateOnData({
5910
- onStdoutChunk,
5810
+ onStdoutChunk: (0, node_events.on)(stream, "data", {
5811
+ signal: controller.signal,
5812
+ highWaterMark: HIGH_WATER_MARK,
5813
+ highWatermark: HIGH_WATER_MARK
5814
+ }),
5911
5815
  controller,
5912
5816
  binary,
5913
5817
  shouldEncode,
@@ -5952,13 +5856,12 @@ const getStreamOutput = async ({ stream, onStreamEnd, fdNumber, encoding, buffer
5952
5856
  await Promise.all([resumeStream(stream), logPromise]);
5953
5857
  return;
5954
5858
  }
5955
- const stripFinalNewlineValue = getStripFinalNewline(stripFinalNewline$1, fdNumber);
5956
5859
  const iterable = iterateForResult({
5957
5860
  stream,
5958
5861
  onStreamEnd,
5959
5862
  lines,
5960
5863
  encoding,
5961
- stripFinalNewline: stripFinalNewlineValue,
5864
+ stripFinalNewline: getStripFinalNewline(stripFinalNewline$1, fdNumber),
5962
5865
  allMixed
5963
5866
  });
5964
5867
  const [output] = await Promise.all([getStreamContents({
@@ -5978,15 +5881,14 @@ const logOutputAsync = async ({ stream, onStreamEnd, fdNumber, encoding, allMixe
5978
5881
  verboseInfo,
5979
5882
  fdNumber
5980
5883
  })) return;
5981
- const linesIterable = iterateForResult({
5884
+ await logLines(iterateForResult({
5982
5885
  stream,
5983
5886
  onStreamEnd,
5984
5887
  lines: true,
5985
5888
  encoding,
5986
5889
  stripFinalNewline: true,
5987
5890
  allMixed
5988
- });
5989
- await logLines(linesIterable, stream, fdNumber, verboseInfo);
5891
+ }), stream, fdNumber, verboseInfo);
5990
5892
  };
5991
5893
  const resumeStream = async (stream) => {
5992
5894
  await (0, node_timers_promises.setImmediate)();
@@ -6136,10 +6038,9 @@ const getAllMixed = ({ all, stdout, stderr }) => all && stdout && stderr && stdo
6136
6038
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/ipc.js
6137
6039
  const shouldLogIpc = (verboseInfo) => isFullVerbose(verboseInfo, "ipc");
6138
6040
  const logIpcOutput = (message, verboseInfo) => {
6139
- const verboseMessage = serializeVerboseMessage(message);
6140
6041
  verboseLog({
6141
6042
  type: "ipc",
6142
- verboseMessage,
6043
+ verboseMessage: serializeVerboseMessage(message),
6143
6044
  fdNumber: "ipc",
6144
6045
  verboseInfo
6145
6046
  });
@@ -6282,9 +6183,8 @@ const addConcurrentStream = (concurrentStreams, stream, waitName) => {
6282
6183
  const promises = weakMap.get(stream);
6283
6184
  const promise = createDeferred();
6284
6185
  promises.push(promise);
6285
- const resolve = promise.resolve.bind(promise);
6286
6186
  return {
6287
- resolve,
6187
+ resolve: promise.resolve.bind(promise),
6288
6188
  promises
6289
6189
  };
6290
6190
  };
@@ -6365,10 +6265,9 @@ const createReadable = ({ subprocess, concurrentStreams, encoding }, { from, bin
6365
6265
  };
6366
6266
  const getSubprocessStdout = (subprocess, from, concurrentStreams) => {
6367
6267
  const subprocessStdout = getFromStream(subprocess, from);
6368
- const waitReadableDestroy = addConcurrentStream(concurrentStreams, subprocessStdout, "readableDestroy");
6369
6268
  return {
6370
6269
  subprocessStdout,
6371
- waitReadableDestroy
6270
+ waitReadableDestroy: addConcurrentStream(concurrentStreams, subprocessStdout, "readableDestroy")
6372
6271
  };
6373
6272
  };
6374
6273
  const getReadableOptions = ({ readableEncoding, readableObjectMode, readableHighWaterMark }, binary) => binary ? {
@@ -6446,12 +6345,10 @@ const createWritable = ({ subprocess, concurrentStreams }, { to } = {}) => {
6446
6345
  };
6447
6346
  const getSubprocessStdin = (subprocess, to, concurrentStreams) => {
6448
6347
  const subprocessStdin = getToStream(subprocess, to);
6449
- const waitWritableFinal = addConcurrentStream(concurrentStreams, subprocessStdin, "writableFinal");
6450
- const waitWritableDestroy = addConcurrentStream(concurrentStreams, subprocessStdin, "writableDestroy");
6451
6348
  return {
6452
6349
  subprocessStdin,
6453
- waitWritableFinal,
6454
- waitWritableDestroy
6350
+ waitWritableFinal: addConcurrentStream(concurrentStreams, subprocessStdin, "writableFinal"),
6351
+ waitWritableDestroy: addConcurrentStream(concurrentStreams, subprocessStdin, "writableDestroy")
6455
6352
  };
6456
6353
  };
6457
6354
  const getWritableMethods = (subprocessStdin, subprocess, waitWritableFinal) => ({
@@ -6547,15 +6444,14 @@ const onDuplexDestroy = async ({ subprocessStdout, subprocessStdin, subprocess,
6547
6444
  const createIterable = (subprocess, encoding, { from, binary: binaryOption = false, preserveNewlines = false } = {}) => {
6548
6445
  const binary = binaryOption || BINARY_ENCODINGS.has(encoding);
6549
6446
  const subprocessStdout = getFromStream(subprocess, from);
6550
- const onStdoutData = iterateOnSubprocessStream({
6447
+ return iterateOnStdoutData(iterateOnSubprocessStream({
6551
6448
  subprocessStdout,
6552
6449
  subprocess,
6553
6450
  binary,
6554
6451
  shouldEncode: true,
6555
6452
  encoding,
6556
6453
  preserveNewlines
6557
- });
6558
- return iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);
6454
+ }), subprocessStdout, subprocess);
6559
6455
  };
6560
6456
  const iterateOnStdoutData = async function* (onStdoutData, subprocessStdout, subprocess) {
6561
6457
  try {
@@ -6637,7 +6533,6 @@ const handleAsyncArguments = (rawFile, rawArguments, rawOptions) => {
6637
6533
  const { command, escapedCommand, startTime, verboseInfo } = handleCommand(rawFile, rawArguments, rawOptions);
6638
6534
  const { file, commandArguments, options: normalizedOptions } = normalizeOptions(rawFile, rawArguments, rawOptions);
6639
6535
  const options = handleAsyncOptions(normalizedOptions);
6640
- const fileDescriptors = handleStdioAsync(options, verboseInfo);
6641
6536
  return {
6642
6537
  file,
6643
6538
  commandArguments,
@@ -6646,7 +6541,7 @@ const handleAsyncArguments = (rawFile, rawArguments, rawOptions) => {
6646
6541
  startTime,
6647
6542
  verboseInfo,
6648
6543
  options,
6649
- fileDescriptors
6544
+ fileDescriptors: handleStdioAsync(options, verboseInfo)
6650
6545
  };
6651
6546
  };
6652
6547
  const handleAsyncOptions = ({ timeout, signal,...options }) => {
@@ -6719,22 +6614,19 @@ const handlePromise = async ({ subprocess, options, startTime, verboseInfo, file
6719
6614
  });
6720
6615
  controller.abort();
6721
6616
  onInternalError.resolve();
6722
- const stdio = stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber));
6723
- const all = stripNewline(allResult, options, "all");
6724
- const result = getAsyncResult({
6617
+ return handleResult(getAsyncResult({
6725
6618
  errorInfo,
6726
6619
  exitCode,
6727
6620
  signal,
6728
- stdio,
6729
- all,
6621
+ stdio: stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber)),
6622
+ all: stripNewline(allResult, options, "all"),
6730
6623
  ipcOutput,
6731
6624
  context,
6732
6625
  options,
6733
6626
  command,
6734
6627
  escapedCommand,
6735
6628
  startTime
6736
- });
6737
- return handleResult(result, verboseInfo, options);
6629
+ }), verboseInfo, options);
6738
6630
  };
6739
6631
  const getAsyncResult = ({ errorInfo, exitCode, signal, stdio, all, ipcOutput, context, options, command, escapedCommand, startTime }) => "error" in errorInfo ? makeError({
6740
6632
  error: errorInfo.error,
@@ -6807,8 +6699,7 @@ const callBoundExeca = ({ mapArguments, deepOptions = {}, boundOptions = {}, set
6807
6699
  return isSync ? execaCoreSync(file, commandArguments, options) : execaCoreAsync(file, commandArguments, options, createNested);
6808
6700
  };
6809
6701
  const parseArguments = ({ mapArguments, firstArgument, nextArguments, deepOptions, boundOptions }) => {
6810
- const callArguments = isTemplateString(firstArgument) ? parseTemplates(firstArgument, nextArguments) : [firstArgument, ...nextArguments];
6811
- const [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments);
6702
+ const [initialFile, initialArguments, initialOptions] = normalizeParameters(...isTemplateString(firstArgument) ? parseTemplates(firstArgument, nextArguments) : [firstArgument, ...nextArguments]);
6812
6703
  const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions);
6813
6704
  const { file = initialFile, commandArguments = initialArguments, options = mergedOptions, isSync = false } = mapArguments({
6814
6705
  file: initialFile,
@@ -6880,22 +6771,6 @@ const execaNode = createExeca(mapNode);
6880
6771
  const $ = createExeca(mapScriptAsync, {}, deepScriptOptions, setScriptSync);
6881
6772
  const { sendMessage, getOneMessage, getEachMessage, getCancelSignal } = getIpcExport();
6882
6773
 
6883
- //#endregion
6884
- //#region src/utils/createWrangler.ts
6885
- const createWrangler = ({ stdio, accountId, cloudflareApiToken, cwd }) => {
6886
- const $$1 = execa({
6887
- stdio,
6888
- extendsEnv: true,
6889
- shell: stdio === "inherit",
6890
- cwd,
6891
- env: {
6892
- CLOUDFLARE_ACCOUNT_ID: accountId,
6893
- CLOUDFLARE_API_TOKEN: cloudflareApiToken
6894
- }
6895
- });
6896
- return (...command) => $$1("npx", ["wrangler", ...command]);
6897
- };
6898
-
6899
6774
  //#endregion
6900
6775
  //#region ../../node_modules/.pnpm/mime@4.0.4/node_modules/mime/dist/types/other.js
6901
6776
  const types$1 = {
@@ -8200,8 +8075,7 @@ var Mime = class {
8200
8075
  const last = path$10.replace(/^.*[/\\]/, "").toLowerCase();
8201
8076
  const ext = last.replace(/^.*\./, "").toLowerCase();
8202
8077
  const hasPath = last.length < path$10.length;
8203
- const hasDot = ext.length < last.length - 1;
8204
- if (!hasDot && hasPath) return null;
8078
+ if (!(ext.length < last.length - 1) && hasPath) return null;
8205
8079
  return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
8206
8080
  }
8207
8081
  getExtension(type) {
@@ -8235,6 +8109,22 @@ var Mime_default = Mime;
8235
8109
  //#region ../../node_modules/.pnpm/mime@4.0.4/node_modules/mime/dist/src/index.js
8236
8110
  var src_default = new Mime_default(standard_default, other_default)._freeze();
8237
8111
 
8112
+ //#endregion
8113
+ //#region src/utils/createWrangler.ts
8114
+ const createWrangler = ({ stdio, accountId, cloudflareApiToken, cwd }) => {
8115
+ const $$1 = execa({
8116
+ stdio,
8117
+ extendsEnv: true,
8118
+ shell: stdio === "inherit",
8119
+ cwd,
8120
+ env: {
8121
+ CLOUDFLARE_ACCOUNT_ID: accountId,
8122
+ CLOUDFLARE_API_TOKEN: cloudflareApiToken
8123
+ }
8124
+ });
8125
+ return (...command) => $$1("npx", ["wrangler", ...command]);
8126
+ };
8127
+
8238
8128
  //#endregion
8239
8129
  //#region src/r2Storage.ts
8240
8130
  const r2Storage = (config, hooks) => (_) => {
@@ -8252,14 +8142,13 @@ const r2Storage = (config, hooks) => (_) => {
8252
8142
  try {
8253
8143
  await wrangler("r2", "object", "delete", [bucketName, Key].join("/"), "--remote");
8254
8144
  return { storageUri: `r2://${bucketName}/${Key}` };
8255
- } catch (error$1) {
8145
+ } catch {
8256
8146
  throw new Error("Can not delete bundle");
8257
8147
  }
8258
8148
  },
8259
8149
  async uploadBundle(bundleId, bundlePath) {
8260
8150
  const contentType = src_default.getType(bundlePath) ?? void 0;
8261
- const filename = path.default.basename(bundlePath);
8262
- const Key = getStorageKey(bundleId, filename);
8151
+ const Key = getStorageKey(bundleId, path.default.basename(bundlePath));
8263
8152
  try {
8264
8153
  const { stderr, exitCode } = await wrangler("r2", "object", "put", [bucketName, Key].join("/"), "--file", bundlePath, ...contentType ? ["--content-type", contentType] : [], "--remote");
8265
8154
  if (exitCode !== 0 && stderr) throw new Error(stderr);