@incajs/cli 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/{src/adapterCore.d.mts → adapterCore.d.mts} +1 -0
  2. package/dist/{src/build.d.mts → build.d.mts} +1 -1
  3. package/dist/cli.js +627 -659
  4. package/dist/{src/defaultBundler.d.mts → defaultBundler.d.mts} +2 -2
  5. package/dist/{src/dev.d.mts → dev.d.mts} +1 -1
  6. package/dist/{src/package.d.mts → package.d.mts} +1 -1
  7. package/dist/{src/adapter/types.d.mts → types.d.mts} +1 -1
  8. package/dist/{src/adapter/vite → vite}/build.d.mts +1 -2
  9. package/dist/{src/adapter/vite → vite}/captureOutput.d.mts +1 -2
  10. package/dist/{src/adapter/vite → vite}/config.d.mts +1 -1
  11. package/dist/{src/adapter/vite → vite}/createBundler.d.mts +1 -2
  12. package/dist/{src/adapter/vite → vite}/hmr.d.mts +9 -2
  13. package/dist/{src/adapter/vite → vite}/unsupported.d.mts +1 -1
  14. package/dist/{src/adapter/vite → vite}/watch.d.mts +1 -2
  15. package/dist/{hmr-runtime.js → vite-runtime.js} +11 -10
  16. package/package.json +7 -6
  17. /package/dist/{src/cli.d.mts → cli.d.mts} +0 -0
  18. /package/dist/{src/config → config}/defaults.d.mts +0 -0
  19. /package/dist/{src/config → config}/index.d.mts +0 -0
  20. /package/dist/{src/config → config}/loader.d.mts +0 -0
  21. /package/dist/{src/config → config}/types.d.mts +0 -0
  22. /package/dist/{src/dev-client → dev-client}/hostBin.d.mts +0 -0
  23. /package/dist/{src/dev-client → dev-client}/hostClient.d.mts +0 -0
  24. /package/dist/{src/dev-client → dev-client}/hostError.d.mts +0 -0
  25. /package/dist/{src/dev-client → dev-client}/index.d.mts +0 -0
  26. /package/dist/{src/dev-client → dev-client}/protocol.d.mts +0 -0
  27. /package/dist/{src/devLock.d.mts → devLock.d.mts} +0 -0
  28. /package/dist/{src/entry.d.mts → entry.d.mts} +0 -0
  29. /package/dist/{src/error.d.mts → error.d.mts} +0 -0
  30. /package/dist/{src/index.d.mts → index.d.mts} +0 -0
  31. /package/dist/{src/log.d.mts → log.d.mts} +0 -0
  32. /package/dist/{src/macosApp.d.mts → macosApp.d.mts} +0 -0
  33. /package/dist/{src/plist.d.mts → plist.d.mts} +0 -0
  34. /package/dist/{src/retryOnEdit.d.mts → retryOnEdit.d.mts} +0 -0
  35. /package/dist/{src/adapter/vite → vite}/emitConfig.d.mts +0 -0
  36. /package/dist/{src/adapter/vite → vite}/index.d.mts +0 -0
  37. /package/dist/{src/adapter/vite → vite}/logger.d.mts +0 -0
  38. /package/dist/{src/watchForEdit.d.mts → watchForEdit.d.mts} +0 -0
package/dist/cli.js CHANGED
@@ -7,27 +7,27 @@ import * as ee from "node:util";
7
7
  import { parseArgs as x, styleText as S } from "node:util";
8
8
  import { chmod as C, cp as w, link as T, mkdir as E, readFile as D, readdir as te, rm as O, writeFile as k } from "node:fs/promises";
9
9
  import { fileURLToPath as ne, pathToFileURL as re } from "node:url";
10
- import { homedir as A } from "node:os";
11
- import { DevEnvironment as ie, build as ae, buildErrorMessage as oe, createServer as se } from "vite";
12
- import ce from "@vitejs/plugin-vue";
13
- import { createRequire as le } from "node:module";
14
- import { spawn as ue } from "node:child_process";
15
- import { once as j } from "node:events";
16
- import de from "node:readline";
17
- import { setTimeout as fe } from "node:timers/promises";
18
- import { randomUUID as pe } from "node:crypto";
10
+ import { homedir as ie } from "node:os";
11
+ import { createRequire as ae } from "node:module";
12
+ import { spawn as oe } from "node:child_process";
13
+ import { once as A } from "node:events";
14
+ import se from "node:readline";
15
+ import { setTimeout as ce } from "node:timers/promises";
16
+ import { DevEnvironment as le, build as ue, buildErrorMessage as de, createServer as fe } from "vite";
17
+ import pe from "@vitejs/plugin-vue";
18
+ import { randomUUID as me } from "node:crypto";
19
19
  //#region ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/_chunks/libs/scule.mjs
