@hot-updater/cloudflare 1.0.0-rc.0 → 1.0.0-rc.14

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.
@@ -6,7 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
10
  var __copyProps = (to, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
12
  key = keys[i];
@@ -17,21 +17,21 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
21
21
  value: mod,
22
22
  enumerable: true
23
23
  }) : target, mod));
24
24
  //#endregion
25
25
  let crypto = require("crypto");
26
- crypto = __toESM(crypto);
26
+ crypto = __toESM(crypto, 1);
27
27
  let fs_promises = require("fs/promises");
28
- fs_promises = __toESM(fs_promises);
28
+ fs_promises = __toESM(fs_promises, 1);
29
29
  let path = require("path");
30
- path = __toESM(path);
30
+ path = __toESM(path, 1);
31
31
  let _hot_updater_cli_tools = require("@hot-updater/cli-tools");
32
32
  let _hot_updater_server = require("@hot-updater/server");
33
33
  let cloudflare = require("cloudflare");
34
- cloudflare = __toESM(cloudflare);
34
+ cloudflare = __toESM(cloudflare, 1);
35
35
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
36
36
  let _hot_updater_plugin_core_internal = require("@hot-updater/plugin-core/internal");
37
37
  let node_url = require("node:url");
@@ -39,13 +39,13 @@ let node_child_process = require("node:child_process");
39
39
  let node_string_decoder = require("node:string_decoder");
40
40
  let node_util = require("node:util");
41
41
  let node_process = require("node:process");
42
- node_process = __toESM(node_process);
42
+ node_process = __toESM(node_process, 1);
43
43
  let node_tty = require("node:tty");
44
- node_tty = __toESM(node_tty);
44
+ node_tty = __toESM(node_tty, 1);
45
45
  let node_path = require("node:path");
46
- node_path = __toESM(node_path);
46
+ node_path = __toESM(node_path, 1);
47
47
  let fs = require("fs");
48
- fs = __toESM(fs);
48
+ fs = __toESM(fs, 1);
49
49
  let node_timers_promises = require("node:timers/promises");
50
50
  let node_os = require("node:os");
51
51
  let node_events = require("node:events");
@@ -56,7 +56,7 @@ let node_stream = require("node:stream");
56
56
  let node_buffer = require("node:buffer");
57
57
  let cloudflare_error = require("cloudflare/error");
58
58
  let os = require("os");
59
- os = __toESM(os);
59
+ os = __toESM(os, 1);
60
60
  //#region src/d1Rows.ts
