@incajs/cli 0.0.9 → 0.0.11

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
@@ -1,168 +1,678 @@
1
- import { i as e, n as t, o as n, r, t as i } from "./chunks/defaults-Bl2pge8b.js";
2
- import a from "node:path";
3
- import { existsSync as o, lstatSync as s, realpathSync as c, statSync as l } from "node:fs";
4
- import { chmod as u, cp as d, link as f, mkdir as p, readFile as m, readdir as h, rm as g, writeFile as _ } from "node:fs/promises";
5
- import { styleText as v } from "node:util";
6
- import { fileURLToPath as y } from "node:url";
7
- import { DevEnvironment as b, build as x, buildErrorMessage as S, createServer as C } from "vite";
8
- import w from "@vitejs/plugin-vue";
9
- import { createRequire as T } from "node:module";
10
- import { spawn as ee } from "node:child_process";
11
- import { once as E } from "node:events";
12
- import te from "node:readline";
13
- import { setTimeout as ne } from "node:timers/promises";
14
- import { randomUUID as D } from "node:crypto";
1
+ import { t as e } from "./chunks/rolldown-runtime-Dy4uBu1J.js";
2
+ import { c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./chunks/dist-Bc5Uk6dY.js";
3
+ import { i as c, n as l, r as u, t as d } from "./chunks/defaults-TOBTBbDy.js";
4
+ import f, { resolve as p } from "node:path";
5
+ import { existsSync as m, lstatSync as h, readFileSync as g, realpathSync as _, statSync as v, watch as y } from "node:fs";
6
+ import { chmod as b, cp as x, link as S, mkdir as C, readFile as w, readdir as T, rm as E, writeFile as D } from "node:fs/promises";
7
+ import * as ee from "node:util";
8
+ import { styleText as O } from "node:util";
9
+ import { fileURLToPath as te, pathToFileURL as ne } from "node:url";
10
+ import { homedir as k } from "node:os";
11
+ import { DevEnvironment as re, build as A, buildErrorMessage as ie, createServer as ae } from "vite";
12
+ import oe from "@vitejs/plugin-vue";
13
+ import { createRequire as se } from "node:module";
14
+ import { spawn as ce } from "node:child_process";
15
+ import { once as j } from "node:events";
16
+ import le from "node:readline";
17
+ import { setTimeout as ue } from "node:timers/promises";
18
+ import { randomUUID as de } from "node:crypto";
19
+ //#region ../../node_modules/.pnpm/rc9@3.1.0/node_modules/rc9/dist/_chunks/libs/flat.mjs
20
+ function fe(e) {
21
+ return e && e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
22
+ }
23
+ function M(e) {
24
+ return e;
25
+ }
26
+ function pe(e, t) {
27
+ t ||= {};
28
+ let n = t.delimiter || ".", r = t.maxDepth, i = t.transformKey || M, a = {};
29
+ function o(e, s, c) {
30
+ 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 = fe(u), m = f === "[object Object]" || f === "[object Array]", h = s ? s + n + i(l) : i(l);
32
+ if (!d && !p && m && Object.keys(u).length && (!t.maxDepth || c < r)) return o(u, h, c + 1);
33
+ a[h] = u;
34
+ });
35
+ }
36
+ return o(e), a;
37
+ }
38
+ function N(e, t) {
39
+ t ||= {};
40
+ let n = t.delimiter || ".", r = t.overwrite || !1, i = t.transformKey || M, a = {};
41
+ if (fe(e) || Object.prototype.toString.call(e) !== "[object Object]") return e;
42
+ function o(e) {
43
+ let n = Number(e);
44
+ return isNaN(n) || e.indexOf(".") !== -1 || t.object ? e : n;
45
+ }
46
+ function s(e, t, r) {
47
+ return Object.keys(r).reduce(function(t, i) {
48
+ return t[e + n + i] = r[i], t;
49
+ }, t);
50
+ }
51
+ function c(e) {
52
+ let t = Object.prototype.toString.call(e), n = t === "[object Array]", r = t === "[object Object]";
53
+ if (!e) return !0;
54
+ if (n) return !e.length;
55
+ if (r) return !Object.keys(e).length;
56
+ }
57
+ return e = Object.keys(e).reduce(function(n, r) {
58
+ 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, pe(e[r], t));
60
+ }, {}), Object.keys(e).forEach(function(s) {
61
+ let c = s.split(n).map(i), l = o(c.shift()), u = o(c[0]), d = a;
62
+ for (; u !== void 0;) {
63
+ if (l === "__proto__") return;
64
+ let e = Object.prototype.toString.call(d[l]), n = e === "[object Object]" || e === "[object Array]";
65
+ if (!r && !n && d[l] !== void 0) return;
66
+ (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
+ }
68
+ d[l] = N(e[s], t);
69
+ }), a;
70
+ }
71
+ //#endregion
72
+ //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
73
+ var me = /"(?:_|\\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*:/, he = /"(?: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*:/, ge = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
74
+ function _e(e, t) {
75
+ if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) {
76
+ ve(e);
77
+ return;
78
+ }
79
+ return t;
80
+ }
81
+ function ve(e) {
82
+ console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);
83
+ }
84
+ function ye(e, t = {}) {
85
+ if (typeof e != "string") return e;
86
+ if (e[0] === "\"" && e[e.length - 1] === "\"" && e.indexOf("\\") === -1) return e.slice(1, -1);
87
+ let n = e.trim();
88
+ if (n.length <= 9) switch (n.toLowerCase()) {
89
+ case "true": return !0;
90
+ case "false": return !1;
91
+ case "undefined": return;
92
+ case "null": return null;
93
+ case "nan": return NaN;
94
+ case "infinity": return Infinity;
95
+ case "-infinity": return -Infinity;
96
+ }
97
+ if (!ge.test(e)) {
98
+ if (t.strict) throw SyntaxError("[destr] Invalid JSON");
99
+ return e;
100
+ }
101
+ try {
102
+ if (me.test(e) || he.test(e)) {
103
+ if (t.strict) throw Error("[destr] Possible prototype pollution");
104
+ return JSON.parse(e, _e);
105
+ }
106
+ return JSON.parse(e);
107
+ } catch (n) {
108
+ if (t.strict) throw n;
109
+ return e;
110
+ }
111
+ }
112
+ //#endregion
113
+ //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
114
+ function P(e) {
115
+ if (typeof e != "object" || !e) return !1;
116
+ let t = Object.getPrototypeOf(e);
117
+ 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;
118
+ }
119
+ function F(e, t, n = ".", r) {
120
+ if (!P(t)) return F(e, {}, n, r);
121
+ let i = { ...t };
122
+ for (let t of Object.keys(e)) {
123
+ if (t === "__proto__" || t === "constructor") continue;
124
+ let a = e[t];
125
+ 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));
126
+ }
127
+ return i;
128
+ }
129
+ function be(e) {
130
+ return (...t) => t.reduce((t, n) => F(t, n, "", e), {});
131
+ }
132
+ var I = be(), xe = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/, Se = /\n|\r|\r\n/, Ce = {
133
+ name: ".conf",
134
+ dir: process.cwd(),
135
+ flat: !1
136
+ };
137
+ function we(e) {
138
+ return typeof e == "string" && (e = { name: e }), {
139
+ ...Ce,
140
+ ...e
141
+ };
142
+ }
143
+ function Te(e, t = {}) {
144
+ let n = {}, r = e.split(Se);
145
+ for (let e of r) {
146
+ let t = e.match(xe);
147
+ if (!t) continue;
148
+ let r = t[1];
149
+ if (!r || r === "__proto__" || r === "constructor") continue;
150
+ let i = ye((t[2] || "").trim());
151
+ if (r.endsWith("[]")) {
152
+ let e = r.slice(0, Math.max(0, r.length - 2));
153
+ n[e] = (n[e] || []).concat(i);
154
+ continue;
155
+ }
156
+ n[r] = i;
157
+ }
158
+ return t.flat ? n : N(n, { overwrite: !0 });
159
+ }
160
+ function Ee(e, t) {
161
+ return m(e) ? Te(g(e, "utf8"), t) : {};
162
+ }
163
+ function L(e) {
164
+ return e = we(e), Ee(p(e.dir, e.name), e);
165
+ }
166
+ function De() {
167
+ return process.env.XDG_CONFIG_HOME || p(k(), ".config");
168
+ }
169
+ function Oe(e) {
170
+ return e = we(e), e.dir = De(), L(e);
171
+ }
172
+ //#endregion
173
+ //#region ../../node_modules/.pnpm/c12@4.0.0-rc.2_magicast@0.5.4/node_modules/c12/dist/index.mjs
174
+ async function ke(e) {
175
+ let t = e.env ?? process.env, n = await Ae({
176
+ cwd: e.cwd,
177
+ fileName: e.fileName ?? ".env",
178
+ env: t,
179
+ interpolate: e.interpolate ?? !0,
180
+ expandFileReferences: e.expandFileReferences ?? !1,
181
+ parse: e.parse
182
+ }), r = Le(t);
183
+ for (let e in n) e.startsWith("_") || (t[e] === void 0 || r.has(e)) && (t[e] = n[e]);
184
+ return n;
185
+ }
186
+ async function Ae(e) {
187
+ let n = Object.create(null), r = t(e.cwd || "."), i = e.fileName || ".env", a = typeof i == "string" ? [i] : i, o = Le(e.env || {});
188
+ Object.assign(n, e.env);
189
+ for (let i of a) {
190
+ let a = t(r, i);
191
+ if (!v(a, { throwIfNoEntry: !1 })?.isFile()) continue;
192
+ let s = await je(a, e.parse);
193
+ for (let e in s) e in n && !o.has(e) || (n[e] = s[e], o.add(e));
194
+ }
195
+ if (e.expandFileReferences) {
196
+ for (let e in n) if (e.endsWith("_FILE")) {
197
+ let t = e.slice(0, -5);
198
+ if (n[t] === void 0) {
199
+ let r = n[e];
200
+ r && v(r, { throwIfNoEntry: !1 })?.isFile() && (n[t] = g(r, "utf8").trim(), o.add(t));
201
+ }
202
+ }
203
+ }
204
+ return e.interpolate && Me(n), n;
205
+ }
206
+ var R = ee.parseEnv;
207
+ async function je(e, t) {
208
+ let n = g(e, "utf8");
209
+ if (t) return t(n);
210
+ if (!R) try {
211
+ let e = await import("./chunks/__vite-optional-peer-dep_dotenv_c12-CxKvRg9-.js");
212
+ R = (t) => e.parse(t);
213
+ } catch {
214
+ 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.");
215
+ }
216
+ return R(n);
217
+ }
218
+ function Me(e, t = {}, n = (e) => e) {
219
+ function r(n) {
220
+ return t[n] === void 0 ? e[n] : t[n];
221
+ }
222
+ function i(e, t = []) {
223
+ if (typeof e != "string") return e;
224
+ let a = "", o = 0;
225
+ for (; o < e.length;) {
226
+ let n = e[o];
227
+ if (n === "\\" && e[o + 1] === "$") {
228
+ a += "$", o += 2;
229
+ continue;
230
+ }
231
+ let s = n === "$" ? Fe(e, o) : void 0;
232
+ if (!s) {
233
+ a += n, o++;
234
+ continue;
235
+ }
236
+ if (t.includes(s.key)) {
237
+ if (s.defaultValue !== void 0) {
238
+ a += i(s.defaultValue, t), o = s.end;
239
+ continue;
240
+ }
241
+ return console.warn(`Please avoid recursive environment variables ( loop: ${t.join(" > ")} > ${s.key} )`), "";
242
+ }
243
+ let c = i(r(s.key), [...t, s.key]);
244
+ s.defaultValue !== void 0 && (c === void 0 || s.operator === ":-" && c === "") && (c = i(s.defaultValue, t)), a += c === void 0 ? e.slice(o, s.end) : c, o = s.end;
245
+ }
246
+ return n(a);
247
+ }
248
+ for (let t in e) e[t] = i(r(t));
249
+ }
250
+ var Ne = /\w+/y, Pe = /[\w:]+/y;
251
+ function Fe(e, t) {
252
+ let n = t + 1, r = e[n] === "{";
253
+ r && n++;
254
+ let i = r ? Pe : Ne;
255
+ i.lastIndex = n;
256
+ let a = i.exec(e);
257
+ if (!a) return;
258
+ let o = a[0];
259
+ if (n = i.lastIndex, !r) return {
260
+ key: o,
261
+ end: n
262
+ };
263
+ if (e[n] === "}") return {
264
+ key: o,
265
+ end: n + 1
266
+ };
267
+ if (e[n] === "-") {
268
+ let t = "-";
269
+ o.endsWith(":") && (o = o.slice(0, -1), t = ":-");
270
+ let r = o ? Ie(e, n + 1) : void 0;
271
+ return r ? {
272
+ key: o,
273
+ operator: t,
274
+ defaultValue: r.value,
275
+ end: r.end
276
+ } : void 0;
277
+ }
278
+ return {
279
+ key: o,
280
+ end: n
281
+ };
282
+ }
283
+ function Ie(e, t) {
284
+ let n = "", r = 1;
285
+ for (let i = t; i < e.length; i++) {
286
+ let t = e[i];
287
+ if (t === "\\" && i + 1 < e.length) {
288
+ let r = e[i + 1];
289
+ n += r === "{" || r === "}" ? r : t + r, i++;
290
+ continue;
291
+ }
292
+ if (t === "$" && e[i + 1] === "{") {
293
+ r++, n += "${", i++;
294
+ continue;
295
+ }
296
+ if (t === "{" && r++, t === "}" && (r--, r === 0)) return {
297
+ value: n,
298
+ end: i + 1
299
+ };
300
+ n += t;
301
+ }
302
+ }
303
+ function Le(e) {
304
+ let t = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
305
+ return t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e);
306
+ }
307
+ var Re = (e) => e?.replace(/\\/g, "/"), ze = 0, Be = {
308
+ ".json": () => JSON.parse,
309
+ ".yaml": () => import("./chunks/yaml-N2dF3WHm.js").then((e) => e.parseYAML),
310
+ ".yml": () => import("./chunks/yaml-N2dF3WHm.js").then((e) => e.parseYAML),
311
+ ".jsonc": () => import("./chunks/jsonc-BDHXk_1o.js").then((e) => e.n).then((e) => (t) => e.parseJSONC(t, { allowTrailingComma: !0 })),
312
+ ".json5": () => import("./chunks/json5-feUuPtTt.js").then((e) => e.parseJSON5),
313
+ ".toml": () => import("./chunks/toml-BERh2MAo.js").then((e) => e.parseTOML)
314
+ }, Ve = Object.freeze([
315
+ ".js",
316
+ ".ts",
317
+ ".mjs",
318
+ ".cjs",
319
+ ".mts",
320
+ ".cts",
321
+ ".json",
322
+ ".jsonc",
323
+ ".json5",
324
+ ".yaml",
325
+ ".yml",
326
+ ".toml"
327
+ ]);
328
+ async function He(e) {
329
+ 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 = {
330
+ extendKey: "extends",
331
+ ...e.extend
332
+ });
333
+ let n = e.merger || I, r = {
334
+ config: {},
335
+ cwd: e.cwd,
336
+ configFile: t(e.cwd, e.configFile),
337
+ layers: [],
338
+ _configFile: void 0
339
+ }, i = {
340
+ overrides: e.overrides,
341
+ main: void 0,
342
+ rc: void 0,
343
+ packageJson: void 0,
344
+ defaultConfig: e.defaultConfig
345
+ };
346
+ e.dotenv && await ke({
347
+ cwd: e.cwd,
348
+ ...e.dotenv === !0 ? {} : e.dotenv
349
+ });
350
+ let a = await z(".", e);
351
+ if (a.configFile && (i.main = a.config, r.configFile = a.configFile, r._configFile = a._configFile), a.meta && (r.meta = a.meta), e.rcFile) {
352
+ let t = [];
353
+ if (t.push(L({
354
+ name: e.rcFile,
355
+ dir: e.cwd
356
+ })), e.globalRc) {
357
+ let { findWorkspaceDir: n } = await import("./chunks/dist-Bp_FYhnk.js"), r = await n(e.cwd).catch(() => {});
358
+ r && t.push(L({
359
+ name: e.rcFile,
360
+ dir: r
361
+ })), t.push(Oe({ name: e.rcFile })), t.push(L({
362
+ name: e.rcFile,
363
+ dir: k()
364
+ }));
365
+ }
366
+ i.rc = n({}, ...t);
367
+ }
368
+ if (e.packageJson) {
369
+ let t = (Array.isArray(e.packageJson) ? e.packageJson : [typeof e.packageJson == "string" ? e.packageJson : e.name]).filter((e) => e && typeof e == "string"), { readPackageJSON: r } = await import("./chunks/dist-Bp_FYhnk.js"), a = await r(e.cwd).catch(() => {});
370
+ i.packageJson = n({}, ...t.map((e) => a?.[e]));
371
+ }
372
+ let o = {};
373
+ for (let e in i) {
374
+ let t = i[e];
375
+ o[e] = await (typeof t == "function" ? t({
376
+ configs: o,
377
+ rawConfigs: i
378
+ }) : t);
379
+ }
380
+ 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 Ue(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 = [...[
381
+ o.overrides && {
382
+ config: o.overrides,
383
+ configFile: void 0,
384
+ cwd: void 0
385
+ },
386
+ {
387
+ config: o.main,
388
+ configFile: e.configFile,
389
+ cwd: e.cwd
390
+ },
391
+ o.rc && {
392
+ config: o.rc,
393
+ configFile: e.rcFile
394
+ },
395
+ o.packageJson && {
396
+ config: o.packageJson,
397
+ configFile: "package.json"
398
+ }
399
+ ].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];
400
+ if (e.configFileRequired && !r._configFile) throw Error(`Required config (${r.configFile}) cannot be resolved.`);
401
+ return e.schema != null && (r.config = await Ke(r.config, e.schema)), r;
402
+ }
403
+ async function Ue(e, t) {
404
+ if (e._layers = e._layers || [], !t.extend) return;
405
+ let n = t.extend.extendKey;
406
+ typeof n == "string" && (n = [n]);
407
+ let r = [];
408
+ for (let t of n) r.push(...(Array.isArray(e[t]) ? e[t] : [e[t]]).filter(Boolean)), delete e[t];
409
+ for (let n of r) {
410
+ let r = n, i = {};
411
+ if (n.source && (i = n.options || {}, n = n.source), Array.isArray(n) && (i = n[1] || {}, n = n[0]), typeof n != "string") {
412
+ console.warn(`Cannot extend config from \`${JSON.stringify(r)}\` in ${t.cwd}`);
413
+ continue;
414
+ }
415
+ let a = await z(n, t, i);
416
+ if (!a.config) {
417
+ console.warn(`Cannot extend config from \`${n}\` in ${t.cwd}`);
418
+ continue;
419
+ }
420
+ await Ue(a.config, {
421
+ ...t,
422
+ cwd: a.cwd
423
+ }), e._layers.push(a), a.config._layers && (e._layers.push(...a.config._layers), delete a.config._layers);
424
+ }
425
+ }
426
+ var We = [
427
+ "gh:",
428
+ "github:",
429
+ "gitlab:",
430
+ "bitbucket:",
431
+ "https://",
432
+ "http://"
433
+ ], Ge = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
434
+ async function z(e, o, s = {}) {
435
+ if (o.resolve) {
436
+ let t = await o.resolve(e, o);
437
+ if (t) return t;
438
+ }
439
+ let c = o.merger || I, l = Object.keys(s.giget?.providers || {}).map((e) => `${e}:`), u = l.length > 0 ? [.../* @__PURE__ */ new Set([...l, ...We])] : We;
440
+ if (o.giget !== !1 && u.some((t) => e.startsWith(t))) {
441
+ let { downloadTemplate: n } = await import("./chunks/__vite-optional-peer-dep_giget_c12-BYcrHYBM.js").catch((t) => {
442
+ throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``, { cause: t });
443
+ }), { 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);
444
+ u = r(f) === ".c12" ? i(f, l) : m(d) ? i(d, ".c12", l) : process.env.XDG_CACHE_HOME ? t(process.env.XDG_CACHE_HOME, "c12", l) : t(k(), ".cache/c12", l);
445
+ let p = s.install ? I(s.install === !0 ? {} : s.install, { ignoreWorkspace: !0 }) : !1;
446
+ m(u) && !p && await E(u, { recursive: !0 }), e = (await n(e, {
447
+ dir: u,
448
+ install: p,
449
+ force: !!p,
450
+ auth: s.auth,
451
+ ...o.giget,
452
+ ...s.giget
453
+ })).dir;
454
+ }
455
+ Ge.test(e) && (e = B(e, o) || e);
456
+ let d = n(e), f = qe(t(o.cwd, e)) ?? (!d || d === r(e)), p = t(o.cwd, f ? e : a(e));
457
+ f && (e = o.configFile);
458
+ let h = {
459
+ config: void 0,
460
+ configFile: void 0,
461
+ cwd: p,
462
+ source: e,
463
+ sourceOptions: s
464
+ };
465
+ if (h.configFile = B(t(p, e), o) || B(t(p, ".config", e.replace(/\.config$/, "")), o) || B(t(p, ".config", e), o) || e, !m(h.configFile)) return h;
466
+ h._configFile = h.configFile;
467
+ let g = n(h.configFile) || "";
468
+ if (g in Be) h.config = (await Be[g]())(await w(h.configFile, "utf8"));
469
+ else {
470
+ let e = o.resolveModule || ((e) => e.default || e);
471
+ if (o.import) h.config = e(await o.import(h.configFile));
472
+ else {
473
+ let t = ne(h.configFile);
474
+ t.search = `_${++ze}`, h.config = await import(t.href).then(e, async (t) => {
475
+ let { createJiti: n } = await import("./chunks/__vite-optional-peer-dep_jiti_c12-DZVJNj6v.js").catch(() => {
476
+ throw Error(`Failed to load config file \`${h.configFile}\`: ${t?.message}. Hint install \`jiti\` for compatibility.`, { cause: t });
477
+ }), r = n(i(o.cwd || ".", o.configFile || "/"), {
478
+ interopDefault: !0,
479
+ moduleCache: !1,
480
+ extensions: [...Ve],
481
+ ...o.jitiOptions
482
+ });
483
+ return o.import = (e) => r.import(e), e(await o.import(h.configFile));
484
+ });
485
+ }
486
+ }
487
+ 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 });
488
+ 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);
489
+ 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 = Re(h.configFile), h.source = Re(h.source), h;
490
+ }
491
+ async function Ke(e, t) {
492
+ if (typeof t?.["~standard"]?.validate != "function") throw TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");
493
+ let n = await t["~standard"].validate(e);
494
+ if (n.issues) {
495
+ let e = n.issues.map((e) => {
496
+ let t = e.path?.map((e) => String(typeof e == "object" ? e.key : e)).join(".");
497
+ return ` - ${t ? `${t}: ` : ""}${e.message}`;
498
+ });
499
+ throw Error(`Config validation failed (${t["~standard"].vendor}):\n${e.join("\n")}`, { cause: n.issues });
500
+ }
501
+ return n.value;
502
+ }
503
+ function B(e, t) {
504
+ let n = s(e, {
505
+ try: !0,
506
+ from: ne(i(t.cwd || ".", t.configFile || "/")),
507
+ suffixes: ["", "/index"],
508
+ extensions: Ve,
509
+ cache: !1
510
+ });
511
+ return n ? o(n) : void 0;
512
+ }
513
+ function qe(e) {
514
+ try {
515
+ return v(e).isDirectory();
516
+ } catch {
517
+ return null;
518
+ }
519
+ }
520
+ //#endregion
15
521
  //#region src/error.mts
