@incajs/cli 0.0.5 → 0.0.6

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