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