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