61
61
  var InvalidD1RowError = class extends Error {
62
62
  name = "InvalidD1RowError";
@@ -142,14 +142,15 @@ const eventRow = (row) => {
142
142
  const type = stringValue(row, "type", "bundle_events");
143
143
  const platform = stringValue(row, "platform", "bundle_events");
144
144
  const fromBundleId = nullableString(row, "from_bundle_id", "bundle_events");
145
- const updateStrategy = nullableString(row, "update_strategy", "bundle_events");
146
- if (platform !== "ios" && platform !== "android" || !((type === "UPDATE_APPLIED" || type === "RECOVERED" || type === "RELEASE_ADOPTED") && typeof fromBundleId === "string" && (updateStrategy === "fingerprint" || updateStrategy === "appVersion") || type === "UNCHANGED" && fromBundleId === null && updateStrategy === null)) throw new InvalidD1RowError("bundle_events");
145
+ const metadata = jsonValue(row["metadata"], "bundle_events");
146
+ if (!(0, _hot_updater_plugin_core.isDatabaseBundleEventMetadata)(metadata)) throw new InvalidD1RowError("bundle_events");
147
+ const updateStrategy = metadata.update_strategy;
148
+ if (platform !== "ios" && platform !== "android" || !((type === "UPDATE_DOWNLOADED" || type === "UPDATE_APPLIED" || type === "RECOVERED") && typeof fromBundleId === "string" && (updateStrategy === "fingerprint" || updateStrategy === "appVersion") || type === "UNCHANGED" && fromBundleId === null && updateStrategy === null)) throw new InvalidD1RowError("bundle_events");
147
149
  return {
148
150
  id: stringValue(row, "id", "bundle_events"),
149
151
  type,
150
152
  install_id: stringValue(row, "install_id", "bundle_events"),
151
153
  user_id: nullableString(row, "user_id", "bundle_events"),
152
- username: nullableString(row, "username", "bundle_events"),
153
154
  from_release_id: nullableString(row, "from_release_id", "bundle_events"),
154
155
  from_bundle_id: fromBundleId,
155
156
  to_release_id: nullableString(row, "to_release_id", "bundle_events"),
@@ -157,10 +158,7 @@ const eventRow = (row) => {
157
158
  platform,
158
159
  app_version: stringValue(row, "app_version", "bundle_events"),
159
160
  channel: stringValue(row, "channel", "bundle_events"),
160
- cohort: stringValue(row, "cohort", "bundle_events"),
161
- update_strategy: updateStrategy,
162
- fingerprint_hash: nullableString(row, "fingerprint_hash", "bundle_events"),
163
- sdk_version: nullableString(row, "sdk_version", "bundle_events"),
161
+ metadata,
164
162
  received_at_ms: numberValue(row, "received_at_ms", "bundle_events")
165
163
  };
166
164
  };
@@ -274,7 +272,8 @@ const stringPredicate = (condition, operator) => {
274
272
  };
275
273
  }
276
274
  const literal = escapeLikePattern(condition.value);
277
- const parameter = bind(operator === "contains" ? `%${literal}%` : operator === "starts_with" ? `${literal}%` : `%${literal}`);
275
+ const pattern = operator === "contains" ? `%${literal}%` : operator === "starts_with" ? `${literal}%` : `%${literal}`;
276
+ const parameter = bind(pattern);
278
277
  return {
279
278
  sql: `lower(${condition.field}) LIKE lower(${parameter.sql}) ESCAPE '\\'`,
280
279
  params: parameter.params
@@ -364,6 +363,7 @@ const d1TableNames = {
364
363
  releases: "releases"
365
364
  };
366
365
  var D1QueryResultError = class extends Error {
366
+ result;
367
367
  name = "D1QueryResultError";
368
368
  operation = "count";
369
369
  constructor(result) {
@@ -401,6 +401,12 @@ const findManyD1Rows = async (executor, input) => {
401
401
  };
402
402
  //#endregion
403
403
  //#region src/d1Implementation.ts
404
+ var D1ExecutionError = class extends Error {
405
+ name = "D1ExecutionError";
406
+ constructor() {
407
+ super("D1 did not successfully execute every requested statement");
408
+ }
409
+ };
404
410
  const EXPECTATION_CONFLICT_MARKER = "HOT_UPDATER_COMMIT_EXPECTATION_CONFLICT";
405
411
  const expectationGuard = (expectations) => {
406
412
  const clauses = [];
@@ -438,7 +444,8 @@ const expectationConflict = async (executor, expectations) => {
438
444
  const versionField = isRelease ? "revision" : "generation";
439
445
  const key = isRelease ? expectation.id : expectation.scopeKey;
440
446
  const expectedVersion = isRelease ? expectation.revision : expectation.generation;
441
- const actualVersion = readVersion((await executor.query(`SELECT ${versionField} FROM ${table} WHERE ${keyField} = json_extract(?, '$') LIMIT 1`, encodeD1Values([key])))[0], versionField);
447
+ const rows = await executor.query(`SELECT ${versionField} FROM ${table} WHERE ${keyField} = json_extract(?, '$') LIMIT 1`, encodeD1Values([key]));
448
+ const actualVersion = readVersion(rows[0], versionField);
442
449
  if (actualVersion !== expectedVersion) return {
443
450
  committed: false,
444
451
  conflict: {
@@ -522,9 +529,8 @@ const insertQuery = (input, guard, conflictMode = "returnExisting") => {
522
529
  case "releases":
523
530
  columns = Object.keys(input.data);
524
531
  values = Object.values(input.data);
525
- break;
526
532
  }
527
- const conflict = input.onConflict !== "ignore" ? "" : input.model === "channels" ? conflictMode === "ignore" ? " ON CONFLICT(name) DO NOTHING" : " ON CONFLICT(name) DO UPDATE SET name = excluded.name" : input.model === "api_keys" ? conflictMode === "ignore" ? " ON CONFLICT(hash) DO NOTHING" : " ON CONFLICT(hash) DO UPDATE SET hash = excluded.hash" : "";
533
+ const conflict = input.onConflict !== "ignore" ? "" : input.model === "channels" ? conflictMode === "ignore" ? " ON CONFLICT(name) DO NOTHING" : " ON CONFLICT(name) DO UPDATE SET name = excluded.name" : input.model === "api_keys" ? conflictMode === "ignore" ? " ON CONFLICT(hash) DO NOTHING" : " ON CONFLICT(hash) DO UPDATE SET hash = excluded.hash" : " ON CONFLICT(install_id) DO UPDATE SET install_id = excluded.install_id";
528
534
  return {
529
535
  sql: `INSERT INTO ${d1TableNames[input.model]} (${columns.join(", ")}) ${guard === void 0 ? `VALUES (${d1Placeholders(values.length)})` : `SELECT ${d1Placeholders(values.length)} WHERE ${guard.sql}`}${conflict} RETURNING *`,
530
536
  params: [...encodeD1Values(values), ...guard?.params ?? []]
@@ -588,9 +594,7 @@ const channelDeletePrecondition = (changes, changeIndex, channelId) => {
588
594
  releaseEffects.set(change.row.id, change.row.channel_id);
589
595
  break;
590
596
  case "update": break;
591
- case "delete":
592
- releaseEffects.set(change.where.id, null);
593
- break;
597
+ case "delete": releaseEffects.set(change.where.id, null);
594
598
  }
595
599
  }
596
600
  return {
@@ -665,10 +669,6 @@ const changeQuery = (change, guard) => {
665
669
  sql: `DELETE FROM channels WHERE id = json_extract(?, '$') AND NOT EXISTS (SELECT 1 FROM releases WHERE channel_id = json_extract(?, '$')) AND ${guard.sql}`,
666
670
  params: [...encodeD1Values([change.where.id, change.where.id]), ...guard.params]
667
671
  };
668
- case "analytics": return insertQuery({
669
- model: "bundle_events",
670
- data: change.row
671
- }, guard);
672
672
  case "apiKeys": return change.operation === "insert" ? insertQuery({
673
673
  model: "api_keys",
674
674
  data: change.row,
@@ -837,6 +837,41 @@ const deleteChannel = async (executor, input) => {
837
837
  };
838
838
  };
839
839
  const createD1Implementation = (executor) => ({
840
+ async recordInsights({ event }) {
841
+ const query = insertQuery({
842
+ model: "bundle_events",
843
+ data: event
844
+ });
845
+ await executor.batch([{
846
+ sql: query.sql.replace(" RETURNING *", " ON CONFLICT(id) DO NOTHING"),
847
+ params: query.params
848
+ }, {
849
+ sql: `INSERT INTO bundle_event_heads (install_id, id, received_at_ms, user_id, platform, channel, type, from_bundle_id, to_bundle_id)
850
+ SELECT install_id, id, received_at_ms, user_id, platform, channel, type, from_bundle_id, to_bundle_id
851
+ FROM bundle_events WHERE id = json_extract(?, '$')
852
+ ON CONFLICT(install_id) DO UPDATE SET
853
+ id = excluded.id, received_at_ms = excluded.received_at_ms, user_id = excluded.user_id,
854
+ platform = excluded.platform, channel = excluded.channel, type = excluded.type,
855
+ from_bundle_id = excluded.from_bundle_id, to_bundle_id = excluded.to_bundle_id
856
+ WHERE (excluded.received_at_ms, excluded.id) > (bundle_event_heads.received_at_ms, bundle_event_heads.id)`,
857
+ params: encodeD1Values([event.id])
858
+ }]);
859
+ },
860
+ async findLatestInsightsEvents(input) {
861
+ const where = buildD1Where((0, _hot_updater_plugin_core_internal.latestInsightsWhere)(input));
862
+ return (await executor.query(`SELECT event.* FROM (SELECT id, install_id FROM bundle_event_heads${where.sql} ORDER BY install_id ASC LIMIT json_extract(?, '$')) AS head JOIN bundle_events AS event ON event.id = head.id ORDER BY head.install_id ASC`, [...where.params, ...encodeD1Values(["installId" in input ? 1 : input.limit])])).map((row) => parseD1Row("bundle_events", row));
863
+ },
864
+ async countLatestInsightsEvents(input) {
865
+ const groups = (0, _hot_updater_plugin_core_internal.latestInsightsCountGroups)(input).map(buildD1Where);
866
+ const where = {
867
+ sql: ` WHERE (${groups.map((group) => `(${group.sql.replace(/^ WHERE /, "")})`).join(" OR ")})`,
868
+ params: groups.flatMap((group) => group.params)
869
+ };
870
+ const first = (await executor.query(`SELECT COUNT(*) AS count FROM bundle_event_heads${where.sql}`, where.params))[0];
871
+ const count = typeof first === "object" && first !== null ? Reflect.get(first, "count") : void 0;
872
+ if (typeof count !== "number") throw new Error("Invalid Insights count result.");
873
+ return count;
874
+ },
840
875
  async create(input) {
841
876
  const query = insertQuery(input);
842
877
  const rows = await executor.query(query.sql, query.params);
@@ -926,7 +961,11 @@ const d1Database = (config) => {
926
961
  };
927
962
  const page = await cloudflare$1.d1.database.query(config.databaseId, { ...body });
928
963
  const results = [];
929
- for await (const resultPage of page.iterPages()) for (const result of resultPage.result) results.push(result.results ?? []);
964
+ for await (const resultPage of page.iterPages()) for (const result of resultPage.result) {
965
+ if (result.success === false) throw new D1ExecutionError();
966
+ results.push(result.results ?? []);
967
+ }
968
+ if (results.length !== statements.length) throw new D1ExecutionError();
930
969
  return results;
931
970
  };
932
971
  const adapter = (0, _hot_updater_plugin_core_internal.createDatabasePluginAdapter)("d1Database", createD1Implementation({
@@ -1044,7 +1083,8 @@ const parseTemplate = ({ templates, expressions, tokens, index, template }) => {
1044
1083
  const newTokens = concatTokens(tokens, nextTokens, leadingWhitespaces);
1045
1084
  if (index === expressions.length) return newTokens;
1046
1085
  const expression = expressions[index];
1047
- return concatTokens(newTokens, Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)], trailingWhitespaces);
1086
+ const expressionTokens = Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)];
1087
+ return concatTokens(newTokens, expressionTokens, trailingWhitespaces);
1048
1088
  };
1049
1089
  const splitByWhitespaces = (template, rawTemplate) => {
1050
1090
  if (rawTemplate.length === 0) return {
@@ -1077,7 +1117,7 @@ const splitByWhitespaces = (template, rawTemplate) => {
1077
1117
  trailingWhitespaces
1078
1118
  };
1079
1119
  };
1080
- const DELIMITERS = new Set([
1120
+ const DELIMITERS = /* @__PURE__ */ new Set([
1081
1121
  " ",
1082
1122
  " ",
1083
1123
  "\r",
@@ -1129,7 +1169,8 @@ const normalizeFdSpecificOptions = (options) => {
1129
1169
  };
1130
1170
  const normalizeFdSpecificOption = (options, optionName) => {
1131
1171
  const optionBaseArray = Array.from({ length: getStdioLength(options) + 1 });
1132
- return addDefaultValue$1(normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName), optionName);
1172
+ const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);
1173
+ return addDefaultValue$1(optionArray, optionName);
1133
1174
  };
1134
1175
  const getStdioLength = ({ stdio }) => Array.isArray(stdio) ? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length) : STANDARD_STREAMS_ALIASES.length;
1135
1176
  const normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue) ? normalizeOptionObject(optionValue, optionArray, optionName) : optionArray.fill(optionValue);
@@ -1162,7 +1203,7 @@ const addDefaultValue$1 = (optionArray, optionName) => optionArray.map((optionVa
1162
1203
  const DEFAULT_OPTIONS = {
1163
1204
  lines: false,
1164
1205
  buffer: true,
1165
- maxBuffer: 1e3 * 1e3 * 100,
1206
+ maxBuffer: 1e8,
1166
1207
  verbose: (0, node_util.debuglog)("execa").enabled ? "full" : "none",
1167
1208
  stripFinalNewline: true
1168
1209
  };
@@ -1210,7 +1251,7 @@ const escapeControlCharacter = (character) => {
1210
1251
  };
1211
1252
  const getSpecialCharRegExp = () => {
1212
1253
  try {
1213
- return /* @__PURE__ */ new RegExp("\\p{Separator}|\\p{Other}", "gu");
1254
+ return new RegExp("\\p{Separator}|\\p{Other}", "gu");
1214
1255
  } catch {
1215
1256
  return /[\s\u0000-\u001F\u007F-\u009F\u00AD]/g;
1216
1257
  }
@@ -1630,11 +1671,13 @@ const appendNewline = (printedLine) => printedLine.endsWith("\n") ? printedLine
1630
1671
  //#endregion
1631
1672
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/log.js
1632
1673
  const verboseLog = ({ type, verboseMessage, fdNumber, verboseInfo, result }) => {
1633
- const finalLines = applyVerboseOnLines(getPrintedLines(verboseMessage, getVerboseObject({
1674
+ const verboseObject = getVerboseObject({
1634
1675
  type,
1635
1676
  result,
1636
1677
  verboseInfo
1637
- })), verboseInfo, fdNumber);
1678
+ });
1679
+ const printedLines = getPrintedLines(verboseMessage, verboseObject);
1680
+ const finalLines = applyVerboseOnLines(printedLines, verboseInfo, fdNumber);
1638
1681
  if (finalLines !== "") console.warn(finalLines.slice(0, -1));
1639
1682
  };
1640
1683
  const getVerboseObject = ({ type, result, verboseInfo: { escapedCommand, commandId, rawOptions: { piped = false, ...options } } }) => ({
@@ -1657,7 +1700,8 @@ const getPrintedLine = (verboseObject) => {
1657
1700
  };
1658
1701
  };
1659
1702
  const serializeVerboseMessage = (message) => {
1660
- return escapeLines(typeof message === "string" ? message : (0, node_util.inspect)(message)).replaceAll(" ", " ".repeat(TAB_SIZE));
1703
+ const messageString = typeof message === "string" ? message : (0, node_util.inspect)(message);
1704
+ return escapeLines(messageString).replaceAll(" ", " ".repeat(TAB_SIZE));
1661
1705
  };
1662
1706
  const TAB_SIZE = 2;
1663
1707
  //#endregion
@@ -1702,7 +1746,8 @@ const getDurationMs = (startTime) => Number(node_process.hrtime.bigint() - start
1702
1746
  const handleCommand = (filePath, rawArguments, rawOptions) => {
1703
1747
  const startTime = getStartTime();
1704
1748
  const { command, escapedCommand } = joinCommand(filePath, rawArguments);
1705
- const verboseInfo = getVerboseInfo(normalizeFdSpecificOption(rawOptions, "verbose"), escapedCommand, { ...rawOptions });
1749
+ const verbose = normalizeFdSpecificOption(rawOptions, "verbose");
1750
+ const verboseInfo = getVerboseInfo(verbose, escapedCommand, { ...rawOptions });
1706
1751
  logCommand(escapedCommand, verboseInfo);
1707
1752
  return {
1708
1753
  command,
@@ -1823,7 +1868,8 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1823
1868
  const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
1824
1869
  const getPathInfo = (cmd, opt) => {
1825
1870
  const colon = opt.colon || COLON;
1826
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH || "").split(colon)];
1871
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
1872
+ /* istanbul ignore next: very unusual */ "").split(colon)];
1827
1873
  const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
1828
1874
  const pathExt = isWindows ? pathExtExe.split(colon) : [""];
1829
1875
  if (isWindows) {
@@ -1848,14 +1894,17 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1848
1894
  const ppRaw = pathEnv[i];
1849
1895
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
1850
1896
  const pCmd = path$13.join(pathPart, cmd);
1851
- resolve(subStep(!pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd, i, 0));
1897
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
1898
+ resolve(subStep(p, i, 0));
1852
1899
  });
1853
1900
  const subStep = (p, i, ii) => new Promise((resolve, reject) => {
1854
1901
  if (ii === pathExt.length) return resolve(step(i + 1));
1855
1902
  const ext = pathExt[ii];
1856
1903
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
1857
- if (!er && is) if (opt.all) found.push(p + ext);
1858
- else return resolve(p + ext);
1904
+ if (!er && is) {
1905
+ if (opt.all) found.push(p + ext);
1906
+ else return resolve(p + ext);
1907
+ }
1859
1908
  return resolve(subStep(p, i, ii + 1));
1860
1909
  });
1861
1910
  });
@@ -1873,8 +1922,10 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1873
1922
  for (let j = 0; j < pathExt.length; j++) {
1874
1923
  const cur = p + pathExt[j];
1875
1924
  try {
1876
- if (isexe.sync(cur, { pathExt: pathExtExe })) if (opt.all) found.push(cur);
1877
- else return cur;
1925
+ if (isexe.sync(cur, { pathExt: pathExtExe })) {
1926
+ if (opt.all) found.push(cur);
1927
+ else return cur;
1928
+ }
1878
1929
  } catch (ex) {}
1879
1930
  }
1880
1931
  }
@@ -2565,7 +2616,7 @@ const normalizeForceKillAfterDelay = (forceKillAfterDelay) => {
2565
2616
  if (!Number.isFinite(forceKillAfterDelay) || forceKillAfterDelay < 0) throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${forceKillAfterDelay}\` (${typeof forceKillAfterDelay})`);
2566
2617
  return forceKillAfterDelay;
2567
2618
  };
2568
- const DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5;
2619
+ const DEFAULT_FORCE_KILL_TIMEOUT = 5e3;
2569
2620
  const subprocessKill = ({ kill, options: { forceKillAfterDelay, killSignal }, onInternalError, context, controller }, signalOrError, errorArgument) => {
2570
2621
  const { signal, error } = parseKillArguments(signalOrError, errorArgument, killSignal);
2571
2622
  emitKillError(error, onInternalError);
@@ -2667,7 +2718,7 @@ const handleSerializationError = ({ error, methodName, isSubprocess, message })
2667
2718
  if (isSerializationError(error)) throw new Error(`${getMethodName(methodName, isSubprocess)}'s argument type is invalid: the message cannot be serialized: ${String(message)}.`, { cause: error });
2668
2719
  };
2669
2720
  const isSerializationError = ({ code, message }) => SERIALIZATION_ERROR_CODES.has(code) || SERIALIZATION_ERROR_MESSAGES.some((serializationErrorMessage) => message.includes(serializationErrorMessage));
2670
- const SERIALIZATION_ERROR_CODES = new Set(["ERR_MISSING_ARGS", "ERR_INVALID_ARG_TYPE"]);
2721
+ const SERIALIZATION_ERROR_CODES = /* @__PURE__ */ new Set(["ERR_MISSING_ARGS", "ERR_INVALID_ARG_TYPE"]);
2671
2722
  const SERIALIZATION_ERROR_MESSAGES = [
2672
2723
  "could not be cloned",
2673
2724
  "circular structure",
@@ -2877,7 +2928,8 @@ const isConnected = (anyProcess) => {
2877
2928
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/ipc/strict.js
2878
2929
  const handleSendStrict = ({ anyProcess, channel, isSubprocess, message, strict }) => {
2879
2930
  if (!strict) return message;
2880
- const hasListeners = hasMessageListeners(anyProcess, getIpcEmitter(anyProcess, channel, isSubprocess));
2931
+ const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
2932
+ const hasListeners = hasMessageListeners(anyProcess, ipcEmitter);
2881
2933
  return {
2882
2934
  id: count++,
2883
2935
  type: REQUEST_TYPE,
@@ -3109,7 +3161,8 @@ const throwOnGracefulCancel = ({ subprocess, cancelSignal, gracefulCancel, force
3109
3161
  })] : [];
3110
3162
  const sendOnAbort = async ({ subprocess, cancelSignal, forceKillAfterDelay, context, controller: { signal } }) => {
3111
3163
  await onAbortedSignal(cancelSignal, signal);
3112
- await sendAbort(subprocess, getReason(cancelSignal));
3164
+ const reason = getReason(cancelSignal);
3165
+ await sendAbort(subprocess, reason);
3113
3166
  killOnTimeout({
3114
3167
  kill: subprocess.kill,
3115
3168
  forceKillAfterDelay,
@@ -3221,8 +3274,8 @@ Please rename it to ${serializeEncoding(correctEncoding)}.`);
3221
3274
  throw new TypeError(`Invalid option \`encoding: ${serializeEncoding(encoding)}\`.
3222
3275
  Please rename it to one of: ${correctEncodings}.`);
3223
3276
  };
3224
- const TEXT_ENCODINGS = new Set(["utf8", "utf16le"]);
3225
- const BINARY_ENCODINGS = new Set([
3277
+ const TEXT_ENCODINGS = /* @__PURE__ */ new Set(["utf8", "utf16le"]);
3278
+ const BINARY_ENCODINGS = /* @__PURE__ */ new Set([
3226
3279
  "buffer",
3227
3280
  "hex",
3228
3281
  "base64",
@@ -3230,7 +3283,7 @@ const BINARY_ENCODINGS = new Set([
3230
3283
  "latin1",
3231
3284
  "ascii"
3232
3285
  ]);
3233
- const ENCODINGS = new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);
3286
+ const ENCODINGS = /* @__PURE__ */ new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);
3234
3287
  const getCorrectEncoding = (encoding) => {
3235
3288
  if (encoding === null) return "buffer";
3236
3289
  if (typeof encoding !== "string") return;
@@ -3277,7 +3330,8 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
3277
3330
  rawOptions.cwd = normalizeCwd(rawOptions.cwd);
3278
3331
  const [processedFile, processedArguments, processedOptions] = handleNodeOption(filePath, rawArguments, rawOptions);
3279
3332
  const { command: file, args: commandArguments, options: initialOptions } = import_cross_spawn.default._parse(processedFile, processedArguments, processedOptions);
3280
- const options = addDefaultOptions(normalizeFdSpecificOptions(initialOptions));
3333
+ const fdOptions = normalizeFdSpecificOptions(initialOptions);
3334
+ const options = addDefaultOptions(fdOptions);
3281
3335
  validateTimeout(options);
3282
3336
  validateEncoding(options);
3283
3337
  validateIpcInputOption(options);
@@ -3478,14 +3532,17 @@ const getStreamContents$1 = async (stream, { init, convertChunk, getSize, trunca
3478
3532
  const state = init();
3479
3533
  state.length = 0;
3480
3534
  try {
3481
- for await (const chunk of asyncIterable) appendChunk({
3482
- convertedChunk: convertChunk[getChunkType(chunk)](chunk, state),
3483
- state,
3484
- getSize,
3485
- truncateChunk,
3486
- addChunk,
3487
- maxBuffer
3488
- });
3535
+ for await (const chunk of asyncIterable) {
3536
+ const convertedChunk = convertChunk[getChunkType(chunk)](chunk, state);
3537
+ appendChunk({
3538
+ convertedChunk,
3539
+ state,
3540
+ getSize,
3541
+ truncateChunk,
3542
+ addChunk,
3543
+ maxBuffer
3544
+ });
3545
+ }
3489
3546
  appendFinalChunk({
3490
3547
  state,
3491
3548
  convertChunk,
@@ -3771,7 +3828,8 @@ const getErrorPrefix = ({ originalError, timedOut, timeout, isMaxBuffer, maxBuff
3771
3828
  const getForcefulSuffix = (isForcefullyTerminated, forceKillAfterDelay) => isForcefullyTerminated ? ` and was forcefully terminated after ${forceKillAfterDelay} milliseconds` : "";
3772
3829
  const getOriginalMessage = (originalError, cwd) => {
3773
3830
  if (originalError instanceof DiscardedError) return;
3774
- const escapedOriginalMessage = escapeLines(fixCwdError(isExecaError(originalError) ? originalError.originalMessage : String(originalError?.message ?? originalError), cwd));
3831
+ const originalMessage = isExecaError(originalError) ? originalError.originalMessage : String(originalError?.message ?? originalError);
3832
+ const escapedOriginalMessage = escapeLines(fixCwdError(originalMessage, cwd));
3775
3833
  return escapedOriginalMessage === "" ? void 0 : escapedOriginalMessage;
3776
3834
  };
3777
3835
  const serializeIpcMessage = (ipcMessage) => typeof ipcMessage === "string" ? ipcMessage : (0, node_util.inspect)(ipcMessage);
@@ -3982,26 +4040,28 @@ function prettyMilliseconds(milliseconds, options) {
3982
4040
  add(Number(parsed.hours), "hour", "h");
3983
4041
  }
3984
4042
  add(Number(parsed.minutes), "minute", "m");
3985
- if (!options.hideSeconds) if (options.separateMilliseconds || options.formatSubMilliseconds || !options.colonNotation && milliseconds < 1e3 && !options.subSecondsAsDecimals) {
3986
- const seconds = Number(parsed.seconds);
3987
- const milliseconds = Number(parsed.milliseconds);
3988
- const microseconds = Number(parsed.microseconds);
3989
- const nanoseconds = Number(parsed.nanoseconds);
3990
- add(seconds, "second", "s");
3991
- if (options.formatSubMilliseconds) {
3992
- add(milliseconds, "millisecond", "ms");
3993
- add(microseconds, "microsecond", "µs");
3994
- add(nanoseconds, "nanosecond", "ns");
4043
+ if (!options.hideSeconds) {
4044
+ if (options.separateMilliseconds || options.formatSubMilliseconds || !options.colonNotation && milliseconds < 1e3 && !options.subSecondsAsDecimals) {
4045
+ const seconds = Number(parsed.seconds);
4046
+ const milliseconds = Number(parsed.milliseconds);
4047
+ const microseconds = Number(parsed.microseconds);
4048
+ const nanoseconds = Number(parsed.nanoseconds);
4049
+ add(seconds, "second", "s");
4050
+ if (options.formatSubMilliseconds) {
4051
+ add(milliseconds, "millisecond", "ms");
4052
+ add(microseconds, "microsecond", "µs");
4053
+ add(nanoseconds, "nanosecond", "ns");
4054
+ } else {
4055
+ const millisecondsAndBelow = milliseconds + microseconds / 1e3 + nanoseconds / 1e6;
4056
+ const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === "number" ? options.millisecondsDecimalDigits : 0;
4057
+ const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
4058
+ add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
4059
+ }
3995
4060
  } else {
3996
- const millisecondsAndBelow = milliseconds + microseconds / 1e3 + nanoseconds / 1e6;
3997
- const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === "number" ? options.millisecondsDecimalDigits : 0;
3998
- const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
3999
- add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
4061
+ const secondsFixed = floorDecimals((isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60, typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1);
4062
+ const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, "");
4063
+ add(Number.parseFloat(secondsString), "second", "s", secondsString);
4000
4064
  }
4001
- } else {
4002
- const secondsFixed = floorDecimals((isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60, typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1);
4003
- const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, "");
4004
- add(Number.parseFloat(secondsString), "second", "s", secondsString);
4005
4065
  }
4006
4066
  if (result.length === 0) return sign + "0" + (options.verbose ? " milliseconds" : "ms");
4007
4067
  const separator = options.colonNotation ? ":" : " ";
@@ -4026,9 +4086,10 @@ const logResult = (result, verboseInfo) => {
4026
4086
  logDuration(result, verboseInfo);
4027
4087
  };
4028
4088
  const logDuration = (result, verboseInfo) => {
4089
+ const verboseMessage = `(done in ${prettyMilliseconds(result.durationMs)})`;
4029
4090
  verboseLog({
4030
4091
  type: "duration",
4031
- verboseMessage: `(done in ${prettyMilliseconds(result.durationMs)})`,
4092
+ verboseMessage,
4032
4093
  verboseInfo,
4033
4094
  result
4034
4095
  });
@@ -4096,10 +4157,10 @@ const isTransformOptions = (value) => isPlainObject(value) && (value.transform !
4096
4157
  const isUrl = (value) => Object.prototype.toString.call(value) === "[object URL]";
4097
4158
  const isRegularUrl = (value) => isUrl(value) && value.protocol !== "file:";
4098
4159
  const isFilePathObject = (value) => isPlainObject(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => FILE_PATH_KEYS.has(key)) && isFilePathString(value.file);
4099
- const FILE_PATH_KEYS = new Set(["file", "append"]);
4160
+ const FILE_PATH_KEYS = /* @__PURE__ */ new Set(["file", "append"]);
4100
4161
  const isFilePathString = (file) => typeof file === "string";
4101
4162
  const isUnknownStdioString = (type, value) => type === "native" && typeof value === "string" && !KNOWN_STDIO_STRINGS.has(value);
4102
- const KNOWN_STDIO_STRINGS = new Set([
4163
+ const KNOWN_STDIO_STRINGS = /* @__PURE__ */ new Set([
4103
4164
  "ipc",
4104
4165
  "ignore",
4105
4166
  "inherit",
@@ -4113,24 +4174,24 @@ const isTransformStream = (value) => isReadableStream(value?.readable) && isWrit
4113
4174
  const isAsyncIterableObject = (value) => isObject(value) && typeof value[Symbol.asyncIterator] === "function";
4114
4175
  const isIterableObject = (value) => isObject(value) && typeof value[Symbol.iterator] === "function";
4115
4176
  const isObject = (value) => typeof value === "object" && value !== null;
4116
- const TRANSFORM_TYPES = new Set([
4177
+ const TRANSFORM_TYPES = /* @__PURE__ */ new Set([
4117
4178
  "generator",
4118
4179
  "asyncGenerator",
4119
4180
  "duplex",
4120
4181
  "webTransform"
4121
4182
  ]);
4122
- const FILE_TYPES = new Set([
4183
+ const FILE_TYPES = /* @__PURE__ */ new Set([
4123
4184
  "fileUrl",
4124
4185
  "filePath",
4125
4186
  "fileNumber"
4126
4187
  ]);
4127
- const SPECIAL_DUPLICATE_TYPES_SYNC = new Set(["fileUrl", "filePath"]);
4128
- const SPECIAL_DUPLICATE_TYPES = new Set([
4188
+ const SPECIAL_DUPLICATE_TYPES_SYNC = /* @__PURE__ */ new Set(["fileUrl", "filePath"]);
4189
+ const SPECIAL_DUPLICATE_TYPES = /* @__PURE__ */ new Set([
4129
4190
  ...SPECIAL_DUPLICATE_TYPES_SYNC,
4130
4191
  "webStream",
4131
4192
  "nodeStream"
4132
4193
  ]);
4133
- const FORBID_DUPLICATE_TYPES = new Set(["webTransform", "duplex"]);
4194
+ const FORBID_DUPLICATE_TYPES = /* @__PURE__ */ new Set(["webTransform", "duplex"]);
4134
4195
  const TYPE_TO_MESSAGE = {
4135
4196
  generator: "a generator",
4136
4197
  asyncGenerator: "an async generator",
@@ -4463,7 +4524,8 @@ const validateDuplicateStreamSync = ({ otherStdioItems, type, value, optionName,
4463
4524
  const getDuplicateStreamInstance = ({ otherStdioItems, type, value, optionName, direction }) => {
4464
4525
  const duplicateStdioItems = otherStdioItems.filter((stdioItem) => hasSameValue(stdioItem, value));
4465
4526
  if (duplicateStdioItems.length === 0) return;
4466
- throwOnDuplicateStream(duplicateStdioItems.find((stdioItem) => stdioItem.direction !== direction), optionName, type);
4527
+ const differentStdioItem = duplicateStdioItems.find((stdioItem) => stdioItem.direction !== direction);
4528
+ throwOnDuplicateStream(differentStdioItem, optionName, type);
4467
4529
  return direction === "output" ? duplicateStdioItems[0].stream : void 0;
4468
4530
  };
4469
4531
  const hasSameValue = ({ type, value }, secondValue) => {
@@ -4472,7 +4534,8 @@ const hasSameValue = ({ type, value }, secondValue) => {
4472
4534
  return value === secondValue;
4473
4535
  };
4474
4536
  const validateDuplicateTransform = ({ otherStdioItems, type, value, optionName }) => {
4475
- throwOnDuplicateStream(otherStdioItems.find(({ value: { transform } }) => transform === value.transform), optionName, type);
4537
+ const duplicateStdioItem = otherStdioItems.find(({ value: { transform } }) => transform === value.transform);
4538
+ throwOnDuplicateStream(duplicateStdioItem, optionName, type);
4476
4539
  };
4477
4540
  const throwOnDuplicateStream = (stdioItem, optionName, type) => {
4478
4541
  if (stdioItem !== void 0) throw new TypeError(`The \`${stdioItem.optionName}\` and \`${optionName}\` options must not target ${TYPE_TO_MESSAGE[type]} that is the same.`);
@@ -4480,13 +4543,14 @@ const throwOnDuplicateStream = (stdioItem, optionName, type) => {
4480
4543
  //#endregion
4481
4544
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/stdio/handle.js
4482
4545
  const handleStdio = (addProperties, options, verboseInfo, isSync) => {
4546
+ const initialFileDescriptors = normalizeStdioOption(options, verboseInfo, isSync).map((stdioOption, fdNumber) => getFileDescriptor({
4547
+ stdioOption,
4548
+ fdNumber,
4549
+ options,
4550
+ isSync
4551
+ }));
4483
4552
  const fileDescriptors = getFinalFileDescriptors({
4484
- initialFileDescriptors: normalizeStdioOption(options, verboseInfo, isSync).map((stdioOption, fdNumber) => getFileDescriptor({
4485
- stdioOption,
4486
- fdNumber,
4487
- options,
4488
- isSync
4489
- })),
4553
+ initialFileDescriptors,
4490
4554
  addProperties,
4491
4555
  options,
4492
4556
  isSync
@@ -4503,13 +4567,14 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
4503
4567
  optionName
4504
4568
  });
4505
4569
  const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);
4506
- const normalizedStdioItems = normalizeTransforms(initialStdioItems.map((stdioItem) => handleNativeStream({
4570
+ const stdioItems = initialStdioItems.map((stdioItem) => handleNativeStream({
4507
4571
  stdioItem,
4508
4572
  isStdioArray,
4509
4573
  fdNumber,
4510
4574
  direction,
4511
4575
  isSync
4512
- })), optionName, direction, options);
4576
+ }));
4577
+ const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);
4513
4578
  const objectMode = getFdObjectMode(normalizedStdioItems, direction);
4514
4579
  validateFileObjectMode(normalizedStdioItems, objectMode);
4515
4580
  return {
@@ -4519,7 +4584,8 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
4519
4584
  };
4520
4585
  };
4521
4586
  const initializeStdioItems = ({ stdioOption, fdNumber, options, optionName }) => {
4522
- const stdioItems = filterDuplicates([...(Array.isArray(stdioOption) ? stdioOption : [stdioOption]).map((value) => initializeStdioItem(value, optionName)), ...handleInputOptions(options, fdNumber)]);
4587
+ const initialStdioItems = [...(Array.isArray(stdioOption) ? stdioOption : [stdioOption]).map((value) => initializeStdioItem(value, optionName)), ...handleInputOptions(options, fdNumber)];
4588
+ const stdioItems = filterDuplicates(initialStdioItems);
4523
4589
  const isStdioArray = stdioItems.length > 1;
4524
4590
  validateStdioArray(stdioItems, isStdioArray, optionName);
4525
4591
  validateStreams(stdioItems);
@@ -4538,7 +4604,7 @@ const validateStdioArray = (stdioItems, isStdioArray, optionName) => {
4538
4604
  if (!isStdioArray) return;
4539
4605
  for (const { value, optionName } of stdioItems) if (INVALID_STDIO_ARRAY_OPTIONS.has(value)) throw new Error(`The \`${optionName}\` option must not include \`${value}\`.`);
4540
4606
  };
4541
- const INVALID_STDIO_ARRAY_OPTIONS = new Set(["ignore", "ipc"]);
4607
+ const INVALID_STDIO_ARRAY_OPTIONS = /* @__PURE__ */ new Set(["ignore", "ipc"]);
4542
4608
  const validateStreams = (stdioItems) => {
4543
4609
  for (const stdioItem of stdioItems) validateFileStdio(stdioItem);
4544
4610
  };
@@ -4867,7 +4933,10 @@ const generatorToStream = ({ value, value: { transform, final, writableObjectMod
4867
4933
  const runGeneratorsSync = (chunks, stdioItems, encoding, isInput) => {
4868
4934
  const generators = stdioItems.filter(({ type }) => type === "generator");
4869
4935
  const reversedGenerators = isInput ? generators.reverse() : generators;
4870
- for (const { value, optionName } of reversedGenerators) chunks = runTransformSync(addInternalGenerators(value, encoding, optionName), chunks);
4936
+ for (const { value, optionName } of reversedGenerators) {
4937
+ const generators = addInternalGenerators(value, encoding, optionName);
4938
+ chunks = runTransformSync(generators, chunks);
4939
+ }
4871
4940
  return chunks;
4872
4941
  };
4873
4942
  const addInternalGenerators = ({ transform, final, binary, writableObjectMode, readableObjectMode, preserveNewlines }, encoding, optionName) => {
@@ -4903,7 +4972,8 @@ const addInputOptionSync = (fileDescriptors, fdNumber, options) => {
4903
4972
  const [{ type, optionName }] = allStdioItems;
4904
4973
  throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);
4905
4974
  }
4906
- options.input = joinToUint8Array(allStdioItems.map(({ contents }) => contents).map((contents) => applySingleInputGeneratorsSync(contents, stdioItems)));
4975
+ const transformedContents = allStdioItems.map(({ contents }) => contents).map((contents) => applySingleInputGeneratorsSync(contents, stdioItems));
4976
+ options.input = joinToUint8Array(transformedContents);
4907
4977
  };
4908
4978
  const applySingleInputGeneratorsSync = (contents, stdioItems) => {
4909
4979
  const newContents = runGeneratorsSync(contents, stdioItems, "utf8", true);
@@ -4918,7 +4988,7 @@ const validateSerializable = (newContents) => {
4918
4988
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/output.js
4919
4989
  const shouldLogOutput = ({ stdioItems, encoding, verboseInfo, fdNumber }) => fdNumber !== "all" && isFullVerbose(verboseInfo, fdNumber) && !BINARY_ENCODINGS.has(encoding) && fdUsesVerbose(fdNumber) && (stdioItems.some(({ type, value }) => type === "native" && PIPED_STDIO_VALUES.has(value)) || stdioItems.every(({ type }) => TRANSFORM_TYPES.has(type)));
4920
4990
  const fdUsesVerbose = (fdNumber) => fdNumber === 1 || fdNumber === 2;
4921
- const PIPED_STDIO_VALUES = new Set(["pipe", "overlapped"]);
4991
+ const PIPED_STDIO_VALUES = /* @__PURE__ */ new Set(["pipe", "overlapped"]);
4922
4992
  const logLines = async (linesIterable, stream, fdNumber, verboseInfo) => {
4923
4993
  for await (const line of linesIterable) if (!isPipingStream(stream)) logLine(line, fdNumber, verboseInfo);
4924
4994
  };
@@ -4927,9 +4997,10 @@ const logLinesSync = (linesArray, fdNumber, verboseInfo) => {
4927
4997
  };
4928
4998
  const isPipingStream = (stream) => stream._readableState.pipes.length > 0;
4929
4999
  const logLine = (line, fdNumber, verboseInfo) => {
5000
+ const verboseMessage = serializeVerboseMessage(line);
4930
5001
  verboseLog({
4931
5002
  type: "output",
4932
- verboseMessage: serializeVerboseMessage(line),
5003
+ verboseMessage,
4933
5004
  fdNumber,
4934
5005
  verboseInfo
4935
5006
  });
@@ -4955,10 +5026,12 @@ const transformOutputSync = ({ fileDescriptors, syncResult: { output }, options,
4955
5026
  };
4956
5027
  const transformOutputResultSync = ({ result, fileDescriptors, fdNumber, state, outputFiles, isMaxBuffer, verboseInfo }, { buffer, encoding, lines, stripFinalNewline, maxBuffer }) => {
4957
5028
  if (result === null) return;
4958
- const uint8ArrayResult = bufferToUint8Array(truncateMaxBufferSync(result, isMaxBuffer, maxBuffer));
5029
+ const truncatedResult = truncateMaxBufferSync(result, isMaxBuffer, maxBuffer);
5030
+ const uint8ArrayResult = bufferToUint8Array(truncatedResult);
4959
5031
  const { stdioItems, objectMode } = fileDescriptors[fdNumber];
5032
+ const chunks = runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state);
4960
5033
  const { serializedResult, finalResult = serializedResult } = serializeChunks({
4961
- chunks: runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state),
5034
+ chunks,
4962
5035
  objectMode,
4963
5036
  encoding,
4964
5037
  lines,
@@ -5082,7 +5155,7 @@ const getResultError = (error, exitCode, signal) => {
5082
5155
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/methods/main-sync.js
5083
5156
  const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
5084
5157
  const { file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors } = handleSyncArguments(rawFile, rawArguments, rawOptions);
5085
- return handleResult(spawnSubprocessSync({
5158
+ const result = spawnSubprocessSync({
5086
5159
  file,
5087
5160
  commandArguments,
5088
5161
  options,
@@ -5091,11 +5164,13 @@ const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
5091
5164
  verboseInfo,
5092
5165
  fileDescriptors,
5093
5166
  startTime
5094
- }), verboseInfo, options);
5167
+ });
5168
+ return handleResult(result, verboseInfo, options);
5095
5169
  };
5096
5170
  const handleSyncArguments = (rawFile, rawArguments, rawOptions) => {
5097
5171
  const { command, escapedCommand, startTime, verboseInfo } = handleCommand(rawFile, rawArguments, rawOptions);
5098
- const { file, commandArguments, options } = normalizeOptions(rawFile, rawArguments, normalizeSyncOptions(rawOptions));
5172
+ const syncOptions = normalizeSyncOptions(rawOptions);
5173
+ const { file, commandArguments, options } = normalizeOptions(rawFile, rawArguments, syncOptions);
5099
5174
  validateSyncOptions(options);
5100
5175
  return {
5101
5176
  file,
@@ -5140,14 +5215,16 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
5140
5215
  isMaxBuffer,
5141
5216
  verboseInfo
5142
5217
  });
5218
+ const stdio = output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber));
5219
+ const all = stripNewline(getAllSync(output, options), options, "all");
5143
5220
  return getSyncResult({
5144
5221
  error,
5145
5222
  exitCode,
5146
5223
  signal,
5147
5224
  timedOut,
5148
5225
  isMaxBuffer,
5149
- stdio: output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber)),
5150
- all: stripNewline(getAllSync(output, options), options, "all"),
5226
+ stdio,
5227
+ all,
5151
5228
  options,
5152
5229
  command,
5153
5230
  escapedCommand,
@@ -5157,7 +5234,8 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
5157
5234
  const runSubprocessSync = ({ file, commandArguments, options, command, escapedCommand, fileDescriptors, startTime }) => {
5158
5235
  try {
5159
5236
  addInputOptionsSync(fileDescriptors, options);
5160
- return (0, node_child_process.spawnSync)(file, commandArguments, normalizeSpawnSyncOptions(options));
5237
+ const normalizedOptions = normalizeSpawnSyncOptions(options);
5238
+ return (0, node_child_process.spawnSync)(file, commandArguments, normalizedOptions);
5161
5239
  } catch (error) {
5162
5240
  return makeEarlyError({
5163
5241
  error,
@@ -5371,17 +5449,18 @@ const handleEarlyError = ({ error, command, escapedCommand, fileDescriptors, opt
5371
5449
  writable,
5372
5450
  duplex
5373
5451
  });
5452
+ const earlyError = makeEarlyError({
5453
+ error,
5454
+ command,
5455
+ escapedCommand,
5456
+ fileDescriptors,
5457
+ options,
5458
+ startTime,
5459
+ isSync: false
5460
+ });
5374
5461
  return {
5375
5462
  subprocess,
5376
- promise: handleDummyPromise(makeEarlyError({
5377
- error,
5378
- command,
5379
- escapedCommand,
5380
- fileDescriptors,
5381
- options,
5382
- startTime,
5383
- isSync: false
5384
- }), verboseInfo, options)
5463
+ promise: handleDummyPromise(earlyError, verboseInfo, options)
5385
5464
  };
5386
5465
  };
5387
5466
  const createDummyStreams = (subprocess, fileDescriptors) => {
@@ -5565,8 +5644,10 @@ const endWhenStreamsDone = async ({ passThroughStream, stream, streams, ended, a
5565
5644
  controller.abort();
5566
5645
  updateMaxListeners(passThroughStream, -PASSTHROUGH_LISTENERS_PER_STREAM);
5567
5646
  }
5568
- if (streams.size > 0 && streams.size === ended.size + aborted.size) if (ended.size === 0 && aborted.size > 0) abortStream(passThroughStream);
5569
- else endStream(passThroughStream);
5647
+ if (streams.size > 0 && streams.size === ended.size + aborted.size) {
5648
+ if (ended.size === 0 && aborted.size > 0) abortStream(passThroughStream);
5649
+ else endStream(passThroughStream);
5650
+ }
5570
5651
  };
5571
5652
  const afterMergedStreamFinished = async (onFinished, stream, { signal }) => {
5572
5653
  try {
@@ -5672,7 +5753,10 @@ const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {
5672
5753
  controller
5673
5754
  });
5674
5755
  }
5675
- for (const [outputStream, inputStreams] of pipeGroups.entries()) pipeStreams(inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams), outputStream);
5756
+ for (const [outputStream, inputStreams] of pipeGroups.entries()) {
5757
+ const inputStream = inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams);
5758
+ pipeStreams(inputStream, outputStream);
5759
+ }
5676
5760
  };
5677
5761
  const pipeTransform = (subprocess, stream, direction, fdNumber) => {
5678
5762
  if (direction === "output") pipeStreams(subprocess.stdio[fdNumber], stream);
@@ -6161,12 +6245,13 @@ const stopReadingOnStreamEnd = async (onStreamEnd, controller, stream) => {
6161
6245
  }
6162
6246
  };
6163
6247
  const iterateOnStream = ({ stream, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines }) => {
6248
+ const onStdoutChunk = (0, node_events.on)(stream, "data", {
6249
+ signal: controller.signal,
6250
+ highWaterMark: HIGH_WATER_MARK,
6251
+ highWatermark: HIGH_WATER_MARK
6252
+ });
6164
6253
  return iterateOnData({
6165
- onStdoutChunk: (0, node_events.on)(stream, "data", {
6166
- signal: controller.signal,
6167
- highWaterMark: HIGH_WATER_MARK,
6168
- highWatermark: HIGH_WATER_MARK
6169
- }),
6254
+ onStdoutChunk,
6170
6255
  controller,
6171
6256
  binary,
6172
6257
  shouldEncode,
@@ -6210,12 +6295,13 @@ const getStreamOutput = async ({ stream, onStreamEnd, fdNumber, encoding, buffer
6210
6295
  await Promise.all([resumeStream(stream), logPromise]);
6211
6296
  return;
6212
6297
  }
6298
+ const stripFinalNewlineValue = getStripFinalNewline(stripFinalNewline, fdNumber);
6213
6299
  const iterable = iterateForResult({
6214
6300
  stream,
6215
6301
  onStreamEnd,
6216
6302
  lines,
6217
6303
  encoding,
6218
- stripFinalNewline: getStripFinalNewline(stripFinalNewline, fdNumber),
6304
+ stripFinalNewline: stripFinalNewlineValue,
6219
6305
  allMixed
6220
6306
  });
6221
6307
  const [output] = await Promise.all([getStreamContents({
@@ -6235,14 +6321,15 @@ const logOutputAsync = async ({ stream, onStreamEnd, fdNumber, encoding, allMixe
6235
6321
  verboseInfo,
6236
6322
  fdNumber
6237
6323
  })) return;
6238
- await logLines(iterateForResult({
6324
+ const linesIterable = iterateForResult({
6239
6325
  stream,
6240
6326
  onStreamEnd,
6241
6327
  lines: true,
6242
6328
  encoding,
6243
6329
  stripFinalNewline: true,
6244
6330
  allMixed
6245
- }), stream, fdNumber, verboseInfo);
6331
+ });
6332
+ await logLines(linesIterable, stream, fdNumber, verboseInfo);
6246
6333
  };
6247
6334
  const resumeStream = async (stream) => {
6248
6335
  await (0, node_timers_promises.setImmediate)();
@@ -6388,9 +6475,10 @@ const getAllMixed = ({ all, stdout, stderr }) => all && stdout && stderr && stdo
6388
6475
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/ipc.js
6389
6476
  const shouldLogIpc = (verboseInfo) => isFullVerbose(verboseInfo, "ipc");
6390
6477
  const logIpcOutput = (message, verboseInfo) => {
6478
+ const verboseMessage = serializeVerboseMessage(message);
6391
6479
  verboseLog({
6392
6480
  type: "ipc",
6393
- verboseMessage: serializeVerboseMessage(message),
6481
+ verboseMessage,
6394
6482
  fdNumber: "ipc",
6395
6483
  verboseInfo
6396
6484
  });
@@ -6786,14 +6874,15 @@ const onDuplexDestroy = async ({ subprocessStdout, subprocessStdin, subprocess,
6786
6874
  const createIterable = (subprocess, encoding, { from, binary: binaryOption = false, preserveNewlines = false } = {}) => {
6787
6875
  const binary = binaryOption || BINARY_ENCODINGS.has(encoding);
6788
6876
  const subprocessStdout = getFromStream(subprocess, from);
6789
- return iterateOnStdoutData(iterateOnSubprocessStream({
6877
+ const onStdoutData = iterateOnSubprocessStream({
6790
6878
  subprocessStdout,
6791
6879
  subprocess,
6792
6880
  binary,
6793
6881
  shouldEncode: true,
6794
6882
  encoding,
6795
6883
  preserveNewlines
6796
- }), subprocessStdout, subprocess);
6884
+ });
6885
+ return iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);
6797
6886
  };
6798
6887
  const iterateOnStdoutData = async function* (onStdoutData, subprocessStdout, subprocess) {
6799
6888
  try {
@@ -6953,19 +7042,22 @@ const handlePromise = async ({ subprocess, options, startTime, verboseInfo, file
6953
7042
  });
6954
7043
  controller.abort();
6955
7044
  onInternalError.resolve();
6956
- return handleResult(getAsyncResult({
7045
+ const stdio = stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber));
7046
+ const all = stripNewline(allResult, options, "all");
7047
+ const result = getAsyncResult({
6957
7048
  errorInfo,
6958
7049
  exitCode,
6959
7050
  signal,
6960
- stdio: stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber)),
6961
- all: stripNewline(allResult, options, "all"),
7051
+ stdio,
7052
+ all,
6962
7053
  ipcOutput,
6963
7054
  context,
6964
7055
  options,
6965
7056
  command,
6966
7057
  escapedCommand,
6967
7058
  startTime
6968
- }), verboseInfo, options);
7059
+ });
7060
+ return handleResult(result, verboseInfo, options);
6969
7061
  };
6970
7062
  const getAsyncResult = ({ errorInfo, exitCode, signal, stdio, all, ipcOutput, context, options, command, escapedCommand, startTime }) => "error" in errorInfo ? makeError({
6971
7063
  error: errorInfo.error,
@@ -7009,7 +7101,7 @@ const mergeOption = (optionName, boundOptionValue, optionValue) => {
7009
7101
  };
7010
7102
  return optionValue;
7011
7103
  };
7012
- const DEEP_OPTIONS = new Set(["env", ...FD_SPECIFIC_OPTIONS]);
7104
+ const DEEP_OPTIONS = /* @__PURE__ */ new Set(["env", ...FD_SPECIFIC_OPTIONS]);
7013
7105
  //#endregion
7014
7106
  //#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/methods/create.js
7015
7107
  const createExeca = (mapArguments, boundOptions, deepOptions, setBoundExeca) => {
@@ -7036,7 +7128,8 @@ const callBoundExeca = ({ mapArguments, deepOptions = {}, boundOptions = {}, set
7036
7128
  return isSync ? execaCoreSync(file, commandArguments, options) : execaCoreAsync(file, commandArguments, options, createNested);
7037
7129
  };
7038
7130
  const parseArguments = ({ mapArguments, firstArgument, nextArguments, deepOptions, boundOptions }) => {
7039
- const [initialFile, initialArguments, initialOptions] = normalizeParameters(...isTemplateString(firstArgument) ? parseTemplates(firstArgument, nextArguments) : [firstArgument, ...nextArguments]);
7131
+ const callArguments = isTemplateString(firstArgument) ? parseTemplates(firstArgument, nextArguments) : [firstArgument, ...nextArguments];
7132
+ const [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments);
7040
7133
  const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions);
7041
7134
  const { file = initialFile, commandArguments = initialArguments, options = mergedOptions, isSync = false } = mapArguments({
7042
7135
  file: initialFile,
@@ -7150,6 +7243,8 @@ const isCloudflareAuthenticationError = (error) => {
7150
7243
  ].some((pattern) => pattern.test(getErrorOutput(error)));
7151
7244
  };
7152
7245
  var CloudflareAuthenticationError = class extends _hot_updater_cli_tools.InitError {
7246
+ source;
7247
+ accountId;
7153
7248
  name = "CloudflareAuthenticationError";
7154
7249
  constructor(source, accountId, options) {
7155
7250
  super([
@@ -7164,6 +7259,7 @@ var CloudflareAuthenticationError = class extends _hot_updater_cli_tools.InitErr
7164
7259
  }
7165
7260
  };
7166
7261
  var CloudflarePermissionError = class extends _hot_updater_cli_tools.InitError {
7262
+ source;
7167
7263
  name = "CloudflarePermissionError";
7168
7264
  constructor(source, { accountId, check, requiredPermission }, options) {
7169
7265
  super([
@@ -9302,12 +9398,14 @@ var require_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9302
9398
  s2 = peg$FAILED;
9303
9399
  if (peg$silentFails === 0) peg$fail(peg$c39);
9304
9400
  }
9305
- if (s2 === peg$FAILED) if (input.charCodeAt(peg$currPos) === 69) {
9306
- s2 = peg$c40;
9307
- peg$currPos++;
9308
- } else {
9309
- s2 = peg$FAILED;
9310
- if (peg$silentFails === 0) peg$fail(peg$c41);
9401
+ if (s2 === peg$FAILED) {
9402
+ if (input.charCodeAt(peg$currPos) === 69) {
9403
+ s2 = peg$c40;
9404
+ peg$currPos++;
9405
+ } else {
9406
+ s2 = peg$FAILED;
9407
+ if (peg$silentFails === 0) peg$fail(peg$c41);
9408
+ }
9311
9409
  }
9312
9410
  if (s2 !== peg$FAILED) {
9313
9411
  s3 = peg$parseinteger_text();
@@ -10476,12 +10574,14 @@ var require_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10476
10574
  s11 = peg$FAILED;
10477
10575
  if (peg$silentFails === 0) peg$fail(peg$c48);
10478
10576
  }
10479
- if (s11 === peg$FAILED) if (input.charCodeAt(peg$currPos) === 43) {
10480
- s11 = peg$c44;
10481
- peg$currPos++;
10482
- } else {
10483
- s11 = peg$FAILED;
10484
- if (peg$silentFails === 0) peg$fail(peg$c45);
10577
+ if (s11 === peg$FAILED) {
10578
+ if (input.charCodeAt(peg$currPos) === 43) {
10579
+ s11 = peg$c44;
10580
+ peg$currPos++;
10581
+ } else {
10582
+ s11 = peg$FAILED;
10583
+ if (peg$silentFails === 0) peg$fail(peg$c45);
10584
+ }
10485
10585
  }
10486
10586
  if (s11 !== peg$FAILED) {
10487
10587
  s12 = peg$parseDIGIT_OR_UNDER();
@@ -11238,9 +11338,7 @@ var require_compiler = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11238
11338
  case "ObjectPath":
11239
11339
  setPath(node);
11240
11340
  break;
11241
- case "ArrayPath":
11242
- addTableArray(node);
11243
- break;
11341
+ case "ArrayPath": addTableArray(node);
11244
11342
  }
11245
11343
  }
11246
11344
  return data;
@@ -11320,9 +11418,10 @@ var require_compiler = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11320
11418
  var key = keys[i];
11321
11419
  traversed.push(key);
11322
11420
  traversedPath = traversed.join(".");
11323
- if (typeof ctx[key] === "undefined") if (i === keys.length - 1) ctx[key] = value;
11324
- else ctx[key] = Object.create(null);
11325
- else if (i !== keys.length - 1 && valueAssignments.indexOf(traversedPath) > -1) genError("Cannot redefine existing key '" + traversedPath + "'.", line, column);
11421
+ if (typeof ctx[key] === "undefined") {
11422
+ if (i === keys.length - 1) ctx[key] = value;
11423
+ else ctx[key] = Object.create(null);
11424
+ } else if (i !== keys.length - 1 && valueAssignments.indexOf(traversedPath) > -1) genError("Cannot redefine existing key '" + traversedPath + "'.", line, column);
11326
11425
  ctx = ctx[key];
11327
11426
  if (ctx instanceof Array && ctx.length && i < keys.length - 1) ctx = ctx[ctx.length - 1];
11328
11427
  }
@@ -12115,7 +12214,7 @@ const inputCloudflareInitSecrets = async ({ accountId, bucketName, apiToken, acc
12115
12214
  }, { onCancel: () => process.exit(1) });
12116
12215
  };
12117
12216
  //#endregion
12118
- //#region iac/index.ts
12217
+ //#region iac/configTemplate.ts
12119
12218
  const getConfigScaffold = (build) => {
12120
12219
  return (0, _hot_updater_cli_tools.createHotUpdaterConfigScaffoldFromBuilder)(new _hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage({
12121
12220
  imports: [{
@@ -12142,6 +12241,8 @@ const getConfigScaffold = (build) => {
12142
12241
  })`
12143
12242
  }));
12144
12243
  };
12244
+ //#endregion
12245
+ //#region iac/index.ts
12145
12246
  const SOURCE_TEMPLATE = `// add this to your App.tsx
12146
12247
  import { HotUpdater } from "@hot-updater/react-native";
12147
12248
 
@@ -12162,7 +12263,8 @@ export default App;`;
12162
12263
  const deployWorker = async (apiToken, accountId, { credentialSource, d1DatabaseId, d1DatabaseName, nonInteractive, r2BucketName, workerName }) => {
12163
12264
  const cwd = (0, _hot_updater_cli_tools.getCwd)();
12164
12265
  const cloudflarePackagePath = require.resolve("@hot-updater/cloudflare/package.json", { paths: [cwd] });
12165
- const { tmpDir, removeTmpDir } = await (0, _hot_updater_cli_tools.copyDirToTmp)(path.default.dirname(cloudflarePackagePath));
12266
+ const cloudflarePackageRoot = path.default.dirname(cloudflarePackagePath);
12267
+ const { tmpDir, removeTmpDir } = await (0, _hot_updater_cli_tools.copyDirToTmp)(cloudflarePackageRoot);
12166
12268
  const workerRoot = path.default.join(tmpDir, "worker");
12167
12269
  try {
12168
12270
  const wranglerConfig = JSON.parse(await fs_promises.default.readFile(path.default.join(workerRoot, "wrangler.json"), "utf-8"));
@@ -12432,13 +12534,16 @@ const runInit = async ({ build, envFile }) => {
12432
12534
  for await (const resultPage of page.iterPages()) for (const result of resultPage.result) rows.push(...result.results ?? []);
12433
12535
  return rows;
12434
12536
  };
12435
- if (!createD1Database) assertCloudflareInfrastructureCanInitialize((await queryD1(`
12537
+ if (!createD1Database) {
12538
+ const tables = await queryD1(`
12436
12539
  SELECT name
12437
12540
  FROM sqlite_schema
12438
12541
  WHERE type = 'table'
12439
12542
  AND name IN ('bundles', 'release_catalogs')
12440
12543
  ORDER BY name
12441
- `)).flatMap(({ name }) => typeof name === "string" ? [name] : []), d1DatabaseName);
12544
+ `);
12545
+ assertCloudflareInfrastructureCanInitialize(tables.flatMap(({ name }) => typeof name === "string" ? [name] : []), d1DatabaseName);
12546
+ }
12442
12547
  const workerScripts = await runCloudflareApiRequest({
12443
12548
  request: () => cf.workers.scripts.list({ account_id: accountId }),
12444
12549
  source: infrastructureCredentialSource
@@ -12465,13 +12570,14 @@ const runInit = async ({ build, envFile }) => {
12465
12570
  secretAccessKey,
12466
12571
  workerName
12467
12572
  };
12573
+ const persistCredentialInputs = await (0, _hot_updater_cli_tools.confirmInitInputPersistence)({
12574
+ existingEnv: managedEnv,
12575
+ inputs: resolvedInputs,
12576
+ nonInteractive,
12577
+ provider: initProvider
12578
+ });
12468
12579
  await (0, _hot_updater_cli_tools.makeEnv)({ ...(0, _hot_updater_cli_tools.getInitProviderEnvVars)({
12469
- includeConsentInputs: await (0, _hot_updater_cli_tools.confirmInitInputPersistence)({
12470
- existingEnv: managedEnv,
12471
- inputs: resolvedInputs,
12472
- nonInteractive,
12473
- provider: initProvider
12474
- }),
12580
+ includeConsentInputs: persistCredentialInputs,
12475
12581
  inputs: resolvedInputs,
12476
12582
  provider: initProvider
12477
12583
  }) });