@incajs/cli 0.0.16 → 0.0.17

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 +616 -660
  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 +1 -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} +3 -3
  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
@@ -8,13 +8,13 @@ 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
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";
11
+ import { createRequire as ie } from "node:module";
12
+ import { spawn as ae } from "node:child_process";
15
13
  import { once as j } from "node:events";
16
- import de from "node:readline";
17
- import { setTimeout as fe } from "node:timers/promises";
14
+ import oe from "node:readline";
15
+ import { setTimeout as se } from "node:timers/promises";
16
+ import { DevEnvironment as ce, build as le, buildErrorMessage as ue, createServer as de } from "vite";
17
+ import fe from "@vitejs/plugin-vue";
18
18
  import { randomUUID as pe } from "node:crypto";
19
19
  //#region ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/_chunks/libs/scule.mjs
20
20
  var me = /\d/, he = [
@@ -64,32 +64,32 @@ function be(e, t) {
64
64
  function M(e, t) {
65
65
  return ye(be(e || "", t));
66
66
  }
67
- function N(e, t) {
67
+ function xe(e, t) {
68
68
  return e ? (Array.isArray(e) ? e : _e(e)).map((e) => e.toLowerCase()).join(t ?? "-") : "";
69
69
  }
70
- function xe(e) {
71
- return N(e || "", "_");
70
+ function Se(e) {
71
+ return xe(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 N(e) {
76
76
  return Array.isArray(e) ? e : e === void 0 ? [] : [e];
77
77
  }
78
- function F(e, t = "") {
78
+ function Ce(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 P(e) {
84
84
  return typeof e == "function" ? e() : e;
85
85
  }
86
- var L = class extends Error {
86
+ var F = 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 we(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 Te = /* @__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
+ })(), I = (e, t = 39) => (n) => Te ? n : `\u001B[${e}m${n}\u001B[${t}m`, L = /* @__PURE__ */ I(1, 22), R = /* @__PURE__ */ I(36), z = /* @__PURE__ */ I(90), B = /* @__PURE__ */ I(4, 24);
169
+ function Ee(e, t) {
170
170
  let n = {
171
171
  boolean: [],
172
172
  string: [],
173
173
  alias: {},
174
174
  default: {}
175
- }, r = Te(t);
175
+ }, r = De(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 = M(e.name), r = xe(e.name);
180
180
  if (t !== e.name || r !== e.name) {
181
- let i = P(n.alias[e.name] || []);
181
+ let i = N(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 = we(e, n), [ ...a] = i._, o = new Proxy(i, { get(e, t) {
186
+ return e[t] ?? e[M(t)] ?? e[xe(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 F(`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 F(`Invalid value for argument: ${R(`--${e.name}`)} (${R(t)}). Expected one of: ${n.map((e) => R(e)).join(", ")}.`, "EARG");
196
+ } else if (e.required && o[e.name] === void 0) throw new F(`Missing required argument: --${e.name}`, "EARG");
197
197
  return o;
198
198
  }
199
- function Te(e) {
199
+ function De(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: N(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 Oe(e) {
209
+ return Promise.all(e.map((e) => P(e)));
210
210
  }
211
- function U(e) {
211
+ function V(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 H(e, t) {
215
+ let n = await P(e.args || {}), r = Ee(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 Oe(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 P(e.subCommands);
225
225
  if (r && Object.keys(r).length > 0) {
226
- let i = Ae(t.rawArgs, n), a = t.rawArgs[i];
226
+ let i = ke(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 W(r, a);
229
+ if (!e) throw new F(`Unknown command ${R(a)}`, "E_UNKNOWN_COMMAND");
230
+ await H(e, { rawArgs: t.rawArgs.slice(i + 1) });
231
231
  } else {
232
- let n = await I(e.default);
232
+ let n = await P(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 F("Cannot specify both 'run' and 'default' on the same command.", "E_DEFAULT_CONFLICT");
235
+ let i = await W(r, n);
236
+ if (!i) throw new F(`Default sub command ${R(n)} not found in subCommands.`, "E_UNKNOWN_COMMAND");
237
+ await H(i, { rawArgs: t.rawArgs });
238
+ } else if (!e.run) throw new F("No command specified.", "E_NO_COMMAND");
239
239
  }
240
240
  }
241
241
  typeof e.run == "function" && (o = await e.run(i));
@@ -258,221 +258,138 @@ 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 U(e, t, n) {
262
+ let r = await P(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 = ke(t, await P(e.args || {})), i = t[n], a = await W(r, i);
265
+ if (a) return U(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 W(e, t) {
270
+ if (t in e) return P(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 P(n), r = await P(e?.meta);
273
+ if (r?.alias && N(r.alias).includes(t)) return e;
274
274
  }
275
275
  }
276
- function Ae(e, t) {
276
+ function ke(e, t) {
277
277
  for (let n = 0; n < e.length; n++) {
278
278
  let r = e[n];
279
279
  if (r === "--") return -1;
280
- if (r.startsWith("-")) !r.includes("=") && je(r, t) && n++;
280
+ if (r.startsWith("-")) !r.includes("=") && Ae(r, t) && n++;
281
281
  else return n;
282
282
  }
283
283
  return -1;
284
284
  }
285
- function je(e, t) {
285
+ function Ae(e, t) {
286
286
  let n = e.replace(/^-{1,2}/, ""), r = M(n);
287
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;
288
288
  return !1;
289
289
  }
290
- async function Me(e, t) {
290
+ async function je(e, t) {
291
291
  try {
292
- console.log(await Pe(e, t) + "\n");
292
+ console.log(await Ne(e, t) + "\n");
293
293
  } catch (e) {
294
294
  console.error(e);
295
295
  }
296
296
  }
297
- var Ne = /^no[-A-Z]/;
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 = [];
297
+ var Me = /^no[-A-Z]/;
298
+ async function Ne(e, t) {
299
+ let n = await P(e.meta || {}), r = De(await P(e.args || {})), i = await P(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([R(t + G(e)), Pe(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(", ") + G(e);
305
+ if (o.push([R(n), Pe(e, t)]), e.type === "boolean" && (e.default === !0 || e.negativeDescription) && !Me.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([R(n), [e.negativeDescription, t ? z("(Required)") : ""].filter(Boolean).join(" ")]);
308
308
  }
309
- t && l.push(`--${e.name}` + Fe(e));
309
+ t && l.push(`--${e.name}` + G(e));
310
310
  }
311
311
  if (e.subCommands) {
312
- let t = [], n = await I(e.subCommands);
312
+ let t = [], n = await P(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 P((await P(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 = N(n?.alias), a = [e, ...i].join(", ");
317
+ c.push([R(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(z(`${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(`${B(L("USAGE"))} ${R(`${a}${f ? " [OPTIONS]" : ""} ${l.join(" ")}`)}`, ""), s.length > 0 && (u.push(B(L("ARGUMENTS")), ""), u.push(Ce(s, " ")), u.push("")), o.length > 0 && (u.push(B(L("OPTIONS")), ""), u.push(Ce(o, " ")), u.push("")), c.length > 0 && (u.push(B(L("COMMANDS")), ""), u.push(Ce(c, " ")), u.push("", `Use ${R(`${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 G(e) {
327
+ let t = e.valueHint ? `=<${e.valueHint}>` : "", n = t || `=<${Se(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 Pe(e, t) {
331
+ let n = t ? z("(Required)") : "", r = e.default === void 0 ? "" : z(`(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 = {}) {
339
- let n = t.rawArgs || process.argv.slice(2), r = t.showUsage || Me;
338
+ async function Fe(e, t = {}) {
339
+ let n = t.rawArgs || process.argv.slice(2), r = t.showUsage || je;
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 Ie(e);
342
+ if (t.help.length > 0 && n.some((e) => t.help.includes(e))) await r(...await U(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 F("No version specified", "E_NO_VERSION");
346
346
  console.log(t.version);
347
- } else await De(e, { rawArgs: n });
347
+ } else await H(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 F ? (await r(...await U(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 Ie(e) {
353
+ let t = await P(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 N(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: Le("help", "h", n, r),
360
+ version: Le("version", "v", n, r)
361
361
  };
362
362
  }
363
- function ze(e, t, n, r) {
363
+ function Le(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 Re = "0.0.17", ze = "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
- function Ve(e) {
371
+ function Be(e) {
455
372
  return e && e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
456
373
  }
457
- function He(e) {
374
+ function Ve(e) {
458
375
  return e;
459
376
  }
460
- function Ue(e, t) {
377
+ function He(e, t) {
461
378
  t ||= {};
462
- let n = t.delimiter || ".", r = t.maxDepth, i = t.transformKey || He, a = {};
379
+ let n = t.delimiter || ".", r = t.maxDepth, i = t.transformKey || Ve, a = {};
463
380
  function o(e, s, c) {
464
381
  c ||= 1, Object.keys(e).forEach(function(l) {
465
- let u = e[l], d = t.safe && Array.isArray(u), f = Object.prototype.toString.call(u), p = Ve(u), m = f === "[object Object]" || f === "[object Array]", h = s ? s + n + i(l) : i(l);
382
+ let u = e[l], d = t.safe && Array.isArray(u), f = Object.prototype.toString.call(u), p = Be(u), m = f === "[object Object]" || f === "[object Array]", h = s ? s + n + i(l) : i(l);
466
383
  if (!d && !p && m && Object.keys(u).length && (!t.maxDepth || c < r)) return o(u, h, c + 1);
467
384
  a[h] = u;
468
385
  });
469
386
  }
470
387
  return o(e), a;
471
388
  }
472
- function We(e, t) {
389
+ function Ue(e, t) {
473
390
  t ||= {};
474
- let n = t.delimiter || ".", r = t.overwrite || !1, i = t.transformKey || He, a = {};
475
- if (Ve(e) || Object.prototype.toString.call(e) !== "[object Object]") return e;
391
+ let n = t.delimiter || ".", r = t.overwrite || !1, i = t.transformKey || Ve, a = {};
392
+ if (Be(e) || Object.prototype.toString.call(e) !== "[object Object]") return e;
476
393
  function o(e) {
477
394
  let n = Number(e);
478
395
  return isNaN(n) || e.indexOf(".") !== -1 || t.object ? e : n;
@@ -490,7 +407,7 @@ function We(e, t) {
490
407
  }
491
408
  return e = Object.keys(e).reduce(function(n, r) {
492
409
  let i = Object.prototype.toString.call(e[r]);
493
- return i !== "[object Object]" && i !== "[object Array]" || c(e[r]) ? (n[r] = e[r], n) : s(r, n, Ue(e[r], t));
410
+ return i !== "[object Object]" && i !== "[object Array]" || c(e[r]) ? (n[r] = e[r], n) : s(r, n, He(e[r], t));
494
411
  }, {}), Object.keys(e).forEach(function(s) {
495
412
  let c = s.split(n).map(i), l = o(c.shift()), u = o(c[0]), d = a;
496
413
  for (; u !== void 0;) {
@@ -499,20 +416,20 @@ function We(e, t) {
499
416
  if (!r && !n && d[l] !== void 0) return;
500
417
  (r && !n || !r && d[l] == null) && (d[l] = typeof u == "number" && !t.object ? [] : {}), d = d[l], c.length > 0 && (l = o(c.shift()), u = o(c[0]));
501
418
  }
502
- d[l] = We(e[s], t);
419
+ d[l] = Ue(e[s], t);
503
420
  }), a;
504
421
  }
505
422
  //#endregion
506
423
  //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
507
- var Ge = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/, Ke = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/, qe = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
508
- function Je(e, t) {
509
- if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) Ye(e);
424
+ var We = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/, Ge = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/, Ke = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
425
+ function qe(e, t) {
426
+ if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) Je(e);
510
427
  else return t;
511
428
  }
512
- function Ye(e) {
429
+ function Je(e) {
513
430
  console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);
514
431
  }
515
- function Xe(e, t = {}) {
432
+ function Ye(e, t = {}) {
516
433
  if (typeof e != "string") return e;
517
434
  if (e[0] === "\"" && e[e.length - 1] === "\"" && e.indexOf("\\") === -1) return e.slice(1, -1);
518
435
  let n = e.trim();
@@ -525,14 +442,14 @@ function Xe(e, t = {}) {
525
442
  case "infinity": return Infinity;
526
443
  case "-infinity": return -Infinity;
527
444
  }
528
- if (!qe.test(e)) {
445
+ if (!Ke.test(e)) {
529
446
  if (t.strict) throw SyntaxError("[destr] Invalid JSON");
530
447
  return e;
531
448
  }
532
449
  try {
533
- if (Ge.test(e) || Ke.test(e)) {
450
+ if (We.test(e) || Ge.test(e)) {
534
451
  if (t.strict) throw Error("[destr] Possible prototype pollution");
535
- return JSON.parse(e, Je);
452
+ return JSON.parse(e, qe);
536
453
  }
537
454
  return JSON.parse(e);
538
455
  } catch (n) {
@@ -542,66 +459,66 @@ 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 Xe(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 (!Xe(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]] : Xe(a) && Xe(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;
581
- let i = Xe((t[2] || "").trim());
498
+ let i = Ye((t[2] || "").trim());
582
499
  if (r.endsWith("[]")) {
583
500
  let e = r.slice(0, Math.max(0, r.length - 2));
584
501
  n[e] = (n[e] || []).concat(i);
585
502
  } else n[r] = i;
586
503
  }
587
- return t.flat ? n : We(n, { overwrite: !0 });
504
+ return t.flat ? n : Ue(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() {
512
+ function at() {
596
513
  return process.env.XDG_CONFIG_HOME || b(A(), ".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,22 +686,22 @@ 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
706
  dir: A()
790
707
  }));
@@ -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
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(A(), ".cache/c12", l);
867
- let m = s.install ? W(s.install === !0 ? {} : s.install, { ignoreWorkspace: !0 }) : !1;
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 ie(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 = ae(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
+ }), oe.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 j(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 = j(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 = j(t, "exit");
1148
+ this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), se(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
+ fe({ 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 le(Sn({
1201
1358
  core: e,
1202
1359
  runtimeModuleName: t,
1203
1360
  entry: n,
@@ -1210,60 +1367,90 @@ 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 = ue(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);
1427
+ async function kn(e, t, n) {
1428
+ let r = En(e);
1245
1429
  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;
1430
+ let i = y.join(r, "entry.js"), a = On(r, n ?? Dn()), o = t.split(y.sep).join("/");
1431
+ return await k(i, wn`
1432
+ import { start } from ${JSON.stringify(a)};
1433
+ await start(${JSON.stringify(o)});
1434
+ `), i;
1248
1435
  }
1249
- function ln(e) {
1436
+ function An(e) {
1250
1437
  if (e.type === "error") return e.err;
1251
1438
  if (e.type === "custom" && e.event === "vite:invoke") return e.data?.data?.error;
1252
1439
  }
1253
- function un(e) {
1440
+ function jn(e) {
1254
1441
  if (e.type !== "custom" || e.event !== "vite:invoke") return !1;
1255
1442
  let t = e.data;
1256
1443
  return t.name === "fetchModule" && !t.data?.error;
1257
1444
  }
1258
- function dn(e, t, n, r, i) {
1445
+ function Mn(e, t, n, r, i) {
1259
1446
  let a = /* @__PURE__ */ new Map(), o = { send: s };
1260
1447
  function s(a) {
1261
1448
  if (a.type === "full-reload") {
1262
1449
  t();
1263
1450
  return;
1264
1451
  }
1265
- let o = ln(a);
1266
- o ? (n(o), i.current = void 0) : un(a) && i.current && (r({
1452
+ let o = An(a);
1453
+ o ? (n(o), i.current = void 0) : jn(a) && i.current && (r({
1267
1454
  file: i.current.file,
1268
1455
  took: Date.now() - i.current.at
1269
1456
  }), i.current = void 0), e(a);
@@ -1285,7 +1472,7 @@ function dn(e, t, n, r, i) {
1285
1472
  }
1286
1473
  };
1287
1474
  }
1288
- function fn() {
1475
+ function Nn() {
1289
1476
  let e = "\0inca:vite-client-shim";
1290
1477
  return {
1291
1478
  name: "inca:shim-vite-client",
@@ -1298,7 +1485,7 @@ function fn() {
1298
1485
  }
1299
1486
  };
1300
1487
  }
1301
- function pn(e) {
1488
+ function Pn(e) {
1302
1489
  return {
1303
1490
  name: "inca:file-changed",
1304
1491
  hotUpdate(t) {
@@ -1313,16 +1500,16 @@ function pn(e) {
1313
1500
  }
1314
1501
  };
1315
1502
  }
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);
1503
+ async function Fn(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 = () => {} }) {
1504
+ let p = await kn(r, n, a), m = pn(i), h = y.join(En(r), fn);
1318
1505
  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({
1506
+ let g = { current: void 0 }, { channel: _, dispatch: v } = Mn(l, u, (t) => d(Tn(e, t)), f, g), b = await de({
1320
1507
  configFile: !1,
1321
1508
  root: y.dirname(n),
1322
1509
  mode: "development",
1323
1510
  clearScreen: !1,
1324
1511
  logLevel: c ? "silent" : "info",
1325
- customLogger: Xt(o, s, c),
1512
+ customLogger: _n(o, s, c),
1326
1513
  define: { "process.env.NODE_ENV": JSON.stringify("development") },
1327
1514
  server: {
1328
1515
  middlewareMode: !0,
@@ -1337,20 +1524,20 @@ async function mn(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, st
1337
1524
  consumer: "client",
1338
1525
  dev: {
1339
1526
  moduleRunnerTransform: !0,
1340
- createEnvironment: (e, t) => new ie(e, t, {
1527
+ createEnvironment: (e, t) => new ce(e, t, {
1341
1528
  hot: !0,
1342
1529
  transport: _
1343
1530
  })
1344
1531
  }
1345
1532
  } },
1346
1533
  plugins: [
1347
- ce({ template: { compilerOptions: {
1534
+ fe({ template: { compilerOptions: {
1348
1535
  runtimeModuleName: t,
1349
1536
  hoistStatic: !1
1350
1537
  } } }),
1351
- $t(e),
1352
- fn(),
1353
- pn(g)
1538
+ bn(e),
1539
+ Nn(),
1540
+ Pn(g)
1354
1541
  ]
1355
1542
  });
1356
1543
  return {
@@ -1360,9 +1547,9 @@ async function mn(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, st
1360
1547
  };
1361
1548
  }
1362
1549
  //#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({
1550
+ //#region src/vite/watch.mts
1551
+ async function In(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, stderr: a = process.stderr, quiet: o = !1, ...s }) {
1552
+ let { outDir: c } = s, l, u = await le(Sn({
1366
1553
  core: e,
1367
1554
  runtimeModuleName: t,
1368
1555
  ...s,
@@ -1371,7 +1558,7 @@ async function hn(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, st
1371
1558
  stderr: a,
1372
1559
  quiet: o,
1373
1560
  onOutput: (e) => {
1374
- n(Ut(c, e, l)), l = void 0;
1561
+ n(un(c, e, l)), l = void 0;
1375
1562
  }
1376
1563
  }));
1377
1564
  return u.on("change", (e) => {
@@ -1387,275 +1574,42 @@ async function hn(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, st
1387
1574
  }), { close: () => u.close() };
1388
1575
  }
1389
1576
  //#endregion
1390
- //#region src/adapter/vite/createBundler.mts
1391
- function gn(e, t) {
1577
+ //#region src/vite/createBundler.mts
1578
+ function Ln(e, t) {
1392
1579
  return {
1393
- watch: (n) => hn(e, t, n),
1394
- build: (n) => nn(e, t, n),
1395
- hmr: (n) => mn(e, t, n)
1580
+ watch: (n) => In(e, t, n),
1581
+ build: (n) => Cn(e, t, n),
1582
+ hmr: (n) => Fn(e, t, n)
1396
1583
  };
1397
1584
  }
1398
1585
  //#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
1622
- };
1623
- }
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
- //#endregion
1633
1586
  //#region src/defaultBundler.mts
1634
- var Fn = gn(/* @__PURE__ */ e({
1635
- IncaError: () => J,
1636
- bundlerFault: () => Nn
1637
- }), "incajs/vue/runtime"), In = [
1587
+ var Rn = Ln(ln, "incajs/vue/runtime"), zn = [
1638
1588
  "main.mts",
1639
1589
  "main.ts",
1640
1590
  "main.js"
1641
1591
  ];
1642
- async function Ln(e) {
1643
- let t = In.map((t) => y.join(e, "src", t)).find((e) => p(e));
1592
+ async function Bn(e) {
1593
+ let t = zn.map((t) => y.join(e, "src", t)).find((e) => p(e));
1644
1594
  if (t) return t;
1645
1595
  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`);
1596
+ if (p(n)) return Vn(n, e);
1597
+ throw new Y("ERR_INCA_ENTRY_NOT_FOUND", `no app entry found. check that ${y.join(e, "src/main.ts")} or ${n} exists`);
1648
1598
  }
1649
- async function Rn(e, t) {
1599
+ async function Vn(e, t) {
1650
1600
  let n = y.join(t, "node_modules/.inca");
1651
1601
  await E(n, { recursive: !0 });
1652
1602
  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;
1603
+ return await k(r, wn`
1604
+ import { createIncaApp } from "incajs/vue";
1605
+ import App from ${i};
1606
+ createIncaApp(App).mount();
1607
+ `), r;
1654
1608
  }
1655
1609
  //#endregion
1656
1610
  //#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);
1611
+ async function Hn(e = {}) {
1612
+ let t = e.cwd ?? process.cwd(), n = e.config ?? await zt(t), r = y.resolve(t, n.outDir), i = e.bundler ?? Rn, a = e.entry ?? n.entry ?? await Bn(t);
1659
1613
  Ft(t, r, a);
1660
1614
  let o = e.runtimeConfig ?? await Ht(t);
1661
1615
  return i.build({
@@ -1669,43 +1623,43 @@ async function zn(e = {}) {
1669
1623
  }
1670
1624
  //#endregion
1671
1625
  //#region src/devLock.mts
1672
- function Bn(e) {
1626
+ function Un(e) {
1673
1627
  return y.join(e, "node_modules/.inca/dev.pid");
1674
1628
  }
1675
- function Vn(e) {
1629
+ function Wn(e) {
1676
1630
  try {
1677
1631
  return process.kill(e, 0), !0;
1678
1632
  } catch (e) {
1679
1633
  return e.code === "EPERM";
1680
1634
  }
1681
1635
  }
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)})`);
1636
+ var Gn = pe();
1637
+ function Kn(e) {
1638
+ return new Y("ERR_INCA_DEV_RUNNING", `inca dev is already running for this app (pid ${String(e)})`);
1685
1639
  }
1686
- async function Wn(e) {
1687
- let t = Bn(e), n = `${String(process.pid)}:${Hn}`, r = `${t}.${pe()}`;
1640
+ async function qn(e) {
1641
+ let t = Un(e), n = `${String(process.pid)}:${Gn}`, r = `${t}.${pe()}`;
1688
1642
  await E(y.dirname(t), { recursive: !0 }), await k(r, n);
1689
1643
  let i = process.pid;
1690
1644
  try {
1691
1645
  for (let e = 0; e < 5; e++) {
1692
1646
  try {
1693
- return await T(r, t), Gn(t, n);
1647
+ return await T(r, t), Jn(t, n);
1694
1648
  } catch (e) {
1695
1649
  if (e.code !== "EEXIST") throw e;
1696
1650
  }
1697
1651
  let e = await D(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
1698
1652
  if (a === process.pid) {
1699
- if (e === n) throw Un(a);
1700
- } else if (Number.isSafeInteger(a) && a > 0 && Vn(a)) throw Un(a);
1653
+ if (e === n) throw Kn(a);
1654
+ } else if (Number.isSafeInteger(a) && a > 0 && Wn(a)) throw Kn(a);
1701
1655
  i = Number.isSafeInteger(a) && a > 0 ? a : i, await O(t, { force: !0 });
1702
1656
  }
1703
- throw Un(i);
1657
+ throw Kn(i);
1704
1658
  } finally {
1705
1659
  await O(r, { force: !0 });
1706
1660
  }
1707
1661
  }
1708
- function Gn(e, t) {
1662
+ function Jn(e, t) {
1709
1663
  let n = !1;
1710
1664
  return async () => {
1711
1665
  n || (n = !0, await D(e, "utf8").catch(() => "") === t && await O(e, { force: !0 }));
@@ -1713,24 +1667,26 @@ function Gn(e, t) {
1713
1667
  }
1714
1668
  //#endregion
1715
1669
  //#region src/plist.mts
1716
- function Kn(e) {
1670
+ function Yn(e) {
1717
1671
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
1718
1672
  }
1719
- function qn(e) {
1720
- return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${Kn(e)}</string>`;
1673
+ function Xn(e) {
1674
+ return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${Yn(e)}</string>`;
1721
1675
  }
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
- `;
1676
+ function Zn(e) {
1677
+ return wn`
1678
+ <?xml version="1.0" encoding="UTF-8"?>
1679
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
1680
+ <plist version="1.0">
1681
+ <dict>
1682
+ ${Object.entries(e).map(([e, t]) => `\t<key>${Yn(e)}</key>\n\t${Xn(t)}`).join("\n")}
1683
+ </dict>
1684
+ </plist>
1685
+ `;
1730
1686
  }
1731
1687
  //#endregion
1732
1688
  //#region src/macosApp.mts
1733
- async function Yn(e) {
1689
+ async function Qn(e) {
1734
1690
  let { appPath: t, metadata: n, hostBin: r } = e;
1735
1691
  await O(t, {
1736
1692
  recursive: !0,
@@ -1755,7 +1711,7 @@ async function Yn(e) {
1755
1711
  let e = y.basename(n.icon);
1756
1712
  await w(n.icon, y.join(o, e)), c.CFBundleIconFile = e;
1757
1713
  }
1758
- return await k(y.join(i, "Info.plist"), Jn(c)), await k(y.join(i, "PkgInfo"), "APPL????"), {
1714
+ return await k(y.join(i, "Info.plist"), Zn(c)), await k(y.join(i, "PkgInfo"), "APPL????"), {
1759
1715
  appPath: t,
1760
1716
  executablePath: s,
1761
1717
  resourcesDir: o
@@ -1763,8 +1719,8 @@ async function Yn(e) {
1763
1719
  }
1764
1720
  //#endregion
1765
1721
  //#region src/watchForEdit.mts
1766
- var Xn = /^(?:inca\.config\.[a-z0-9]+|package\.json)$/, Zn = [...In, "App.vue"];
1767
- function Qn(e, t = {}) {
1722
+ var $n = /^(?:inca\.config\.[a-z0-9]+|package\.json)$/, er = [...zn, "App.vue"];
1723
+ function tr(e, t = {}) {
1768
1724
  let n = t.debounceMs ?? 100, r = /* @__PURE__ */ new Set(), i, a = !1, o = () => {}, s = new Promise((e) => {
1769
1725
  o = e;
1770
1726
  }), c = () => {
@@ -1785,7 +1741,7 @@ function Qn(e, t = {}) {
1785
1741
  r.clear();
1786
1742
  };
1787
1743
  try {
1788
- l(e, (e) => e === "src" || Xn.test(e)), l(y.join(e, "src"), (e) => Zn.includes(e));
1744
+ l(e, (e) => e === "src" || $n.test(e)), l(y.join(e, "src"), (e) => er.includes(e));
1789
1745
  } catch (e) {
1790
1746
  throw u(), e;
1791
1747
  }
@@ -1801,7 +1757,7 @@ function Qn(e, t = {}) {
1801
1757
  }
1802
1758
  //#endregion
1803
1759
  //#region src/retryOnEdit.mts
1804
- function $n(e, t) {
1760
+ function nr(e, t) {
1805
1761
  return new Promise((n) => {
1806
1762
  let r = () => n(!1);
1807
1763
  t.addEventListener("abort", r, { once: !0 }), e.then(() => {
@@ -1809,25 +1765,25 @@ function $n(e, t) {
1809
1765
  });
1810
1766
  });
1811
1767
  }
1812
- async function er(e) {
1768
+ async function rr(e) {
1813
1769
  let { cwd: t, signal: n, stdout: r, stderr: i, debounceMs: a } = e, o = !1;
1814
1770
  for (;;) {
1815
- let s = Qn(t, { debounceMs: a });
1771
+ let s = tr(t, { debounceMs: a });
1816
1772
  try {
1817
1773
  return await e.attempt(s);
1818
1774
  } catch (e) {
1819
- let t = e instanceof J ? e.path : void 0;
1775
+ let t = e instanceof Y ? e.path : void 0;
1820
1776
  if (t) try {
1821
1777
  s.add(t);
1822
1778
  } catch (t) {
1823
- throw $(i, "build failed", Q(e), Y), t;
1779
+ throw $(i, "build failed", Q(e), X), t;
1824
1780
  }
1825
1781
  if (!n.aborted && !o && t && p(t)) {
1826
1782
  o = !0;
1827
1783
  continue;
1828
1784
  }
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);
1785
+ if (o = !1, $(i, "build failed", Q(e), X), n.aborted || (Z(r, "waiting for a change to retry", X), !await nr(s.edited, n))) return;
1786
+ Z(r, "retrying", X);
1831
1787
  } finally {
1832
1788
  s.close();
1833
1789
  }
@@ -1835,30 +1791,30 @@ async function er(e) {
1835
1791
  }
1836
1792
  //#endregion
1837
1793
  //#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) {
1794
+ var ir = 1e4, ar = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
1795
+ async function or(e, t) {
1840
1796
  try {
1841
1797
  return await Bt(e);
1842
1798
  } catch (e) {
1843
- if (!(e instanceof J) || !nr.includes(e.code)) throw e;
1844
- Z(t, `running unnamed. ${e.message}`, Y);
1799
+ if (!(e instanceof Y) || !ar.includes(e.code)) throw e;
1800
+ Z(t, `running unnamed. ${e.message}`, X);
1845
1801
  return;
1846
1802
  }
1847
1803
  }
1848
- async function ir(e, t, n, r) {
1804
+ async function sr(e, t, n, r) {
1849
1805
  if (process.platform === "darwin" && t) try {
1850
- return (await Yn({
1806
+ return (await Qn({
1851
1807
  appPath: y.join(e, "node_modules/.inca", `${t.productName}.app`),
1852
1808
  metadata: t,
1853
1809
  hostBin: n,
1854
1810
  link: !0
1855
1811
  })).executablePath;
1856
1812
  } catch (e) {
1857
- Z(r, `running unbundled. ${Q(e).message}`, Y);
1813
+ Z(r, `running unbundled. ${Q(e).message}`, X);
1858
1814
  return;
1859
1815
  }
1860
1816
  }
1861
- async function ar(e, t) {
1817
+ async function cr(e, t) {
1862
1818
  let n = new Set(t), r;
1863
1819
  try {
1864
1820
  r = await te(e, {
@@ -1870,29 +1826,29 @@ async function ar(e, t) {
1870
1826
  }
1871
1827
  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
1828
  }
1873
- function or(e) {
1829
+ function lr(e) {
1874
1830
  let { NO_COLOR: t, FORCE_COLOR: n } = process.env;
1875
1831
  if (!(!e.isTTY || t || n)) return {
1876
1832
  ...process.env,
1877
1833
  FORCE_COLOR: "1"
1878
1834
  };
1879
1835
  }
1880
- async function sr(e) {
1881
- let t = e.cwd ?? process.cwd(), n = await Wn(t);
1836
+ async function ur(e) {
1837
+ let t = e.cwd ?? process.cwd(), n = await qn(t);
1882
1838
  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({
1839
+ let n = e.hostBin ?? Kt();
1840
+ qt(n);
1841
+ let r = e.bundler ?? Rn, i = e.stdout ?? process.stdout, a = e.stderr ?? process.stderr, o = e.experimentalHmr ? r.hmr?.bind(r) : void 0;
1842
+ if (e.experimentalHmr && !o) throw new Y("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
1843
+ let s = await rr({
1888
1844
  cwd: t,
1889
1845
  signal: e.signal,
1890
1846
  stdout: i,
1891
1847
  stderr: a,
1892
1848
  async attempt() {
1893
- let n = await zt(t), r = y.resolve(t, n.outDir), a = e.entry ?? n.entry ?? await Ln(t);
1849
+ let n = await zt(t), r = y.resolve(t, n.outDir), a = e.entry ?? n.entry ?? await Bn(t);
1894
1850
  Ft(t, r, a);
1895
- let o = await rr(t, i);
1851
+ let o = await or(t, i);
1896
1852
  return {
1897
1853
  outDir: r,
1898
1854
  entry: a,
@@ -1902,48 +1858,48 @@ async function sr(e) {
1902
1858
  }
1903
1859
  });
1904
1860
  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) => {
1861
+ let { outDir: c, entry: l, metadata: u, runtimeConfig: d } = s, f = await sr(t, u, n, i) ?? n, p, m = !1, h = !1, g = !1, _, v = Promise.resolve(), b = () => {}, ee = new Promise((e) => {
1906
1862
  b = e;
1907
1863
  });
1908
1864
  async function x() {
1909
1865
  try {
1910
- return await p?.call("reload", void 0, tr), !0;
1866
+ return await p?.call("reload", void 0, ir), !0;
1911
1867
  } catch (e) {
1912
- return $(a, "reload failed", Q(e), Y), !1;
1868
+ return $(a, "reload failed", Q(e), X), !1;
1913
1869
  }
1914
1870
  }
1915
1871
  async function C(e, t) {
1916
- let n = new En({
1872
+ let n = new Qt({
1917
1873
  entryFile: e,
1918
1874
  hostBin: f,
1919
- env: or(a),
1875
+ env: lr(a),
1920
1876
  onStderr: (e) => a.write(e),
1921
1877
  onReady: () => {
1922
- m = !0, Z(i, "ready", Y), h && (h = !1, x());
1878
+ m = !0, Z(i, "ready", X), h && (h = !1, x());
1923
1879
  },
1924
- onAppError: (e) => $(a, "app error", e, Y),
1880
+ onAppError: (e) => $(a, "app error", e, X),
1925
1881
  onExit: (e, t) => {
1926
1882
  g = !m, _ = {
1927
1883
  code: e,
1928
1884
  signal: t
1929
- }, Z(i, "host exited. stopping", Y), b();
1885
+ }, Z(i, "host exited. stopping", X), b();
1930
1886
  },
1931
1887
  integrations: t
1932
1888
  });
1933
1889
  try {
1934
1890
  await n.start();
1935
1891
  } catch (e) {
1936
- $(a, "failed to start inca-host", Q(e), Y);
1892
+ $(a, "failed to start the host", Q(e), X);
1937
1893
  return;
1938
1894
  }
1939
1895
  p = n;
1940
1896
  }
1941
1897
  async function w(e) {
1942
- if (await ar(e.outDir, e.files), !p) await C(e.entryFile);
1898
+ if (await cr(e.outDir, e.files), !p) await C(e.entryFile);
1943
1899
  else if (!m) h = !0;
1944
1900
  else if (await x() && e.changed) {
1945
1901
  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);
1902
+ Z(i, `${S("green", "reload")} ${n} (${r}ms)`, X);
1947
1903
  }
1948
1904
  }
1949
1905
  let T;
@@ -1958,11 +1914,11 @@ async function sr(e) {
1958
1914
  reload: () => {
1959
1915
  m ? x() : h = !0;
1960
1916
  },
1961
- onError: (e) => $(a, "build failed", e, Y),
1917
+ onError: (e) => $(a, "build failed", e, X),
1962
1918
  onUpdate: ({ file: e, took: n }) => {
1963
1919
  if (!m) return;
1964
1920
  let r = S("dim", y.relative(t, e), { stream: i });
1965
- Z(i, `${S("green", "update")} ${r} (${n}ms)`, Y);
1921
+ Z(i, `${S("green", "update")} ${r} (${n}ms)`, X);
1966
1922
  }
1967
1923
  });
1968
1924
  await C(e.entryFile, { vite: (t) => e.dispatch(t) }), T = e, p || b();
@@ -1977,13 +1933,13 @@ async function sr(e) {
1977
1933
  v = v.then(() => w(e));
1978
1934
  },
1979
1935
  onError: (e) => {
1980
- $(a, "build failed", e, Y);
1936
+ $(a, "build failed", e, X);
1981
1937
  }
1982
1938
  });
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");
1939
+ 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
1940
  if (_ && _.code !== 0 && _.signal !== "SIGINT" && _.signal !== "SIGTERM") {
1985
1941
  let { code: e, signal: t } = _;
1986
- throw new J("ERR_INCA_HOST_CRASHED", `the host exited with ${t ? `signal ${t}` : `code ${e}`}`);
1942
+ throw new Y("ERR_INCA_HOST_CRASHED", `the host exited with ${t ? `signal ${t}` : `code ${e}`}`);
1987
1943
  }
1988
1944
  } finally {
1989
1945
  await n();
@@ -1991,44 +1947,44 @@ async function sr(e) {
1991
1947
  }
1992
1948
  //#endregion
1993
1949
  //#region src/package.mts
1994
- function cr() {
1950
+ function dr() {
1995
1951
  if (process.platform === "darwin") return "macos";
1996
1952
  if (process.platform === "linux") return "linux";
1997
- throw new J("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
1953
+ throw new Y("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
1998
1954
  }
1999
- async function lr(e, t) {
1955
+ async function fr(e, t) {
2000
1956
  await Promise.all(e.files.map(async (n) => {
2001
1957
  let r = y.join(t, n);
2002
1958
  await E(y.dirname(r), { recursive: !0 }), await w(y.join(e.outDir, n), r);
2003
1959
  }));
2004
1960
  }
2005
- function ur(e, t) {
1961
+ function pr(e, t) {
2006
1962
  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`);
1963
+ 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
1964
  }
2009
- async function dr({ metadata: e, output: t, hostBin: n }) {
2010
- let { appPath: r, resourcesDir: i } = await Yn({
1965
+ async function mr({ metadata: e, output: t, hostBin: n }) {
1966
+ let { appPath: r, resourcesDir: i } = await Qn({
2011
1967
  appPath: y.join(t.outDir, `${e.productName}.app`),
2012
1968
  metadata: e,
2013
1969
  hostBin: n
2014
1970
  });
2015
- return await lr(t, i), r;
1971
+ return await fr(t, i), r;
2016
1972
  }
2017
- async function fr({ metadata: e, output: t, hostBin: n }) {
1973
+ async function hr({ metadata: e, output: t, hostBin: n }) {
2018
1974
  let r = c(e.productName);
2019
- ur(t, r);
1975
+ pr(t, r);
2020
1976
  let i = y.join(t.outDir, r);
2021
1977
  await O(i, {
2022
1978
  recursive: !0,
2023
1979
  force: !0
2024
1980
  }), await E(i, { recursive: !0 });
2025
1981
  let a = y.join(i, r);
2026
- return await w(n, a), await C(a, 493), await lr(t, i), i;
1982
+ return await w(n, a), await C(a, 493), await fr(t, i), i;
2027
1983
  }
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);
1984
+ async function gr(e = {}) {
1985
+ let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? dr(), i = await Bt(t);
2030
1986
  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({
1987
+ let a = await Hn({
2032
1988
  cwd: t,
2033
1989
  entry: e.entry,
2034
1990
  config: i,
@@ -2037,26 +1993,26 @@ async function pr(e = {}) {
2037
1993
  bundler: e.bundler,
2038
1994
  stdout: n,
2039
1995
  stderr: e.stderr
2040
- }), o = e.hostBin ?? bn();
2041
- xn(o);
1996
+ }), o = e.hostBin ?? Kt();
1997
+ qt(o);
2042
1998
  let s = {
2043
1999
  metadata: i,
2044
2000
  output: a,
2045
2001
  hostBin: o
2046
2002
  };
2047
- return { appPath: r === "macos" ? await dr(s) : await fr(s) };
2003
+ return { appPath: r === "macos" ? await mr(s) : await hr(s) };
2048
2004
  }
2049
2005
  //#endregion
2050
2006
  //#region src/cli.mts
2051
- function mr(e) {
2007
+ function _r(e) {
2052
2008
  return y.relative(process.cwd(), e);
2053
2009
  }
2054
- var hr = {
2010
+ var vr = {
2055
2011
  type: "boolean",
2056
2012
  description: "Write a source map",
2057
2013
  negativeDescription: "Skip the source map"
2058
2014
  };
2059
- function gr() {
2015
+ function yr() {
2060
2016
  for (let e of [
2061
2017
  0,
2062
2018
  1,
@@ -2065,35 +2021,35 @@ function gr() {
2065
2021
  f.closeSync(e);
2066
2022
  } catch {}
2067
2023
  }
2068
- var _r = U({
2024
+ var br = V({
2069
2025
  meta: {
2070
2026
  name: "build",
2071
2027
  description: "Bundle the app into dist"
2072
2028
  },
2073
- args: { sourcemap: hr },
2029
+ args: { sourcemap: vr },
2074
2030
  async run({ args: e }) {
2075
2031
  try {
2076
- let t = await zn({ sourcemap: e.sourcemap });
2077
- Z(process.stdout, `built ${mr(t.entryFile)}`);
2032
+ let t = await Hn({ sourcemap: e.sourcemap });
2033
+ Z(process.stdout, `built ${_r(t.entryFile)}`);
2078
2034
  } catch (e) {
2079
2035
  $(process.stderr, "build failed", Q(e)), process.exitCode = 1;
2080
2036
  }
2081
2037
  }
2082
- }), vr = U({
2038
+ }), xr = V({
2083
2039
  meta: {
2084
2040
  name: "package",
2085
2041
  description: "Package the app as an application bundle"
2086
2042
  },
2087
- args: { sourcemap: hr },
2043
+ args: { sourcemap: vr },
2088
2044
  async run({ args: e }) {
2089
2045
  try {
2090
- let { appPath: t } = await pr({ sourcemap: e.sourcemap });
2091
- Z(process.stdout, `packaged ${mr(t)}`);
2046
+ let { appPath: t } = await gr({ sourcemap: e.sourcemap });
2047
+ Z(process.stdout, `packaged ${_r(t)}`);
2092
2048
  } catch (e) {
2093
2049
  $(process.stderr, "package failed", Q(e)), process.exitCode = 1;
2094
2050
  }
2095
2051
  }
2096
- }), yr = U({
2052
+ }), Sr = V({
2097
2053
  meta: {
2098
2054
  name: "dev",
2099
2055
  description: "Run the app in a development window"
@@ -2103,7 +2059,7 @@ var _r = U({
2103
2059
  description: "Apply edits without a reload (or set INCA_EXPERIMENTAL_HMR)"
2104
2060
  } },
2105
2061
  async run({ args: e }) {
2106
- "sourcemap" in e && kn(process.stderr, "dev ignores --sourcemap and --no-sourcemap", { timestamp: !0 });
2062
+ "sourcemap" in e && nn(process.stderr, "dev ignores --sourcemap and --no-sourcemap", { timestamp: !0 });
2107
2063
  let t = new AbortController(), n = () => {
2108
2064
  t.signal.aborted || (Z(process.stderr, "shutting down", { timestamp: !0 }), t.abort());
2109
2065
  };
@@ -2115,28 +2071,28 @@ var _r = U({
2115
2071
  ].includes(process.env.INCA_EXPERIMENTAL_HMR ?? "");
2116
2072
  r && Z(process.stdout, "experimental HMR active", { timestamp: !0 });
2117
2073
  try {
2118
- await sr({
2074
+ await ur({
2119
2075
  signal: t.signal,
2120
2076
  experimentalHmr: r
2121
- }), t.signal.aborted && gr();
2077
+ }), t.signal.aborted && yr();
2122
2078
  } catch (e) {
2123
2079
  $(process.stderr, "dev failed", Q(e), { timestamp: !0 }), process.exitCode = 1;
2124
2080
  }
2125
2081
  }
2126
- }), br = U({
2082
+ }), Cr = V({
2127
2083
  meta: {
2128
2084
  name: "inca",
2129
- version: Be.version,
2130
- description: Be.description
2085
+ version: Re,
2086
+ description: ze
2131
2087
  },
2132
2088
  subCommands: {
2133
- dev: yr,
2134
- build: _r,
2135
- package: vr
2089
+ dev: Sr,
2090
+ build: br,
2091
+ package: xr
2136
2092
  }
2137
2093
  });
2138
- async function xr(e = process.argv) {
2139
- await Le(br, { rawArgs: e.slice(2) });
2094
+ async function wr(e = process.argv) {
2095
+ await Fe(Cr, { rawArgs: e.slice(2) });
2140
2096
  }
2141
2097
  //#endregion
2142
- export { xr as run };
2098
+ export { wr as run };