citadel_cli 1.4.1 → 1.4.2
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 +1 -0
- package/dist/citadel.es.js +744 -717
- package/dist/citadel.umd.cjs +6 -6
- package/dist/citadel.umd.js +6 -6
- package/dist/components/Citadel/config/defaults.d.ts +2 -0
- package/dist/components/Citadel/config/types.d.ts +6 -0
- package/dist/examples/runtimeConfigCommands.d.ts +1 -0
- package/package.json +1 -1
package/dist/citadel.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var y = (
|
|
4
|
-
import { jsx as m, jsxs as A, Fragment as
|
|
5
|
-
import
|
|
6
|
-
import { createRoot as
|
|
7
|
-
var
|
|
8
|
-
class
|
|
1
|
+
var Te = Object.defineProperty;
|
|
2
|
+
var Me = (n, e, t) => e in n ? Te(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var y = (n, e, t) => Me(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { jsx as m, jsxs as A, Fragment as Oe } from "react/jsx-runtime";
|
|
5
|
+
import K, { createContext as De, useState as M, useMemo as _, useEffect as I, useContext as re, useCallback as f, useReducer as ze, useRef as R, useLayoutEffect as Fe } from "react";
|
|
6
|
+
import { createRoot as Le } from "react-dom/client";
|
|
7
|
+
var Y = /* @__PURE__ */ ((n) => (n.Pending = "pending", n.Success = "success", n.Failure = "failure", n.Timeout = "timeout", n))(Y || {});
|
|
8
|
+
class W {
|
|
9
9
|
constructor(e = Date.now()) {
|
|
10
10
|
y(this, "_status", "pending");
|
|
11
11
|
this.timestamp = e;
|
|
@@ -23,46 +23,46 @@ class K {
|
|
|
23
23
|
this._status = "timeout";
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
27
|
-
constructor(e,
|
|
28
|
-
super(
|
|
26
|
+
class Ue extends W {
|
|
27
|
+
constructor(e, t) {
|
|
28
|
+
super(t), this.data = e;
|
|
29
29
|
}
|
|
30
30
|
render() {
|
|
31
31
|
return /* @__PURE__ */ m("pre", { className: "citadel-result-json", children: JSON.stringify(this.data, null, 2) });
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
class
|
|
35
|
-
constructor(e,
|
|
36
|
-
super(
|
|
34
|
+
class ee extends W {
|
|
35
|
+
constructor(e, t) {
|
|
36
|
+
super(t), this.text = e;
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
39
|
return /* @__PURE__ */ m("div", { className: "citadel-result-text", children: this.text });
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
class
|
|
43
|
-
constructor(e,
|
|
44
|
-
super(
|
|
42
|
+
class $e extends W {
|
|
43
|
+
constructor(e, t = "true", r = "false", s) {
|
|
44
|
+
super(s), this.value = e, this.trueText = t, this.falseText = r;
|
|
45
45
|
}
|
|
46
46
|
render() {
|
|
47
47
|
return /* @__PURE__ */ m("div", { className: "citadel-result-text citadel-result-boolean", children: this.value ? this.trueText : this.falseText });
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
class
|
|
51
|
-
constructor(e,
|
|
52
|
-
super(
|
|
50
|
+
class be extends W {
|
|
51
|
+
constructor(e, t) {
|
|
52
|
+
super(t), this.error = e, this.markFailure();
|
|
53
53
|
}
|
|
54
54
|
render() {
|
|
55
55
|
return /* @__PURE__ */ m("div", { className: "citadel-result-error", children: this.error });
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
class
|
|
58
|
+
class je extends W {
|
|
59
59
|
render() {
|
|
60
60
|
return /* @__PURE__ */ m("div", { className: "citadel-result-pending", children: "..." });
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
class
|
|
64
|
-
constructor(e,
|
|
65
|
-
super(
|
|
63
|
+
class Ke extends W {
|
|
64
|
+
constructor(e, t = "", r) {
|
|
65
|
+
super(r), this.imageUrl = e, this.altText = t;
|
|
66
66
|
}
|
|
67
67
|
render() {
|
|
68
68
|
return /* @__PURE__ */ m("div", { className: "citadel-result-image-wrap", children: /* @__PURE__ */ m(
|
|
@@ -75,36 +75,36 @@ class Fe extends K {
|
|
|
75
75
|
) });
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
78
|
+
const We = (n) => async function() {
|
|
79
|
+
const t = n.commands.filter((r) => r.fullPath[0] !== "help").map((r) => {
|
|
80
|
+
const a = `${r.segments.map((c) => c.type === "argument" ? `<${c.name}>` : c.name).join(" ")} - ${r.description}`, o = r.segments.filter((c) => c.type === "argument" && c.description).map((c) => ` <${c.name}>: ${c.description}`);
|
|
81
81
|
return {
|
|
82
|
-
commandLine:
|
|
83
|
-
argumentLines:
|
|
82
|
+
commandLine: a,
|
|
83
|
+
argumentLines: o
|
|
84
84
|
};
|
|
85
|
-
}).sort((
|
|
86
|
-
|
|
87
|
-
...
|
|
85
|
+
}).sort((r, s) => r.commandLine.localeCompare(s.commandLine)).flatMap((r) => [
|
|
86
|
+
r.commandLine,
|
|
87
|
+
...r.argumentLines
|
|
88
88
|
]);
|
|
89
|
-
return
|
|
89
|
+
return t.length === 0 ? new ee(
|
|
90
90
|
"No commands available yet. Add some commands to get started!"
|
|
91
|
-
) : (
|
|
91
|
+
) : (t.push("help - Show available commands"), new ee(
|
|
92
92
|
`Available Commands:
|
|
93
|
-
` +
|
|
93
|
+
` + t.join(`
|
|
94
94
|
`)
|
|
95
95
|
));
|
|
96
96
|
};
|
|
97
|
-
var
|
|
98
|
-
const
|
|
99
|
-
class
|
|
97
|
+
var me = /* @__PURE__ */ ((n) => (n[n.NONE = 0] = "NONE", n[n.ERROR = 1] = "ERROR", n[n.WARN = 2] = "WARN", n[n.INFO = 3] = "INFO", n[n.DEBUG = 4] = "DEBUG", n[n.TRACE = 5] = "TRACE", n))(me || {});
|
|
98
|
+
const fe = !0;
|
|
99
|
+
class k {
|
|
100
100
|
static configure(e) {
|
|
101
101
|
this.level = e.level, this.prefix = e.prefix || "[Citadel]";
|
|
102
102
|
}
|
|
103
103
|
static trace(...e) {
|
|
104
|
-
this.level >= 5 && !
|
|
104
|
+
this.level >= 5 && !fe && console.trace(this.prefix, ...e);
|
|
105
105
|
}
|
|
106
106
|
static debug(...e) {
|
|
107
|
-
this.level >= 4 && !
|
|
107
|
+
this.level >= 4 && !fe && console.debug(this.prefix, ...e);
|
|
108
108
|
}
|
|
109
109
|
static info(...e) {
|
|
110
110
|
this.level >= 3 && console.info(this.prefix, ...e);
|
|
@@ -116,8 +116,8 @@ class b {
|
|
|
116
116
|
this.level >= 1 && console.error(this.prefix, ...e);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
y(
|
|
120
|
-
const
|
|
119
|
+
y(k, "level", 0), y(k, "prefix", "");
|
|
120
|
+
const E = {
|
|
121
121
|
commandTimeoutMs: 1e4,
|
|
122
122
|
cursorColor: "var(--cursor-color, #fff)",
|
|
123
123
|
cursorSpeed: 530,
|
|
@@ -126,10 +126,11 @@ const x = {
|
|
|
126
126
|
fontFamily: "monospace",
|
|
127
127
|
fontSize: "0.875rem",
|
|
128
128
|
initialHeight: "50vh",
|
|
129
|
-
logLevel:
|
|
129
|
+
logLevel: me.ERROR,
|
|
130
130
|
maxHeight: "80vh",
|
|
131
131
|
minHeight: "200",
|
|
132
132
|
outputFontSize: "0.875rem",
|
|
133
|
+
showOutputPane: !0,
|
|
133
134
|
resetStateOnHide: !1,
|
|
134
135
|
closeOnEscape: !0,
|
|
135
136
|
showCitadelKey: ".",
|
|
@@ -139,35 +140,35 @@ const x = {
|
|
|
139
140
|
type: "localStorage",
|
|
140
141
|
maxCommands: 100
|
|
141
142
|
}
|
|
142
|
-
},
|
|
143
|
-
class
|
|
144
|
-
constructor(e,
|
|
145
|
-
this.type = e, this.name =
|
|
143
|
+
}, Ee = async () => new ee("");
|
|
144
|
+
class ue {
|
|
145
|
+
constructor(e, t, r) {
|
|
146
|
+
this.type = e, this.name = t, this.description = r;
|
|
146
147
|
}
|
|
147
148
|
toString() {
|
|
148
149
|
return this.name;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
|
-
class
|
|
152
|
+
class pe extends ue {
|
|
152
153
|
constructor() {
|
|
153
154
|
super("null", ">null<", "Empty segment");
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
|
-
class
|
|
157
|
-
constructor(e,
|
|
158
|
-
super("word", e,
|
|
157
|
+
class ke extends ue {
|
|
158
|
+
constructor(e, t) {
|
|
159
|
+
super("word", e, t);
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
|
-
class q extends
|
|
162
|
-
constructor(e,
|
|
163
|
-
super("argument", e,
|
|
162
|
+
class q extends ue {
|
|
163
|
+
constructor(e, t, r, s) {
|
|
164
|
+
super("argument", e, t), this.value = r, this.valid = s;
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
return new
|
|
169
|
-
if (
|
|
170
|
-
const e =
|
|
167
|
+
const qe = (n) => {
|
|
168
|
+
if (n.type === "word")
|
|
169
|
+
return new ke(n.name, n.description);
|
|
170
|
+
if (n.type === "argument") {
|
|
171
|
+
const e = n;
|
|
171
172
|
return new q(
|
|
172
173
|
e.name,
|
|
173
174
|
e.description,
|
|
@@ -175,15 +176,15 @@ const je = (t) => {
|
|
|
175
176
|
e.valid
|
|
176
177
|
);
|
|
177
178
|
}
|
|
178
|
-
return new
|
|
179
|
-
},
|
|
180
|
-
class
|
|
181
|
-
constructor(e,
|
|
179
|
+
return new pe();
|
|
180
|
+
}, L = (n) => n.map((e) => qe(e));
|
|
181
|
+
class Be {
|
|
182
|
+
constructor(e, t, r = Ee) {
|
|
182
183
|
y(this, "_segments");
|
|
183
184
|
y(this, "_description");
|
|
184
185
|
// Used by `Help` command, etc.
|
|
185
186
|
y(this, "_handler");
|
|
186
|
-
this._segments = e, this._description =
|
|
187
|
+
this._segments = e, this._description = t, this._handler = r;
|
|
187
188
|
}
|
|
188
189
|
get segments() {
|
|
189
190
|
return this._segments;
|
|
@@ -207,7 +208,7 @@ class Ue {
|
|
|
207
208
|
return this.fullPath.join(" ") === e.fullPath.join(" ");
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
|
-
class
|
|
211
|
+
class se {
|
|
211
212
|
constructor() {
|
|
212
213
|
y(this, "_commands", []);
|
|
213
214
|
}
|
|
@@ -225,20 +226,20 @@ class ee {
|
|
|
225
226
|
* @param handler Async handler executed when the command is submitted; defaults to `NoopHandler`.
|
|
226
227
|
* @throws {Error} If the segment list is empty or the path collides with an existing command.
|
|
227
228
|
*/
|
|
228
|
-
addCommand(e,
|
|
229
|
+
addCommand(e, t, r = Ee) {
|
|
229
230
|
if (e === void 0 || e.length === 0)
|
|
230
231
|
throw new Error("Command path cannot be empty");
|
|
231
|
-
const
|
|
232
|
-
const c =
|
|
232
|
+
const s = new Be(e, t, r), a = this._commands.find((o) => {
|
|
233
|
+
const c = o.segments.map(
|
|
233
234
|
(d) => d.type === "argument" ? "*" : d.name
|
|
234
235
|
).join(" "), i = e.map(
|
|
235
236
|
(d) => d.type === "argument" ? "*" : d.name
|
|
236
237
|
).join(" ");
|
|
237
238
|
return c === i;
|
|
238
239
|
});
|
|
239
|
-
if (
|
|
240
|
-
throw new Error(`Duplicate commands: '${
|
|
241
|
-
this._commands.push(
|
|
240
|
+
if (a)
|
|
241
|
+
throw new Error(`Duplicate commands: '${a.fullPath_s}' and '${s.fullPath_s}'`);
|
|
242
|
+
this._commands.push(s);
|
|
242
243
|
}
|
|
243
244
|
/**
|
|
244
245
|
* Removes a command that exactly matches the provided path.
|
|
@@ -247,8 +248,8 @@ class ee {
|
|
|
247
248
|
* @returns True if a command was removed; otherwise false.
|
|
248
249
|
*/
|
|
249
250
|
removeCommand(e) {
|
|
250
|
-
const
|
|
251
|
-
return
|
|
251
|
+
const t = e.join(" "), r = this._commands.findIndex((s) => s.fullPath.join(" ") === t);
|
|
252
|
+
return r === -1 ? !1 : (this._commands.splice(r, 1), !0);
|
|
252
253
|
}
|
|
253
254
|
/**
|
|
254
255
|
* Retrieves a command from the registry for the given path.
|
|
@@ -257,26 +258,26 @@ class ee {
|
|
|
257
258
|
* @returns The command node or undefined if not found.
|
|
258
259
|
*/
|
|
259
260
|
getCommand(e) {
|
|
260
|
-
return this._commands.find((
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
261
|
+
return this._commands.find((t) => {
|
|
262
|
+
const r = t.fullPath.join(" "), s = e.join(" ");
|
|
263
|
+
if (r === s)
|
|
263
264
|
return !0;
|
|
264
|
-
const
|
|
265
|
-
return
|
|
265
|
+
const o = t.segments.filter((c) => c.type === "word").map((c) => c.name);
|
|
266
|
+
return o.length === e.length && o.join(" ") === s;
|
|
266
267
|
});
|
|
267
268
|
}
|
|
268
269
|
commandExistsForPath(e) {
|
|
269
|
-
const
|
|
270
|
-
(
|
|
271
|
-
(
|
|
270
|
+
const t = this._commands.map(
|
|
271
|
+
(s) => s.segments.map(
|
|
272
|
+
(a) => a.type === "argument" ? "*" : a.name
|
|
272
273
|
).join(" ")
|
|
273
|
-
),
|
|
274
|
+
), r = e.map((s, a) => this._commands.some(
|
|
274
275
|
(c) => {
|
|
275
276
|
var i;
|
|
276
|
-
return ((i = c.segments[
|
|
277
|
+
return ((i = c.segments[a]) == null ? void 0 : i.type) === "argument";
|
|
277
278
|
}
|
|
278
|
-
) ? "*" :
|
|
279
|
-
return
|
|
279
|
+
) ? "*" : s).join(" ");
|
|
280
|
+
return t.includes(r);
|
|
280
281
|
}
|
|
281
282
|
/**
|
|
282
283
|
* Gets possible matches for a given path.
|
|
@@ -285,26 +286,26 @@ class ee {
|
|
|
285
286
|
* @returns An array of completion strings.
|
|
286
287
|
*/
|
|
287
288
|
getCompletionNames(e) {
|
|
288
|
-
return this.getCompletions(e).map((
|
|
289
|
+
return this.getCompletions(e).map((t) => t.name);
|
|
289
290
|
}
|
|
290
291
|
/**
|
|
291
292
|
* Returns completion segments whose names start with the given prefix.
|
|
292
293
|
* Matching is case-insensitive.
|
|
293
294
|
*/
|
|
294
|
-
getMatchingCompletions(e,
|
|
295
|
-
const
|
|
296
|
-
return
|
|
297
|
-
(
|
|
298
|
-
) :
|
|
295
|
+
getMatchingCompletions(e, t) {
|
|
296
|
+
const r = t.trim().toLowerCase(), s = this.getCompletions(e);
|
|
297
|
+
return r ? s.filter(
|
|
298
|
+
(a) => a.name.toLowerCase().startsWith(r)
|
|
299
|
+
) : s;
|
|
299
300
|
}
|
|
300
301
|
/**
|
|
301
302
|
* Returns a single completion when prefix matching is unambiguous.
|
|
302
303
|
* Returns undefined for ambiguous or no-match prefixes.
|
|
303
304
|
*/
|
|
304
|
-
getUniqueCompletion(e,
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
307
|
-
return
|
|
305
|
+
getUniqueCompletion(e, t) {
|
|
306
|
+
const r = this.getMatchingCompletions(e, t);
|
|
307
|
+
if (r.length === 1)
|
|
308
|
+
return r[0];
|
|
308
309
|
}
|
|
309
310
|
/**
|
|
310
311
|
* Gets an array of segments reachable from a given path
|
|
@@ -313,29 +314,29 @@ class ee {
|
|
|
313
314
|
* @returns An array of completion strings.
|
|
314
315
|
*/
|
|
315
316
|
getCompletions(e) {
|
|
316
|
-
if (
|
|
317
|
-
const
|
|
318
|
-
return
|
|
319
|
-
(i, d,
|
|
317
|
+
if (k.debug("[getCompletions] path: ", e), !e.length) {
|
|
318
|
+
const a = this._commands.map((i) => i.segments[0]), o = (i, d) => i.type === d.type && i.name === d.name;
|
|
319
|
+
return a.filter(
|
|
320
|
+
(i, d, h) => d === h.findIndex((u) => o(u, i))
|
|
320
321
|
);
|
|
321
322
|
}
|
|
322
|
-
const
|
|
323
|
-
return this._commands.filter((
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
323
|
+
const t = e.length;
|
|
324
|
+
return this._commands.filter((a) => {
|
|
325
|
+
const o = a.segments;
|
|
326
|
+
if (o.length <= t - 1)
|
|
326
327
|
return !1;
|
|
327
|
-
for (let c = 0; c <
|
|
328
|
-
const i = e[c], d =
|
|
328
|
+
for (let c = 0; c < t; c++) {
|
|
329
|
+
const i = e[c], d = o[c];
|
|
329
330
|
if (!(i === "*" && d.type === "argument") && i !== d.name)
|
|
330
331
|
return !1;
|
|
331
332
|
}
|
|
332
333
|
return !0;
|
|
333
|
-
}).filter((
|
|
334
|
-
const
|
|
335
|
-
return new c(
|
|
334
|
+
}).filter((a) => a.segments.length > t).map((a) => {
|
|
335
|
+
const o = a.segments[t], c = o.type === "argument" ? q : ke;
|
|
336
|
+
return new c(o.name, o.description);
|
|
336
337
|
}).filter(
|
|
337
|
-
(
|
|
338
|
-
(i) => i.type ===
|
|
338
|
+
(a, o, c) => o === c.findIndex(
|
|
339
|
+
(i) => i.type === a.type && i.name === a.name
|
|
339
340
|
)
|
|
340
341
|
);
|
|
341
342
|
}
|
|
@@ -343,7 +344,7 @@ class ee {
|
|
|
343
344
|
return this.getCompletions(e).length > 0;
|
|
344
345
|
}
|
|
345
346
|
}
|
|
346
|
-
class
|
|
347
|
+
class Ne {
|
|
347
348
|
constructor(e) {
|
|
348
349
|
y(this, "config");
|
|
349
350
|
this.config = {
|
|
@@ -356,88 +357,88 @@ class Se {
|
|
|
356
357
|
* Add a command to history, enforcing storage limits
|
|
357
358
|
*/
|
|
358
359
|
async addStoredCommand(e) {
|
|
359
|
-
const
|
|
360
|
-
for (
|
|
361
|
-
|
|
362
|
-
await this.saveCommands(
|
|
360
|
+
const t = await this.getStoredCommands();
|
|
361
|
+
for (t.push(e); t.length > this.config.maxCommands; )
|
|
362
|
+
t.shift();
|
|
363
|
+
await this.saveCommands(t);
|
|
363
364
|
}
|
|
364
365
|
}
|
|
365
|
-
class
|
|
366
|
-
constructor(
|
|
367
|
-
super(
|
|
366
|
+
class Ve extends Ne {
|
|
367
|
+
constructor(t) {
|
|
368
|
+
super(t);
|
|
368
369
|
y(this, "storageKey", "citadel_command_history");
|
|
369
370
|
}
|
|
370
371
|
async getStoredCommands() {
|
|
371
372
|
try {
|
|
372
|
-
const
|
|
373
|
-
return
|
|
374
|
-
commandSegments: Array.isArray(
|
|
375
|
-
timestamp:
|
|
373
|
+
const t = window.localStorage.getItem(this.storageKey);
|
|
374
|
+
return t ? JSON.parse(t).map((s) => ({
|
|
375
|
+
commandSegments: Array.isArray(s.commandSegments) ? L(s.commandSegments) : [],
|
|
376
|
+
timestamp: s.timestamp
|
|
376
377
|
})) : [];
|
|
377
|
-
} catch (
|
|
378
|
-
return console.warn("Failed to load commands from localStorage:",
|
|
378
|
+
} catch (t) {
|
|
379
|
+
return console.warn("Failed to load commands from localStorage:", t), [];
|
|
379
380
|
}
|
|
380
381
|
}
|
|
381
382
|
async clear() {
|
|
382
383
|
try {
|
|
383
384
|
window.localStorage.removeItem(this.storageKey);
|
|
384
|
-
} catch (
|
|
385
|
-
console.warn("Failed to clear localStorage:",
|
|
385
|
+
} catch (t) {
|
|
386
|
+
console.warn("Failed to clear localStorage:", t);
|
|
386
387
|
}
|
|
387
388
|
}
|
|
388
|
-
async saveCommands(
|
|
389
|
+
async saveCommands(t) {
|
|
389
390
|
try {
|
|
390
|
-
const
|
|
391
|
-
commandSegments: Array.isArray(
|
|
392
|
-
type:
|
|
393
|
-
name:
|
|
394
|
-
description:
|
|
395
|
-
...
|
|
391
|
+
const r = t.map((s) => ({
|
|
392
|
+
commandSegments: Array.isArray(s.commandSegments) ? L(s.commandSegments).map((a) => ({
|
|
393
|
+
type: a.type,
|
|
394
|
+
name: a.name,
|
|
395
|
+
description: a.description,
|
|
396
|
+
...a instanceof q ? { value: a.value } : {}
|
|
396
397
|
})) : [],
|
|
397
|
-
timestamp:
|
|
398
|
+
timestamp: s.timestamp
|
|
398
399
|
}));
|
|
399
|
-
window.localStorage.setItem(this.storageKey, JSON.stringify(
|
|
400
|
-
} catch (
|
|
401
|
-
throw console.warn("Failed to save commands to localStorage:",
|
|
400
|
+
window.localStorage.setItem(this.storageKey, JSON.stringify(r));
|
|
401
|
+
} catch (r) {
|
|
402
|
+
throw console.warn("Failed to save commands to localStorage:", r), r;
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
405
|
}
|
|
405
|
-
class
|
|
406
|
-
constructor(
|
|
407
|
-
super(
|
|
406
|
+
class ye extends Ne {
|
|
407
|
+
constructor(t) {
|
|
408
|
+
super(t);
|
|
408
409
|
y(this, "storedCommands", []);
|
|
409
410
|
}
|
|
410
411
|
async getStoredCommands() {
|
|
411
|
-
return this.storedCommands.map((
|
|
412
|
-
commandSegments: Array.isArray(
|
|
413
|
-
timestamp:
|
|
412
|
+
return this.storedCommands.map((t) => ({
|
|
413
|
+
commandSegments: Array.isArray(t.commandSegments) ? L(t.commandSegments) : [],
|
|
414
|
+
timestamp: t.timestamp
|
|
414
415
|
}));
|
|
415
416
|
}
|
|
416
417
|
async clear() {
|
|
417
418
|
this.storedCommands = [];
|
|
418
419
|
}
|
|
419
|
-
async saveCommands(
|
|
420
|
-
this.storedCommands =
|
|
421
|
-
commandSegments: Array.isArray(
|
|
422
|
-
timestamp:
|
|
420
|
+
async saveCommands(t) {
|
|
421
|
+
this.storedCommands = t.map((r) => ({
|
|
422
|
+
commandSegments: Array.isArray(r.commandSegments) ? L(r.commandSegments) : [],
|
|
423
|
+
timestamp: r.timestamp
|
|
423
424
|
}));
|
|
424
425
|
}
|
|
425
426
|
}
|
|
426
|
-
const
|
|
427
|
+
const $ = class $ {
|
|
427
428
|
constructor() {
|
|
428
429
|
y(this, "currentStorage");
|
|
429
430
|
}
|
|
430
431
|
static reset() {
|
|
431
|
-
|
|
432
|
+
$.instance = void 0;
|
|
432
433
|
}
|
|
433
434
|
static getInstance() {
|
|
434
|
-
return
|
|
435
|
+
return $.instance || ($.instance = new $()), $.instance;
|
|
435
436
|
}
|
|
436
437
|
initializeStorage(e) {
|
|
437
438
|
try {
|
|
438
|
-
e.type === "memory" ? this.currentStorage = new
|
|
439
|
-
} catch (
|
|
440
|
-
console.warn("Failed to create storage, falling back to memory storage:",
|
|
439
|
+
e.type === "memory" ? this.currentStorage = new ye(e) : this.currentStorage = new Ve(e);
|
|
440
|
+
} catch (t) {
|
|
441
|
+
console.warn("Failed to create storage, falling back to memory storage:", t), this.currentStorage = new ye(e);
|
|
441
442
|
}
|
|
442
443
|
}
|
|
443
444
|
getStorage() {
|
|
@@ -446,19 +447,19 @@ const j = class j {
|
|
|
446
447
|
return this.currentStorage;
|
|
447
448
|
}
|
|
448
449
|
};
|
|
449
|
-
y(
|
|
450
|
-
let
|
|
451
|
-
class
|
|
450
|
+
y($, "instance");
|
|
451
|
+
let te = $;
|
|
452
|
+
class Ie {
|
|
452
453
|
constructor() {
|
|
453
454
|
y(this, "segments", []);
|
|
454
|
-
y(this, "nullSegment", new
|
|
455
|
+
y(this, "nullSegment", new pe());
|
|
455
456
|
y(this, "observers", []);
|
|
456
457
|
}
|
|
457
458
|
subscribe(e) {
|
|
458
459
|
this.observers.push(e);
|
|
459
460
|
}
|
|
460
461
|
unsubscribe(e) {
|
|
461
|
-
this.observers = this.observers.filter((
|
|
462
|
+
this.observers = this.observers.filter((t) => t !== e);
|
|
462
463
|
}
|
|
463
464
|
notifyObservers() {
|
|
464
465
|
this.observers.forEach((e) => e.update());
|
|
@@ -479,7 +480,7 @@ class xe {
|
|
|
479
480
|
* Pushes an array of segments onto the stack
|
|
480
481
|
*/
|
|
481
482
|
pushAll(e) {
|
|
482
|
-
e.forEach((
|
|
483
|
+
e.forEach((t) => this.push(t));
|
|
483
484
|
}
|
|
484
485
|
/**
|
|
485
486
|
* Removes and returns the top segment from the stack
|
|
@@ -535,36 +536,36 @@ class xe {
|
|
|
535
536
|
return [...this.segments];
|
|
536
537
|
}
|
|
537
538
|
}
|
|
538
|
-
const
|
|
539
|
-
config:
|
|
540
|
-
commands: new
|
|
541
|
-
segmentStack: new
|
|
542
|
-
},
|
|
543
|
-
const [
|
|
544
|
-
...
|
|
545
|
-
...
|
|
539
|
+
const Ge = {
|
|
540
|
+
config: E,
|
|
541
|
+
commands: new se(),
|
|
542
|
+
segmentStack: new Ie()
|
|
543
|
+
}, J = De(Ge), Ye = ({ config: n = E, commandRegistry: e, children: t }) => {
|
|
544
|
+
const [r, s] = K.useState(), [a] = M(() => new Ie()), o = _(() => ({
|
|
545
|
+
...E,
|
|
546
|
+
...n,
|
|
546
547
|
// Ensure nested objects are properly merged
|
|
547
548
|
storage: {
|
|
548
|
-
...
|
|
549
|
-
...
|
|
549
|
+
...E.storage,
|
|
550
|
+
...n.storage
|
|
550
551
|
},
|
|
551
552
|
// Ensure explicit values from config take precedence
|
|
552
|
-
cursorType:
|
|
553
|
-
cursorColor:
|
|
554
|
-
cursorSpeed:
|
|
555
|
-
closeOnEscape:
|
|
556
|
-
showCitadelKey:
|
|
557
|
-
showOnLoad:
|
|
558
|
-
}), [
|
|
553
|
+
cursorType: n.cursorType ?? E.cursorType,
|
|
554
|
+
cursorColor: n.cursorColor ?? E.cursorColor,
|
|
555
|
+
cursorSpeed: n.cursorSpeed ?? E.cursorSpeed,
|
|
556
|
+
closeOnEscape: n.closeOnEscape ?? E.closeOnEscape,
|
|
557
|
+
showCitadelKey: n.showCitadelKey ?? E.showCitadelKey,
|
|
558
|
+
showOnLoad: n.showOnLoad ?? E.showOnLoad
|
|
559
|
+
}), [n]);
|
|
559
560
|
I(() => {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
),
|
|
563
|
-
}, [
|
|
561
|
+
te.getInstance().initializeStorage(
|
|
562
|
+
o.storage ?? E.storage
|
|
563
|
+
), s(te.getInstance().getStorage());
|
|
564
|
+
}, [o.storage]), I(() => {
|
|
564
565
|
if (e) {
|
|
565
|
-
if (
|
|
566
|
+
if (o.includeHelpCommand) {
|
|
566
567
|
if (!e.commandExistsForPath(["help"])) {
|
|
567
|
-
const i =
|
|
568
|
+
const i = We(e);
|
|
568
569
|
e.addCommand(
|
|
569
570
|
[{ type: "word", name: "help" }],
|
|
570
571
|
"Show available commands",
|
|
@@ -575,105 +576,105 @@ const Ke = {
|
|
|
575
576
|
}
|
|
576
577
|
e.removeCommand(["help"]);
|
|
577
578
|
}
|
|
578
|
-
}, [e,
|
|
579
|
-
const c =
|
|
580
|
-
config:
|
|
581
|
-
commands: e || new
|
|
582
|
-
storage:
|
|
583
|
-
segmentStack:
|
|
584
|
-
}), [
|
|
585
|
-
return /* @__PURE__ */ m(
|
|
586
|
-
},
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
579
|
+
}, [e, o.includeHelpCommand]);
|
|
580
|
+
const c = _(() => ({
|
|
581
|
+
config: o,
|
|
582
|
+
commands: e || new se(),
|
|
583
|
+
storage: r,
|
|
584
|
+
segmentStack: a
|
|
585
|
+
}), [o, e, r, a]);
|
|
586
|
+
return /* @__PURE__ */ m(J.Provider, { value: c, children: t });
|
|
587
|
+
}, j = () => {
|
|
588
|
+
const n = re(J);
|
|
589
|
+
if (n === void 0)
|
|
589
590
|
throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
|
|
590
|
-
return
|
|
591
|
-
},
|
|
592
|
-
const
|
|
593
|
-
if (
|
|
591
|
+
return n.config;
|
|
592
|
+
}, oe = () => {
|
|
593
|
+
const n = re(J);
|
|
594
|
+
if (n === void 0)
|
|
594
595
|
throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
|
|
595
|
-
return
|
|
596
|
-
},
|
|
597
|
-
const
|
|
598
|
-
if (
|
|
596
|
+
return n.commands;
|
|
597
|
+
}, Ae = () => {
|
|
598
|
+
const n = re(J);
|
|
599
|
+
if (n === void 0)
|
|
599
600
|
throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
|
|
600
|
-
return
|
|
601
|
-
},
|
|
602
|
-
const
|
|
603
|
-
if (
|
|
601
|
+
return n.storage;
|
|
602
|
+
}, X = () => {
|
|
603
|
+
const n = re(J);
|
|
604
|
+
if (n === void 0)
|
|
604
605
|
throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
|
|
605
|
-
return
|
|
606
|
-
},
|
|
607
|
-
constructor(e,
|
|
606
|
+
return n.segmentStack;
|
|
607
|
+
}, ne = class ne {
|
|
608
|
+
constructor(e, t) {
|
|
608
609
|
y(this, "id");
|
|
609
610
|
y(this, "timestamp");
|
|
610
611
|
y(this, "command");
|
|
611
612
|
y(this, "result");
|
|
612
|
-
this.id = `output-${Date.now()}-${
|
|
613
|
+
this.id = `output-${Date.now()}-${ne.idCounter++}`, this.command = e.toArray().map((r) => r.type === "argument" ? r.value || "" : r.name), this.timestamp = Date.now(), this.result = t ?? new je();
|
|
613
614
|
}
|
|
614
615
|
};
|
|
615
|
-
y(
|
|
616
|
-
let
|
|
617
|
-
function
|
|
616
|
+
y(ne, "idCounter", 0);
|
|
617
|
+
let de = ne;
|
|
618
|
+
function Je(n) {
|
|
618
619
|
return {
|
|
619
|
-
commandSegments:
|
|
620
|
+
commandSegments: L(n),
|
|
620
621
|
timestamp: Date.now()
|
|
621
622
|
};
|
|
622
623
|
}
|
|
623
|
-
function
|
|
624
|
-
const
|
|
624
|
+
function Pe() {
|
|
625
|
+
const n = Ae(), [e, t] = M({
|
|
625
626
|
storedCommands: [],
|
|
626
627
|
position: null
|
|
627
|
-
}),
|
|
628
|
-
if (
|
|
628
|
+
}), r = f(async (c) => {
|
|
629
|
+
if (n)
|
|
629
630
|
try {
|
|
630
|
-
const i =
|
|
631
|
-
await
|
|
631
|
+
const i = Je(c);
|
|
632
|
+
await n.addStoredCommand(i), t((d) => ({
|
|
632
633
|
...d,
|
|
633
634
|
storedCommands: [...d.storedCommands, {
|
|
634
635
|
...i,
|
|
635
|
-
commandSegments:
|
|
636
|
+
commandSegments: L(i.commandSegments)
|
|
636
637
|
}],
|
|
637
638
|
position: null
|
|
638
639
|
}));
|
|
639
640
|
} catch (i) {
|
|
640
641
|
console.warn("Failed to save command to history:", i);
|
|
641
642
|
}
|
|
642
|
-
}, [
|
|
643
|
+
}, [n]), s = f(async () => n ? (await n.getStoredCommands()).map((i) => ({
|
|
643
644
|
...i,
|
|
644
|
-
commandSegments:
|
|
645
|
-
})) : [], [
|
|
645
|
+
commandSegments: L(i.commandSegments)
|
|
646
|
+
})) : [], [n]);
|
|
646
647
|
I(() => {
|
|
647
|
-
if (!
|
|
648
|
+
if (!n) return;
|
|
648
649
|
(async () => {
|
|
649
650
|
try {
|
|
650
|
-
const d = (await
|
|
651
|
-
...
|
|
652
|
-
commandSegments:
|
|
651
|
+
const d = (await n.getStoredCommands()).map((h) => ({
|
|
652
|
+
...h,
|
|
653
|
+
commandSegments: L(h.commandSegments)
|
|
653
654
|
}));
|
|
654
|
-
return
|
|
655
|
-
...
|
|
655
|
+
return t((h) => ({
|
|
656
|
+
...h,
|
|
656
657
|
storedCommands: d
|
|
657
658
|
})), d;
|
|
658
659
|
} catch (i) {
|
|
659
660
|
console.warn("Failed to load command history:", i);
|
|
660
661
|
}
|
|
661
662
|
})();
|
|
662
|
-
}, [
|
|
663
|
-
const
|
|
664
|
-
const i = await
|
|
663
|
+
}, [n]);
|
|
664
|
+
const a = f(async (c) => {
|
|
665
|
+
const i = await s();
|
|
665
666
|
if (i.length === 0)
|
|
666
|
-
return
|
|
667
|
+
return t((u) => ({
|
|
667
668
|
...u,
|
|
668
669
|
storedCommands: [],
|
|
669
670
|
position: null
|
|
670
671
|
})), { segments: null, position: null };
|
|
671
672
|
let d = null;
|
|
672
|
-
if (c === "up" ? e.position === null ? d = i.length - 1 : e.position > 0 ? d = e.position - 1 : d = 0 : e.position === null || e.position >= i.length - 1 ? d = null : d = e.position + 1,
|
|
673
|
+
if (c === "up" ? e.position === null ? d = i.length - 1 : e.position > 0 ? d = e.position - 1 : d = 0 : e.position === null || e.position >= i.length - 1 ? d = null : d = e.position + 1, t((u) => ({
|
|
673
674
|
...u,
|
|
674
|
-
storedCommands: i.map((
|
|
675
|
-
...
|
|
676
|
-
commandSegments:
|
|
675
|
+
storedCommands: i.map((g) => ({
|
|
676
|
+
...g,
|
|
677
|
+
commandSegments: L(g.commandSegments)
|
|
677
678
|
})),
|
|
678
679
|
position: d
|
|
679
680
|
})), d === null)
|
|
@@ -681,198 +682,198 @@ function ke() {
|
|
|
681
682
|
segments: [],
|
|
682
683
|
position: null
|
|
683
684
|
};
|
|
684
|
-
const
|
|
685
|
-
return
|
|
686
|
-
segments:
|
|
685
|
+
const h = i[d];
|
|
686
|
+
return h ? {
|
|
687
|
+
segments: L(h.commandSegments),
|
|
687
688
|
position: d
|
|
688
689
|
} : {
|
|
689
690
|
segments: [],
|
|
690
691
|
position: null
|
|
691
692
|
};
|
|
692
|
-
}, [e.position,
|
|
693
|
+
}, [e.position, s]), o = f(async () => {
|
|
693
694
|
try {
|
|
694
|
-
if (!
|
|
695
|
-
await
|
|
695
|
+
if (!n) return;
|
|
696
|
+
await n.clear(), t({
|
|
696
697
|
storedCommands: [],
|
|
697
698
|
position: null
|
|
698
699
|
});
|
|
699
700
|
} catch (c) {
|
|
700
701
|
console.warn("Failed to clear command history:", c);
|
|
701
702
|
}
|
|
702
|
-
}, [
|
|
703
|
+
}, [n]);
|
|
703
704
|
return {
|
|
704
705
|
history: e,
|
|
705
|
-
addStoredCommand:
|
|
706
|
-
getStoredCommands:
|
|
707
|
-
navigateHistory:
|
|
708
|
-
clear:
|
|
706
|
+
addStoredCommand: r,
|
|
707
|
+
getStoredCommands: s,
|
|
708
|
+
navigateHistory: a,
|
|
709
|
+
clear: o
|
|
709
710
|
};
|
|
710
711
|
}
|
|
711
|
-
const
|
|
712
|
-
const
|
|
712
|
+
const he = () => {
|
|
713
|
+
const n = j(), e = oe(), t = Pe(), r = X(), s = Ae(), [a, o] = M({
|
|
713
714
|
currentInput: "",
|
|
714
715
|
isEnteringArg: !1,
|
|
715
716
|
output: [],
|
|
716
717
|
history: {
|
|
717
718
|
commands: [],
|
|
718
719
|
position: null,
|
|
719
|
-
storage:
|
|
720
|
+
storage: s
|
|
720
721
|
}
|
|
721
722
|
});
|
|
722
723
|
I(() => {
|
|
723
|
-
}, [
|
|
724
|
-
|
|
724
|
+
}, [s]), I(() => {
|
|
725
|
+
o((i) => ({
|
|
725
726
|
...i,
|
|
726
727
|
history: {
|
|
727
|
-
commands:
|
|
728
|
-
position:
|
|
729
|
-
storage:
|
|
728
|
+
commands: t.history.storedCommands,
|
|
729
|
+
position: t.history.position,
|
|
730
|
+
storage: s
|
|
730
731
|
}
|
|
731
732
|
}));
|
|
732
|
-
}, [
|
|
733
|
+
}, [t.history, s]);
|
|
733
734
|
const c = {
|
|
734
735
|
setCurrentInput: f((i) => {
|
|
735
|
-
|
|
736
|
+
k.debug("[CitadelActions] setCurrentInput: ", i), o((d) => ({ ...d, currentInput: i }));
|
|
736
737
|
}, []),
|
|
737
738
|
setIsEnteringArg: f((i) => {
|
|
738
|
-
|
|
739
|
+
k.debug("[CitadelActions] setIsEnteringArg: ", i), o((d) => ({ ...d, isEnteringArg: i }));
|
|
739
740
|
}, []),
|
|
740
741
|
addOutput: f((i) => {
|
|
741
|
-
|
|
742
|
+
k.debug("[CitadelActions]addOutput: ", i), o((d) => ({
|
|
742
743
|
...d,
|
|
743
744
|
output: [...d.output, i]
|
|
744
745
|
}));
|
|
745
746
|
}, []),
|
|
746
747
|
executeCommand: f(async () => {
|
|
747
|
-
const i =
|
|
748
|
+
const i = r.path(), d = e.getCommand(i);
|
|
748
749
|
if (!d) {
|
|
749
750
|
console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", i);
|
|
750
751
|
return;
|
|
751
752
|
}
|
|
752
|
-
const
|
|
753
|
-
|
|
753
|
+
const h = new de(r);
|
|
754
|
+
o((u) => ({
|
|
754
755
|
...u,
|
|
755
|
-
output: [...u.output,
|
|
756
|
+
output: [...u.output, h]
|
|
756
757
|
}));
|
|
757
758
|
try {
|
|
758
|
-
const u = new Promise((
|
|
759
|
+
const u = new Promise((v, b) => {
|
|
759
760
|
setTimeout(() => {
|
|
760
|
-
|
|
761
|
-
},
|
|
762
|
-
}),
|
|
763
|
-
d.handler(
|
|
761
|
+
b(new Error("Request timed out"));
|
|
762
|
+
}, n.commandTimeoutMs);
|
|
763
|
+
}), g = r.arguments.map((v) => v.value || ""), w = await Promise.race([
|
|
764
|
+
d.handler(g),
|
|
764
765
|
u
|
|
765
766
|
]);
|
|
766
|
-
if (!(
|
|
767
|
+
if (!(w instanceof W))
|
|
767
768
|
throw new Error(
|
|
768
769
|
`The ${i.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
769
770
|
For example:
|
|
770
771
|
return new JsonCommandResult({ text: "Hello World" });
|
|
771
772
|
Check the definition of the ${i.join(".")} command and update the return type for its handler.`
|
|
772
773
|
);
|
|
773
|
-
|
|
774
|
-
...
|
|
775
|
-
output:
|
|
776
|
-
(
|
|
774
|
+
w.markSuccess(), o((v) => ({
|
|
775
|
+
...v,
|
|
776
|
+
output: v.output.map(
|
|
777
|
+
(b) => b.id === h.id ? { ...b, result: w } : b
|
|
777
778
|
)
|
|
778
779
|
}));
|
|
779
780
|
} catch (u) {
|
|
780
|
-
const
|
|
781
|
+
const g = new be(
|
|
781
782
|
u instanceof Error ? u.message : "Unknown error"
|
|
782
783
|
);
|
|
783
|
-
|
|
784
|
-
...
|
|
785
|
-
output:
|
|
786
|
-
(
|
|
784
|
+
g.markFailure(), o((w) => ({
|
|
785
|
+
...w,
|
|
786
|
+
output: w.output.map(
|
|
787
|
+
(v) => v.id === h.id ? { ...v, result: g } : v
|
|
787
788
|
)
|
|
788
789
|
}));
|
|
789
790
|
}
|
|
790
|
-
}, [e,
|
|
791
|
+
}, [e, n.commandTimeoutMs, r]),
|
|
791
792
|
clearHistory: f(async () => {
|
|
792
793
|
try {
|
|
793
|
-
await
|
|
794
|
+
await t.clear();
|
|
794
795
|
} catch (i) {
|
|
795
796
|
console.warn("Failed to clear history:", i);
|
|
796
797
|
}
|
|
797
|
-
}, [
|
|
798
|
+
}, [t])
|
|
798
799
|
};
|
|
799
|
-
return { state:
|
|
800
|
-
},
|
|
801
|
-
onOpen:
|
|
800
|
+
return { state: a, actions: c };
|
|
801
|
+
}, Xe = ({
|
|
802
|
+
onOpen: n,
|
|
802
803
|
onClose: e,
|
|
803
|
-
isVisible:
|
|
804
|
-
showCitadelKey:
|
|
805
|
-
closeOnEscape:
|
|
804
|
+
isVisible: t,
|
|
805
|
+
showCitadelKey: r,
|
|
806
|
+
closeOnEscape: s
|
|
806
807
|
}) => {
|
|
807
808
|
I(() => {
|
|
808
|
-
const
|
|
809
|
+
const a = (o) => {
|
|
809
810
|
var c, i;
|
|
810
|
-
!
|
|
811
|
+
!t && o.key === r && !["input", "textarea"].includes(((i = (c = o.target) == null ? void 0 : c.tagName) == null ? void 0 : i.toLowerCase()) || "") && (o.preventDefault(), n()), s && t && o.key === "Escape" && (o.preventDefault(), e());
|
|
811
812
|
};
|
|
812
|
-
return document.addEventListener("keydown",
|
|
813
|
-
}, [
|
|
814
|
-
},
|
|
815
|
-
const { isVisible: e, isClosing:
|
|
813
|
+
return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
|
|
814
|
+
}, [n, e, t, r, s]);
|
|
815
|
+
}, Qe = 200, Ze = (n) => {
|
|
816
|
+
const { isVisible: e, isClosing: t, onAnimationComplete: r } = n, s = _(() => e ? t ? "citadel_slideDown" : "citadel_slideUp" : "", [e, t]);
|
|
816
817
|
return I(() => {
|
|
817
|
-
if (!
|
|
818
|
+
if (!t || !r) return;
|
|
818
819
|
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
819
|
-
|
|
820
|
+
r();
|
|
820
821
|
return;
|
|
821
822
|
}
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
},
|
|
825
|
-
return () => clearTimeout(
|
|
826
|
-
}, [
|
|
827
|
-
animationClass:
|
|
823
|
+
const o = setTimeout(() => {
|
|
824
|
+
r();
|
|
825
|
+
}, Qe);
|
|
826
|
+
return () => clearTimeout(o);
|
|
827
|
+
}, [t, r]), {
|
|
828
|
+
animationClass: s
|
|
828
829
|
};
|
|
829
|
-
},
|
|
830
|
+
}, et = () => /* @__PURE__ */ m(
|
|
830
831
|
"div",
|
|
831
832
|
{
|
|
832
833
|
"data-testid": "spinner",
|
|
833
834
|
className: "citadel-spinner"
|
|
834
835
|
}
|
|
835
|
-
),
|
|
836
|
-
const e =
|
|
836
|
+
), He = (n) => {
|
|
837
|
+
const e = n == null ? void 0 : n.trim();
|
|
837
838
|
return e || void 0;
|
|
838
|
-
},
|
|
839
|
-
const e =
|
|
839
|
+
}, tt = (n) => {
|
|
840
|
+
const e = He(n);
|
|
840
841
|
return e ? { style: { fontSize: e } } : {};
|
|
841
|
-
},
|
|
842
|
-
const
|
|
843
|
-
...
|
|
842
|
+
}, ae = (n, e) => {
|
|
843
|
+
const t = He(n), s = {
|
|
844
|
+
...tt(e).style
|
|
844
845
|
};
|
|
845
|
-
return
|
|
846
|
-
style: Object.keys(
|
|
846
|
+
return t && (s.fontFamily = t), {
|
|
847
|
+
style: Object.keys(s).length > 0 ? s : void 0
|
|
847
848
|
};
|
|
848
|
-
},
|
|
849
|
-
command:
|
|
849
|
+
}, nt = ({
|
|
850
|
+
command: n,
|
|
850
851
|
timestamp: e,
|
|
851
|
-
status:
|
|
852
|
-
fontFamily:
|
|
853
|
-
fontSize:
|
|
852
|
+
status: t,
|
|
853
|
+
fontFamily: r,
|
|
854
|
+
fontSize: s
|
|
854
855
|
}) => {
|
|
855
|
-
const
|
|
856
|
-
() =>
|
|
857
|
-
[
|
|
856
|
+
const a = _(
|
|
857
|
+
() => ae(r, s ?? "0.875rem"),
|
|
858
|
+
[r, s]
|
|
858
859
|
);
|
|
859
860
|
return /* @__PURE__ */ A(
|
|
860
861
|
"div",
|
|
861
862
|
{
|
|
862
863
|
className: "citadel-output-line",
|
|
863
|
-
style:
|
|
864
|
+
style: a.style,
|
|
864
865
|
children: [
|
|
865
866
|
/* @__PURE__ */ A("span", { className: "citadel-output-command", children: [
|
|
866
867
|
"> ",
|
|
867
|
-
|
|
868
|
-
const i =
|
|
868
|
+
n.split(" ").map((o, c) => {
|
|
869
|
+
const i = o.startsWith("<") && o.endsWith(">");
|
|
869
870
|
return /* @__PURE__ */ A(
|
|
870
871
|
"span",
|
|
871
872
|
{
|
|
872
873
|
className: i ? "citadel-output-command-arg" : "citadel-output-command-word",
|
|
873
874
|
children: [
|
|
874
875
|
c > 0 ? " " : "",
|
|
875
|
-
|
|
876
|
+
o
|
|
876
877
|
]
|
|
877
878
|
},
|
|
878
879
|
c
|
|
@@ -881,15 +882,15 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
881
882
|
] }),
|
|
882
883
|
/* @__PURE__ */ m("span", { className: "citadel-output-separator", children: "·" }),
|
|
883
884
|
/* @__PURE__ */ m("span", { className: "citadel-output-timestamp", children: e }),
|
|
884
|
-
|
|
885
|
-
|
|
885
|
+
t === Y.Pending && /* @__PURE__ */ m(et, {}),
|
|
886
|
+
t === Y.Success && /* @__PURE__ */ m(
|
|
886
887
|
"div",
|
|
887
888
|
{
|
|
888
889
|
"data-testid": "success-indicator",
|
|
889
890
|
className: "citadel-status-dot citadel-status-dot-success"
|
|
890
891
|
}
|
|
891
892
|
),
|
|
892
|
-
(
|
|
893
|
+
(t === Y.Timeout || t === Y.Failure) && /* @__PURE__ */ m(
|
|
893
894
|
"div",
|
|
894
895
|
{
|
|
895
896
|
"data-testid": "success-indicator",
|
|
@@ -899,53 +900,53 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
899
900
|
]
|
|
900
901
|
}
|
|
901
902
|
);
|
|
902
|
-
},
|
|
903
|
-
const
|
|
904
|
-
() =>
|
|
905
|
-
[
|
|
906
|
-
),
|
|
903
|
+
}, rt = ({ output: n, outputRef: e }) => {
|
|
904
|
+
const t = j(), r = _(
|
|
905
|
+
() => ae(t.fontFamily, t.outputFontSize ?? t.fontSize),
|
|
906
|
+
[t.fontFamily, t.fontSize, t.outputFontSize]
|
|
907
|
+
), s = f(() => {
|
|
907
908
|
if (e.current) {
|
|
908
|
-
const
|
|
909
|
+
const a = e.current;
|
|
909
910
|
requestAnimationFrame(() => {
|
|
910
|
-
|
|
911
|
+
a.scrollTop = a.scrollHeight;
|
|
911
912
|
});
|
|
912
913
|
}
|
|
913
914
|
}, [e]);
|
|
914
915
|
return I(() => {
|
|
915
|
-
if (
|
|
916
|
-
const
|
|
917
|
-
if (
|
|
918
|
-
return
|
|
916
|
+
if (s(), e.current) {
|
|
917
|
+
const a = e.current.getElementsByTagName("img"), o = a[a.length - 1];
|
|
918
|
+
if (o && !o.complete)
|
|
919
|
+
return o.addEventListener("load", s), () => o.removeEventListener("load", s);
|
|
919
920
|
}
|
|
920
|
-
}, [
|
|
921
|
+
}, [n, s, e]), /* @__PURE__ */ m(
|
|
921
922
|
"div",
|
|
922
923
|
{
|
|
923
924
|
ref: e,
|
|
924
925
|
className: "citadel-output",
|
|
925
926
|
"data-testid": "citadel-command-output",
|
|
926
|
-
children:
|
|
927
|
+
children: n.map((a) => /* @__PURE__ */ A("div", { className: "citadel-output-item", children: [
|
|
927
928
|
/* @__PURE__ */ m(
|
|
928
|
-
|
|
929
|
+
nt,
|
|
929
930
|
{
|
|
930
|
-
command:
|
|
931
|
-
timestamp: new Date(
|
|
932
|
-
status:
|
|
933
|
-
fontFamily:
|
|
934
|
-
fontSize:
|
|
931
|
+
command: a.command.join(" "),
|
|
932
|
+
timestamp: new Date(a.timestamp).toLocaleTimeString(),
|
|
933
|
+
status: a.result.status,
|
|
934
|
+
fontFamily: t.fontFamily,
|
|
935
|
+
fontSize: t.fontSize
|
|
935
936
|
}
|
|
936
937
|
),
|
|
937
938
|
/* @__PURE__ */ m(
|
|
938
939
|
"div",
|
|
939
940
|
{
|
|
940
941
|
className: "citadel-output-content",
|
|
941
|
-
style:
|
|
942
|
-
children:
|
|
942
|
+
style: r.style,
|
|
943
|
+
children: a.result.render()
|
|
943
944
|
}
|
|
944
945
|
)
|
|
945
|
-
] },
|
|
946
|
+
] }, a.id))
|
|
946
947
|
}
|
|
947
948
|
);
|
|
948
|
-
},
|
|
949
|
+
}, st = {
|
|
949
950
|
blink: {
|
|
950
951
|
character: "▋",
|
|
951
952
|
speed: 530,
|
|
@@ -966,276 +967,276 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
966
967
|
speed: 120,
|
|
967
968
|
color: "#fff"
|
|
968
969
|
}
|
|
969
|
-
},
|
|
970
|
-
style:
|
|
970
|
+
}, we = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], Ce = ["|", "/", "-", "\\"], ot = ({
|
|
971
|
+
style: n = { type: "blink" },
|
|
971
972
|
isValid: e = !0,
|
|
972
|
-
errorMessage:
|
|
973
|
+
errorMessage: t
|
|
973
974
|
}) => {
|
|
974
|
-
const
|
|
975
|
-
...
|
|
976
|
-
...
|
|
977
|
-
}), [
|
|
975
|
+
const r = _(() => ({
|
|
976
|
+
...st[n.type],
|
|
977
|
+
...n
|
|
978
|
+
}), [n]), [s, a] = M(!0), [o, c] = M(0);
|
|
978
979
|
I(() => {
|
|
979
|
-
if (
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
},
|
|
983
|
-
return () => clearInterval(
|
|
984
|
-
}, [
|
|
985
|
-
const i =
|
|
986
|
-
color: e ?
|
|
980
|
+
if (r.speed === 0) return;
|
|
981
|
+
const h = setInterval(() => {
|
|
982
|
+
r.type === "blink" ? a((u) => !u) : ["spin", "bbs"].includes(r.type) && c((u) => (u + 1) % (r.type === "bbs" ? Ce.length : we.length));
|
|
983
|
+
}, r.speed);
|
|
984
|
+
return () => clearInterval(h);
|
|
985
|
+
}, [r.type, r.speed]);
|
|
986
|
+
const i = _(() => ({
|
|
987
|
+
color: e ? r.color : "#ff4444",
|
|
987
988
|
transition: "color 0.15s ease-in-out"
|
|
988
|
-
}), [e,
|
|
989
|
+
}), [e, r.color]);
|
|
989
990
|
return /* @__PURE__ */ m("div", { className: "citadel-cursor-wrapper", children: /* @__PURE__ */ m(
|
|
990
991
|
"span",
|
|
991
992
|
{
|
|
992
993
|
className: `command-cursor ${e ? "" : "animate-shake"}`,
|
|
993
994
|
style: i,
|
|
994
|
-
title:
|
|
995
|
-
children: !e &&
|
|
995
|
+
title: t,
|
|
996
|
+
children: !e && t ? "✗" : ["spin", "bbs"].includes(r.type) ? (r.type === "bbs" ? Ce : we)[o] : r.type === "solid" || s ? r.character : " "
|
|
996
997
|
}
|
|
997
998
|
) });
|
|
998
999
|
};
|
|
999
|
-
function
|
|
1000
|
+
function at(n, e) {
|
|
1000
1001
|
switch (e.type) {
|
|
1001
1002
|
case "set":
|
|
1002
|
-
return
|
|
1003
|
+
return k.debug(`[inputStateReducer] InputState changing from ${n} to ${e.state}`), e.state;
|
|
1003
1004
|
default:
|
|
1004
|
-
return
|
|
1005
|
+
return n;
|
|
1005
1006
|
}
|
|
1006
1007
|
}
|
|
1007
|
-
const
|
|
1008
|
-
const { state:
|
|
1009
|
-
|
|
1008
|
+
const it = () => {
|
|
1009
|
+
const { state: n } = he(), e = oe(), t = Pe(), r = X(), [s, a] = ze(at, "idle"), o = (l) => {
|
|
1010
|
+
a({ type: "set", state: l });
|
|
1010
1011
|
}, c = f(() => {
|
|
1011
|
-
const p = e.getCompletions(
|
|
1012
|
-
return
|
|
1013
|
-
}, [e,
|
|
1012
|
+
const p = e.getCompletions(r.path())[0] || r.nullSegment;
|
|
1013
|
+
return k.debug("[getNextExpectedSegment] ", p), p;
|
|
1014
|
+
}, [e, r]), i = f(() => e.getCompletionNames(r.path()).map((p) => e.getCommand([...r.path(), p])).filter((p) => p !== void 0), [e, r]), d = f((l, p) => {
|
|
1014
1015
|
if (!l) return p;
|
|
1015
|
-
const
|
|
1016
|
+
const C = r.path().length;
|
|
1016
1017
|
return p.filter((D) => {
|
|
1017
|
-
const
|
|
1018
|
-
return !
|
|
1018
|
+
const S = D.segments[C];
|
|
1019
|
+
return !S || S.type !== "word" ? !1 : S.name.toLowerCase().startsWith(l.toLowerCase());
|
|
1019
1020
|
});
|
|
1020
|
-
}, [
|
|
1021
|
-
const p = e.getUniqueCompletion(
|
|
1022
|
-
return p && p.type === "word" ? p :
|
|
1023
|
-
}, [e,
|
|
1024
|
-
const p =
|
|
1025
|
-
return
|
|
1026
|
-
}, [e,
|
|
1027
|
-
|
|
1028
|
-
const p =
|
|
1029
|
-
return !p || p.type === "null" ? new
|
|
1030
|
-
}, [
|
|
1031
|
-
if (
|
|
1021
|
+
}, [r]), h = f((l) => {
|
|
1022
|
+
const p = e.getUniqueCompletion(r.path(), l);
|
|
1023
|
+
return p && p.type === "word" ? p : r.nullSegment;
|
|
1024
|
+
}, [e, r]), u = f((l) => {
|
|
1025
|
+
const p = r.path(), C = e.getCompletions(p);
|
|
1026
|
+
return C.length === 0 && l ? !1 : C.some((S) => S.type === "argument") ? !0 : e.getMatchingCompletions(p, l).some((S) => S.type === "word");
|
|
1027
|
+
}, [e, r]), g = f((l) => {
|
|
1028
|
+
k.debug("[tryAutoComplete] input: ", l);
|
|
1029
|
+
const p = h(l);
|
|
1030
|
+
return !p || p.type === "null" ? new pe() : (k.debug("[tryAutoComplete] result: ", p), p);
|
|
1031
|
+
}, [h]), w = f((l, p) => {
|
|
1032
|
+
if (n.history.position !== null)
|
|
1032
1033
|
return;
|
|
1033
|
-
p.setCurrentInput(l),
|
|
1034
|
-
const
|
|
1035
|
-
if (
|
|
1036
|
-
const
|
|
1037
|
-
if (
|
|
1038
|
-
if (
|
|
1039
|
-
if (!(
|
|
1040
|
-
|
|
1034
|
+
p.setCurrentInput(l), k.debug("[useCommandParser][handleInputChange] newValue: ", l);
|
|
1035
|
+
const C = c();
|
|
1036
|
+
if (C.type === "argument" || s === "entering_argument") {
|
|
1037
|
+
const T = ve(l);
|
|
1038
|
+
if (T.isQuoted)
|
|
1039
|
+
if (T.isComplete) {
|
|
1040
|
+
if (!(C instanceof q)) return;
|
|
1041
|
+
C.value = l.trim() || "", k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", C), r.push(C), p.setCurrentInput(""), o("idle");
|
|
1041
1042
|
return;
|
|
1042
1043
|
} else
|
|
1043
1044
|
return;
|
|
1044
|
-
else if (
|
|
1045
|
-
if (!(
|
|
1046
|
-
|
|
1045
|
+
else if (T.isComplete) {
|
|
1046
|
+
if (!(C instanceof q)) return;
|
|
1047
|
+
C.value = l.trim() || "", k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", C), r.push(C), p.setCurrentInput(""), o("idle");
|
|
1047
1048
|
return;
|
|
1048
1049
|
} else
|
|
1049
1050
|
return;
|
|
1050
1051
|
}
|
|
1051
1052
|
if (l.endsWith(" ")) {
|
|
1052
|
-
const
|
|
1053
|
-
(
|
|
1053
|
+
const T = l.trim().toLowerCase(), U = e.getCompletions(r.path()).filter(
|
|
1054
|
+
(N) => N.type === "word" && N.name.toLowerCase() === T
|
|
1054
1055
|
);
|
|
1055
|
-
if (
|
|
1056
|
-
|
|
1056
|
+
if (U.length === 1) {
|
|
1057
|
+
r.push(U[0]), p.setCurrentInput(""), o("idle");
|
|
1057
1058
|
return;
|
|
1058
1059
|
}
|
|
1059
1060
|
}
|
|
1060
|
-
const
|
|
1061
|
-
if (
|
|
1062
|
-
|
|
1061
|
+
const S = g(l);
|
|
1062
|
+
if (S.type === "word") {
|
|
1063
|
+
k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", S), r.push(S), p.setCurrentInput(""), o("idle");
|
|
1063
1064
|
return;
|
|
1064
1065
|
}
|
|
1065
|
-
}, [
|
|
1066
|
-
l.setCurrentInput(""), l.setIsEnteringArg(!1),
|
|
1067
|
-
}, [
|
|
1066
|
+
}, [g, n, c, s, r, e]), v = f((l) => {
|
|
1067
|
+
l.setCurrentInput(""), l.setIsEnteringArg(!1), r.clear(), o("idle");
|
|
1068
|
+
}, [r]), b = f((l, p, C) => {
|
|
1068
1069
|
if (!(l.key === "Backspace" || l.key === "Enter" || l.key === "ArrowUp" || l.key === "ArrowDown" || l.key === "ArrowLeft" || l.key === "ArrowRight" || l.key === "Escape" || l.key === "Delete" || l.key === "Home" || l.key === "End" || l.key.length === 1))
|
|
1069
1070
|
return !0;
|
|
1070
|
-
const { currentInput:
|
|
1071
|
+
const { currentInput: S, isEnteringArg: T } = p, U = ve(S);
|
|
1071
1072
|
switch (l.key) {
|
|
1072
1073
|
case "Backspace":
|
|
1073
|
-
return
|
|
1074
|
+
return S === "" && (l.preventDefault(), r.size() > 0 && r.pop(), o("idle")), !0;
|
|
1074
1075
|
case "Enter": {
|
|
1075
|
-
if (l.preventDefault(),
|
|
1076
|
+
if (l.preventDefault(), U.isQuoted && !U.isComplete)
|
|
1076
1077
|
return !0;
|
|
1077
|
-
if (
|
|
1078
|
+
if (s === "entering_argument" || T && S.trim()) {
|
|
1078
1079
|
const F = c();
|
|
1079
|
-
F instanceof q && (F.value =
|
|
1080
|
+
F instanceof q && (F.value = S, k.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", F), r.push(F));
|
|
1080
1081
|
}
|
|
1081
|
-
const
|
|
1082
|
-
if (!
|
|
1082
|
+
const N = r.path(), z = e.getCommand(N);
|
|
1083
|
+
if (!z)
|
|
1083
1084
|
return !1;
|
|
1084
|
-
const O =
|
|
1085
|
-
return O.length >
|
|
1085
|
+
const O = z.segments.filter((F) => F.type === "argument"), B = r.arguments;
|
|
1086
|
+
return O.length > B.length ? !1 : (k.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", r), C.executeCommand(), t.addStoredCommand(r.toArray()), v(C), !0);
|
|
1086
1087
|
}
|
|
1087
1088
|
case "ArrowUp":
|
|
1088
1089
|
return l.preventDefault(), (async () => {
|
|
1089
|
-
const
|
|
1090
|
-
return
|
|
1090
|
+
const N = await t.navigateHistory("up");
|
|
1091
|
+
return N.segments && (r.clear(), r.pushAll(N.segments), C.setCurrentInput("")), !0;
|
|
1091
1092
|
})();
|
|
1092
1093
|
case "ArrowDown":
|
|
1093
1094
|
return l.preventDefault(), (async () => {
|
|
1094
|
-
const
|
|
1095
|
-
return
|
|
1095
|
+
const N = await t.navigateHistory("down");
|
|
1096
|
+
return N.segments && (r.clear(), r.pushAll(N.segments), C.setCurrentInput("")), !0;
|
|
1096
1097
|
})();
|
|
1097
1098
|
default: {
|
|
1098
|
-
if (!
|
|
1099
|
-
const
|
|
1100
|
-
if (!u(
|
|
1099
|
+
if (!T && l.key.length === 1) {
|
|
1100
|
+
const N = S + l.key;
|
|
1101
|
+
if (!u(N))
|
|
1101
1102
|
return l.preventDefault(), !1;
|
|
1102
1103
|
}
|
|
1103
1104
|
return !0;
|
|
1104
1105
|
}
|
|
1105
1106
|
}
|
|
1106
1107
|
}, [
|
|
1107
|
-
|
|
1108
|
+
s,
|
|
1108
1109
|
u,
|
|
1109
1110
|
c,
|
|
1110
|
-
|
|
1111
|
-
|
|
1111
|
+
t,
|
|
1112
|
+
v,
|
|
1112
1113
|
e,
|
|
1113
|
-
|
|
1114
|
+
r
|
|
1114
1115
|
]);
|
|
1115
1116
|
return {
|
|
1116
|
-
handleInputChange:
|
|
1117
|
-
handleKeyDown:
|
|
1118
|
-
inputState:
|
|
1119
|
-
setInputStateWithLogging:
|
|
1117
|
+
handleInputChange: w,
|
|
1118
|
+
handleKeyDown: b,
|
|
1119
|
+
inputState: s,
|
|
1120
|
+
setInputStateWithLogging: o,
|
|
1120
1121
|
// Expose internal functions for testing
|
|
1121
1122
|
findMatchingCommands: d,
|
|
1122
|
-
getAutocompleteSuggestion:
|
|
1123
|
+
getAutocompleteSuggestion: h,
|
|
1123
1124
|
getAvailableNodes: i,
|
|
1124
1125
|
getNextExpectedSegment: c,
|
|
1125
1126
|
isValidCommandInput: u
|
|
1126
1127
|
};
|
|
1127
1128
|
};
|
|
1128
|
-
function
|
|
1129
|
+
function ve(n) {
|
|
1129
1130
|
const e = [];
|
|
1130
|
-
let
|
|
1131
|
-
for (let
|
|
1132
|
-
const
|
|
1133
|
-
(
|
|
1131
|
+
let t = "", r = !1, s;
|
|
1132
|
+
for (let a = 0; a < n.length; a++) {
|
|
1133
|
+
const o = n[a];
|
|
1134
|
+
(o === '"' || o === "'") && (!r || o === s) ? r ? (e.push(t), t = "", r = !1, s = void 0) : (t && (e.push(t), t = ""), r = !0, s = o) : !r && o === " " ? t && (e.push(t), t = "") : t += o;
|
|
1134
1135
|
}
|
|
1135
1136
|
return {
|
|
1136
1137
|
words: e,
|
|
1137
|
-
currentWord:
|
|
1138
|
-
isQuoted:
|
|
1139
|
-
quoteChar:
|
|
1140
|
-
isComplete: !
|
|
1138
|
+
currentWord: t,
|
|
1139
|
+
isQuoted: r,
|
|
1140
|
+
quoteChar: s,
|
|
1141
|
+
isComplete: !r && !t
|
|
1141
1142
|
};
|
|
1142
1143
|
}
|
|
1143
|
-
const
|
|
1144
|
-
const
|
|
1144
|
+
const ct = () => {
|
|
1145
|
+
const n = X(), [e, t] = M(0);
|
|
1145
1146
|
return I(() => {
|
|
1146
|
-
const
|
|
1147
|
+
const r = {
|
|
1147
1148
|
update: () => {
|
|
1148
|
-
|
|
1149
|
+
t((s) => s + 1);
|
|
1149
1150
|
}
|
|
1150
1151
|
};
|
|
1151
|
-
return
|
|
1152
|
-
|
|
1152
|
+
return n.subscribe(r), () => {
|
|
1153
|
+
n.unsubscribe(r);
|
|
1153
1154
|
};
|
|
1154
|
-
}, [
|
|
1155
|
-
},
|
|
1156
|
-
state:
|
|
1155
|
+
}, [n]), e;
|
|
1156
|
+
}, lt = ({
|
|
1157
|
+
state: n,
|
|
1157
1158
|
actions: e
|
|
1158
1159
|
}) => {
|
|
1159
|
-
const
|
|
1160
|
-
handleKeyDown:
|
|
1161
|
-
handleInputChange:
|
|
1160
|
+
const t = R(null), r = oe(), s = X(), {
|
|
1161
|
+
handleKeyDown: a,
|
|
1162
|
+
handleInputChange: o,
|
|
1162
1163
|
inputState: c,
|
|
1163
1164
|
setInputStateWithLogging: i,
|
|
1164
1165
|
getNextExpectedSegment: d
|
|
1165
|
-
} =
|
|
1166
|
-
() =>
|
|
1167
|
-
[
|
|
1168
|
-
),
|
|
1169
|
-
const
|
|
1170
|
-
await Promise.resolve(
|
|
1171
|
-
}, [e,
|
|
1172
|
-
|
|
1173
|
-
}, [e,
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
}, [e,
|
|
1166
|
+
} = it(), [h, u] = M(!1), g = j(), w = ct(), v = R(null), [b, l] = M(0), p = _(
|
|
1167
|
+
() => ae(g.fontFamily, g.fontSize),
|
|
1168
|
+
[g.fontFamily, g.fontSize]
|
|
1169
|
+
), C = f(async (x) => {
|
|
1170
|
+
const P = a(x, n, e);
|
|
1171
|
+
await Promise.resolve(P) === !1 && (u(!0), setTimeout(() => u(!1), 500));
|
|
1172
|
+
}, [e, a, n]), D = f((x) => {
|
|
1173
|
+
o(x.target.value, e);
|
|
1174
|
+
}, [e, o]), S = f((x) => {
|
|
1175
|
+
x.preventDefault();
|
|
1176
|
+
const P = x.clipboardData.getData("text");
|
|
1177
|
+
o(P, e);
|
|
1178
|
+
}, [e, o]);
|
|
1178
1179
|
I(() => {
|
|
1179
|
-
|
|
1180
|
+
t.current && t.current.focus(), c !== "entering_command" && i("entering_command");
|
|
1180
1181
|
}, [c, i]), I(() => {
|
|
1181
1182
|
if (c !== "idle") return;
|
|
1182
|
-
const
|
|
1183
|
-
let
|
|
1184
|
-
switch (
|
|
1183
|
+
const x = d();
|
|
1184
|
+
let P = "idle";
|
|
1185
|
+
switch (x.type) {
|
|
1185
1186
|
case "word":
|
|
1186
|
-
|
|
1187
|
+
P = "entering_command", e.setIsEnteringArg(!1);
|
|
1187
1188
|
break;
|
|
1188
1189
|
case "argument":
|
|
1189
|
-
|
|
1190
|
+
P = "entering_argument", e.setIsEnteringArg(!0);
|
|
1190
1191
|
break;
|
|
1191
1192
|
}
|
|
1192
|
-
i(
|
|
1193
|
-
}, [
|
|
1194
|
-
const
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1198
|
-
if (
|
|
1199
|
-
const
|
|
1200
|
-
return /* @__PURE__ */ A(
|
|
1201
|
-
/* @__PURE__ */ m("span", { className: "citadel-input-segment-arg", children:
|
|
1202
|
-
|
|
1203
|
-
] }, "arg-" +
|
|
1193
|
+
i(P);
|
|
1194
|
+
}, [w, c, d, i, e]);
|
|
1195
|
+
const T = _(() => {
|
|
1196
|
+
const x = [], P = s.toArray().map((H, V) => {
|
|
1197
|
+
x.push(H.name);
|
|
1198
|
+
const Q = r.hasNextSegment(x);
|
|
1199
|
+
if (H.type === "argument") {
|
|
1200
|
+
const G = H;
|
|
1201
|
+
return /* @__PURE__ */ A(K.Fragment, { children: [
|
|
1202
|
+
/* @__PURE__ */ m("span", { className: "citadel-input-segment-arg", children: G.value }),
|
|
1203
|
+
V < s.size() && Q && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space", children: " " })
|
|
1204
|
+
] }, "arg-" + G.name + G.value);
|
|
1204
1205
|
}
|
|
1205
|
-
return /* @__PURE__ */ A(
|
|
1206
|
-
/* @__PURE__ */ m("span", { className: "citadel-input-segment-word", children:
|
|
1207
|
-
|
|
1208
|
-
] }, "word-" +
|
|
1206
|
+
return /* @__PURE__ */ A(K.Fragment, { children: [
|
|
1207
|
+
/* @__PURE__ */ m("span", { className: "citadel-input-segment-word", children: H.name }),
|
|
1208
|
+
V < s.size() && Q && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space citadel-input-segment-space-command", children: " " })
|
|
1209
|
+
] }, "word-" + H.name);
|
|
1209
1210
|
});
|
|
1210
|
-
return [/* @__PURE__ */ m("div", { className: "citadel-input-segments", "data-testid": "user-input-area", children:
|
|
1211
|
-
}, [
|
|
1211
|
+
return [/* @__PURE__ */ m("div", { className: "citadel-input-segments", "data-testid": "user-input-area", children: P }, w)];
|
|
1212
|
+
}, [w, r, s]), [U, N] = M("");
|
|
1212
1213
|
I(() => {
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
}, [
|
|
1216
|
-
const O = !
|
|
1214
|
+
const x = d();
|
|
1215
|
+
x.type === "argument" ? N(x.name) : N("");
|
|
1216
|
+
}, [w, d]);
|
|
1217
|
+
const O = !n.isEnteringArg ? "is-command-mode" : "is-argument-mode", B = _(
|
|
1217
1218
|
() => ({
|
|
1218
|
-
left: `${
|
|
1219
|
+
left: `${b}px`,
|
|
1219
1220
|
transition: "left 0.05s ease-out"
|
|
1220
1221
|
}),
|
|
1221
|
-
[
|
|
1222
|
-
), F =
|
|
1222
|
+
[b]
|
|
1223
|
+
), F = _(
|
|
1223
1224
|
() => ({
|
|
1224
|
-
type:
|
|
1225
|
-
color:
|
|
1226
|
-
speed:
|
|
1225
|
+
type: g.cursorType ?? E.cursorType,
|
|
1226
|
+
color: g.cursorColor || E.cursorColor,
|
|
1227
|
+
speed: g.cursorSpeed || E.cursorSpeed
|
|
1227
1228
|
}),
|
|
1228
|
-
[
|
|
1229
|
+
[g.cursorColor, g.cursorSpeed, g.cursorType]
|
|
1229
1230
|
);
|
|
1230
|
-
return
|
|
1231
|
-
const
|
|
1232
|
-
if (!
|
|
1231
|
+
return Fe(() => {
|
|
1232
|
+
const x = v.current, P = t.current;
|
|
1233
|
+
if (!x || !P) {
|
|
1233
1234
|
l(0);
|
|
1234
1235
|
return;
|
|
1235
1236
|
}
|
|
1236
|
-
const
|
|
1237
|
-
l(Math.max(0,
|
|
1238
|
-
}, [
|
|
1237
|
+
const H = x.getBoundingClientRect().width;
|
|
1238
|
+
l(Math.max(0, H - P.scrollLeft));
|
|
1239
|
+
}, [n.currentInput, O, p.style]), /* @__PURE__ */ m("div", { className: "citadel-input-shell", children: /* @__PURE__ */ A(
|
|
1239
1240
|
"div",
|
|
1240
1241
|
{
|
|
1241
1242
|
className: "citadel-input-line",
|
|
@@ -1243,40 +1244,40 @@ const st = () => {
|
|
|
1243
1244
|
children: [
|
|
1244
1245
|
/* @__PURE__ */ m("div", { className: "citadel-input-prompt", children: ">" }),
|
|
1245
1246
|
/* @__PURE__ */ A("div", { className: "citadel-input-row", children: [
|
|
1246
|
-
|
|
1247
|
+
T,
|
|
1247
1248
|
/* @__PURE__ */ A("div", { className: "citadel-input-control", children: [
|
|
1248
1249
|
/* @__PURE__ */ m(
|
|
1249
1250
|
"span",
|
|
1250
1251
|
{
|
|
1251
|
-
ref:
|
|
1252
|
+
ref: v,
|
|
1252
1253
|
className: `citadel-input-measure ${O}`.trim(),
|
|
1253
1254
|
"aria-hidden": "true",
|
|
1254
|
-
children:
|
|
1255
|
+
children: n.currentInput
|
|
1255
1256
|
}
|
|
1256
1257
|
),
|
|
1257
1258
|
/* @__PURE__ */ m(
|
|
1258
1259
|
"input",
|
|
1259
1260
|
{
|
|
1260
|
-
ref:
|
|
1261
|
+
ref: t,
|
|
1261
1262
|
type: "text",
|
|
1262
1263
|
role: "textbox",
|
|
1263
|
-
value:
|
|
1264
|
+
value: n.currentInput,
|
|
1264
1265
|
onChange: D,
|
|
1265
|
-
onKeyDown:
|
|
1266
|
-
onPaste:
|
|
1266
|
+
onKeyDown: C,
|
|
1267
|
+
onPaste: S,
|
|
1267
1268
|
"data-testid": "citadel-command-input",
|
|
1268
|
-
className: `citadel-input-field ${O} ${
|
|
1269
|
+
className: `citadel-input-field ${O} ${h ? "invalid-input-animation" : ""}`.trim(),
|
|
1269
1270
|
spellCheck: !1,
|
|
1270
1271
|
autoComplete: "off",
|
|
1271
|
-
placeholder:
|
|
1272
|
+
placeholder: U
|
|
1272
1273
|
}
|
|
1273
1274
|
),
|
|
1274
1275
|
/* @__PURE__ */ m(
|
|
1275
1276
|
"div",
|
|
1276
1277
|
{
|
|
1277
1278
|
className: "citadel-input-cursor",
|
|
1278
|
-
style:
|
|
1279
|
-
children: /* @__PURE__ */ m(
|
|
1279
|
+
style: B,
|
|
1280
|
+
children: /* @__PURE__ */ m(ot, { style: F })
|
|
1280
1281
|
}
|
|
1281
1282
|
)
|
|
1282
1283
|
] })
|
|
@@ -1284,171 +1285,197 @@ const st = () => {
|
|
|
1284
1285
|
]
|
|
1285
1286
|
}
|
|
1286
1287
|
) });
|
|
1287
|
-
},
|
|
1288
|
-
const e =
|
|
1289
|
-
() =>
|
|
1290
|
-
[
|
|
1291
|
-
),
|
|
1292
|
-
|
|
1293
|
-
|
|
1288
|
+
}, dt = ({ currentInput: n = "" }) => {
|
|
1289
|
+
const e = oe(), t = j(), r = X(), s = K.useMemo(
|
|
1290
|
+
() => ae(t.fontFamily, t.fontSize),
|
|
1291
|
+
[t.fontFamily, t.fontSize]
|
|
1292
|
+
), a = n.trim().toLowerCase(), o = e.getMatchingCompletions(
|
|
1293
|
+
r.path(),
|
|
1294
|
+
a
|
|
1294
1295
|
);
|
|
1295
|
-
|
|
1296
|
-
const c =
|
|
1297
|
-
const u = [...
|
|
1298
|
-
return [...u.filter((l) => !
|
|
1296
|
+
k.debug("[AvailableCommands] nextCommandSegments: ", o);
|
|
1297
|
+
const c = K.useMemo(() => {
|
|
1298
|
+
const u = [...o], g = (l) => l.name.toLowerCase() === "help", w = u.filter(g);
|
|
1299
|
+
return [...u.filter((l) => !g(l)).sort(
|
|
1299
1300
|
(l, p) => l.name.localeCompare(p.name, void 0, { sensitivity: "base" })
|
|
1300
|
-
), ...
|
|
1301
|
-
}, [
|
|
1301
|
+
), ...w];
|
|
1302
|
+
}, [o]), i = K.useMemo(() => {
|
|
1302
1303
|
const u = /* @__PURE__ */ new Map();
|
|
1303
|
-
for (const
|
|
1304
|
-
const
|
|
1305
|
-
if (
|
|
1304
|
+
for (const g of c) {
|
|
1305
|
+
const w = c.reduce((v, b) => {
|
|
1306
|
+
if (b === g) return v;
|
|
1306
1307
|
let l = 0;
|
|
1307
|
-
for (; l <
|
|
1308
|
+
for (; l < g.name.length && l < b.name.length && g.name[l].toLowerCase() === b.name[l].toLowerCase(); )
|
|
1308
1309
|
l++;
|
|
1309
|
-
return Math.max(
|
|
1310
|
+
return Math.max(v, l + 1);
|
|
1310
1311
|
}, 1);
|
|
1311
|
-
u.set(
|
|
1312
|
+
u.set(g.name, w);
|
|
1312
1313
|
}
|
|
1313
1314
|
return u;
|
|
1314
|
-
}, [c]), d =
|
|
1315
|
-
return /* @__PURE__ */ m("div", { className: "citadel-available-commands", "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: "citadel-available-commands-content", style:
|
|
1316
|
-
/* @__PURE__ */ m("span", { className: "citadel-available-next-arg", children:
|
|
1317
|
-
|
|
1315
|
+
}, [c]), d = o.some((u) => u.type === "argument"), h = o[0];
|
|
1316
|
+
return /* @__PURE__ */ m("div", { className: "citadel-available-commands", "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: "citadel-available-commands-content", style: s.style, children: d ? o.length > 0 ? /* @__PURE__ */ A(Oe, { children: [
|
|
1317
|
+
/* @__PURE__ */ m("span", { className: "citadel-available-next-arg", children: h.name }),
|
|
1318
|
+
h.description && /* @__PURE__ */ A("span", { className: "citadel-available-next-desc", children: [
|
|
1318
1319
|
"- ",
|
|
1319
|
-
|
|
1320
|
+
h.description
|
|
1320
1321
|
] })
|
|
1321
1322
|
] }) : null : /* @__PURE__ */ m("div", { className: "citadel-available-chip-list", children: c == null ? void 0 : c.map((u) => {
|
|
1322
|
-
const
|
|
1323
|
+
const g = i.get(u.name) ?? 1;
|
|
1323
1324
|
return /* @__PURE__ */ m(
|
|
1324
1325
|
"div",
|
|
1325
1326
|
{
|
|
1326
1327
|
"data-testid": "available-command-chip",
|
|
1327
1328
|
className: "citadel-available-chip",
|
|
1328
1329
|
children: /* @__PURE__ */ A("span", { className: "citadel-available-chip-text", children: [
|
|
1329
|
-
/* @__PURE__ */ m("strong", { className: "citadel-available-chip-prefix", children: u.name.slice(0,
|
|
1330
|
-
u.name.slice(
|
|
1330
|
+
/* @__PURE__ */ m("strong", { className: "citadel-available-chip-prefix", children: u.name.slice(0, g) }),
|
|
1331
|
+
u.name.slice(g)
|
|
1331
1332
|
] })
|
|
1332
1333
|
},
|
|
1333
1334
|
u.name
|
|
1334
1335
|
);
|
|
1335
1336
|
}) }) }) });
|
|
1336
|
-
},
|
|
1337
|
-
state:
|
|
1337
|
+
}, _e = ({
|
|
1338
|
+
state: n,
|
|
1338
1339
|
actions: e,
|
|
1339
|
-
outputRef:
|
|
1340
|
+
outputRef: t
|
|
1340
1341
|
}) => {
|
|
1341
|
-
const r =
|
|
1342
|
-
() =>
|
|
1343
|
-
[
|
|
1342
|
+
const r = j(), s = r.displayMode === "inline", a = r.showOutputPane ?? !0, o = K.useMemo(
|
|
1343
|
+
() => a && s ? { overflow: "hidden" } : void 0,
|
|
1344
|
+
[s, a]
|
|
1344
1345
|
);
|
|
1345
1346
|
return /* @__PURE__ */ A("div", { className: "innerContainer citadel-tty", children: [
|
|
1346
|
-
/* @__PURE__ */ m(
|
|
1347
|
+
a ? /* @__PURE__ */ m(
|
|
1347
1348
|
"div",
|
|
1348
1349
|
{
|
|
1349
1350
|
className: "citadel-tty-output-pane",
|
|
1350
1351
|
"data-testid": "citadel-output-pane",
|
|
1351
1352
|
style: o,
|
|
1352
|
-
children: /* @__PURE__ */ m(
|
|
1353
|
+
children: /* @__PURE__ */ m(rt, { output: n.output, outputRef: t })
|
|
1353
1354
|
}
|
|
1354
|
-
),
|
|
1355
|
+
) : null,
|
|
1355
1356
|
/* @__PURE__ */ A("div", { className: "citadel-tty-input-region", children: [
|
|
1356
|
-
/* @__PURE__ */ m(
|
|
1357
|
-
/* @__PURE__ */ m(
|
|
1357
|
+
/* @__PURE__ */ m(lt, { state: n, actions: e }),
|
|
1358
|
+
/* @__PURE__ */ m(dt, { currentInput: n.isEnteringArg ? "" : n.currentInput })
|
|
1358
1359
|
] })
|
|
1359
1360
|
] });
|
|
1360
|
-
},
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1361
|
+
}, Z = "128px", mt = "200px", ut = "80vh", ie = (n) => {
|
|
1362
|
+
if (!n) return;
|
|
1363
|
+
const e = n.trim();
|
|
1364
|
+
if (e)
|
|
1365
|
+
return /^\d+(\.\d+)?$/.test(e) ? `${e}px` : e;
|
|
1366
|
+
}, Se = (n, e) => {
|
|
1367
|
+
if (!n) return e;
|
|
1368
|
+
const t = n.trim();
|
|
1369
|
+
if (!t) return e;
|
|
1370
|
+
if (t.endsWith("vh")) {
|
|
1371
|
+
const s = Number.parseFloat(t);
|
|
1372
|
+
return Number.isFinite(s) ? window.innerHeight * s / 100 : e;
|
|
1373
|
+
}
|
|
1374
|
+
const r = Number.parseFloat(t);
|
|
1375
|
+
return Number.isFinite(r) ? r : e;
|
|
1376
|
+
}, pt = () => {
|
|
1377
|
+
const n = j(), e = n.showOutputPane ?? !0, t = ie(n.minHeight) ?? mt, r = ie(n.maxHeight) ?? ut, s = e ? t : Z, a = Number.parseFloat(Z), [o, c] = M(() => {
|
|
1378
|
+
const H = ie(n.initialHeight);
|
|
1379
|
+
return e ? H ?? null : Z;
|
|
1380
|
+
}), [i, d] = M(() => n.showOnLoad ?? !1), [h, u] = M(!1), g = R(null), w = R(null), v = R(!1), b = R(0), l = R(0), p = R(null), C = R(o), D = R(e), { state: S, actions: T } = he(), U = f(() => {
|
|
1381
|
+
u(!1), d(!0);
|
|
1382
|
+
}, []), N = f(() => {
|
|
1383
|
+
u(!0);
|
|
1365
1384
|
}, []);
|
|
1366
|
-
|
|
1367
|
-
onOpen:
|
|
1368
|
-
onClose:
|
|
1369
|
-
isVisible:
|
|
1370
|
-
showCitadelKey:
|
|
1371
|
-
closeOnEscape:
|
|
1385
|
+
Xe({
|
|
1386
|
+
onOpen: U,
|
|
1387
|
+
onClose: N,
|
|
1388
|
+
isVisible: i && !h,
|
|
1389
|
+
showCitadelKey: n.showCitadelKey || ".",
|
|
1390
|
+
closeOnEscape: n.closeOnEscape ?? !0
|
|
1372
1391
|
});
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
B
|
|
1392
|
+
const z = f((H) => {
|
|
1393
|
+
if (!v.current) return;
|
|
1394
|
+
const V = H.clientY - b.current, Q = Se(r, window.innerHeight * 80 / 100), G = Se(s, a), ge = Math.min(
|
|
1395
|
+
Math.max(l.current - V, G),
|
|
1396
|
+
Q
|
|
1379
1397
|
);
|
|
1380
|
-
|
|
1381
|
-
}, [
|
|
1382
|
-
|
|
1383
|
-
}, [
|
|
1384
|
-
|
|
1385
|
-
}, [
|
|
1398
|
+
w.current && (w.current.style.height = `${ge}px`, w.current.style.bottom = "0", c(`${ge}px`));
|
|
1399
|
+
}, [a, s, r]), O = f(() => {
|
|
1400
|
+
v.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", z), document.removeEventListener("mouseup", O);
|
|
1401
|
+
}, [z]), B = f((H) => {
|
|
1402
|
+
w.current && (v.current = !0, b.current = H.clientY, l.current = w.current.offsetHeight, document.documentElement.style.userSelect = "none", document.documentElement.style.webkitUserSelect = "none", document.documentElement.style.mozUserSelect = "none", document.documentElement.style.msUserSelect = "none", document.addEventListener("mousemove", z), document.addEventListener("mouseup", O));
|
|
1403
|
+
}, [z, O]);
|
|
1386
1404
|
I(() => () => {
|
|
1387
|
-
document.removeEventListener("mousemove",
|
|
1388
|
-
}, [
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1405
|
+
document.removeEventListener("mousemove", z), document.removeEventListener("mouseup", O);
|
|
1406
|
+
}, [z, O]), I(() => {
|
|
1407
|
+
C.current = o;
|
|
1408
|
+
}, [o]), I(() => {
|
|
1409
|
+
if (!e) {
|
|
1410
|
+
D.current && (p.current = C.current ?? (w.current ? `${w.current.offsetHeight}px` : null)), D.current = !1, c(Z);
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
D.current = !0, p.current && (c(p.current), p.current = null);
|
|
1414
|
+
}, [e]);
|
|
1415
|
+
const F = f(() => {
|
|
1416
|
+
h && (d(!1), u(!1));
|
|
1417
|
+
}, [h]), { animationClass: x } = Ze({
|
|
1418
|
+
isVisible: i,
|
|
1419
|
+
isClosing: h,
|
|
1420
|
+
onAnimationComplete: F
|
|
1421
|
+
}), P = _(
|
|
1396
1422
|
() => ({
|
|
1397
1423
|
...o ? { height: o } : {},
|
|
1398
|
-
|
|
1424
|
+
minHeight: s,
|
|
1425
|
+
maxHeight: r
|
|
1399
1426
|
}),
|
|
1400
|
-
[
|
|
1427
|
+
[s, o, r]
|
|
1401
1428
|
);
|
|
1402
|
-
return
|
|
1429
|
+
return i ? /* @__PURE__ */ A(
|
|
1403
1430
|
"div",
|
|
1404
1431
|
{
|
|
1405
|
-
ref:
|
|
1406
|
-
className: `panelContainer ${
|
|
1407
|
-
style:
|
|
1432
|
+
ref: w,
|
|
1433
|
+
className: `panelContainer ${x}`.trim(),
|
|
1434
|
+
style: P,
|
|
1408
1435
|
children: [
|
|
1409
|
-
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown:
|
|
1436
|
+
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: B }),
|
|
1410
1437
|
/* @__PURE__ */ m(
|
|
1411
|
-
|
|
1438
|
+
_e,
|
|
1412
1439
|
{
|
|
1413
|
-
state:
|
|
1414
|
-
actions:
|
|
1415
|
-
outputRef:
|
|
1440
|
+
state: S,
|
|
1441
|
+
actions: T,
|
|
1442
|
+
outputRef: g
|
|
1416
1443
|
}
|
|
1417
1444
|
)
|
|
1418
1445
|
]
|
|
1419
1446
|
}
|
|
1420
1447
|
) : null;
|
|
1421
|
-
},
|
|
1422
|
-
if (!
|
|
1423
|
-
const e =
|
|
1448
|
+
}, ce = "128px", le = (n) => {
|
|
1449
|
+
if (!n) return;
|
|
1450
|
+
const e = n.trim();
|
|
1424
1451
|
if (e)
|
|
1425
1452
|
return /^\d+(\.\d+)?$/.test(e) ? `${e}px` : e;
|
|
1426
|
-
},
|
|
1427
|
-
const { state:
|
|
1453
|
+
}, ht = () => {
|
|
1454
|
+
const { state: n, actions: e } = he(), t = j(), r = t.showOutputPane ?? !0, s = R(null), a = _(
|
|
1428
1455
|
() => ({
|
|
1429
|
-
height:
|
|
1430
|
-
maxHeight:
|
|
1431
|
-
minHeight:
|
|
1456
|
+
height: r ? le(t.initialHeight) : ce,
|
|
1457
|
+
maxHeight: r ? le(t.maxHeight) : ce,
|
|
1458
|
+
minHeight: r ? le(t.minHeight) : ce
|
|
1432
1459
|
}),
|
|
1433
|
-
[
|
|
1460
|
+
[t.initialHeight, t.maxHeight, t.minHeight, r]
|
|
1434
1461
|
);
|
|
1435
1462
|
return /* @__PURE__ */ m(
|
|
1436
1463
|
"div",
|
|
1437
1464
|
{
|
|
1438
1465
|
className: "inlineContainer",
|
|
1439
1466
|
"data-testid": "citadel-inline-container",
|
|
1440
|
-
style:
|
|
1467
|
+
style: a,
|
|
1441
1468
|
children: /* @__PURE__ */ m(
|
|
1442
|
-
|
|
1469
|
+
_e,
|
|
1443
1470
|
{
|
|
1444
|
-
state:
|
|
1471
|
+
state: n,
|
|
1445
1472
|
actions: e,
|
|
1446
1473
|
outputRef: s
|
|
1447
1474
|
}
|
|
1448
1475
|
)
|
|
1449
1476
|
}
|
|
1450
1477
|
);
|
|
1451
|
-
},
|
|
1478
|
+
}, xe = `:host {
|
|
1452
1479
|
--citadel-bg: oklch(20.8% 0.042 265.8);
|
|
1453
1480
|
--citadel-surface: oklch(27.9% 0.041 260);
|
|
1454
1481
|
--citadel-border: oklch(37.2% 0.044 257.3);
|
|
@@ -1920,76 +1947,76 @@ const st = () => {
|
|
|
1920
1947
|
object-fit: contain;
|
|
1921
1948
|
border-radius: 0.5rem;
|
|
1922
1949
|
}
|
|
1923
|
-
`,
|
|
1924
|
-
config:
|
|
1950
|
+
`, It = ({
|
|
1951
|
+
config: n = E,
|
|
1925
1952
|
commandRegistry: e,
|
|
1926
|
-
containerId:
|
|
1953
|
+
containerId: t = null
|
|
1927
1954
|
}) => {
|
|
1928
|
-
const
|
|
1955
|
+
const r = R(new se()), s = e ?? r.current, a = R(null), o = _(() => ({ width: "100%", height: "100%" }), []), c = n.displayMode ?? E.displayMode ?? "panel";
|
|
1929
1956
|
return I(() => {
|
|
1930
|
-
|
|
1931
|
-
level:
|
|
1957
|
+
k.configure({
|
|
1958
|
+
level: n.logLevel || E.logLevel || me.ERROR,
|
|
1932
1959
|
prefix: "[Citadel]"
|
|
1933
1960
|
});
|
|
1934
|
-
const i = new
|
|
1935
|
-
if (
|
|
1936
|
-
|
|
1961
|
+
const i = new Re(s, n), d = c === "inline" && !t, h = d ? a.current : t ? document.getElementById(t) : document.body;
|
|
1962
|
+
if (h)
|
|
1963
|
+
h.appendChild(i);
|
|
1937
1964
|
else {
|
|
1938
1965
|
if (d) {
|
|
1939
1966
|
console.warn("[Citadel] No host available for inline mode; skipping mount.");
|
|
1940
1967
|
return;
|
|
1941
1968
|
}
|
|
1942
|
-
console.warn(`Container with id "${
|
|
1969
|
+
console.warn(`Container with id "${t}" not found, falling back to body`), document.body.appendChild(i);
|
|
1943
1970
|
}
|
|
1944
1971
|
return () => {
|
|
1945
1972
|
var u;
|
|
1946
1973
|
(u = i.parentElement) == null || u.removeChild(i);
|
|
1947
1974
|
};
|
|
1948
|
-
}, [
|
|
1975
|
+
}, [s, t, n, c]), c === "inline" && !t ? /* @__PURE__ */ m("div", { ref: a, style: o }) : null;
|
|
1949
1976
|
};
|
|
1950
|
-
class
|
|
1951
|
-
constructor(
|
|
1952
|
-
var
|
|
1977
|
+
class Re extends HTMLElement {
|
|
1978
|
+
constructor(t, r) {
|
|
1979
|
+
var a;
|
|
1953
1980
|
super();
|
|
1954
1981
|
y(this, "shadow");
|
|
1955
1982
|
y(this, "root", null);
|
|
1956
1983
|
y(this, "commandRegistry");
|
|
1957
1984
|
y(this, "config");
|
|
1958
|
-
this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry =
|
|
1959
|
-
const
|
|
1960
|
-
this.setAttribute("data-display-mode",
|
|
1985
|
+
this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = t, this.config = r;
|
|
1986
|
+
const s = ((a = this.config) == null ? void 0 : a.displayMode) ?? "panel";
|
|
1987
|
+
this.setAttribute("data-display-mode", s);
|
|
1961
1988
|
}
|
|
1962
1989
|
connectedCallback() {
|
|
1963
1990
|
try {
|
|
1964
|
-
const
|
|
1965
|
-
const
|
|
1966
|
-
return
|
|
1991
|
+
const r = [xe].map((s) => {
|
|
1992
|
+
const a = new CSSStyleSheet();
|
|
1993
|
+
return a.replaceSync(s), a;
|
|
1967
1994
|
});
|
|
1968
|
-
this.shadow.adoptedStyleSheets = [...
|
|
1995
|
+
this.shadow.adoptedStyleSheets = [...r];
|
|
1969
1996
|
} catch {
|
|
1970
|
-
const
|
|
1971
|
-
`),
|
|
1972
|
-
|
|
1997
|
+
const r = [xe].join(`
|
|
1998
|
+
`), s = document.createElement("style");
|
|
1999
|
+
s.textContent = r, this.shadow.appendChild(s);
|
|
1973
2000
|
}
|
|
1974
|
-
const
|
|
1975
|
-
|
|
1976
|
-
/* @__PURE__ */ m(
|
|
2001
|
+
const t = document.createElement("div");
|
|
2002
|
+
t.id = "citadel-root", t.style.width = "100%", t.style.height = "100%", this.shadow.appendChild(t), this.root = Le(t), this.root.render(
|
|
2003
|
+
/* @__PURE__ */ m(Ye, { config: this.config || E, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(gt, {}) })
|
|
1977
2004
|
);
|
|
1978
2005
|
}
|
|
1979
2006
|
disconnectedCallback() {
|
|
1980
|
-
const
|
|
1981
|
-
if (this.root = null, !
|
|
2007
|
+
const t = this.root;
|
|
2008
|
+
if (this.root = null, !t) {
|
|
1982
2009
|
this.shadow.replaceChildren();
|
|
1983
2010
|
return;
|
|
1984
2011
|
}
|
|
1985
2012
|
queueMicrotask(() => {
|
|
1986
|
-
|
|
2013
|
+
t.unmount(), this.shadow.replaceChildren();
|
|
1987
2014
|
});
|
|
1988
2015
|
}
|
|
1989
2016
|
}
|
|
1990
|
-
typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element",
|
|
1991
|
-
const
|
|
1992
|
-
class
|
|
2017
|
+
typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element", Re);
|
|
2018
|
+
const gt = () => (j().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(ht, {}) : /* @__PURE__ */ m(pt, {});
|
|
2019
|
+
class ft {
|
|
1993
2020
|
constructor() {
|
|
1994
2021
|
y(this, "_description");
|
|
1995
2022
|
}
|
|
@@ -2000,13 +2027,13 @@ class lt {
|
|
|
2000
2027
|
return this._description;
|
|
2001
2028
|
}
|
|
2002
2029
|
}
|
|
2003
|
-
class
|
|
2030
|
+
class yt {
|
|
2004
2031
|
constructor(e) {
|
|
2005
2032
|
y(this, "state");
|
|
2006
2033
|
this.state = {
|
|
2007
2034
|
path: e,
|
|
2008
2035
|
description: "",
|
|
2009
|
-
segments:
|
|
2036
|
+
segments: wt(e)
|
|
2010
2037
|
};
|
|
2011
2038
|
}
|
|
2012
2039
|
describe(e) {
|
|
@@ -2015,12 +2042,12 @@ class dt {
|
|
|
2015
2042
|
details(e) {
|
|
2016
2043
|
return this.state.details = e, this;
|
|
2017
2044
|
}
|
|
2018
|
-
arg(e,
|
|
2019
|
-
const
|
|
2020
|
-
return
|
|
2045
|
+
arg(e, t) {
|
|
2046
|
+
const r = new ft();
|
|
2047
|
+
return t == null || t(r), this.state.segments.push({
|
|
2021
2048
|
type: "argument",
|
|
2022
2049
|
name: e,
|
|
2023
|
-
description:
|
|
2050
|
+
description: r.description
|
|
2024
2051
|
}), this;
|
|
2025
2052
|
}
|
|
2026
2053
|
handle(e) {
|
|
@@ -2033,90 +2060,90 @@ class dt {
|
|
|
2033
2060
|
};
|
|
2034
2061
|
}
|
|
2035
2062
|
}
|
|
2036
|
-
function
|
|
2037
|
-
const e =
|
|
2063
|
+
function wt(n) {
|
|
2064
|
+
const e = n.trim();
|
|
2038
2065
|
if (!e)
|
|
2039
2066
|
throw new Error("Command path cannot be empty");
|
|
2040
|
-
const
|
|
2041
|
-
if (
|
|
2042
|
-
throw new Error(`Invalid command path "${
|
|
2043
|
-
if (
|
|
2067
|
+
const t = e.split(".");
|
|
2068
|
+
if (t.some((r) => r.trim() === ""))
|
|
2069
|
+
throw new Error(`Invalid command path "${n}". Empty segments are not allowed.`);
|
|
2070
|
+
if (t.some((r) => r.includes(" ")))
|
|
2044
2071
|
throw new Error(
|
|
2045
|
-
`Invalid command path "${
|
|
2072
|
+
`Invalid command path "${n}". Use dot-delimited words (e.g. "user.show").`
|
|
2046
2073
|
);
|
|
2047
|
-
return
|
|
2074
|
+
return t.map((r) => ({
|
|
2048
2075
|
type: "word",
|
|
2049
|
-
name:
|
|
2076
|
+
name: r
|
|
2050
2077
|
}));
|
|
2051
2078
|
}
|
|
2052
|
-
function
|
|
2053
|
-
return
|
|
2079
|
+
function Ct(n) {
|
|
2080
|
+
return n.flatMap((e) => e.type === "argument" ? [e.name] : []);
|
|
2054
2081
|
}
|
|
2055
|
-
function
|
|
2056
|
-
const e =
|
|
2057
|
-
return async (
|
|
2058
|
-
const
|
|
2082
|
+
function vt(n) {
|
|
2083
|
+
const e = Ct(n.segments);
|
|
2084
|
+
return async (t) => {
|
|
2085
|
+
const r = e.reduce((s, a, o) => (s[a] = t[o], s), {});
|
|
2059
2086
|
return Promise.resolve(
|
|
2060
|
-
|
|
2061
|
-
rawArgs:
|
|
2062
|
-
namedArgs:
|
|
2063
|
-
commandPath:
|
|
2087
|
+
n.handler({
|
|
2088
|
+
rawArgs: t,
|
|
2089
|
+
namedArgs: r,
|
|
2090
|
+
commandPath: n.path
|
|
2064
2091
|
})
|
|
2065
2092
|
);
|
|
2066
2093
|
};
|
|
2067
2094
|
}
|
|
2068
|
-
function
|
|
2069
|
-
return new
|
|
2095
|
+
function At(n) {
|
|
2096
|
+
return new yt(n);
|
|
2070
2097
|
}
|
|
2071
|
-
function
|
|
2072
|
-
|
|
2098
|
+
function St(n, e) {
|
|
2099
|
+
n.addCommand(
|
|
2073
2100
|
e.segments,
|
|
2074
2101
|
e.description,
|
|
2075
|
-
|
|
2102
|
+
vt(e)
|
|
2076
2103
|
);
|
|
2077
2104
|
}
|
|
2078
|
-
function
|
|
2079
|
-
return e.forEach((
|
|
2105
|
+
function xt(n, e) {
|
|
2106
|
+
return e.forEach((t) => St(n, t)), n;
|
|
2080
2107
|
}
|
|
2081
|
-
function
|
|
2082
|
-
const e = new
|
|
2083
|
-
return
|
|
2108
|
+
function Pt(n) {
|
|
2109
|
+
const e = new se();
|
|
2110
|
+
return xt(e, n);
|
|
2084
2111
|
}
|
|
2085
|
-
function
|
|
2086
|
-
return new
|
|
2112
|
+
function Ht(n) {
|
|
2113
|
+
return new ee(n);
|
|
2087
2114
|
}
|
|
2088
|
-
function
|
|
2089
|
-
return new
|
|
2115
|
+
function _t(n, e = "true", t = "false") {
|
|
2116
|
+
return new $e(n, e, t);
|
|
2090
2117
|
}
|
|
2091
|
-
function
|
|
2092
|
-
return new
|
|
2118
|
+
function Rt(n) {
|
|
2119
|
+
return new Ue(n);
|
|
2093
2120
|
}
|
|
2094
|
-
function
|
|
2095
|
-
return new
|
|
2121
|
+
function Tt(n, e = "") {
|
|
2122
|
+
return new Ke(n, e);
|
|
2096
2123
|
}
|
|
2097
|
-
function
|
|
2098
|
-
return new
|
|
2124
|
+
function Mt(n) {
|
|
2125
|
+
return new be(n);
|
|
2099
2126
|
}
|
|
2100
2127
|
export {
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2128
|
+
$e as BooleanCommandResult,
|
|
2129
|
+
It as Citadel,
|
|
2130
|
+
se as CommandRegistry,
|
|
2131
|
+
W as CommandResult,
|
|
2132
|
+
Y as CommandStatus,
|
|
2133
|
+
st as DEFAULT_CURSOR_CONFIGS,
|
|
2134
|
+
be as ErrorCommandResult,
|
|
2135
|
+
Ke as ImageCommandResult,
|
|
2136
|
+
Ue as JsonCommandResult,
|
|
2137
|
+
de as OutputItem,
|
|
2138
|
+
je as PendingCommandResult,
|
|
2139
|
+
ee as TextCommandResult,
|
|
2140
|
+
_t as bool,
|
|
2141
|
+
At as command,
|
|
2142
|
+
Pt as createCommandRegistry,
|
|
2143
|
+
Mt as error,
|
|
2144
|
+
Tt as image,
|
|
2145
|
+
Rt as json,
|
|
2146
|
+
St as registerCommand,
|
|
2147
|
+
xt as registerCommands,
|
|
2148
|
+
Ht as text
|
|
2122
2149
|
};
|