@incajs/cli 0.0.6 → 0.0.7

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
@@ -7,61 +7,76 @@ import { fileURLToPath as g } from "node:url";
7
7
  import { DevEnvironment as _, build as v, buildErrorMessage as y, createServer as b } from "vite";
8
8
  import x from "@vitejs/plugin-vue";
9
9
  import { createRequire as S } from "node:module";
10
- import { spawn as ee } from "node:child_process";
11
- import { once as C } from "node:events";
12
- import te from "node:readline";
13
- import { setTimeout as ne } from "node:timers/promises";
10
+ import { spawn as C } from "node:child_process";
11
+ import { once as w } from "node:events";
12
+ import ee from "node:readline";
13
+ import { setTimeout as te } from "node:timers/promises";
14
14
  //#region src/error.mts
15
- var w = class extends Error {
15
+ var T = class extends Error {
16
16
  code;
17
17
  name = "IncaError";
18
18
  constructor(e, t) {
19
19
  super(t), this.code = e;
20
20
  }
21
- }, re = {
21
+ }, ne = {
22
22
  name: "inca",
23
23
  packageJson: "inca",
24
24
  rcFile: !1,
25
25
  globalRc: !1,
26
26
  giget: !1,
27
27
  extend: !1
28
- }, ie = /[/\\:*?"<>|\0]/;
29
- function ae(e) {
30
- return e === e.trim() && e !== "" && e !== "." && e !== ".." && !ie.test(e);
28
+ }, re = /[/\\:*?"<>|\0]/;
29
+ function ie(e) {
30
+ return e === e.trim() && e !== "" && e !== "." && e !== ".." && !re.test(e);
31
+ }
32
+ function E(e) {
33
+ if (!(typeof e == "string" && ie(e))) throw new T("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 \`/\\:*?"<>|\``);
34
+ }
35
+ var ae = process.platform === "darwin" || process.platform === "win32";
36
+ function oe(e, t) {
37
+ let n = (e) => ae ? e.toLowerCase() : e, r = a.relative(n(e), n(t));
38
+ return r === "" || r !== ".." && !r.startsWith(`..${a.sep}`) && !a.isAbsolute(r);
39
+ }
40
+ function D(e, t, n) {
41
+ let r = a.resolve(e, t ?? i.outDir);
42
+ if ([
43
+ e,
44
+ a.join(e, "src"),
45
+ a.join(e, "node_modules"),
46
+ ...n ? [n] : []
47
+ ].some((e) => oe(r, e))) throw new T("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"`);
48
+ return r;
31
49
  }
32
- function T(e) {
33
- if (!(typeof e == "string" && ae(e))) throw new w("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 \`/\\:*?"<>|\``);
34
- }
35
- async function E(e) {
50
+ async function O(e) {
36
51
  let { config: t, layers: r } = await n({
37
52
  cwd: e,
38
- ...re
53
+ ...ne
39
54
  }), i = r?.find((e) => e.configFile === "package.json");
40
55
  return {
41
56
  config: t,
42
57
  usedPackageJsonKey: Object.keys(i?.config ?? {}).length > 0
43
58
  };
44
59
  }
45
- async function D(e) {
46
- let { config: t } = await E(e);
60
+ async function k(e) {
61
+ let { config: t } = await O(e), n = t.entry ? a.resolve(e, t.entry) : void 0;
47
62
  return {
48
- entry: t.entry ? a.resolve(e, t.entry) : void 0,
49
- outDir: a.resolve(e, t.outDir ?? i.outDir)
63
+ entry: n,
64
+ outDir: D(e, t.outDir, n)
50
65
  };
51
66
  }
52
- async function O(e) {
67
+ async function A(e) {
53
68
  let n = a.join(e, "package.json"), s;
54
69
  try {
55
70
  s = await d(n, "utf8");
56
71
  } catch {
57
- throw new w("ERR_INCA_PACKAGE_JSON_NOT_FOUND", `no package.json found at ${n}`);
72
+ throw new T("ERR_INCA_PACKAGE_JSON_NOT_FOUND", `no package.json found at ${n}`);
58
73
  }
59
- let c = JSON.parse(s), { config: l, usedPackageJsonKey: u } = await E(e), f = l.productName ?? r(c.name);
60
- if (!f) throw new w("ERR_INCA_PRODUCT_NAME_MISSING", `${n} needs a "name", or "productName" in inca.config.ts`);
61
- T(f);
74
+ let c = JSON.parse(s), { config: l, usedPackageJsonKey: u } = await O(e), f = l.productName ?? r(c.name);
75
+ if (!f) throw new T("ERR_INCA_PRODUCT_NAME_MISSING", `${n} needs a "name", or "productName" in inca.config.ts`);
76
+ E(f);
62
77
  let p = l.version ?? c.version ?? i.version, m = l.identifier ?? t(f), h;
63
- if (l.icon && (h = a.resolve(e, l.icon), !o(h))) throw new w("ERR_INCA_ICON_NOT_FOUND", `"icon" points to ${h}, which doesn't exist`);
64
- let g = l.entry ? a.resolve(e, l.entry) : void 0, _ = a.resolve(e, l.outDir ?? i.outDir);
78
+ if (l.icon && (h = a.resolve(e, l.icon), !o(h))) throw new T("ERR_INCA_ICON_NOT_FOUND", `"icon" points to ${h}, which doesn't exist`);
79
+ let g = l.entry ? a.resolve(e, l.entry) : void 0, _ = D(e, l.outDir, g);
65
80
  return {
66
81
  productName: f,
67
82
  identifier: m,
@@ -74,20 +89,20 @@ async function O(e) {
74
89
  usedPackageJsonKey: u
75
90
  };
76
91
  }
77
- function k(e) {
92
+ function j(e) {
78
93
  return {
79
94
  name: e.productName,
80
95
  identifier: e.identifier,
81
96
  window: e.window
82
97
  };
83
98
  }
84
- async function A(e) {
85
- let { config: n } = await E(e), i = {};
99
+ async function se(e) {
100
+ let { config: n } = await O(e), i = {};
86
101
  try {
87
102
  i = JSON.parse(await d(a.join(e, "package.json"), "utf8"));
88
103
  } catch {}
89
104
  let o = n.productName ?? r(i.name);
90
- o && T(o);
105
+ o && E(o);
91
106
  let s = {
92
107
  name: o,
93
108
  identifier: n.identifier ?? (o ? t(o) : void 0),
@@ -97,7 +112,7 @@ async function A(e) {
97
112
  }
98
113
  //#endregion
99
114
  //#region src/adapter/vite/captureOutput.mts
100
- function j(e, t, n) {
115
+ function M(e, t, n) {
101
116
  return {
102
117
  outDir: e,
103
118
  entryFile: a.join(e, t.entryFile),
@@ -105,12 +120,12 @@ function j(e, t, n) {
105
120
  changed: n
106
121
  };
107
122
  }
108
- function oe(e) {
123
+ function ce(e) {
109
124
  return {
110
125
  name: "inca:capture-output",
111
126
  writeBundle(t, n) {
112
127
  let r = Object.keys(n), i = Object.values(n).find((e) => e.type === "chunk" && e.isEntry);
113
- if (!i) throw new w("ERR_INCA_BUILD_NO_ENTRY_CHUNK", "build produced no entry chunk");
128
+ if (!i) throw new T("ERR_INCA_BUILD_NO_ENTRY_CHUNK", "build produced no entry chunk");
114
129
  e({
115
130
  entryFile: i.fileName,
116
131
  files: r
@@ -120,19 +135,19 @@ function oe(e) {
120
135
  }
121
136
  //#endregion
122
137
  //#region src/adapter/vite/emitConfig.mts
123
- var M = "inca.json";
124
- function N(e) {
138
+ var N = "inca.json";
139
+ function P(e) {
125
140
  let t = JSON.stringify(e, void 0, 2);
126
141
  if (t !== void 0 && t !== "{}") return `${t}\n`;
127
142
  }
128
- function se(e) {
129
- let t = N(e);
143
+ function le(e) {
144
+ let t = P(e);
130
145
  return {
131
146
  name: "inca:emit-config",
132
147
  generateBundle() {
133
148
  t && this.emitFile({
134
149
  type: "asset",
135
- fileName: M,
150
+ fileName: N,
136
151
  source: t
137
152
  });
138
153
  }
@@ -140,8 +155,8 @@ function se(e) {
140
155
  }
141
156
  //#endregion
142
157
  //#region src/adapter/vite/logger.mts
143
- var ce = "Build failed with ", le = "Pre-transform error";
144
- function P(e, t, n = !1) {
158
+ var ue = "Build failed with ", de = "Pre-transform error";
159
+ function F(e, t, n = !1) {
145
160
  let r = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new Set(), a = {
146
161
  hasWarned: !1,
147
162
  info(t) {
@@ -154,7 +169,7 @@ function P(e, t, n = !1) {
154
169
  i.has(e) || (i.add(e), a.warn(e));
155
170
  },
156
171
  error(e, n) {
157
- a.hasWarned = !0, n?.error && r.add(n.error), !e.includes(ce) && (e.includes(le) || t.write(`${e.replace(/\n\s+at .*/g, "")}\n`));
172
+ a.hasWarned = !0, n?.error && r.add(n.error), !e.includes(ue) && (e.includes(de) || t.write(`${e.replace(/\n\s+at .*/g, "")}\n`));
158
173
  },
159
174
  clearScreen() {},
160
175
  hasErrorLogged(e) {
@@ -165,7 +180,7 @@ function P(e, t, n = !1) {
165
180
  }
166
181
  //#endregion
167
182
  //#region src/adapter/vite/unsupported.mts
168
- var ue = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, de = [{
183
+ var fe = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, pe = [{
169
184
  code: "ERR_INCA_UNSUPPORTED_STYLE",
170
185
  name: "a <style> block",
171
186
  matches: (e) => e.includes("vue&type=style"),
@@ -173,10 +188,10 @@ var ue = /\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/, de = [{
173
188
  }, {
174
189
  code: "ERR_INCA_UNSUPPORTED_STYLESHEET",
175
190
  name: "a stylesheet import",
176
- matches: (e) => ue.test(e),
191
+ matches: (e) => fe.test(e),
177
192
  hint: "the renderer applies no stylesheet — use a :style binding instead"
178
193
  }];
179
- function F(e = de) {
194
+ function I(e = pe) {
180
195
  return {
181
196
  name: "inca:reject-unsupported",
182
197
  enforce: "pre",
@@ -184,33 +199,33 @@ function F(e = de) {
184
199
  let r = e.find((e) => e.matches(n));
185
200
  if (!r) return null;
186
201
  let i = a.relative(process.cwd(), n.split("?")[0] ?? n);
187
- throw new w(r.code, `${r.code}: ${i} uses ${r.name}, unsupported for now: ${r.hint}`);
202
+ throw new T(r.code, `${r.code}: ${i} uses ${r.name}, unsupported for now: ${r.hint}`);
188
203
  }
189
204
  };
190
205
  }
191
206
  //#endregion
192
207
  //#region src/adapter/vite/config.mts
193
- var fe = "bundle.js";
194
- function I({ entry: e, outDir: t, mode: n, watch: r, onOutput: i, stdout: o, stderr: s, quiet: c, runtimeConfig: l }) {
208
+ var me = "bundle.js";
209
+ function L({ entry: e, outDir: t, mode: n, watch: r, onOutput: i, stdout: o, stderr: s, quiet: c, runtimeConfig: l }) {
195
210
  return {
196
211
  configFile: !1,
197
212
  root: a.dirname(e),
198
213
  mode: n,
199
214
  clearScreen: !1,
200
215
  logLevel: c ? "silent" : "info",
201
- customLogger: P(o, s),
216
+ customLogger: F(o, s),
202
217
  define: { "process.env.NODE_ENV": JSON.stringify(n) },
203
218
  plugins: [
204
219
  x({ template: { compilerOptions: { runtimeModuleName: "@vue/runtime-core" } } }),
205
- F(),
206
- se(l),
207
- oe(i)
220
+ I(),
221
+ le(l),
222
+ ce(i)
208
223
  ],
209
224
  build: {
210
225
  lib: {
211
226
  entry: e,
212
227
  formats: ["es"],
213
- fileName: () => fe
228
+ fileName: () => me
214
229
  },
215
230
  outDir: t,
216
231
  emptyOutDir: n === "production",
@@ -225,9 +240,9 @@ function I({ entry: e, outDir: t, mode: n, watch: r, onOutput: i, stdout: o, std
225
240
  }
226
241
  //#endregion
227
242
  //#region src/adapter/vite/build.mts
228
- async function pe({ entry: e, outDir: t, runtimeConfig: n, stdout: r = process.stdout, stderr: i = process.stderr, quiet: a = !1 }) {
243
+ async function he({ entry: e, outDir: t, runtimeConfig: n, stdout: r = process.stdout, stderr: i = process.stderr, quiet: a = !1 }) {
229
244
  let o;
230
- if (await v(I({
245
+ if (await v(L({
231
246
  entry: e,
232
247
  outDir: t,
233
248
  runtimeConfig: n,
@@ -237,17 +252,17 @@ async function pe({ entry: e, outDir: t, runtimeConfig: n, stdout: r = process.s
237
252
  stderr: i,
238
253
  quiet: a,
239
254
  onOutput: (e) => {
240
- o = j(t, e);
255
+ o = M(t, e);
241
256
  }
242
- })), !o) throw new w("ERR_INCA_BUILD_NO_OUTPUT", "build produced no output");
257
+ })), !o) throw new T("ERR_INCA_BUILD_NO_OUTPUT", "build produced no output");
243
258
  return o;
244
259
  }
245
260
  //#endregion
246
261
  //#region src/adapter/vite/hmr.mts
247
- function L(e) {
262
+ function R(e) {
248
263
  return a.join(e, "node_modules/.inca/hmr");
249
264
  }
250
- function me() {
265
+ function ge() {
251
266
  let e = a.dirname(g(import.meta.url));
252
267
  for (; !o(a.join(e, "package.json"));) {
253
268
  let t = a.dirname(e);
@@ -256,34 +271,34 @@ function me() {
256
271
  }
257
272
  return a.join(e, "dist/hmr-runtime.js");
258
273
  }
259
- function he(e, t) {
274
+ function _e(e, t) {
260
275
  let n = a.relative(e, t).split(a.sep).join("/");
261
276
  return n.startsWith(".") ? n : `./${n}`;
262
277
  }
263
- async function ge(e, t, n) {
264
- let r = L(e);
278
+ async function ve(e, t, n) {
279
+ let r = R(e);
265
280
  await u(r, { recursive: !0 });
266
- let i = a.join(r, "entry.js"), o = he(r, n ?? me()), s = t.split(a.sep).join("/");
281
+ let i = a.join(r, "entry.js"), o = _e(r, n ?? ge()), s = t.split(a.sep).join("/");
267
282
  return await m(i, `import { start } from ${JSON.stringify(o)};\nstart(${JSON.stringify(s)}).catch((err) => console.error(err));\n`), i;
268
283
  }
269
- function _e(e) {
284
+ function ye(e) {
270
285
  if (e.type === "error") return e.err;
271
286
  if (e.type === "custom" && e.event === "vite:invoke") return e.data?.data?.error;
272
287
  }
273
- function ve(e) {
288
+ function be(e) {
274
289
  if (e.type !== "custom" || e.event !== "vite:invoke") return !1;
275
290
  let t = e.data;
276
291
  return t.name === "fetchModule" && !t.data?.error;
277
292
  }
278
- function ye(e, t, n, r, i) {
293
+ function xe(e, t, n, r, i) {
279
294
  let a = /* @__PURE__ */ new Map(), o = { send: s };
280
295
  function s(a) {
281
296
  if (a.type === "full-reload") {
282
297
  t();
283
298
  return;
284
299
  }
285
- let o = _e(a);
286
- o ? (n(o), i.current = void 0) : ve(a) && i.current && (r({
300
+ let o = ye(a);
301
+ o ? (n(o), i.current = void 0) : be(a) && i.current && (r({
287
302
  file: i.current.file,
288
303
  took: Date.now() - i.current.at
289
304
  }), i.current = void 0), e(a);
@@ -305,7 +320,7 @@ function ye(e, t, n, r, i) {
305
320
  }
306
321
  };
307
322
  }
308
- function be() {
323
+ function Se() {
309
324
  let e = "\0inca:vite-client-shim";
310
325
  return {
311
326
  name: "inca:shim-vite-client",
@@ -318,7 +333,7 @@ function be() {
318
333
  }
319
334
  };
320
335
  }
321
- function xe(e) {
336
+ function Ce(e) {
322
337
  return {
323
338
  name: "inca:file-changed",
324
339
  hotUpdate(t) {
@@ -333,16 +348,16 @@ function xe(e) {
333
348
  }
334
349
  };
335
350
  }
336
- async function Se({ 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 = () => {} }) {
337
- let f = await ge(t, e, r), p = N(n);
338
- p && await m(a.join(L(t), M), p);
339
- let h = { current: void 0 }, { channel: g, dispatch: v } = ye(c, l, u, d, h), y = await b({
351
+ async function we({ 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 = () => {} }) {
352
+ let f = await ve(t, e, r), p = P(n);
353
+ p && await m(a.join(R(t), N), p);
354
+ let h = { current: void 0 }, { channel: g, dispatch: v } = xe(c, l, u, d, h), y = await b({
340
355
  configFile: !1,
341
356
  root: a.dirname(e),
342
357
  mode: "development",
343
358
  clearScreen: !1,
344
359
  logLevel: s ? "silent" : "info",
345
- customLogger: P(i, o, s),
360
+ customLogger: F(i, o, s),
346
361
  define: { "process.env.NODE_ENV": JSON.stringify("development") },
347
362
  server: {
348
363
  middlewareMode: !0,
@@ -361,9 +376,9 @@ async function Se({ entry: e, cwd: t, runtimeConfig: n, runtimePath: r, stdout:
361
376
  } },
362
377
  plugins: [
363
378
  x({ template: { compilerOptions: { runtimeModuleName: "@vue/runtime-core" } } }),
364
- F(),
365
- be(),
366
- xe(h)
379
+ I(),
380
+ Se(),
381
+ Ce(h)
367
382
  ]
368
383
  });
369
384
  return {
@@ -374,44 +389,44 @@ async function Se({ entry: e, cwd: t, runtimeConfig: n, runtimePath: r, stdout:
374
389
  }
375
390
  //#endregion
376
391
  //#region src/dev-client/hostBin.mts
377
- var R = "INCA_HOST_BIN";
378
- function z() {
392
+ var z = "INCA_HOST_BIN";
393
+ function B() {
379
394
  let e = process.platform === "darwin" || process.platform === "linux" ? process.platform : void 0, t = process.arch === "arm64" || process.arch === "x64" ? process.arch : void 0;
380
395
  return e && t ? `@incajs/host-${e}-${t}` : void 0;
381
396
  }
382
- function Ce() {
383
- let e = z();
397
+ function Te() {
398
+ let e = B();
384
399
  if (e) try {
385
400
  return S(import.meta.url).resolve(`${e}/bin/inca-host`);
386
401
  } catch {
387
402
  return;
388
403
  }
389
404
  }
390
- function B() {
391
- let e = process.env[R];
405
+ function V() {
406
+ let e = process.env[z];
392
407
  if (e) return e;
393
- let t = Ce();
408
+ let t = Te();
394
409
  if (t) return t;
395
- let n = z();
396
- throw new w("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 ${R} isn't set to one`);
410
+ let n = B();
411
+ throw new T("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 ${z} isn't set to one`);
397
412
  }
398
413
  //#endregion
399
414
  //#region src/dev-client/hostError.mts
400
- var V = class extends Error {
415
+ var H = class extends Error {
401
416
  code;
402
417
  hostStack;
403
418
  constructor(e, t, n = null) {
404
419
  super(e), this.code = t, this.hostStack = n, this.name = "HostError";
405
420
  }
406
421
  };
407
- function we(e) {
422
+ function Ee(e) {
408
423
  return typeof e == "object" && !!e && e.jsonrpc === "2.0";
409
424
  }
410
425
  //#endregion
411
426
  //#region src/dev-client/hostClient.mts
412
- var Te = (e) => {
427
+ var De = (e) => {
413
428
  process.stderr.write(e.endsWith("\n") ? e : `${e}\n`);
414
- }, Ee = class {
429
+ }, Oe = -32e3, ke = class {
415
430
  #e;
416
431
  #t;
417
432
  #n = 1;
@@ -421,22 +436,22 @@ var Te = (e) => {
421
436
  this.#e = e;
422
437
  }
423
438
  async start() {
424
- let e = this.#e.hostBin ?? B(), t = ee(e, ["--dev", this.#e.entryFile], { stdio: [
439
+ let e = this.#e.hostBin ?? V(), t = C(e, ["--dev", this.#e.entryFile], { stdio: [
425
440
  "pipe",
426
441
  "pipe",
427
442
  "pipe"
428
443
  ] });
429
444
  this.#t = t;
430
- let n = this.#e.onStderr ?? Te;
445
+ let n = this.#e.onStderr ?? De;
431
446
  t.stderr.setEncoding("utf8"), t.stderr.on("data", (e) => n(e)), t.stdin.on("error", (e) => {
432
447
  e.code !== "EPIPE" && n(`inca-host stdin: ${e.message}\n`);
433
- }), te.createInterface({ input: t.stdout }).on("line", (e) => {
448
+ }), ee.createInterface({ input: t.stdout }).on("line", (e) => {
434
449
  this.#a(e, n);
435
450
  }), t.on("exit", (e, t) => {
436
451
  let n = /* @__PURE__ */ Error(`inca-host exited (code=${String(e)}, signal=${String(t)}) before answering`);
437
452
  for (let { reject: e } of this.#r.values()) e(n);
438
453
  this.#r.clear(), this.#i || this.#e.onExit?.(e, t);
439
- }), await C(t, "spawn");
454
+ }), await w(t, "spawn");
440
455
  }
441
456
  #a(e, t) {
442
457
  let n;
@@ -446,7 +461,7 @@ var Te = (e) => {
446
461
  t(`[stray stdout] ${e}`);
447
462
  return;
448
463
  }
449
- if (!we(n)) {
464
+ if (!Ee(n)) {
450
465
  t(`[stray stdout] ${e}`);
451
466
  return;
452
467
  }
@@ -454,8 +469,17 @@ var Te = (e) => {
454
469
  this.#o(n.method, n.params, t);
455
470
  return;
456
471
  }
472
+ if (n.id === null) {
473
+ if (!("error" in n)) return;
474
+ let { code: e, message: r, data: i } = n.error;
475
+ e === Oe ? this.#e.onAppError?.({
476
+ message: r,
477
+ stack: i?.stack ?? null
478
+ }) : t(`[host error ${String(e)}] ${r}`);
479
+ return;
480
+ }
457
481
  let r = this.#r.get(n.id);
458
- r && (this.#r.delete(n.id), "error" in n ? r.reject(new V(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
482
+ r && (this.#r.delete(n.id), "error" in n ? r.reject(new H(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
459
483
  }
460
484
  #o(e, t, n) {
461
485
  switch (e) {
@@ -478,8 +502,7 @@ var Te = (e) => {
478
502
  }
479
503
  }
480
504
  async #s(e) {
481
- this.#i = !0;
482
- let t = C(e, "exit");
505
+ let t = w(e, "exit");
483
506
  e.kill(), await t;
484
507
  }
485
508
  async call(e, t, n) {
@@ -520,35 +543,35 @@ var Te = (e) => {
520
543
  let t = this.#t;
521
544
  if (!t || t.exitCode !== null || t.signalCode !== null) return;
522
545
  this.#i = !0;
523
- let n = C(t, "exit");
524
- this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), ne(e).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
546
+ let n = w(t, "exit");
547
+ this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), te(e).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
525
548
  }
526
- }, De = "[inca]", Oe = new Intl.DateTimeFormat(void 0, {
549
+ }, Ae = "[inca]", je = new Intl.DateTimeFormat(void 0, {
527
550
  hour: "numeric",
528
551
  minute: "numeric",
529
552
  second: "numeric"
530
553
  });
531
- function H(e, t, n) {
532
- let r = h(["bold", n], De, { stream: e });
533
- return t.timestamp ? `${h("dim", Oe.format(/* @__PURE__ */ new Date()), { stream: e })} ${r}` : r;
554
+ function U(e, t, n) {
555
+ let r = h(["bold", n], Ae, { stream: e });
556
+ return t.timestamp ? `${h("dim", je.format(/* @__PURE__ */ new Date()), { stream: e })} ${r}` : r;
534
557
  }
535
- function U(e, t, n = {}) {
536
- e.write(`${H(e, n, "cyan")} ${t}\n`);
558
+ function W(e, t, n = {}) {
559
+ e.write(`${U(e, n, "cyan")} ${t}\n`);
537
560
  }
538
- function W(e) {
561
+ function G(e) {
539
562
  let t = e.code;
540
563
  return typeof t == "string" ? t : null;
541
564
  }
542
- function ke(e) {
565
+ function Me(e) {
543
566
  return /\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0] ?? null;
544
567
  }
545
- function Ae(e) {
568
+ function Ne(e) {
546
569
  let t = e.stack;
547
570
  if (!t) return null;
548
571
  for (let n of [`${e.name}: ${e.message}`, e.message]) if (t.startsWith(n)) return t.slice(n.length).replace(/^\r?\n/, "") || null;
549
572
  return t;
550
573
  }
551
- function je(e) {
574
+ function Pe(e) {
552
575
  let t = /^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);
553
576
  return t ? {
554
577
  message: e.slice(t[0].length),
@@ -560,40 +583,40 @@ function je(e) {
560
583
  code: null
561
584
  };
562
585
  }
563
- function G(e) {
564
- return e instanceof V ? {
586
+ function K(e) {
587
+ return e instanceof H ? {
565
588
  message: e.message,
566
589
  stack: e.hostStack,
567
- code: W(e)
590
+ code: G(e)
568
591
  } : e instanceof Error ? {
569
592
  message: e.message,
570
- stack: Ae(e),
571
- code: W(e) ?? ke(e.message)
593
+ stack: Ne(e),
594
+ code: G(e) ?? Me(e.message)
572
595
  } : {
573
596
  message: String(e),
574
597
  stack: null,
575
598
  code: null
576
599
  };
577
600
  }
578
- function Me(e, t) {
601
+ function Fe(e, t) {
579
602
  return e.split("\n").map((e) => /^\s*at\b/.test(e) ? h("dim", e, { stream: t }) : e).join("\n");
580
603
  }
581
- function K(e, t, n, r = {}) {
582
- n.stack && e.write(`${Me(n.stack, e)}\n`);
604
+ function q(e, t, n, r = {}) {
605
+ n.stack && e.write(`${Fe(n.stack, e)}\n`);
583
606
  let i = n.code ? ` (${h("bold", n.code, { stream: e })})` : "";
584
- e.write(`${H(e, r, "red")} ${t}${i}: ${n.message}\n`);
607
+ e.write(`${U(e, r, "red")} ${t}${i}: ${n.message}\n`);
585
608
  }
586
609
  //#endregion
587
610
  //#region src/adapter/vite/watch.mts
588
- async function Ne({ onBuild: e, onError: t, stdout: n = process.stdout, stderr: r = process.stderr, quiet: i = !1, ...a }) {
589
- let { outDir: o } = a, s, c = await v(I({
611
+ async function Ie({ onBuild: e, onError: t, stdout: n = process.stdout, stderr: r = process.stderr, quiet: i = !1, ...a }) {
612
+ let { outDir: o } = a, s, c = await v(L({
590
613
  ...a,
591
614
  watch: !0,
592
615
  stdout: n,
593
616
  stderr: r,
594
617
  quiet: i,
595
618
  onOutput: (t) => {
596
- e(j(o, t, s)), s = void 0;
619
+ e(M(o, t, s)), s = void 0;
597
620
  }
598
621
  }));
599
622
  return c.on("change", (e) => {
@@ -605,26 +628,26 @@ async function Ne({ onBuild: e, onError: t, stdout: n = process.stdout, stderr:
605
628
  if (e.code !== "ERROR") return;
606
629
  s = void 0;
607
630
  let { errors: n } = e.error;
608
- t(je(n?.[0]?.message ?? e.error.message));
631
+ t(Pe(n?.[0]?.message ?? e.error.message));
609
632
  }), { close: () => c.close() };
610
633
  }
611
634
  //#endregion
612
635
  //#region src/defaultBundler.mts
613
- var q = {
614
- watch: Ne,
615
- build: pe,
616
- hmr: Se
636
+ var J = {
637
+ watch: Ie,
638
+ build: he,
639
+ hmr: we
617
640
  };
618
641
  //#endregion
619
642
  //#region src/entry.mts
620
- async function J(e) {
643
+ async function Y(e) {
621
644
  let t = a.join(e, "src/main.mts");
622
645
  if (o(t)) return t;
623
646
  let n = a.join(e, "src/App.vue");
624
- if (o(n)) return Pe(n, e);
625
- throw new w("ERR_INCA_ENTRY_NOT_FOUND", `no app entry found — expected ${t} or ${n}`);
647
+ if (o(n)) return Le(n, e);
648
+ throw new T("ERR_INCA_ENTRY_NOT_FOUND", `no app entry found — expected ${t} or ${n}`);
626
649
  }
627
- async function Pe(e, t) {
650
+ async function Le(e, t) {
628
651
  let n = a.join(t, "node_modules/.inca");
629
652
  await u(n, { recursive: !0 });
630
653
  let r = a.join(n, "entry.mts"), i = JSON.stringify(e.split(a.sep).join("/"));
@@ -632,8 +655,8 @@ async function Pe(e, t) {
632
655
  }
633
656
  //#endregion
634
657
  //#region src/build.mts
635
- async function Y(e = {}) {
636
- let t = e.cwd ?? process.cwd(), n = e.config ?? await D(t), r = n.outDir, i = e.bundler ?? q, a = e.entry ?? n.entry ?? await J(t), o = e.runtimeConfig ?? await A(t);
658
+ async function X(e = {}) {
659
+ let t = e.cwd ?? process.cwd(), n = e.config ?? await k(t), r = n.outDir, i = e.bundler ?? J, a = e.entry ?? n.entry ?? await Y(t), o = e.runtimeConfig ?? await se(t);
637
660
  return i.build({
638
661
  entry: a,
639
662
  outDir: r,
@@ -644,41 +667,41 @@ async function Y(e = {}) {
644
667
  }
645
668
  //#endregion
646
669
  //#region src/dev-lock.mts
647
- function Fe(e) {
670
+ function Re(e) {
648
671
  return a.join(e, "node_modules/.inca/dev.pid");
649
672
  }
650
- function Ie(e) {
673
+ function ze(e) {
651
674
  try {
652
675
  return process.kill(e, 0), !0;
653
676
  } catch (e) {
654
677
  return e.code === "EPERM";
655
678
  }
656
679
  }
657
- async function Le(e) {
658
- let t = Fe(e), n = Number.parseInt(await d(t, "utf8").catch(() => ""), 10);
659
- if (Number.isInteger(n) && Ie(n)) throw new w("ERR_INCA_DEV_RUNNING", `inca dev is already running for this app (pid ${String(n)})`);
680
+ async function Be(e) {
681
+ let t = Re(e), n = Number.parseInt(await d(t, "utf8").catch(() => ""), 10);
682
+ if (Number.isInteger(n) && ze(n)) throw new T("ERR_INCA_DEV_RUNNING", `inca dev is already running for this app (pid ${String(n)})`);
660
683
  return await u(a.dirname(t), { recursive: !0 }), await m(t, String(process.pid)), () => p(t, { force: !0 });
661
684
  }
662
685
  //#endregion
663
686
  //#region src/plist.mts
664
- function X(e) {
687
+ function Z(e) {
665
688
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
666
689
  }
667
- function Re(e) {
668
- return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${X(e)}</string>`;
690
+ function Ve(e) {
691
+ return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${Z(e)}</string>`;
669
692
  }
670
- function ze(e) {
693
+ function He(e) {
671
694
  return `<?xml version="1.0" encoding="UTF-8"?>
672
695
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
673
696
  <plist version="1.0">
674
697
  <dict>
675
- ${Object.entries(e).map(([e, t]) => `\t<key>${X(e)}</key>\n\t${Re(t)}`).join("\n")}\n</dict>
698
+ ${Object.entries(e).map(([e, t]) => `\t<key>${Z(e)}</key>\n\t${Ve(t)}`).join("\n")}\n</dict>
676
699
  </plist>
677
700
  `;
678
701
  }
679
702
  //#endregion
680
703
  //#region src/macos-app.mts
681
- async function Z(e) {
704
+ async function Q(e) {
682
705
  let { appPath: t, metadata: n, hostBin: r } = e;
683
706
  await p(t, {
684
707
  recursive: !0,
@@ -703,7 +726,7 @@ async function Z(e) {
703
726
  let e = a.basename(n.icon);
704
727
  await c(n.icon, a.join(d, e)), h.CFBundleIconFile = e;
705
728
  }
706
- return await m(a.join(i, "Info.plist"), ze(h)), await m(a.join(i, "PkgInfo"), "APPL????"), {
729
+ return await m(a.join(i, "Info.plist"), He(h)), await m(a.join(i, "PkgInfo"), "APPL????"), {
707
730
  appPath: t,
708
731
  executablePath: f,
709
732
  resourcesDir: d
@@ -711,30 +734,30 @@ async function Z(e) {
711
734
  }
712
735
  //#endregion
713
736
  //#region src/dev.mts
714
- var Q = { timestamp: !0 }, Be = 1e4, Ve = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
715
- async function He(e, t) {
737
+ var $ = { timestamp: !0 }, Ue = 1e4, We = ["ERR_INCA_PACKAGE_JSON_NOT_FOUND", "ERR_INCA_PRODUCT_NAME_MISSING"];
738
+ async function Ge(e, t) {
716
739
  try {
717
- return await O(e);
740
+ return await A(e);
718
741
  } catch (e) {
719
- if (!(e instanceof w) || !Ve.includes(e.code)) throw e;
720
- U(t, `running unnamed — ${e.message}`, Q);
742
+ if (!(e instanceof T) || !We.includes(e.code)) throw e;
743
+ W(t, `running unnamed — ${e.message}`, $);
721
744
  return;
722
745
  }
723
746
  }
724
- async function Ue(e, t, n, r) {
747
+ async function Ke(e, t, n, r) {
725
748
  if (process.platform === "darwin" && t) try {
726
- return (await Z({
749
+ return (await Q({
727
750
  appPath: a.join(e, "node_modules/.inca", `${t.productName}.app`),
728
751
  metadata: t,
729
- hostBin: n ?? B(),
752
+ hostBin: n ?? V(),
730
753
  link: !0
731
754
  })).executablePath;
732
755
  } catch (e) {
733
- U(r, `running unbundled — ${G(e).message}`, Q);
756
+ W(r, `running unbundled — ${K(e).message}`, $);
734
757
  return;
735
758
  }
736
759
  }
737
- function We(e) {
760
+ function qe(e) {
738
761
  let t = y(e, [], !1), n = [e.stack, t].filter((e) => e).join("\n");
739
762
  return {
740
763
  message: e.message,
@@ -742,7 +765,7 @@ function We(e) {
742
765
  code: null
743
766
  };
744
767
  }
745
- async function Ge(e, t) {
768
+ async function Je(e, t) {
746
769
  let n = new Set(t), r;
747
770
  try {
748
771
  r = await f(e, {
@@ -754,58 +777,58 @@ async function Ge(e, t) {
754
777
  }
755
778
  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) => p(a.join(e, t), { force: !0 })));
756
779
  }
757
- async function Ke(e) {
758
- let t = e.cwd ?? process.cwd(), n = await D(t), r = await Le(t);
780
+ async function Ye(e) {
781
+ let t = e.cwd ?? process.cwd(), n = await k(t), r = await Be(t);
759
782
  try {
760
- let r = n.outDir, i = e.bundler ?? q, o = e.stdout ?? process.stdout, s = e.stderr ?? process.stderr, c = e.entry ?? n.entry ?? await J(t), l = await He(t, o), u = l ? k(l) : await A(t), d = await Ue(t, l, e.hostBin, o) ?? e.hostBin, f, p = !1, m = !1, g = Promise.resolve(), _ = () => {}, v = new Promise((e) => {
761
- _ = e;
783
+ let r = n.outDir, i = e.bundler ?? J, o = e.stdout ?? process.stdout, s = e.stderr ?? process.stderr, c = e.entry ?? n.entry ?? await Y(t), l = await Ge(t, o), u = l ? j(l) : await se(t), d = await Ke(t, l, e.hostBin, o) ?? e.hostBin, f, p = !1, m = !1, g = !1, _ = Promise.resolve(), v = () => {}, y = new Promise((e) => {
784
+ v = e;
762
785
  });
763
- async function y() {
786
+ async function b() {
764
787
  try {
765
- return await f?.call("reload", void 0, Be), !0;
788
+ return await f?.call("reload", void 0, Ue), !0;
766
789
  } catch (e) {
767
- return K(s, "reload failed", G(e), Q), !1;
790
+ return q(s, "reload failed", K(e), $), !1;
768
791
  }
769
792
  }
770
- async function b(e, t) {
771
- let n = new Ee({
793
+ async function x(e, t) {
794
+ let n = new ke({
772
795
  entryFile: e,
773
796
  hostBin: d,
774
797
  onStderr: (e) => s.write(e),
775
798
  onReady: () => {
776
- p = !0, U(o, "ready", Q), m && (m = !1, y());
799
+ p = !0, W(o, "ready", $), m && (m = !1, b());
777
800
  },
778
- onAppError: (e) => K(s, "app error", e, Q),
801
+ onAppError: (e) => q(s, "app error", e, $),
779
802
  onExit: () => {
780
- U(o, "host exited — stopping", Q), _();
803
+ g = !p, W(o, "host exited — stopping", $), v();
781
804
  },
782
805
  integrations: t
783
806
  });
784
807
  try {
785
808
  await n.start();
786
809
  } catch (e) {
787
- K(s, "failed to start inca-host", G(e), Q);
810
+ q(s, "failed to start inca-host", K(e), $);
788
811
  return;
789
812
  }
790
813
  f = n;
791
814
  }
792
- async function x(e) {
793
- if (await Ge(e.outDir, e.files), !f) {
794
- await b(e.entryFile);
815
+ async function S(e) {
816
+ if (await Je(e.outDir, e.files), !f) {
817
+ await x(e.entryFile);
795
818
  return;
796
819
  }
797
820
  if (!p) {
798
821
  m = !0;
799
822
  return;
800
823
  }
801
- if (await y() && e.changed) {
824
+ if (await b() && e.changed) {
802
825
  let n = h("dim", a.relative(t, e.changed.file), { stream: o }), r = Date.now() - e.changed.at;
803
- U(o, `${h("green", "reload")} ${n} (${r}ms)`, Q);
826
+ W(o, `${h("green", "reload")} ${n} (${r}ms)`, $);
804
827
  }
805
828
  }
806
- let S;
829
+ let C;
807
830
  if (e.experimentalHmr) {
808
- if (!i.hmr) throw new w("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
831
+ if (!i.hmr) throw new T("ERR_INCA_HMR_UNSUPPORTED", "--experimental-hmr was set, but the configured bundler has no HMR support");
809
832
  let e = await i.hmr({
810
833
  entry: c,
811
834
  cwd: t,
@@ -813,15 +836,15 @@ async function Ke(e) {
813
836
  stdout: o,
814
837
  stderr: s,
815
838
  notify: (e) => f?.notify("vite", e),
816
- reload: () => void y(),
817
- onError: (e) => K(s, "build failed", We(e), Q),
839
+ reload: () => void b(),
840
+ onError: (e) => q(s, "build failed", qe(e), $),
818
841
  onUpdate: ({ file: e, took: n }) => {
819
842
  let r = h("dim", a.relative(t, e), { stream: o });
820
- U(o, `${h("green", "update")} ${r} (${n}ms)`, Q);
843
+ W(o, `${h("green", "update")} ${r} (${n}ms)`, $);
821
844
  }
822
845
  });
823
- await b(e.entryFile, { vite: (t) => e.dispatch(t) }), S = e, f || _();
824
- } else S = await i.watch({
846
+ await x(e.entryFile, { vite: (t) => e.dispatch(t) }), C = e, f || v();
847
+ } else C = await i.watch({
825
848
  entry: c,
826
849
  outDir: r,
827
850
  runtimeConfig: u,
@@ -829,99 +852,105 @@ async function Ke(e) {
829
852
  stdout: o,
830
853
  stderr: s,
831
854
  onBuild: (e) => {
832
- g = g.then(() => x(e));
855
+ _ = _.then(() => S(e));
833
856
  },
834
857
  onError: (e) => {
835
- K(s, "build failed", e, Q);
858
+ q(s, "build failed", e, $);
836
859
  }
837
860
  });
838
- e.signal.aborted ? _() : e.signal.addEventListener("abort", () => _(), { once: !0 }), await v, await g, await f?.stop(), await S.close();
861
+ if (e.signal.aborted ? v() : e.signal.addEventListener("abort", () => v(), { once: !0 }), await y, await _, await f?.stop(), await C.close(), g) throw new T("ERR_INCA_HOST_EXITED_EARLY", "the host exited before it was ready");
839
862
  } finally {
840
863
  await r();
841
864
  }
842
865
  }
843
866
  //#endregion
844
867
  //#region src/package.mts
845
- function qe() {
868
+ function Xe() {
846
869
  if (process.platform === "darwin") return "macos";
847
870
  if (process.platform === "linux") return "linux";
848
- throw new w("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
871
+ throw new T("ERR_INCA_PLATFORM_UNSUPPORTED", `inca package doesn't support ${process.platform} yet`);
849
872
  }
850
- async function $(e, t) {
873
+ async function Ze(e, t) {
851
874
  await Promise.all(e.files.map(async (n) => {
852
875
  let r = a.join(t, n);
853
876
  await u(a.dirname(r), { recursive: !0 }), await c(a.join(e.outDir, n), r);
854
877
  }));
855
878
  }
856
- async function Je({ metadata: e, output: t, hostBin: n }) {
857
- let { appPath: r, resourcesDir: i } = await Z({
879
+ function Qe(e, t) {
880
+ let n = e.files.map((e) => e.split("/")[0] ?? e).find((e) => e.toLowerCase() === t.toLowerCase());
881
+ if (n !== void 0) throw new T("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`);
882
+ }
883
+ async function $e({ metadata: e, output: t, hostBin: n }) {
884
+ let { appPath: r, resourcesDir: i } = await Q({
858
885
  appPath: a.join(t.outDir, `${e.productName}.app`),
859
886
  metadata: e,
860
887
  hostBin: n
861
888
  });
862
- return await $(t, i), r;
889
+ return await Ze(t, i), r;
863
890
  }
864
- async function Ye({ metadata: t, output: n, hostBin: r }) {
865
- let i = e(t.productName), o = a.join(n.outDir, i);
891
+ async function et({ metadata: t, output: n, hostBin: r }) {
892
+ let i = e(t.productName);
893
+ Qe(n, i);
894
+ let o = a.join(n.outDir, i);
866
895
  await p(o, {
867
896
  recursive: !0,
868
897
  force: !0
869
898
  }), await u(o, { recursive: !0 });
870
899
  let l = a.join(o, i);
871
- return await c(r, l), await s(l, 493), await $(n, o), o;
900
+ return await c(r, l), await s(l, 493), await Ze(n, o), o;
872
901
  }
873
- async function Xe(e = {}) {
874
- let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? qe(), i = await O(t);
875
- i.usedPackageJsonKey && U(n, "the \"inca\" key in package.json is deprecated — move these settings to inca.config.ts"), i.identifierIsDefault && U(n, `no "identifier" set in inca.config.ts — using generated identifier ${i.identifier}`);
876
- let a = await Y({
902
+ async function tt(e = {}) {
903
+ let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? Xe(), i = await A(t);
904
+ i.usedPackageJsonKey && W(n, "the \"inca\" key in package.json is deprecated — move these settings to inca.config.ts"), i.identifierIsDefault && W(n, `no "identifier" set in inca.config.ts — using generated identifier ${i.identifier}`);
905
+ let a = await X({
877
906
  cwd: t,
878
907
  entry: e.entry,
879
908
  config: i,
880
- runtimeConfig: k(i),
909
+ runtimeConfig: j(i),
881
910
  bundler: e.bundler,
882
911
  stdout: n,
883
912
  stderr: e.stderr
884
- }), s = e.hostBin ?? B();
885
- if (!o(s)) throw new w("ERR_INCA_HOST_BIN_NOT_FOUND", `no host binary at ${s} — check that it was built and is executable`);
913
+ }), s = e.hostBin ?? V();
914
+ if (!o(s)) throw new T("ERR_INCA_HOST_BIN_NOT_FOUND", `no host binary at ${s} — check that it was built and is executable`);
886
915
  let c = {
887
916
  metadata: i,
888
917
  output: a,
889
918
  hostBin: s
890
919
  };
891
- return { appPath: r === "macos" ? await Je(c) : await Ye(c) };
920
+ return { appPath: r === "macos" ? await $e(c) : await et(c) };
892
921
  }
893
922
  //#endregion
894
923
  //#region src/cli.mts
895
- var Ze = "Usage: inca <dev|build|package>";
896
- function Qe(e) {
924
+ var nt = "Usage: inca <dev|build|package>";
925
+ function rt(e) {
897
926
  return a.relative(process.cwd(), e);
898
927
  }
899
- async function $e(e = process.argv) {
928
+ async function it(e = process.argv) {
900
929
  let t = e[2];
901
930
  if (t === "build") {
902
931
  try {
903
- let e = await Y();
904
- U(process.stdout, `built ${Qe(e.entryFile)}`);
932
+ let e = await X();
933
+ W(process.stdout, `built ${rt(e.entryFile)}`);
905
934
  } catch (e) {
906
- K(process.stderr, "build failed", G(e)), process.exitCode = 1;
935
+ q(process.stderr, "build failed", K(e)), process.exitCode = 1;
907
936
  }
908
937
  return;
909
938
  }
910
939
  if (t === "package") {
911
940
  try {
912
- let { appPath: e } = await Xe();
913
- U(process.stdout, `packaged ${Qe(e)}`);
941
+ let { appPath: e } = await tt();
942
+ W(process.stdout, `packaged ${rt(e)}`);
914
943
  } catch (e) {
915
- K(process.stderr, "package failed", G(e)), process.exitCode = 1;
944
+ q(process.stderr, "package failed", K(e)), process.exitCode = 1;
916
945
  }
917
946
  return;
918
947
  }
919
948
  if (t !== "dev") {
920
- process.stderr.write(`${Ze}\n`), process.exitCode = 1;
949
+ process.stderr.write(`${nt}\n`), process.exitCode = 1;
921
950
  return;
922
951
  }
923
952
  let n = new AbortController(), r = () => {
924
- n.signal.aborted || (U(process.stderr, "shutting down", { timestamp: !0 }), n.abort());
953
+ n.signal.aborted || (W(process.stderr, "shutting down", { timestamp: !0 }), n.abort());
925
954
  };
926
955
  process.on("SIGINT", r), process.on("SIGTERM", r);
927
956
  let i = e.includes("--experimental-hmr") || ![
@@ -929,15 +958,15 @@ async function $e(e = process.argv) {
929
958
  "0",
930
959
  "false"
931
960
  ].includes(process.env.INCA_EXPERIMENTAL_HMR ?? "");
932
- i && U(process.stdout, "experimental HMR active", { timestamp: !0 });
961
+ i && W(process.stdout, "experimental HMR active", { timestamp: !0 });
933
962
  try {
934
- await Ke({
963
+ await Ye({
935
964
  signal: n.signal,
936
965
  experimentalHmr: i
937
966
  });
938
967
  } catch (e) {
939
- K(process.stderr, "dev failed", G(e), { timestamp: !0 }), process.exitCode = 1;
968
+ q(process.stderr, "dev failed", K(e), { timestamp: !0 }), process.exitCode = 1;
940
969
  }
941
970
  }
942
971
  //#endregion
943
- export { $e as run };
972
+ export { it as run };
@@ -45,7 +45,8 @@ export declare function resolveBuildConfig(cwd: string): Promise<ResolvedBuildCo
45
45
  * @param cwd - the app's root directory
46
46
  * @returns the resolved config
47
47
  * @throws if `package.json` is missing, has neither a `name` nor a
48
- * `productName`, or an `icon` doesn't resolve to a real file
48
+ * `productName`, an `icon` doesn't resolve to a real file, or `outDir`
49
+ * would hold the app's own files
49
50
  */
50
51
  export declare function resolveAppConfig(cwd: string): Promise<ResolvedAppConfig>;
51
52
  /**
@@ -15,10 +15,10 @@ export interface HostClientOptions {
15
15
  * speaks the protocol revision this package was built for.
16
16
  */
17
17
  onReady?: () => void;
18
- /** An app's own event listener threw; the host caught it and kept rendering. */
18
+ /** An app's event listener threw, or the app threw while the host loaded it. */
19
19
  onAppError?: (error: AppErrorParams) => void;
20
20
  /**
21
- * The host exited on its own — its window was closed, or it crashed.
21
+ * The host exited on its own, or was stopped over a protocol mismatch.
22
22
  * Not called for the exit `stop()` asks for.
23
23
  */
24
24
  onExit?: (code: number | null, signal: NodeJS.Signals | null) => void;
@@ -21,7 +21,8 @@ export interface RpcResult {
21
21
  }
22
22
  export interface RpcFailure {
23
23
  jsonrpc: typeof JSONRPC;
24
- id: number;
24
+ /** `null` when the host fails before any call could be answered. */
25
+ id: number | null;
25
26
  error: {
26
27
  code: number;
27
28
  message: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incajs/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Dev server, bundler, and packager for Incarnative.js apps.",
5
5
  "keywords": [
6
6
  "bundler",
@@ -70,9 +70,9 @@
70
70
  }
71
71
  },
72
72
  "optionalDependencies": {
73
- "@incajs/host-darwin-arm64": "0.0.6",
74
- "@incajs/host-linux-arm64": "0.0.6",
75
- "@incajs/host-linux-x64": "0.0.6"
73
+ "@incajs/host-darwin-arm64": "0.0.7",
74
+ "@incajs/host-linux-arm64": "0.0.7",
75
+ "@incajs/host-linux-x64": "0.0.7"
76
76
  },
77
77
  "engines": {
78
78
  "node": ">=22.18"