@incajs/cli 0.0.15 → 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.
package/dist/cli.js CHANGED
@@ -3,42 +3,393 @@ import { c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./chunks
3
3
  import { i as c, n as l, r as u, t as d } from "./chunks/defaults-Ct95BSBl.js";
4
4
  import f, { existsSync as p, lstatSync as m, readFileSync as h, realpathSync as g, statSync as _, watch as v } from "node:fs";
5
5
  import y, { resolve as b } from "node:path";
6
- import { chmod as x, cp as S, link as C, mkdir as w, readFile as T, readdir as ee, rm as E, writeFile as D } from "node:fs/promises";
7
- import * as te from "node:util";
8
- import { styleText as O } from "node:util";
6
+ import * as ee from "node:util";
7
+ import { parseArgs as x, styleText as S } from "node:util";
8
+ import { chmod as C, cp as w, link as T, mkdir as E, readFile as D, readdir as te, rm as O, writeFile as k } from "node:fs/promises";
9
9
  import { fileURLToPath as ne, pathToFileURL as re } from "node:url";
10
- import { homedir as k } from "node:os";
11
- import { DevEnvironment as ie, build as A, buildErrorMessage as ae, createServer as oe } from "vite";
12
- import se from "@vitejs/plugin-vue";
13
- import { createRequire as ce } from "node:module";
14
- import { spawn as le } from "node:child_process";
10
+ import { homedir as A } from "node:os";
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 ue from "node:readline";
17
- import { setTimeout as de } from "node:timers/promises";
18
- import { randomUUID as fe } from "node:crypto";
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
+ import { randomUUID as pe } from "node:crypto";
19
+ //#region ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/_chunks/libs/scule.mjs
20
+ var me = /\d/, he = [
21
+ "-",
22
+ "_",
23
+ "/",
24
+ "."
25
+ ];
26
+ function ge(e = "") {
27
+ if (!me.test(e)) return e !== e.toLowerCase();
28
+ }
29
+ function _e(e, t) {
30
+ let n = t ?? he, r = [];
31
+ if (!e || typeof e != "string") return r;
32
+ let i = "", a, o;
33
+ for (let t of e) {
34
+ let e = n.includes(t);
35
+ if (e === !0) {
36
+ r.push(i), i = "", a = void 0;
37
+ continue;
38
+ }
39
+ let s = ge(t);
40
+ if (o === !1) {
41
+ if (a === !1 && s === !0) {
42
+ r.push(i), i = t, a = s;
43
+ continue;
44
+ }
45
+ if (a === !0 && s === !1 && i.length > 1) {
46
+ let e = i.at(-1);
47
+ r.push(i.slice(0, Math.max(0, i.length - 1))), i = e + t, a = s;
48
+ continue;
49
+ }
50
+ }
51
+ i += t, a = s, o = e;
52
+ }
53
+ return r.push(i), r;
54
+ }
55
+ function ve(e) {
56
+ return e ? e[0].toUpperCase() + e.slice(1) : "";
57
+ }
58
+ function ye(e) {
59
+ return e ? e[0].toLowerCase() + e.slice(1) : "";
60
+ }
61
+ function be(e, t) {
62
+ return e ? (Array.isArray(e) ? e : _e(e)).map((e) => ve(t?.normalize ? e.toLowerCase() : e)).join("") : "";
63
+ }
64
+ function M(e, t) {
65
+ return ye(be(e || "", t));
66
+ }
67
+ function xe(e, t) {
68
+ return e ? (Array.isArray(e) ? e : _e(e)).map((e) => e.toLowerCase()).join(t ?? "-") : "";
69
+ }
70
+ function Se(e) {
71
+ return xe(e || "", "_");
72
+ }
73
+ //#endregion
74
+ //#region ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/index.mjs
75
+ function N(e) {
76
+ return Array.isArray(e) ? e : e === void 0 ? [] : [e];
77
+ }
78
+ function Ce(e, t = "") {
79
+ let n = [];
80
+ for (let t of e) for (let [e, r] of t.entries()) n[e] = Math.max(n[e] || 0, r.length);
81
+ return e.map((e) => e.map((e, r) => t + e[r === 0 ? "padStart" : "padEnd"](n[r])).join(" ")).join("\n");
82
+ }
83
+ function P(e) {
84
+ return typeof e == "function" ? e() : e;
85
+ }
86
+ var F = class extends Error {
87
+ code;
88
+ constructor(e, t) {
89
+ super(e), this.name = "CLIError", this.code = t;
90
+ }
91
+ };
92
+ function we(e = [], t = {}) {
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
+ for (let [e, t] of Object.entries(i)) {
95
+ let n = t;
96
+ for (let t of n) o.set(e, t), s.has(t) || s.set(t, []), s.get(t).push(e), o.set(t, e), s.has(e) || s.set(e, []), s.get(e).push(t);
97
+ }
98
+ let c = {};
99
+ function l(e) {
100
+ if (n.has(e)) return "boolean";
101
+ let t = s.get(e) || [];
102
+ for (let e of t) if (n.has(e)) return "boolean";
103
+ return "string";
104
+ }
105
+ function u(e) {
106
+ if (r.has(e)) return !0;
107
+ let t = s.get(e) || [];
108
+ for (let e of t) if (r.has(e)) return !0;
109
+ return !1;
110
+ }
111
+ let d = /* @__PURE__ */ new Set([
112
+ ...n,
113
+ ...r,
114
+ ...Object.keys(i),
115
+ ...Object.values(i).flat(),
116
+ ...Object.keys(a)
117
+ ]);
118
+ for (let e of d) c[e] || (c[e] = {
119
+ type: l(e),
120
+ default: a[e]
121
+ });
122
+ for (let [e, t] of o.entries()) e.length === 1 && c[t] && !c[t].short && (c[t].short = e);
123
+ let f = [], p = {};
124
+ for (let t = 0; t < e.length; t++) {
125
+ let n = e[t];
126
+ if (n === "--") {
127
+ f.push(...e.slice(t));
128
+ break;
129
+ }
130
+ if (n.startsWith("--no-")) {
131
+ let e = n.slice(5);
132
+ p[e] = !0;
133
+ } else f.push(n);
134
+ }
135
+ let m;
136
+ try {
137
+ m = x({
138
+ args: f,
139
+ options: Object.keys(c).length > 0 ? c : void 0,
140
+ allowPositionals: !0,
141
+ strict: !1
142
+ });
143
+ } catch {
144
+ m = {
145
+ values: {},
146
+ positionals: f
147
+ };
148
+ }
149
+ let h = { _: [] };
150
+ h._ = m.positionals;
151
+ for (let [e, t] of Object.entries(m.values)) {
152
+ let n = t;
153
+ l(e) === "boolean" && typeof t == "string" ? n = t !== "false" : u(e) && typeof t == "boolean" && (n = ""), h[e] = n;
154
+ }
155
+ for (let [e] of Object.entries(p)) {
156
+ h[e] = !1;
157
+ let t = o.get(e);
158
+ t && (h[t] = !1);
159
+ let n = s.get(e);
160
+ if (n) for (let e of n) h[e] = !1;
161
+ }
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
+ return h;
164
+ }
165
+ var Te = /* @__PURE__ */ (() => {
166
+ let e = globalThis.process?.env ?? {};
167
+ return e.NO_COLOR === "1" || e.TERM === "dumb" || e.TEST || e.CI;
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
+ let n = {
171
+ boolean: [],
172
+ string: [],
173
+ alias: {},
174
+ default: {}
175
+ }, r = De(t);
176
+ for (let e of r) {
177
+ if (e.type === "positional") continue;
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 = xe(e.name);
180
+ if (t !== e.name || r !== e.name) {
181
+ let i = N(n.alias[e.name] || []);
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
+ }
184
+ }
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
+ } });
188
+ for (let [, e] of r.entries()) if (e.type === "positional") {
189
+ let t = a.shift();
190
+ if (t !== void 0) o[e.name] = t;
191
+ else if (e.default === void 0 && e.required !== !1) throw new F(`Missing required positional argument: ${e.name.toUpperCase()}`, "EARG");
192
+ else o[e.name] = e.default;
193
+ } else if (e.type === "enum") {
194
+ let t = o[e.name], n = e.options || [];
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
+ return o;
198
+ }
199
+ function De(e) {
200
+ let t = [];
201
+ for (let [n, r] of Object.entries(e || {})) t.push({
202
+ ...r,
203
+ name: n,
204
+ alias: N(r.alias)
205
+ });
206
+ return t;
207
+ }
208
+ async function Oe(e) {
209
+ return Promise.all(e.map((e) => P(e)));
210
+ }
211
+ function V(e) {
212
+ return e;
213
+ }
214
+ async function H(e, t) {
215
+ let n = await P(e.args || {}), r = Ee(t.rawArgs, n), i = {
216
+ rawArgs: t.rawArgs,
217
+ args: r,
218
+ data: t.data,
219
+ cmd: e
220
+ }, a = await Oe(e.plugins ?? []), o, s;
221
+ try {
222
+ for (let e of a) await e.setup?.(i);
223
+ typeof e.setup == "function" && await e.setup(i);
224
+ let r = await P(e.subCommands);
225
+ if (r && Object.keys(r).length > 0) {
226
+ let i = ke(t.rawArgs, n), a = t.rawArgs[i];
227
+ if (a) {
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
+ } else {
232
+ let n = await P(e.default);
233
+ if (n) {
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
+ }
240
+ }
241
+ typeof e.run == "function" && (o = await e.run(i));
242
+ } catch (e) {
243
+ s = e;
244
+ }
245
+ let c = [];
246
+ if (typeof e.cleanup == "function") try {
247
+ await e.cleanup(i);
248
+ } catch (e) {
249
+ c.push(e);
250
+ }
251
+ for (let e of [...a].reverse()) try {
252
+ await e.cleanup?.(i);
253
+ } catch (e) {
254
+ c.push(e);
255
+ }
256
+ if (s) throw s;
257
+ if (c.length === 1) throw c[0];
258
+ if (c.length > 1) throw Error("Multiple cleanup errors", { cause: c });
259
+ return { result: o };
260
+ }
261
+ async function U(e, t, n) {
262
+ let r = await P(e.subCommands);
263
+ if (r && Object.keys(r).length > 0) {
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
+ }
267
+ return [e, n];
268
+ }
269
+ async function W(e, t) {
270
+ if (t in e) return P(e[t]);
271
+ for (let n of Object.values(e)) {
272
+ let e = await P(n), r = await P(e?.meta);
273
+ if (r?.alias && N(r.alias).includes(t)) return e;
274
+ }
275
+ }
276
+ function ke(e, t) {
277
+ for (let n = 0; n < e.length; n++) {
278
+ let r = e[n];
279
+ if (r === "--") return -1;
280
+ if (r.startsWith("-")) !r.includes("=") && Ae(r, t) && n++;
281
+ else return n;
282
+ }
283
+ return -1;
284
+ }
285
+ function Ae(e, t) {
286
+ let n = e.replace(/^-{1,2}/, ""), r = M(n);
287
+ for (let [e, i] of Object.entries(t)) if ((i.type === "string" || i.type === "enum") && (r === M(e) || (Array.isArray(i.alias) ? i.alias : i.alias ? [i.alias] : []).includes(n))) return !0;
288
+ return !1;
289
+ }
290
+ async function je(e, t) {
291
+ try {
292
+ console.log(await Ne(e, t) + "\n");
293
+ } catch (e) {
294
+ console.error(e);
295
+ }
296
+ }
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
+ for (let e of r) if (e.type === "positional") {
301
+ let t = e.name.toUpperCase(), n = e.required !== !1 && e.default === void 0;
302
+ s.push([R(t + G(e)), Pe(e, n)]), l.push(n ? `<${t}>` : `[${t}]`);
303
+ } else {
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
+ let n = [...(e.alias || []).map((e) => `--no-${e}`), `--no-${e.name}`].join(", ");
307
+ o.push([R(n), [e.negativeDescription, t ? z("(Required)") : ""].filter(Boolean).join(" ")]);
308
+ }
309
+ t && l.push(`--${e.name}` + G(e));
310
+ }
311
+ if (e.subCommands) {
312
+ let t = [], n = await P(e.subCommands);
313
+ for (let [e, r] of Object.entries(n)) {
314
+ let n = await P((await P(r))?.meta);
315
+ if (n?.hidden) continue;
316
+ let i = N(n?.alias), a = [e, ...i].join(", ");
317
+ c.push([R(a), n?.description || ""]), t.push(e, ...i);
318
+ }
319
+ l.push(t.join("|"));
320
+ }
321
+ let u = [], d = n.version || i.version;
322
+ u.push(z(`${n.description} (${a + (d ? ` v${d}` : "")})`), "");
323
+ let f = o.length > 0 || s.length > 0;
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
+ }
326
+ function G(e) {
327
+ let t = e.valueHint ? `=<${e.valueHint}>` : "", n = t || `=<${Se(e.name)}>`;
328
+ return !e.type || e.type === "positional" || e.type === "boolean" ? t : e.type === "enum" && e.options?.length ? `=<${e.options.join("|")}>` : n;
329
+ }
330
+ function Pe(e, t) {
331
+ let n = t ? z("(Required)") : "", r = e.default === void 0 ? "" : z(`(Default: ${e.default})`);
332
+ return [
333
+ e.description,
334
+ n,
335
+ r
336
+ ].filter(Boolean).join(" ");
337
+ }
338
+ async function Fe(e, t = {}) {
339
+ let n = t.rawArgs || process.argv.slice(2), r = t.showUsage || je;
340
+ try {
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
+ else if (n.length === 1 && t.version.includes(n[0])) {
344
+ let t = typeof e.meta == "function" ? await e.meta() : await e.meta;
345
+ if (!t?.version) throw new F("No version specified", "E_NO_VERSION");
346
+ console.log(t.version);
347
+ } else await H(e, { rawArgs: n });
348
+ } catch (t) {
349
+ t instanceof F ? (await r(...await U(e, n)), console.error(t.message)) : console.error(t, "\n"), process.exit(1);
350
+ }
351
+ }
352
+ async function Ie(e) {
353
+ let t = await P(e.args || {}), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
354
+ for (let [e, i] of Object.entries(t)) {
355
+ n.add(e);
356
+ for (let e of N(i.alias)) r.add(e);
357
+ }
358
+ return {
359
+ help: Le("help", "h", n, r),
360
+ version: Le("version", "v", n, r)
361
+ };
362
+ }
363
+ function Le(e, t, n, r) {
364
+ return n.has(e) || r.has(e) ? [] : n.has(t) || r.has(t) ? [`--${e}`] : [`--${e}`, `-${t}`];
365
+ }
366
+ //#endregion
367
+ //#region package.json
368
+ var Re = "0.0.17", ze = "Commands to develop, bundle, and package Incarnative.js apps.";
369
+ //#endregion
19
370
  //#region ../../node_modules/.pnpm/rc9@3.1.0/node_modules/rc9/dist/_chunks/libs/flat.mjs