20
- var me = /\d/, he = [
20
+ var he = /\d/, ge = [
21
21
  "-",
22
22
  "_",
23
23
  "/",
24
24
  "."
25
25
  ];
26
- function ge(e = "") {
27
- if (!me.test(e)) return e !== e.toLowerCase();
26
+ function _e(e = "") {
27
+ if (!he.test(e)) return e !== e.toLowerCase();
28
28
  }
29
- function _e(e, t) {
30
- let n = t ?? he, r = [];
29
+ function ve(e, t) {
30
+ let n = t ?? ge, r = [];
31
31
  if (!e || typeof e != "string") return r;
32
32
  let i = "", a, o;
33
33
  for (let t of e) {
@@ -36,7 +36,7 @@ function _e(e, t) {
36
36
  r.push(i), i = "", a = void 0;
37
37
  continue;
38
38
  }
39
- let s = ge(t);
39
+ let s = _e(t);
40
40
  if (o === !1) {
41
41
  if (a === !1 && s === !0) {
42
42
  r.push(i), i = t, a = s;
@@ -52,44 +52,44 @@ function _e(e, t) {
52
52
  }
53
53
  return r.push(i), r;
54
54
  }
55
- function ve(e) {
55
+ function ye(e) {
56
56
  return e ? e[0].toUpperCase() + e.slice(1) : "";
57
57
  }
58
- function ye(e) {
58
+ function be(e) {
59
59
  return e ? e[0].toLowerCase() + e.slice(1) : "";
60
60
  }
61
- function be(e, t) {
62
- return e ? (Array.isArray(e) ? e : _e(e)).map((e) => ve(t?.normalize ? e.toLowerCase() : e)).join("") : "";
61
+ function xe(e, t) {
62
+ return e ? (Array.isArray(e) ? e : ve(e)).map((e) => ye(t?.normalize ? e.toLowerCase() : e)).join("") : "";
63
63
  }
64
- function M(e, t) {
65
- return ye(be(e || "", t));
64
+ function j(e, t) {
65
+ return be(xe(e || "", t));
66
66
  }
67
- function N(e, t) {
68
- return e ? (Array.isArray(e) ? e : _e(e)).map((e) => e.toLowerCase()).join(t ?? "-") : "";
67
+ function Se(e, t) {
68
+ return e ? (Array.isArray(e) ? e : ve(e)).map((e) => e.toLowerCase()).join(t ?? "-") : "";
69
69
  }
70
- function xe(e) {
71
- return N(e || "", "_");
70
+ function Ce(e) {
71
+ return Se(e || "", "_");
72
72
  }
73
73
  //#endregion
74
74
  //#region ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/index.mjs
75
- function P(e) {
75
+ function M(e) {
76
76
  return Array.isArray(e) ? e : e === void 0 ? [] : [e];
77
77
  }
78
- function F(e, t = "") {
78
+ function we(e, t = "") {
79
79
  let n = [];
80
80
  for (let t of e) for (let [e, r] of t.entries()) n[e] = Math.max(n[e] || 0, r.length);
81
81
  return e.map((e) => e.map((e, r) => t + e[r === 0 ? "padStart" : "padEnd"](n[r])).join(" ")).join("\n");
82
82
  }
83
- function I(e) {
83
+ function N(e) {
84
84
  return typeof e == "function" ? e() : e;
85
85
  }
86
- var L = class extends Error {
86
+ var P = class extends Error {
87
87
  code;
88
88
  constructor(e, t) {
89
89
  super(e), this.name = "CLIError", this.code = t;
90
90
  }
91
91
  };
92
- function Se(e = [], t = {}) {
92
+ function Te(e = [], t = {}) {
93
93
  let n = new Set(t.boolean || []), r = new Set(t.string || []), i = t.alias || {}, a = t.default || {}, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
94
94
  for (let [e, t] of Object.entries(i)) {
95
95
  let n = t;
@@ -162,80 +162,80 @@ function Se(e = [], t = {}) {
162
162
  for (let [e, t] of o.entries()) h[e] !== void 0 && h[t] === void 0 && (h[t] = h[e]), h[t] !== void 0 && h[e] === void 0 && (h[e] = h[t]), h[e] !== h[t] && a[t] === h[t] && (h[t] = h[e]);
163
163
  return h;
164
164
  }
165
- var Ce = /* @__PURE__ */ (() => {
165
+ var Ee = /* @__PURE__ */ (() => {
166
166
  let e = globalThis.process?.env ?? {};
167
167
  return e.NO_COLOR === "1" || e.TERM === "dumb" || e.TEST || e.CI;
168
- })(), R = (e, t = 39) => (n) => Ce ? n : `\u001B[${e}m${n}\u001B[${t}m`, z = /* @__PURE__ */ R(1, 22), B = /* @__PURE__ */ R(36), V = /* @__PURE__ */ R(90), H = /* @__PURE__ */ R(4, 24);
169
- function we(e, t) {
168
+ })(), F = (e, t = 39) => (n) => Ee ? n : `\u001B[${e}m${n}\u001B[${t}m`, I = /* @__PURE__ */ F(1, 22), L = /* @__PURE__ */ F(36), R = /* @__PURE__ */ F(90), z = /* @__PURE__ */ F(4, 24);
169
+ function De(e, t) {
170
170
  let n = {
171
171
  boolean: [],
172
172
  string: [],
173
173
  alias: {},
174
174
  default: {}
175
- }, r = Te(t);
175
+ }, r = Oe(t);
176
176
  for (let e of r) {
177
177
  if (e.type === "positional") continue;
178
178
  e.type === "string" || e.type === "enum" ? n.string.push(e.name) : e.type === "boolean" && n.boolean.push(e.name), e.default !== void 0 && (n.default[e.name] = e.default), e.alias && (n.alias[e.name] = e.alias);
179
- let t = M(e.name), r = N(e.name);
179
+ let t = j(e.name), r = Se(e.name);
180
180
  if (t !== e.name || r !== e.name) {
181
- let i = P(n.alias[e.name] || []);
181
+ let i = M(n.alias[e.name] || []);
182
182
  t !== e.name && !i.includes(t) && i.push(t), r !== e.name && !i.includes(r) && i.push(r), i.length > 0 && (n.alias[e.name] = i);
183
183
  }
184
184
  }
185
- let i = Se(e, n), [ ...a] = i._, o = new Proxy(i, { get(e, t) {
186
- return e[t] ?? e[M(t)] ?? e[N(t)];
185
+ let i = Te(e, n), [ ...a] = i._, o = new Proxy(i, { get(e, t) {
186
+ return e[t] ?? e[j(t)] ?? e[Se(t)];
187
187
  } });
188
188
  for (let [, e] of r.entries()) if (e.type === "positional") {
189
189
  let t = a.shift();
190
190
  if (t !== void 0) o[e.name] = t;
191
- else if (e.default === void 0 && e.required !== !1) throw new L(`Missing required positional argument: ${e.name.toUpperCase()}`, "EARG");
191
+ else if (e.default === void 0 && e.required !== !1) throw new P(`Missing required positional argument: ${e.name.toUpperCase()}`, "EARG");
192
192
  else o[e.name] = e.default;
193
193
  } else if (e.type === "enum") {
194
194
  let t = o[e.name], n = e.options || [];
195
- if (t !== void 0 && n.length > 0 && !n.includes(t)) throw new L(`Invalid value for argument: ${B(`--${e.name}`)} (${B(t)}). Expected one of: ${n.map((e) => B(e)).join(", ")}.`, "EARG");
196
- } else if (e.required && o[e.name] === void 0) throw new L(`Missing required argument: --${e.name}`, "EARG");
195
+ if (t !== void 0 && n.length > 0 && !n.includes(t)) throw new P(`Invalid value for argument: ${L(`--${e.name}`)} (${L(t)}). Expected one of: ${n.map((e) => L(e)).join(", ")}.`, "EARG");
196
+ } else if (e.required && o[e.name] === void 0) throw new P(`Missing required argument: --${e.name}`, "EARG");
197
197
  return o;
198
198
  }
199
- function Te(e) {
199
+ function Oe(e) {
200
200
  let t = [];
201
201
  for (let [n, r] of Object.entries(e || {})) t.push({
202
202
  ...r,
203
203
  name: n,
204
- alias: P(r.alias)
204
+ alias: M(r.alias)
205
205
  });
206
206
  return t;
207
207
  }
208
- async function Ee(e) {
209
- return Promise.all(e.map((e) => I(e)));
208
+ async function ke(e) {
209
+ return Promise.all(e.map((e) => N(e)));
210
210
  }
211
- function U(e) {
211
+ function B(e) {
212
212
  return e;
213
213
  }
214
- async function De(e, t) {
215
- let n = await I(e.args || {}), r = we(t.rawArgs, n), i = {
214
+ async function V(e, t) {
215
+ let n = await N(e.args || {}), r = De(t.rawArgs, n), i = {
216
216
  rawArgs: t.rawArgs,
217
217
  args: r,
218
218
  data: t.data,
219
219
  cmd: e
220
- }, a = await Ee(e.plugins ?? []), o, s;
220
+ }, a = await ke(e.plugins ?? []), o, s;
221
221
  try {
222
222
  for (let e of a) await e.setup?.(i);
223
223
  typeof e.setup == "function" && await e.setup(i);
224
- let r = await I(e.subCommands);
224
+ let r = await N(e.subCommands);
225
225
  if (r && Object.keys(r).length > 0) {
226
226
  let i = Ae(t.rawArgs, n), a = t.rawArgs[i];
227
227
  if (a) {
228
- let e = await ke(r, a);
229
- if (!e) throw new L(`Unknown command ${B(a)}`, "E_UNKNOWN_COMMAND");
230
- await De(e, { rawArgs: t.rawArgs.slice(i + 1) });
228
+ let e = await U(r, a);
229
+ if (!e) throw new P(`Unknown command ${L(a)}`, "E_UNKNOWN_COMMAND");
230
+ await V(e, { rawArgs: t.rawArgs.slice(i + 1) });
231
231
  } else {
232
- let n = await I(e.default);
232
+ let n = await N(e.default);
233
233
  if (n) {
234
- if (e.run) throw new L("Cannot specify both 'run' and 'default' on the same command.", "E_DEFAULT_CONFLICT");
235
- let i = await ke(r, n);
236
- if (!i) throw new L(`Default sub command ${B(n)} not found in subCommands.`, "E_UNKNOWN_COMMAND");
237
- await De(i, { rawArgs: t.rawArgs });
238
- } else if (!e.run) throw new L("No command specified.", "E_NO_COMMAND");
234
+ if (e.run) throw new P("Cannot specify both 'run' and 'default' on the same command.", "E_DEFAULT_CONFLICT");
235
+ let i = await U(r, n);
236
+ if (!i) throw new P(`Default sub command ${L(n)} not found in subCommands.`, "E_UNKNOWN_COMMAND");
237
+ await V(i, { rawArgs: t.rawArgs });
238
+ } else if (!e.run) throw new P("No command specified.", "E_NO_COMMAND");
239
239
  }
240
240
  }
241
241
  typeof e.run == "function" && (o = await e.run(i));
@@ -258,19 +258,19 @@ async function De(e, t) {
258
258
  if (c.length > 1) throw Error("Multiple cleanup errors", { cause: c });
259
259
  return { result: o };
260
260
  }
261
- async function Oe(e, t, n) {
262
- let r = await I(e.subCommands);
261
+ async function H(e, t, n) {
262
+ let r = await N(e.subCommands);
263
263
  if (r && Object.keys(r).length > 0) {
264
- let n = Ae(t, await I(e.args || {})), i = t[n], a = await ke(r, i);
265
- if (a) return Oe(a, t.slice(n + 1), e);
264
+ let n = Ae(t, await N(e.args || {})), i = t[n], a = await U(r, i);
265
+ if (a) return H(a, t.slice(n + 1), e);
266
266
  }
267
267
  return [e, n];
268
268
  }
269
- async function ke(e, t) {
270
- if (t in e) return I(e[t]);
269
+ async function U(e, t) {
270
+ if (t in e) return N(e[t]);
271
271
  for (let n of Object.values(e)) {
272
- let e = await I(n), r = await I(e?.meta);
273
- if (r?.alias && P(r.alias).includes(t)) return e;
272
+ let e = await N(n), r = await N(e?.meta);
273
+ if (r?.alias && M(r.alias).includes(t)) return e;
274
274
  }
275
275
  }
276
276
  function Ae(e, t) {
@@ -283,8 +283,8 @@ function Ae(e, t) {
283
283
  return -1;
284
284
  }
285
285
  function je(e, t) {
286
- let n = e.replace(/^-{1,2}/, ""), r = M(n);
287
- for (let [e, i] of Object.entries(t)) if ((i.type === "string" || i.type === "enum") && (r === M(e) || (Array.isArray(i.alias) ? i.alias : i.alias ? [i.alias] : []).includes(n))) return !0;
286
+ let n = e.replace(/^-{1,2}/, ""), r = j(n);
287
+ for (let [e, i] of Object.entries(t)) if ((i.type === "string" || i.type === "enum") && (r === j(e) || (Array.isArray(i.alias) ? i.alias : i.alias ? [i.alias] : []).includes(n))) return !0;
288
288
  return !1;
289
289
  }
290
290
  async function Me(e, t) {
@@ -296,159 +296,76 @@ async function Me(e, t) {
296
296
  }
297
297
  var Ne = /^no[-A-Z]/;
298
298
  async function Pe(e, t) {
299
- let n = await I(e.meta || {}), r = Te(await I(e.args || {})), i = await I(t?.meta || {}), a = `${i.name ? `${i.name} ` : ""}` + (n.name || process.argv[1]), o = [], s = [], c = [], l = [];
299
+ let n = await N(e.meta || {}), r = Oe(await N(e.args || {})), i = await N(t?.meta || {}), a = `${i.name ? `${i.name} ` : ""}` + (n.name || process.argv[1]), o = [], s = [], c = [], l = [];
300
300
  for (let e of r) if (e.type === "positional") {
301
301
  let t = e.name.toUpperCase(), n = e.required !== !1 && e.default === void 0;
302
- s.push([B(t + Fe(e)), Ie(e, n)]), l.push(n ? `<${t}>` : `[${t}]`);
302
+ s.push([L(t + W(e)), Fe(e, n)]), l.push(n ? `<${t}>` : `[${t}]`);
303
303
  } else {
304
- let t = e.required === !0 && e.default === void 0, n = [...(e.alias || []).map((e) => `-${e}`), `--${e.name}`].join(", ") + Fe(e);
305
- if (o.push([B(n), Ie(e, t)]), e.type === "boolean" && (e.default === !0 || e.negativeDescription) && !Ne.test(e.name)) {
304
+ let t = e.required === !0 && e.default === void 0, n = [...(e.alias || []).map((e) => `-${e}`), `--${e.name}`].join(", ") + W(e);
305
+ if (o.push([L(n), Fe(e, t)]), e.type === "boolean" && (e.default === !0 || e.negativeDescription) && !Ne.test(e.name)) {
306
306
  let n = [...(e.alias || []).map((e) => `--no-${e}`), `--no-${e.name}`].join(", ");
307
- o.push([B(n), [e.negativeDescription, t ? V("(Required)") : ""].filter(Boolean).join(" ")]);
307
+ o.push([L(n), [e.negativeDescription, t ? R("(Required)") : ""].filter(Boolean).join(" ")]);
308
308
  }
309
- t && l.push(`--${e.name}` + Fe(e));
309
+ t && l.push(`--${e.name}` + W(e));
310
310
  }
311
311
  if (e.subCommands) {
312
- let t = [], n = await I(e.subCommands);
312
+ let t = [], n = await N(e.subCommands);
313
313
  for (let [e, r] of Object.entries(n)) {
314
- let n = await I((await I(r))?.meta);
314
+ let n = await N((await N(r))?.meta);
315
315
  if (n?.hidden) continue;
316
- let i = P(n?.alias), a = [e, ...i].join(", ");
317
- c.push([B(a), n?.description || ""]), t.push(e, ...i);
316
+ let i = M(n?.alias), a = [e, ...i].join(", ");
317
+ c.push([L(a), n?.description || ""]), t.push(e, ...i);
318
318
  }
319
319
  l.push(t.join("|"));
320
320
  }
321
321
  let u = [], d = n.version || i.version;
322
- u.push(V(`${n.description} (${a + (d ? ` v${d}` : "")})`), "");
322
+ u.push(R(`${n.description} (${a + (d ? ` v${d}` : "")})`), "");
323
323
  let f = o.length > 0 || s.length > 0;
324
- return u.push(`${H(z("USAGE"))} ${B(`${a}${f ? " [OPTIONS]" : ""} ${l.join(" ")}`)}`, ""), s.length > 0 && (u.push(H(z("ARGUMENTS")), ""), u.push(F(s, " ")), u.push("")), o.length > 0 && (u.push(H(z("OPTIONS")), ""), u.push(F(o, " ")), u.push("")), c.length > 0 && (u.push(H(z("COMMANDS")), ""), u.push(F(c, " ")), u.push("", `Use ${B(`${a} <command> --help`)} for more information about a command.`)), u.filter((e) => typeof e == "string").join("\n");
324
+ return u.push(`${z(I("USAGE"))} ${L(`${a}${f ? " [OPTIONS]" : ""} ${l.join(" ")}`)}`, ""), s.length > 0 && (u.push(z(I("ARGUMENTS")), ""), u.push(we(s, " ")), u.push("")), o.length > 0 && (u.push(z(I("OPTIONS")), ""), u.push(we(o, " ")), u.push("")), c.length > 0 && (u.push(z(I("COMMANDS")), ""), u.push(we(c, " ")), u.push("", `Use ${L(`${a} <command> --help`)} for more information about a command.`)), u.filter((e) => typeof e == "string").join("\n");
325
325
  }
326
- function Fe(e) {
327
- let t = e.valueHint ? `=<${e.valueHint}>` : "", n = t || `=<${xe(e.name)}>`;
326
+ function W(e) {
327
+ let t = e.valueHint ? `=<${e.valueHint}>` : "", n = t || `=<${Ce(e.name)}>`;
328
328
  return !e.type || e.type === "positional" || e.type === "boolean" ? t : e.type === "enum" && e.options?.length ? `=<${e.options.join("|")}>` : n;
329
329
  }
330
- function Ie(e, t) {
331
- let n = t ? V("(Required)") : "", r = e.default === void 0 ? "" : V(`(Default: ${e.default})`);
330
+ function Fe(e, t) {
331
+ let n = t ? R("(Required)") : "", r = e.default === void 0 ? "" : R(`(Default: ${e.default})`);
332
332
  return [
333
333
  e.description,
334
334
  n,
335
335
  r
336
336
  ].filter(Boolean).join(" ");
337
337
  }
338
- async function Le(e, t = {}) {
338
+ async function Ie(e, t = {}) {
339
339
  let n = t.rawArgs || process.argv.slice(2), r = t.showUsage || Me;
340
340
  try {
341
- let t = await Re(e);
342
- if (t.help.length > 0 && n.some((e) => t.help.includes(e))) await r(...await Oe(e, n)), process.exit(0);
341
+ let t = await Le(e);
342
+ if (t.help.length > 0 && n.some((e) => t.help.includes(e))) await r(...await H(e, n)), process.exit(0);
343
343
  else if (n.length === 1 && t.version.includes(n[0])) {
344
344
  let t = typeof e.meta == "function" ? await e.meta() : await e.meta;
345
- if (!t?.version) throw new L("No version specified", "E_NO_VERSION");
345
+ if (!t?.version) throw new P("No version specified", "E_NO_VERSION");
346
346
  console.log(t.version);
347
- } else await De(e, { rawArgs: n });
347
+ } else await V(e, { rawArgs: n });
348
348
  } catch (t) {
349
- t instanceof L ? (await r(...await Oe(e, n)), console.error(t.message)) : console.error(t, "\n"), process.exit(1);
349
+ t instanceof P ? (await r(...await H(e, n)), console.error(t.message)) : console.error(t, "\n"), process.exit(1);
350
350
  }
351
351
  }
352
- async function Re(e) {
353
- let t = await I(e.args || {}), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
352
+ async function Le(e) {
353
+ let t = await N(e.args || {}), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
354
354
  for (let [e, i] of Object.entries(t)) {
355
355
  n.add(e);
356
- for (let e of P(i.alias)) r.add(e);
356
+ for (let e of M(i.alias)) r.add(e);
357
357
  }
358
358
  return {
359
- help: ze("help", "h", n, r),
360
- version: ze("version", "v", n, r)
359
+ help: Re("help", "h", n, r),
360
+ version: Re("version", "v", n, r)
361
361
  };
362
362
  }
363
- function ze(e, t, n, r) {
363
+ function Re(e, t, n, r) {
364
364
  return n.has(e) || r.has(e) ? [] : n.has(t) || r.has(t) ? [`--${e}`] : [`--${e}`, `-${t}`];
365
365
  }
366
- var Be = {
367
- name: "@incajs/cli",
368
- version: "0.0.16",
369
- description: "Commands to develop, bundle, and package Incarnative.js apps.",
370
- keywords: [
371
- "bundler",
372
- "cli",
373
- "desktop-app",
374
- "dev-server",
375
- "gpui",
376
- "gui",
377
- "incajs",
378
- "incarnative.js",
379
- "json-rpc",
380
- "quickjs",
381
- "vite"
382
- ],
383
- homepage: "https://incajs.tom96da.com/",
384
- license: "(MIT OR Apache-2.0)",
385
- repository: {
386
- type: "git",
387
- url: "git+https://github.com/tom96da/incajs.git",
388
- directory: "packages/cli"
389
- },
390
- bin: { inca: "./bin/inca.mjs" },
391
- files: ["dist", "bin"],
392
- type: "module",
393
- sideEffects: ["src/adapter/vite/runtime/globals.mts"],
394
- main: "./dist/index.js",
395
- types: "./dist/index.d.mts",
396
- exports: {
397
- ".": {
398
- source: "./src/index.mts",
399
- types: "./dist/index.d.mts",
400
- import: "./dist/index.js"
401
- },
402
- "./config": {
403
- source: "./src/config/index.mts",
404
- types: "./dist/config/index.d.mts",
405
- import: "./dist/config.js"
406
- }
407
- },
408
- publishConfig: {
409
- exports: {
410
- ".": {
411
- types: "./dist/index.d.mts",
412
- import: "./dist/index.js"
413
- },
414
- "./config": {
415
- types: "./dist/config/index.d.mts",
416
- import: "./dist/config.js"
417
- }
418
- },
419
- access: "public"
420
- },
421
- scripts: {
422
- build: "vite build",
423
- test: "vitest run",
424
- lint: "oxlint --type-aware",
425
- format: "oxfmt --check .",
426
- typecheck: "oxlint -A all --type-aware --type-check"
427
- },
428
- dependencies: {
429
- "@vitejs/plugin-vue": "^6.0.9",
430
- vite: "catalog:"
431
- },
432
- devDependencies: {
433
- "@types/node": "catalog:",
434
- "@vue/runtime-core": "catalog:",
435
- c12: "4.0.0-rc.2",
436
- citty: "0.2.2",
437
- oxfmt: "catalog:",
438
- oxlint: "catalog:",
439
- rolldown: "~1.2.13",
440
- vue: "catalog:"
441
- },
442
- peerDependencies: { vue: "catalog:" },
443
- peerDependenciesMeta: { vue: { optional: !0 } },
444
- optionalDependencies: {
445
- "@incajs/host-darwin-arm64": "workspace:*",
446
- "@incajs/host-darwin-x64": "workspace:*",
447
- "@incajs/host-linux-arm64": "workspace:*",
448
- "@incajs/host-linux-x64": "workspace:*"
449
- },
450
- engines: { node: ">=22.18" }
451
- };
366
+ //#endregion
367
+ //#region package.json
368
+ var ze = "0.0.18", Be = "Commands to develop, bundle, and package Incarnative.js apps.";
452
369
  //#endregion
453
370
  //#region ../../node_modules/.pnpm/rc9@3.1.0/node_modules/rc9/dist/_chunks/libs/flat.mjs
454
371
  function Ve(e) {
@@ -542,39 +459,39 @@ function Xe(e, t = {}) {
542
459
  }
543
460
  //#endregion
544
461
  //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
545
- function Ze(e) {
462
+ function G(e) {
546
463
  if (typeof e != "object" || !e) return !1;
547
464
  let t = Object.getPrototypeOf(e);
548
465
  return t !== null && t !== Object.prototype && Object.getPrototypeOf(t) !== null || Symbol.iterator in e ? !1 : Symbol.toStringTag in e ? Object.prototype.toString.call(e) === "[object Module]" : !0;
549
466
  }
550
- function Qe(e, t, n = ".", r) {
551
- if (!Ze(t)) return Qe(e, {}, n, r);
467
+ function Ze(e, t, n = ".", r) {
468
+ if (!G(t)) return Ze(e, {}, n, r);
552
469
  let i = { ...t };
553
470
  for (let t of Object.keys(e)) {
554
471
  if (t === "__proto__" || t === "constructor") continue;
555
472
  let a = e[t];
556
- a != null && (r && r(i, t, a, n) || (i[t] = Array.isArray(a) && Array.isArray(i[t]) ? [...a, ...i[t]] : Ze(a) && Ze(i[t]) ? Qe(a, i[t], (n ? `${n}.` : "") + t.toString(), r) : a));
473
+ a != null && (r && r(i, t, a, n) || (i[t] = Array.isArray(a) && Array.isArray(i[t]) ? [...a, ...i[t]] : G(a) && G(i[t]) ? Ze(a, i[t], (n ? `${n}.` : "") + t.toString(), r) : a));
557
474
  }
558
475
  return i;
559
476
  }
560
- function $e(e) {
561
- return (...t) => t.reduce((t, n) => Qe(t, n, "", e), {});
477
+ function Qe(e) {
478
+ return (...t) => t.reduce((t, n) => Ze(t, n, "", e), {});
562
479
  }
563
- var W = $e(), et = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/, tt = /\n|\r|\r\n/, nt = {
480
+ var K = Qe(), $e = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/, et = /\n|\r|\r\n/, tt = {
564
481
  name: ".conf",
565
482
  dir: process.cwd(),
566
483
  flat: !1
567
484
  };
568
- function rt(e) {
485
+ function nt(e) {
569
486
  return typeof e == "string" && (e = { name: e }), {
570
- ...nt,
487
+ ...tt,
571
488
  ...e
572
489
  };
573
490
  }
574
- function it(e, t = {}) {
575
- let n = {}, r = e.split(tt);
491
+ function rt(e, t = {}) {
492
+ let n = {}, r = e.split(et);
576
493
  for (let e of r) {
577
- let t = e.match(et);
494
+ let t = e.match($e);
578
495
  if (!t) continue;
579
496
  let r = t[1];
580
497
  if (!r || r === "__proto__" || r === "constructor") continue;
@@ -586,22 +503,22 @@ function it(e, t = {}) {
586
503
  }
587
504
  return t.flat ? n : We(n, { overwrite: !0 });
588
505
  }
589
- function at(e, t) {
590
- return p(e) ? it(h(e, "utf8"), t) : {};
506
+ function it(e, t) {
507
+ return p(e) ? rt(h(e, "utf8"), t) : {};
591
508
  }
592
- function G(e) {
593
- return e = rt(e), at(b(e.dir, e.name), e);
509
+ function q(e) {
510
+ return e = nt(e), it(b(e.dir, e.name), e);
594
511
  }
595
- function ot() {
596
- return process.env.XDG_CONFIG_HOME || b(A(), ".config");
512
+ function at() {
513
+ return process.env.XDG_CONFIG_HOME || b(ie(), ".config");
597
514
  }
598
- function st(e) {
599
- return e = rt(e), e.dir = ot(), G(e);
515
+ function ot(e) {
516
+ return e = nt(e), e.dir = at(), q(e);
600
517
  }
601
518
  //#endregion
602
519
  //#region ../../node_modules/.pnpm/c12@4.0.0-rc.2_magicast@0.5.4/node_modules/c12/dist/index.mjs
603
- async function ct(e) {
604
- let t = e.env ?? process.env, n = await lt({
520
+ async function st(e) {
521
+ let t = e.env ?? process.env, n = await ct({
605
522
  cwd: e.cwd,
606
523
  fileName: e.fileName ?? ".env",
607
524
  env: t,
@@ -612,7 +529,7 @@ async function ct(e) {
612
529
  for (let e in n) e.startsWith("_") || (t[e] === void 0 || r.has(e)) && (t[e] = n[e]);
613
530
  return n;
614
531
  }
615
- async function lt(e) {
532
+ async function ct(e) {
616
533
  let n = Object.create(null), r = t(e.cwd || "."), i = e.fileName || ".env", a = typeof i == "string" ? [i] : i, o = gt(e.env || {});
617
534
  Object.assign(n, e.env);
618
535
  for (let i of a) {
@@ -632,17 +549,17 @@ async function lt(e) {
632
549
  }
633
550
  return e.interpolate && dt(n), n;
634
551
  }
635
- var K = ee.parseEnv;
552
+ var lt = ee.parseEnv;
636
553
  async function ut(e, t) {
637
554
  let n = h(e, "utf8");
638
555
  if (t) return t(n);
639
- if (!K) try {
556
+ if (!lt) try {
640
557
  let e = await import("./chunks/__vite-optional-peer-dep_dotenv_c12-CxKvRg9-.js");
641
- K = (t) => e.parse(t);
558
+ lt = (t) => e.parse(t);
642
559
  } catch {
643
560
  throw Error("Failed to parse .env file: `node:util.parseEnv` is not available and `dotenv` package is not installed. Please upgrade your runtime, install `dotenv` as a dependency or provide a custom `parse` option.");
644
561
  }
645
- return K(n);
562
+ return lt(n);
646
563
  }
647
564
  function dt(e, t = {}, n = (e) => e) {
648
565
  function r(n) {
@@ -756,7 +673,7 @@ async function xt(e) {
756
673
  extendKey: "extends",
757
674
  ...e.extend
758
675
  });
759
- let n = e.merger || W, r = {
676
+ let n = e.merger || K, r = {
760
677
  config: {},
761
678
  cwd: e.cwd,
762
679
  configFile: t(e.cwd, e.configFile),
@@ -769,24 +686,24 @@ async function xt(e) {
769
686
  packageJson: void 0,
770
687
  defaultConfig: e.defaultConfig
771
688
  };
772
- e.dotenv && await ct({
689
+ e.dotenv && await st({
773
690
  cwd: e.cwd,
774
691
  ...e.dotenv === !0 ? {} : e.dotenv
775
692
  });
776
693
  let a = await Tt(".", e);
777
694
  if (a.configFile && (i.main = a.config, r.configFile = a.configFile, r._configFile = a._configFile), a.meta && (r.meta = a.meta), e.rcFile) {
778
695
  let t = [];
779
- if (t.push(G({
696
+ if (t.push(q({
780
697
  name: e.rcFile,
781
698
  dir: e.cwd
782
699
  })), e.globalRc) {
783
700
  let { findWorkspaceDir: n } = await import("./chunks/dist-DrnNGO2a.js"), r = await n(e.cwd).catch(() => {});
784
- r && t.push(G({
701
+ r && t.push(q({
785
702
  name: e.rcFile,
786
703
  dir: r
787
- })), t.push(st({ name: e.rcFile })), t.push(G({
704
+ })), t.push(ot({ name: e.rcFile })), t.push(q({
788
705
  name: e.rcFile,
789
- dir: A()
706
+ dir: ie()
790
707
  }));
791
708
  }
792
709
  i.rc = n({}, ...t);
@@ -858,13 +775,13 @@ async function Tt(e, o, s = {}) {
858
775
  let t = await o.resolve(e, o);
859
776
  if (t) return t;
860
777
  }
861
- let c = o.merger || W, l = Object.keys(s.giget?.providers || {}).map((e) => `${e}:`), u = l.length > 0 ? [.../* @__PURE__ */ new Set([...l, ...Ct])] : Ct;
778
+ let c = o.merger || K, l = Object.keys(s.giget?.providers || {}).map((e) => `${e}:`), u = l.length > 0 ? [.../* @__PURE__ */ new Set([...l, ...Ct])] : Ct;
862
779
  if (o.giget !== !1 && u.some((t) => e.startsWith(t))) {
863
780
  let { downloadTemplate: n } = await import("./chunks/__vite-optional-peer-dep_giget_c12-BYcrHYBM.js").catch((t) => {
864
781
  throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``, { cause: t });
865
782
  }), { digest: c } = await import("./chunks/ohash-Cc4pJh84.js").then((e) => e.dist_exports), l = e.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + c(e).slice(0, 10).replace(/[-_]/g, ""), u, d = t(o.cwd, "node_modules"), f = a(o.cwd);
866
- u = r(f) === ".c12" ? i(f, l) : p(d) ? i(d, ".c12", l) : process.env.XDG_CACHE_HOME ? t(process.env.XDG_CACHE_HOME, "c12", l) : t(A(), ".cache/c12", l);
867
- let m = s.install ? W(s.install === !0 ? {} : s.install, { ignoreWorkspace: !0 }) : !1;
783
+ u = r(f) === ".c12" ? i(f, l) : p(d) ? i(d, ".c12", l) : process.env.XDG_CACHE_HOME ? t(process.env.XDG_CACHE_HOME, "c12", l) : t(ie(), ".cache/c12", l);
784
+ let m = s.install ? K(s.install === !0 ? {} : s.install, { ignoreWorkspace: !0 }) : !1;
868
785
  p(u) && !m && await O(u, { recursive: !0 }), e = (await n(e, {
869
786
  dir: u,
870
787
  install: m,
@@ -874,7 +791,7 @@ async function Tt(e, o, s = {}) {
874
791
  ...s.giget
875
792
  })).dir;
876
793
  }
877
- wt.test(e) && (e = q(e, o) || e);
794
+ wt.test(e) && (e = J(e, o) || e);
878
795
  let d = n(e), f = Dt(t(o.cwd, e)) ?? (!d || d === r(e)), m = t(o.cwd, f ? e : a(e));
879
796
  f && (e = o.configFile);
880
797
  let h = {
@@ -884,7 +801,7 @@ async function Tt(e, o, s = {}) {
884
801
  source: e,
885
802
  sourceOptions: s
886
803
  };
887
- if (h.configFile = q(t(m, e), o) || q(t(m, ".config", e.replace(/\.config$/, "")), o) || q(t(m, ".config", e), o) || e, !p(h.configFile)) return h;
804
+ if (h.configFile = J(t(m, e), o) || J(t(m, ".config", e.replace(/\.config$/, "")), o) || J(t(m, ".config", e), o) || e, !p(h.configFile)) return h;
888
805
  h._configFile = h.configFile;
889
806
  let g = n(h.configFile) || "";
890
807
  if (g in yt) h.config = (await yt[g]())(await D(h.configFile, "utf8"));
@@ -908,7 +825,7 @@ async function Tt(e, o, s = {}) {
908
825
  }
909
826
  typeof h.config == "function" && (h.config = await h.config(o.context)), h.config && typeof h.config == "object" && !Array.isArray(h.config) && !Object.isExtensible(h.config) && (h.config = { ...h.config });
910
827
  let _ = (Array.isArray(o.envName) ? o.envName : [o.envName]).filter(Boolean).reverse().flatMap((e) => [h.config.$env?.[e], h.config["$" + e]]).filter((e) => e && Object.keys(e).length > 0);
911
- return _.length > 0 && (h.config = (o.envMerger || c)({}, ..._, h.config)), h.meta = W(h.sourceOptions.meta, h.config.$meta), delete h.config.$meta, h.sourceOptions.overrides && (h.config = c(h.sourceOptions.overrides, h.config)), h.configFile = _t(h.configFile), h.source = _t(h.source), h;
828
+ return _.length > 0 && (h.config = (o.envMerger || c)({}, ..._, h.config)), h.meta = K(h.sourceOptions.meta, h.config.$meta), delete h.config.$meta, h.sourceOptions.overrides && (h.config = c(h.sourceOptions.overrides, h.config)), h.configFile = _t(h.configFile), h.source = _t(h.source), h;
912
829
  }
913
830
  async function Et(e, t) {
914
831
  if (typeof t?.["~standard"]?.validate != "function") throw TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");
@@ -922,7 +839,7 @@ async function Et(e, t) {
922
839
  }
923
840
  return n.value;
924
841
  }
925
- function q(e, t) {
842
+ function J(e, t) {
926
843
  let n = s(e, {
927
844
  try: !0,
928
845
  from: re(i(t.cwd || ".", t.configFile || "/")),
@@ -941,7 +858,7 @@ function Dt(e) {
941
858
  }
942
859
  //#endregion
943
860
  //#region src/error.mts
944
- var J = class extends Error {
861
+ var Y = class extends Error {
945
862
  code;
946
863
  path;
947
864
  name = "IncaError";
@@ -960,7 +877,7 @@ function At(e) {
960
877
  return e === e.trim() && e !== "" && e !== "." && e !== ".." && !kt.test(e);
961
878
  }
962
879
  function jt(e) {
963
- if (!(typeof e == "string" && At(e))) throw new J("ERR_INCA_PRODUCT_NAME_INVALID", `${JSON.stringify(e)} can't name a directory. set a "productName" in inca.config.ts with no leading or trailing space, and none of \`/\\:*?"<>|\``);
880
+ if (!(typeof e == "string" && At(e))) throw new Y("ERR_INCA_PRODUCT_NAME_INVALID", `${JSON.stringify(e)} can't name a directory. set a "productName" in inca.config.ts with no leading or trailing space, and none of \`/\\:*?"<>|\``);
964
881
  }
965
882
  var Mt = process.platform === "darwin" || process.platform === "win32";
966
883
  function Nt(e, t) {
@@ -985,7 +902,7 @@ function Ft(e, t, n) {
985
902
  } catch {
986
903
  i = !0;
987
904
  }
988
- if (i) throw new J("ERR_INCA_OUT_DIR_INVALID", `"outDir" resolves to ${r}, which holds the app's own files. Set it to a directory the build can own, such as "dist"`);
905
+ if (i) throw new Y("ERR_INCA_OUT_DIR_INVALID", `"outDir" resolves to ${r}, which holds the app's own files. Set it to a directory the build can own, such as "dist"`);
989
906
  }
990
907
  function It(e, t, n) {
991
908
  let r = y.resolve(e, t ?? d.outDir);
@@ -995,7 +912,7 @@ function Lt(e, t) {
995
912
  try {
996
913
  return JSON.parse(e);
997
914
  } catch (e) {
998
- throw new J("ERR_INCA_PACKAGE_JSON_INVALID", `${t} holds malformed JSON: ${e.message}`, t);
915
+ throw new Y("ERR_INCA_PACKAGE_JSON_INVALID", `${t} holds malformed JSON: ${e.message}`, t);
999
916
  }
1000
917
  }
1001
918
  async function Rt(e) {
@@ -1021,13 +938,13 @@ async function Bt(e) {
1021
938
  try {
1022
939
  n = await D(t, "utf8");
1023
940
  } catch {
1024
- throw new J("ERR_INCA_PACKAGE_JSON_NOT_FOUND", `no package.json found at ${t}`);
941
+ throw new Y("ERR_INCA_PACKAGE_JSON_NOT_FOUND", `no package.json found at ${t}`);
1025
942
  }
1026
943
  let r = Lt(n, t), { config: i, usedPackageJsonKey: a } = await Rt(e), o = i.productName ?? u(r.name);
1027
- if (!o) throw new J("ERR_INCA_PRODUCT_NAME_MISSING", `${t} needs a "name", or "productName" in inca.config.ts`);
944
+ if (!o) throw new Y("ERR_INCA_PRODUCT_NAME_MISSING", `${t} needs a "name", or "productName" in inca.config.ts`);
1028
945
  jt(o);
1029
946
  let s = i.version ?? r.version ?? d.version, c = i.identifier ?? l(o), f;
1030
- if (i.icon && (f = y.resolve(e, i.icon), !p(f))) throw new J("ERR_INCA_ICON_NOT_FOUND", `"icon" points to ${f}, which doesn't exist`, f);
947
+ if (i.icon && (f = y.resolve(e, i.icon), !p(f))) throw new Y("ERR_INCA_ICON_NOT_FOUND", `"icon" points to ${f}, which doesn't exist`, f);
1031
948
  let m = i.entry ? y.resolve(e, i.entry) : void 0, h = It(e, i.outDir, m);
1032
949
  return {
1033
950
  productName: o,
@@ -1060,8 +977,248 @@ async function Ht(e) {
1060
977
  return Object.values(o).some((e) => e !== void 0) ? o : void 0;
1061
978
  }
1062
979
  //#endregion
1063
- //#region src/adapter/vite/captureOutput.mts
1064
- function Ut(e, t, n) {
980
+ //#region src/dev-client/hostBin.mts
981
+ var Ut = "INCA_HOST_BIN";
982
+ function Wt() {
983
+ let e = process.platform === "darwin" || process.platform === "linux" ? process.platform : void 0, t = process.arch === "arm64" || process.arch === "x64" ? process.arch : void 0;
984
+ return e && t ? `@incajs/host-${e}-${t}` : void 0;
985
+ }
986
+ function Gt() {
987
+ let e = Wt();
988
+ if (e) try {
989
+ return ae(import.meta.url).resolve(`${e}/bin/inca-host`);
990
+ } catch {
991
+ return;
992
+ }
993
+ }
994
+ function Kt() {
995
+ let e = process.env[Ut];
996
+ if (e) return e;
997
+ let t = Gt();
998
+ if (t) return t;
999
+ let n = Wt();
1000
+ throw new Y("ERR_INCA_HOST_BIN_UNRESOLVED", `no host binary found. ${n ? `no ${n} package is installed for it` : `this platform (${process.platform}/${process.arch}) has no published package`}, and ${Ut} isn't set to one`);
1001
+ }
1002
+ function qt(e) {
1003
+ if (!_(e, { throwIfNoEntry: !1 })?.isFile()) throw new Y("ERR_INCA_HOST_BIN_NOT_FOUND", `no host binary at ${e}. check that it was built`);
1004
+ }
1005
+ //#endregion
1006
+ //#region src/dev-client/hostError.mts
1007
+ var Jt = class extends Error {
1008
+ code;
1009
+ hostStack;
1010
+ constructor(e, t, n = null) {
1011
+ super(e), this.code = t, this.hostStack = n, this.name = "HostError";
1012
+ }
1013
+ };
1014
+ function Yt(e) {
1015
+ return typeof e == "object" && !!e && e.jsonrpc === "2.0";
1016
+ }
1017
+ //#endregion
1018
+ //#region src/dev-client/hostClient.mts
1019
+ var Xt = (e) => {
1020
+ process.stderr.write(e.endsWith("\n") ? e : `${e}\n`);
1021
+ }, Zt = -32e3, Qt = class {
1022
+ #e;
1023
+ #t;
1024
+ #n = 1;
1025
+ #r = /* @__PURE__ */ new Map();
1026
+ #i = !1;
1027
+ constructor(e) {
1028
+ this.#e = e;
1029
+ }
1030
+ async start() {
1031
+ let e = this.#e.hostBin ?? Kt();
1032
+ qt(e);
1033
+ let t = oe(e, ["--dev", this.#e.entryFile], {
1034
+ stdio: [
1035
+ "pipe",
1036
+ "pipe",
1037
+ "pipe"
1038
+ ],
1039
+ env: this.#e.env
1040
+ });
1041
+ this.#t = t;
1042
+ let n = this.#e.onStderr ?? Xt;
1043
+ t.stderr.setEncoding("utf8"), t.stderr.on("data", (e) => n(e)), t.stdin.on("error", (e) => {
1044
+ e.code !== "EPIPE" && n(`host stdin: ${e.message}\n`);
1045
+ }), se.createInterface({ input: t.stdout }).on("line", (e) => {
1046
+ this.#a(e, n);
1047
+ }), t.on("exit", (e, t) => {
1048
+ let n = /* @__PURE__ */ Error(`the host exited (code=${String(e)}, signal=${String(t)}) before answering`);
1049
+ for (let { reject: e } of this.#r.values()) e(n);
1050
+ this.#r.clear(), this.#i || this.#e.onExit?.(e, t);
1051
+ });
1052
+ let r = !1;
1053
+ t.on("error", (e) => {
1054
+ r && n(`host: ${e.message}\n`);
1055
+ }), await A(t, "spawn"), r = !0;
1056
+ }
1057
+ #a(e, t) {
1058
+ let n;
1059
+ try {
1060
+ n = JSON.parse(e);
1061
+ } catch {
1062
+ t(`[stray stdout] ${e}`);
1063
+ return;
1064
+ }
1065
+ if (!Yt(n)) {
1066
+ t(`[stray stdout] ${e}`);
1067
+ return;
1068
+ }
1069
+ if ("method" in n) {
1070
+ this.#o(n.method, n.params, t);
1071
+ return;
1072
+ }
1073
+ if (n.id === null) {
1074
+ if (!("error" in n)) return;
1075
+ let { code: e, message: r, data: i } = n.error;
1076
+ e === Zt ? this.#e.onAppError?.({
1077
+ message: r,
1078
+ stack: i?.stack ?? null
1079
+ }) : t(`[host error ${String(e)}] ${r}\n`);
1080
+ return;
1081
+ }
1082
+ let r = this.#r.get(n.id);
1083
+ r && (this.#r.delete(n.id), "error" in n ? r.reject(new Jt(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
1084
+ }
1085
+ #o(e, t, n) {
1086
+ switch (e) {
1087
+ case "ready": {
1088
+ let { protocol: e } = t;
1089
+ if (e !== 0) {
1090
+ n(`the host speaks protocol ${String(e)}, this package was built for 0. stopping it`), this.#t && this.#s(this.#t);
1091
+ return;
1092
+ }
1093
+ this.#e.onReady?.();
1094
+ return;
1095
+ }
1096
+ case "appError":
1097
+ this.#e.onAppError?.(t);
1098
+ return;
1099
+ default: {
1100
+ let r = this.#e.integrations?.[e];
1101
+ r ? r(t) : n(`[unhandled notification] ${e}`);
1102
+ }
1103
+ }
1104
+ }
1105
+ async #s(e) {
1106
+ let t = A(e, "exit");
1107
+ e.kill(), await t;
1108
+ }
1109
+ async call(e, t, n) {
1110
+ let r = this.#t;
1111
+ if (!r) throw Error("HostClient.start() has not been called");
1112
+ let i = this.#n++, a = JSON.stringify({
1113
+ jsonrpc: "2.0",
1114
+ id: i,
1115
+ method: e,
1116
+ params: t
1117
+ });
1118
+ return new Promise((t, o) => {
1119
+ let s = n === void 0 ? void 0 : setTimeout(() => {
1120
+ this.#r.delete(i), o(/* @__PURE__ */ Error(`${e} timed out after ${String(n)}ms`));
1121
+ }, n);
1122
+ this.#r.set(i, {
1123
+ resolve: (e) => {
1124
+ clearTimeout(s), t(e);
1125
+ },
1126
+ reject: (e) => {
1127
+ clearTimeout(s), o(e);
1128
+ }
1129
+ }), r.stdin.write(`${a}\n`, (e) => {
1130
+ e && (clearTimeout(s), this.#r.delete(i), o(e));
1131
+ });
1132
+ });
1133
+ }
1134
+ notify(e, t) {
1135
+ let n = this.#t;
1136
+ if (!n) throw Error("HostClient.start() has not been called");
1137
+ n.stdin.write(`${JSON.stringify({
1138
+ jsonrpc: "2.0",
1139
+ method: e,
1140
+ params: t
1141
+ })}\n`);
1142
+ }
1143
+ async stop(e = 2e3) {
1144
+ let t = this.#t;
1145
+ if (!t || t.exitCode !== null || t.signalCode !== null) return;
1146
+ this.#i = !0;
1147
+ let n = A(t, "exit");
1148
+ this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), ce(e, void 0, { ref: !1 }).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
1149
+ }
1150
+ }, $t = "[inca]", en = new Intl.DateTimeFormat(void 0, {
1151
+ hour: "numeric",
1152
+ minute: "numeric",
1153
+ second: "numeric"
1154
+ }), X = { timestamp: !0 };
1155
+ function tn(e, t, n) {
1156
+ let r = S(["bold", n], $t, { stream: e });
1157
+ return t.timestamp ? `${S("dim", en.format(/* @__PURE__ */ new Date()), { stream: e })} ${r}` : r;
1158
+ }
1159
+ function Z(e, t, n = {}) {
1160
+ e.write(`${tn(e, n, "cyan")} ${t}\n`);
1161
+ }
1162
+ function nn(e, t, n = {}) {
1163
+ e.write(`${tn(e, n, "yellow")} ${t}\n`);
1164
+ }
1165
+ function rn(e) {
1166
+ let t = e.code;
1167
+ return typeof t == "string" ? t : null;
1168
+ }
1169
+ function an(e) {
1170
+ return /\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0] ?? null;
1171
+ }
1172
+ function on(e) {
1173
+ let t = e.stack;
1174
+ if (!t) return null;
1175
+ for (let n of [`${e.name}: ${e.message}`, e.message]) if (t.startsWith(n)) return t.slice(n.length).replace(/^\r?\n/, "") || null;
1176
+ return t;
1177
+ }
1178
+ function sn(e) {
1179
+ let t = /^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);
1180
+ return t ? {
1181
+ message: e.slice(t[0].length),
1182
+ stack: null,
1183
+ code: t[1]
1184
+ } : {
1185
+ message: e.replace(/^\w*Error: /, ""),
1186
+ stack: null,
1187
+ code: null
1188
+ };
1189
+ }
1190
+ function Q(e) {
1191
+ return e instanceof Jt ? {
1192
+ message: e.message,
1193
+ stack: e.hostStack,
1194
+ code: rn(e)
1195
+ } : e instanceof Error ? {
1196
+ message: e.message,
1197
+ stack: on(e),
1198
+ code: rn(e) ?? an(e.message)
1199
+ } : {
1200
+ message: String(e),
1201
+ stack: null,
1202
+ code: null
1203
+ };
1204
+ }
1205
+ function cn(e, t) {
1206
+ return e.split("\n").map((e) => /^\s*at\b/.test(e) ? S("dim", e, { stream: t }) : e).join("\n");
1207
+ }
1208
+ function $(e, t, n, r = {}) {
1209
+ n.stack && e.write(`${cn(n.stack, e)}\n`);
1210
+ let i = n.code ? ` (${S("bold", n.code, { stream: e })})` : "";
1211
+ e.write(`${tn(e, r, "red")} ${t}${i}: ${n.message}\n`);
1212
+ }
1213
+ //#endregion
1214
+ //#region src/adapterCore.mts
1215
+ var ln = /* @__PURE__ */ e({
1216
+ IncaError: () => Y,
1217
+ bundlerFault: () => sn
1218
+ });
1219
+ //#endregion
1220
+ //#region src/vite/captureOutput.mts
1221
+ function un(e, t, n) {
1065
1222
  return {
1066
1223
  outDir: e,
1067
1224
  entryFile: y.join(e, t.entryFile),
@@ -1069,7 +1226,7 @@ function Ut(e, t, n) {
1069
1226
  changed: n
1070
1227
  };
1071
1228
  }
1072
- function Wt(e, t) {
1229
+ function dn(e, t) {
1073
1230
  return {
1074
1231
  name: "inca:capture-output",
1075
1232
  writeBundle(n, r) {
@@ -1083,29 +1240,29 @@ function Wt(e, t) {
1083
1240
  };
1084
1241
  }
1085
1242
  //#endregion
1086
- //#region src/adapter/vite/emitConfig.mts
1087
- var Gt = "inca.json";
1088
- function Kt(e) {
1243
+ //#region src/vite/emitConfig.mts
1244
+ var fn = "inca.json";
1245
+ function pn(e) {
1089
1246
  let t = JSON.stringify(e, void 0, 2);
1090
1247
  if (t !== void 0 && t !== "{}") return `${t}\n`;
1091
1248
  }
1092
- function qt(e) {
1093
- let t = Kt(e);
1249
+ function mn(e) {
1250
+ let t = pn(e);
1094
1251
  return {
1095
1252
  name: "inca:emit-config",
1096
1253
  generateBundle() {
1097
1254
  t && this.emitFile({
1098
1255
  type: "asset",
1099
- fileName: Gt,
1256
+ fileName: fn,
1100
1257
  source: t
1101
1258
  });
1102
1259
  }
1103
1260
  };
1104
1261
  }
1105
1262
  //#endregion
1106
- //#region src/adapter/vite/logger.mts
1107
- var Jt = "Build failed with ", Yt = "Pre-transform error";
1108
- function Xt(e, t, n = !1) {
1263
+ //#region src/vite/logger.mts
1264
+ var hn = "Build failed with ", gn = "Pre-transform error";
1265
+ function _n(e, t, n = !1) {
1109
1266
  let r = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new Set(), a = {
1110
1267
  hasWarned: !1,
1111
1268
  info(t) {
@@ -1118,7 +1275,7 @@ function Xt(e, t, n = !1) {
1118
1275
  i.has(e) || (i.add(e), a.warn(e));
1119
1276
  },
1120
1277
  error(e, n) {
1121
- a.hasWarned = !0, n?.error && r.add(n.error), !e.includes(Jt) && (e.includes(Yt) || t.write(`${e.replace(/\n\s+at .*/g, "")}\n`));
1278
+ a.hasWarned = !0, n?.error && r.add(n.error), !e.includes(hn) && (e.includes(gn) || t.write(`${e.replace(/\n\s+at .*/g, "")}\n`));
1122
1279
  },
1123
1280
  clearScreen() {},
1124
1281
  hasErrorLogged(e) {
@@ -1128,8 +1285,8 @@ function Xt(e, t, n = !1) {
1128
1285
  return a;
1129
1286
  }
1130
1287
  //#endregion
1131
- //#region src/adapter/vite/unsupported.mts
1132
- var Zt = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, Qt = [{
1288
+ //#region src/vite/unsupported.mts
1289
+ var vn = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, yn = [{
1133
1290
  code: "ERR_INCA_UNSUPPORTED_STYLE",
1134
1291
  name: "a <style> block",
1135
1292
  matches: (e) => e.includes("vue&type=style"),
@@ -1137,10 +1294,10 @@ var Zt = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, Qt = [{
1137
1294
  }, {
1138
1295
  code: "ERR_INCA_UNSUPPORTED_STYLESHEET",
1139
1296
  name: "a stylesheet import",
1140
- matches: (e) => Zt.test(e),
1297
+ matches: (e) => vn.test(e),
1141
1298
  hint: "the renderer applies no stylesheet. use a :style binding instead"
1142
1299
  }];
1143
- function $t(e, t = Qt) {
1300
+ function bn(e, t = yn) {
1144
1301
  return {
1145
1302
  name: "inca:reject-unsupported",
1146
1303
  enforce: "pre",
@@ -1153,9 +1310,9 @@ function $t(e, t = Qt) {
1153
1310
  };
1154
1311
  }
1155
1312
  //#endregion
1156
- //#region src/adapter/vite/config.mts
1157
- var en = "bundle.js";
1158
- function tn({ core: e, runtimeModuleName: t, entry: n, outDir: r, mode: i, sourcemap: a = !1, watch: o, onOutput: s, stdout: c, stderr: l, quiet: u, runtimeConfig: d }) {
1313
+ //#region src/vite/config.mts
1314
+ var xn = "bundle.js";
1315
+ function Sn({ core: e, runtimeModuleName: t, entry: n, outDir: r, mode: i, sourcemap: a = !1, watch: o, onOutput: s, stdout: c, stderr: l, quiet: u, runtimeConfig: d }) {
1159
1316
  let f = i === "development" || a;
1160
1317
  return {
1161
1318
  configFile: !1,
@@ -1163,22 +1320,22 @@ function tn({ core: e, runtimeModuleName: t, entry: n, outDir: r, mode: i, sourc
1163
1320
  mode: i,
1164
1321
  clearScreen: !1,
1165
1322
  logLevel: u ? "silent" : "info",
1166
- customLogger: Xt(c, l),
1323
+ customLogger: _n(c, l),
1167
1324
  define: { "process.env.NODE_ENV": JSON.stringify(i) },
1168
1325
  plugins: [
1169
- ce({ template: { compilerOptions: {
1326
+ pe({ template: { compilerOptions: {
1170
1327
  runtimeModuleName: t,
1171
1328
  hoistStatic: !1
1172
1329
  } } }),
1173
- $t(e),
1174
- qt(d),
1175
- Wt(e, s)
1330
+ bn(e),
1331
+ mn(d),
1332
+ dn(e, s)
1176
1333
  ],
1177
1334
  build: {
1178
1335
  lib: {
1179
1336
  entry: n,
1180
1337
  formats: ["es"],
1181
- fileName: () => en
1338
+ fileName: () => xn
1182
1339
  },
1183
1340
  outDir: r,
1184
1341
  emptyOutDir: i === "production",
@@ -1194,10 +1351,10 @@ function tn({ core: e, runtimeModuleName: t, entry: n, outDir: r, mode: i, sourc
1194
1351
  };
1195
1352
  }
1196
1353
  //#endregion
1197
- //#region src/adapter/vite/build.mts
1198
- async function nn(e, t, { entry: n, outDir: r, sourcemap: i, runtimeConfig: a, stdout: o = process.stdout, stderr: s = process.stderr, quiet: c = !1 }) {
1354
+ //#region src/vite/build.mts
1355
+ async function Cn(e, t, { entry: n, outDir: r, sourcemap: i, runtimeConfig: a, stdout: o = process.stdout, stderr: s = process.stderr, quiet: c = !1 }) {
1199
1356
  let l;
1200
- if (await ae(tn({
1357
+ if (await ue(Sn({
1201
1358
  core: e,
1202
1359
  runtimeModuleName: t,
1203
1360
  entry: n,
@@ -1210,60 +1367,96 @@ async function nn(e, t, { entry: n, outDir: r, sourcemap: i, runtimeConfig: a, s
1210
1367
  stderr: s,
1211
1368
  quiet: c,
1212
1369
  onOutput: (e) => {
1213
- l = Ut(r, e);
1370
+ l = un(r, e);
1214
1371
  }
1215
1372
  })), !l) throw new e.IncaError("ERR_INCA_BUILD_NO_OUTPUT", "build produced no output");
1216
1373
  return l;
1217
1374
  }
1218
1375
  //#endregion
1219
- //#region src/adapter/vite/hmr.mts
1220
- function rn(e, t) {
1221
- let n = oe(t, [], !1), r = [t.stack, n].filter((e) => e).join("\n");
1376
+ //#region ../../node_modules/.pnpm/ts-dedent@2.3.0/node_modules/ts-dedent/esm/index.js
1377
+ function wn(e) {
1378
+ var t = [...arguments].slice(1), n = Array.from(typeof e == "string" ? [e] : e);
1379
+ n[n.length - 1] = n[n.length - 1].replace(/\r?\n([\t ]*)$/, "");
1380
+ var r = n.reduce(function(e, t) {
1381
+ var n = t.match(/\n([\t ]+|(?!\s).)/g);
1382
+ return n ? e.concat(n.map(function(e) {
1383
+ return e.match(/[\t ]/g)?.length ?? 0;
1384
+ })) : e;
1385
+ }, []);
1386
+ if (r.length) {
1387
+ var i = RegExp(`
1388
+ [ ]{${Math.min.apply(Math, r)}}`, "g");
1389
+ n = n.map(function(e) {
1390
+ return e.replace(i, "\n");
1391
+ });
1392
+ }
1393
+ n[0] = n[0].replace(/^\r?\n/, "");
1394
+ var a = n[0];
1395
+ return t.forEach(function(e, t) {
1396
+ var r = a.match(/(?:^|\n)( *)$/), i = r ? r[1] : "", o = e;
1397
+ typeof e == "string" && e.includes("\n") && (o = String(e).split("\n").map(function(e, t) {
1398
+ return t === 0 ? e : `${i}${e}`;
1399
+ }).join("\n")), a += o + n[t + 1];
1400
+ }), a;
1401
+ }
1402
+ //#endregion
1403
+ //#region src/vite/hmr.mts
1404
+ function Tn(e, t) {
1405
+ let n = de(t, [], !1), r = [t.stack, n].filter((e) => e).join("\n");
1222
1406
  return {
1223
1407
  ...e.bundlerFault(t.message),
1224
1408
  stack: r || null
1225
1409
  };
1226
1410
  }
1227
- function an(e) {
1411
+ function En(e) {
1228
1412
  return y.join(e, "node_modules/.inca/hmr");
1229
1413
  }
1230
- function on() {
1414
+ function Dn() {
1231
1415
  let e = y.dirname(ne(import.meta.url));
1232
1416
  for (; !p(y.join(e, "package.json"));) {
1233
1417
  let t = y.dirname(e);
1234
1418
  if (t === e) throw Error("could not locate @incajs/cli's own package.json");
1235
1419
  e = t;
1236
1420
  }
1237
- return y.join(e, "dist/hmr-runtime.js");
1421
+ return y.join(e, "dist/vite-runtime.js");
1238
1422
  }
1239
- function sn(e, t) {
1423
+ function On(e, t) {
1240
1424
  let n = y.relative(e, t).split(y.sep).join("/");
1241
1425
  return n.startsWith(".") ? n : `./${n}`;
1242
1426
  }
1243
- async function cn(e, t, n) {
1244
- let r = an(e);
1245
- await E(r, { recursive: !0 });
1246
- let i = y.join(r, "entry.js"), a = sn(r, n ?? on()), o = t.split(y.sep).join("/");
1247
- return await k(i, `import { start } from ${JSON.stringify(a)};\nawait start(${JSON.stringify(o)});\n`), i;
1427
+ var kn = /^[A-Za-z_$][\w$]*$/;
1428
+ function An(e) {
1429
+ let t = {};
1430
+ for (let [n, r] of Object.entries(e ?? {})) if (kn.test(n)) try {
1431
+ t[n] = JSON.parse(typeof r == "string" ? r : JSON.stringify(r));
1432
+ } catch {}
1433
+ return t;
1434
+ }
1435
+ async function jn(e, t, n, r) {
1436
+ let i = En(e), a = y.join(i, "entry.js"), o = On(i, r ?? Dn()), s = t.split(y.sep).join("/");
1437
+ return await k(a, wn`
1438
+ import { start } from ${JSON.stringify(o)};
1439
+ await start(${JSON.stringify(s)}, ${JSON.stringify(n)});
1440
+ `), a;
1248
1441
  }
1249
- function ln(e) {
1442
+ function Mn(e) {
1250
1443
  if (e.type === "error") return e.err;
1251
1444
  if (e.type === "custom" && e.event === "vite:invoke") return e.data?.data?.error;
1252
1445
  }
1253
- function un(e) {
1446
+ function Nn(e) {
1254
1447
  if (e.type !== "custom" || e.event !== "vite:invoke") return !1;
1255
1448
  let t = e.data;
1256
1449
  return t.name === "fetchModule" && !t.data?.error;
1257
1450
  }
1258
- function dn(e, t, n, r, i) {
1451
+ function Pn(e, t, n, r, i) {
1259
1452
  let a = /* @__PURE__ */ new Map(), o = { send: s };
1260
1453
  function s(a) {
1261
1454
  if (a.type === "full-reload") {
1262
1455
  t();
1263
1456
  return;
1264
1457
  }
1265
- let o = ln(a);
1266
- o ? (n(o), i.current = void 0) : un(a) && i.current && (r({
1458
+ let o = Mn(a);
1459
+ o ? (n(o), i.current = void 0) : Nn(a) && i.current && (r({
1267
1460
  file: i.current.file,
1268
1461
  took: Date.now() - i.current.at
1269
1462
  }), i.current = void 0), e(a);
@@ -1285,7 +1478,7 @@ function dn(e, t, n, r, i) {
1285
1478
  }
1286
1479
  };
1287
1480
  }
1288
- function fn() {
1481
+ function Fn() {
1289
1482
  let e = "\0inca:vite-client-shim";
1290
1483
  return {
1291
1484
  name: "inca:shim-vite-client",
@@ -1298,7 +1491,7 @@ function fn() {
1298
1491
  }
1299
1492
  };
1300
1493
  }
1301
- function pn(e) {
1494
+ function In(e) {
1302
1495
  return {
1303
1496
  name: "inca:file-changed",
1304
1497
  hotUpdate(t) {
@@ -1313,16 +1506,17 @@ function pn(e) {
1313
1506
  }
1314
1507
  };
1315
1508
  }
1316
- async function mn(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, stdout: o = process.stdout, stderr: s = process.stderr, quiet: c = !1, notify: l, reload: u, onError: d, onUpdate: f = () => {} }) {
1317
- let p = await cn(r, n, a), m = Kt(i), h = y.join(an(r), Gt);
1318
- m ? await k(h, m) : await O(h, { force: !0 });
1319
- let g = { current: void 0 }, { channel: _, dispatch: v } = dn(l, u, (t) => d(rn(e, t)), f, g), b = await se({
1509
+ async function Ln(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, stdout: o = process.stdout, stderr: s = process.stderr, quiet: c = !1, notify: l, reload: u, onError: d, onUpdate: f = () => {} }) {
1510
+ await E(En(r), { recursive: !0 });
1511
+ let p = pn(i), m = y.join(En(r), fn);
1512
+ p ? await k(m, p) : await O(m, { force: !0 });
1513
+ let h = { current: void 0 }, { channel: g, dispatch: _ } = Pn(l, u, (t) => d(Tn(e, t)), f, h), v = await fe({
1320
1514
  configFile: !1,
1321
1515
  root: y.dirname(n),
1322
1516
  mode: "development",
1323
1517
  clearScreen: !1,
1324
1518
  logLevel: c ? "silent" : "info",
1325
- customLogger: Xt(o, s, c),
1519
+ customLogger: _n(o, s, c),
1326
1520
  define: { "process.env.NODE_ENV": JSON.stringify("development") },
1327
1521
  server: {
1328
1522
  middlewareMode: !0,
@@ -1337,32 +1531,37 @@ async function mn(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, st
1337
1531
  consumer: "client",
1338
1532
  dev: {
1339
1533
  moduleRunnerTransform: !0,
1340
- createEnvironment: (e, t) => new ie(e, t, {
1534
+ createEnvironment: (e, t) => new le(e, t, {
1341
1535
  hot: !0,
1342
- transport: _
1536
+ transport: g
1343
1537
  })
1344
1538
  }
1345
1539
  } },
1346
1540
  plugins: [
1347
- ce({ template: { compilerOptions: {
1541
+ pe({ template: { compilerOptions: {
1348
1542
  runtimeModuleName: t,
1349
1543
  hoistStatic: !1
1350
1544
  } } }),
1351
- $t(e),
1352
- fn(),
1353
- pn(g)
1545
+ bn(e),
1546
+ Fn(),
1547
+ In(h)
1354
1548
  ]
1355
- });
1549
+ }), b;
1550
+ try {
1551
+ b = await jn(r, n, An(v.environments.client.config.define), a);
1552
+ } catch (e) {
1553
+ throw await v.close(), e;
1554
+ }
1356
1555
  return {
1357
- entryFile: p,
1358
- dispatch: v,
1359
- close: () => b.close()
1556
+ entryFile: b,
1557
+ dispatch: _,
1558
+ close: () => v.close()
1360
1559
  };
1361
1560
  }
1362
1561
  //#endregion
1363
- //#region src/adapter/vite/watch.mts
1364
- async function hn(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, stderr: a = process.stderr, quiet: o = !1, ...s }) {
1365
- let { outDir: c } = s, l, u = await ae(tn({
1562
+ //#region src/vite/watch.mts
1563
+ async function Rn(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, stderr: a = process.stderr, quiet: o = !1, ...s }) {
1564
+ let { outDir: c } = s, l, u = await ue(Sn({
1366
1565
  core: e,
1367
1566
  runtimeModuleName: t,
1368
1567
  ...s,
@@ -1371,7 +1570,7 @@ async function hn(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, st
1371
1570
  stderr: a,
1372
1571
  quiet: o,
1373
1572
  onOutput: (e) => {
1374
- n(Ut(c, e, l)), l = void 0;
1573
+ n(un(c, e, l)), l = void 0;
1375
1574
  }
1376
1575
  }));
1377
1576
  return u.on("change", (e) => {
@@ -1387,275 +1586,42 @@ async function hn(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, st
1387
1586
  }), { close: () => u.close() };
1388
1587
  }
1389
1588
  //#endregion
1390
- //#region src/adapter/vite/createBundler.mts
1391
- function gn(e, t) {
1589
+ //#region src/vite/createBundler.mts
1590
+ function zn(e, t) {
1392
1591
  return {
1393
- watch: (n) => hn(e, t, n),
1394
- build: (n) => nn(e, t, n),
1395
- hmr: (n) => mn(e, t, n)
1396
- };
1397
- }
1398
- //#endregion
1399
- //#region src/dev-client/hostBin.mts
1400
- var _n = "INCA_HOST_BIN";
1401
- function vn() {
1402
- let e = process.platform === "darwin" || process.platform === "linux" ? process.platform : void 0, t = process.arch === "arm64" || process.arch === "x64" ? process.arch : void 0;
1403
- return e && t ? `@incajs/host-${e}-${t}` : void 0;
1404
- }
1405
- function yn() {
1406
- let e = vn();
1407
- if (e) try {
1408
- return le(import.meta.url).resolve(`${e}/bin/inca-host`);
1409
- } catch {
1410
- return;
1411
- }
1412
- }
1413
- function bn() {
1414
- let e = process.env[_n];
1415
- if (e) return e;
1416
- let t = yn();
1417
- if (t) return t;
1418
- let n = vn();
1419
- throw new J("ERR_INCA_HOST_BIN_UNRESOLVED", `no inca-host binary found. ${n ? `no ${n} package is installed for it` : `this platform (${process.platform}/${process.arch}) has no published package`}, and ${_n} isn't set to one`);
1420
- }
1421
- function xn(e) {
1422
- if (!_(e, { throwIfNoEntry: !1 })?.isFile()) throw new J("ERR_INCA_HOST_BIN_NOT_FOUND", `no host binary at ${e}. check that it was built`);
1423
- }
1424
- //#endregion
1425
- //#region src/dev-client/hostError.mts
1426
- var Sn = class extends Error {
1427
- code;
1428
- hostStack;
1429
- constructor(e, t, n = null) {
1430
- super(e), this.code = t, this.hostStack = n, this.name = "HostError";
1431
- }
1432
- };
1433
- function Cn(e) {
1434
- return typeof e == "object" && !!e && e.jsonrpc === "2.0";
1435
- }
1436
- //#endregion
1437
- //#region src/dev-client/hostClient.mts
1438
- var wn = (e) => {
1439
- process.stderr.write(e.endsWith("\n") ? e : `${e}\n`);
1440
- }, Tn = -32e3, En = class {
1441
- #e;
1442
- #t;
1443
- #n = 1;
1444
- #r = /* @__PURE__ */ new Map();
1445
- #i = !1;
1446
- constructor(e) {
1447
- this.#e = e;
1448
- }
1449
- async start() {
1450
- let e = this.#e.hostBin ?? bn();
1451
- xn(e);
1452
- let t = ue(e, ["--dev", this.#e.entryFile], {
1453
- stdio: [
1454
- "pipe",
1455
- "pipe",
1456
- "pipe"
1457
- ],
1458
- env: this.#e.env
1459
- });
1460
- this.#t = t;
1461
- let n = this.#e.onStderr ?? wn;
1462
- t.stderr.setEncoding("utf8"), t.stderr.on("data", (e) => n(e)), t.stdin.on("error", (e) => {
1463
- e.code !== "EPIPE" && n(`inca-host stdin: ${e.message}\n`);
1464
- }), de.createInterface({ input: t.stdout }).on("line", (e) => {
1465
- this.#a(e, n);
1466
- }), t.on("exit", (e, t) => {
1467
- let n = /* @__PURE__ */ Error(`inca-host exited (code=${String(e)}, signal=${String(t)}) before answering`);
1468
- for (let { reject: e } of this.#r.values()) e(n);
1469
- this.#r.clear(), this.#i || this.#e.onExit?.(e, t);
1470
- });
1471
- let r = !1;
1472
- t.on("error", (e) => {
1473
- r && n(`inca-host: ${e.message}\n`);
1474
- }), await j(t, "spawn"), r = !0;
1475
- }
1476
- #a(e, t) {
1477
- let n;
1478
- try {
1479
- n = JSON.parse(e);
1480
- } catch {
1481
- t(`[stray stdout] ${e}`);
1482
- return;
1483
- }
1484
- if (!Cn(n)) {
1485
- t(`[stray stdout] ${e}`);
1486
- return;
1487
- }
1488
- if ("method" in n) {
1489
- this.#o(n.method, n.params, t);
1490
- return;
1491
- }
1492
- if (n.id === null) {
1493
- if (!("error" in n)) return;
1494
- let { code: e, message: r, data: i } = n.error;
1495
- e === Tn ? this.#e.onAppError?.({
1496
- message: r,
1497
- stack: i?.stack ?? null
1498
- }) : t(`[host error ${String(e)}] ${r}\n`);
1499
- return;
1500
- }
1501
- let r = this.#r.get(n.id);
1502
- r && (this.#r.delete(n.id), "error" in n ? r.reject(new Sn(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
1503
- }
1504
- #o(e, t, n) {
1505
- switch (e) {
1506
- case "ready": {
1507
- let { protocol: e } = t;
1508
- if (e !== 0) {
1509
- n(`inca-host speaks protocol ${String(e)}, this package was built for 0. stopping it rather than carrying on`), this.#t && this.#s(this.#t);
1510
- return;
1511
- }
1512
- this.#e.onReady?.();
1513
- return;
1514
- }
1515
- case "appError":
1516
- this.#e.onAppError?.(t);
1517
- return;
1518
- default: {
1519
- let r = this.#e.integrations?.[e];
1520
- r ? r(t) : n(`[unhandled notification] ${e}`);
1521
- }
1522
- }
1523
- }
1524
- async #s(e) {
1525
- let t = j(e, "exit");
1526
- e.kill(), await t;
1527
- }
1528
- async call(e, t, n) {
1529
- let r = this.#t;
1530
- if (!r) throw Error("HostClient.start() has not been called");
1531
- let i = this.#n++, a = JSON.stringify({
1532
- jsonrpc: "2.0",
1533
- id: i,
1534
- method: e,
1535
- params: t
1536
- });
1537
- return new Promise((t, o) => {
1538
- let s = n === void 0 ? void 0 : setTimeout(() => {
1539
- this.#r.delete(i), o(/* @__PURE__ */ Error(`${e} timed out after ${String(n)}ms`));
1540
- }, n);
1541
- this.#r.set(i, {
1542
- resolve: (e) => {
1543
- clearTimeout(s), t(e);
1544
- },
1545
- reject: (e) => {
1546
- clearTimeout(s), o(e);
1547
- }
1548
- }), r.stdin.write(`${a}\n`, (e) => {
1549
- e && (clearTimeout(s), this.#r.delete(i), o(e));
1550
- });
1551
- });
1552
- }
1553
- notify(e, t) {
1554
- let n = this.#t;
1555
- if (!n) throw Error("HostClient.start() has not been called");
1556
- n.stdin.write(`${JSON.stringify({
1557
- jsonrpc: "2.0",
1558
- method: e,
1559
- params: t
1560
- })}\n`);
1561
- }
1562
- async stop(e = 2e3) {
1563
- let t = this.#t;
1564
- if (!t || t.exitCode !== null || t.signalCode !== null) return;
1565
- this.#i = !0;
1566
- let n = j(t, "exit");
1567
- this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), fe(e, void 0, { ref: !1 }).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
1568
- }
1569
- }, Dn = "[inca]", On = new Intl.DateTimeFormat(void 0, {
1570
- hour: "numeric",
1571
- minute: "numeric",
1572
- second: "numeric"
1573
- }), Y = { timestamp: !0 };
1574
- function X(e, t, n) {
1575
- let r = S(["bold", n], Dn, { stream: e });
1576
- return t.timestamp ? `${S("dim", On.format(/* @__PURE__ */ new Date()), { stream: e })} ${r}` : r;
1577
- }
1578
- function Z(e, t, n = {}) {
1579
- e.write(`${X(e, n, "cyan")} ${t}\n`);
1580
- }
1581
- function kn(e, t, n = {}) {
1582
- e.write(`${X(e, n, "yellow")} ${t}\n`);
1583
- }
1584
- function An(e) {
1585
- let t = e.code;
1586
- return typeof t == "string" ? t : null;
1587
- }
1588
- function jn(e) {
1589
- return /\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0] ?? null;
1590
- }
1591
- function Mn(e) {
1592
- let t = e.stack;
1593
- if (!t) return null;
1594
- for (let n of [`${e.name}: ${e.message}`, e.message]) if (t.startsWith(n)) return t.slice(n.length).replace(/^\r?\n/, "") || null;
1595
- return t;
1596
- }
1597
- function Nn(e) {
1598
- let t = /^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);
1599
- return t ? {
1600
- message: e.slice(t[0].length),
1601
- stack: null,
1602
- code: t[1]
1603
- } : {
1604
- message: e.replace(/^\w*Error: /, ""),
1605
- stack: null,
1606
- code: null
1607
- };
1608
- }
1609
- function Q(e) {
1610
- return e instanceof Sn ? {
1611
- message: e.message,
1612
- stack: e.hostStack,
1613
- code: An(e)
1614
- } : e instanceof Error ? {
1615
- message: e.message,
1616
- stack: Mn(e),
1617
- code: An(e) ?? jn(e.message)
1618
- } : {
1619
- message: String(e),
1620
- stack: null,
1621
- code: null
1592
+ watch: (n) => Rn(e, t, n),
1593
+ build: (n) => Cn(e, t, n),
1594
+ hmr: (n) => Ln(e, t, n)
1622
1595
  };
1623
1596
  }
1624
- function Pn(e, t) {
1625
- return e.split("\n").map((e) => /^\s*at\b/.test(e) ? S("dim", e, { stream: t }) : e).join("\n");
1626
- }
1627
- function $(e, t, n, r = {}) {
1628
- n.stack && e.write(`${Pn(n.stack, e)}\n`);
1629
- let i = n.code ? ` (${S("bold", n.code, { stream: e })})` : "";
1630
- e.write(`${X(e, r, "red")} ${t}${i}: ${n.message}\n`);
1631
- }
1632
1597
  //#endregion
1633
1598
  //#region src/defaultBundler.mts
1634
- var Fn = gn(/* @__PURE__ */ e({
1635
- IncaError: () => J,
1636
- bundlerFault: () => Nn
1637
- }), "incajs/vue/runtime"), In = [
1599
+ var Bn = zn(ln, "incajs/vue/runtime"), Vn = [
1638
1600
  "main.mts",
1639
1601
  "main.ts",
1640
1602
  "main.js"
1641
1603
  ];
1642
- async function Ln(e) {
1643
- let t = In.map((t) => y.join(e, "src", t)).find((e) => p(e));
1604
+ async function Hn(e) {
1605
+ let t = Vn.map((t) => y.join(e, "src", t)).find((e) => p(e));
1644
1606
  if (t) return t;
1645
1607
  let n = y.join(e, "src/App.vue");
1646
- if (p(n)) return Rn(n, e);
1647
- throw new J("ERR_INCA_ENTRY_NOT_FOUND", `no app entry found. check that ${y.join(e, "src/main.ts")} or ${n} exists`);
1608
+ if (p(n)) return Un(n, e);
1609
+ throw new Y("ERR_INCA_ENTRY_NOT_FOUND", `no app entry found. check that ${y.join(e, "src/main.ts")} or ${n} exists`);
1648
1610
  }
1649
- async function Rn(e, t) {
1611
+ async function Un(e, t) {
1650
1612
  let n = y.join(t, "node_modules/.inca");
1651
1613
  await E(n, { recursive: !0 });
1652
1614
  let r = y.join(n, "entry.mts"), i = JSON.stringify(e.split(y.sep).join("/"));
1653
- return await k(r, `import { createIncaApp } from "incajs/vue";\nimport App from ${i};\ncreateIncaApp(App).mount();\n`), r;
1615
+ return await k(r, wn`
1616
+ import { createIncaApp } from "incajs/vue";
1617
+ import App from ${i};
1618
+ createIncaApp(App).mount();
1619
+ `), r;
1654
1620
  }
1655
1621
  //#endregion
1656
1622
  //#region src/build.mts
1657
- async function zn(e = {}) {
1658
- let t = e.cwd ?? process.cwd(), n = e.config ?? await zt(t), r = y.resolve(t, n.outDir), i = e.bundler ?? Fn, a = e.entry ?? n.entry ?? await Ln(t);
1623
+ async function Wn(e = {}) {
1624
+ let t = e.cwd ?? process.cwd(), n = e.config ?? await zt(t), r = y.resolve(t, n.outDir), i = e.bundler ?? Bn, a = e.entry ?? n.entry ?? await Hn(t);
1659
1625
  Ft(t, r, a);
1660
1626
  let o = e.runtimeConfig ?? await Ht(t);
1661
1627
  return i.build({
@@ -1669,43 +1635,43 @@ async function zn(e = {}) {
1669
1635
  }
1670
1636
  //#endregion
1671
1637
  //#region src/devLock.mts
1672
- function Bn(e) {
1638
+ function Gn(e) {
1673
1639
  return y.join(e, "node_modules/.inca/dev.pid");
1674
1640
  }
1675
- function Vn(e) {
1641
+ function Kn(e) {
1676
1642
  try {
1677
1643
  return process.kill(e, 0), !0;
1678
1644
  } catch (e) {
1679
1645
  return e.code === "EPERM";
1680
1646
  }
1681
1647
  }
1682
- var Hn = pe();
1683
- function Un(e) {
1684
- return new J("ERR_INCA_DEV_RUNNING", `inca dev is already running for this app (pid ${String(e)})`);
1648
+ var qn = me();
1649
+ function Jn(e) {
1650
+ return new Y("ERR_INCA_DEV_RUNNING", `inca dev is already running for this app (pid ${String(e)})`);
1685
1651
  }
1686
- async function Wn(e) {
1687
- let t = Bn(e), n = `${String(process.pid)}:${Hn}`, r = `${t}.${pe()}`;
1652
+ async function Yn(e) {
1653
+ let t = Gn(e), n = `${String(process.pid)}:${qn}`, r = `${t}.${me()}`;
1688
1654
  await E(y.dirname(t), { recursive: !0 }), await k(r, n);
1689
1655
  let i = process.pid;
1690
1656
  try {
1691
1657
  for (let e = 0; e < 5; e++) {
1692
1658
  try {
1693
- return await T(r, t), Gn(t, n);
1659
+ return await T(r, t), Xn(t, n);
1694
1660
  } catch (e) {
1695
1661
  if (e.code !== "EEXIST") throw e;
1696
1662
  }
1697
1663
  let e = await D(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
1698
1664
  if (a === process.pid) {
1699
- if (e === n) throw Un(a);
1700
- } else if (Number.isSafeInteger(a) && a > 0 && Vn(a)) throw Un(a);
1665
+ if (e === n) throw Jn(a);
1666
+ } else if (Number.isSafeInteger(a) && a > 0 && Kn(a)) throw Jn(a);
1701
1667
  i = Number.isSafeInteger(a) && a > 0 ? a : i, await O(t, { force: !0 });
1702
1668
  }
1703
- throw Un(i);
1669
+ throw Jn(i);
1704
1670
  } finally {
1705
1671
  await O(r, { force: !0 });
1706
1672
  }
1707
1673
  }
1708
- function Gn(e, t) {
1674
+ function Xn(e, t) {
1709
1675
  let n = !1;
1710
1676
  return async () => {
1711
1677
  n || (n = !0, await D(e, "utf8").catch(() => "") === t && await O(e, { force: !0 }));
@@ -1713,24 +1679,26 @@ function Gn(e, t) {
1713
1679
  }
1714
1680
  //#endregion
1715
1681
  //#region src/plist.mts
1716
- function Kn(e) {
1682
+ function Zn(e) {
1717
1683
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
1718
1684
  }
1719
- function qn(e) {
1720
- return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${Kn(e)}</string>`;
1685
+ function Qn(e) {
1686
+ return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${Zn(e)}</string>`;
1721
1687
  }
1722
- function Jn(e) {
1723
- return `<?xml version="1.0" encoding="UTF-8"?>
1724
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
1725
- <plist version="1.0">
1726
- <dict>
1727
- ${Object.entries(e).map(([e, t]) => `\t<key>${Kn(e)}</key>\n\t${qn(t)}`).join("\n")}\n</dict>
1728
- </plist>
1729
- `;
1688
+ function $n(e) {
1689
+ return wn`
1690
+ <?xml version="1.0" encoding="UTF-8"?>
1691
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
1692
+ <plist version="1.0">
1693
+ <dict>
1694
+ ${Object.entries(e).map(([e, t]) => `\t<key>${Zn(e)}</key>\n\t${Qn(t)}`).join("\n")}
1695
+ </dict>
1696
+ </plist>
1697
+ `;
1730
1698
  }
1731
1699
  //#endregion
1732
1700
  //#region src/macosApp.mts
1733
- async function Yn(e) {
1701
+ async function er(e) {
1734
1702
  let { appPath: t, metadata: n, hostBin: r } = e;
1735
1703
  await O(t, {
1736
1704
  recursive: !0,
@@ -1755,7 +1723,7 @@ async function Yn(e) {
1755
1723
  let e = y.basename(n.icon);
1756
1724
  await w(n.icon, y.join(o, e)), c.CFBundleIconFile = e;
1757
1725
  }
1758
- return await k(y.join(i, "Info.plist"), Jn(c)), await k(y.join(i, "PkgInfo"), "APPL????"), {
1726
+ return await k(y.join(i, "Info.plist"), $n(c)), await k(y.join(i, "PkgInfo"), "APPL????"), {
1759
1727
  appPath: t,
1760
1728
  executablePath: s,
1761
1729
  resourcesDir: o
@@ -1763,8 +1731,8 @@ async function Yn(e) {
1763
1731
  }
1764
1732
  //#endregion
1765
1733
  //#region src/watchForEdit.mts
1766
- var Xn = /^(?:inca\.config\.[a-z0-9]+|package\.json)$/, Zn = [...In, "App.vue"];
1767
- function Qn(e, t = {}) {
1734
+ var tr = /^(?:inca\.config\.[a-z0-9]+|package\.json)$/, nr = [...Vn, "App.vue"];
1735
+ function rr(e, t = {}) {
1768
1736
  let n = t.debounceMs ?? 100, r = /* @__PURE__ */ new Set(), i, a = !1, o = () => {}, s = new Promise((e) => {
1769
1737
  o = e;
1770
1738
  }), c = () => {
@@ -1785,7 +1753,7 @@ function Qn(e, t = {}) {
1785
1753
  r.clear();
1786
1754
  };
1787
1755
  try {
1788
- l(e, (e) => e === "src" || Xn.test(e)), l(y.join(e, "src"), (e) => Zn.includes(e));
1756
+ l(e, (e) => e === "src" || tr.test(e)), l(y.join(e, "src"), (e) => nr.includes(e));
1789
1757
  } catch (e) {
1790
1758
  throw u(), e;
1791
1759
  }
@@ -1801,7 +1769,7 @@ function Qn(e, t = {}) {
1801
1769
  }
1802
1770
  //#endregion
1803
1771
  //#region src/retryOnEdit.mts
1804
- function $n(e, t) {
1772
+ function ir(e, t) {
1805
1773
  return new Promise((n) => {
1806
1774
  let r = () => n(!1);
1807
1775
  t.addEventListener("abort", r, { once: !0 }), e.then(() => {
@@ -1809,25 +1777,25 @@ function $n(e, t) {
1809
1777
  });
1810
1778
  });
1811
1779
  }
1812
- async function er(e) {
1780
+ async function ar(e) {
1813
1781
  let { cwd: t, signal: n, stdout: r, stderr: i, debounceMs: a } = e, o = !1;
1814
1782
  for (;;) {
1815
- let s = Qn(t, { debounceMs: a });
1783
+ let s = rr(t, { debounceMs: a });
1816
1784
  try {
1817
1785
  return await e.attempt(s);
1818
1786
  } catch (e) {
1819
- let t = e instanceof J ? e.path : void 0;
1787
+ let t = e instanceof Y ? e.path : void 0;
1820
1788
  if (t) try {
1821
1789
  s.add(t);
1822
1790
  } catch (t) {
1823
- throw $(i, "build failed", Q(e), Y), t;
1791
+ throw $(i, "build failed", Q(e), X), t;
1824
1792
  }
1825
1793
  if (!n.aborted && !o && t && p(t)) {
1826
1794
  o = !0;
1827
1795
  continue;
1828
1796
  }
1829
- if (o = !1, $(i, "build failed", Q(e), Y), n.aborted || (Z(r, "waiting for a change to retry", Y), !await $n(s.edited, n))) return;
1830
- Z(r, "retrying", Y);
1797
+ if (o = !1, $(i, "build failed", Q(e), X), n.aborted || (Z(r, "waiting for a change to retry", X), !await ir(s.edited, n))) return;
1798
+ Z(r, "retrying", X);
1831
1799
  } finally {
1832
1800
  s.close();
1833
1801
  }
@@ -1835,30 +1803,30 @@ async function er(e) {
1835
1803
  }
1836
1804
  //#endregion
1837
1805
  //#region src/dev.mts
1838
- var tr = 1e4, nr = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
1839
- async function rr(e, t) {
1806
+ var or = 1e4, sr = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
1807
+ async function cr(e, t) {
1840
1808
  try {
1841
1809
  return await Bt(e);
1842
1810
  } catch (e) {
1843
- if (!(e instanceof J) || !nr.includes(e.code)) throw e;
1844
- Z(t, `running unnamed. ${e.message}`, Y);
1811
+ if (!(e instanceof Y) || !sr.includes(e.code)) throw e;
1812
+ Z(t, `running unnamed. ${e.message}`, X);
1845
1813
  return;
1846
1814
  }
1847
1815
  }
1848
- async function ir(e, t, n, r) {
1816
+ async function lr(e, t, n, r) {
1849
1817
  if (process.platform === "darwin" && t) try {
1850
- return (await Yn({
1818
+ return (await er({
1851
1819
  appPath: y.join(e, "node_modules/.inca", `${t.productName}.app`),
1852
1820
  metadata: t,
1853
1821
  hostBin: n,
1854
1822
  link: !0
1855
1823
  })).executablePath;
1856
1824
  } catch (e) {
1857
- Z(r, `running unbundled. ${Q(e).message}`, Y);
1825
+ Z(r, `running unbundled. ${Q(e).message}`, X);
1858
1826
  return;
1859
1827
  }
1860
1828
  }
1861
- async function ar(e, t) {
1829
+ async function ur(e, t) {
1862
1830
  let n = new Set(t), r;
1863
1831
  try {
1864
1832
  r = await te(e, {
@@ -1870,29 +1838,29 @@ async function ar(e, t) {
1870
1838
  }
1871
1839
  await Promise.all(r.filter((e) => e.isFile()).map((t) => y.relative(e, y.join(t.parentPath, t.name))).filter((e) => !n.has(e)).map((t) => O(y.join(e, t), { force: !0 })));
1872
1840
  }
1873
- function or(e) {
1841
+ function dr(e) {
1874
1842
  let { NO_COLOR: t, FORCE_COLOR: n } = process.env;
1875
1843
  if (!(!e.isTTY || t || n)) return {
1876
1844
  ...process.env,
1877
1845
  FORCE_COLOR: "1"
1878
1846
  };
1879
1847
  }
1880
- async function sr(e) {
1881
- let t = e.cwd ?? process.cwd(), n = await Wn(t);
1848
+ async function fr(e) {
1849
+ let t = e.cwd ?? process.cwd(), n = await Yn(t);
1882
1850
  try {
1883
- let n = e.hostBin ?? bn();
1884
- xn(n);
1885
- let r = e.bundler ?? Fn, i = e.stdout ?? process.stdout, a = e.stderr ?? process.stderr, o = e.experimentalHmr ? r.hmr?.bind(r) : void 0;
1886
- if (e.experimentalHmr && !o) throw new J("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
1887
- let s = await er({
1851
+ let n = e.hostBin ?? Kt();
1852
+ qt(n);
1853
+ let r = e.bundler ?? Bn, i = e.stdout ?? process.stdout, a = e.stderr ?? process.stderr, o = e.experimentalHmr ? r.hmr?.bind(r) : void 0;
1854
+ if (e.experimentalHmr && !o) throw new Y("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
1855
+ let s = await ar({
1888
1856
  cwd: t,
1889
1857
  signal: e.signal,
1890
1858
  stdout: i,
1891
1859
  stderr: a,
1892
1860
  async attempt() {
1893
- let n = await zt(t), r = y.resolve(t, n.outDir), a = e.entry ?? n.entry ?? await Ln(t);
1861
+ let n = await zt(t), r = y.resolve(t, n.outDir), a = e.entry ?? n.entry ?? await Hn(t);
1894
1862
  Ft(t, r, a);
1895
- let o = await rr(t, i);
1863
+ let o = await cr(t, i);
1896
1864
  return {
1897
1865
  outDir: r,
1898
1866
  entry: a,
@@ -1902,48 +1870,48 @@ async function sr(e) {
1902
1870
  }
1903
1871
  });
1904
1872
  if (!s) return;
1905
- let { outDir: c, entry: l, metadata: u, runtimeConfig: d } = s, f = await ir(t, u, n, i) ?? n, p, m = !1, h = !1, g = !1, _, v = Promise.resolve(), b = () => {}, ee = new Promise((e) => {
1873
+ let { outDir: c, entry: l, metadata: u, runtimeConfig: d } = s, f = await lr(t, u, n, i) ?? n, p, m = !1, h = !1, g = !1, _, v = Promise.resolve(), b = () => {}, ee = new Promise((e) => {
1906
1874
  b = e;
1907
1875
  });
1908
1876
  async function x() {
1909
1877
  try {
1910
- return await p?.call("reload", void 0, tr), !0;
1878
+ return await p?.call("reload", void 0, or), !0;
1911
1879
  } catch (e) {
1912
- return $(a, "reload failed", Q(e), Y), !1;
1880
+ return $(a, "reload failed", Q(e), X), !1;
1913
1881
  }
1914
1882
  }
1915
1883
  async function C(e, t) {
1916
- let n = new En({
1884
+ let n = new Qt({
1917
1885
  entryFile: e,
1918
1886
  hostBin: f,
1919
- env: or(a),
1887
+ env: dr(a),
1920
1888
  onStderr: (e) => a.write(e),
1921
1889
  onReady: () => {
1922
- m = !0, Z(i, "ready", Y), h && (h = !1, x());
1890
+ m = !0, Z(i, "ready", X), h && (h = !1, x());
1923
1891
  },
1924
- onAppError: (e) => $(a, "app error", e, Y),
1892
+ onAppError: (e) => $(a, "app error", e, X),
1925
1893
  onExit: (e, t) => {
1926
1894
  g = !m, _ = {
1927
1895
  code: e,
1928
1896
  signal: t
1929
- }, Z(i, "host exited. stopping", Y), b();
1897
+ }, Z(i, "host exited. stopping", X), b();
1930
1898
  },
1931
1899
  integrations: t
1932
1900
  });
1933
1901
  try {
1934
1902
  await n.start();
1935
1903
  } catch (e) {
1936
- $(a, "failed to start inca-host", Q(e), Y);
1904
+ $(a, "failed to start the host", Q(e), X);
1937
1905
  return;
1938
1906
  }
1939
1907
  p = n;
1940
1908
  }
1941
1909
  async function w(e) {
1942
- if (await ar(e.outDir, e.files), !p) await C(e.entryFile);
1910
+ if (await ur(e.outDir, e.files), !p) await C(e.entryFile);
1943
1911
  else if (!m) h = !0;
1944
1912
  else if (await x() && e.changed) {
1945
1913
  let n = S("dim", y.relative(t, e.changed.file), { stream: i }), r = Date.now() - e.changed.at;
1946
- Z(i, `${S("green", "reload")} ${n} (${r}ms)`, Y);
1914
+ Z(i, `${S("green", "reload")} ${n} (${r}ms)`, X);
1947
1915
  }
1948
1916
  }
1949
1917
  let T;
@@ -1958,11 +1926,11 @@ async function sr(e) {
1958
1926
  reload: () => {
1959
1927
  m ? x() : h = !0;
1960
1928
  },
1961
- onError: (e) => $(a, "build failed", e, Y),
1929
+ onError: (e) => $(a, "build failed", e, X),
1962
1930
  onUpdate: ({ file: e, took: n }) => {
1963
1931
  if (!m) return;
1964
1932
  let r = S("dim", y.relative(t, e), { stream: i });
1965
- Z(i, `${S("green", "update")} ${r} (${n}ms)`, Y);
1933
+ Z(i, `${S("green", "update")} ${r} (${n}ms)`, X);
1966
1934
  }
1967
1935
  });
1968
1936
  await C(e.entryFile, { vite: (t) => e.dispatch(t) }), T = e, p || b();
@@ -1977,13 +1945,13 @@ async function sr(e) {
1977
1945
  v = v.then(() => w(e));
1978
1946
  },
1979
1947
  onError: (e) => {
1980
- $(a, "build failed", e, Y);
1948
+ $(a, "build failed", e, X);
1981
1949
  }
1982
1950
  });
1983
- if (e.signal.aborted ? b() : e.signal.addEventListener("abort", () => b(), { once: !0 }), await ee, await v, await p?.stop(), await T.close(), g) throw new J("ERR_INCA_HOST_EXITED_EARLY", "the host exited before it was ready");
1951
+ if (e.signal.aborted ? b() : e.signal.addEventListener("abort", () => b(), { once: !0 }), await ee, await v, await p?.stop(), await T.close(), g) throw new Y("ERR_INCA_HOST_EXITED_EARLY", "the host exited before it was ready");
1984
1952
  if (_ && _.code !== 0 && _.signal !== "SIGINT" && _.signal !== "SIGTERM") {
1985
1953
  let { code: e, signal: t } = _;
1986
- throw new J("ERR_INCA_HOST_CRASHED", `the host exited with ${t ? `signal ${t}` : `code ${e}`}`);
1954
+ throw new Y("ERR_INCA_HOST_CRASHED", `the host exited with ${t ? `signal ${t}` : `code ${e}`}`);
1987
1955
  }
1988
1956
  } finally {
1989
1957
  await n();
@@ -1991,44 +1959,44 @@ async function sr(e) {
1991
1959
  }
1992
1960
  //#endregion
1993
1961
  //#region src/package.mts
1994
- function cr() {
1962
+ function pr() {
1995
1963
  if (process.platform === "darwin") return "macos";
1996
1964
  if (process.platform === "linux") return "linux";
1997
- throw new J("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
1965
+ throw new Y("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
1998
1966
  }
1999
- async function lr(e, t) {
1967
+ async function mr(e, t) {
2000
1968
  await Promise.all(e.files.map(async (n) => {
2001
1969
  let r = y.join(t, n);
2002
1970
  await E(y.dirname(r), { recursive: !0 }), await w(y.join(e.outDir, n), r);
2003
1971
  }));
2004
1972
  }
2005
- function ur(e, t) {
1973
+ function hr(e, t) {
2006
1974
  let n = e.files.map((e) => e.split("/")[0] ?? e).find((e) => e.toLowerCase() === t.toLowerCase());
2007
- if (n !== void 0) throw new J("ERR_INCA_PRODUCT_NAME_INVALID", `the packaged app's directory "${t}" collides with "${n}" in the build output. Set a different "productName" in inca.config.ts`);
1975
+ if (n !== void 0) throw new Y("ERR_INCA_PRODUCT_NAME_INVALID", `the packaged app's directory "${t}" collides with "${n}" in the build output. Set a different "productName" in inca.config.ts`);
2008
1976
  }
2009
- async function dr({ metadata: e, output: t, hostBin: n }) {
2010
- let { appPath: r, resourcesDir: i } = await Yn({
1977
+ async function gr({ metadata: e, output: t, hostBin: n }) {
1978
+ let { appPath: r, resourcesDir: i } = await er({
2011
1979
  appPath: y.join(t.outDir, `${e.productName}.app`),
2012
1980
  metadata: e,
2013
1981
  hostBin: n
2014
1982
  });
2015
- return await lr(t, i), r;
1983
+ return await mr(t, i), r;
2016
1984
  }
2017
- async function fr({ metadata: e, output: t, hostBin: n }) {
1985
+ async function _r({ metadata: e, output: t, hostBin: n }) {
2018
1986
  let r = c(e.productName);
2019
- ur(t, r);
1987
+ hr(t, r);
2020
1988
  let i = y.join(t.outDir, r);
2021
1989
  await O(i, {
2022
1990
  recursive: !0,
2023
1991
  force: !0
2024
1992
  }), await E(i, { recursive: !0 });
2025
1993
  let a = y.join(i, r);
2026
- return await w(n, a), await C(a, 493), await lr(t, i), i;
1994
+ return await w(n, a), await C(a, 493), await mr(t, i), i;
2027
1995
  }
2028
- async function pr(e = {}) {
2029
- let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? cr(), i = await Bt(t);
1996
+ async function vr(e = {}) {
1997
+ let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? pr(), i = await Bt(t);
2030
1998
  i.usedPackageJsonKey && Z(n, "the \"inca\" key in package.json is deprecated. move these settings to inca.config.ts"), i.identifierIsDefault && Z(n, `no "identifier" set in inca.config.ts. using generated identifier ${i.identifier}`);
2031
- let a = await zn({
1999
+ let a = await Wn({
2032
2000
  cwd: t,
2033
2001
  entry: e.entry,
2034
2002
  config: i,
@@ -2037,26 +2005,26 @@ async function pr(e = {}) {
2037
2005
  bundler: e.bundler,
2038
2006
  stdout: n,
2039
2007
  stderr: e.stderr
2040
- }), o = e.hostBin ?? bn();
2041
- xn(o);
2008
+ }), o = e.hostBin ?? Kt();
2009
+ qt(o);
2042
2010
  let s = {
2043
2011
  metadata: i,
2044
2012
  output: a,
2045
2013
  hostBin: o
2046
2014
  };
2047
- return { appPath: r === "macos" ? await dr(s) : await fr(s) };
2015
+ return { appPath: r === "macos" ? await gr(s) : await _r(s) };
2048
2016
  }
2049
2017
  //#endregion
2050
2018
  //#region src/cli.mts
2051
- function mr(e) {
2019
+ function yr(e) {
2052
2020
  return y.relative(process.cwd(), e);
2053
2021
  }
2054
- var hr = {
2022
+ var br = {
2055
2023
  type: "boolean",
2056
2024
  description: "Write a source map",
2057
2025
  negativeDescription: "Skip the source map"
2058
2026
  };
2059
- function gr() {
2027
+ function xr() {
2060
2028
  for (let e of [
2061
2029
  0,
2062
2030
  1,
@@ -2065,35 +2033,35 @@ function gr() {
2065
2033
  f.closeSync(e);
2066
2034
  } catch {}
2067
2035
  }
2068
- var _r = U({
2036
+ var Sr = B({
2069
2037
  meta: {
2070
2038
  name: "build",
2071
2039
  description: "Bundle the app into dist"
2072
2040
  },
2073
- args: { sourcemap: hr },
2041
+ args: { sourcemap: br },
2074
2042
  async run({ args: e }) {
2075
2043
  try {
2076
- let t = await zn({ sourcemap: e.sourcemap });
2077
- Z(process.stdout, `built ${mr(t.entryFile)}`);
2044
+ let t = await Wn({ sourcemap: e.sourcemap });
2045
+ Z(process.stdout, `built ${yr(t.entryFile)}`);
2078
2046
  } catch (e) {
2079
2047
  $(process.stderr, "build failed", Q(e)), process.exitCode = 1;
2080
2048
  }
2081
2049
  }
2082
- }), vr = U({
2050
+ }), Cr = B({
2083
2051
  meta: {
2084
2052
  name: "package",
2085
2053
  description: "Package the app as an application bundle"
2086
2054
  },
2087
- args: { sourcemap: hr },
2055
+ args: { sourcemap: br },
2088
2056
  async run({ args: e }) {
2089
2057
  try {
2090
- let { appPath: t } = await pr({ sourcemap: e.sourcemap });
2091
- Z(process.stdout, `packaged ${mr(t)}`);
2058
+ let { appPath: t } = await vr({ sourcemap: e.sourcemap });
2059
+ Z(process.stdout, `packaged ${yr(t)}`);
2092
2060
  } catch (e) {
2093
2061
  $(process.stderr, "package failed", Q(e)), process.exitCode = 1;
2094
2062
  }
2095
2063
  }
2096
- }), yr = U({
2064
+ }), wr = B({
2097
2065
  meta: {
2098
2066
  name: "dev",
2099
2067
  description: "Run the app in a development window"
@@ -2103,7 +2071,7 @@ var _r = U({
2103
2071
  description: "Apply edits without a reload (or set INCA_EXPERIMENTAL_HMR)"
2104
2072
  } },
2105
2073
  async run({ args: e }) {
2106
- "sourcemap" in e && kn(process.stderr, "dev ignores --sourcemap and --no-sourcemap", { timestamp: !0 });
2074
+ "sourcemap" in e && nn(process.stderr, "dev ignores --sourcemap and --no-sourcemap", { timestamp: !0 });
2107
2075
  let t = new AbortController(), n = () => {
2108
2076
  t.signal.aborted || (Z(process.stderr, "shutting down", { timestamp: !0 }), t.abort());
2109
2077
  };
@@ -2115,28 +2083,28 @@ var _r = U({
2115
2083
  ].includes(process.env.INCA_EXPERIMENTAL_HMR ?? "");
2116
2084
  r && Z(process.stdout, "experimental HMR active", { timestamp: !0 });
2117
2085
  try {
2118
- await sr({
2086
+ await fr({
2119
2087
  signal: t.signal,
2120
2088
  experimentalHmr: r
2121
- }), t.signal.aborted && gr();
2089
+ }), t.signal.aborted && xr();
2122
2090
  } catch (e) {
2123
2091
  $(process.stderr, "dev failed", Q(e), { timestamp: !0 }), process.exitCode = 1;
2124
2092
  }
2125
2093
  }
2126
- }), br = U({
2094
+ }), Tr = B({
2127
2095
  meta: {
2128
2096
  name: "inca",
2129
- version: Be.version,
2130
- description: Be.description
2097
+ version: ze,
2098
+ description: Be
2131
2099
  },
2132
2100
  subCommands: {
2133
- dev: yr,
2134
- build: _r,
2135
- package: vr
2101
+ dev: wr,
2102
+ build: Sr,
2103
+ package: Cr
2136
2104
  }
2137
2105
  });
2138
- async function xr(e = process.argv) {
2139
- await Le(br, { rawArgs: e.slice(2) });
2106
+ async function Er(e = process.argv) {
2107
+ await Ie(Tr, { rawArgs: e.slice(2) });
2140
2108
  }
2141
2109
  //#endregion
2142
- export { xr as run };
2110
+ export { Er as run };