16
- var O = class extends Error {
522
+ var V = class extends Error {
17
523
  code;
524
+ path;
18
525
  name = "IncaError";
19
- constructor(e, t) {
20
- super(t), this.code = e;
526
+ constructor(e, t, n) {
527
+ super(t), this.code = e, this.path = n;
21
528
  }
22
- }, re = {
529
+ }, Je = {
23
530
  name: "inca",
24
531
  packageJson: "inca",
25
532
  rcFile: !1,
26
533
  globalRc: !1,
27
534
  giget: !1,
28
535
  extend: !1
29
- }, ie = /[/\\:*?"<>|\0]/;
30
- function ae(e) {
31
- return e === e.trim() && e !== "" && e !== "." && e !== ".." && !ie.test(e);
536
+ }, Ye = /[/\\:*?"<>|\0]/;
537
+ function Xe(e) {
538
+ return e === e.trim() && e !== "" && e !== "." && e !== ".." && !Ye.test(e);
32
539
  }
33
- function k(e) {
34
- if (!(typeof e == "string" && ae(e))) throw new O("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 \`/\\:*?"<>|\``);
540
+ function H(e) {
541
+ if (!(typeof e == "string" && Xe(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 \`/\\:*?"<>|\``);
35
542
  }
36
- var oe = process.platform === "darwin" || process.platform === "win32";
37
- function se(e, t) {
38
- let n = (e) => oe ? e.toLowerCase() : e, r = a.relative(n(e), n(t));
39
- return r === "" || r !== ".." && !r.startsWith(`..${a.sep}`) && !a.isAbsolute(r);
543
+ var Ze = process.platform === "darwin" || process.platform === "win32";
544
+ function Qe(e, t) {
545
+ let n = (e) => Ze ? e.toLowerCase() : e, r = f.relative(n(e), n(t));
546
+ return r === "" || r !== ".." && !r.startsWith(`..${f.sep}`) && !f.isAbsolute(r);
40
547
  }
41
- function A(e) {
42
- let t = a.resolve(e), n = t;
43
- for (let e; !s(n, { throwIfNoEntry: !1 }) && (e = a.dirname(n)) !== n;) n = e;
44
- return a.join(c.native(n), a.relative(n, t));
548
+ function U(e) {
549
+ let t = f.resolve(e), n = t;
550
+ for (let e; !h(n, { throwIfNoEntry: !1 }) && (e = f.dirname(n)) !== n;) n = e;
551
+ return f.join(_.native(n), f.relative(n, t));
45
552
  }
46
- function j(e, t, n) {
47
- let r = a.resolve(e, t), i;
553
+ function W(e, t, n) {
554
+ let r = f.resolve(e, t), i;
48
555
  try {
49
- let t = A(r);
556
+ let t = U(r);
50
557
  i = [
51
558
  e,
52
- a.join(e, "src"),
53
- a.join(e, "node_modules"),
559
+ f.join(e, "src"),
560
+ f.join(e, "node_modules"),
54
561
  ...n ? [n] : []
55
- ].some((e) => se(t, A(e)));
562
+ ].some((e) => Qe(t, U(e)));
56
563
  } catch {
57
564
  i = !0;
58
565
  }
59
- if (i) throw new O("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"`);
566
+ 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"`);
567
+ }
568
+ function $e(e, t, n) {
569
+ let r = f.resolve(e, t ?? d.outDir);
570
+ return W(e, r, n), r;
60
571
  }
61
- function M(e, t, n) {
62
- let r = a.resolve(e, t ?? i.outDir);
63
- return j(e, r, n), r;
572
+ function et(e, t) {
573
+ try {
574
+ return JSON.parse(e);
575
+ } catch (e) {
576
+ throw new V("ERR_INCA_PACKAGE_JSON_INVALID", `${t} holds malformed JSON: ${e.message}`, t);
577
+ }
64
578
  }
65
- async function N(e) {
66
- let { config: t, layers: r } = await n({
579
+ async function G(e) {
580
+ let { config: t, layers: n } = await He({
67
581
  cwd: e,
68
- ...re
69
- }), i = r?.find((e) => e.configFile === "package.json");
582
+ ...Je
583
+ }), r = n?.find((e) => e.configFile === "package.json");
70
584
  return {
71
585
  config: t,
72
- usedPackageJsonKey: Object.keys(i?.config ?? {}).length > 0
586
+ usedPackageJsonKey: Object.keys(r?.config ?? {}).length > 0
73
587
  };
74
588
  }
75
- async function P(e) {
76
- let { config: t } = await N(e), n = t.entry ? a.resolve(e, t.entry) : void 0;
589
+ async function tt(e) {
590
+ let { config: t } = await G(e), n = t.entry ? f.resolve(e, t.entry) : void 0;
77
591
  return {
78
592
  entry: n,
79
- outDir: M(e, t.outDir, n)
593
+ outDir: $e(e, t.outDir, n)
80
594
  };
81
595
  }
82
- async function ce(e) {
83
- let n = a.join(e, "package.json"), s;
596
+ async function nt(e) {
597
+ let t = f.join(e, "package.json"), n;
84
598
  try {
85
- s = await m(n, "utf8");
599
+ n = await w(t, "utf8");
86
600
  } catch {
87
- throw new O("ERR_INCA_PACKAGE_JSON_NOT_FOUND", `no package.json found at ${n}`);
601
+ throw new V("ERR_INCA_PACKAGE_JSON_NOT_FOUND", `no package.json found at ${t}`);
88
602
  }
89
- let c = JSON.parse(s), { config: l, usedPackageJsonKey: u } = await N(e), d = l.productName ?? r(c.name);
90
- if (!d) throw new O("ERR_INCA_PRODUCT_NAME_MISSING", `${n} needs a "name", or "productName" in inca.config.ts`);
91
- k(d);
92
- let f = l.version ?? c.version ?? i.version, p = l.identifier ?? t(d), h;
93
- if (l.icon && (h = a.resolve(e, l.icon), !o(h))) throw new O("ERR_INCA_ICON_NOT_FOUND", `"icon" points to ${h}, which doesn't exist`);
94
- let g = l.entry ? a.resolve(e, l.entry) : void 0, _ = M(e, l.outDir, g);
603
+ let r = et(n, t), { config: i, usedPackageJsonKey: a } = await G(e), o = i.productName ?? u(r.name);
604
+ if (!o) throw new V("ERR_INCA_PRODUCT_NAME_MISSING", `${t} needs a "name", or "productName" in inca.config.ts`);
605
+ H(o);
606
+ let s = i.version ?? r.version ?? d.version, c = i.identifier ?? l(o), p;
607
+ if (i.icon && (p = f.resolve(e, i.icon), !m(p))) throw new V("ERR_INCA_ICON_NOT_FOUND", `"icon" points to ${p}, which doesn't exist`, p);
608
+ let h = i.entry ? f.resolve(e, i.entry) : void 0, g = $e(e, i.outDir, h);
95
609
  return {
96
- productName: d,
97
- identifier: p,
98
- identifierIsDefault: l.identifier === void 0,
99
- version: f,
100
- icon: h,
101
- window: l.window,
102
- entry: g,
103
- outDir: _,
104
- usedPackageJsonKey: u
610
+ productName: o,
611
+ identifier: c,
612
+ identifierIsDefault: i.identifier === void 0,
613
+ version: s,
614
+ icon: p,
615
+ window: i.window,
616
+ entry: h,
617
+ outDir: g,
618
+ usedPackageJsonKey: a
105
619
  };
106
620
  }
107
- function le(e) {
621
+ function rt(e) {
108
622
  return {
109
623
  name: e.productName,
110
624
  identifier: e.identifier,
111
625
  window: e.window
112
626
  };
113
627
  }
114
- async function ue(e) {
115
- let { config: n } = await N(e), i = {};
116
- try {
117
- i = JSON.parse(await m(a.join(e, "package.json"), "utf8"));
118
- } catch {}
119
- let o = n.productName ?? r(i.name);
120
- o && k(o);
121
- let s = {
122
- name: o,
123
- identifier: n.identifier ?? (o ? t(o) : void 0),
124
- window: n.window
628
+ async function it(e) {
629
+ let { config: t } = await G(e), n = f.join(e, "package.json"), r = await w(n, "utf8").catch(() => void 0), i = r === void 0 ? {} : et(r, n), a = t.productName ?? u(i.name);
630
+ a && H(a);
631
+ let o = {
632
+ name: a,
633
+ identifier: t.identifier ?? (a ? l(a) : void 0),
634
+ window: t.window
125
635
  };
126
- return Object.values(s).some((e) => e !== void 0) ? s : void 0;
636
+ return Object.values(o).some((e) => e !== void 0) ? o : void 0;
127
637
  }
128
638
  //#endregion
129
639
  //#region src/adapter/vite/captureOutput.mts
130
- function de(e, t, n) {
640
+ function at(e, t, n) {
131
641
  return {
132
642
  outDir: e,
133
- entryFile: a.join(e, t.entryFile),
643
+ entryFile: f.join(e, t.entryFile),
134
644
  files: t.files,
135
645
  changed: n
136
646
  };
137
647
  }
138
- function fe(e) {
648
+ function ot(e, t) {
139
649
  return {
140
650
  name: "inca:capture-output",
141
- writeBundle(t, n) {
142
- let r = Object.keys(n), i = Object.values(n).find((e) => e.type === "chunk" && e.isEntry);
143
- if (!i) throw new O("ERR_INCA_BUILD_NO_ENTRY_CHUNK", "build produced no entry chunk");
144
- e({
145
- entryFile: i.fileName,
146
- files: r
651
+ writeBundle(n, r) {
652
+ let i = Object.keys(r), a = Object.values(r).find((e) => e.type === "chunk" && e.isEntry);
653
+ if (!a) throw new e.IncaError("ERR_INCA_BUILD_NO_ENTRY_CHUNK", "build produced no entry chunk");
654
+ t({
655
+ entryFile: a.fileName,
656
+ files: i
147
657
  });
148
658
  }
149
659
  };
150
660
  }
151
661
  //#endregion
152
662
  //#region src/adapter/vite/emitConfig.mts
153
- var F = "inca.json";
154
- function I(e) {
663
+ var st = "inca.json";
664
+ function ct(e) {
155
665
  let t = JSON.stringify(e, void 0, 2);
156
666
  if (t !== void 0 && t !== "{}") return `${t}\n`;
157
667
  }
158
- function pe(e) {
159
- let t = I(e);
668
+ function lt(e) {
669
+ let t = ct(e);
160
670
  return {
161
671
  name: "inca:emit-config",
162
672
  generateBundle() {
163
673
  t && this.emitFile({
164
674
  type: "asset",
165
- fileName: F,
675
+ fileName: st,
166
676
  source: t
167
677
  });
168
678
  }
@@ -170,8 +680,8 @@ function pe(e) {
170
680
  }
171
681
  //#endregion
172
682
  //#region src/adapter/vite/logger.mts
173
- var me = "Build failed with ", he = "Pre-transform error";
174
- function L(e, t, n = !1) {
683
+ var ut = "Build failed with ", dt = "Pre-transform error";
684
+ function ft(e, t, n = !1) {
175
685
  let r = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new Set(), a = {
176
686
  hasWarned: !1,
177
687
  info(t) {
@@ -184,7 +694,7 @@ function L(e, t, n = !1) {
184
694
  i.has(e) || (i.add(e), a.warn(e));
185
695
  },
186
696
  error(e, n) {
187
- a.hasWarned = !0, n?.error && r.add(n.error), !e.includes(me) && (e.includes(he) || t.write(`${e.replace(/\n\s+at .*/g, "")}\n`));
697
+ a.hasWarned = !0, n?.error && r.add(n.error), !e.includes(ut) && (e.includes(dt) || t.write(`${e.replace(/\n\s+at .*/g, "")}\n`));
188
698
  },
189
699
  clearScreen() {},
190
700
  hasErrorLogged(e) {
@@ -195,7 +705,7 @@ function L(e, t, n = !1) {
195
705
  }
196
706
  //#endregion
197
707
  //#region src/adapter/vite/unsupported.mts
198
- var ge = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, _e = [{
708
+ var pt = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, mt = [{
199
709
  code: "ERR_INCA_UNSUPPORTED_STYLE",
200
710
  name: "a <style> block",
201
711
  matches: (e) => e.includes("vue&type=style"),
@@ -203,52 +713,52 @@ var ge = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, _e = [{
203
713
  }, {
204
714
  code: "ERR_INCA_UNSUPPORTED_STYLESHEET",
205
715
  name: "a stylesheet import",
206
- matches: (e) => ge.test(e),
716
+ matches: (e) => pt.test(e),
207
717
  hint: "the renderer applies no stylesheet — use a :style binding instead"
208
718
  }];
209
- function R(e = _e) {
719
+ function ht(e, t = mt) {
210
720
  return {
211
721
  name: "inca:reject-unsupported",
212
722
  enforce: "pre",
213
- transform(t, n) {
214
- let r = e.find((e) => e.matches(n));
215
- if (!r) return null;
216
- let i = a.relative(process.cwd(), n.split("?")[0] ?? n);
217
- throw new O(r.code, `${r.code}: ${i} uses ${r.name}, unsupported for now: ${r.hint}`);
723
+ transform(n, r) {
724
+ let i = t.find((e) => e.matches(r));
725
+ if (!i) return null;
726
+ let a = f.relative(process.cwd(), r.split("?")[0] ?? r);
727
+ throw new e.IncaError(i.code, `${i.code}: ${a} uses ${i.name}, unsupported for now: ${i.hint}`);
218
728
  }
219
729
  };
220
730
  }
221
731
  //#endregion
222
732
  //#region src/adapter/vite/config.mts
223
- var ve = "bundle.js";
224
- function z({ entry: e, outDir: t, mode: n, watch: r, onOutput: i, stdout: o, stderr: s, quiet: c, runtimeConfig: l }) {
733
+ var gt = "bundle.js";
734
+ function _t({ core: e, runtimeModuleName: t, entry: n, outDir: r, mode: i, watch: a, onOutput: o, stdout: s, stderr: c, quiet: l, runtimeConfig: u }) {
225
735
  return {
226
736
  configFile: !1,
227
- root: a.dirname(e),
228
- mode: n,
737
+ root: f.dirname(n),
738
+ mode: i,
229
739
  clearScreen: !1,
230
- logLevel: c ? "silent" : "info",
231
- customLogger: L(o, s),
232
- define: { "process.env.NODE_ENV": JSON.stringify(n) },
740
+ logLevel: l ? "silent" : "info",
741
+ customLogger: ft(s, c),
742
+ define: { "process.env.NODE_ENV": JSON.stringify(i) },
233
743
  plugins: [
234
- w({ template: { compilerOptions: {
235
- runtimeModuleName: "@vue/runtime-core",
744
+ oe({ template: { compilerOptions: {
745
+ runtimeModuleName: t,
236
746
  hoistStatic: !1
237
747
  } } }),
238
- R(),
239
- pe(l),
240
- fe(i)
748
+ ht(e),
749
+ lt(u),
750
+ ot(e, o)
241
751
  ],
242
752
  build: {
243
753
  lib: {
244
- entry: e,
754
+ entry: n,
245
755
  formats: ["es"],
246
- fileName: () => ve
756
+ fileName: () => gt
247
757
  },
248
- outDir: t,
249
- emptyOutDir: n === "production",
250
- minify: n === "production",
251
- watch: r ? {} : void 0,
758
+ outDir: r,
759
+ emptyOutDir: i === "production",
760
+ minify: i === "production",
761
+ watch: a ? {} : void 0,
252
762
  rolldownOptions: { output: {
253
763
  chunkFileNames: "chunks/[name]-[hash].js",
254
764
  assetFileNames: "assets/[name]-[hash][extname]"
@@ -258,65 +768,74 @@ function z({ entry: e, outDir: t, mode: n, watch: r, onOutput: i, stdout: o, std
258
768
  }
259
769
  //#endregion
260
770
  //#region src/adapter/vite/build.mts
261
- async function ye({ entry: e, outDir: t, runtimeConfig: n, stdout: r = process.stdout, stderr: i = process.stderr, quiet: a = !1 }) {
262
- let o;
263
- if (await x(z({
264
- entry: e,
265
- outDir: t,
266
- runtimeConfig: n,
771
+ async function vt(e, t, { entry: n, outDir: r, runtimeConfig: i, stdout: a = process.stdout, stderr: o = process.stderr, quiet: s = !1 }) {
772
+ let c;
773
+ if (await A(_t({
774
+ core: e,
775
+ runtimeModuleName: t,
776
+ entry: n,
777
+ outDir: r,
778
+ runtimeConfig: i,
267
779
  mode: "production",
268
780
  watch: !1,
269
- stdout: r,
270
- stderr: i,
271
- quiet: a,
781
+ stdout: a,
782
+ stderr: o,
783
+ quiet: s,
272
784
  onOutput: (e) => {
273
- o = de(t, e);
785
+ c = at(r, e);
274
786
  }
275
- })), !o) throw new O("ERR_INCA_BUILD_NO_OUTPUT", "build produced no output");
276
- return o;
787
+ })), !c) throw new e.IncaError("ERR_INCA_BUILD_NO_OUTPUT", "build produced no output");
788
+ return c;
277
789
  }
278
790
  //#endregion
279
791
  //#region src/adapter/vite/hmr.mts
280
- function B(e) {
281
- return a.join(e, "node_modules/.inca/hmr");
792
+ function yt(e, t) {
793
+ let n = ie(t, [], !1), r = [t.stack, n].filter((e) => e).join("\n");
794
+ return {
795
+ ...e.bundlerFault(t.message),
796
+ stack: r || null
797
+ };
282
798
  }
283
- function be() {
284
- let e = a.dirname(y(import.meta.url));
285
- for (; !o(a.join(e, "package.json"));) {
286
- let t = a.dirname(e);
799
+ function bt(e) {
800
+ return f.join(e, "node_modules/.inca/hmr");
801
+ }
802
+ function xt() {
803
+ let e = f.dirname(te(import.meta.url));
804
+ for (; !m(f.join(e, "package.json"));) {
805
+ let t = f.dirname(e);
287
806
  if (t === e) throw Error("could not locate @incajs/cli's own package.json");
288
807
  e = t;
289
808
  }
290
- return a.join(e, "dist/hmr-runtime.js");
809
+ return f.join(e, "dist/hmr-runtime.js");
291
810
  }
292
- function xe(e, t) {
293
- let n = a.relative(e, t).split(a.sep).join("/");
811
+ function St(e, t) {
812
+ let n = f.relative(e, t).split(f.sep).join("/");
294
813
  return n.startsWith(".") ? n : `./${n}`;
295
814
  }
296
- async function Se(e, t, n) {
297
- let r = B(e);
298
- await p(r, { recursive: !0 });
299
- let i = a.join(r, "entry.js"), o = xe(r, n ?? be()), s = t.split(a.sep).join("/");
300
- return await _(i, `import { start } from ${JSON.stringify(o)};\nstart(${JSON.stringify(s)}).catch((err) => console.error(err));\n`), i;
815
+ async function Ct(e, t, n) {
816
+ let r = bt(e);
817
+ await C(r, { recursive: !0 });
818
+ let i = f.join(r, "entry.js"), a = St(r, n ?? xt()), o = t.split(f.sep).join("/");
819
+ return await D(i, `import { start } from ${JSON.stringify(a)};\nstart(${JSON.stringify(o)}).catch((err) => console.error(err));\n`), i;
301
820
  }
302
- function Ce(e) {
821
+ function wt(e) {
303
822
  if (e.type === "error") return e.err;
304
823
  if (e.type === "custom" && e.event === "vite:invoke") return e.data?.data?.error;
305
824
  }
306
- function we(e) {
825
+ function Tt(e) {
307
826
  if (e.type !== "custom" || e.event !== "vite:invoke") return !1;
308
827
  let t = e.data;
309
828
  return t.name === "fetchModule" && !t.data?.error;
310
829
  }
311
- function Te(e, t, n, r, i) {
830
+ function Et(e, t, n, r, i) {
312
831
  let a = /* @__PURE__ */ new Map(), o = { send: s };
313
832
  function s(a) {
314
833
  if (a.type === "full-reload") {
315
834
  t();
316
835
  return;
317
836
  }
318
- let o = Ce(a);
319
- o ? (n(o), i.current = void 0) : we(a) && i.current && (r({
837
+ let o = wt(a);
838
+ o ? (n(o), i.current = void 0) : Tt(a) && i.current && (r({
320
839
  file: i.current.file,
321
840
  took: Date.now() - i.current.at
322
841
  }), i.current = void 0), e(a);
@@ -338,7 +857,7 @@ function Te(e, t, n, r, i) {
338
857
  }
339
858
  };
340
859
  }
341
- function Ee() {
860
+ function Dt() {
342
861
  let e = "\0inca:vite-client-shim";
343
862
  return {
344
863
  name: "inca:shim-vite-client",
@@ -351,7 +870,7 @@ function Ee() {
351
870
  }
352
871
  };
353
872
  }
354
- function De(e) {
873
+ function Ot(e) {
355
874
  return {
356
875
  name: "inca:file-changed",
357
876
  hotUpdate(t) {
@@ -366,16 +885,16 @@ function De(e) {
366
885
  }
367
886
  };
368
887
  }
369
- async function Oe({ entry: e, cwd: t, runtimeConfig: n, runtimePath: r, stdout: i = process.stdout, stderr: o = process.stderr, quiet: s = !1, notify: c, reload: l, onError: u, onUpdate: d = () => {} }) {
370
- let f = await Se(t, e, r), p = I(n);
371
- p && await _(a.join(B(t), F), p);
372
- let m = { current: void 0 }, { channel: h, dispatch: g } = Te(c, l, u, d, m), v = await C({
888
+ async function kt(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: p = () => {} }) {
889
+ let m = await Ct(r, n, a), h = ct(i), g = f.join(bt(r), st);
890
+ h ? await D(g, h) : await E(g, { force: !0 });
891
+ let _ = { current: void 0 }, { channel: v, dispatch: y } = Et(l, u, (t) => d(yt(e, t)), p, _), b = await ae({
373
892
  configFile: !1,
374
- root: a.dirname(e),
893
+ root: f.dirname(n),
375
894
  mode: "development",
376
895
  clearScreen: !1,
377
- logLevel: s ? "silent" : "info",
378
- customLogger: L(i, o, s),
896
+ logLevel: c ? "silent" : "info",
897
+ customLogger: ft(o, s, c),
379
898
  define: { "process.env.NODE_ENV": JSON.stringify("development") },
380
899
  server: {
381
900
  middlewareMode: !0,
@@ -386,71 +905,107 @@ async function Oe({ entry: e, cwd: t, runtimeConfig: n, runtimePath: r, stdout:
386
905
  consumer: "client",
387
906
  dev: {
388
907
  moduleRunnerTransform: !0,
389
- createEnvironment: (e, t) => new b(e, t, {
908
+ createEnvironment: (e, t) => new re(e, t, {
390
909
  hot: !0,
391
- transport: h
910
+ transport: v
392
911
  })
393
912
  }
394
913
  } },
395
914
  plugins: [
396
- w({ template: { compilerOptions: {
397
- runtimeModuleName: "@vue/runtime-core",
915
+ oe({ template: { compilerOptions: {
916
+ runtimeModuleName: t,
398
917
  hoistStatic: !1
399
918
  } } }),
400
- R(),
401
- Ee(),
402
- De(m)
919
+ ht(e),
920
+ Dt(),
921
+ Ot(_)
403
922
  ]
404
923
  });
405
924
  return {
406
- entryFile: f,
407
- dispatch: g,
408
- close: () => v.close()
925
+ entryFile: m,
926
+ dispatch: y,
927
+ close: () => b.close()
928
+ };
929
+ }
930
+ //#endregion
931
+ //#region src/adapter/vite/watch.mts
932
+ async function At(e, t, { onBuild: n, onError: r, stdout: i = process.stdout, stderr: a = process.stderr, quiet: o = !1, ...s }) {
933
+ let { outDir: c } = s, l, u = await A(_t({
934
+ core: e,
935
+ runtimeModuleName: t,
936
+ ...s,
937
+ watch: !0,
938
+ stdout: i,
939
+ stderr: a,
940
+ quiet: o,
941
+ onOutput: (e) => {
942
+ n(at(c, e, l)), l = void 0;
943
+ }
944
+ }));
945
+ return u.on("change", (e) => {
946
+ l ??= {
947
+ file: e,
948
+ at: Date.now()
949
+ };
950
+ }), u.on("event", (t) => {
951
+ if (t.code !== "ERROR") return;
952
+ l = void 0;
953
+ let { errors: n } = t.error;
954
+ r(e.bundlerFault(n?.[0]?.message ?? t.error.message));
955
+ }), { close: () => u.close() };
956
+ }
957
+ //#endregion
958
+ //#region src/adapter/vite/createBundler.mts
959
+ function jt(e, t) {
960
+ return {
961
+ watch: (n) => At(e, t, n),
962
+ build: (n) => vt(e, t, n),
963
+ hmr: (n) => kt(e, t, n)
409
964
  };
410
965
  }
411
966
  //#endregion
412
967
  //#region src/dev-client/hostBin.mts
413
- var V = "INCA_HOST_BIN";
414
- function H() {
968
+ var Mt = "INCA_HOST_BIN";
969
+ function Nt() {
415
970
  let e = process.platform === "darwin" || process.platform === "linux" ? process.platform : void 0, t = process.arch === "arm64" || process.arch === "x64" ? process.arch : void 0;
416
971
  return e && t ? `@incajs/host-${e}-${t}` : void 0;
417
972
  }
418
- function ke() {
419
- let e = H();
973
+ function Pt() {
974
+ let e = Nt();
420
975
  if (e) try {
421
- return T(import.meta.url).resolve(`${e}/bin/inca-host`);
976
+ return se(import.meta.url).resolve(`${e}/bin/inca-host`);
422
977
  } catch {
423
978
  return;
424
979
  }
425
980
  }
426
- function U() {
427
- let e = process.env[V];
981
+ function K() {
982
+ let e = process.env[Mt];
428
983
  if (e) return e;
429
- let t = ke();
984
+ let t = Pt();
430
985
  if (t) return t;
431
- let n = H();
432
- throw new O("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 ${V} isn't set to one`);
986
+ let n = Nt();
987
+ 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 ${Mt} isn't set to one`);
433
988
  }
434
- function W(e) {
435
- if (!l(e, { throwIfNoEntry: !1 })?.isFile()) throw new O("ERR_INCA_HOST_BIN_NOT_FOUND", `no host binary at ${e} — check that it was built and is executable`);
989
+ function q(e) {
990
+ if (!v(e, { throwIfNoEntry: !1 })?.isFile()) throw new V("ERR_INCA_HOST_BIN_NOT_FOUND", `no host binary at ${e} — check that it was built`);
436
991
  }
437
992
  //#endregion
438
993
  //#region src/dev-client/hostError.mts
439
- var G = class extends Error {
994
+ var Ft = class extends Error {
440
995
  code;
441
996
  hostStack;
442
997
  constructor(e, t, n = null) {
443
998
  super(e), this.code = t, this.hostStack = n, this.name = "HostError";
444
999
  }
445
1000
  };
446
- function Ae(e) {
1001
+ function It(e) {
447
1002
  return typeof e == "object" && !!e && e.jsonrpc === "2.0";
448
1003
  }
449
1004
  //#endregion
450
1005
  //#region src/dev-client/hostClient.mts
451
- var je = (e) => {
1006
+ var Lt = (e) => {
452
1007
  process.stderr.write(e.endsWith("\n") ? e : `${e}\n`);
453
- }, Me = -32e3, Ne = class {
1008
+ }, Rt = -32e3, zt = class {
454
1009
  #e;
455
1010
  #t;
456
1011
  #n = 1;
@@ -460,9 +1015,9 @@ var je = (e) => {
460
1015
  this.#e = e;
461
1016
  }
462
1017
  async start() {
463
- let e = this.#e.hostBin ?? U();
464
- W(e);
465
- let t = ee(e, ["--dev", this.#e.entryFile], {
1018
+ let e = this.#e.hostBin ?? K();
1019
+ q(e);
1020
+ let t = ce(e, ["--dev", this.#e.entryFile], {
466
1021
  stdio: [
467
1022
  "pipe",
468
1023
  "pipe",
@@ -471,10 +1026,10 @@ var je = (e) => {
471
1026
  env: this.#e.env
472
1027
  });
473
1028
  this.#t = t;
474
- let n = this.#e.onStderr ?? je;
1029
+ let n = this.#e.onStderr ?? Lt;
475
1030
  t.stderr.setEncoding("utf8"), t.stderr.on("data", (e) => n(e)), t.stdin.on("error", (e) => {
476
1031
  e.code !== "EPIPE" && n(`inca-host stdin: ${e.message}\n`);
477
- }), te.createInterface({ input: t.stdout }).on("line", (e) => {
1032
+ }), le.createInterface({ input: t.stdout }).on("line", (e) => {
478
1033
  this.#a(e, n);
479
1034
  }), t.on("exit", (e, t) => {
480
1035
  let n = /* @__PURE__ */ Error(`inca-host exited (code=${String(e)}, signal=${String(t)}) before answering`);
@@ -484,7 +1039,7 @@ var je = (e) => {
484
1039
  let r = !1;
485
1040
  t.on("error", (e) => {
486
1041
  r && n(`inca-host: ${e.message}\n`);
487
- }), await E(t, "spawn"), r = !0;
1042
+ }), await j(t, "spawn"), r = !0;
488
1043
  }
489
1044
  #a(e, t) {
490
1045
  let n;
@@ -494,7 +1049,7 @@ var je = (e) => {
494
1049
  t(`[stray stdout] ${e}`);
495
1050
  return;
496
1051
  }
497
- if (!Ae(n)) {
1052
+ if (!It(n)) {
498
1053
  t(`[stray stdout] ${e}`);
499
1054
  return;
500
1055
  }
@@ -505,14 +1060,14 @@ var je = (e) => {
505
1060
  if (n.id === null) {
506
1061
  if (!("error" in n)) return;
507
1062
  let { code: e, message: r, data: i } = n.error;
508
- e === Me ? this.#e.onAppError?.({
1063
+ e === Rt ? this.#e.onAppError?.({
509
1064
  message: r,
510
1065
  stack: i?.stack ?? null
511
1066
  }) : t(`[host error ${String(e)}] ${r}\n`);
512
1067
  return;
513
1068
  }
514
1069
  let r = this.#r.get(n.id);
515
- r && (this.#r.delete(n.id), "error" in n ? r.reject(new G(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
1070
+ r && (this.#r.delete(n.id), "error" in n ? r.reject(new Ft(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
516
1071
  }
517
1072
  #o(e, t, n) {
518
1073
  switch (e) {
@@ -535,7 +1090,7 @@ var je = (e) => {
535
1090
  }
536
1091
  }
537
1092
  async #s(e) {
538
- let t = E(e, "exit");
1093
+ let t = j(e, "exit");
539
1094
  e.kill(), await t;
540
1095
  }
541
1096
  async call(e, t, n) {
@@ -576,35 +1131,35 @@ var je = (e) => {
576
1131
  let t = this.#t;
577
1132
  if (!t || t.exitCode !== null || t.signalCode !== null) return;
578
1133
  this.#i = !0;
579
- let n = E(t, "exit");
580
- this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), ne(e, void 0, { ref: !1 }).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
1134
+ let n = j(t, "exit");
1135
+ this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), ue(e, void 0, { ref: !1 }).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
581
1136
  }
582
- }, Pe = "[inca]", Fe = new Intl.DateTimeFormat(void 0, {
1137
+ }, Bt = "[inca]", Vt = new Intl.DateTimeFormat(void 0, {
583
1138
  hour: "numeric",
584
1139
  minute: "numeric",
585
1140
  second: "numeric"
586
- });
587
- function K(e, t, n) {
588
- let r = v(["bold", n], Pe, { stream: e });
589
- return t.timestamp ? `${v("dim", Fe.format(/* @__PURE__ */ new Date()), { stream: e })} ${r}` : r;
1141
+ }), J = { timestamp: !0 };
1142
+ function Ht(e, t, n) {
1143
+ let r = O(["bold", n], Bt, { stream: e });
1144
+ return t.timestamp ? `${O("dim", Vt.format(/* @__PURE__ */ new Date()), { stream: e })} ${r}` : r;
590
1145
  }
591
- function q(e, t, n = {}) {
592
- e.write(`${K(e, n, "cyan")} ${t}\n`);
1146
+ function Y(e, t, n = {}) {
1147
+ e.write(`${Ht(e, n, "cyan")} ${t}\n`);
593
1148
  }
594
- function J(e) {
1149
+ function Ut(e) {
595
1150
  let t = e.code;
596
1151
  return typeof t == "string" ? t : null;
597
1152
  }
598
- function Ie(e) {
1153
+ function Wt(e) {
599
1154
  return /\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0] ?? null;
600
1155
  }
601
- function Le(e) {
1156
+ function Gt(e) {
602
1157
  let t = e.stack;
603
1158
  if (!t) return null;
604
1159
  for (let n of [`${e.name}: ${e.message}`, e.message]) if (t.startsWith(n)) return t.slice(n.length).replace(/^\r?\n/, "") || null;
605
1160
  return t;
606
1161
  }
607
- function Re(e) {
1162
+ function Kt(e) {
608
1163
  let t = /^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);
609
1164
  return t ? {
610
1165
  message: e.slice(t[0].length),
@@ -616,164 +1171,140 @@ function Re(e) {
616
1171
  code: null
617
1172
  };
618
1173
  }
619
- function Y(e) {
620
- return e instanceof G ? {
1174
+ function X(e) {
1175
+ return e instanceof Ft ? {
621
1176
  message: e.message,
622
1177
  stack: e.hostStack,
623
- code: J(e)
1178
+ code: Ut(e)
624
1179
  } : e instanceof Error ? {
625
1180
  message: e.message,
626
- stack: Le(e),
627
- code: J(e) ?? Ie(e.message)
1181
+ stack: Gt(e),
1182
+ code: Ut(e) ?? Wt(e.message)
628
1183
  } : {
629
1184
  message: String(e),
630
1185
  stack: null,
631
1186
  code: null
632
1187
  };
633
1188
  }
634
- function ze(e, t) {
635
- return e.split("\n").map((e) => /^\s*at\b/.test(e) ? v("dim", e, { stream: t }) : e).join("\n");
1189
+ function qt(e, t) {
1190
+ return e.split("\n").map((e) => /^\s*at\b/.test(e) ? O("dim", e, { stream: t }) : e).join("\n");
636
1191
  }
637
- function X(e, t, n, r = {}) {
638
- n.stack && e.write(`${ze(n.stack, e)}\n`);
639
- let i = n.code ? ` (${v("bold", n.code, { stream: e })})` : "";
640
- e.write(`${K(e, r, "red")} ${t}${i}: ${n.message}\n`);
641
- }
642
- //#endregion
643
- //#region src/adapter/vite/watch.mts
644
- async function Be({ onBuild: e, onError: t, stdout: n = process.stdout, stderr: r = process.stderr, quiet: i = !1, ...a }) {
645
- let { outDir: o } = a, s, c = await x(z({
646
- ...a,
647
- watch: !0,
648
- stdout: n,
649
- stderr: r,
650
- quiet: i,
651
- onOutput: (t) => {
652
- e(de(o, t, s)), s = void 0;
653
- }
654
- }));
655
- return c.on("change", (e) => {
656
- s ??= {
657
- file: e,
658
- at: Date.now()
659
- };
660
- }), c.on("event", (e) => {
661
- if (e.code !== "ERROR") return;
662
- s = void 0;
663
- let { errors: n } = e.error;
664
- t(Re(n?.[0]?.message ?? e.error.message));
665
- }), { close: () => c.close() };
1192
+ function Z(e, t, n, r = {}) {
1193
+ n.stack && e.write(`${qt(n.stack, e)}\n`);
1194
+ let i = n.code ? ` (${O("bold", n.code, { stream: e })})` : "";
1195
+ e.write(`${Ht(e, r, "red")} ${t}${i}: ${n.message}\n`);
666
1196
  }
667
1197
  //#endregion
668
1198
  //#region src/defaultBundler.mts
669
- var Ve = {
670
- watch: Be,
671
- build: ye,
672
- hmr: Oe
673
- };
674
- //#endregion
675
- //#region src/entry.mts
676
- async function He(e) {
677
- let t = a.join(e, "src/main.mts");
678
- if (o(t)) return t;
679
- let n = a.join(e, "src/App.vue");
680
- if (o(n)) return Ue(n, e);
681
- throw new O("ERR_INCA_ENTRY_NOT_FOUND", `no app entry found — expected ${t} or ${n}`);
1199
+ var Jt = jt(/* @__PURE__ */ e({
1200
+ IncaError: () => V,
1201
+ bundlerFault: () => Kt
1202
+ }), "incajs/vue/runtime"), Q = [
1203
+ "main.mts",
1204
+ "main.ts",
1205
+ "main.js"
1206
+ ];
1207
+ async function Yt(e) {
1208
+ let t = Q.map((t) => f.join(e, "src", t)).find((e) => m(e));
1209
+ if (t) return t;
1210
+ let n = f.join(e, "src/App.vue");
1211
+ if (m(n)) return Xt(n, e);
1212
+ throw new V("ERR_INCA_ENTRY_NOT_FOUND", `no app entry found — check that ${f.join(e, "src/main.ts")} or ${n} exists`);
682
1213
  }
683
- async function Ue(e, t) {
684
- let n = a.join(t, "node_modules/.inca");
685
- await p(n, { recursive: !0 });
686
- let r = a.join(n, "entry.mts"), i = JSON.stringify(e.split(a.sep).join("/"));
687
- return await _(r, `import { createIncaApp } from "incajs/vue";\nimport App from ${i};\ncreateIncaApp(App).mount();\n`), r;
1214
+ async function Xt(e, t) {
1215
+ let n = f.join(t, "node_modules/.inca");
1216
+ await C(n, { recursive: !0 });
1217
+ let r = f.join(n, "entry.mts"), i = JSON.stringify(e.split(f.sep).join("/"));
1218
+ return await D(r, `import { createIncaApp } from "incajs/vue";\nimport App from ${i};\ncreateIncaApp(App).mount();\n`), r;
688
1219
  }
689
1220
  //#endregion
690
1221
  //#region src/build.mts
691
- async function We(e = {}) {
692
- let t = e.cwd ?? process.cwd(), n = e.config ?? await P(t), r = a.resolve(t, n.outDir), i = e.bundler ?? Ve, o = e.entry ?? n.entry ?? await He(t);
693
- j(t, r, o);
694
- let s = e.runtimeConfig ?? await ue(t);
1222
+ async function Zt(e = {}) {
1223
+ let t = e.cwd ?? process.cwd(), n = e.config ?? await tt(t), r = f.resolve(t, n.outDir), i = e.bundler ?? Jt, a = e.entry ?? n.entry ?? await Yt(t);
1224
+ W(t, r, a);
1225
+ let o = e.runtimeConfig ?? await it(t);
695
1226
  return i.build({
696
- entry: o,
1227
+ entry: a,
697
1228
  outDir: r,
698
- runtimeConfig: s,
1229
+ runtimeConfig: o,
699
1230
  stdout: e.stdout,
700
1231
  stderr: e.stderr
701
1232
  });
702
1233
  }
703
1234
  //#endregion
704
- //#region src/dev-lock.mts
705
- function Ge(e) {
706
- return a.join(e, "node_modules/.inca/dev.pid");
1235
+ //#region src/devLock.mts
1236
+ function Qt(e) {
1237
+ return f.join(e, "node_modules/.inca/dev.pid");
707
1238
  }
708
- function Ke(e) {
1239
+ function $t(e) {
709
1240
  try {
710
1241
  return process.kill(e, 0), !0;
711
1242
  } catch (e) {
712
1243
  return e.code === "EPERM";
713
1244
  }
714
1245
  }
715
- var qe = D();
716
- function Z(e) {
717
- return new O("ERR_INCA_DEV_RUNNING", `inca dev is already running for this app (pid ${String(e)})`);
1246
+ var en = de();
1247
+ function $(e) {
1248
+ return new V("ERR_INCA_DEV_RUNNING", `inca dev is already running for this app (pid ${String(e)})`);
718
1249
  }
719
- async function Je(e) {
720
- let t = Ge(e), n = `${String(process.pid)}:${qe}`, r = `${t}.${D()}`;
721
- await p(a.dirname(t), { recursive: !0 }), await _(r, n);
1250
+ async function tn(e) {
1251
+ let t = Qt(e), n = `${String(process.pid)}:${en}`, r = `${t}.${de()}`;
1252
+ await C(f.dirname(t), { recursive: !0 }), await D(r, n);
722
1253
  let i = process.pid;
723
1254
  try {
724
1255
  for (let e = 0; e < 5; e++) {
725
1256
  try {
726
- return await f(r, t), Ye(t, n);
1257
+ return await S(r, t), nn(t, n);
727
1258
  } catch (e) {
728
1259
  if (e.code !== "EEXIST") throw e;
729
1260
  }
730
- let e = await m(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
1261
+ let e = await w(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
731
1262
  if (a === process.pid) {
732
- if (e === n) throw Z(a);
733
- } else if (Number.isSafeInteger(a) && a > 0 && Ke(a)) throw Z(a);
734
- i = Number.isSafeInteger(a) && a > 0 ? a : i, await g(t, { force: !0 });
1263
+ if (e === n) throw $(a);
1264
+ } else if (Number.isSafeInteger(a) && a > 0 && $t(a)) throw $(a);
1265
+ i = Number.isSafeInteger(a) && a > 0 ? a : i, await E(t, { force: !0 });
735
1266
  }
736
- throw Z(i);
1267
+ throw $(i);
737
1268
  } finally {
738
- await g(r, { force: !0 });
1269
+ await E(r, { force: !0 });
739
1270
  }
740
1271
  }
741
- function Ye(e, t) {
1272
+ function nn(e, t) {
742
1273
  let n = !1;
743
1274
  return async () => {
744
- n || (n = !0, await m(e, "utf8").catch(() => "") === t && await g(e, { force: !0 }));
1275
+ n || (n = !0, await w(e, "utf8").catch(() => "") === t && await E(e, { force: !0 }));
745
1276
  };
746
1277
  }
747
1278
  //#endregion
748
1279
  //#region src/plist.mts
749
- function Xe(e) {
1280
+ function rn(e) {
750
1281
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
751
1282
  }
752
- function Ze(e) {
753
- return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${Xe(e)}</string>`;
1283
+ function an(e) {
1284
+ return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${rn(e)}</string>`;
754
1285
  }
755
- function Qe(e) {
1286
+ function on(e) {
756
1287
  return `<?xml version="1.0" encoding="UTF-8"?>
757
1288
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
758
1289
  <plist version="1.0">
759
1290
  <dict>
760
- ${Object.entries(e).map(([e, t]) => `\t<key>${Xe(e)}</key>\n\t${Ze(t)}`).join("\n")}\n</dict>
1291
+ ${Object.entries(e).map(([e, t]) => `\t<key>${rn(e)}</key>\n\t${an(t)}`).join("\n")}\n</dict>
761
1292
  </plist>
762
1293
  `;
763
1294
  }
764
1295
  //#endregion
765
- //#region src/macos-app.mts
766
- async function $e(e) {
1296
+ //#region src/macosApp.mts
1297
+ async function sn(e) {
767
1298
  let { appPath: t, metadata: n, hostBin: r } = e;
768
- await g(t, {
1299
+ await E(t, {
769
1300
  recursive: !0,
770
1301
  force: !0
771
1302
  });
772
- let i = a.join(t, "Contents"), o = a.join(i, "MacOS"), s = a.join(i, "Resources");
773
- await p(o, { recursive: !0 }), await p(s, { recursive: !0 });
774
- let c = a.join(o, n.productName);
775
- e.link ? await f(r, c).catch(() => d(r, c)) : await d(r, c), await u(c, 493);
776
- let l = {
1303
+ let i = f.join(t, "Contents"), a = f.join(i, "MacOS"), o = f.join(i, "Resources");
1304
+ await C(a, { recursive: !0 }), await C(o, { recursive: !0 });
1305
+ let s = f.join(a, n.productName);
1306
+ e.link ? await S(r, s).catch(() => x(r, s)) : await x(r, s), await b(s, 493);
1307
+ let c = {
777
1308
  CFBundleName: n.productName,
778
1309
  CFBundleDisplayName: n.productName,
779
1310
  CFBundleExecutable: n.productName,
@@ -785,253 +1316,334 @@ async function $e(e) {
785
1316
  NSHighResolutionCapable: !0
786
1317
  };
787
1318
  if (n.icon) {
788
- let e = a.basename(n.icon);
789
- await d(n.icon, a.join(s, e)), l.CFBundleIconFile = e;
1319
+ let e = f.basename(n.icon);
1320
+ await x(n.icon, f.join(o, e)), c.CFBundleIconFile = e;
790
1321
  }
791
- return await _(a.join(i, "Info.plist"), Qe(l)), await _(a.join(i, "PkgInfo"), "APPL????"), {
1322
+ return await D(f.join(i, "Info.plist"), on(c)), await D(f.join(i, "PkgInfo"), "APPL????"), {
792
1323
  appPath: t,
793
- executablePath: c,
794
- resourcesDir: s
1324
+ executablePath: s,
1325
+ resourcesDir: o
1326
+ };
1327
+ }
1328
+ //#endregion
1329
+ //#region src/watchForEdit.mts
1330
+ var cn = /^(?:inca\.config\.[a-z0-9]+|package\.json)$/, ln = [...Q, "App.vue"];
1331
+ function un(e, t = {}) {
1332
+ let n = t.debounceMs ?? 100, r = /* @__PURE__ */ new Set(), i, a = !1, o = () => {}, s = new Promise((e) => {
1333
+ o = e;
1334
+ }), c = () => {
1335
+ a || (clearTimeout(i), i = setTimeout(o, n), i.unref());
1336
+ }, l = (e, t) => {
1337
+ let n = e;
1338
+ for (let e; !m(n) && (e = f.dirname(n)) !== n;) n = e;
1339
+ let i = n === e ? void 0 : f.relative(n, e).split(f.sep)[0], a = y(n);
1340
+ a.on("change", (e, n) => {
1341
+ let r = n === null ? null : String(n);
1342
+ (r === null || (i === void 0 ? t(r) : r === i)) && c();
1343
+ }), a.on("error", () => {
1344
+ a.close(), r.delete(a), c();
1345
+ }), r.add(a);
1346
+ }, u = () => {
1347
+ a = !0, clearTimeout(i);
1348
+ for (let e of r) e.close();
1349
+ r.clear();
1350
+ };
1351
+ try {
1352
+ l(e, (e) => e === "src" || cn.test(e)), l(f.join(e, "src"), (e) => ln.includes(e));
1353
+ } catch (e) {
1354
+ throw u(), e;
1355
+ }
1356
+ return {
1357
+ edited: s,
1358
+ add(e) {
1359
+ if (a) return;
1360
+ let t = f.resolve(e);
1361
+ l(f.dirname(t), (e) => e === f.basename(t));
1362
+ },
1363
+ close: u
795
1364
  };
796
1365
  }
797
1366
  //#endregion
1367
+ //#region src/retryOnEdit.mts
1368
+ function dn(e, t) {
1369
+ return new Promise((n) => {
1370
+ let r = () => n(!1);
1371
+ t.addEventListener("abort", r, { once: !0 }), e.then(() => {
1372
+ t.removeEventListener("abort", r), n(!0);
1373
+ });
1374
+ });
1375
+ }
1376
+ async function fn(e) {
1377
+ let { cwd: t, signal: n, stdout: r, stderr: i, debounceMs: a } = e, o = !1;
1378
+ for (;;) {
1379
+ let s = un(t, { debounceMs: a });
1380
+ try {
1381
+ return await e.attempt(s);
1382
+ } catch (e) {
1383
+ let t = e instanceof V ? e.path : void 0;
1384
+ if (t) try {
1385
+ s.add(t);
1386
+ } catch (t) {
1387
+ throw Z(i, "build failed", X(e), J), t;
1388
+ }
1389
+ if (!n.aborted && !o && t && m(t)) {
1390
+ o = !0;
1391
+ continue;
1392
+ }
1393
+ if (o = !1, Z(i, "build failed", X(e), J), n.aborted || (Y(r, "waiting for a change to retry", J), !await dn(s.edited, n))) return;
1394
+ Y(r, "retrying", J);
1395
+ } finally {
1396
+ s.close();
1397
+ }
1398
+ }
1399
+ }
1400
+ //#endregion
798
1401
  //#region src/dev.mts
799
- var Q = { timestamp: !0 }, et = 1e4, tt = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
800
- async function nt(e, t) {
1402
+ var pn = 1e4, mn = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
1403
+ async function hn(e, t) {
801
1404
  try {
802
- return await ce(e);
1405
+ return await nt(e);
803
1406
  } catch (e) {
804
- if (!(e instanceof O) || !tt.includes(e.code)) throw e;
805
- q(t, `running unnamed — ${e.message}`, Q);
1407
+ if (!(e instanceof V) || !mn.includes(e.code)) throw e;
1408
+ Y(t, `running unnamed — ${e.message}`, J);
806
1409
  return;
807
1410
  }
808
1411
  }
809
- async function rt(e, t, n, r) {
1412
+ async function gn(e, t, n, r) {
810
1413
  if (process.platform === "darwin" && t) try {
811
- return (await $e({
812
- appPath: a.join(e, "node_modules/.inca", `${t.productName}.app`),
1414
+ return (await sn({
1415
+ appPath: f.join(e, "node_modules/.inca", `${t.productName}.app`),
813
1416
  metadata: t,
814
1417
  hostBin: n,
815
1418
  link: !0
816
1419
  })).executablePath;
817
1420
  } catch (e) {
818
- q(r, `running unbundled — ${Y(e).message}`, Q);
1421
+ Y(r, `running unbundled — ${X(e).message}`, J);
819
1422
  return;
820
1423
  }
821
1424
  }
822
- function it(e) {
823
- let t = S(e, [], !1), n = [e.stack, t].filter((e) => e).join("\n");
824
- return {
825
- message: e.message,
826
- stack: n || null,
827
- code: null
828
- };
829
- }
830
- async function at(e, t) {
1425
+ async function _n(e, t) {
831
1426
  let n = new Set(t), r;
832
1427
  try {
833
- r = await h(e, {
1428
+ r = await T(e, {
834
1429
  recursive: !0,
835
1430
  withFileTypes: !0
836
1431
  });
837
1432
  } catch {
838
1433
  return;
839
1434
  }
840
- await Promise.all(r.filter((e) => e.isFile()).map((t) => a.relative(e, a.join(t.parentPath, t.name))).filter((e) => !n.has(e)).map((t) => g(a.join(e, t), { force: !0 })));
1435
+ await Promise.all(r.filter((e) => e.isFile()).map((t) => f.relative(e, f.join(t.parentPath, t.name))).filter((e) => !n.has(e)).map((t) => E(f.join(e, t), { force: !0 })));
841
1436
  }
842
- function ot(e) {
1437
+ function vn(e) {
843
1438
  let { NO_COLOR: t, FORCE_COLOR: n } = process.env;
844
1439
  if (!(!e.isTTY || t || n)) return {
845
1440
  ...process.env,
846
1441
  FORCE_COLOR: "1"
847
1442
  };
848
1443
  }
849
- async function st(e) {
850
- let t = e.cwd ?? process.cwd(), n = await P(t), r = await Je(t);
1444
+ async function yn(e) {
1445
+ let t = e.cwd ?? process.cwd(), n = await tn(t);
851
1446
  try {
852
- let r = e.hostBin ?? U();
853
- W(r);
854
- let i = a.resolve(t, n.outDir), o = e.bundler ?? Ve, s = e.stdout ?? process.stdout, c = e.stderr ?? process.stderr, l = e.entry ?? n.entry ?? await He(t);
855
- j(t, i, l);
856
- let u = await nt(t, s), d = u ? le(u) : await ue(t), f = await rt(t, u, r, s) ?? r, p, m = !1, h = !1, g = !1, _, y = Promise.resolve(), b = () => {}, x = new Promise((e) => {
1447
+ let n = e.hostBin ?? K();
1448
+ q(n);
1449
+ let r = e.bundler ?? Jt, i = e.stdout ?? process.stdout, a = e.stderr ?? process.stderr, o = e.experimentalHmr ? r.hmr?.bind(r) : void 0;
1450
+ if (e.experimentalHmr && !o) throw new V("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
1451
+ let s = await fn({
1452
+ cwd: t,
1453
+ signal: e.signal,
1454
+ stdout: i,
1455
+ stderr: a,
1456
+ async attempt() {
1457
+ let n = await tt(t), r = f.resolve(t, n.outDir), a = e.entry ?? n.entry ?? await Yt(t);
1458
+ W(t, r, a);
1459
+ let o = await hn(t, i);
1460
+ return {
1461
+ outDir: r,
1462
+ entry: a,
1463
+ metadata: o,
1464
+ runtimeConfig: o ? rt(o) : await it(t)
1465
+ };
1466
+ }
1467
+ });
1468
+ if (!s) return;
1469
+ let { outDir: c, entry: l, metadata: u, runtimeConfig: d } = s, p = await gn(t, u, n, i) ?? n, m, h = !1, g = !1, _ = !1, v, y = Promise.resolve(), b = () => {}, x = new Promise((e) => {
857
1470
  b = e;
858
1471
  });
859
1472
  async function S() {
860
1473
  try {
861
- return await p?.call("reload", void 0, et), !0;
1474
+ return await m?.call("reload", void 0, pn), !0;
862
1475
  } catch (e) {
863
- return X(c, "reload failed", Y(e), Q), !1;
1476
+ return Z(a, "reload failed", X(e), J), !1;
864
1477
  }
865
1478
  }
866
1479
  async function C(e, t) {
867
- let n = new Ne({
1480
+ let n = new zt({
868
1481
  entryFile: e,
869
- hostBin: f,
870
- env: ot(c),
871
- onStderr: (e) => c.write(e),
1482
+ hostBin: p,
1483
+ env: vn(a),
1484
+ onStderr: (e) => a.write(e),
872
1485
  onReady: () => {
873
- m = !0, q(s, "ready", Q), h && (h = !1, S());
1486
+ h = !0, Y(i, "ready", J), g && (g = !1, S());
874
1487
  },
875
- onAppError: (e) => X(c, "app error", e, Q),
1488
+ onAppError: (e) => Z(a, "app error", e, J),
876
1489
  onExit: (e, t) => {
877
- g = !m, _ = {
1490
+ _ = !h, v = {
878
1491
  code: e,
879
1492
  signal: t
880
- }, q(s, "host exited — stopping", Q), b();
1493
+ }, Y(i, "host exited — stopping", J), b();
881
1494
  },
882
1495
  integrations: t
883
1496
  });
884
1497
  try {
885
1498
  await n.start();
886
1499
  } catch (e) {
887
- X(c, "failed to start inca-host", Y(e), Q);
1500
+ Z(a, "failed to start inca-host", X(e), J);
888
1501
  return;
889
1502
  }
890
- p = n;
1503
+ m = n;
891
1504
  }
892
1505
  async function w(e) {
893
- if (await at(e.outDir, e.files), !p) {
1506
+ if (await _n(e.outDir, e.files), !m) {
894
1507
  await C(e.entryFile);
895
1508
  return;
896
1509
  }
897
- if (!m) {
898
- h = !0;
1510
+ if (!h) {
1511
+ g = !0;
899
1512
  return;
900
1513
  }
901
1514
  if (await S() && e.changed) {
902
- let n = v("dim", a.relative(t, e.changed.file), { stream: s }), r = Date.now() - e.changed.at;
903
- q(s, `${v("green", "reload")} ${n} (${r}ms)`, Q);
1515
+ let n = O("dim", f.relative(t, e.changed.file), { stream: i }), r = Date.now() - e.changed.at;
1516
+ Y(i, `${O("green", "reload")} ${n} (${r}ms)`, J);
904
1517
  }
905
1518
  }
906
1519
  let T;
907
- if (e.experimentalHmr) {
908
- if (!o.hmr) throw new O("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
909
- let e = await o.hmr({
1520
+ if (o) {
1521
+ let e = await o({
910
1522
  entry: l,
911
1523
  cwd: t,
912
1524
  runtimeConfig: d,
913
- stdout: s,
914
- stderr: c,
915
- notify: (e) => p?.notify("vite", e),
1525
+ stdout: i,
1526
+ stderr: a,
1527
+ notify: (e) => m?.notify("vite", e),
916
1528
  reload: () => void S(),
917
- onError: (e) => X(c, "build failed", it(e), Q),
1529
+ onError: (e) => Z(a, "build failed", e, J),
918
1530
  onUpdate: ({ file: e, took: n }) => {
919
- let r = v("dim", a.relative(t, e), { stream: s });
920
- q(s, `${v("green", "update")} ${r} (${n}ms)`, Q);
1531
+ let r = O("dim", f.relative(t, e), { stream: i });
1532
+ Y(i, `${O("green", "update")} ${r} (${n}ms)`, J);
921
1533
  }
922
1534
  });
923
- await C(e.entryFile, { vite: (t) => e.dispatch(t) }), T = e, p || b();
924
- } else T = await o.watch({
1535
+ await C(e.entryFile, { vite: (t) => e.dispatch(t) }), T = e, m || b();
1536
+ } else T = await r.watch({
925
1537
  entry: l,
926
- outDir: i,
1538
+ outDir: c,
927
1539
  runtimeConfig: d,
928
1540
  mode: "development",
929
- stdout: s,
930
- stderr: c,
1541
+ stdout: i,
1542
+ stderr: a,
931
1543
  onBuild: (e) => {
932
1544
  y = y.then(() => w(e));
933
1545
  },
934
1546
  onError: (e) => {
935
- X(c, "build failed", e, Q);
1547
+ Z(a, "build failed", e, J);
936
1548
  }
937
1549
  });
938
- if (e.signal.aborted ? b() : e.signal.addEventListener("abort", () => b(), { once: !0 }), await x, await y, await p?.stop(), await T.close(), g) throw new O("ERR_INCA_HOST_EXITED_EARLY", "the host exited before it was ready");
939
- if (_ && _.code !== 0 && _.signal !== "SIGINT" && _.signal !== "SIGTERM") {
940
- let { code: e, signal: t } = _;
941
- throw new O("ERR_INCA_HOST_CRASHED", `the host exited with ${t ? `signal ${t}` : `code ${e}`}`);
1550
+ if (e.signal.aborted ? b() : e.signal.addEventListener("abort", () => b(), { once: !0 }), await x, await y, await m?.stop(), await T.close(), _) throw new V("ERR_INCA_HOST_EXITED_EARLY", "the host exited before it was ready");
1551
+ if (v && v.code !== 0 && v.signal !== "SIGINT" && v.signal !== "SIGTERM") {
1552
+ let { code: e, signal: t } = v;
1553
+ throw new V("ERR_INCA_HOST_CRASHED", `the host exited with ${t ? `signal ${t}` : `code ${e}`}`);
942
1554
  }
943
1555
  } finally {
944
- await r();
1556
+ await n();
945
1557
  }
946
1558
  }
947
1559
  //#endregion
948
1560
  //#region src/package.mts
949
- function ct() {
1561
+ function bn() {
950
1562
  if (process.platform === "darwin") return "macos";
951
1563
  if (process.platform === "linux") return "linux";
952
- throw new O("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
1564
+ throw new V("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
953
1565
  }
954
- async function lt(e, t) {
1566
+ async function xn(e, t) {
955
1567
  await Promise.all(e.files.map(async (n) => {
956
- let r = a.join(t, n);
957
- await p(a.dirname(r), { recursive: !0 }), await d(a.join(e.outDir, n), r);
1568
+ let r = f.join(t, n);
1569
+ await C(f.dirname(r), { recursive: !0 }), await x(f.join(e.outDir, n), r);
958
1570
  }));
959
1571
  }
960
- function ut(e, t) {
1572
+ function Sn(e, t) {
961
1573
  let n = e.files.map((e) => e.split("/")[0] ?? e).find((e) => e.toLowerCase() === t.toLowerCase());
962
- if (n !== void 0) throw new O("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`);
1574
+ 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`);
963
1575
  }
964
- async function dt({ metadata: e, output: t, hostBin: n }) {
965
- let { appPath: r, resourcesDir: i } = await $e({
966
- appPath: a.join(t.outDir, `${e.productName}.app`),
1576
+ async function Cn({ metadata: e, output: t, hostBin: n }) {
1577
+ let { appPath: r, resourcesDir: i } = await sn({
1578
+ appPath: f.join(t.outDir, `${e.productName}.app`),
967
1579
  metadata: e,
968
1580
  hostBin: n
969
1581
  });
970
- return await lt(t, i), r;
1582
+ return await xn(t, i), r;
971
1583
  }
972
- async function ft({ metadata: t, output: n, hostBin: r }) {
973
- let i = e(t.productName);
974
- ut(n, i);
975
- let o = a.join(n.outDir, i);
976
- await g(o, {
1584
+ async function wn({ metadata: e, output: t, hostBin: n }) {
1585
+ let r = c(e.productName);
1586
+ Sn(t, r);
1587
+ let i = f.join(t.outDir, r);
1588
+ await E(i, {
977
1589
  recursive: !0,
978
1590
  force: !0
979
- }), await p(o, { recursive: !0 });
980
- let s = a.join(o, i);
981
- return await d(r, s), await u(s, 493), await lt(n, o), o;
982
- }
983
- async function pt(e = {}) {
984
- let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? ct(), i = await ce(t);
985
- i.usedPackageJsonKey && q(n, "the \"inca\" key in package.json is deprecated — move these settings to inca.config.ts"), i.identifierIsDefault && q(n, `no "identifier" set in inca.config.ts — using generated identifier ${i.identifier}`);
986
- let a = await We({
1591
+ }), await C(i, { recursive: !0 });
1592
+ let a = f.join(i, r);
1593
+ return await x(n, a), await b(a, 493), await xn(t, i), i;
1594
+ }
1595
+ async function Tn(e = {}) {
1596
+ let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? bn(), i = await nt(t);
1597
+ 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}`);
1598
+ let a = await Zt({
987
1599
  cwd: t,
988
1600
  entry: e.entry,
989
1601
  config: i,
990
- runtimeConfig: le(i),
1602
+ runtimeConfig: rt(i),
991
1603
  bundler: e.bundler,
992
1604
  stdout: n,
993
1605
  stderr: e.stderr
994
- }), o = e.hostBin ?? U();
995
- W(o);
1606
+ }), o = e.hostBin ?? K();
1607
+ q(o);
996
1608
  let s = {
997
1609
  metadata: i,
998
1610
  output: a,
999
1611
  hostBin: o
1000
1612
  };
1001
- return { appPath: r === "macos" ? await dt(s) : await ft(s) };
1613
+ return { appPath: r === "macos" ? await Cn(s) : await wn(s) };
1002
1614
  }
1003
1615
  //#endregion
1004
1616
  //#region src/cli.mts
1005
- var mt = "Usage: inca <dev|build|package>";
1006
- function $(e) {
1007
- return a.relative(process.cwd(), e);
1617
+ var En = "Usage: inca <dev|build|package>";
1618
+ function Dn(e) {
1619
+ return f.relative(process.cwd(), e);
1008
1620
  }
1009
- async function ht(e = process.argv) {
1621
+ async function On(e = process.argv) {
1010
1622
  let t = e[2];
1011
1623
  if (t === "build") {
1012
1624
  try {
1013
- let e = await We();
1014
- q(process.stdout, `built ${$(e.entryFile)}`);
1625
+ let e = await Zt();
1626
+ Y(process.stdout, `built ${Dn(e.entryFile)}`);
1015
1627
  } catch (e) {
1016
- X(process.stderr, "build failed", Y(e)), process.exitCode = 1;
1628
+ Z(process.stderr, "build failed", X(e)), process.exitCode = 1;
1017
1629
  }
1018
1630
  return;
1019
1631
  }
1020
1632
  if (t === "package") {
1021
1633
  try {
1022
- let { appPath: e } = await pt();
1023
- q(process.stdout, `packaged ${$(e)}`);
1634
+ let { appPath: e } = await Tn();
1635
+ Y(process.stdout, `packaged ${Dn(e)}`);
1024
1636
  } catch (e) {
1025
- X(process.stderr, "package failed", Y(e)), process.exitCode = 1;
1637
+ Z(process.stderr, "package failed", X(e)), process.exitCode = 1;
1026
1638
  }
1027
1639
  return;
1028
1640
  }
1029
1641
  if (t !== "dev") {
1030
- process.stderr.write(`${mt}\n`), process.exitCode = 1;
1642
+ process.stderr.write(`${En}\n`), process.exitCode = 1;
1031
1643
  return;
1032
1644
  }
1033
1645
  let n = new AbortController(), r = () => {
1034
- n.signal.aborted || (q(process.stderr, "shutting down", { timestamp: !0 }), n.abort());
1646
+ n.signal.aborted || (Y(process.stderr, "shutting down", { timestamp: !0 }), n.abort());
1035
1647
  };
1036
1648
  process.on("SIGINT", r), process.on("SIGTERM", r);
1037
1649
  let i = e.includes("--experimental-hmr") || ![
@@ -1039,15 +1651,15 @@ async function ht(e = process.argv) {
1039
1651
  "0",
1040
1652
  "false"
1041
1653
  ].includes(process.env.INCA_EXPERIMENTAL_HMR ?? "");
1042
- i && q(process.stdout, "experimental HMR active", { timestamp: !0 });
1654
+ i && Y(process.stdout, "experimental HMR active", { timestamp: !0 });
1043
1655
  try {
1044
- await st({
1656
+ await yn({
1045
1657
  signal: n.signal,
1046
1658
  experimentalHmr: i
1047
1659
  });
1048
1660
  } catch (e) {
1049
- X(process.stderr, "dev failed", Y(e), { timestamp: !0 }), process.exitCode = 1;
1661
+ Z(process.stderr, "dev failed", X(e), { timestamp: !0 }), process.exitCode = 1;
1050
1662
  }
1051
1663
  }
1052
1664
  //#endregion
1053
- export { ht as run };
1665
+ export { On as run };