20
- function pe(e) {
371
+ function Be(e) {
21
372
  return e && e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
22
373
  }
23
- function M(e) {
374
+ function Ve(e) {
24
375
  return e;
25
376
  }
26
- function me(e, t) {
377
+ function He(e, t) {
27
378
  t ||= {};
28
- let n = t.delimiter || ".", r = t.maxDepth, i = t.transformKey || M, a = {};
379
+ let n = t.delimiter || ".", r = t.maxDepth, i = t.transformKey || Ve, a = {};
29
380
  function o(e, s, c) {
30
381
  c ||= 1, Object.keys(e).forEach(function(l) {
31
- let u = e[l], d = t.safe && Array.isArray(u), f = Object.prototype.toString.call(u), p = pe(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);
32
383
  if (!d && !p && m && Object.keys(u).length && (!t.maxDepth || c < r)) return o(u, h, c + 1);
33
384
  a[h] = u;
34
385
  });
35
386
  }
36
387
  return o(e), a;
37
388
  }
38
- function N(e, t) {
389
+ function Ue(e, t) {
39
390
  t ||= {};
40
- let n = t.delimiter || ".", r = t.overwrite || !1, i = t.transformKey || M, a = {};
41
- if (pe(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;
42
393
  function o(e) {
43
394
  let n = Number(e);
44
395
  return isNaN(n) || e.indexOf(".") !== -1 || t.object ? e : n;
@@ -56,7 +407,7 @@ function N(e, t) {
56
407
  }
57
408
  return e = Object.keys(e).reduce(function(n, r) {
58
409
  let i = Object.prototype.toString.call(e[r]);
59
- return i !== "[object Object]" && i !== "[object Array]" || c(e[r]) ? (n[r] = e[r], n) : s(r, n, me(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));
60
411
  }, {}), Object.keys(e).forEach(function(s) {
61
412
  let c = s.split(n).map(i), l = o(c.shift()), u = o(c[0]), d = a;
62
413
  for (; u !== void 0;) {
@@ -65,20 +416,20 @@ function N(e, t) {
65
416
  if (!r && !n && d[l] !== void 0) return;
66
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]));
67
418
  }
68
- d[l] = N(e[s], t);
419
+ d[l] = Ue(e[s], t);
69
420
  }), a;
70
421
  }
71
422
  //#endregion
72
423
  //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
73
- var he = /"(?:_|\\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*:/, _e = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
74
- function ve(e, t) {
75
- 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);
76
427
  else return t;
77
428
  }
78
- function ye(e) {
429
+ function Je(e) {
79
430
  console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);
80
431
  }
81
- function be(e, t = {}) {
432
+ function Ye(e, t = {}) {
82
433
  if (typeof e != "string") return e;
83
434
  if (e[0] === "\"" && e[e.length - 1] === "\"" && e.indexOf("\\") === -1) return e.slice(1, -1);
84
435
  let n = e.trim();
@@ -91,14 +442,14 @@ function be(e, t = {}) {
91
442
  case "infinity": return Infinity;
92
443
  case "-infinity": return -Infinity;
93
444
  }
94
- if (!_e.test(e)) {
445
+ if (!Ke.test(e)) {
95
446
  if (t.strict) throw SyntaxError("[destr] Invalid JSON");
96
447
  return e;
97
448
  }
98
449
  try {
99
- if (he.test(e) || ge.test(e)) {
450
+ if (We.test(e) || Ge.test(e)) {
100
451
  if (t.strict) throw Error("[destr] Possible prototype pollution");
101
- return JSON.parse(e, ve);
452
+ return JSON.parse(e, qe);
102
453
  }
103
454
  return JSON.parse(e);
104
455
  } catch (n) {
@@ -108,83 +459,83 @@ function be(e, t = {}) {
108
459
  }
109
460
  //#endregion
110
461
  //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
111
- function P(e) {
462
+ function Xe(e) {
112
463
  if (typeof e != "object" || !e) return !1;
113
464
  let t = Object.getPrototypeOf(e);
114
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;
115
466
  }
116
- function F(e, t, n = ".", r) {
117
- if (!P(t)) return F(e, {}, n, r);
467
+ function Ze(e, t, n = ".", r) {
468
+ if (!Xe(t)) return Ze(e, {}, n, r);
118
469
  let i = { ...t };
119
470
  for (let t of Object.keys(e)) {
120
471
  if (t === "__proto__" || t === "constructor") continue;
121
472
  let a = e[t];
122
- a != null && (r && r(i, t, a, n) || (i[t] = Array.isArray(a) && Array.isArray(i[t]) ? [...a, ...i[t]] : P(a) && P(i[t]) ? F(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));
123
474
  }
124
475
  return i;
125
476
  }
126
- function xe(e) {
127
- return (...t) => t.reduce((t, n) => F(t, n, "", e), {});
477
+ function Qe(e) {
478
+ return (...t) => t.reduce((t, n) => Ze(t, n, "", e), {});
128
479
  }
129
- var I = xe(), Se = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/, Ce = /\n|\r|\r\n/, we = {
480
+ var K = Qe(), $e = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/, et = /\n|\r|\r\n/, tt = {
130
481
  name: ".conf",
131
482
  dir: process.cwd(),
132
483
  flat: !1
133
484
  };
134
- function Te(e) {
485
+ function nt(e) {
135
486
  return typeof e == "string" && (e = { name: e }), {
136
- ...we,
487
+ ...tt,
137
488
  ...e
138
489
  };
139
490
  }
140
- function Ee(e, t = {}) {
141
- let n = {}, r = e.split(Ce);
491
+ function rt(e, t = {}) {
492
+ let n = {}, r = e.split(et);
142
493
  for (let e of r) {
143
- let t = e.match(Se);
494
+ let t = e.match($e);
144
495
  if (!t) continue;
145
496
  let r = t[1];
146
497
  if (!r || r === "__proto__" || r === "constructor") continue;
147
- let i = be((t[2] || "").trim());
498
+ let i = Ye((t[2] || "").trim());
148
499
  if (r.endsWith("[]")) {
149
500
  let e = r.slice(0, Math.max(0, r.length - 2));
150
501
  n[e] = (n[e] || []).concat(i);
151
502
  } else n[r] = i;
152
503
  }
153
- return t.flat ? n : N(n, { overwrite: !0 });
504
+ return t.flat ? n : Ue(n, { overwrite: !0 });
154
505
  }
155
- function De(e, t) {
156
- return p(e) ? Ee(h(e, "utf8"), t) : {};
506
+ function it(e, t) {
507
+ return p(e) ? rt(h(e, "utf8"), t) : {};
157
508
  }
158
- function L(e) {
159
- return e = Te(e), De(b(e.dir, e.name), e);
509
+ function q(e) {
510
+ return e = nt(e), it(b(e.dir, e.name), e);
160
511
  }
161
- function Oe() {
162
- return process.env.XDG_CONFIG_HOME || b(k(), ".config");
512
+ function at() {
513
+ return process.env.XDG_CONFIG_HOME || b(A(), ".config");
163
514
  }
164
- function ke(e) {
165
- return e = Te(e), e.dir = Oe(), L(e);
515
+ function ot(e) {
516
+ return e = nt(e), e.dir = at(), q(e);
166
517
  }
167
518
  //#endregion
168
519
  //#region ../../node_modules/.pnpm/c12@4.0.0-rc.2_magicast@0.5.4/node_modules/c12/dist/index.mjs
169
- async function Ae(e) {
170
- let t = e.env ?? process.env, n = await je({
520
+ async function st(e) {
521
+ let t = e.env ?? process.env, n = await ct({
171
522
  cwd: e.cwd,
172
523
  fileName: e.fileName ?? ".env",
173
524
  env: t,
174
525
  interpolate: e.interpolate ?? !0,
175
526
  expandFileReferences: e.expandFileReferences ?? !1,
176
527
  parse: e.parse
177
- }), r = Re(t);
528
+ }), r = gt(t);
178
529
  for (let e in n) e.startsWith("_") || (t[e] === void 0 || r.has(e)) && (t[e] = n[e]);
179
530
  return n;
180
531
  }
181
- async function je(e) {
182
- let n = Object.create(null), r = t(e.cwd || "."), i = e.fileName || ".env", a = typeof i == "string" ? [i] : i, o = Re(e.env || {});
532
+ async function ct(e) {
533
+ let n = Object.create(null), r = t(e.cwd || "."), i = e.fileName || ".env", a = typeof i == "string" ? [i] : i, o = gt(e.env || {});
183
534
  Object.assign(n, e.env);
184
535
  for (let i of a) {
185
536
  let a = t(r, i);
186
537
  if (!_(a, { throwIfNoEntry: !1 })?.isFile()) continue;
187
- let s = await Me(a, e.parse);
538
+ let s = await ut(a, e.parse);
188
539
  for (let e in s) e in n && !o.has(e) || (n[e] = s[e], o.add(e));
189
540
  }
190
541
  if (e.expandFileReferences) {
@@ -196,21 +547,21 @@ async function je(e) {
196
547
  }
197
548
  }
198
549
  }
199
- return e.interpolate && Ne(n), n;
550
+ return e.interpolate && dt(n), n;
200
551
  }
201
- var R = te.parseEnv;
202
- async function Me(e, t) {
552
+ var lt = ee.parseEnv;
553
+ async function ut(e, t) {
203
554
  let n = h(e, "utf8");
204
555
  if (t) return t(n);
205
- if (!R) try {
556
+ if (!lt) try {
206
557
  let e = await import("./chunks/__vite-optional-peer-dep_dotenv_c12-CxKvRg9-.js");
207
- R = (t) => e.parse(t);
558
+ lt = (t) => e.parse(t);
208
559
  } catch {
209
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.");
210
561
  }
211
- return R(n);
562
+ return lt(n);
212
563
  }
213
- function Ne(e, t = {}, n = (e) => e) {
564
+ function dt(e, t = {}, n = (e) => e) {
214
565
  function r(n) {
215
566
  return t[n] === void 0 ? e[n] : t[n];
216
567
  }
@@ -223,7 +574,7 @@ function Ne(e, t = {}, n = (e) => e) {
223
574
  a += "$", o += 2;
224
575
  continue;
225
576
  }
226
- let s = n === "$" ? Ie(e, o) : void 0;
577
+ let s = n === "$" ? mt(e, o) : void 0;
227
578
  if (!s) {
228
579
  a += n, o++;
229
580
  continue;
@@ -242,11 +593,11 @@ function Ne(e, t = {}, n = (e) => e) {
242
593
  }
243
594
  for (let t in e) e[t] = i(r(t));
244
595
  }
245
- var Pe = /\w+/y, Fe = /[\w:]+/y;
246
- function Ie(e, t) {
596
+ var ft = /\w+/y, pt = /[\w:]+/y;
597
+ function mt(e, t) {
247
598
  let n = t + 1, r = e[n] === "{";
248
599
  r && n++;
249
- let i = r ? Fe : Pe;
600
+ let i = r ? pt : ft;
250
601
  i.lastIndex = n;
251
602
  let a = i.exec(e);
252
603
  if (!a) return;
@@ -262,7 +613,7 @@ function Ie(e, t) {
262
613
  if (e[n] === "-") {
263
614
  let t = "-";
264
615
  o.endsWith(":") && (o = o.slice(0, -1), t = ":-");
265
- let r = o ? Le(e, n + 1) : void 0;
616
+ let r = o ? ht(e, n + 1) : void 0;
266
617
  return r ? {
267
618
  key: o,
268
619
  operator: t,
@@ -275,7 +626,7 @@ function Ie(e, t) {
275
626
  end: n
276
627
  };
277
628
  }
278
- function Le(e, t) {
629
+ function ht(e, t) {
279
630
  let n = "", r = 1;
280
631
  for (let i = t; i < e.length; i++) {
281
632
  let t = e[i];
@@ -292,18 +643,18 @@ function Le(e, t) {
292
643
  }
293
644
  }
294
645
  }
295
- function Re(e) {
646
+ function gt(e) {
296
647
  let t = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
297
648
  return t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e);
298
649
  }
299
- var ze = (e) => e?.replace(/\\/g, "/"), Be = 0, Ve = {
650
+ var _t = (e) => e?.replace(/\\/g, "/"), vt = 0, yt = {
300
651
  ".json": () => JSON.parse,
301
652
  ".yaml": () => import("./chunks/yaml-U_oPOIGK.js").then((e) => e.parseYAML),
302
653
  ".yml": () => import("./chunks/yaml-U_oPOIGK.js").then((e) => e.parseYAML),
303
654
  ".jsonc": () => import("./chunks/jsonc-BDHXk_1o.js").then((e) => e.n).then((e) => (t) => e.parseJSONC(t, { allowTrailingComma: !0 })),
304
655
  ".json5": () => import("./chunks/json5-RapVXICN.js").then((e) => e.parseJSON5),
305
656
  ".toml": () => import("./chunks/toml-CgS7wGvD.js").then((e) => e.parseTOML)
306
- }, He = Object.freeze([
657
+ }, bt = Object.freeze([
307
658
  ".js",
308
659
  ".ts",
309
660
  ".mjs",
@@ -317,12 +668,12 @@ var ze = (e) => e?.replace(/\\/g, "/"), Be = 0, Ve = {
317
668
  ".yml",
318
669
  ".toml"
319
670
  ]);
320
- async function Ue(e) {
671
+ async function xt(e) {
321
672
  e.cwd = t(process.cwd(), e.cwd || "."), e.name = e.name || "config", e.envName = e.envName ?? process.env.NODE_ENV, e.configFile = e.configFile ?? (e.name === "config" ? "config" : `${e.name}.config`), e.rcFile = e.rcFile ?? `.${e.name}rc`, e.extend !== !1 && (e.extend = {
322
673
  extendKey: "extends",
323
674
  ...e.extend
324
675
  });
325
- let n = e.merger || I, r = {
676
+ let n = e.merger || K, r = {
326
677
  config: {},
327
678
  cwd: e.cwd,
328
679
  configFile: t(e.cwd, e.configFile),
@@ -335,24 +686,24 @@ async function Ue(e) {
335
686
  packageJson: void 0,
336
687
  defaultConfig: e.defaultConfig
337
688
  };
338
- e.dotenv && await Ae({
689
+ e.dotenv && await st({
339
690
  cwd: e.cwd,
340
691
  ...e.dotenv === !0 ? {} : e.dotenv
341
692
  });
342
- let a = await z(".", e);
693
+ let a = await Tt(".", e);
343
694
  if (a.configFile && (i.main = a.config, r.configFile = a.configFile, r._configFile = a._configFile), a.meta && (r.meta = a.meta), e.rcFile) {
344
695
  let t = [];
345
- if (t.push(L({
696
+ if (t.push(q({
346
697
  name: e.rcFile,
347
698
  dir: e.cwd
348
699
  })), e.globalRc) {
349
700
  let { findWorkspaceDir: n } = await import("./chunks/dist-DrnNGO2a.js"), r = await n(e.cwd).catch(() => {});
350
- r && t.push(L({
701
+ r && t.push(q({
351
702
  name: e.rcFile,
352
703
  dir: r
353
- })), t.push(ke({ name: e.rcFile })), t.push(L({
704
+ })), t.push(ot({ name: e.rcFile })), t.push(q({
354
705
  name: e.rcFile,
355
- dir: k()
706
+ dir: A()
356
707
  }));
357
708
  }
358
709
  i.rc = n({}, ...t);
@@ -369,7 +720,7 @@ async function Ue(e) {
369
720
  rawConfigs: i
370
721
  }) : t);
371
722
  }
372
- if (Array.isArray(o.main) ? r.config = o.main : (r.config = n(o.overrides, o.main, o.rc, o.packageJson, o.defaultConfig), e.extend && (await We(r.config, e), r.layers = r.config._layers, delete r.config._layers, r.config = n(r.config, ...r.layers.map((e) => e.config)))), r.layers = [...[
723
+ if (Array.isArray(o.main) ? r.config = o.main : (r.config = n(o.overrides, o.main, o.rc, o.packageJson, o.defaultConfig), e.extend && (await St(r.config, e), r.layers = r.config._layers, delete r.config._layers, r.config = n(r.config, ...r.layers.map((e) => e.config)))), r.layers = [...[
373
724
  o.overrides && {
374
725
  config: o.overrides,
375
726
  configFile: void 0,
@@ -390,9 +741,9 @@ async function Ue(e) {
390
741
  }
391
742
  ].filter((e) => e && e.config), ...r.layers], e.defaults && (r.config = n(r.config, e.defaults)), e.omit$Keys) for (let e in r.config) e.startsWith("$") && delete r.config[e];
392
743
  if (e.configFileRequired && !r._configFile) throw Error(`Required config (${r.configFile}) cannot be resolved.`);
393
- return e.schema != null && (r.config = await qe(r.config, e.schema)), r;
744
+ return e.schema != null && (r.config = await Et(r.config, e.schema)), r;
394
745
  }
395
- async function We(e, t) {
746
+ async function St(e, t) {
396
747
  if (e._layers = e._layers || [], !t.extend) return;
397
748
  let n = t.extend.extendKey;
398
749
  typeof n == "string" && (n = [n]);
@@ -404,34 +755,34 @@ async function We(e, t) {
404
755
  console.warn(`Cannot extend config from \`${JSON.stringify(r)}\` in ${t.cwd}`);
405
756
  continue;
406
757
  }
407
- let a = await z(n, t, i);
408
- a.config ? (await We(a.config, {
758
+ let a = await Tt(n, t, i);
759
+ a.config ? (await St(a.config, {
409
760
  ...t,
410
761
  cwd: a.cwd
411
762
  }), e._layers.push(a), a.config._layers && (e._layers.push(...a.config._layers), delete a.config._layers)) : console.warn(`Cannot extend config from \`${n}\` in ${t.cwd}`);
412
763
  }
413
764
  }
414
- var Ge = [
765
+ var Ct = [
415
766
  "gh:",
416
767
  "github:",
417
768
  "gitlab:",
418
769
  "bitbucket:",
419
770
  "https://",
420
771
  "http://"
421
- ], Ke = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
422
- async function z(e, o, s = {}) {
772
+ ], wt = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
773
+ async function Tt(e, o, s = {}) {
423
774
  if (o.resolve) {
424
775
  let t = await o.resolve(e, o);
425
776
  if (t) return t;
426
777
  }
427
- let c = o.merger || I, l = Object.keys(s.giget?.providers || {}).map((e) => `${e}:`), u = l.length > 0 ? [.../* @__PURE__ */ new Set([...l, ...Ge])] : Ge;
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;
428
779
  if (o.giget !== !1 && u.some((t) => e.startsWith(t))) {
429
780
  let { downloadTemplate: n } = await import("./chunks/__vite-optional-peer-dep_giget_c12-BYcrHYBM.js").catch((t) => {
430
781
  throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``, { cause: t });
431
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);
432
- 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(k(), ".cache/c12", l);
433
- let m = s.install ? I(s.install === !0 ? {} : s.install, { ignoreWorkspace: !0 }) : !1;
434
- p(u) && !m && await E(u, { recursive: !0 }), e = (await n(e, {
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);
784
+ let m = s.install ? K(s.install === !0 ? {} : s.install, { ignoreWorkspace: !0 }) : !1;
785
+ p(u) && !m && await O(u, { recursive: !0 }), e = (await n(e, {
435
786
  dir: u,
436
787
  install: m,
437
788
  force: !!m,
@@ -440,8 +791,8 @@ async function z(e, o, s = {}) {
440
791
  ...s.giget
441
792
  })).dir;
442
793
  }
443
- Ke.test(e) && (e = B(e, o) || e);
444
- let d = n(e), f = Je(t(o.cwd, e)) ?? (!d || d === r(e)), m = t(o.cwd, f ? e : a(e));
794
+ wt.test(e) && (e = J(e, o) || e);
795
+ let d = n(e), f = Dt(t(o.cwd, e)) ?? (!d || d === r(e)), m = t(o.cwd, f ? e : a(e));
445
796
  f && (e = o.configFile);
446
797
  let h = {
447
798
  config: void 0,
@@ -450,22 +801,22 @@ async function z(e, o, s = {}) {
450
801
  source: e,
451
802
  sourceOptions: s
452
803
  };
453
- if (h.configFile = B(t(m, e), o) || B(t(m, ".config", e.replace(/\.config$/, "")), o) || B(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;
454
805
  h._configFile = h.configFile;
455
806
  let g = n(h.configFile) || "";
456
- if (g in Ve) h.config = (await Ve[g]())(await T(h.configFile, "utf8"));
807
+ if (g in yt) h.config = (await yt[g]())(await D(h.configFile, "utf8"));
457
808
  else {
458
809
  let e = o.resolveModule || ((e) => e.default || e);
459
810
  if (o.import) h.config = e(await o.import(h.configFile));
460
811
  else {
461
812
  let t = re(h.configFile);
462
- t.search = `_${++Be}`, h.config = await import(t.href).then(e, async (t) => {
813
+ t.search = `_${++vt}`, h.config = await import(t.href).then(e, async (t) => {
463
814
  let { createJiti: n } = await import("./chunks/__vite-optional-peer-dep_jiti_c12-DZVJNj6v.js").catch(() => {
464
815
  throw Error(`Failed to load config file \`${h.configFile}\`: ${t?.message}. Hint install \`jiti\` for compatibility.`, { cause: t });
465
816
  }), r = n(i(o.cwd || ".", o.configFile || "/"), {
466
817
  interopDefault: !0,
467
818
  moduleCache: !1,
468
- extensions: [...He],
819
+ extensions: [...bt],
469
820
  ...o.jitiOptions
470
821
  });
471
822
  return o.import = (e) => r.import(e), e(await o.import(h.configFile));
@@ -474,9 +825,9 @@ async function z(e, o, s = {}) {
474
825
  }
475
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 });
476
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);
477
- return _.length > 0 && (h.config = (o.envMerger || c)({}, ..._, h.config)), h.meta = I(h.sourceOptions.meta, h.config.$meta), delete h.config.$meta, h.sourceOptions.overrides && (h.config = c(h.sourceOptions.overrides, h.config)), h.configFile = ze(h.configFile), h.source = ze(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;
478
829
  }
479
- async function qe(e, t) {
830
+ async function Et(e, t) {
480
831
  if (typeof t?.["~standard"]?.validate != "function") throw TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");
481
832
  let n = await t["~standard"].validate(e);
482
833
  if (n.issues) {
@@ -488,17 +839,17 @@ async function qe(e, t) {
488
839
  }
489
840
  return n.value;
490
841
  }
491
- function B(e, t) {
842
+ function J(e, t) {
492
843
  let n = s(e, {
493
844
  try: !0,
494
845
  from: re(i(t.cwd || ".", t.configFile || "/")),
495
846
  suffixes: ["", "/index"],
496
- extensions: He,
847
+ extensions: bt,
497
848
  cache: !1
498
849
  });
499
850
  return n ? o(n) : void 0;
500
851
  }
501
- function Je(e) {
852
+ function Dt(e) {
502
853
  try {
503
854
  return _(e).isDirectory();
504
855
  } catch {
@@ -507,94 +858,94 @@ function Je(e) {
507
858
  }
508
859
  //#endregion
509
860
  //#region src/error.mts
510
- var V = class extends Error {
861
+ var Y = class extends Error {
511
862
  code;
512
863
  path;
513
864
  name = "IncaError";
514
865
  constructor(e, t, n) {
515
866
  super(t), this.code = e, this.path = n;
516
867
  }
517
- }, Ye = {
868
+ }, Ot = {
518
869
  name: "inca",
519
870
  packageJson: "inca",
520
871
  rcFile: !1,
521
872
  globalRc: !1,
522
873
  giget: !1,
523
874
  extend: !1
524
- }, Xe = /[/\\:*?"<>|\0]/;
525
- function Ze(e) {
526
- return e === e.trim() && e !== "" && e !== "." && e !== ".." && !Xe.test(e);
875
+ }, kt = /[/\\:*?"<>|\0]/;
876
+ function At(e) {
877
+ return e === e.trim() && e !== "" && e !== "." && e !== ".." && !kt.test(e);
527
878
  }
528
- function H(e) {
529
- if (!(typeof e == "string" && Ze(e))) throw new V("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 \`/\\:*?"<>|\``);
879
+ function jt(e) {
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 \`/\\:*?"<>|\``);
530
881
  }
531
- var Qe = process.platform === "darwin" || process.platform === "win32";
532
- function $e(e, t) {
533
- let n = (e) => Qe ? e.toLowerCase() : e, r = y.relative(n(e), n(t));
882
+ var Mt = process.platform === "darwin" || process.platform === "win32";
883
+ function Nt(e, t) {
884
+ let n = (e) => Mt ? e.toLowerCase() : e, r = y.relative(n(e), n(t));
534
885
  return r === "" || r !== ".." && !r.startsWith(`..${y.sep}`) && !y.isAbsolute(r);
535
886
  }
536
- function U(e) {
887
+ function Pt(e) {
537
888
  let t = y.resolve(e), n = t;
538
889
  for (let e; !m(n, { throwIfNoEntry: !1 }) && (e = y.dirname(n)) !== n;) n = e;
539
890
  return y.join(g.native(n), y.relative(n, t));
540
891
  }
541
- function W(e, t, n) {
892
+ function Ft(e, t, n) {
542
893
  let r = y.resolve(e, t), i;
543
894
  try {
544
- let t = U(r);
895
+ let t = Pt(r);
545
896
  i = [
546
897
  e,
547
898
  y.join(e, "src"),
548
899
  y.join(e, "node_modules"),
549
900
  ...n ? [n] : []
550
- ].some((e) => $e(t, U(e)));
901
+ ].some((e) => Nt(t, Pt(e)));
551
902
  } catch {
552
903
  i = !0;
553
904
  }
554
- if (i) throw new V("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"`);
555
906
  }
556
- function et(e, t, n) {
907
+ function It(e, t, n) {
557
908
  let r = y.resolve(e, t ?? d.outDir);
558
- return W(e, r, n), r;
909
+ return Ft(e, r, n), r;
559
910
  }
560
- function tt(e, t) {
911
+ function Lt(e, t) {
561
912
  try {
562
913
  return JSON.parse(e);
563
914
  } catch (e) {
564
- throw new V("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);
565
916
  }
566
917
  }
567
- async function G(e) {
568
- let { config: t, layers: n } = await Ue({
918
+ async function Rt(e) {
919
+ let { config: t, layers: n } = await xt({
569
920
  cwd: e,
570
- ...Ye
921
+ ...Ot
571
922
  }), r = n?.find((e) => e.configFile === "package.json");
572
923
  return {
573
924
  config: t,
574
925
  usedPackageJsonKey: Object.keys(r?.config ?? {}).length > 0
575
926
  };
576
927
  }
577
- async function nt(e) {
578
- let { config: t } = await G(e), n = t.entry ? y.resolve(e, t.entry) : void 0;
928
+ async function zt(e) {
929
+ let { config: t } = await Rt(e), n = t.entry ? y.resolve(e, t.entry) : void 0;
579
930
  return {
580
931
  entry: n,
581
- outDir: et(e, t.outDir, n),
932
+ outDir: It(e, t.outDir, n),
582
933
  sourcemap: t.sourcemap ?? d.sourcemap
583
934
  };
584
935
  }
585
- async function rt(e) {
936
+ async function Bt(e) {
586
937
  let t = y.join(e, "package.json"), n;
587
938
  try {
588
- n = await T(t, "utf8");
939
+ n = await D(t, "utf8");
589
940
  } catch {
590
- throw new V("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}`);
591
942
  }
592
- let r = tt(n, t), { config: i, usedPackageJsonKey: a } = await G(e), o = i.productName ?? u(r.name);
593
- if (!o) throw new V("ERR_INCA_PRODUCT_NAME_MISSING", `${t} needs a "name", or "productName" in inca.config.ts`);
594
- H(o);
943
+ let r = Lt(n, t), { config: i, usedPackageJsonKey: a } = await Rt(e), o = i.productName ?? u(r.name);
944
+ if (!o) throw new Y("ERR_INCA_PRODUCT_NAME_MISSING", `${t} needs a "name", or "productName" in inca.config.ts`);
945
+ jt(o);
595
946
  let s = i.version ?? r.version ?? d.version, c = i.identifier ?? l(o), f;
596
- if (i.icon && (f = y.resolve(e, i.icon), !p(f))) throw new V("ERR_INCA_ICON_NOT_FOUND", `"icon" points to ${f}, which doesn't exist`, f);
597
- let m = i.entry ? y.resolve(e, i.entry) : void 0, h = et(e, i.outDir, m);
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);
948
+ let m = i.entry ? y.resolve(e, i.entry) : void 0, h = It(e, i.outDir, m);
598
949
  return {
599
950
  productName: o,
600
951
  identifier: c,
@@ -608,16 +959,16 @@ async function rt(e) {
608
959
  usedPackageJsonKey: a
609
960
  };
610
961
  }
611
- function it(e) {
962
+ function Vt(e) {
612
963
  return {
613
964
  name: e.productName,
614
965
  identifier: e.identifier,
615
966
  window: e.window
616
967
  };
617
968
  }
618
- async function at(e) {
619
- let { config: t } = await G(e), n = y.join(e, "package.json"), r = await T(n, "utf8").catch(() => void 0), i = r === void 0 ? {} : tt(r, n), a = t.productName ?? u(i.name);
620
- a && H(a);
969
+ async function Ht(e) {
970
+ let { config: t } = await Rt(e), n = y.join(e, "package.json"), r = await D(n, "utf8").catch(() => void 0), i = r === void 0 ? {} : Lt(r, n), a = t.productName ?? u(i.name);
971
+ a && jt(a);
621
972
  let o = {
622
973
  name: a,
623
974
  identifier: t.identifier ?? (a ? l(a) : void 0),
@@ -626,8 +977,248 @@ async function at(e) {
626
977
  return Object.values(o).some((e) => e !== void 0) ? o : void 0;
627
978
  }
628
979
  //#endregion
629
- //#region src/adapter/vite/captureOutput.mts
630
- function ot(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) {
631
1222
  return {
632
1223
  outDir: e,
633
1224
  entryFile: y.join(e, t.entryFile),
@@ -635,7 +1226,7 @@ function ot(e, t, n) {
635
1226
  changed: n
636
1227
  };
637
1228
  }
638
- function st(e, t) {
1229
+ function dn(e, t) {
639
1230
  return {
640
1231
  name: "inca:capture-output",
641
1232
  writeBundle(n, r) {
@@ -649,29 +1240,29 @@ function st(e, t) {
649
1240
  };
650
1241
  }
651
1242
  //#endregion
652
- //#region src/adapter/vite/emitConfig.mts
653
- var ct = "inca.json";
654
- function lt(e) {
1243
+ //#region src/vite/emitConfig.mts
1244
+ var fn = "inca.json";
1245
+ function pn(e) {
655
1246
  let t = JSON.stringify(e, void 0, 2);
656
1247
  if (t !== void 0 && t !== "{}") return `${t}\n`;
657
1248
  }
658
- function ut(e) {
659
- let t = lt(e);
1249
+ function mn(e) {
1250
+ let t = pn(e);
660
1251
  return {
661
1252
  name: "inca:emit-config",
662
1253
  generateBundle() {
663
1254
  t && this.emitFile({
664
1255
  type: "asset",
665
- fileName: ct,
1256
+ fileName: fn,
666
1257
  source: t
667
1258
  });
668
1259
  }
669
1260
  };
670
1261
  }
671
1262
  //#endregion
672
- //#region src/adapter/vite/logger.mts
673
- var dt = "Build failed with ", ft = "Pre-transform error";
674
- function pt(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) {
675
1266
  let r = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new Set(), a = {
676
1267
  hasWarned: !1,
677
1268
  info(t) {
@@ -684,7 +1275,7 @@ function pt(e, t, n = !1) {
684
1275
  i.has(e) || (i.add(e), a.warn(e));
685
1276
  },
686
1277
  error(e, n) {
687
- a.hasWarned = !0, n?.error && r.add(n.error), !e.includes(dt) && (e.includes(ft) || 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`));
688
1279
  },
689
1280
  clearScreen() {},
690
1281
  hasErrorLogged(e) {
@@ -694,19 +1285,19 @@ function pt(e, t, n = !1) {
694
1285
  return a;
695
1286
  }
696
1287
  //#endregion
697
- //#region src/adapter/vite/unsupported.mts
698
- var mt = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, ht = [{
1288
+ //#region src/vite/unsupported.mts
1289
+ var vn = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, yn = [{
699
1290
  code: "ERR_INCA_UNSUPPORTED_STYLE",
700
1291
  name: "a <style> block",
701
1292
  matches: (e) => e.includes("vue&type=style"),
702
- hint: "the renderer applies no stylesheet — use a :style binding instead"
1293
+ hint: "the renderer applies no stylesheet. use a :style binding instead"
703
1294
  }, {
704
1295
  code: "ERR_INCA_UNSUPPORTED_STYLESHEET",
705
1296
  name: "a stylesheet import",
706
- matches: (e) => mt.test(e),
707
- hint: "the renderer applies no stylesheet — use a :style binding instead"
1297
+ matches: (e) => vn.test(e),
1298
+ hint: "the renderer applies no stylesheet. use a :style binding instead"
708
1299
  }];
709
- function gt(e, t = ht) {
1300
+ function bn(e, t = yn) {
710
1301
  return {
711
1302
  name: "inca:reject-unsupported",
712
1303
  enforce: "pre",
@@ -719,9 +1310,9 @@ function gt(e, t = ht) {
719
1310
  };
720
1311
  }
721
1312
  //#endregion
722
- //#region src/adapter/vite/config.mts
723
- var _t = "bundle.js";
724
- function vt({ 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 }) {
725
1316
  let f = i === "development" || a;
726
1317
  return {
727
1318
  configFile: !1,
@@ -729,22 +1320,22 @@ function vt({ core: e, runtimeModuleName: t, entry: n, outDir: r, mode: i, sourc
729
1320
  mode: i,
730
1321
  clearScreen: !1,
731
1322
  logLevel: u ? "silent" : "info",
732
- customLogger: pt(c, l),
1323
+ customLogger: _n(c, l),
733
1324
  define: { "process.env.NODE_ENV": JSON.stringify(i) },
734
1325
  plugins: [
735
- se({ template: { compilerOptions: {
1326
+ fe({ template: { compilerOptions: {
736
1327
  runtimeModuleName: t,
737
1328
  hoistStatic: !1
738
1329
  } } }),
739
- gt(e),
740
- ut(d),
741
- st(e, s)
1330
+ bn(e),
1331
+ mn(d),
1332
+ dn(e, s)
742
1333
  ],
743
1334
  build: {
744
1335
  lib: {
745
1336
  entry: n,
746
1337
  formats: ["es"],
747
- fileName: () => _t
1338
+ fileName: () => xn
748
1339
  },
749
1340
  outDir: r,
750
1341
  emptyOutDir: i === "production",
@@ -760,10 +1351,10 @@ function vt({ core: e, runtimeModuleName: t, entry: n, outDir: r, mode: i, sourc
760
1351
  };
761
1352
  }
762
1353
  //#endregion
763
- //#region src/adapter/vite/build.mts
764
- async function yt(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 }) {
765
1356
  let l;
766
- if (await A(vt({
1357
+ if (await le(Sn({
767
1358
  core: e,
768
1359
  runtimeModuleName: t,
769
1360
  entry: n,
@@ -776,60 +1367,90 @@ async function yt(e, t, { entry: n, outDir: r, sourcemap: i, runtimeConfig: a, s
776
1367
  stderr: s,
777
1368
  quiet: c,
778
1369
  onOutput: (e) => {
779
- l = ot(r, e);
1370
+ l = un(r, e);
780
1371
  }
781
1372
  })), !l) throw new e.IncaError("ERR_INCA_BUILD_NO_OUTPUT", "build produced no output");
782
1373
  return l;
783
1374
  }
784
1375
  //#endregion
785
- //#region src/adapter/vite/hmr.mts
786
- function bt(e, t) {
787
- let n = ae(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");
788
1406
  return {
789
1407
  ...e.bundlerFault(t.message),
790
1408
  stack: r || null
791
1409
  };
792
1410
  }
793
- function xt(e) {
1411
+ function En(e) {
794
1412
  return y.join(e, "node_modules/.inca/hmr");
795
1413
  }
796
- function St() {
1414
+ function Dn() {
797
1415
  let e = y.dirname(ne(import.meta.url));
798
1416
  for (; !p(y.join(e, "package.json"));) {
799
1417
  let t = y.dirname(e);
800
1418
  if (t === e) throw Error("could not locate @incajs/cli's own package.json");
801
1419
  e = t;
802
1420
  }
803
- return y.join(e, "dist/hmr-runtime.js");
1421
+ return y.join(e, "dist/vite-runtime.js");
804
1422
  }
805
- function Ct(e, t) {
1423
+ function On(e, t) {
806
1424
  let n = y.relative(e, t).split(y.sep).join("/");
807
1425
  return n.startsWith(".") ? n : `./${n}`;
808
1426
  }
809
- async function wt(e, t, n) {
810
- let r = xt(e);
811
- await w(r, { recursive: !0 });
812
- let i = y.join(r, "entry.js"), a = Ct(r, n ?? St()), o = t.split(y.sep).join("/");
813
- return await D(i, `import { start } from ${JSON.stringify(a)};\nawait start(${JSON.stringify(o)});\n`), i;
1427
+ async function kn(e, t, n) {
1428
+ let r = En(e);
1429
+ await E(r, { recursive: !0 });
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;
814
1435
  }
815
- function Tt(e) {
1436
+ function An(e) {
816
1437
  if (e.type === "error") return e.err;
817
1438
  if (e.type === "custom" && e.event === "vite:invoke") return e.data?.data?.error;
818
1439
  }
819
- function Et(e) {
1440
+ function jn(e) {
820
1441
  if (e.type !== "custom" || e.event !== "vite:invoke") return !1;
821
1442
  let t = e.data;
822
1443
  return t.name === "fetchModule" && !t.data?.error;
823
1444
  }
824
- function Dt(e, t, n, r, i) {
1445
+ function Mn(e, t, n, r, i) {
825
1446
  let a = /* @__PURE__ */ new Map(), o = { send: s };
826
1447
  function s(a) {
827
1448
  if (a.type === "full-reload") {
828
1449
  t();
829
1450
  return;
830
1451
  }
831
- let o = Tt(a);
832
- o ? (n(o), i.current = void 0) : Et(a) && i.current && (r({
1452
+ let o = An(a);
1453
+ o ? (n(o), i.current = void 0) : jn(a) && i.current && (r({
833
1454
  file: i.current.file,
834
1455
  took: Date.now() - i.current.at
835
1456
  }), i.current = void 0), e(a);
@@ -851,7 +1472,7 @@ function Dt(e, t, n, r, i) {
851
1472
  }
852
1473
  };
853
1474
  }
854
- function Ot() {
1475
+ function Nn() {
855
1476
  let e = "\0inca:vite-client-shim";
856
1477
  return {
857
1478
  name: "inca:shim-vite-client",
@@ -864,7 +1485,7 @@ function Ot() {
864
1485
  }
865
1486
  };
866
1487
  }
867
- function kt(e) {
1488
+ function Pn(e) {
868
1489
  return {
869
1490
  name: "inca:file-changed",
870
1491
  hotUpdate(t) {
@@ -879,16 +1500,16 @@ function kt(e) {
879
1500
  }
880
1501
  };
881
1502
  }
882
- async function At(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 = () => {} }) {
883
- let p = await wt(r, n, a), m = lt(i), h = y.join(xt(r), ct);
884
- m ? await D(h, m) : await E(h, { force: !0 });
885
- let g = { current: void 0 }, { channel: _, dispatch: v } = Dt(l, u, (t) => d(bt(e, t)), f, g), b = await oe({
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);
1505
+ m ? await k(h, m) : await O(h, { force: !0 });
1506
+ let g = { current: void 0 }, { channel: _, dispatch: v } = Mn(l, u, (t) => d(Tn(e, t)), f, g), b = await de({
886
1507
  configFile: !1,
887
1508
  root: y.dirname(n),
888
1509
  mode: "development",
889
1510
  clearScreen: !1,
890
1511
  logLevel: c ? "silent" : "info",
891
- customLogger: pt(o, s, c),
1512
+ customLogger: _n(o, s, c),
892
1513
  define: { "process.env.NODE_ENV": JSON.stringify("development") },
893
1514
  server: {
894
1515
  middlewareMode: !0,
@@ -903,20 +1524,20 @@ async function At(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, st
903
1524
  consumer: "client",
904
1525
  dev: {
905
1526
  moduleRunnerTransform: !0,
906
- createEnvironment: (e, t) => new ie(e, t, {
1527
+ createEnvironment: (e, t) => new ce(e, t, {
907
1528
  hot: !0,
908
1529
  transport: _
909
1530
  })
910
1531
  }
911
1532
  } },
912
1533
  plugins: [
913
- se({ template: { compilerOptions: {
1534
+ fe({ template: { compilerOptions: {
914
1535
  runtimeModuleName: t,
915
1536
  hoistStatic: !1
916
1537
  } } }),
917
- gt(e),
918
- Ot(),
919
- kt(g)
1538
+ bn(e),
1539
+ Nn(),
1540
+ Pn(g)
920
1541
  ]
921
1542
  });
922
1543
  return {
@@ -926,9 +1547,9 @@ async function At(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, st
926
1547
  };
927
1548
  }
928
1549
  //#endregion
929
- //#region src/adapter/vite/watch.mts
930
- async function jt(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, stderr: a = process.stderr, quiet: o = !1, ...s }) {
931
- let { outDir: c } = s, l, u = await A(vt({
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({
932
1553
  core: e,
933
1554
  runtimeModuleName: t,
934
1555
  ...s,
@@ -937,7 +1558,7 @@ async function jt(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, st
937
1558
  stderr: a,
938
1559
  quiet: o,
939
1560
  onOutput: (e) => {
940
- n(ot(c, e, l)), l = void 0;
1561
+ n(un(c, e, l)), l = void 0;
941
1562
  }
942
1563
  }));
943
1564
  return u.on("change", (e) => {
@@ -953,274 +1574,44 @@ async function jt(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, st
953
1574
  }), { close: () => u.close() };
954
1575
  }
955
1576
  //#endregion
956
- //#region src/adapter/vite/createBundler.mts
957
- function Mt(e, t) {
1577
+ //#region src/vite/createBundler.mts
1578
+ function Ln(e, t) {
958
1579
  return {
959
- watch: (n) => jt(e, t, n),
960
- build: (n) => yt(e, t, n),
961
- hmr: (n) => At(e, t, n)
1580
+ watch: (n) => In(e, t, n),
1581
+ build: (n) => Cn(e, t, n),
1582
+ hmr: (n) => Fn(e, t, n)
962
1583
  };
963
1584
  }
964
1585
  //#endregion
965
- //#region src/dev-client/hostBin.mts
966
- var Nt = "INCA_HOST_BIN";
967
- function Pt() {
968
- let e = process.platform === "darwin" || process.platform === "linux" ? process.platform : void 0, t = process.arch === "arm64" || process.arch === "x64" ? process.arch : void 0;
969
- return e && t ? `@incajs/host-${e}-${t}` : void 0;
970
- }
971
- function Ft() {
972
- let e = Pt();
973
- if (e) try {
974
- return ce(import.meta.url).resolve(`${e}/bin/inca-host`);
975
- } catch {
976
- return;
977
- }
978
- }
979
- function K() {
980
- let e = process.env[Nt];
981
- if (e) return e;
982
- let t = Ft();
983
- if (t) return t;
984
- let n = Pt();
985
- throw new V("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 ${Nt} isn't set to one`);
986
- }
987
- function q(e) {
988
- if (!_(e, { throwIfNoEntry: !1 })?.isFile()) throw new V("ERR_INCA_HOST_BIN_NOT_FOUND", `no host binary at ${e} — check that it was built`);
989
- }
990
- //#endregion
991
- //#region src/dev-client/hostError.mts
992
- var It = class extends Error {
993
- code;
994
- hostStack;
995
- constructor(e, t, n = null) {
996
- super(e), this.code = t, this.hostStack = n, this.name = "HostError";
997
- }
998
- };
999
- function Lt(e) {
1000
- return typeof e == "object" && !!e && e.jsonrpc === "2.0";
1001
- }
1002
- //#endregion
1003
- //#region src/dev-client/hostClient.mts
1004
- var Rt = (e) => {
1005
- process.stderr.write(e.endsWith("\n") ? e : `${e}\n`);
1006
- }, zt = -32e3, Bt = class {
1007
- #e;
1008
- #t;
1009
- #n = 1;
1010
- #r = /* @__PURE__ */ new Map();
1011
- #i = !1;
1012
- constructor(e) {
1013
- this.#e = e;
1014
- }
1015
- async start() {
1016
- let e = this.#e.hostBin ?? K();
1017
- q(e);
1018
- let t = le(e, ["--dev", this.#e.entryFile], {
1019
- stdio: [
1020
- "pipe",
1021
- "pipe",
1022
- "pipe"
1023
- ],
1024
- env: this.#e.env
1025
- });
1026
- this.#t = t;
1027
- let n = this.#e.onStderr ?? Rt;
1028
- t.stderr.setEncoding("utf8"), t.stderr.on("data", (e) => n(e)), t.stdin.on("error", (e) => {
1029
- e.code !== "EPIPE" && n(`inca-host stdin: ${e.message}\n`);
1030
- }), ue.createInterface({ input: t.stdout }).on("line", (e) => {
1031
- this.#a(e, n);
1032
- }), t.on("exit", (e, t) => {
1033
- let n = /* @__PURE__ */ Error(`inca-host exited (code=${String(e)}, signal=${String(t)}) before answering`);
1034
- for (let { reject: e } of this.#r.values()) e(n);
1035
- this.#r.clear(), this.#i || this.#e.onExit?.(e, t);
1036
- });
1037
- let r = !1;
1038
- t.on("error", (e) => {
1039
- r && n(`inca-host: ${e.message}\n`);
1040
- }), await j(t, "spawn"), r = !0;
1041
- }
1042
- #a(e, t) {
1043
- let n;
1044
- try {
1045
- n = JSON.parse(e);
1046
- } catch {
1047
- t(`[stray stdout] ${e}`);
1048
- return;
1049
- }
1050
- if (!Lt(n)) {
1051
- t(`[stray stdout] ${e}`);
1052
- return;
1053
- }
1054
- if ("method" in n) {
1055
- this.#o(n.method, n.params, t);
1056
- return;
1057
- }
1058
- if (n.id === null) {
1059
- if (!("error" in n)) return;
1060
- let { code: e, message: r, data: i } = n.error;
1061
- e === zt ? this.#e.onAppError?.({
1062
- message: r,
1063
- stack: i?.stack ?? null
1064
- }) : t(`[host error ${String(e)}] ${r}\n`);
1065
- return;
1066
- }
1067
- let r = this.#r.get(n.id);
1068
- r && (this.#r.delete(n.id), "error" in n ? r.reject(new It(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
1069
- }
1070
- #o(e, t, n) {
1071
- switch (e) {
1072
- case "ready": {
1073
- let { protocol: e } = t;
1074
- if (e !== 0) {
1075
- 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);
1076
- return;
1077
- }
1078
- this.#e.onReady?.();
1079
- return;
1080
- }
1081
- case "appError":
1082
- this.#e.onAppError?.(t);
1083
- return;
1084
- default: {
1085
- let r = this.#e.integrations?.[e];
1086
- r ? r(t) : n(`[unhandled notification] ${e}`);
1087
- }
1088
- }
1089
- }
1090
- async #s(e) {
1091
- let t = j(e, "exit");
1092
- e.kill(), await t;
1093
- }
1094
- async call(e, t, n) {
1095
- let r = this.#t;
1096
- if (!r) throw Error("HostClient.start() has not been called");
1097
- let i = this.#n++, a = JSON.stringify({
1098
- jsonrpc: "2.0",
1099
- id: i,
1100
- method: e,
1101
- params: t
1102
- });
1103
- return new Promise((t, o) => {
1104
- let s = n === void 0 ? void 0 : setTimeout(() => {
1105
- this.#r.delete(i), o(/* @__PURE__ */ Error(`${e} timed out after ${String(n)}ms`));
1106
- }, n);
1107
- this.#r.set(i, {
1108
- resolve: (e) => {
1109
- clearTimeout(s), t(e);
1110
- },
1111
- reject: (e) => {
1112
- clearTimeout(s), o(e);
1113
- }
1114
- }), r.stdin.write(`${a}\n`, (e) => {
1115
- e && (clearTimeout(s), this.#r.delete(i), o(e));
1116
- });
1117
- });
1118
- }
1119
- notify(e, t) {
1120
- let n = this.#t;
1121
- if (!n) throw Error("HostClient.start() has not been called");
1122
- n.stdin.write(`${JSON.stringify({
1123
- jsonrpc: "2.0",
1124
- method: e,
1125
- params: t
1126
- })}\n`);
1127
- }
1128
- async stop(e = 2e3) {
1129
- let t = this.#t;
1130
- if (!t || t.exitCode !== null || t.signalCode !== null) return;
1131
- this.#i = !0;
1132
- let n = j(t, "exit");
1133
- this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), de(e, void 0, { ref: !1 }).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
1134
- }
1135
- }, Vt = "[inca]", Ht = new Intl.DateTimeFormat(void 0, {
1136
- hour: "numeric",
1137
- minute: "numeric",
1138
- second: "numeric"
1139
- }), J = { timestamp: !0 };
1140
- function Ut(e, t, n) {
1141
- let r = O(["bold", n], Vt, { stream: e });
1142
- return t.timestamp ? `${O("dim", Ht.format(/* @__PURE__ */ new Date()), { stream: e })} ${r}` : r;
1143
- }
1144
- function Y(e, t, n = {}) {
1145
- e.write(`${Ut(e, n, "cyan")} ${t}\n`);
1146
- }
1147
- function Wt(e) {
1148
- let t = e.code;
1149
- return typeof t == "string" ? t : null;
1150
- }
1151
- function Gt(e) {
1152
- return /\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0] ?? null;
1153
- }
1154
- function Kt(e) {
1155
- let t = e.stack;
1156
- if (!t) return null;
1157
- for (let n of [`${e.name}: ${e.message}`, e.message]) if (t.startsWith(n)) return t.slice(n.length).replace(/^\r?\n/, "") || null;
1158
- return t;
1159
- }
1160
- function qt(e) {
1161
- let t = /^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);
1162
- return t ? {
1163
- message: e.slice(t[0].length),
1164
- stack: null,
1165
- code: t[1]
1166
- } : {
1167
- message: e.replace(/^\w*Error: /, ""),
1168
- stack: null,
1169
- code: null
1170
- };
1171
- }
1172
- function X(e) {
1173
- return e instanceof It ? {
1174
- message: e.message,
1175
- stack: e.hostStack,
1176
- code: Wt(e)
1177
- } : e instanceof Error ? {
1178
- message: e.message,
1179
- stack: Kt(e),
1180
- code: Wt(e) ?? Gt(e.message)
1181
- } : {
1182
- message: String(e),
1183
- stack: null,
1184
- code: null
1185
- };
1186
- }
1187
- function Jt(e, t) {
1188
- return e.split("\n").map((e) => /^\s*at\b/.test(e) ? O("dim", e, { stream: t }) : e).join("\n");
1189
- }
1190
- function Z(e, t, n, r = {}) {
1191
- n.stack && e.write(`${Jt(n.stack, e)}\n`);
1192
- let i = n.code ? ` (${O("bold", n.code, { stream: e })})` : "";
1193
- e.write(`${Ut(e, r, "red")} ${t}${i}: ${n.message}\n`);
1194
- }
1195
- //#endregion
1196
1586
  //#region src/defaultBundler.mts
1197
- var Yt = Mt(/* @__PURE__ */ e({
1198
- IncaError: () => V,
1199
- bundlerFault: () => qt
1200
- }), "incajs/vue/runtime"), Q = [
1587
+ var Rn = Ln(ln, "incajs/vue/runtime"), zn = [
1201
1588
  "main.mts",
1202
1589
  "main.ts",
1203
1590
  "main.js"
1204
1591
  ];
1205
- async function Xt(e) {
1206
- let t = Q.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));
1207
1594
  if (t) return t;
1208
1595
  let n = y.join(e, "src/App.vue");
1209
- if (p(n)) return Zt(n, e);
1210
- throw new V("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`);
1211
1598
  }
1212
- async function Zt(e, t) {
1599
+ async function Vn(e, t) {
1213
1600
  let n = y.join(t, "node_modules/.inca");
1214
- await w(n, { recursive: !0 });
1601
+ await E(n, { recursive: !0 });
1215
1602
  let r = y.join(n, "entry.mts"), i = JSON.stringify(e.split(y.sep).join("/"));
1216
- return await D(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;
1217
1608
  }
1218
1609
  //#endregion
1219
1610
  //#region src/build.mts
1220
- async function Qt(e = {}) {
1221
- let t = e.cwd ?? process.cwd(), n = e.config ?? await nt(t), r = y.resolve(t, n.outDir), i = e.bundler ?? Yt, a = e.entry ?? n.entry ?? await Xt(t);
1222
- W(t, r, a);
1223
- let o = e.runtimeConfig ?? await at(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);
1613
+ Ft(t, r, a);
1614
+ let o = e.runtimeConfig ?? await Ht(t);
1224
1615
  return i.build({
1225
1616
  entry: a,
1226
1617
  outDir: r,
@@ -1232,77 +1623,79 @@ async function Qt(e = {}) {
1232
1623
  }
1233
1624
  //#endregion
1234
1625
  //#region src/devLock.mts
1235
- function $t(e) {
1626
+ function Un(e) {
1236
1627
  return y.join(e, "node_modules/.inca/dev.pid");
1237
1628
  }
1238
- function en(e) {
1629
+ function Wn(e) {
1239
1630
  try {
1240
1631
  return process.kill(e, 0), !0;
1241
1632
  } catch (e) {
1242
1633
  return e.code === "EPERM";
1243
1634
  }
1244
1635
  }
1245
- var tn = fe();
1246
- function $(e) {
1247
- return new V("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)})`);
1248
1639
  }
1249
- async function nn(e) {
1250
- let t = $t(e), n = `${String(process.pid)}:${tn}`, r = `${t}.${fe()}`;
1251
- await w(y.dirname(t), { recursive: !0 }), await D(r, n);
1640
+ async function qn(e) {
1641
+ let t = Un(e), n = `${String(process.pid)}:${Gn}`, r = `${t}.${pe()}`;
1642
+ await E(y.dirname(t), { recursive: !0 }), await k(r, n);
1252
1643
  let i = process.pid;
1253
1644
  try {
1254
1645
  for (let e = 0; e < 5; e++) {
1255
1646
  try {
1256
- return await C(r, t), rn(t, n);
1647
+ return await T(r, t), Jn(t, n);
1257
1648
  } catch (e) {
1258
1649
  if (e.code !== "EEXIST") throw e;
1259
1650
  }
1260
- let e = await T(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
1651
+ let e = await D(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
1261
1652
  if (a === process.pid) {
1262
- if (e === n) throw $(a);
1263
- } else if (Number.isSafeInteger(a) && a > 0 && en(a)) throw $(a);
1264
- i = Number.isSafeInteger(a) && a > 0 ? a : i, await E(t, { force: !0 });
1653
+ if (e === n) throw Kn(a);
1654
+ } else if (Number.isSafeInteger(a) && a > 0 && Wn(a)) throw Kn(a);
1655
+ i = Number.isSafeInteger(a) && a > 0 ? a : i, await O(t, { force: !0 });
1265
1656
  }
1266
- throw $(i);
1657
+ throw Kn(i);
1267
1658
  } finally {
1268
- await E(r, { force: !0 });
1659
+ await O(r, { force: !0 });
1269
1660
  }
1270
1661
  }
1271
- function rn(e, t) {
1662
+ function Jn(e, t) {
1272
1663
  let n = !1;
1273
1664
  return async () => {
1274
- n || (n = !0, await T(e, "utf8").catch(() => "") === t && await E(e, { force: !0 }));
1665
+ n || (n = !0, await D(e, "utf8").catch(() => "") === t && await O(e, { force: !0 }));
1275
1666
  };
1276
1667
  }
1277
1668
  //#endregion
1278
1669
  //#region src/plist.mts
1279
- function an(e) {
1670
+ function Yn(e) {
1280
1671
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
1281
1672
  }
1282
- function on(e) {
1283
- return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${an(e)}</string>`;
1673
+ function Xn(e) {
1674
+ return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${Yn(e)}</string>`;
1284
1675
  }
1285
- function sn(e) {
1286
- return `<?xml version="1.0" encoding="UTF-8"?>
1287
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
1288
- <plist version="1.0">
1289
- <dict>
1290
- ${Object.entries(e).map(([e, t]) => `\t<key>${an(e)}</key>\n\t${on(t)}`).join("\n")}\n</dict>
1291
- </plist>
1292
- `;
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
+ `;
1293
1686
  }
1294
1687
  //#endregion
1295
1688
  //#region src/macosApp.mts
1296
- async function cn(e) {
1689
+ async function Qn(e) {
1297
1690
  let { appPath: t, metadata: n, hostBin: r } = e;
1298
- await E(t, {
1691
+ await O(t, {
1299
1692
  recursive: !0,
1300
1693
  force: !0
1301
1694
  });
1302
1695
  let i = y.join(t, "Contents"), a = y.join(i, "MacOS"), o = y.join(i, "Resources");
1303
- await w(a, { recursive: !0 }), await w(o, { recursive: !0 });
1696
+ await E(a, { recursive: !0 }), await E(o, { recursive: !0 });
1304
1697
  let s = y.join(a, n.productName);
1305
- e.link ? await C(r, s).catch(() => S(r, s)) : await S(r, s), await x(s, 493);
1698
+ e.link ? await T(r, s).catch(() => w(r, s)) : await w(r, s), await C(s, 493);
1306
1699
  let c = {
1307
1700
  CFBundleName: n.productName,
1308
1701
  CFBundleDisplayName: n.productName,
@@ -1316,9 +1709,9 @@ async function cn(e) {
1316
1709
  };
1317
1710
  if (n.icon) {
1318
1711
  let e = y.basename(n.icon);
1319
- await S(n.icon, y.join(o, e)), c.CFBundleIconFile = e;
1712
+ await w(n.icon, y.join(o, e)), c.CFBundleIconFile = e;
1320
1713
  }
1321
- return await D(y.join(i, "Info.plist"), sn(c)), await D(y.join(i, "PkgInfo"), "APPL????"), {
1714
+ return await k(y.join(i, "Info.plist"), Zn(c)), await k(y.join(i, "PkgInfo"), "APPL????"), {
1322
1715
  appPath: t,
1323
1716
  executablePath: s,
1324
1717
  resourcesDir: o
@@ -1326,8 +1719,8 @@ async function cn(e) {
1326
1719
  }
1327
1720
  //#endregion
1328
1721
  //#region src/watchForEdit.mts
1329
- var ln = /^(?:inca\.config\.[a-z0-9]+|package\.json)$/, un = [...Q, "App.vue"];
1330
- function dn(e, t = {}) {
1722
+ var $n = /^(?:inca\.config\.[a-z0-9]+|package\.json)$/, er = [...zn, "App.vue"];
1723
+ function tr(e, t = {}) {
1331
1724
  let n = t.debounceMs ?? 100, r = /* @__PURE__ */ new Set(), i, a = !1, o = () => {}, s = new Promise((e) => {
1332
1725
  o = e;
1333
1726
  }), c = () => {
@@ -1348,7 +1741,7 @@ function dn(e, t = {}) {
1348
1741
  r.clear();
1349
1742
  };
1350
1743
  try {
1351
- l(e, (e) => e === "src" || ln.test(e)), l(y.join(e, "src"), (e) => un.includes(e));
1744
+ l(e, (e) => e === "src" || $n.test(e)), l(y.join(e, "src"), (e) => er.includes(e));
1352
1745
  } catch (e) {
1353
1746
  throw u(), e;
1354
1747
  }
@@ -1364,7 +1757,7 @@ function dn(e, t = {}) {
1364
1757
  }
1365
1758
  //#endregion
1366
1759
  //#region src/retryOnEdit.mts
1367
- function fn(e, t) {
1760
+ function nr(e, t) {
1368
1761
  return new Promise((n) => {
1369
1762
  let r = () => n(!1);
1370
1763
  t.addEventListener("abort", r, { once: !0 }), e.then(() => {
@@ -1372,25 +1765,25 @@ function fn(e, t) {
1372
1765
  });
1373
1766
  });
1374
1767
  }
1375
- async function pn(e) {
1768
+ async function rr(e) {
1376
1769
  let { cwd: t, signal: n, stdout: r, stderr: i, debounceMs: a } = e, o = !1;
1377
1770
  for (;;) {
1378
- let s = dn(t, { debounceMs: a });
1771
+ let s = tr(t, { debounceMs: a });
1379
1772
  try {
1380
1773
  return await e.attempt(s);
1381
1774
  } catch (e) {
1382
- let t = e instanceof V ? e.path : void 0;
1775
+ let t = e instanceof Y ? e.path : void 0;
1383
1776
  if (t) try {
1384
1777
  s.add(t);
1385
1778
  } catch (t) {
1386
- throw Z(i, "build failed", X(e), J), t;
1779
+ throw $(i, "build failed", Q(e), X), t;
1387
1780
  }
1388
1781
  if (!n.aborted && !o && t && p(t)) {
1389
1782
  o = !0;
1390
1783
  continue;
1391
1784
  }
1392
- if (o = !1, Z(i, "build failed", X(e), J), n.aborted || (Y(r, "waiting for a change to retry", J), !await fn(s.edited, n))) return;
1393
- Y(r, "retrying", J);
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);
1394
1787
  } finally {
1395
1788
  s.close();
1396
1789
  }
@@ -1398,115 +1791,115 @@ async function pn(e) {
1398
1791
  }
1399
1792
  //#endregion
1400
1793
  //#region src/dev.mts
1401
- var mn = 1e4, hn = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
1402
- async function gn(e, t) {
1794
+ var ir = 1e4, ar = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
1795
+ async function or(e, t) {
1403
1796
  try {
1404
- return await rt(e);
1797
+ return await Bt(e);
1405
1798
  } catch (e) {
1406
- if (!(e instanceof V) || !hn.includes(e.code)) throw e;
1407
- Y(t, `running unnamed — ${e.message}`, J);
1799
+ if (!(e instanceof Y) || !ar.includes(e.code)) throw e;
1800
+ Z(t, `running unnamed. ${e.message}`, X);
1408
1801
  return;
1409
1802
  }
1410
1803
  }
1411
- async function _n(e, t, n, r) {
1804
+ async function sr(e, t, n, r) {
1412
1805
  if (process.platform === "darwin" && t) try {
1413
- return (await cn({
1806
+ return (await Qn({
1414
1807
  appPath: y.join(e, "node_modules/.inca", `${t.productName}.app`),
1415
1808
  metadata: t,
1416
1809
  hostBin: n,
1417
1810
  link: !0
1418
1811
  })).executablePath;
1419
1812
  } catch (e) {
1420
- Y(r, `running unbundled — ${X(e).message}`, J);
1813
+ Z(r, `running unbundled. ${Q(e).message}`, X);
1421
1814
  return;
1422
1815
  }
1423
1816
  }
1424
- async function vn(e, t) {
1817
+ async function cr(e, t) {
1425
1818
  let n = new Set(t), r;
1426
1819
  try {
1427
- r = await ee(e, {
1820
+ r = await te(e, {
1428
1821
  recursive: !0,
1429
1822
  withFileTypes: !0
1430
1823
  });
1431
1824
  } catch {
1432
1825
  return;
1433
1826
  }
1434
- 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) => E(y.join(e, t), { force: !0 })));
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 })));
1435
1828
  }
1436
- function yn(e) {
1829
+ function lr(e) {
1437
1830
  let { NO_COLOR: t, FORCE_COLOR: n } = process.env;
1438
1831
  if (!(!e.isTTY || t || n)) return {
1439
1832
  ...process.env,
1440
1833
  FORCE_COLOR: "1"
1441
1834
  };
1442
1835
  }
1443
- async function bn(e) {
1444
- let t = e.cwd ?? process.cwd(), n = await nn(t);
1836
+ async function ur(e) {
1837
+ let t = e.cwd ?? process.cwd(), n = await qn(t);
1445
1838
  try {
1446
- let n = e.hostBin ?? K();
1447
- q(n);
1448
- let r = e.bundler ?? Yt, i = e.stdout ?? process.stdout, a = e.stderr ?? process.stderr, o = e.experimentalHmr ? r.hmr?.bind(r) : void 0;
1449
- if (e.experimentalHmr && !o) throw new V("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
1450
- let s = await pn({
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({
1451
1844
  cwd: t,
1452
1845
  signal: e.signal,
1453
1846
  stdout: i,
1454
1847
  stderr: a,
1455
1848
  async attempt() {
1456
- let n = await nt(t), r = y.resolve(t, n.outDir), a = e.entry ?? n.entry ?? await Xt(t);
1457
- W(t, r, a);
1458
- let o = await gn(t, i);
1849
+ let n = await zt(t), r = y.resolve(t, n.outDir), a = e.entry ?? n.entry ?? await Bn(t);
1850
+ Ft(t, r, a);
1851
+ let o = await or(t, i);
1459
1852
  return {
1460
1853
  outDir: r,
1461
1854
  entry: a,
1462
1855
  metadata: o,
1463
- runtimeConfig: o ? it(o) : await at(t)
1856
+ runtimeConfig: o ? Vt(o) : await Ht(t)
1464
1857
  };
1465
1858
  }
1466
1859
  });
1467
1860
  if (!s) return;
1468
- let { outDir: c, entry: l, metadata: u, runtimeConfig: d } = s, f = await _n(t, u, n, i) ?? n, p, m = !1, h = !1, g = !1, _, v = Promise.resolve(), b = () => {}, x = 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) => {
1469
1862
  b = e;
1470
1863
  });
1471
- async function S() {
1864
+ async function x() {
1472
1865
  try {
1473
- return await p?.call("reload", void 0, mn), !0;
1866
+ return await p?.call("reload", void 0, ir), !0;
1474
1867
  } catch (e) {
1475
- return Z(a, "reload failed", X(e), J), !1;
1868
+ return $(a, "reload failed", Q(e), X), !1;
1476
1869
  }
1477
1870
  }
1478
1871
  async function C(e, t) {
1479
- let n = new Bt({
1872
+ let n = new Qt({
1480
1873
  entryFile: e,
1481
1874
  hostBin: f,
1482
- env: yn(a),
1875
+ env: lr(a),
1483
1876
  onStderr: (e) => a.write(e),
1484
1877
  onReady: () => {
1485
- m = !0, Y(i, "ready", J), h && (h = !1, S());
1878
+ m = !0, Z(i, "ready", X), h && (h = !1, x());
1486
1879
  },
1487
- onAppError: (e) => Z(a, "app error", e, J),
1880
+ onAppError: (e) => $(a, "app error", e, X),
1488
1881
  onExit: (e, t) => {
1489
1882
  g = !m, _ = {
1490
1883
  code: e,
1491
1884
  signal: t
1492
- }, Y(i, "host exited — stopping", J), b();
1885
+ }, Z(i, "host exited. stopping", X), b();
1493
1886
  },
1494
1887
  integrations: t
1495
1888
  });
1496
1889
  try {
1497
1890
  await n.start();
1498
1891
  } catch (e) {
1499
- Z(a, "failed to start inca-host", X(e), J);
1892
+ $(a, "failed to start the host", Q(e), X);
1500
1893
  return;
1501
1894
  }
1502
1895
  p = n;
1503
1896
  }
1504
1897
  async function w(e) {
1505
- if (await vn(e.outDir, e.files), !p) await C(e.entryFile);
1898
+ if (await cr(e.outDir, e.files), !p) await C(e.entryFile);
1506
1899
  else if (!m) h = !0;
1507
- else if (await S() && e.changed) {
1508
- let n = O("dim", y.relative(t, e.changed.file), { stream: i }), r = Date.now() - e.changed.at;
1509
- Y(i, `${O("green", "reload")} ${n} (${r}ms)`, J);
1900
+ else if (await x() && e.changed) {
1901
+ let n = S("dim", y.relative(t, e.changed.file), { stream: i }), r = Date.now() - e.changed.at;
1902
+ Z(i, `${S("green", "reload")} ${n} (${r}ms)`, X);
1510
1903
  }
1511
1904
  }
1512
1905
  let T;
@@ -1519,13 +1912,13 @@ async function bn(e) {
1519
1912
  stderr: a,
1520
1913
  notify: (e) => p?.notify("vite", e),
1521
1914
  reload: () => {
1522
- m ? S() : h = !0;
1915
+ m ? x() : h = !0;
1523
1916
  },
1524
- onError: (e) => Z(a, "build failed", e, J),
1917
+ onError: (e) => $(a, "build failed", e, X),
1525
1918
  onUpdate: ({ file: e, took: n }) => {
1526
1919
  if (!m) return;
1527
- let r = O("dim", y.relative(t, e), { stream: i });
1528
- Y(i, `${O("green", "update")} ${r} (${n}ms)`, J);
1920
+ let r = S("dim", y.relative(t, e), { stream: i });
1921
+ Z(i, `${S("green", "update")} ${r} (${n}ms)`, X);
1529
1922
  }
1530
1923
  });
1531
1924
  await C(e.entryFile, { vite: (t) => e.dispatch(t) }), T = e, p || b();
@@ -1540,13 +1933,13 @@ async function bn(e) {
1540
1933
  v = v.then(() => w(e));
1541
1934
  },
1542
1935
  onError: (e) => {
1543
- Z(a, "build failed", e, J);
1936
+ $(a, "build failed", e, X);
1544
1937
  }
1545
1938
  });
1546
- if (e.signal.aborted ? b() : e.signal.addEventListener("abort", () => b(), { once: !0 }), await x, await v, await p?.stop(), await T.close(), g) throw new V("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");
1547
1940
  if (_ && _.code !== 0 && _.signal !== "SIGINT" && _.signal !== "SIGTERM") {
1548
1941
  let { code: e, signal: t } = _;
1549
- throw new V("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}`}`);
1550
1943
  }
1551
1944
  } finally {
1552
1945
  await n();
@@ -1554,73 +1947,72 @@ async function bn(e) {
1554
1947
  }
1555
1948
  //#endregion
1556
1949
  //#region src/package.mts
1557
- function xn() {
1950
+ function dr() {
1558
1951
  if (process.platform === "darwin") return "macos";
1559
1952
  if (process.platform === "linux") return "linux";
1560
- throw new V("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`);
1561
1954
  }
1562
- async function Sn(e, t) {
1955
+ async function fr(e, t) {
1563
1956
  await Promise.all(e.files.map(async (n) => {
1564
1957
  let r = y.join(t, n);
1565
- await w(y.dirname(r), { recursive: !0 }), await S(y.join(e.outDir, n), r);
1958
+ await E(y.dirname(r), { recursive: !0 }), await w(y.join(e.outDir, n), r);
1566
1959
  }));
1567
1960
  }
1568
- function Cn(e, t) {
1961
+ function pr(e, t) {
1569
1962
  let n = e.files.map((e) => e.split("/")[0] ?? e).find((e) => e.toLowerCase() === t.toLowerCase());
1570
- if (n !== void 0) throw new V("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`);
1571
1964
  }
1572
- async function wn({ metadata: e, output: t, hostBin: n }) {
1573
- let { appPath: r, resourcesDir: i } = await cn({
1965
+ async function mr({ metadata: e, output: t, hostBin: n }) {
1966
+ let { appPath: r, resourcesDir: i } = await Qn({
1574
1967
  appPath: y.join(t.outDir, `${e.productName}.app`),
1575
1968
  metadata: e,
1576
1969
  hostBin: n
1577
1970
  });
1578
- return await Sn(t, i), r;
1971
+ return await fr(t, i), r;
1579
1972
  }
1580
- async function Tn({ metadata: e, output: t, hostBin: n }) {
1973
+ async function hr({ metadata: e, output: t, hostBin: n }) {
1581
1974
  let r = c(e.productName);
1582
- Cn(t, r);
1975
+ pr(t, r);
1583
1976
  let i = y.join(t.outDir, r);
1584
- await E(i, {
1977
+ await O(i, {
1585
1978
  recursive: !0,
1586
1979
  force: !0
1587
- }), await w(i, { recursive: !0 });
1980
+ }), await E(i, { recursive: !0 });
1588
1981
  let a = y.join(i, r);
1589
- return await S(n, a), await x(a, 493), await Sn(t, i), i;
1982
+ return await w(n, a), await C(a, 493), await fr(t, i), i;
1590
1983
  }
1591
- async function En(e = {}) {
1592
- let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? xn(), i = await rt(t);
1593
- i.usedPackageJsonKey && Y(n, "the \"inca\" key in package.json is deprecated — move these settings to inca.config.ts"), i.identifierIsDefault && Y(n, `no "identifier" set in inca.config.ts — using generated identifier ${i.identifier}`);
1594
- let a = await Qt({
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);
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}`);
1987
+ let a = await Hn({
1595
1988
  cwd: t,
1596
1989
  entry: e.entry,
1597
1990
  config: i,
1598
1991
  sourcemap: e.sourcemap,
1599
- runtimeConfig: it(i),
1992
+ runtimeConfig: Vt(i),
1600
1993
  bundler: e.bundler,
1601
1994
  stdout: n,
1602
1995
  stderr: e.stderr
1603
- }), o = e.hostBin ?? K();
1604
- q(o);
1996
+ }), o = e.hostBin ?? Kt();
1997
+ qt(o);
1605
1998
  let s = {
1606
1999
  metadata: i,
1607
2000
  output: a,
1608
2001
  hostBin: o
1609
2002
  };
1610
- return { appPath: r === "macos" ? await wn(s) : await Tn(s) };
2003
+ return { appPath: r === "macos" ? await mr(s) : await hr(s) };
1611
2004
  }
1612
2005
  //#endregion
1613
2006
  //#region src/cli.mts
1614
- var Dn = "Usage: inca <dev|build|package> [--sourcemap|--no-sourcemap]";
1615
- function On(e) {
2007
+ function _r(e) {
1616
2008
  return y.relative(process.cwd(), e);
1617
2009
  }
1618
- function kn(e) {
1619
- let t;
1620
- for (let n of e) n === "--sourcemap" ? t = !0 : n === "--no-sourcemap" && (t = !1);
1621
- return t;
1622
- }
1623
- function An() {
2010
+ var vr = {
2011
+ type: "boolean",
2012
+ description: "Write a source map",
2013
+ negativeDescription: "Skip the source map"
2014
+ };
2015
+ function yr() {
1624
2016
  for (let e of [
1625
2017
  0,
1626
2018
  1,
@@ -1629,48 +2021,78 @@ function An() {
1629
2021
  f.closeSync(e);
1630
2022
  } catch {}
1631
2023
  }
1632
- async function jn(e = process.argv) {
1633
- let t = e[2];
1634
- if (t === "build") {
2024
+ var br = V({
2025
+ meta: {
2026
+ name: "build",
2027
+ description: "Bundle the app into dist"
2028
+ },
2029
+ args: { sourcemap: vr },
2030
+ async run({ args: e }) {
1635
2031
  try {
1636
- let t = await Qt({ sourcemap: kn(e) });
1637
- Y(process.stdout, `built ${On(t.entryFile)}`);
2032
+ let t = await Hn({ sourcemap: e.sourcemap });
2033
+ Z(process.stdout, `built ${_r(t.entryFile)}`);
1638
2034
  } catch (e) {
1639
- Z(process.stderr, "build failed", X(e)), process.exitCode = 1;
2035
+ $(process.stderr, "build failed", Q(e)), process.exitCode = 1;
1640
2036
  }
1641
- return;
1642
2037
  }
1643
- if (t === "package") {
2038
+ }), xr = V({
2039
+ meta: {
2040
+ name: "package",
2041
+ description: "Package the app as an application bundle"
2042
+ },
2043
+ args: { sourcemap: vr },
2044
+ async run({ args: e }) {
1644
2045
  try {
1645
- let { appPath: t } = await En({ sourcemap: kn(e) });
1646
- Y(process.stdout, `packaged ${On(t)}`);
2046
+ let { appPath: t } = await gr({ sourcemap: e.sourcemap });
2047
+ Z(process.stdout, `packaged ${_r(t)}`);
1647
2048
  } catch (e) {
1648
- Z(process.stderr, "package failed", X(e)), process.exitCode = 1;
2049
+ $(process.stderr, "package failed", Q(e)), process.exitCode = 1;
1649
2050
  }
1650
- return;
1651
2051
  }
1652
- if (t !== "dev") {
1653
- process.stderr.write(`${Dn}\n`), process.exitCode = 1;
1654
- return;
2052
+ }), Sr = V({
2053
+ meta: {
2054
+ name: "dev",
2055
+ description: "Run the app in a development window"
2056
+ },
2057
+ args: { "experimental-hmr": {
2058
+ type: "boolean",
2059
+ description: "Apply edits without a reload (or set INCA_EXPERIMENTAL_HMR)"
2060
+ } },
2061
+ async run({ args: e }) {
2062
+ "sourcemap" in e && nn(process.stderr, "dev ignores --sourcemap and --no-sourcemap", { timestamp: !0 });
2063
+ let t = new AbortController(), n = () => {
2064
+ t.signal.aborted || (Z(process.stderr, "shutting down", { timestamp: !0 }), t.abort());
2065
+ };
2066
+ process.on("SIGINT", n), process.on("SIGTERM", n);
2067
+ let r = e["experimental-hmr"] === !0 || ![
2068
+ "",
2069
+ "0",
2070
+ "false"
2071
+ ].includes(process.env.INCA_EXPERIMENTAL_HMR ?? "");
2072
+ r && Z(process.stdout, "experimental HMR active", { timestamp: !0 });
2073
+ try {
2074
+ await ur({
2075
+ signal: t.signal,
2076
+ experimentalHmr: r
2077
+ }), t.signal.aborted && yr();
2078
+ } catch (e) {
2079
+ $(process.stderr, "dev failed", Q(e), { timestamp: !0 }), process.exitCode = 1;
2080
+ }
1655
2081
  }
1656
- let n = new AbortController(), r = () => {
1657
- n.signal.aborted || (Y(process.stderr, "shutting down", { timestamp: !0 }), n.abort());
1658
- };
1659
- process.on("SIGINT", r), process.on("SIGTERM", r);
1660
- let i = e.includes("--experimental-hmr") || ![
1661
- "",
1662
- "0",
1663
- "false"
1664
- ].includes(process.env.INCA_EXPERIMENTAL_HMR ?? "");
1665
- i && Y(process.stdout, "experimental HMR active", { timestamp: !0 });
1666
- try {
1667
- await bn({
1668
- signal: n.signal,
1669
- experimentalHmr: i
1670
- }), n.signal.aborted && An();
1671
- } catch (e) {
1672
- Z(process.stderr, "dev failed", X(e), { timestamp: !0 }), process.exitCode = 1;
2082
+ }), Cr = V({
2083
+ meta: {
2084
+ name: "inca",
2085
+ version: Re,
2086
+ description: ze
2087
+ },
2088
+ subCommands: {
2089
+ dev: Sr,
2090
+ build: br,
2091
+ package: xr
1673
2092
  }
2093
+ });
2094
+ async function wr(e = process.argv) {
2095
+ await Fe(Cr, { rawArgs: e.slice(2) });
1674
2096
  }
1675
2097
  //#endregion
1676
- export { jn as run };
2098
+ export { wr as run };